summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2014-02-17 14:44:07 +0100
committerKevin Wolf <kwolf@redhat.com>2014-02-21 21:02:24 +0100
commit5b7aa9b56d1bfc79916262f380c3fc7961becb50 (patch)
tree99b5631b32da2f47bbf73996691ebbabe24691c0
parent76abe4071d111a9ca6dcc9b9689a831c39ffa718 (diff)
downloadqemu-5b7aa9b56d1bfc79916262f380c3fc7961becb50.tar.gz
qemu-5b7aa9b56d1bfc79916262f380c3fc7961becb50.tar.bz2
qemu-5b7aa9b56d1bfc79916262f380c3fc7961becb50.zip
vdi: say why an image is bad
Instead of just putting it in debugging output, we can now put the value in an Error. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/vdi.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/block/vdi.c b/block/vdi.c
index f3c6acf3cf..ae49cd83ca 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -399,39 +399,46 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
ret = -EINVAL;
goto fail;
} else if (header.version != VDI_VERSION_1_1) {
- logout("unsupported version %u.%u\n",
- header.version >> 16, header.version & 0xffff);
+ error_setg(errp, "unsupported VDI image (version %u.%u)",
+ 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);
+ error_setg(errp, "unsupported VDI image (unaligned block map offset "
+ "0x%x)", 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);
+ error_setg(errp, "unsupported VDI image (unaligned data offset 0x%x)",
+ header.offset_data);
ret = -ENOTSUP;
goto fail;
} else if (header.sector_size != SECTOR_SIZE) {
- logout("unsupported sector size %u B\n", header.sector_size);
+ error_setg(errp, "unsupported VDI image (sector size %u is not %u)",
+ header.sector_size, SECTOR_SIZE);
ret = -ENOTSUP;
goto fail;
} else if (header.block_size != 1 * MiB) {
- logout("unsupported block size %u B\n", header.block_size);
+ error_setg(errp, "unsupported VDI image (sector size %u is not %u)",
+ header.block_size, 1 * MiB);
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);
+ error_setg(errp, "unsupported VDI image (disk size %" PRIu64 ", "
+ "image bitmap has room for %" PRIu64 ")",
+ header.disk_size,
+ (uint64_t)header.blocks_in_image * header.block_size);
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_link)) {
- logout("link uuid != 0, unsupported\n");
+ error_setg(errp, "unsupported VDI image (non-NULL link UUID)");
ret = -ENOTSUP;
goto fail;
} else if (!uuid_is_null(header.uuid_parent)) {
- logout("parent uuid != 0, unsupported\n");
+ error_setg(errp, "unsupported VDI image (non-NULL parent UUID)");
ret = -ENOTSUP;
goto fail;
}