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

Re: [libvirt] [PATCH 06/12] Introduce qemuSetupCgroupHypervisorPin and synchronize hypervisorpin info to cgroup.



On Wed, Jul 25, 2012 at 01:24:37PM +0800, tangchen wrote:
> From: Tang Chen <tangchen cn fujitsu com>
> 
> Introduce qemuSetupCgroupHypervisorPin() function to add hypervisor threads
> pin info to cpuset cgroup, the same as vcpupin.
> 
> Signed-off-by: Tang Chen <tangchen cn fujitsu com>
> Signed-off-by: Hu Tao <hutao cn fujitsu com>
> ---
>  src/qemu/qemu_cgroup.c |   36 ++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_cgroup.h |    1 +
>  2 files changed, 37 insertions(+)
> 
> diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> index 30346aa..43f71dc 100644
> --- a/src/qemu/qemu_cgroup.c
> +++ b/src/qemu/qemu_cgroup.c
> @@ -516,6 +516,36 @@ cleanup:
>      return rc;
>  }
>  
> +int qemuSetupCgroupHypervisorPin(virCgroupPtr cgroup, virDomainDefPtr def)
> +{
> +    int rc = 0;
> +    char *new_cpus = NULL;
> +
> +    if (!def->cputune.hypervisorpin)
> +        return 0;
> +
> +    new_cpus = virDomainCpuSetFormat(def->cputune.hypervisorpin->cpumask,
> +                                     VIR_DOMAIN_CPUMASK_LEN);
> +    if (!new_cpus) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("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;
> +}
> +
>  int qemuSetupCgroupForVcpu(struct qemud_driver *driver, virDomainObjPtr vm)
>  {
>      virCgroupPtr cgroup = NULL;
> @@ -625,6 +655,7 @@ int qemuSetupCgroupForHypervisor(struct qemud_driver *driver,
>  {
>      virCgroupPtr cgroup = NULL;
>      virCgroupPtr cgroup_hypervisor = NULL;
> +    virDomainDefPtr def = vm->def;
>      int rc, i;
>  
>      if (driver->cgroup == NULL)
> @@ -661,6 +692,11 @@ int qemuSetupCgroupForHypervisor(struct qemud_driver *driver,
>          }
>      }
>  
> +    if (def->cputune.hypervisorpin &&
> +        qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPUSET) &&
> +        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 62ec953..f321683 100644
> --- a/src/qemu/qemu_cgroup.h
> +++ b/src/qemu/qemu_cgroup.h
> @@ -55,6 +55,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.10.2

ACK.

-- 
Thanks,
Hu Tao


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