From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, famz@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v3 19/20] block: do not abuse EMEDIUMTYPE
Date: Mon, 17 Feb 2014 14:44:06 +0100 [thread overview]
Message-ID: <1392644647-9897-20-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1392644647-9897-1-git-send-email-pbonzini@redhat.com>
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 <pbonzini@redhat.com>
---
block/bochs.c | 3 ++-
block/cow.c | 3 ++-
block/parallels.c | 3 ++-
block/qcow.c | 3 ++-
block/qcow2.c | 2 +-
block/qed.c | 3 ++-
block/vdi.c | 4 ++--
block/vmdk.c | 6 ++++--
block/vpc.c | 3 ++-
9 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/block/bochs.c b/block/bochs.c
index 51d9a90..4d6403f 100644
--- a/block/bochs.c
+++ b/block/bochs.c
@@ -129,7 +129,8 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
strcmp(bochs.subtype, GROWING_TYPE) ||
((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
(le32_to_cpu(bochs.version) != HEADER_V1))) {
- return -EMEDIUMTYPE;
+ error_setg(errp, "Image not in Bochs format");
+ return -EINVAL;
}
if (le32_to_cpu(bochs.version) == HEADER_V1) {
diff --git a/block/cow.c b/block/cow.c
index 0564744..9603347 100644
--- a/block/cow.c
+++ b/block/cow.c
@@ -74,7 +74,8 @@ static int cow_open(BlockDriverState *bs, QDict *options, int flags,
}
if (be32_to_cpu(cow_header.magic) != COW_MAGIC) {
- ret = -EMEDIUMTYPE;
+ error_setg(errp, "Image not in COW format");
+ ret = -EINVAL;
goto fail;
}
diff --git a/block/parallels.c b/block/parallels.c
index 2121e43..3f588f5 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -85,7 +85,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
(le32_to_cpu(ph.version) != HEADER_VERSION)) {
- ret = -EMEDIUMTYPE;
+ error_setg(errp, "Image not in Parallels format");
+ ret = -EINVAL;
goto fail;
}
diff --git a/block/qcow.c b/block/qcow.c
index a915bc3..b273b2f 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -113,7 +113,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
be64_to_cpus(&header.l1_table_offset);
if (header.magic != QCOW_MAGIC) {
- ret = -EMEDIUMTYPE;
+ error_setg(errp, "Image not in qcow format");
+ ret = -EINVAL;
goto fail;
}
if (header.version != QCOW_VERSION) {
diff --git a/block/qcow2.c b/block/qcow2.c
index 0b4335c..4f7a3d1 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -449,7 +449,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
if (header.magic != QCOW_MAGIC) {
error_setg(errp, "Image is not in qcow2 format");
- ret = -EMEDIUMTYPE;
+ ret = -EINVAL;
goto fail;
}
if (header.version < 2 || header.version > 3) {
diff --git a/block/qed.c b/block/qed.c
index b13ef8a..236d985 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -391,7 +391,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
qed_header_le_to_cpu(&le_header, &s->header);
if (s->header.magic != QED_MAGIC) {
- return -EMEDIUMTYPE;
+ error_setg(errp, "Image not in QED format");
+ return -EINVAL;
}
if (s->header.features & ~QED_FEATURE_MASK) {
/* image uses unsupported feature bits */
diff --git a/block/vdi.c b/block/vdi.c
index 2d7490f..f3c6acf 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -395,8 +395,8 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
}
if (header.signature != VDI_SIGNATURE) {
- logout("bad vdi signature %08x\n", header.signature);
- ret = -EMEDIUMTYPE;
+ error_setg(errp, "Image not in VDI format (bad signature %08x)", header.signature);
+ ret = -EINVAL;
goto fail;
} else if (header.version != VDI_VERSION_1_1) {
logout("unsupported version %u.%u\n",
diff --git a/block/vmdk.c b/block/vmdk.c
index ba2b6f5..54ecbd6 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;
}
}
@@ -861,7 +862,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") &&
diff --git a/block/vpc.c b/block/vpc.c
index 1d326cb..82bf248 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -190,7 +190,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
if (strncmp(footer->creator, "conectix", 8)) {
- ret = -EMEDIUMTYPE;
+ error_setg(errp, "invalid VPC image");
+ ret = -EINVAL;
goto fail;
}
disk_type = VHD_FIXED;
--
1.8.5.3
next prev parent reply other threads:[~2014-02-17 13:45 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-17 13:43 [Qemu-devel] [PATCH v3 00/20] Improve bdrv_open error messages Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 01/20] nbd: produce a better error if neither host nor port is passed Paolo Bonzini
2014-02-17 18:48 ` Eric Blake
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 02/20] nbd: correctly propagate errors Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 03/20] nbd: inline tcp_socket_incoming_spec into sole caller Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 04/20] nbd: move socket wrappers to qemu-nbd Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 05/20] iscsi: fix indentation Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 06/20] iscsi: correctly propagate errors in iscsi_open Paolo Bonzini
2014-02-19 9:34 ` Stefan Hajnoczi
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 07/20] gluster: default scheme to gluster:// and host to localhost Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 08/20] gluster: correctly propagate errors Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 09/20] cow: " Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 10/20] curl: " Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 11/20] qcow: " Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 12/20] qed: " Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 13/20] vhdx: " Paolo Bonzini
2014-02-17 14:38 ` Jeff Cody
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 14/20] vvfat: " Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 15/20] vmdk: extract vmdk_read_desc Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 16/20] vmdk: push vmdk_read_desc up to caller Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 17/20] vmdk: do not try opening a file as both image and descriptor Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 18/20] vmdk: correctly propagate errors Paolo Bonzini
2014-02-17 13:44 ` Paolo Bonzini [this message]
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 20/20] vdi: say why an image is bad Paolo Bonzini
2014-02-18 6:32 ` [Qemu-devel] [PATCH v3 00/20] Improve bdrv_open error messages Fam Zheng
2014-02-19 14:06 ` Kevin Wolf
2014-02-20 17:29 ` Paolo Bonzini
2014-02-21 11:08 ` Kevin Wolf
2014-02-21 11:37 ` Paolo Bonzini
2014-02-21 11:47 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392644647-9897-20-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).