Re: [PATCH 4/7] qemu: Abstract code for cpuset controller setting into a helper

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

 



On Fri, May 17, 2013 at 07:59:34PM +0800, Osier Yang wrote:
> ---
>  src/qemu/qemu_cgroup.c | 73 ++++++++++++++++++++++++++++++++------------------
>  1 file changed, 47 insertions(+), 26 deletions(-)
> 
> diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> index 1e8afb1..8f84ef9 100644
> --- a/src/qemu/qemu_cgroup.c
> +++ b/src/qemu/qemu_cgroup.c
> @@ -626,6 +626,51 @@ cleanup:
>      return ret;
>  }
>  
> +static int
> +qemuSetupCpusetCgroup(virDomainObjPtr vm,
> +                      virBitmapPtr nodemask)
> +{
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    char *mask = NULL;
> +    int rc;
> +    int ret = -1;
> +
> +    if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
> +        return 0;
> +
> +    if ((vm->def->numatune.memory.nodemask ||
> +         (vm->def->numatune.memory.placement_mode ==
> +          VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) &&
> +        vm->def->numatune.memory.mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) {
> +
> +        if (vm->def->numatune.memory.placement_mode ==
> +            VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)
> +            mask = virBitmapFormat(nodemask);
> +        else
> +            mask = virBitmapFormat(vm->def->numatune.memory.nodemask);
> +
> +        if (!mask) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                           _("failed to convert memory nodemask"));
> +            goto cleanup;
> +        }
> +
> +        rc = virCgroupSetCpusetMems(priv->cgroup, mask);
> +
> +        if (rc != 0) {
> +            virReportSystemError(-rc,
> +                                 _("Unable to set cpuset.mems for domain %s"),
> +                                 vm->def->name);
> +            goto cleanup;
> +        }
> +    }
> +
> +    ret = 0;
> +cleanup:
> +    VIR_FREE(mask);
> +    return ret;
> +}
> +


Add a 2nd blank line 

>  int qemuInitCgroup(virQEMUDriverPtr driver,
>                     virDomainObjPtr vm,
>                     bool startup)
> @@ -772,32 +817,8 @@ int qemuSetupCgroup(virQEMUDriverPtr driver,
>          }
>      }
>  
> -    if ((vm->def->numatune.memory.nodemask ||
> -         (vm->def->numatune.memory.placement_mode ==
> -          VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)) &&
> -        vm->def->numatune.memory.mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT &&
> -        virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) {
> -        char *mask = NULL;
> -        if (vm->def->numatune.memory.placement_mode ==
> -            VIR_NUMA_TUNE_MEM_PLACEMENT_MODE_AUTO)
> -            mask = virBitmapFormat(nodemask);
> -        else
> -            mask = virBitmapFormat(vm->def->numatune.memory.nodemask);
> -        if (!mask) {
> -            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                           _("failed to convert memory nodemask"));
> -            goto cleanup;
> -        }
> -
> -        rc = virCgroupSetCpusetMems(priv->cgroup, mask);
> -        VIR_FREE(mask);
> -        if (rc != 0) {
> -            virReportSystemError(-rc,
> -                                 _("Unable to set cpuset.mems for domain %s"),
> -                                 vm->def->name);
> -            goto cleanup;
> -        }
> -    }
> +    if (qemuSetupCpusetCgroup(vm, nodemask) < 0)
> +        goto cleanup;
>  
>  done:
>      rc = 0;

ACK with whitespace tweak


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
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]