Blame SOURCES/kvm-file-posix-Include-filename-in-locking-error-message.patch

7711c0
From 53e0ff897da0cac47f08e1cb49ab98823301fe3b Mon Sep 17 00:00:00 2001
7711c0
From: Max Reitz <mreitz@redhat.com>
7711c0
Date: Mon, 4 Feb 2019 20:42:02 +0100
7711c0
Subject: [PATCH 02/33] file-posix: Include filename in locking error message
7711c0
7711c0
RH-Author: Max Reitz <mreitz@redhat.com>
7711c0
Message-id: <20190204204207.18079-3-mreitz@redhat.com>
7711c0
Patchwork-id: 84221
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 2/7] file-posix: Include filename in locking error message
7711c0
Bugzilla: 1551486
7711c0
RH-Acked-by: John Snow <jsnow@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
7711c0
7711c0
From: Fam Zheng <famz@redhat.com>
7711c0
7711c0
Image locking errors happening at device initialization time doesn't say
7711c0
which file cannot be locked, for instance,
7711c0
7711c0
    -device scsi-disk,drive=drive-1: Failed to get shared "write" lock
7711c0
    Is another process using the image?
7711c0
7711c0
could refer to either the overlay image or its backing image.
7711c0
7711c0
Hoist the error_append_hint to the caller of raw_check_lock_bytes where
7711c0
file name is known, and include it in the error hint.
7711c0
7711c0
Signed-off-by: Fam Zheng <famz@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
(cherry picked from commit b857431d2abe3945b672b41f33690e9943a8752a)
7711c0
Signed-off-by: Max Reitz <mreitz@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 block/file-posix.c         | 10 +++---
7711c0
 tests/qemu-iotests/153.out | 76 +++++++++++++++++++++++-----------------------
7711c0
 tests/qemu-iotests/182.out |  2 +-
7711c0
 3 files changed, 45 insertions(+), 43 deletions(-)
7711c0
7711c0
diff --git a/block/file-posix.c b/block/file-posix.c
7711c0
index 7e6869d..c2403ba 100644
7711c0
--- a/block/file-posix.c
7711c0
+++ b/block/file-posix.c
7711c0
@@ -738,8 +738,6 @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
7711c0
                            "Failed to get \"%s\" lock",
7711c0
                            perm_name);
7711c0
                 g_free(perm_name);
7711c0
-                error_append_hint(errp,
7711c0
-                                  "Is another process using the image?\n");
7711c0
                 return ret;
7711c0
             }
7711c0
         }
7711c0
@@ -755,8 +753,6 @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
7711c0
                            "Failed to get shared \"%s\" lock",
7711c0
                            perm_name);
7711c0
                 g_free(perm_name);
7711c0
-                error_append_hint(errp,
7711c0
-                                  "Is another process using the image?\n");
7711c0
                 return ret;
7711c0
             }
7711c0
         }
7711c0
@@ -793,6 +789,9 @@ static int raw_handle_perm_lock(BlockDriverState *bs,
7711c0
             if (!ret) {
7711c0
                 return 0;
7711c0
             }
7711c0
+            error_append_hint(errp,
7711c0
+                              "Is another process using the image [%s]?\n",
7711c0
+                              bs->filename);
7711c0
         }
7711c0
         op = RAW_PL_ABORT;
7711c0
         /* fall through to unlock bytes. */
7711c0
@@ -2169,6 +2168,9 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
7711c0
     /* Step two: Check that nobody else has taken conflicting locks */
7711c0
     result = raw_check_lock_bytes(fd, perm, shared, errp);
7711c0
     if (result < 0) {
7711c0
+        error_append_hint(errp,
7711c0
+                          "Is another process using the image [%s]?\n",
7711c0
+                          file_opts->filename);
7711c0
         goto out_unlock;
7711c0
     }
7711c0
 
7711c0
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
7711c0
index 93eaf10..8842548 100644
7711c0
--- a/tests/qemu-iotests/153.out
7711c0
+++ b/tests/qemu-iotests/153.out
7711c0
@@ -12,11 +12,11 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
7711c0
 
7711c0
 == Launching another QEMU, opts: '' ==
7711c0
 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Launching another QEMU, opts: 'read-only=on' ==
7711c0
 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,read-only=on: Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Launching another QEMU, opts: 'read-only=on,force-share=on' ==
