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

fix(migrate): the next start's definition names a copied disk under its new path

A copied disk was found by its target as well as its path: after a bus
change waiting for the next start (vda to sda), the next start's
definition kept the source path, which the destination does not have,
and the VM would not start again there. The path alone finds it, so two
disks of one file can no longer be copied to two places.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
catborise 2026-11-07 22:41:22 +03:00
parent 826eaac813
commit e822e27f5e
2 changed files with 23 additions and 4 deletions

View file

@ -248,10 +248,11 @@ class wvmInstances(wvmConnect):
@staticmethod
def moved_disks(xml, copies):
"""xml with each copied disk's source at its path here; a disk is
found by its target and its source path before the copy."""
found by its source path before the copy, as the next start's
definition may name it with another target (a changed bus)."""
tree = etree.fromstring(xml)
sources = [(source, copy["dest"]) for copy in copies for source in tree.xpath(
"devices/disk[target/@dev=$target]/source[@file=$path]", target=copy["target"], path=copy["path"])]
"devices/disk/source[@file=$path]", path=copy["path"])]
for source, dest in sources:
source.set("file", dest)
return etree.tostring(tree, encoding="unicode")
@ -367,9 +368,12 @@ class wvmInstances(wvmConnect):
"%(target)s (%(path)s): pool %(pool)s of the destination host already has a file %(file)s"),
**disk, pool=name, file=file))
continue
if any(copy["dest"] == f"{directory}/{file}" for copy in copies):
# one file, one copy: the definitions name a disk's copy by its path
other = next((copy for copy in copies if copy["dest"] == f"{directory}/{file}"
or copy["path"] == row["path"]), None)
if other is not None:
problems.append(util.message(gettext_noop("%(target)s (%(path)s): another disk is copied to %(dest)s"),
**disk, dest=f"{directory}/{file}"))
**disk, dest=other["dest"]))
continue
copies.append({"target": row["target"], "path": row["path"], "dest": f"{directory}/{file}",
"pool": pool})