[libvirt] [PATCH v2.1 10/21] qemu: synchronize emulatorpin info to cgroup
Daniel Veillard
veillard at redhat.com
Wed Aug 22 08:12:42 UTC 2012
On Tue, Aug 21, 2012 at 05:18:33PM +0800, Hu Tao wrote:
> From: Tang Chen <tangchen at cn.fujitsu.com>
>
> Introduce qemuSetupCgroupEmulatorPin() function to add emulator
> threads pin info to cpuset cgroup, the same as vcpupin.
>
> Signed-off-by: Tang Chen <tangchen at cn.fujitsu.com>
> Signed-off-by: Hu Tao <hutao at cn.fujitsu.com>
> ---
> src/qemu/qemu_cgroup.c | 51 ++++++++++++++++++++++++++++++++----------------
> src/qemu/qemu_cgroup.h | 1 +
> 2 files changed, 35 insertions(+), 17 deletions(-)
>
> diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> index 37874d3..9bebfd5 100644
> --- a/src/qemu/qemu_cgroup.c
> +++ b/src/qemu/qemu_cgroup.c
> @@ -496,29 +496,40 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
> int nvcpupin,
> int vcpuid)
> {
> - int i, rc = 0;
> - char *new_cpus = NULL;
> + int i;
>
> for (i = 0; i < nvcpupin; i++) {
> if (vcpuid == vcpupin[i]->vcpuid) {
> - new_cpus = virDomainCpuSetFormat(vcpupin[i]->cpumask,
> - VIR_DOMAIN_CPUMASK_LEN);
> - if (!new_cpus) {
> - virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> - _("failed to convert cpu mask"));
> - rc = -1;
> - goto cleanup;
> - }
> - rc = virCgroupSetCpusetCpus(cgroup, new_cpus);
> - if (rc != 0) {
> - virReportSystemError(-rc,
> - "%s",
> - _("Unable to set cpuset.cpus"));
> - goto cleanup;
> - }
> + return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]);
> }
> }
>
> + return -1;
> +}
> +
> +int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup,
> + virDomainVcpuPinDefPtr vcpupin)
> +{
> + int rc = 0;
> + char *new_cpus = NULL;
> +
> + new_cpus = virDomainCpuSetFormat(vcpupin->cpumask,
> + VIR_DOMAIN_CPUMASK_LEN);
> + if (!new_cpus) {
> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> + _("failed to convert cpu mask"));
> + rc = -1;
> + goto cleanup;
> + }
> +
> + rc = virCgroupSetCpusetCpus(cgroup, new_cpus);
> + if (rc < 0) {
> + virReportSystemError(-rc,
> + "%s",
> + _("Unable to set cpuset.cpus"));
> + goto cleanup;
> + }
> +
> cleanup:
> VIR_FREE(new_cpus);
> return rc;
> @@ -636,6 +647,7 @@ int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
> {
> virCgroupPtr cgroup = NULL;
> virCgroupPtr cgroup_emulator = NULL;
> + virDomainDefPtr def = vm->def;
> int rc, i;
>
> if (driver->cgroup == NULL)
> @@ -672,6 +684,11 @@ int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
> }
> }
>
> + if (def->cputune.emulatorpin &&
> + qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET) &&
> + qemuSetupCgroupEmulatorPin(cgroup_emulator, def->cputune.emulatorpin) < 0)
> + goto cleanup;
> +
> virCgroupFree(&cgroup_emulator);
> virCgroupFree(&cgroup);
> return 0;
> diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
> index fa93cdb..04f70a1 100644
> --- a/src/qemu/qemu_cgroup.h
> +++ b/src/qemu/qemu_cgroup.h
> @@ -57,6 +57,7 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
> virDomainVcpuPinDefPtr *vcpupin,
> int nvcpupin,
> int vcpuid);
> +int qemuSetupCgroupEmulatorPin(virCgroupPtr cgroup, virDomainVcpuPinDefPtr vcpupin);
> int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm);
> int qemuSetupCgroupForEmulator(struct qemud_driver *driver,
> virDomainObjPtr vm);
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list