[PATCH 03/10] Add qemuSetupCgroupHypervisorPin and synchronize hypervisorpin info to cgroup.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Tang Chen <tangchen@xxxxxxxxxxxxxx>
---
 src/qemu/qemu_cgroup.c |   41 +++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_cgroup.h |    1 +
 2 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index a123a00..2d8d9ee 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -509,6 +509,39 @@ cleanup:
     return -1;
 }
 
+int qemuSetupCgroupHypervisorPin(virCgroupPtr cgroup, virDomainDefPtr def)
+{
+    int rc;
+    char *new_cpus = NULL;
+
+    if (!def->cputune.hypervisorpin)
+        return 0;
+
+    new_cpus = virDomainCpuSetFormat(def->cputune.hypervisorpin->cpumask,
+                                     VIR_DOMAIN_CPUMASK_LEN);
+    if (!new_cpus) {
+        qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                        _("failed to convert cpu mask"));
+        goto cleanup;
+    }
+
+    rc = virCgroupSetCpusetCpus(cgroup, new_cpus);
+    if (rc < 0) {
+        virReportSystemError(-rc,
+                             _("%s"), _("Unable to set cpuset.cpus"));
+        goto cleanup;
+    }
+
+    VIR_FREE(new_cpus);
+
+    return 0;
+
+cleanup:
+    if (new_cpus)
+        VIR_FREE(new_cpus);
+    return -1;
+}
+
 int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm)
 {
     virCgroupPtr cgroup = NULL;
@@ -625,6 +658,7 @@ int qemuSetupCgroupForHypervisor(struct qemud_driver *driver,
     qemuDomainObjPrivatePtr priv = vm->privateData;
     unsigned long long period = vm->def->cputune.hypervisor_period;
     long long quota = vm->def->cputune.hypervisor_quota;
+    virDomainDefPtr def = vm->def;
     int rc;
 
     if (driver->cgroup == NULL)
@@ -670,6 +704,13 @@ int qemuSetupCgroupForHypervisor(struct qemud_driver *driver,
         }
     }
 
+    if (def->cputune.hypervisorpin) {
+        if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) {
+            if (qemuSetupCgroupHypervisorPin(cgroup_hypervisor, def) < 0)
+                goto cleanup;
+        }
+    }
+
     virCgroupFree(&cgroup_hypervisor);
     virCgroupFree(&cgroup);
     return 0;
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index dbf783a..8664cea 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -54,6 +54,7 @@ int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
                           long long quota);
 int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, virDomainDefPtr def,
                            int vcpuid);
+int qemuSetupCgroupHypervisorPin(virCgroupPtr cgroup, virDomainDefPtr def);
 int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm);
 int qemuSetupCgroupForHypervisor(struct qemud_driver *driver,
                                  virDomainObjPtr vm);
-- 
1.7.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]