[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen staging] block: Error if backing file fails during creation without -u



commit add8200dd14041d059cc376eff91461fadd93ec5
Author:     Eric Blake <eblake@xxxxxxxxxx>
AuthorDate: Mon Jul 6 15:39:50 2020 -0500
Commit:     Kevin Wolf <kwolf@xxxxxxxxxx>
CommitDate: Tue Jul 14 15:18:59 2020 +0200

    block: Error if backing file fails during creation without -u
    
    Back in commit 6e6e55f5 (Jul 2017, v2.10), we tweaked the code to warn
    if the backing file could not be opened but the user gave a size,
    unless the user also passes the -u option to bypass the open of the
    backing file.  As one common reason for failure to open the backing
    file is when there is mismatch in the requested backing format in
    relation to what the backing file actually contains, we actually want
    to open the backing file and ensure that it has the right format in as
    many cases as possible.  iotest 301 for qcow demonstrates how
    detecting explicit format mismatch is useful to prevent the creation
    of an image that would probe differently than the user requested.  Now
    is the time to finally turn the warning an error, as promised.
    
    Note that the original warning was added prior to our documentation of
    an official deprecation policy (eb22aeca, also Jul 2017), and because
    the warning didn't mention the word "deprecated", we never actually
    remembered to document it as such.  But the warning has been around
    long enough that I don't see prolonging it another two releases.
    
    Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
    Message-Id: <20200706203954.341758-7-eblake@xxxxxxxxxx>
    Signed-off-by: Kevin Wolf <kwolf@xxxxxxxxxx>
---
 block.c                    | 12 ++----------
 docs/system/deprecated.rst | 12 ++++++++++++
 tests/qemu-iotests/111.out |  2 +-
 tests/qemu-iotests/301.out | 13 +++++--------
 4 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/block.c b/block.c
index 98cad57cda..6925e57d7c 100644
--- a/block.c
+++ b/block.c
@@ -6128,16 +6128,8 @@ void bdrv_img_create(const char *filename, const char 
*fmt,
         bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
                        &local_err);
         g_free(full_backing);
-        if (!bs && size != -1) {
-            /* Couldn't open BS, but we have a size, so it's nonfatal */
-            warn_reportf_err(local_err,
-                            "Could not verify backing image. "
-                            "This may become an error in future versions.\n");
-            local_err = NULL;
-        } else if (!bs) {
-            /* Couldn't open bs, do not have size */
-            error_append_hint(&local_err,
-                              "Could not open backing image to determine 
size.\n");
+        if (!bs) {
+            error_append_hint(&local_err, "Could not open backing image.\n");
             goto out;
         } else {
             if (size == -1) {
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index aa9fdc8c53..c014e049c3 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -555,6 +555,18 @@ can be rewritten as::
 All options specified in ``-o`` are image creation options, so
 they are now rejected when used with ``-n`` to skip image creation.
 
+
+``qemu-img create -b bad file $size`` (removed in 5.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+When creating an image with a backing file that could not be opened,
+``qemu-img create`` used to issue a warning about the failure but
+proceed with the image creation if an explicit size was provided.
+However, as the ``-u`` option exists for this purpose, it is safer to
+enforce that any failure to open the backing image (including if the
+backing file is missing or an incorrect format was specified) is an
+error when ``-u`` is not used.
+
 Command line options
 --------------------
 
diff --git a/tests/qemu-iotests/111.out b/tests/qemu-iotests/111.out
index 5279c462fc..ba034e5c58 100644
--- a/tests/qemu-iotests/111.out
+++ b/tests/qemu-iotests/111.out
@@ -1,4 +1,4 @@
 QA output created by 111
 qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.inexistent': No 
such file or directory
-Could not open backing image to determine size.
+Could not open backing image.
 *** done
diff --git a/tests/qemu-iotests/301.out b/tests/qemu-iotests/301.out
index adaf11d42d..281a16d87a 100644
--- a/tests/qemu-iotests/301.out
+++ b/tests/qemu-iotests/301.out
@@ -17,18 +17,15 @@ backing file: TEST_DIR/t.IMGFMT.base
 
 == mismatched command line detection ==
 qemu-img: TEST_DIR/t.IMGFMT: invalid VMDK image descriptor
-Could not open backing image to determine size.
-qemu-img: warning: Could not verify backing image. This may become an error in 
future versions.
-invalid VMDK image descriptor
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 
backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=vmdk
+Could not open backing image.
+qemu-img: TEST_DIR/t.IMGFMT: invalid VMDK image descriptor
+Could not open backing image.
 
 qemu-img: TEST_DIR/t.IMGFMT: Image creation needs a size parameter
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 
backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=vmdk
 
-qemu-img: warning: Could not verify backing image. This may become an error in 
future versions.
-Unknown driver 'garbage'
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 
backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=garbage
-qemu-img: TEST_DIR/t.IMGFMT: unrecognized backing format 'garbage'
+qemu-img: TEST_DIR/t.IMGFMT: Unknown driver 'garbage'
+Could not open backing image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 
backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=garbage
 qemu-img: TEST_DIR/t.IMGFMT: unrecognized backing format 'garbage'
 image: TEST_DIR/t.IMGFMT
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.