Re: [RFC PATCH 05/12] qemu: domain: Add helper to lookup disk by node name

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

 



On 02/23/2017 01:21 PM, Peter Krempa wrote:
> Looks up a disk and it's corresponding backing chain element by node
> name.
> ---
>  src/qemu/qemu_domain.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  src/qemu/qemu_domain.h |  6 ++++++
>  2 files changed, 50 insertions(+)
> 

> +virDomainDiskDefPtr
> +qemuDomainDiskLookupByNodename(virDomainDefPtr def,
> +                               const char *nodename,
> +                               virStorageSourcePtr *src,
> +                               unsigned int *idx)
> +{
> +    size_t i;
> +    unsigned int srcindex;
> +    virStorageSourcePtr tmp = NULL;

Sometimes, I find it easier to do:

if (!idx)
    idx = &srcindex;

so that later on...

> +
> +    if (src)
> +        *src = NULL;
> +
> +    if (idx)
> +        *idx = 0;
> +
> +    for (i = 0; i < def->ndisks; i++) {
> +        if ((tmp = virStorageSourceFindByNodeName(def->disks[i]->src,
> +                                                  nodename, &srcindex))) {

...I can just pass 'idx' instead of '&srcindex' here...

> +            if (src)
> +                *src = tmp;
> +
> +            if (idx)
> +                *idx = srcindex;

...and completely skip this conditional.  But not a show-stopper.

ACK

-- 
Eric Blake   eblake redhat com    +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]
  Powered by Linux