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

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

 



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@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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