1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 09:26:03 +00:00

fix: a downloading volume is not put in a new VM or a CD-ROM; slow downloads read as bytes come

A download writes its volume under its final name, so the volume was
offered while half written. #685 kept a copy and an attach away from
it; a new VM and a CD-ROM still took it. The VM create job now claims
the volumes it is made from (a writable one exclusive, a template or a
CD-ROM image shared), and adding a CD-ROM or inserting media holds the
ISO's volume shared and reads the ISO again in that pool under the
claim (iso_location, iso_path_in). Each is refused with the download
named.

A claim's key holds a pool's and a volume's names: longer than 255
characters on PostgreSQL it failed the request; Claim.resource is text.

A pool that belongs to more than one backup target is not stopped while
a backup to any of them runs (it took the first target only).

The download read 1 MiB at a time: on a slow server a cancel and the
progress waited for a whole MiB. It reads what has come (read1).
This commit is contained in:
catborise 2026-11-20 16:37:59 +03:00
parent 1a39bd3480
commit 84d633af08
17 changed files with 484 additions and 378 deletions

View file

@ -1401,21 +1401,33 @@ class wvmInstance(wvmConnect):
raise util.OperationError(gettext_noop("Media of %(dev)s changed in the running VM only: %(err)s"), dev=dev, err=err) from err
raise
def get_iso_path(self, image):
"""The path of the ISO image of that name, in one of the active pools."""
paths = []
def iso_location(self, image):
"""(pool, path) of the ISO image of that name, in one of the active pools."""
found = []
for storage in self.get_storages(only_actives=True):
stg = self.get_storage(storage)
if image in stg.listVolumes():
paths.append(stg.storageVolLookupByName(image).path())
if not paths:
found.append((storage, stg.storageVolLookupByName(image).path()))
if not found:
raise util.OperationError(gettext_noop("ISO image %(image)s was not found"), image=image)
if len(paths) > 1:
if len(found) > 1:
raise util.OperationError(gettext_noop("ISO image %(image)s is in more than one storage pool"), image=image)
return paths[0]
return found[0]
def mount_iso(self, dev, image):
self._set_cdrom_media(dev, self.get_iso_path(image))
def get_iso_path(self, image):
return self.iso_location(image)[1]
def iso_path_in(self, image, pool):
"""The path of the ISO image, which must still be the one of that pool (the one a caller claimed)."""
found, path = self.iso_location(image)
if found != pool:
raise util.OperationError(gettext_noop("ISO image %(image)s is no longer in pool %(pool)s; choose it again"),
image=image, pool=pool)
return path
def mount_iso(self, dev, image, pool=None):
"""Insert the ISO image; pool: the pool it must be in, when the caller claimed its volume there."""
self._set_cdrom_media(dev, self.iso_path_in(image, pool) if pool else self.get_iso_path(image))
def umount_iso(self, dev, image=None):
self._set_cdrom_media(dev, None)