From 76abe4071d111a9ca6dcc9b9689a831c39ffa718 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 17 Feb 2014 14:44:06 +0100 Subject: block: do not abuse EMEDIUMTYPE Returning "Wrong medium type" for an image that does not have a valid header is a bit weird. Improve the error by mentioning what format was trying to open it. Signed-off-by: Paolo Bonzini Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf --- block/vmdk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'block/vmdk.c') diff --git a/block/vmdk.c b/block/vmdk.c index 9c3711cbbf..83839f9b7a 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -748,7 +748,8 @@ static int vmdk_open_sparse(BlockDriverState *bs, return vmdk_open_vmdk4(bs, file, flags, errp); break; default: - return -EMEDIUMTYPE; + error_setg(errp, "Image not in VMDK format"); + return -EINVAL; break; } } @@ -862,7 +863,8 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags, char *buf, BDRVVmdkState *s = bs->opaque; if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) { - ret = -EMEDIUMTYPE; + error_setg(errp, "invalid VMDK image descriptor"); + ret = -EINVAL; goto exit; } if (strcmp(ct, "monolithicFlat") && -- cgit v1.2.3