qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [Qemu-devel] [PATCH 02/16] introduce a new API to check


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 02/16] introduce a new API to check if blk is attached
Date: Wed, 2 Sep 2015 09:40:22 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

On 09/02/2015 02:51 AM, Wen Congyang wrote:
> Signed-off-by: Wen Congyang <address@hidden>
> ---
>  block.c                        | 4 ++--
>  block/block-backend.c          | 9 +++++++++
>  include/sysemu/block-backend.h | 1 +
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 

>  /*
> + * Return true if a device model is attached to @blk already,
> + * otherwise, return false.
> + */
> +bool blk_is_attached(BlockBackend *blk)
> +{
> +    return blk != NULL && blk->dev != NULL && blk->dev != (void *)-1;

Again, I don't like the raw magic constant, even if we go with this
patch.  And it is shorter to write:

   return blk && blk->dev && blk->dev != MAGIC;

But I think it is better to just allow for a NULL BDS to represent an
unattached media (in which case Max's patches may already cover what you
are trying to do here), rather than trying to overload a special value
different from NULL.

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]