mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 08:26:03 +00:00
fix(vrtManager): an ISO put in a host CD-ROM drive is read
A CD-ROM of type block (a host drive) kept its type when an ISO was inserted, and libvirt reads only source/@dev for that type, so the drive stayed empty. Inserting an ISO now makes it a file drive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
1ddc941b2d
commit
f94124c891
2 changed files with 8 additions and 0 deletions
|
|
@ -1139,6 +1139,7 @@ class wvmInstance(wvmConnect):
|
|||
for source in disk.findall("source"):
|
||||
disk.remove(source)
|
||||
if path:
|
||||
disk.set("type", "file") # a host drive (type block) reads source/@dev only
|
||||
disk.insert(1, etree.Element("source", file=path))
|
||||
try:
|
||||
self.instance.updateDeviceFlags(etree.tostring(disk).decode(), affect)
|
||||
|
|
|
|||
|
|
@ -45,6 +45,13 @@ class IsoMediaTestCase(unittest.TestCase):
|
|||
self.updates(inst), [("sdb", "", VIR_DOMAIN_AFFECT_LIVE), ("sdb", "", VIR_DOMAIN_AFFECT_CONFIG)]
|
||||
)
|
||||
|
||||
def test_an_iso_in_a_host_drive_makes_it_a_file_drive(self):
|
||||
inst = vm(active=False)
|
||||
inst._XMLDesc = MagicMock(return_value=DOMAIN.replace("<disk type='file'", "<disk type='block'"))
|
||||
inst._set_cdrom_media("sdb", "/iso/a.iso")
|
||||
disk = etree.fromstring(inst.instance.updateDeviceFlags.call_args.args[0])
|
||||
self.assertEqual((disk.get("type"), disk.find("source").get("file")), ("file", "/iso/a.iso"))
|
||||
|
||||
def test_unknown_cdrom_changes_nothing(self):
|
||||
inst = vm(active=True)
|
||||
with self.assertRaises(libvirtError):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue