Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit f47143f

Browse files
committed
Accomodate no 'driver' field if cloning between disks with different storage types (file vs. block).
1 parent cfda5af commit f47143f

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

virtinst/CloneManager.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -448,25 +448,24 @@ def _change_disk_type(self, org_type, cln_type, idxs, ctx):
448448
for dev_idx in idxs:
449449
disk_type = ctx.xpathEval("/domain/devices/disk[%d]/@type" %
450450
dev_idx)
451-
driv_name = ctx.xpathEval("/domain/devices/disk[%d]/driver/@name" %
452-
dev_idx)
451+
driv_name = ctx.xpathEval("/domain/devices/disk[%d]/driver/@name" % dev_idx)
453452
src = ctx.xpathEval("/domain/devices/disk[%d]/source" % dev_idx)
454453
src_chid_txt = src[0].get_properties().getContent()
455454

456455
# different type
457456
if org_type[type_idx] != cln_type[type_idx]:
458-
# changing from file to disk
459457
if org_type[type_idx] == True:
460-
disk_type[0].setContent("block")
461-
driv_name[0].setContent("phy")
462-
src[0].get_properties().unlinkNode()
463-
src[0].newProp("dev", src_chid_txt)
464-
# changing from disk to file
458+
# changing from file to disk
459+
typ, driv, newprop = ("block", "phy", "dev")
465460
else:
466-
disk_type[0].setContent("file")
467-
driv_name[0].setContent("file")
468-
src[0].get_properties().unlinkNode()
469-
src[0].newProp("file", src_chid_txt)
461+
# changing from disk to file
462+
typ, driv, newprop = ("file", "file", "file")
463+
464+
disk_type[0].setContent(typ)
465+
if driv_name:
466+
driv_name[0].setContent(driv)
467+
src[0].get_properties().unlinkNode()
468+
src[0].newProp(newprop, src_chid_txt)
470469

471470
type_idx += 1
472471

0 commit comments

Comments
 (0)