[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 16/24] block/vdi: Improved return values from vdi_op
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 16/24] block/vdi: Improved return values from vdi_open |
Date: |
Fri, 25 Jan 2013 19:45:52 +0100 |
From: Stefan Weil <address@hidden>
vdi_open returned -1 in case of any error, but it should return an
error code (negative value of errno or -EMEDIUMTYPE).
Signed-off-by: Stefan Weil <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vdi.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/block/vdi.c b/block/vdi.c
index 0e1ed61..8b768bf 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -369,10 +369,12 @@ static int vdi_open(BlockDriverState *bs, int flags)
BDRVVdiState *s = bs->opaque;
VdiHeader header;
size_t bmap_size;
+ int ret;
logout("\n");
- if (bdrv_read(bs->file, 0, (uint8_t *)&header, 1) < 0) {
+ ret = bdrv_read(bs->file, 0, (uint8_t *)&header, 1);
+ if (ret < 0) {
goto fail;
}
@@ -393,30 +395,38 @@ static int vdi_open(BlockDriverState *bs, int flags)
if (header.version != VDI_VERSION_1_1) {
logout("unsupported version %u.%u\n",
header.version >> 16, header.version & 0xffff);
+ ret = -ENOTSUP;
goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) {
/* We only support block maps which start on a sector boundary. */
logout("unsupported block map offset 0x%x B\n", header.offset_bmap);
+ ret = -ENOTSUP;
goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) {
/* We only support data blocks which start on a sector boundary. */
logout("unsupported data offset 0x%x B\n", header.offset_data);
+ ret = -ENOTSUP;
goto fail;
} else if (header.sector_size != SECTOR_SIZE) {
logout("unsupported sector size %u B\n", header.sector_size);
+ ret = -ENOTSUP;
goto fail;
} else if (header.block_size != 1 * MiB) {
logout("unsupported block size %u B\n", header.block_size);
+ ret = -ENOTSUP;
goto fail;
} else if (header.disk_size >
(uint64_t)header.blocks_in_image * header.block_size) {
logout("unsupported disk size %" PRIu64 " B\n", header.disk_size);
+ ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
logout("link uuid != 0, unsupported\n");
+ ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
logout("parent uuid != 0, unsupported\n");
+ ret = -ENOTSUP;
goto fail;
}
@@ -432,7 +442,8 @@ static int vdi_open(BlockDriverState *bs, int flags)
if (bmap_size > 0) {
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
}
- if (bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size) <
0) {
+ ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
+ if (ret < 0) {
goto fail_free_bmap;
}
@@ -448,7 +459,7 @@ static int vdi_open(BlockDriverState *bs, int flags)
g_free(s->bmap);
fail:
- return -1;
+ return ret;
}
static int vdi_reopen_prepare(BDRVReopenState *state,
--
1.7.6.5
- [Qemu-devel] [PATCH 08/24] mirror: allow customizing the granularity, (continued)
- [Qemu-devel] [PATCH 08/24] mirror: allow customizing the granularity, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 10/24] mirror: add buf-size argument to drive-mirror, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 11/24] mirror: support more than one in-flight AIO operation, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 13/24] block: Add special error code for wrong format, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 12/24] mirror: support arbitrarily-sized iterations, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 14/24] block: Use error code EMEDIUMTYPE for wrong format in some block drivers, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 18/24] mirror: do nothing on zero-sized disk, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 19/24] hbitmap: add assertion on hbitmap_iter_init, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 17/24] block/vdi: Check for bad signature, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 15/24] block/vdi: Improve debug output for signature, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 16/24] block/vdi: Improved return values from vdi_open,
Kevin Wolf <=
- [Qemu-devel] [PATCH 23/24] block: Create proper size file for disk mirror, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 20/24] ahci: Remove unused AHCIDevice fields, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 22/24] ahci: Add migration support, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 24/24] ide: Add fall through annotations, Kevin Wolf, 2013/01/25
- [Qemu-devel] [PATCH 21/24] ahci: Change data types in preparation for migration, Kevin Wolf, 2013/01/25