[libvirt] [PATCH v2 1/2] Refactor disk unplugging

Eric Blake eblake at redhat.com
Thu May 6 21:27:14 UTC 2010


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 at siemens.com>
> ---
>  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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list