Signed-off-by: Tang Chen <tangchen(a)cn.fujitsu.com>
---
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