[libvirt] [PATCHv4 3/4] blkiotune: add interface for blkiotune.device_weight

Eric Blake eblake at redhat.com
Tue Nov 15 22:41:03 UTC 2011


On 11/15/2011 12:15 AM, Hu Tao wrote:

> We can filter out 0-weight here:
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b35c83c..5160003 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -10893,6 +10893,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
>      char uuidstr[VIR_UUID_STRING_BUFLEN];
>      const char *type = NULL;
>      int n, allones = 1;
> +    int blkio = 0;

If we go this route, then this should be bool, not int.

>  
>      virCheckFlags(DUMPXML_FLAGS |
>                    VIR_DOMAIN_XML_INTERNAL_STATUS |
> @@ -10930,7 +10931,15 @@ virDomainDefFormatInternal(virDomainDefPtr def,
>                        def->mem.cur_balloon);
>  
>      /* add blkiotune only if there are any */
> -    if (def->blkio.weight || def->blkio.devices) {
> +
> +    if (def->blkio.weight)
> +        blkio = 1;
> +    for (n = 0; n < def->blkio.ndevices; n++) {
> +        if (def->blkio.devices[n].weight)
> +            blkio = 1;

and once you set the flag, you can break to shorten the loop.

> +    }
> +
> +    if (blkio) {
>          virBufferAddLit(buf, "  <blkiotune>\n");
>  
>          if (def->blkio.weight)
> @@ -10938,6 +10947,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
>                                def->blkio.weight);
>  
>          for (n = 0; n < def->blkio.ndevices; n++) {
> +            if (def->blkio.devices[n].weight == 0)
> +                continue;
>              virBufferAddLit(buf, "    <device>\n");
>              virBufferEscapeString(buf, "      <path>%s</path>\n",
>                                    def->blkio.devices[n].path);
> 

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111115/8654c18c/attachment-0001.sig>


More information about the libvir-list mailing list