提交 a55448b3 编写于 作者: M Max Reitz 提交者: Kevin Wolf

qapi: Drop QERR_UNKNOWN_BLOCK_FORMAT_FEATURE

Just specifying a custom string is simpler in basically all places that
used it, and in addition, specifying the BB or node name is something we
generally do not do in other error messages when opening a BDS, so we
should not do it here.

This changes the output for iotest 036 (to the better, in my opinion),
so the reference output needs to be changed accordingly.
Signed-off-by: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 da31d594
...@@ -121,11 +121,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -121,11 +121,7 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
goto fail; goto fail;
} }
if (header.version != QCOW_VERSION) { if (header.version != QCOW_VERSION) {
char version[64]; error_setg(errp, "Unsupported qcow version %" PRIu32, header.version);
snprintf(version, sizeof(version), "QCOW version %" PRIu32,
header.version);
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "qcow", version);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} }
......
...@@ -198,22 +198,8 @@ static void cleanup_unknown_header_ext(BlockDriverState *bs) ...@@ -198,22 +198,8 @@ static void cleanup_unknown_header_ext(BlockDriverState *bs)
} }
} }
static void GCC_FMT_ATTR(3, 4) report_unsupported(BlockDriverState *bs, static void report_unsupported_feature(Error **errp, Qcow2Feature *table,
Error **errp, const char *fmt, ...) uint64_t mask)
{
char msg[64];
va_list ap;
va_start(ap, fmt);
vsnprintf(msg, sizeof(msg), fmt, ap);
va_end(ap);
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "qcow2", msg);
}
static void report_unsupported_feature(BlockDriverState *bs,
Error **errp, Qcow2Feature *table, uint64_t mask)
{ {
char *features = g_strdup(""); char *features = g_strdup("");
char *old; char *old;
...@@ -238,7 +224,7 @@ static void report_unsupported_feature(BlockDriverState *bs, ...@@ -238,7 +224,7 @@ static void report_unsupported_feature(BlockDriverState *bs,
g_free(old); g_free(old);
} }
report_unsupported(bs, errp, "%s", features); error_setg(errp, "Unsupported qcow2 feature(s): %s", features);
g_free(features); g_free(features);
} }
...@@ -855,7 +841,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -855,7 +841,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
goto fail; goto fail;
} }
if (header.version < 2 || header.version > 3) { if (header.version < 2 || header.version > 3) {
report_unsupported(bs, errp, "QCOW version %" PRIu32, header.version); error_setg(errp, "Unsupported qcow2 version %" PRIu32, header.version);
ret = -ENOTSUP; ret = -ENOTSUP;
goto fail; goto fail;
} }
...@@ -935,7 +921,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -935,7 +921,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
void *feature_table = NULL; void *feature_table = NULL;
qcow2_read_extensions(bs, header.header_length, ext_end, qcow2_read_extensions(bs, header.header_length, ext_end,
&feature_table, NULL); &feature_table, NULL);
report_unsupported_feature(bs, errp, feature_table, report_unsupported_feature(errp, feature_table,
s->incompatible_features & s->incompatible_features &
~QCOW2_INCOMPAT_MASK); ~QCOW2_INCOMPAT_MASK);
ret = -ENOTSUP; ret = -ENOTSUP;
......
...@@ -400,11 +400,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags, ...@@ -400,11 +400,8 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
} }
if (s->header.features & ~QED_FEATURE_MASK) { if (s->header.features & ~QED_FEATURE_MASK) {
/* image uses unsupported feature bits */ /* image uses unsupported feature bits */
char buf[64]; error_setg(errp, "Unsupported QED features: %" PRIx64,
snprintf(buf, sizeof(buf), "%" PRIx64, s->header.features & ~QED_FEATURE_MASK);
s->header.features & ~QED_FEATURE_MASK);
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "QED", buf);
return -ENOTSUP; return -ENOTSUP;
} }
if (!qed_is_cluster_size_valid(s->header.cluster_size)) { if (!qed_is_cluster_size_valid(s->header.cluster_size)) {
......
...@@ -661,11 +661,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs, ...@@ -661,11 +661,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
compressed = compressed =
le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE; le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE;
if (le32_to_cpu(header.version) > 3) { if (le32_to_cpu(header.version) > 3) {
char buf[64]; error_setg(errp, "Unsupported VMDK version %" PRIu32,
snprintf(buf, sizeof(buf), "VMDK version %" PRId32, le32_to_cpu(header.version));
le32_to_cpu(header.version));
error_setg(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
bdrv_get_device_or_node_name(bs), "vmdk", buf);
return -ENOTSUP; return -ENOTSUP;
} else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR) && } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR) &&
!compressed) { !compressed) {
......
...@@ -100,9 +100,6 @@ ...@@ -100,9 +100,6 @@
#define QERR_UNDEFINED_ERROR \ #define QERR_UNDEFINED_ERROR \
"An undefined error has occurred" "An undefined error has occurred"
#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
"'%s' uses a %s feature which is not supported by this qemu version: %s"
#define QERR_UNSUPPORTED \ #define QERR_UNSUPPORTED \
"this feature or command is not currently supported" "this feature or command is not currently supported"
......
...@@ -22,18 +22,18 @@ autoclear_features 0x0 ...@@ -22,18 +22,18 @@ autoclear_features 0x0
refcount_order 4 refcount_order 4
header_length 104 header_length 104
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Unknown incompatible feature: 8000000000000000 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Test feature qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature
=== Image with multiple incompatible feature bits === === Image with multiple incompatible feature bits ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Unknown incompatible feature: e000000000000000 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: e000000000000000
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Test feature, Unknown incompatible feature: 6000000000000000 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: 6000000000000000
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: Test feature, Unknown incompatible feature: c000000000000000 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature, Unknown incompatible feature: c000000000000000
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: test1, test2, Unknown incompatible feature: 8000000000000000 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, Unknown incompatible feature: 8000000000000000
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: test1, test2, test3 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test1, test2, test3
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': 'image' uses a IMGFMT feature which is not supported by this qemu version: test2, Unknown incompatible feature: a000000000000000 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): test2, Unknown incompatible feature: a000000000000000
=== Create image with unknown autoclear feature bit === === Create image with unknown autoclear feature bit ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册