]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: add support for offline vcpupin
authorPeter Krempa <pkrempa@redhat.com>
Fri, 12 Feb 2016 13:57:45 +0000 (14:57 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 9 Mar 2016 09:09:16 +0000 (10:09 +0100)
Allow pinning for inactive vcpus. The pinning mask will be automatically
applied as we would apply the default mask in case of a cpu hotplug.

Setting the scheduler settings for a vcpu has the same semantics.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1306556

src/qemu/qemu_domain.c
src/qemu/qemu_driver.c

index 4fcb85cb599e64d642798b84c6b8e72cf5390caf..e859d8ff933ef20a218ea93c3ab53daf1d6a0813 100644 (file)
@@ -1620,7 +1620,8 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
 virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
     .devicesPostParseCallback = qemuDomainDeviceDefPostParse,
     .domainPostParseCallback = qemuDomainDefPostParse,
-    .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG,
+    .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
+                VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN
 };
 
 
index 3b02cdbe17a682c8bb29cb1286310cc0b93f3100..72ed3c096df6e05e38ef3e9664c388743104145f 100644 (file)
@@ -4760,9 +4760,6 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver,
                                      VIR_CGROUP_THREAD_VCPU, vcpu) < 0)
         goto cleanup;
 
-    virBitmapFree(vcpuinfo->cpumask);
-    vcpuinfo->cpumask = NULL;
-
     ret = 0;
 
  cleanup:
@@ -5022,36 +5019,19 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
 
     priv = vm->privateData;
 
-    if (def) {
-        if (!(vcpuinfolive = virDomainDefGetVcpu(def, vcpu))) {
-            virReportError(VIR_ERR_INVALID_ARG,
-                           _("vcpu %d is out of range of live cpu count %d"),
-                           vcpu, virDomainDefGetVcpus(def));
-            goto endjob;
-        }
-
-        if (!vcpuinfolive->online) {
-            virReportError(VIR_ERR_OPERATION_INVALID,
-                           _("setting cpu pinning for inactive vcpu '%d' is not "
-                             "supported"), vcpu);
-            goto endjob;
-        }
+    if (def && !(vcpuinfolive = virDomainDefGetVcpu(def, vcpu))) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("vcpu %d is out of range of live cpu count %d"),
+                       vcpu, virDomainDefGetVcpus(def));
+        goto endjob;
     }
 
-    if (persistentDef) {
-        if (!(vcpuinfopersist = virDomainDefGetVcpu(persistentDef, vcpu))) {
-            virReportError(VIR_ERR_INVALID_ARG,
-                           _("vcpu %d is out of range of persistent cpu count %d"),
-                           vcpu, virDomainDefGetVcpus(persistentDef));
-            goto endjob;
-        }
-
-        if (!vcpuinfopersist->online) {
-            virReportError(VIR_ERR_OPERATION_INVALID,
-                           _("setting cpu pinning for inactive vcpu '%d' is not "
-                             "supported"), vcpu);
-            goto endjob;
-        }
+    if (persistentDef &&
+        !(vcpuinfopersist = virDomainDefGetVcpu(persistentDef, vcpu))) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("vcpu %d is out of range of persistent cpu count %d"),
+                       vcpu, virDomainDefGetVcpus(persistentDef));
+        goto endjob;
     }
 
     if (!(pcpumap = virBitmapNewData(cpumap, maplen)))
@@ -5074,18 +5054,20 @@ qemuDomainPinVcpuFlags(virDomainPtr dom,
             goto endjob;
         }
 
-        /* Configure the corresponding cpuset cgroup before set affinity. */
-        if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
-            if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu,
-                                   false, &cgroup_vcpu) < 0)
-                goto endjob;
-            if (qemuSetupCgroupCpusetCpus(cgroup_vcpu, pcpumap) < 0)
+        if (vcpuinfolive->online) {
+            /* Configure the corresponding cpuset cgroup before set affinity. */
+            if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
+                if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_VCPU, vcpu,
+                                       false, &cgroup_vcpu) < 0)
+                    goto endjob;
+                if (qemuSetupCgroupCpusetCpus(cgroup_vcpu, pcpumap) < 0)
+                    goto endjob;
+            }
+
+            if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), pcpumap) < 0)
                 goto endjob;
         }
 
-        if (virProcessSetAffinity(qemuDomainGetVcpuPid(vm, vcpu), pcpumap) < 0)
-            goto endjob;
-
         virBitmapFree(vcpuinfolive->cpumask);
         vcpuinfolive->cpumask = pcpumaplive;
         pcpumaplive = NULL;