mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(instances): disk and agent channel changes on paused VMs
attach_disk (new or existing volume, CD-ROM), add_guest_agent and remove_guest_agent acted only when the status was running (1) or shut off (5). On a paused VM they changed neither definition and the request reported success. They now use the same rule as the NIC edits: the running definition while the VM is active, paused included, and the persistent one always. remove_guest_agent reads each definition from its own XML, so a channel present only in the persistent one is removed too. Unit tests check paused, running and stopped VMs (paused fails on the previous code). The live effects test adds attach_disk and add_guest_agent, and now also checks that edits meant for the running VM reach it, which showed that an ejected CD-ROM keeps an empty <source> in the live XML; NIC unplug is left to the guest tests, as these VMs have no OS to acknowledge it.
This commit is contained in:
parent
9931b73b2c
commit
16e1a334d0
3 changed files with 69 additions and 22 deletions
|
|
@ -67,6 +67,7 @@ def domain_xml(name, disk, iso):
|
|||
<serial type='pty'><target port='0'/></serial>
|
||||
<rng model='virtio'><backend model='random'>/dev/urandom</backend></rng>
|
||||
<watchdog model='i6300esb' action='reset'/>
|
||||
<controller type='virtio-serial'/> <!-- add_guest_agent hotplugs a channel -->
|
||||
</devices>
|
||||
</domain>"""
|
||||
|
||||
|
|
@ -142,7 +143,7 @@ EDITS = {
|
|||
),
|
||||
"umount_iso": (
|
||||
lambda vm: vm.umount_iso("sda"),
|
||||
lambda t: not t.xpath("devices/disk[target/@dev='sda']/source"),
|
||||
lambda t: not t.xpath("devices/disk[target/@dev='sda']/source/@file"),
|
||||
["devices/disk[target/@dev='sda']/source"], True, True,
|
||||
),
|
||||
"set_link_state": (
|
||||
|
|
@ -166,6 +167,16 @@ EDITS = {
|
|||
lambda t: not t.xpath("devices/interface"),
|
||||
["devices/interface"], True, True,
|
||||
),
|
||||
"attach_disk": (
|
||||
lambda vm: vm.attach_disk("vdc", livetest.create_volume(vm.wvm, P + "fx-extra"), target_bus="virtio", format_type="qcow2"),
|
||||
lambda t: bool(t.xpath("devices/disk[target/@dev='vdc']")),
|
||||
["devices/disk[target/@dev='vdc']"], True, True,
|
||||
),
|
||||
"add_guest_agent": (
|
||||
lambda vm: vm.add_guest_agent(),
|
||||
lambda t: bool(t.xpath("devices/channel/target[@name='org.qemu.guest_agent.0']")),
|
||||
["devices/channel[target/@name='org.qemu.guest_agent.0']"], True, True,
|
||||
),
|
||||
"edit_disk (cache mode)": (
|
||||
lambda vm: vm.edit_disk("vda", vm.get_disk_devices(config=True)[0]["path"], False, False, "virtio",
|
||||
"keep-serial", "qcow2", "writeback", None, None, None),
|
||||
|
|
@ -246,6 +257,10 @@ class LiveXmlEffectsTestCase(SimpleTestCase):
|
|||
after = self.persistent(dom)
|
||||
self.assertTrue(effect(after), "edit had no effect")
|
||||
self.assertEqual(canonical(after, touched), canonical(before, touched), "unrelated change")
|
||||
# An unplug completes only when the guest acknowledges it; these
|
||||
# VMs have no OS (test_live_guest covers it with a real guest).
|
||||
if running and changes_live and name != "delete_network":
|
||||
self.assertTrue(effect(self.live(dom)), "edit did not reach the running VM")
|
||||
if running and not changes_live:
|
||||
self.assertEqual(
|
||||
canonical(self.live(dom), ["devices/graphics/@port"]),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue