diff options
author | 2012-10-17 16:39:31 +0200 | |
---|---|---|
committer | 2012-10-17 19:06:03 -0500 | |
commit | f22cc069e5e492e31b8c9ec9bdb451afde9e02bb (patch) | |
tree | a0a0f13deac63bb63a34143fa80ab5c0ffafc4e2 | |
parent | qemu: Clear async job when p2p migration fails early (diff) | |
download | libvirt-f22cc069e5e492e31b8c9ec9bdb451afde9e02bb.tar.gz libvirt-f22cc069e5e492e31b8c9ec9bdb451afde9e02bb.tar.bz2 libvirt-f22cc069e5e492e31b8c9ec9bdb451afde9e02bb.zip |
qemu: Pin the emulator when only cpuset is specified
According to our recent changes (clarifications), we should be pinning
qemu's emulator processes using the <vcpu> 'cpuset' attribute in case
there is no <emulatorpin> specified. This however doesn't work
entirely as expected and this patch should resolve all the remaining
issues.
-rw-r--r-- | src/qemu/qemu_cgroup.c | 25 | ||||
-rw-r--r-- | src/qemu/qemu_cgroup.h | 4 | ||||
-rw-r--r-- | src/qemu/qemu_driver.c | 3 | ||||
-rw-r--r-- | src/qemu/qemu_process.c | 16 |
4 files changed, 28 insertions, 20 deletions
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 79faf8e16..6580a9598 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -499,7 +499,7 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, for (i = 0; i < nvcpupin; i++) { if (vcpuid == vcpupin[i]->vcpuid) { - return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]); + return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]->cpumask); } } @@ -507,12 +507,12 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, } int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, - virDomainVcpuPinDefPtr vcpupin) + virBitmapPtr cpumask) { int rc = 0; char *new_cpus = NULL; - new_cpus = virBitmapFormat(vcpupin->cpumask); + new_cpus = virBitmapFormat(cpumask); if (!new_cpus) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to convert cpu mask")); @@ -641,6 +641,7 @@ cleanup: int qemuSetupCgroupForEmulator(struct qemud_driver *driver, virDomainObjPtr vm) { + virBitmapPtr cpumask = NULL; virCgroupPtr cgroup = NULL; virCgroupPtr cgroup_emulator = NULL; virDomainDefPtr def = vm->def; @@ -688,12 +689,18 @@ int qemuSetupCgroupForEmulator(struct qemud_driver *driver, } } - if (def->cputune.emulatorpin && - qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) { - rc = qemuSetupCgroupEmulatorPin(cgroup_emulator, - def->cputune.emulatorpin); - if (rc < 0) - goto cleanup; + if (def->cputune.emulatorpin) + cpumask = def->cputune.emulatorpin->cpumask; + else if (def->cpumask) + cpumask = def->cpumask; + + if (cpumask) { + if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET)) { + rc = qemuSetupCgroupEmulatorPin(cgroup_emulator, cpumask); + if (rc < 0) + goto cleanup; + } + cpumask = NULL; /* sanity */ } if (period || quota) { diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h index b7b021189..362080aa2 100644 --- a/src/qemu/qemu_cgroup.h +++ b/src/qemu/qemu_cgroup.h @@ -1,7 +1,7 @@ /* * qemu_cgroup.h: QEMU cgroup management * - * Copyright (C) 2006-2007, 2009-2011 Red Hat, Inc. + * Copyright (C) 2006-2007, 2009-2012 Red Hat, Inc. * Copyright (C) 2006 Daniel P. Berrange * * This library is free software; you can redistribute it and/or @@ -57,7 +57,7 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, virDomainVcpuPinDefPtr *vcpupin, int nvcpupin, int vcpuid); -int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virDomainVcpuPinDefPtr vcpupin); +int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virBitmapPtr cpumask); int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm); int qemuSetupCgroupForEmulator(struct qemud_driver *driver, virDomainObjPtr vm); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 684892452..2987fbf9c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4050,7 +4050,8 @@ qemudDomainPinEmulator(virDomainPtr dom, if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup_dom, 0) == 0) { if (virCgroupForEmulator(cgroup_dom, &cgroup_emulator, 0) == 0) { - if (qemuSetupCgroupEmulatorPin(cgroup_emulator, newVcpuPin[0]) < 0) { + if (qemuSetupCgroupEmulatorPin(cgroup_emulator, + newVcpuPin[0]->cpumask) < 0) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("failed to set cpuset.cpus in cgroup" " for emulator threads")); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f30493877..def638c5b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1974,11 +1974,12 @@ cleanup: return ret; } -/* Set CPU affinities for emulator threads if emulatorpin xml provided. */ +/* Set CPU affinities for emulator threads. */ static int qemuProcessSetEmulatorAffinites(virConnectPtr conn, virDomainObjPtr vm) { + virBitmapPtr cpumask; virDomainDefPtr def = vm->def; virNodeInfo nodeinfo; int ret = -1; @@ -1986,15 +1987,14 @@ qemuProcessSetEmulatorAffinites(virConnectPtr conn, if (virNodeGetInfo(conn, &nodeinfo) != 0) return -1; - if (!def->cputune.emulatorpin) - return 0; - - if (virProcessInfoSetAffinity(vm->pid, - def->cputune.emulatorpin->cpumask) < 0) { + if (def->cputune.emulatorpin) + cpumask = def->cputune.emulatorpin->cpumask; + else if (def->cpumask) + cpumask = def->cpumask; + else goto cleanup; - } - ret = 0; + ret = virProcessInfoSetAffinity(vm->pid, cpumask); cleanup: return ret; } |