qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: allow best-effort query
@ 2015-10-26 18:12 John Snow
  2015-10-26 18:56 ` Eric Blake
  2015-10-26 21:18 ` Max Reitz
  0 siblings, 2 replies; 5+ messages in thread
From: John Snow @ 2015-10-26 18:12 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, John Snow, qemu-devel, mreitz

For more complex BDS trees that can be created under normal circumstances,
we lose the ability to issue query commands because of our inability to
re-construct the absolute filename.

Instead, omit this field when it is a problem and present as much information
as we can.

This will change the expected output in iotest 110, where we will now see a
json filename and the lack of an absolute filename instead of an error.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 block/qapi.c               | 10 ++++++----
 tests/qemu-iotests/110.out |  5 ++++-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index 355ba32..c4101d5 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -245,13 +245,15 @@ void bdrv_query_image_info(BlockDriverState *bs,
         info->has_backing_filename = true;
         bdrv_get_full_backing_filename(bs, backing_filename2, PATH_MAX, &err);
         if (err) {
-            error_propagate(errp, err);
-            qapi_free_ImageInfo(info);
+            /* Couldn't reconstruct that backing filename,
+             * So we'll skip this field, but apply a Best Effort to the query */
             g_free(backing_filename2);
-            return;
+            backing_filename2 = NULL;
+            error_free(err);
         }
 
-        if (strcmp(backing_filename, backing_filename2) != 0) {
+        if (backing_filename2 &&
+            strcmp(backing_filename, backing_filename2) != 0) {
             info->full_backing_filename =
                         g_strdup(backing_filename2);
             info->has_full_backing_filename = true;
diff --git a/tests/qemu-iotests/110.out b/tests/qemu-iotests/110.out
index 0270980..425485f 100644
--- a/tests/qemu-iotests/110.out
+++ b/tests/qemu-iotests/110.out
@@ -11,7 +11,10 @@ backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base)
 
 === Non-reconstructable filename ===
 
-qemu-img: Cannot use relative backing file names for 'json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio", "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "set-state.0.new_state": 42}}'
+image: json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio", "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "set-state.0.new_state": 42}}
+file format: IMGFMT
+virtual size: 64M (67108864 bytes)
+backing file: t.IMGFMT.base
 
 === Backing name is always relative to the backed image ===
 
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-26 22:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-26 18:12 [Qemu-devel] [PATCH] block: allow best-effort query John Snow
2015-10-26 18:56 ` Eric Blake
2015-10-26 21:18 ` Max Reitz
2015-10-26 21:34   ` John Snow
2015-10-26 22:22     ` Max Reitz

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).