|
|
958e1b |
From 0b0c86931a7da43b6358b202799510b20775aa17 Mon Sep 17 00:00:00 2001
|
|
|
958e1b |
From: Jeffrey Cody <jcody@redhat.com>
|
|
|
958e1b |
Date: Tue, 16 Sep 2014 20:11:43 +0200
|
|
|
958e1b |
Subject: [PATCH 05/20] block: do not abuse EMEDIUMTYPE
|
|
|
958e1b |
|
|
|
958e1b |
Message-id: <e7489a9924b5a762f270901b59c974e79172f0fb.1410897407.git.jcody@redhat.com>
|
|
|
958e1b |
Patchwork-id: 61209
|
|
|
958e1b |
O-Subject: [PATCH qemu-kvm-rhel RHEL7.1 04/15] block: do not abuse EMEDIUMTYPE
|
|
|
958e1b |
Bugzilla: 1098086
|
|
|
958e1b |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
958e1b |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
Returning "Wrong medium type" for an image that does not have a valid
|
|
|
958e1b |
header is a bit weird. Improve the error by mentioning what format
|
|
|
958e1b |
was trying to open it.
|
|
|
958e1b |
|
|
|
958e1b |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
958e1b |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
958e1b |
(cherry picked from commit 76abe4071d111a9ca6dcc9b9689a831c39ffa718)
|
|
|
958e1b |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
958e1b |
---
|
|
|
958e1b |
block/bochs.c | 3 ++-
|
|
|
958e1b |
block/cow.c | 3 ++-
|
|
|
958e1b |
block/parallels.c | 3 ++-
|
|
|
958e1b |
block/qcow.c | 3 ++-
|
|
|
958e1b |
block/qcow2.c | 2 +-
|
|
|
958e1b |
block/qed.c | 3 ++-
|
|
|
958e1b |
block/vdi.c | 4 ++--
|
|
|
958e1b |
block/vmdk.c | 6 ++++--
|
|
|
958e1b |
block/vpc.c | 3 ++-
|
|
|
958e1b |
9 files changed, 19 insertions(+), 11 deletions(-)
|
|
|
958e1b |
|
|
|
958e1b |
diff --git a/block/bochs.c b/block/bochs.c
|
|
|
958e1b |
index 5c74223..826ec12 100644
|
|
|
958e1b |
--- a/block/bochs.c
|
|
|
958e1b |
+++ b/block/bochs.c
|
|
|
958e1b |
@@ -113,7 +113,8 @@ static int bochs_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
strcmp(bochs.subtype, GROWING_TYPE) ||
|
|
|
958e1b |
((le32_to_cpu(bochs.version) != HEADER_VERSION) &&
|
|
|
958e1b |
(le32_to_cpu(bochs.version) != HEADER_V1))) {
|
|
|
958e1b |
- return -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "Image not in Bochs format");
|
|
|
958e1b |
+ return -EINVAL;
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
if (le32_to_cpu(bochs.version) == HEADER_V1) {
|
|
|
958e1b |
diff --git a/block/cow.c b/block/cow.c
|
|
|
958e1b |
index 909c3e7..46295d4 100644
|
|
|
958e1b |
--- a/block/cow.c
|
|
|
958e1b |
+++ b/block/cow.c
|
|
|
958e1b |
@@ -74,7 +74,8 @@ static int cow_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
if (be32_to_cpu(cow_header.magic) != COW_MAGIC) {
|
|
|
958e1b |
- ret = -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "Image not in COW format");
|
|
|
958e1b |
+ ret = -EINVAL;
|
|
|
958e1b |
goto fail;
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
diff --git a/block/parallels.c b/block/parallels.c
|
|
|
958e1b |
index d83cde4..1a5bd35 100644
|
|
|
958e1b |
--- a/block/parallels.c
|
|
|
958e1b |
+++ b/block/parallels.c
|
|
|
958e1b |
@@ -85,7 +85,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
|
|
|
958e1b |
if (memcmp(ph.magic, HEADER_MAGIC, 16) ||
|
|
|
958e1b |
(le32_to_cpu(ph.version) != HEADER_VERSION)) {
|
|
|
958e1b |
- ret = -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "Image not in Parallels format");
|
|
|
958e1b |
+ ret = -EINVAL;
|
|
|
958e1b |
goto fail;
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
diff --git a/block/qcow.c b/block/qcow.c
|
|
|
958e1b |
index ad44f78..a5f601f 100644
|
|
|
958e1b |
--- a/block/qcow.c
|
|
|
958e1b |
+++ b/block/qcow.c
|
|
|
958e1b |
@@ -115,7 +115,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
be64_to_cpus(&header.l1_table_offset);
|
|
|
958e1b |
|
|
|
958e1b |
if (header.magic != QCOW_MAGIC) {
|
|
|
958e1b |
- ret = -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "Image not in qcow format");
|
|
|
958e1b |
+ ret = -EINVAL;
|
|
|
958e1b |
goto fail;
|
|
|
958e1b |
}
|
|
|
958e1b |
if (header.version != QCOW_VERSION) {
|
|
|
958e1b |
diff --git a/block/qcow2.c b/block/qcow2.c
|
|
|
958e1b |
index 7398b16..0878d88 100644
|
|
|
958e1b |
--- a/block/qcow2.c
|
|
|
958e1b |
+++ b/block/qcow2.c
|
|
|
958e1b |
@@ -476,7 +476,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
|
|
|
958e1b |
if (header.magic != QCOW_MAGIC) {
|
|
|
958e1b |
error_setg(errp, "Image is not in qcow2 format");
|
|
|
958e1b |
- ret = -EMEDIUMTYPE;
|
|
|
958e1b |
+ ret = -EINVAL;
|
|
|
958e1b |
goto fail;
|
|
|
958e1b |
}
|
|
|
958e1b |
if (header.version < 2 || header.version > 3) {
|
|
|
958e1b |
diff --git a/block/qed.c b/block/qed.c
|
|
|
958e1b |
index 619f2d0..d1de0a2 100644
|
|
|
958e1b |
--- a/block/qed.c
|
|
|
958e1b |
+++ b/block/qed.c
|
|
|
958e1b |
@@ -391,7 +391,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
qed_header_le_to_cpu(&le_header, &s->header);
|
|
|
958e1b |
|
|
|
958e1b |
if (s->header.magic != QED_MAGIC) {
|
|
|
958e1b |
- return -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "Image not in QED format");
|
|
|
958e1b |
+ return -EINVAL;
|
|
|
958e1b |
}
|
|
|
958e1b |
if (s->header.features & ~QED_FEATURE_MASK) {
|
|
|
958e1b |
/* image uses unsupported feature bits */
|
|
|
958e1b |
diff --git a/block/vdi.c b/block/vdi.c
|
|
|
958e1b |
index b095bee..0f8b294 100644
|
|
|
958e1b |
--- a/block/vdi.c
|
|
|
958e1b |
+++ b/block/vdi.c
|
|
|
958e1b |
@@ -408,8 +408,8 @@ static int vdi_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
if (header.signature != VDI_SIGNATURE) {
|
|
|
958e1b |
- logout("bad vdi signature %08x\n", header.signature);
|
|
|
958e1b |
- ret = -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "Image not in VDI format (bad signature %08x)", header.signature);
|
|
|
958e1b |
+ ret = -EINVAL;
|
|
|
958e1b |
goto fail;
|
|
|
958e1b |
} else if (header.version != VDI_VERSION_1_1) {
|
|
|
958e1b |
error_setg(errp, "unsupported VDI image (version %u.%u)",
|
|
|
958e1b |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
958e1b |
index 4ff9531..eff0663 100644
|
|
|
958e1b |
--- a/block/vmdk.c
|
|
|
958e1b |
+++ b/block/vmdk.c
|
|
|
958e1b |
@@ -712,7 +712,8 @@ static int vmdk_open_sparse(BlockDriverState *bs,
|
|
|
958e1b |
return vmdk_open_vmdk4(bs, file, flags, errp);
|
|
|
958e1b |
break;
|
|
|
958e1b |
default:
|
|
|
958e1b |
- return -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "Image not in VMDK format");
|
|
|
958e1b |
+ return -EINVAL;
|
|
|
958e1b |
break;
|
|
|
958e1b |
}
|
|
|
958e1b |
}
|
|
|
958e1b |
@@ -828,7 +829,8 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
|
|
|
958e1b |
goto exit;
|
|
|
958e1b |
}
|
|
|
958e1b |
if (vmdk_parse_description(buf, "createType", ct, sizeof(ct))) {
|
|
|
958e1b |
- ret = -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "invalid VMDK image descriptor");
|
|
|
958e1b |
+ ret = -EINVAL;
|
|
|
958e1b |
goto exit;
|
|
|
958e1b |
}
|
|
|
958e1b |
if (strcmp(ct, "monolithicFlat") &&
|
|
|
958e1b |
diff --git a/block/vpc.c b/block/vpc.c
|
|
|
958e1b |
index 000d1c6..6e8fb33 100644
|
|
|
958e1b |
--- a/block/vpc.c
|
|
|
958e1b |
+++ b/block/vpc.c
|
|
|
958e1b |
@@ -193,7 +193,8 @@ static int vpc_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
958e1b |
goto fail;
|
|
|
958e1b |
}
|
|
|
958e1b |
if (strncmp(footer->creator, "conectix", 8)) {
|
|
|
958e1b |
- ret = -EMEDIUMTYPE;
|
|
|
958e1b |
+ error_setg(errp, "invalid VPC image");
|
|
|
958e1b |
+ ret = -EINVAL;
|
|
|
958e1b |
goto fail;
|
|
|
958e1b |
}
|
|
|
958e1b |
disk_type = VHD_FIXED;
|
|
|
958e1b |
--
|
|
|
958e1b |
1.7.1
|
|
|
958e1b |
|