[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/16] introduce a new API to check if blk is at
From: |
Eric Blake |
Subject: |
Re: [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
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH 01/16] introduce a new API to enable/disable attach device model, (continued)
- [Qemu-devel] [PATCH 03/16] allow writing to the backing file, Wen Congyang, 2015/09/02
- [Qemu-devel] [PATCH 04/16] block: Allow references for backing files, Wen Congyang, 2015/09/02
- [Qemu-devel] [PATCH 07/16] Backup: clear all bitmap when doing block checkpoint, Wen Congyang, 2015/09/02
- [Qemu-devel] [PATCH 02/16] introduce a new API to check if blk is attached, Wen Congyang, 2015/09/02
- Re: [Qemu-devel] [PATCH 02/16] introduce a new API to check if blk is attached,
Eric Blake <=
- [Qemu-devel] [PATCH 06/16] quorum: allow ignoring child errors, Wen Congyang, 2015/09/02
- [Qemu-devel] [PATCH 09/16] Allow creating backup jobs when opening BDS, Wen Congyang, 2015/09/02
- [Qemu-devel] [PATCH 05/16] introduce a new API qemu_opts_absorb_qdict_by_index(), Wen Congyang, 2015/09/02