* [Qemu-devel] [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features
@ 2011-02-10 11:18 Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 1/4] qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE Kevin Wolf
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Kevin Wolf @ 2011-02-10 11:18 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha, lcapitulino
With 0.15 we'll most likely get some incompatible image format extensions. This
series prepares 0.14 to output more helpful messages if it stumbles over a too
new image file.
Kevin Wolf (4):
qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE
qcow2: Report error for version > 2
qed: Report error for unsupported features
qemu-img: Improve error messages for failed bdrv_open
block/qcow2.c | 13 +++++++++++--
block/qed.c | 9 ++++++++-
qemu-img.c | 10 +++++++---
qerror.c | 5 +++++
qerror.h | 3 +++
5 files changed, 34 insertions(+), 6 deletions(-)
--
1.7.2.3
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 1/4] qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE
2011-02-10 11:18 [Qemu-devel] [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Kevin Wolf
@ 2011-02-10 11:18 ` Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 2/4] qcow2: Report error for version > 2 Kevin Wolf
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2011-02-10 11:18 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha, lcapitulino
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qerror.c | 5 +++++
qerror.h | 3 +++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/qerror.c b/qerror.c
index 9d0cdeb..4855604 100644
--- a/qerror.c
+++ b/qerror.c
@@ -201,6 +201,11 @@ static const QErrorStringTable qerror_table[] = {
.desc = "An undefined error has ocurred",
},
{
+ .error_fmt = QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+ .desc = "'%(device)' uses a %(format) feature which is not "
+ "supported by this qemu version: %(feature)",
+ },
+ {
.error_fmt = QERR_VNC_SERVER_FAILED,
.desc = "Could not start VNC server on %(target)",
},
diff --git a/qerror.h b/qerror.h
index b0f69da..f732d45 100644
--- a/qerror.h
+++ b/qerror.h
@@ -165,6 +165,9 @@ QError *qobject_to_qerror(const QObject *obj);
#define QERR_UNDEFINED_ERROR \
"{ 'class': 'UndefinedError', 'data': {} }"
+#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
+ "{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
+
#define QERR_VNC_SERVER_FAILED \
"{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }"
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 2/4] qcow2: Report error for version > 2
2011-02-10 11:18 [Qemu-devel] [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 1/4] qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE Kevin Wolf
@ 2011-02-10 11:18 ` Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 3/4] qed: Report error for unsupported features Kevin Wolf
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2011-02-10 11:18 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha, lcapitulino
The qcow2 driver is now declared responsible for any QCOW image that has
version 2 or greater (before this, version 3 would be detected as raw).
For everything newer than version 2, an error is reported.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 551b3c2..75b8bec 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -28,6 +28,7 @@
#include "aes.h"
#include "block/qcow2.h"
#include "qemu-error.h"
+#include "qerror.h"
/*
Differences with QCOW:
@@ -59,7 +60,7 @@ static int qcow2_probe(const uint8_t *buf, int buf_size, const char *filename)
if (buf_size >= sizeof(QCowHeader) &&
be32_to_cpu(cow_header->magic) == QCOW_MAGIC &&
- be32_to_cpu(cow_header->version) == QCOW_VERSION)
+ be32_to_cpu(cow_header->version) >= QCOW_VERSION)
return 100;
else
return 0;
@@ -163,10 +164,18 @@ static int qcow2_open(BlockDriverState *bs, int flags)
be64_to_cpus(&header.snapshots_offset);
be32_to_cpus(&header.nb_snapshots);
- if (header.magic != QCOW_MAGIC || header.version != QCOW_VERSION) {
+ if (header.magic != QCOW_MAGIC) {
ret = -EINVAL;
goto fail;
}
+ if (header.version != QCOW_VERSION) {
+ char version[64];
+ snprintf(version, sizeof(version), "QCOW version %d", header.version);
+ qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+ bs->device_name, "qcow2", version);
+ ret = -ENOTSUP;
+ goto fail;
+ }
if (header.cluster_bits < MIN_CLUSTER_BITS ||
header.cluster_bits > MAX_CLUSTER_BITS) {
ret = -EINVAL;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 3/4] qed: Report error for unsupported features
2011-02-10 11:18 [Qemu-devel] [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 1/4] qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 2/4] qcow2: Report error for version > 2 Kevin Wolf
@ 2011-02-10 11:18 ` Kevin Wolf
2011-02-10 12:07 ` [Qemu-devel] " Stefan Hajnoczi
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 4/4] qemu-img: Improve error messages for failed bdrv_open Kevin Wolf
2011-02-10 12:14 ` [Qemu-devel] Re: [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Anthony Liguori
4 siblings, 1 reply; 7+ messages in thread
From: Kevin Wolf @ 2011-02-10 11:18 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha, lcapitulino
Instead of just returning -ENOTSUP, generate a more detailed error.
Unfortunately we don't have a helpful text for features that we don't know yet,
so just print the feature mask. It might be useful at least if someone asks for
help.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qed.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/block/qed.c b/block/qed.c
index 3273448..75ae244 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -14,6 +14,7 @@
#include "trace.h"
#include "qed.h"
+#include "qerror.h"
static void qed_aio_cancel(BlockDriverAIOCB *blockacb)
{
@@ -311,7 +312,13 @@ static int bdrv_qed_open(BlockDriverState *bs, int flags)
return -EINVAL;
}
if (s->header.features & ~QED_FEATURE_MASK) {
- return -ENOTSUP; /* image uses unsupported feature bits */
+ /* image uses unsupported feature bits */
+ char buf[64];
+ snprintf(buf, sizeof(buf), "%" PRIx64,
+ s->header.features & ~QED_FEATURE_MASK);
+ qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
+ bs->device_name, "QED", buf);
+ return -ENOTSUP;
}
if (!qed_is_cluster_size_valid(s->header.cluster_size)) {
return -EINVAL;
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2 4/4] qemu-img: Improve error messages for failed bdrv_open
2011-02-10 11:18 [Qemu-devel] [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Kevin Wolf
` (2 preceding siblings ...)
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 3/4] qed: Report error for unsupported features Kevin Wolf
@ 2011-02-10 11:18 ` Kevin Wolf
2011-02-10 12:14 ` [Qemu-devel] Re: [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Anthony Liguori
4 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2011-02-10 11:18 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, stefanha, lcapitulino
Output the error message string of the bdrv_open return code. Also set a
non-empty device name for the images because the unknown feature error message
includes it.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 4a37358..7e3cc4c 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -213,8 +213,9 @@ static BlockDriverState *bdrv_new_open(const char *filename,
BlockDriverState *bs;
BlockDriver *drv;
char password[256];
+ int ret;
- bs = bdrv_new("");
+ bs = bdrv_new("image");
if (fmt) {
drv = bdrv_find_format(fmt);
@@ -225,10 +226,13 @@ static BlockDriverState *bdrv_new_open(const char *filename,
} else {
drv = NULL;
}
- if (bdrv_open(bs, filename, flags, drv) < 0) {
- error_report("Could not open '%s'", filename);
+
+ ret = bdrv_open(bs, filename, flags, drv);
+ if (ret < 0) {
+ error_report("Could not open '%s': %s", filename, strerror(-ret));
goto fail;
}
+
if (bdrv_is_encrypted(bs)) {
printf("Disk image '%s' is encrypted.\n", filename);
if (read_password(password, sizeof(password)) < 0) {
--
1.7.2.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] Re: [PATCH v2 3/4] qed: Report error for unsupported features
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 3/4] qed: Report error for unsupported features Kevin Wolf
@ 2011-02-10 12:07 ` Stefan Hajnoczi
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2011-02-10 12:07 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel, lcapitulino
On Thu, Feb 10, 2011 at 11:18 AM, Kevin Wolf <kwolf@redhat.com> wrote:
> Instead of just returning -ENOTSUP, generate a more detailed error.
>
> Unfortunately we don't have a helpful text for features that we don't know yet,
> so just print the feature mask. It might be useful at least if someone asks for
> help.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/qed.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
Thanks!
Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] Re: [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features
2011-02-10 11:18 [Qemu-devel] [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Kevin Wolf
` (3 preceding siblings ...)
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 4/4] qemu-img: Improve error messages for failed bdrv_open Kevin Wolf
@ 2011-02-10 12:14 ` Anthony Liguori
4 siblings, 0 replies; 7+ messages in thread
From: Anthony Liguori @ 2011-02-10 12:14 UTC (permalink / raw)
To: Kevin Wolf; +Cc: stefanha, qemu-devel, lcapitulino
On 02/10/2011 12:18 PM, Kevin Wolf wrote:
> With 0.15 we'll most likely get some incompatible image format extensions. This
> series prepares 0.14 to output more helpful messages if it stumbles over a too
> new image file.
>
> Kevin Wolf (4):
> qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE
> qcow2: Report error for version> 2
> qed: Report error for unsupported features
> qemu-img: Improve error messages for failed bdrv_open
>
Whole series:
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
> block/qcow2.c | 13 +++++++++++--
> block/qed.c | 9 ++++++++-
> qemu-img.c | 10 +++++++---
> qerror.c | 5 +++++
> qerror.h | 3 +++
> 5 files changed, 34 insertions(+), 6 deletions(-)
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-02-10 12:15 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-10 11:18 [Qemu-devel] [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 1/4] qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 2/4] qcow2: Report error for version > 2 Kevin Wolf
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 3/4] qed: Report error for unsupported features Kevin Wolf
2011-02-10 12:07 ` [Qemu-devel] " Stefan Hajnoczi
2011-02-10 11:18 ` [Qemu-devel] [PATCH v2 4/4] qemu-img: Improve error messages for failed bdrv_open Kevin Wolf
2011-02-10 12:14 ` [Qemu-devel] Re: [PATCH 0.14/master v2 0/4] Error messages for unsupoorted image format features Anthony Liguori
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).