* [Qemu-devel] [PATCH] vpc: Add missing error handling in alloc_block
@ 2011-11-23 10:40 Kevin Wolf
2011-11-23 11:01 ` Stefan Hajnoczi
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Wolf @ 2011-11-23 10:40 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/vpc.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/block/vpc.c b/block/vpc.c
index 75d7d4a..89a5ee2 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -362,8 +362,11 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num)
// Initialize the block's bitmap
memset(bitmap, 0xff, s->bitmap_size);
- bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
+ ret = bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
s->bitmap_size);
+ if (ret < 0) {
+ return ret;
+ }
// Write new footer (the old one will be overwritten)
s->free_data_block_offset += s->block_size + s->bitmap_size;
--
1.7.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] vpc: Add missing error handling in alloc_block
2011-11-23 10:40 [Qemu-devel] [PATCH] vpc: Add missing error handling in alloc_block Kevin Wolf
@ 2011-11-23 11:01 ` Stefan Hajnoczi
2011-11-23 11:23 ` Kevin Wolf
0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2011-11-23 11:01 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel
On Wed, Nov 23, 2011 at 10:40 AM, Kevin Wolf <kwolf@redhat.com> wrote:
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/vpc.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/block/vpc.c b/block/vpc.c
> index 75d7d4a..89a5ee2 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -362,8 +362,11 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num)
>
> // Initialize the block's bitmap
> memset(bitmap, 0xff, s->bitmap_size);
> - bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
> + ret = bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
> s->bitmap_size);
> + if (ret < 0) {
> + return ret;
> + }
I notice that s->pagetable[index] is left modified when the function
fails. But this is a larger issue and could be addressed in a later
patch which also looks at the other failure cases in this function.
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] vpc: Add missing error handling in alloc_block
2011-11-23 11:01 ` Stefan Hajnoczi
@ 2011-11-23 11:23 ` Kevin Wolf
2011-11-25 11:57 ` Andreas Färber
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Wolf @ 2011-11-23 11:23 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: qemu-devel
Am 23.11.2011 12:01, schrieb Stefan Hajnoczi:
> On Wed, Nov 23, 2011 at 10:40 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>> block/vpc.c | 5 ++++-
>> 1 files changed, 4 insertions(+), 1 deletions(-)
>>
>> diff --git a/block/vpc.c b/block/vpc.c
>> index 75d7d4a..89a5ee2 100644
>> --- a/block/vpc.c
>> +++ b/block/vpc.c
>> @@ -362,8 +362,11 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num)
>>
>> // Initialize the block's bitmap
>> memset(bitmap, 0xff, s->bitmap_size);
>> - bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
>> + ret = bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
>> s->bitmap_size);
>> + if (ret < 0) {
>> + return ret;
>> + }
>
> I notice that s->pagetable[index] is left modified when the function
> fails. But this is a larger issue and could be addressed in a later
> patch which also looks at the other failure cases in this function.
Error handling in vpc needs some work anyway. For example, almost all
places return -1 instead of the real error number. Probably even the
order of operations is unsafe, didn't check that yet.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] vpc: Add missing error handling in alloc_block
2011-11-23 11:23 ` Kevin Wolf
@ 2011-11-25 11:57 ` Andreas Färber
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2011-11-25 11:57 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Stefan Hajnoczi, qemu-devel
Am 23.11.2011 12:23, schrieb Kevin Wolf:
> Am 23.11.2011 12:01, schrieb Stefan Hajnoczi:
>> On Wed, Nov 23, 2011 at 10:40 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>>> ---
>>> block/vpc.c | 5 ++++-
>>> 1 files changed, 4 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/block/vpc.c b/block/vpc.c
>>> index 75d7d4a..89a5ee2 100644
>>> --- a/block/vpc.c
>>> +++ b/block/vpc.c
>>> @@ -362,8 +362,11 @@ static int64_t alloc_block(BlockDriverState* bs, int64_t sector_num)
>>>
>>> // Initialize the block's bitmap
>>> memset(bitmap, 0xff, s->bitmap_size);
>>> - bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
>>> + ret = bdrv_pwrite_sync(bs->file, s->free_data_block_offset, bitmap,
>>> s->bitmap_size);
>>> + if (ret < 0) {
>>> + return ret;
>>> + }
>>
>> I notice that s->pagetable[index] is left modified when the function
>> fails. But this is a larger issue and could be addressed in a later
>> patch which also looks at the other failure cases in this function.
>
> Error handling in vpc needs some work anyway. For example, almost all
> places return -1 instead of the real error number. Probably even the
> order of operations is unsafe, didn't check that yet.
As a note, as part of QEMU Test Day(s) I tested VHD images (cf. Wiki) -
booting, installing software, etc. and haven't encountered any problem.
Doesn't mean it's entirely safe though, obviously.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-25 11:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-23 10:40 [Qemu-devel] [PATCH] vpc: Add missing error handling in alloc_block Kevin Wolf
2011-11-23 11:01 ` Stefan Hajnoczi
2011-11-23 11:23 ` Kevin Wolf
2011-11-25 11:57 ` Andreas Färber
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).