]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: hotplug: Add validation for coldplug of individual vcpus
authorPeter Krempa <pkrempa@redhat.com>
Fri, 31 Mar 2017 11:13:14 +0000 (13:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 4 Apr 2017 07:17:59 +0000 (09:17 +0200)
Validate that users don't try to disable vcpu 0.

src/qemu/qemu_hotplug.c

index 5488b1dd4d177074d1fb6b90f3a5978980852279..999c8b8049b3cce1318896fc6ea5997b36b16329 100644 (file)
@@ -5875,6 +5875,21 @@ qemuDomainFilterHotplugVcpuEntities(virDomainDefPtr def,
 }
 
 
+static int
+qemuDomainVcpuValidateConfig(virBitmapPtr map,
+                             bool state)
+{
+    /* vcpu 0 can't be disabled */
+    if (!state && virBitmapIsBitSet(map, 0)) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("vCPU '0' must be enabled"));
+        return -1;
+    }
+
+    return 0;
+}
+
+
 int
 qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
                           virDomainObjPtr vm,
@@ -5909,6 +5924,11 @@ qemuDomainSetVcpuInternal(virQEMUDriverPtr driver,
         }
     }
 
+    if (persistentDef) {
+        if (qemuDomainVcpuValidateConfig(map, state) < 0)
+            goto cleanup;
+    }
+
     if (livevcpus &&
         qemuDomainSetVcpusLive(driver, cfg, vm, livevcpus, state) < 0)
         goto cleanup;