* [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value
@ 2014-07-07 15:37 Kevin Wolf
2014-07-07 15:50 ` Eric Blake
2014-07-08 12:57 ` Kevin Wolf
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2014-07-07 15:37 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha
bdrv_is_allocated() should return either 0 or 1 in successful cases.
We're lucky that currently, the callers that rely on this (e.g. because
they check for ret == 1) don't seem to break badly. They just might skip
some optimisation or in the case of qemu-io 'map' print separate lines
where a single line would suffice. In theory, a wrong allocation status
could lead to image corruption with certain operations, so let's fix
this quickly.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block.c b/block.c
index f80e2b2..e2e9cbb 100644
--- a/block.c
+++ b/block.c
@@ -4039,7 +4039,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
if (ret < 0) {
return ret;
}
- return (ret & BDRV_BLOCK_ALLOCATED);
+ return !!(ret & BDRV_BLOCK_ALLOCATED);
}
/*
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value
2014-07-07 15:37 [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value Kevin Wolf
@ 2014-07-07 15:50 ` Eric Blake
2014-07-08 12:57 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2014-07-07 15:50 UTC (permalink / raw)
To: Kevin Wolf, qemu-devel; +Cc: stefanha
[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]
On 07/07/2014 09:37 AM, Kevin Wolf wrote:
> bdrv_is_allocated() should return either 0 or 1 in successful cases.
> We're lucky that currently, the callers that rely on this (e.g. because
> they check for ret == 1) don't seem to break badly. They just might skip
> some optimisation or in the case of qemu-io 'map' print separate lines
> where a single line would suffice. In theory, a wrong allocation status
> could lead to image corruption with certain operations, so let's fix
> this quickly.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block.c b/block.c
> index f80e2b2..e2e9cbb 100644
> --- a/block.c
> +++ b/block.c
> @@ -4039,7 +4039,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
> if (ret < 0) {
> return ret;
> }
> - return (ret & BDRV_BLOCK_ALLOCATED);
> + return !!(ret & BDRV_BLOCK_ALLOCATED);
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value
2014-07-07 15:37 [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value Kevin Wolf
2014-07-07 15:50 ` Eric Blake
@ 2014-07-08 12:57 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2014-07-08 12:57 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanha
Am 07.07.2014 um 17:37 hat Kevin Wolf geschrieben:
> bdrv_is_allocated() should return either 0 or 1 in successful cases.
> We're lucky that currently, the callers that rely on this (e.g. because
> they check for ret == 1) don't seem to break badly. They just might skip
> some optimisation or in the case of qemu-io 'map' print separate lines
> where a single line would suffice. In theory, a wrong allocation status
> could lead to image corruption with certain operations, so let's fix
> this quickly.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-08 12:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-07 15:37 [Qemu-devel] [PATCH for-2.1] block: Fix bdrv_is_allocated() return value Kevin Wolf
2014-07-07 15:50 ` Eric Blake
2014-07-08 12:57 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).