From dfcd164ba97198a69ec3576a2724ca5630d828c9 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 21 Sep 2016 07:57:43 +0200 Subject: [PATCH] qemu: Allow making vcpus hotpluggable with virDomainSetVcpusFlags Implement support for VIR_DOMAIN_VCPU_HOTPLUGGABLE so that users can choose to make vcpus added by the API removable. --- src/qemu/qemu_driver.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 12ddbc0c9a..29a7e3fae5 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4915,7 +4915,8 @@ qemuDomainSetVcpusLive(virQEMUDriverPtr driver, */ static void qemuDomainSetVcpusConfig(virDomainDefPtr def, - unsigned int nvcpus) + unsigned int nvcpus, + bool hotpluggable) { virDomainVcpuDefPtr vcpu; size_t curvcpus = virDomainDefGetVcpus(def); @@ -4936,7 +4937,12 @@ qemuDomainSetVcpusConfig(virDomainDefPtr def, continue; vcpu->online = true; - vcpu->hotpluggable = VIR_TRISTATE_BOOL_NO; + if (hotpluggable) { + vcpu->hotpluggable = VIR_TRISTATE_BOOL_YES; + def->individualvcpus = true; + } else { + vcpu->hotpluggable = VIR_TRISTATE_BOOL_NO; + } if (++curvcpus == nvcpus) break; @@ -4963,7 +4969,8 @@ qemuDomainSetVcpusInternal(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDefPtr def, virDomainDefPtr persistentDef, - unsigned int nvcpus) + unsigned int nvcpus, + bool hotpluggable) { virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); int ret = -1; @@ -4988,7 +4995,7 @@ qemuDomainSetVcpusInternal(virQEMUDriverPtr driver, goto cleanup; if (persistentDef) { - qemuDomainSetVcpusConfig(persistentDef, nvcpus); + qemuDomainSetVcpusConfig(persistentDef, nvcpus, hotpluggable); if (virDomainSaveConfig(cfg->configDir, driver->caps, persistentDef) < 0) goto cleanup; @@ -5011,12 +5018,14 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, virDomainObjPtr vm = NULL; virDomainDefPtr def; virDomainDefPtr persistentDef; + bool hotpluggable = !!(flags & VIR_DOMAIN_VCPU_HOTPLUGGABLE); int ret = -1; virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG | VIR_DOMAIN_VCPU_MAXIMUM | - VIR_DOMAIN_VCPU_GUEST, -1); + VIR_DOMAIN_VCPU_GUEST | + VIR_DOMAIN_VCPU_HOTPLUGGABLE, -1); if (!(vm = qemuDomObjFromDomain(dom))) goto cleanup; @@ -5035,7 +5044,8 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, else if (flags & VIR_DOMAIN_VCPU_MAXIMUM) ret = qemuDomainSetVcpusMax(driver, def, persistentDef, nvcpus); else - ret = qemuDomainSetVcpusInternal(driver, vm, def, persistentDef, nvcpus); + ret = qemuDomainSetVcpusInternal(driver, vm, def, persistentDef, + nvcpus, hotpluggable); endjob: qemuDomainObjEndJob(driver, vm);