aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2010-01-17 15:39:57 +0200
committerAvi Kivity <avi@redhat.com>2010-01-17 15:39:57 +0200
commitb874ce1db7d8654850c8a6606b95ffb1c7d22ce2 (patch)
tree0e031a914e520fdc6e86cd49c7b0156dd0decd92 /block
parentMerge branch 'stable-0.12-upstream' into stable-0.12 (diff)
parentUpdate version and changelog for release (diff)
downloadqemu-kvm-b874ce1db7d8654850c8a6606b95ffb1c7d22ce2.tar.gz
qemu-kvm-b874ce1db7d8654850c8a6606b95ffb1c7d22ce2.tar.bz2
qemu-kvm-b874ce1db7d8654850c8a6606b95ffb1c7d22ce2.zip
Merge remote branch 'upstream/stable-0.12' into stable-0.12
* upstream/stable-0.12: (27 commits) Update version and changelog for release Update SeaBIOS to 0.5.1 Qemu's internal TFTP server breaks lock-step-iness of TFTP osdep.c: Fix accept4 fallback pc: add rombar to compat properties for pc-0.10 and pc-0.11 pci: allow loading roms via fw_cfg. roms: rework rom loading via fw fw_cfg: rom loader tweaks. roms: minor fixes and cleanups. pc: add machine type for 0.12 loader: more ignores for rom intended to be loaded by the bios vnc_refresh: return if vd->timer is NULL QMP: Don't free async event's 'data' Handle TFTP ERROR from client dmg: fix ->open failure virtio-pci: thinko fix pc-bios: Update README (SeaBIOS) vmware_vga: Check cursor dimensions passed from guest to avoid buffer overflow remove pending exception on vcpu reset. Fix CPU topology initialization ... Conflicts: hw/pc.c hw/pci.h qemu-options.hx Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/dmg.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/block/dmg.c b/block/dmg.c
index 262560ffd..f4c01c76b 100644
--- a/block/dmg.c
+++ b/block/dmg.c
@@ -90,24 +90,21 @@ static int dmg_open(BlockDriverState *bs, const char *filename, int flags)
/* 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,