From: Anthony Liguori <anthony@codemonkey.ws>
To: Christoph Hellwig <hch@lst.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] dmg: fix ->open failure
Date: Mon, 11 Jan 2010 13:51:00 -0600 [thread overview]
Message-ID: <4B4B8124.5020500@codemonkey.ws> (raw)
In-Reply-To: <20100111130654.GA24241@lst.de>
On 01/11/2010 07:06 AM, Christoph Hellwig wrote:
> Currently the dmg image format driver simply opens the images as raw
> if any kind of failure happens. This is contrarty to the behaviour
> of all other image formats which just return an error and let the
> block core deal with it.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
>
Applied. Thanks.
Regards,
Anthony Liguori
> Index: qemu/block/dmg.c
> ===================================================================
> --- qemu.orig/block/dmg.c 2010-01-11 14:00:25.945021645 +0100
> +++ qemu/block/dmg.c 2010-01-11 14:03:03.006036707 +0100
> @@ -90,24 +90,21 @@ static int dmg_open(BlockDriverState *bs
>
> /* read offset of info blocks */
> if(lseek(s->fd,-0x1d8,SEEK_END)<0) {
> -dmg_close:
> - close(s->fd);
> - /* open raw instead */
> - bs->drv=bdrv_find_format("raw");
> - return bs->drv->bdrv_open(bs, filename, flags);
> + goto fail;
> }
> +
> info_begin=read_off(s->fd);
> if(info_begin==0)
> - goto dmg_close;
> + goto fail;
> if(lseek(s->fd,info_begin,SEEK_SET)<0)
> - goto dmg_close;
> + goto fail;
> if(read_uint32(s->fd)!=0x100)
> - goto dmg_close;
> + goto fail;
> if((count = read_uint32(s->fd))==0)
> - goto dmg_close;
> + goto fail;
> info_end = info_begin+count;
> if(lseek(s->fd,0xf8,SEEK_CUR)<0)
> - goto dmg_close;
> + goto fail;
>
> /* read offsets */
> last_in_offset = last_out_offset = 0;
> @@ -116,14 +113,14 @@ dmg_close:
>
> count = read_uint32(s->fd);
> if(count==0)
> - goto dmg_close;
> + goto fail;
> type = read_uint32(s->fd);
> if(type!=0x6d697368 || count<244)
> lseek(s->fd,count-4,SEEK_CUR);
> else {
> int new_size, chunk_count;
> if(lseek(s->fd,200,SEEK_CUR)<0)
> - goto dmg_close;
> + goto fail;
> chunk_count = (count-204)/40;
> new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
> s->types = qemu_realloc(s->types, new_size/2);
> @@ -142,7 +139,7 @@ dmg_close:
> chunk_count--;
> i--;
> if(lseek(s->fd,36,SEEK_CUR)<0)
> - goto dmg_close;
> + goto fail;
> continue;
> }
> read_uint32(s->fd);
> @@ -163,11 +160,14 @@ dmg_close:
> s->compressed_chunk = qemu_malloc(max_compressed_size+1);
> s->uncompressed_chunk = qemu_malloc(512*max_sectors_per_chunk);
> if(inflateInit(&s->zstream) != Z_OK)
> - goto dmg_close;
> + goto fail;
>
> s->current_chunk = s->n_chunks;
>
> return 0;
> +fail:
> + close(s->fd);
> + return -1;
> }
>
> static inline int is_sector_in_chunk(BDRVDMGState* s,
>
>
>
>
prev parent reply other threads:[~2010-01-11 19:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-11 13:06 [Qemu-devel] [PATCH] dmg: fix ->open failure Christoph Hellwig
2010-01-11 13:43 ` Kevin Wolf
2010-01-11 13:46 ` Christoph Hellwig
2010-01-11 13:56 ` Kevin Wolf
2010-01-11 14:00 ` Christoph Hellwig
2010-01-11 14:11 ` Kevin Wolf
2010-01-11 17:47 ` Christoph Hellwig
2010-01-12 9:25 ` Kevin Wolf
2010-01-11 19:07 ` malc
2010-01-11 19:51 ` Anthony Liguori [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B4B8124.5020500@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=hch@lst.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).