[libvirt] [PATCH] qemu: setvcpus: Properly coldplug vcpus when hotpluggable vcpus are present

When coldplugging vcpus to a VM that already has a few hotpluggable vcpus the code might generate a invalid configuration as non-hotpluggable cpus need to be clustered starting from vcpu 0. This fix forces the added vcpus to be hotpluggable in such case. Fixes a corner case described in: https://bugzilla.redhat.com/show_bug.cgi?id=1370357 --- src/qemu/qemu_driver.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 675a4d0e7..30edb6cde 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4943,9 +4943,20 @@ qemuDomainSetVcpusConfig(virDomainDefPtr def, for (i = 0; i < maxvcpus; i++) { vcpu = virDomainDefGetVcpu(def, i); - if (!vcpu || vcpu->online) + if (!vcpu) continue; + if (vcpu->online) { + /* non-hotpluggable vcpus need to be clustered at the beggining, + * thus we need to force vcpus to be hotpluggable when we find + * vcpus that are hotpluggable and online prior to the ones + * we are going to add */ + if (vcpu->hotpluggable == VIR_TRISTATE_BOOL_YES) + hotpluggable = true; + + continue; + } + vcpu->online = true; if (hotpluggable) { vcpu->hotpluggable = VIR_TRISTATE_BOOL_YES; -- 2.11.0

On Mon, Jan 09, 2017 at 02:32:13PM +0100, Peter Krempa wrote:
When coldplugging vcpus to a VM that already has a few hotpluggable vcpus the code might generate a invalid configuration as
"an invalid" or just "invalid"
non-hotpluggable cpus need to be clustered starting from vcpu 0.
This fix forces the added vcpus to be hotpluggable in such case.
I don't feel like changing the intentions of the user here is wrong, so ACK.
participants (2)
-
Martin Kletzander
-
Peter Krempa