1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-10 20:26:48 +00:00

fix(instances): enabling vCPU hot plug keeps the current vCPU count

Enabling hot plug on a stopped VM wrote every vCPU up to the maximum as
enabled, so a VM with 2 of 4 vCPUs booted with 4. The current vCPUs stay
enabled now; libvirt adds the rest as disabled hotpluggable vCPUs.
This commit is contained in:
catborise 2026-10-10 09:43:02 +03:00
parent 251ddbbec1
commit c1d2e9610d
4 changed files with 29 additions and 3 deletions

View file

@ -278,3 +278,17 @@ class LiveXmlEffectsTestCase(SimpleTestCase):
def test_edits_of_a_paused_vm(self):
self.check(running=True, paused=True)
def test_enabling_vcpu_hotplug_keeps_the_current_vcpus(self):
try:
dom, vm = self.vm(running=False)
vm.resize_cpu("2", "4")
vm.set_vcpu_hotplug(True)
after = self.persistent(dom)
self.assertEqual((after.findtext("vcpu"), first(after, "vcpu/@current")), ("4", "2"))
self.assertEqual(after.xpath("vcpus/vcpu/@enabled"), ["yes", "yes", "no", "no"])
self.assertEqual(after.xpath("vcpus/vcpu/@hotpluggable"), ["no", "yes", "yes", "yes"])
dom.create()
self.assertEqual(dom.vcpusFlags(libvirt.VIR_DOMAIN_AFFECT_LIVE), 2)
finally:
livetest.cleanup(self.conn)