Re: [PATCH 1/7] qemu: Abstract the code for blkio 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:31PM +0800, Osier Yang wrote:
> ---
>  src/qemu/qemu_cgroup.c | 90 ++++++++++++++++++++++++++++----------------------
>  1 file changed, 50 insertions(+), 40 deletions(-)
> 
> diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
> index 9784f31..0c4792e 100644
> --- a/src/qemu/qemu_cgroup.c
> +++ b/src/qemu/qemu_cgroup.c
> @@ -407,6 +407,53 @@ cleanup:
>      return ret;
>  }
>  
> +static int
> +qemuSetupBlkioCgroup(virDomainObjPtr vm)
> +{
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    int rc = -1;
> +    int i;
> +
> +    if (!virCgroupHasController(priv->cgroup,
> +                                VIR_CGROUP_CONTROLLER_BLKIO)) {
> +        if (vm->def->blkio.weight || vm->def->blkio.ndevices) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                           _("Block I/O tuning is not available on this host"));
> +            return -1;
> +        } else {
> +            return 0;
> +        }
> +    }
> +
> +    if (vm->def->blkio.weight != 0) {
> +        rc = virCgroupSetBlkioWeight(priv->cgroup, vm->def->blkio.weight);
> +        if (rc != 0) {
> +            virReportSystemError(-rc,
> +                                 _("Unable to set io weight for domain %s"),
> +                                 vm->def->name);
> +            return -1;
> +        }
> +    }
> +
> +    if (vm->def->blkio.ndevices) {
> +        for (i = 0; i < vm->def->blkio.ndevices; i++) {
> +            virBlkioDeviceWeightPtr dw = &vm->def->blkio.devices[i];
> +            if (!dw->weight)
> +                continue;
> +            rc = virCgroupSetBlkioDeviceWeight(priv->cgroup, dw->path,
> +                                               dw->weight);
> +            if (rc != 0) {
> +                virReportSystemError(-rc,
> +                                     _("Unable to set io device weight "
> +                                       "for domain %s"),
> +                                     vm->def->name);
> +                return -1;
> +            }
> +        }
> +    }
> +
> +    return 0;
> +}
>  

Use 2 blank lines here

>  int qemuInitCgroup(virQEMUDriverPtr driver,
>                     virDomainObjPtr vm,
> @@ -517,7 +564,6 @@ cleanup:
>      return rc;
>  }
>  
> -


Keep 2 blank lines between functions

>  int qemuSetupCgroup(virQEMUDriverPtr driver,
>                      virDomainObjPtr vm,
>                      virBitmapPtr nodemask)
> @@ -609,7 +655,7 @@ int qemuSetupCgroup(virQEMUDriverPtr driver,
>  
>          if (vm->def->tpm &&
>              (qemuSetupTPMCgroup(vm->def,
> -                               vm->def->tpm,
> +                                vm->def->tpm,
>                                  vm) < 0))
>              goto cleanup;
>  
> @@ -619,44 +665,8 @@ int qemuSetupCgroup(virQEMUDriverPtr driver,
>          }
>      }
>  
> -    if (vm->def->blkio.weight != 0) {
> -        if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) {
> -            rc = virCgroupSetBlkioWeight(priv->cgroup, vm->def->blkio.weight);
> -            if (rc != 0) {
> -                virReportSystemError(-rc,
> -                                     _("Unable to set io weight for domain %s"),
> -                                     vm->def->name);
> -                goto cleanup;
> -            }
> -        } else {
> -            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                           _("Block I/O tuning is not available on this host"));
> -            goto cleanup;
> -        }
> -    }
> -
> -    if (vm->def->blkio.ndevices) {
> -        if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_BLKIO)) {
> -            for (i = 0; i < vm->def->blkio.ndevices; i++) {
> -                virBlkioDeviceWeightPtr dw = &vm->def->blkio.devices[i];
> -                if (!dw->weight)
> -                    continue;
> -                rc = virCgroupSetBlkioDeviceWeight(priv->cgroup, dw->path,
> -                                                   dw->weight);
> -                if (rc != 0) {
> -                    virReportSystemError(-rc,
> -                                         _("Unable to set io device weight "
> -                                           "for domain %s"),
> -                                         vm->def->name);
> -                    goto cleanup;
> -                }
> -            }
> -        } else {
> -            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                           _("Block I/O tuning is not available on this host"));
> -            goto cleanup;
> -        }
> -    }
> +    if (qemuSetupBlkioCgroup(vm) < 0)
> +        goto cleanup;
>  
>      if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_MEMORY)) {
>          unsigned long long hard_limit = vm->def->mem.hard_limit;

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]