summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2010-07-13 19:49:16 -0300
committerMarcelo Tosatti <mtosatti@redhat.com>2010-07-13 19:49:16 -0300
commit6b440ef2a97e45f6839413f7609fa16090c5d5ff (patch)
tree3563a2aab82ed0fa011a5353acd01b617c8d3947 /block
parentdd09bf100b244a4af389eb5e427e1986836366e5 (diff)
parentd17b5288d91c935cc8795fa0620721da0a3865e1 (diff)
Merge commit 'd17b5288d91c935cc8795fa0620721da0a3865e1' into upstream-merge
* commit 'd17b5288d91c935cc8795fa0620721da0a3865e1': (54 commits) Remove uses of ram.last_offset (aka last_ram_offset) make rtc alatm work scsi: Fix SCSI bus reset Fix io-thread build breakage of a88790a14f Include sys/mman.h before qemu-options.h cris: Avoid debug clobbering for both I & D MMU state. cris: Dont clobber the MMU state across calls to cpu_get_phys_page_debug. cris: Break out rand LFSR update into a separate func. block: Handle multiwrite errors only when all requests have completed block: Fix early failure in multiwrite qemu-img: avoid calling exit(1) to release resources properly pc: Fix CMOS info for drives defined with -device ide: Make PIIX and ISA IDE init functions return the qdev block: Fix virtual media change for if=none block: Clean up bdrv_snapshots() savevm: Survive hot-unplug of snapshot device blkdebug: Initialize state as 1 blkdebug: Free QemuOpts after having read the config blkdebug: Fix set_state_opts definition qemu-option: New qemu_opts_reset() ... Conflicts: exec.c Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkdebug.c7
-rw-r--r--block/qcow2.c15
2 files changed, 15 insertions, 7 deletions
diff --git a/block/blkdebug.c b/block/blkdebug.c
index 98fed944b..2a63df932 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -111,7 +111,7 @@ static QemuOptsList inject_error_opts = {
static QemuOptsList set_state_opts = {
.name = "set-state",
- .head = QTAILQ_HEAD_INITIALIZER(inject_error_opts.head),
+ .head = QTAILQ_HEAD_INITIALIZER(set_state_opts.head),
.desc = {
{
.name = "event",
@@ -267,6 +267,8 @@ static int read_config(BDRVBlkdebugState *s, const char *filename)
ret = 0;
fail:
+ qemu_opts_reset(&inject_error_opts);
+ qemu_opts_reset(&set_state_opts);
fclose(f);
return ret;
}
@@ -299,6 +301,9 @@ static int blkdebug_open(BlockDriverState *bs, const char *filename, int flags)
}
filename = c + 1;
+ /* Set initial state */
+ s->vars.state = 1;
+
/* Open the backing file */
ret = bdrv_file_open(&bs->file, filename, flags);
if (ret < 0) {
diff --git a/block/qcow2.c b/block/qcow2.c
index d29e6b6c0..9ee34b6dd 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -805,14 +805,14 @@ static int preallocate(BlockDriverState *bs)
while (nb_sectors) {
num = MIN(nb_sectors, INT_MAX >> 9);
ret = qcow2_alloc_cluster_offset(bs, offset, 0, num, &num, &meta);
-
if (ret < 0) {
- return -1;
+ return ret;
}
- if (qcow2_alloc_cluster_link_l2(bs, &meta) < 0) {
+ ret = qcow2_alloc_cluster_link_l2(bs, &meta);
+ if (ret < 0) {
qcow2_free_any_clusters(bs, meta.cluster_offset, meta.nb_clusters);
- return -1;
+ return ret;
}
/* There are no dependent requests, but we need to remove our request
@@ -833,7 +833,10 @@ static int preallocate(BlockDriverState *bs)
if (meta.cluster_offset != 0) {
uint8_t buf[512];
memset(buf, 0, 512);
- bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1);
+ ret = bdrv_write(bs->file, (meta.cluster_offset >> 9) + num - 1, buf, 1);
+ if (ret < 0) {
+ return ret;
+ }
}
return 0;
@@ -1030,7 +1033,7 @@ exit:
BlockDriver *drv = bdrv_find_format("qcow2");
bs = bdrv_new("");
bdrv_open(bs, filename, BDRV_O_CACHE_WB | BDRV_O_RDWR, drv);
- preallocate(bs);
+ ret = preallocate(bs);
bdrv_close(bs);
}