提交 5b7aa9b5 编写于 作者: P Paolo Bonzini 提交者: Kevin Wolf

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: NPaolo Bonzini <pbonzini@redhat.com>
Reviewed-by: NFam Zheng <famz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 76abe407
...@@ -399,39 +399,46 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -399,39 +399,46 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
} else if (header.version != VDI_VERSION_1_1) { } else if (header.version != VDI_VERSION_1_1) {
logout("unsupported version %u.%u\n", error_setg(errp, "unsupported VDI image (version %u.%u)",
header.version >> 16, header.version & 0xffff); header.version >> 16, header.version & 0xffff);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.offset_bmap % SECTOR_SIZE != 0) { } else if (header.offset_bmap % SECTOR_SIZE != 0) {
/* We only support block maps which start on a sector boundary. */ /* 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; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.offset_data % SECTOR_SIZE != 0) { } else if (header.offset_data % SECTOR_SIZE != 0) {
/* We only support data blocks which start on a sector boundary. */ /* 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; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.sector_size != SECTOR_SIZE) { } 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; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.block_size != 1 * MiB) { } 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; ret = -ENOTSUP;
goto fail; goto fail;
} else if (header.disk_size > } else if (header.disk_size >
(uint64_t)header.blocks_in_image * header.block_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; ret = -ENOTSUP;
goto fail; goto fail;
} else if (!uuid_is_null(header.uuid_link)) { } 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; ret = -ENOTSUP;
goto fail; goto fail;
} else if (!uuid_is_null(header.uuid_parent)) { } 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; ret = -ENOTSUP;
goto fail; goto fail;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册