7711c0
 
7711c0
@@ -24,77 +24,77 @@ Is another process using the image?
7711c0
 
7711c0
 _qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_io_wrapper -c open  TEST_DIR/t.qcow2 -c read 0 512
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 no file open, try 'help open'
7711c0
 
7711c0
 _qemu_io_wrapper -c open -r  TEST_DIR/t.qcow2 -c read 0 512
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 no file open, try 'help open'
7711c0
 
7711c0
 _qemu_img_wrapper info TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper check TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper map TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper amend -o  TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper commit TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper dd if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 count=1
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
7711c0
 qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 file format: IMGFMT
7711c0
 
7711c0
 == Running utility commands -U ==
7711c0
@@ -132,7 +132,7 @@ Try 'qemu-img --help' for more information
7711c0
 
7711c0
 _qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
7711c0
 
7711c0
@@ -157,7 +157,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
7711c0
 
7711c0
 == Launching another QEMU, opts: '' ==
7711c0
 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Launching another QEMU, opts: 'read-only=on' ==
7711c0
 
7711c0
@@ -167,13 +167,13 @@ Is another process using the image?
7711c0
 
7711c0
 _qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
7711c0
 
7711c0
 _qemu_io_wrapper -c open  TEST_DIR/t.qcow2 -c read 0 512
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 no file open, try 'help open'
7711c0
 
7711c0
 _qemu_io_wrapper -c open -r  TEST_DIR/t.qcow2 -c read 0 512
7711c0
@@ -188,19 +188,19 @@ _qemu_img_wrapper map TEST_DIR/t.qcow2
7711c0
 
7711c0
 _qemu_img_wrapper amend -o  TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper commit TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
7711c0
 
7711c0
@@ -212,11 +212,11 @@ _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
7711c0
 
7711c0
 _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
7711c0
 qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 file format: IMGFMT
7711c0
 
7711c0
 == Running utility commands -U ==
7711c0
@@ -254,7 +254,7 @@ Try 'qemu-img --help' for more information
7711c0
 
7711c0
 _qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base
7711c0
 qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 _qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
7711c0
 
7711c0
@@ -372,17 +372,17 @@ Round done
7711c0
 
7711c0
 == Two devices with the same image (read-only=off - read-only=off) ==
7711c0
 QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Two devices with the same image (read-only=off - read-only=on) ==
7711c0
 QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=on: Failed to get shared "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Two devices with the same image (read-only=off - read-only=on,force-share=on) ==
7711c0
 
7711c0
 == Two devices with the same image (read-only=on - read-only=off) ==
7711c0
 QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Two devices with the same image (read-only=on - read-only=on) ==
7711c0
 
7711c0
@@ -403,13 +403,13 @@ Formatting 'TEST_DIR/t.IMGFMT.c', fmt=IMGFMT size=33554432 backing_file=TEST_DIR
7711c0
 
7711c0
 == Backing image also as an active device ==
7711c0
 QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Backing image also as an active device (ro) ==
7711c0
 
7711c0
 == Symbolic link ==
7711c0
 QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 
7711c0
 == Active commit to intermediate layer should work when base in use ==
7711c0
 {"return": {}}
7711c0
@@ -420,7 +420,7 @@ Adding drive
7711c0
 
7711c0
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 Creating overlay with qemu-img when the guest is running should be allowed
7711c0
 
7711c0
 _qemu_img_wrapper create -f qcow2 -b TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.overlay
7711c0
@@ -433,7 +433,7 @@ _qemu_img_wrapper info TEST_DIR/t.qcow2
7711c0
 
7711c0
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
7711c0
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 Closing the other
7711c0
 
7711c0
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
7711c0
diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out
7711c0
index 23a4dbf..f1463c8 100644
7711c0
--- a/tests/qemu-iotests/182.out
7711c0
+++ b/tests/qemu-iotests/182.out
7711c0
@@ -4,5 +4,5 @@ Starting QEMU
7711c0
 
7711c0
 Starting a second QEMU using the same image should fail
7711c0
 QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,id=drive0,file.locking=on: Failed to get "write" lock
7711c0
-Is another process using the image?
7711c0
+Is another process using the image [TEST_DIR/t.qcow2]?
7711c0
 *** done
7711c0
-- 
7711c0
1.8.3.1
7711c0