Re: [PATCH v2 1/2] Refactor disk unplugging

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

 



On 05/05/2010 08:52 AM, Wolfgang Mauerer wrote:
> We can reuse some of the code for other purposes.
> 
> Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@xxxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c |   56 ++++++++++++++++++++++++++++++-----------------
>  1 files changed, 36 insertions(+), 20 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 47ae52c..63ca57c 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -7867,6 +7867,36 @@ cleanup:
>  }
>  
>  
> +static inline int qemudFindDisk(virDomainDefPtr def, char *dst)

dst can be const char *.

> +{
> +    int i;
> +
> +    for (i = 0 ; i < def->ndisks ; i++) {
> +        if (STREQ(def->disks[i]->dst, dst)) {
> +            return i;
> +        }
> +    }
> +
> +    return -1;
> +}
> +
> +static inline void qemudShrinkDisks(virDomainDefPtr def, int i)

And i can be unsigned (better yet, size_t).

> +{
> +    if (def->ndisks > 1) {
> +        memmove(def->disks + i,
> +                def->disks + i + 1,
> +                sizeof(*def->disks) *
> +                (def->ndisks - (i + 1)));
> +        def->ndisks--;
> +        if (VIR_REALLOC_N(def->disks, def->ndisks) < 0) {
> +            /* ignore, harmless */
> +        }
> +    } else {
> +        VIR_FREE(def->disks);
> +        def->ndisks = 0;
> +    }
> +}

But since this is just code motion for future use, it looks fine to me.
 ACK, and I went ahead and pushed it with those edits.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
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]