All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] block: report errno when flock fcntl fails
@ 2020-12-21 13:49 David Edmondson
  2020-12-21 13:49 ` [PATCH v2 1/2] " David Edmondson
  2020-12-21 13:49 ` [PATCH v2 2/2] tests: Collapse echoed JSON input to a single line David Edmondson
  0 siblings, 2 replies; 8+ messages in thread
From: David Edmondson @ 2020-12-21 13:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, David Edmondson, qemu-block, Max Reitz

As Kevin pointed out, adding the error reported by fcntl to the
reported error required updates to the tests.

When running the tests there were lots of failures due to output
comparison problems, such as:

@@ -6,7 +6,9 @@
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=SIZE
 { 'execute': 'qmp_capabilities' }
 {"return": {}}
-{'execute':'drive-mirror', 'arguments':{ 'device': 'src', 'target': 'TEST_DIR/t.IMGFMT', 'mode': 'existing', 'sync': 'full'}}
+{'execute':'drive-mirror', 'arguments':{
+            'device': 'src', 'target': 'TEST_DIR/t.IMGFMT',
+            'mode': 'existing', 'sync': 'full'}}
 WARNING: Image format was not specified for 'TEST_DIR/t.raw' and probing guessed raw.
          Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
          Specify the 'raw' format explicitly to remove the restrictions.

To avoid this, the second patch flattens the input command that will
be sent to the tool before it is echoed back for later comparison.

v2:
- Update the tests appropriately (Kevin).
- Removed qemu-trivial given that there was debate.
- Filter the input echoed before sending to qemu* during testing such
  that comparisons succeed.

David Edmondson (2):
  block: report errno when flock fcntl fails
  tests: Collapse echoed JSON input to a single line

 block/file-posix.c               | 20 ++++-----
 tests/qemu-iotests/153.out       | 76 ++++++++++++++++----------------
 tests/qemu-iotests/182.out       |  2 +-
 tests/qemu-iotests/common.filter |  6 +++
 tests/qemu-iotests/common.qemu   |  2 +-
 5 files changed, 56 insertions(+), 50 deletions(-)

-- 
2.29.2



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

* [PATCH v2 1/2] block: report errno when flock fcntl fails
  2020-12-21 13:49 [PATCH v2 0/2] block: report errno when flock fcntl fails David Edmondson
@ 2020-12-21 13:49 ` David Edmondson
  2020-12-22 14:31   ` Philippe Mathieu-Daudé
  2021-01-06  9:48   ` Max Reitz
  2020-12-21 13:49 ` [PATCH v2 2/2] tests: Collapse echoed JSON input to a single line David Edmondson
  1 sibling, 2 replies; 8+ messages in thread
From: David Edmondson @ 2020-12-21 13:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, David Edmondson, qemu-block, Max Reitz

When a call to fcntl(2) for the purpose of manipulating file locks
fails, report the error returned by fcntl.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
 block/file-posix.c         | 20 +++++-----
 tests/qemu-iotests/153.out | 76 +++++++++++++++++++-------------------
 tests/qemu-iotests/182.out |  2 +-
 3 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 9804681d5c..f866fc9742 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -836,7 +836,7 @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
         if ((perm_lock_bits & bit) && !(locked_perm & bit)) {
             ret = qemu_lock_fd(fd, off, 1, false);
             if (ret) {
-                error_setg(errp, "Failed to lock byte %d", off);
+                error_setg_errno(errp, -ret, "Failed to lock byte %d", off);
                 return ret;
             } else if (s) {
                 s->locked_perm |= bit;
@@ -844,7 +844,7 @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
         } else if (unlock && (locked_perm & bit) && !(perm_lock_bits & bit)) {
             ret = qemu_unlock_fd(fd, off, 1);
             if (ret) {
-                error_setg(errp, "Failed to unlock byte %d", off);
+                error_setg_errno(errp, -ret, "Failed to unlock byte %d", off);
                 return ret;
             } else if (s) {
                 s->locked_perm &= ~bit;
@@ -857,7 +857,7 @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
         if ((shared_perm_lock_bits & bit) && !(locked_shared_perm & bit)) {
             ret = qemu_lock_fd(fd, off, 1, false);
             if (ret) {
-                error_setg(errp, "Failed to lock byte %d", off);
+                error_setg_errno(errp, -ret, "Failed to lock byte %d", off);
                 return ret;
             } else if (s) {
                 s->locked_shared_perm |= bit;
@@ -866,7 +866,7 @@ static int raw_apply_lock_bytes(BDRVRawState *s, int fd,
                    !(shared_perm_lock_bits & bit)) {
             ret = qemu_unlock_fd(fd, off, 1);
             if (ret) {
-                error_setg(errp, "Failed to unlock byte %d", off);
+                error_setg_errno(errp, -ret, "Failed to unlock byte %d", off);
                 return ret;
             } else if (s) {
                 s->locked_shared_perm &= ~bit;
@@ -890,9 +890,9 @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
             ret = qemu_lock_fd_test(fd, off, 1, true);
             if (ret) {
                 char *perm_name = bdrv_perm_names(p);
-                error_setg(errp,
-                           "Failed to get \"%s\" lock",
-                           perm_name);
+                error_setg_errno(errp, -ret,
+                                 "Failed to get \"%s\" lock",
+                                 perm_name);
                 g_free(perm_name);
                 return ret;
             }
@@ -905,9 +905,9 @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,
             ret = qemu_lock_fd_test(fd, off, 1, true);
             if (ret) {
                 char *perm_name = bdrv_perm_names(p);
-                error_setg(errp,
-                           "Failed to get shared \"%s\" lock",
-                           perm_name);
+                error_setg_errno(errp, -ret,
+                                 "Failed to get shared \"%s\" lock",
+                                 perm_name);
                 g_free(perm_name);
                 return ret;
             }
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index fcaa71aeee..c1f8494a63 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -11,11 +11,11 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
 == Launching QEMU, opts: '' ==
 
 == Launching another QEMU, opts: '' ==
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Launching another QEMU, opts: 'read-only=on' ==
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,read-only=on: Failed to get shared "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,read-only=on: Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Launching another QEMU, opts: 'read-only=on,force-share=on' ==
@@ -23,77 +23,77 @@ Is another process using the image [TEST_DIR/t.qcow2]?
 == Running utility commands  ==
 
 _qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_io_wrapper -c open  TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 no file open, try 'help open'
 
 _qemu_io_wrapper -c open -r  TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 no file open, try 'help open'
 
 _qemu_img_wrapper info TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper check TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper map TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper amend -o size=32M TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper commit TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper convert TEST_DIR/t.qcow2 TEST_DIR/t.qcow2.convert
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper dd if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 count=1
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
-qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 file format: IMGFMT
 backing file format: IMGFMT
@@ -132,7 +132,7 @@ qemu-img: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
@@ -158,7 +158,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432 backing_file=TEST_DIR/t
 == Launching QEMU, opts: 'read-only=on' ==
 
 == Launching another QEMU, opts: '' ==
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Launching another QEMU, opts: 'read-only=on' ==
@@ -168,13 +168,13 @@ Is another process using the image [TEST_DIR/t.qcow2]?
 == Running utility commands  ==
 
 _qemu_io_wrapper -c read 0 512 TEST_DIR/t.qcow2
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_io_wrapper -r -c read 0 512 TEST_DIR/t.qcow2
 
 _qemu_io_wrapper -c open  TEST_DIR/t.qcow2 -c read 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 no file open, try 'help open'
 
@@ -189,19 +189,19 @@ _qemu_img_wrapper compare TEST_DIR/t.qcow2 TEST_DIR/t.qcow2
 _qemu_img_wrapper map TEST_DIR/t.qcow2
 
 _qemu_img_wrapper amend -o size=32M TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper commit TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper resize TEST_DIR/t.qcow2 32M
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper rebase TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l TEST_DIR/t.qcow2
@@ -213,11 +213,11 @@ _qemu_img_wrapper dd if=TEST_DIR/t.qcow2 of=TEST_DIR/t.qcow2.convert bs=512 coun
 _qemu_img_wrapper bench -c 1 TEST_DIR/t.qcow2
 
 _qemu_img_wrapper bench -w -c 1 TEST_DIR/t.qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper create -f qcow2 TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
-qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-img: TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 file format: IMGFMT
 backing file format: IMGFMT
@@ -256,7 +256,7 @@ qemu-img: unrecognized option '-U'
 Try 'qemu-img --help' for more information
 
 _qemu_img_wrapper rebase -U TEST_DIR/t.qcow2 -b TEST_DIR/t.qcow2.base -F qcow2
-qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock
+qemu-img: Could not open 'TEST_DIR/t.qcow2': Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 _qemu_img_wrapper snapshot -l -U TEST_DIR/t.qcow2
@@ -377,17 +377,17 @@ qemu-img: Could not open 'TEST_DIR/t.qcow2': force-share=on can only be used wit
 Round done
 
 == Two devices with the same image (read-only=off - read-only=off) ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Two devices with the same image (read-only=off - read-only=on) ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=on: Failed to get shared "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=on: Failed to get shared "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Two devices with the same image (read-only=off - read-only=on,force-share=on) ==
 
 == Two devices with the same image (read-only=on - read-only=off) ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2,read-only=off: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Two devices with the same image (read-only=on - read-only=on) ==
@@ -408,13 +408,13 @@ Formatting 'TEST_DIR/t.IMGFMT.c', fmt=IMGFMT size=33554432 backing_file=TEST_DIR
 == Two devices sharing the same file in backing chain ==
 
 == Backing image also as an active device ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Backing image also as an active device (ro) ==
 
 == Symbolic link ==
-QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
+QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 == Active commit to intermediate layer should work when base in use ==
@@ -429,7 +429,7 @@ Adding drive
 {"return": "OKrn"}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 Creating overlay with qemu-img when the guest is running should be allowed
 
@@ -450,7 +450,7 @@ _qemu_img_wrapper info TEST_DIR/t.qcow2
 {"return": ""}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
-qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
+qemu-io: can't open device TEST_DIR/t.qcow2: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 Closing the other
 { 'execute': 'human-monitor-command', 'arguments': { 'command-line': 'drive_del d1' } }
diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out
index ce23340670..63b7ecb325 100644
--- a/tests/qemu-iotests/182.out
+++ b/tests/qemu-iotests/182.out
@@ -3,7 +3,7 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=33554432
 Starting QEMU
 
 Starting a second QEMU using the same image should fail
-QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,id=drive0,file.locking=on: Failed to get "write" lock
+QEMU_PROG: -drive file=TEST_DIR/t.qcow2,if=none,id=drive0,file.locking=on: Failed to get "write" lock: Resource temporarily unavailable
 Is another process using the image [TEST_DIR/t.qcow2]?
 
 === Testing reopen ===
-- 
2.29.2



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

* [PATCH v2 2/2] tests: Collapse echoed JSON input to a single line
  2020-12-21 13:49 [PATCH v2 0/2] block: report errno when flock fcntl fails David Edmondson
  2020-12-21 13:49 ` [PATCH v2 1/2] " David Edmondson
@ 2020-12-21 13:49 ` David Edmondson
  2021-01-06  9:49   ` Max Reitz
  1 sibling, 1 reply; 8+ messages in thread
From: David Edmondson @ 2020-12-21 13:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, David Edmondson, qemu-block, Max Reitz

When sending JSON to running qemu, qemu-io, etc. instances, flatten
the echoed input to a single line to ensure that comparisons with the
expected input (which is always a single line) are successful.

Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
 tests/qemu-iotests/common.filter | 6 ++++++
 tests/qemu-iotests/common.qemu   | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 172ea5752e..d51df59769 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -332,5 +332,11 @@ for fname in fnames:
 sys.stdout.write(result)'
 }
 
+# Convert multi-line input to a single line.
+_filter_collapse_lines()
+{
+    (tr -d '\n'; echo)
+}
+
 # make sure this script returns success
 true
diff --git a/tests/qemu-iotests/common.qemu b/tests/qemu-iotests/common.qemu
index de680cf1c7..9604c78b8a 100644
--- a/tests/qemu-iotests/common.qemu
+++ b/tests/qemu-iotests/common.qemu
@@ -159,7 +159,7 @@ _send_qemu_cmd()
     # input back to output); decide based on leading '{'
     if [ -z "$silent" ] && [ -z "$mismatch_only" ] &&
             [ "$cmd" != "${cmd#\{}" ]; then
-        echo "${cmd}" | _filter_testdir | _filter_imgfmt
+        echo "${cmd}" | _filter_testdir | _filter_imgfmt | _filter_collapse_lines
     fi
     while [ ${count} -gt 0 ]
     do
-- 
2.29.2



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

* Re: [PATCH v2 1/2] block: report errno when flock fcntl fails
  2020-12-21 13:49 ` [PATCH v2 1/2] " David Edmondson
@ 2020-12-22 14:31   ` Philippe Mathieu-Daudé
  2021-01-06  9:48   ` Max Reitz
  1 sibling, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-12-22 14:31 UTC (permalink / raw)
  To: David Edmondson, qemu-devel; +Cc: Kevin Wolf, qemu-block, Max Reitz

On 12/21/20 2:49 PM, David Edmondson wrote:
> When a call to fcntl(2) for the purpose of manipulating file locks
> fails, report the error returned by fcntl.
> 
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
>  block/file-posix.c         | 20 +++++-----
>  tests/qemu-iotests/153.out | 76 +++++++++++++++++++-------------------
>  tests/qemu-iotests/182.out |  2 +-
>  3 files changed, 49 insertions(+), 49 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


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

* Re: [PATCH v2 1/2] block: report errno when flock fcntl fails
  2020-12-21 13:49 ` [PATCH v2 1/2] " David Edmondson
  2020-12-22 14:31   ` Philippe Mathieu-Daudé
@ 2021-01-06  9:48   ` Max Reitz
  2021-01-06 11:58     ` David Edmondson
  1 sibling, 1 reply; 8+ messages in thread
From: Max Reitz @ 2021-01-06  9:48 UTC (permalink / raw)
  To: David Edmondson, qemu-devel; +Cc: Kevin Wolf, qemu-block

On 21.12.20 14:49, David Edmondson wrote:
> When a call to fcntl(2) for the purpose of manipulating file locks
> fails, report the error returned by fcntl.
> 
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
>   block/file-posix.c         | 20 +++++-----
>   tests/qemu-iotests/153.out | 76 +++++++++++++++++++-------------------
>   tests/qemu-iotests/182.out |  2 +-
>   3 files changed, 49 insertions(+), 49 deletions(-)

tests/qemu-iotests/296.out also needs to be adjusted (found by grepping 
for 'Failed to get').

And now I might as well add this idea: EAGAIN is the most common errno 
when flock fcntl fails, so would it make sense to generate a custom 
error message then?  I’d like to think we could do better than “Resource 
temporarily unavailable”, e.g. perhaps “Lock is already taken”.

OTOH, “Resource temporarily unavailable” isn’t *that* bad, so if you 
don’t want to, I won’t push for it.

Max



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

* Re: [PATCH v2 2/2] tests: Collapse echoed JSON input to a single line
  2020-12-21 13:49 ` [PATCH v2 2/2] tests: Collapse echoed JSON input to a single line David Edmondson
@ 2021-01-06  9:49   ` Max Reitz
  2021-01-06 17:20     ` David Edmondson
  0 siblings, 1 reply; 8+ messages in thread
From: Max Reitz @ 2021-01-06  9:49 UTC (permalink / raw)
  To: David Edmondson, qemu-devel; +Cc: Kevin Wolf, qemu-block

On 21.12.20 14:49, David Edmondson wrote:
> When sending JSON to running qemu, qemu-io, etc. instances, flatten
> the echoed input to a single line to ensure that comparisons with the
> expected input (which is always a single line) are successful.
> 
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
>   tests/qemu-iotests/common.filter | 6 ++++++
>   tests/qemu-iotests/common.qemu   | 2 +-
>   2 files changed, 7 insertions(+), 1 deletion(-)

I think this is superseded now by commit 0e72078128229bf9efb54.

Max



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

* Re: [PATCH v2 1/2] block: report errno when flock fcntl fails
  2021-01-06  9:48   ` Max Reitz
@ 2021-01-06 11:58     ` David Edmondson
  0 siblings, 0 replies; 8+ messages in thread
From: David Edmondson @ 2021-01-06 11:58 UTC (permalink / raw)
  To: Max Reitz; +Cc: David Edmondson, Kevin Wolf, qemu-devel, qemu-block

On Wednesday, 2021-01-06 at 10:48:09 +01, Max Reitz wrote:

> On 21.12.20 14:49, David Edmondson wrote:
>> When a call to fcntl(2) for the purpose of manipulating file locks
>> fails, report the error returned by fcntl.
>> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
>> ---
>>   block/file-posix.c         | 20 +++++-----
>>   tests/qemu-iotests/153.out | 76 +++++++++++++++++++-------------------
>>   tests/qemu-iotests/182.out |  2 +-
>>   3 files changed, 49 insertions(+), 49 deletions(-)
>
> tests/qemu-iotests/296.out also needs to be adjusted (found by
> grepping for 'Failed to get').

I will check and add it.

> And now I might as well add this idea: EAGAIN is the most common errno
> when flock fcntl fails, so would it make sense to generate a custom
> error message then?  I’d like to think we could do better than
> “Resource temporarily unavailable”, e.g. perhaps “Lock is already
> taken”.

Kevin previously suggested that we should elide the detail in this
common case (please correct me if that's a misrepresentation), but there
didn't seem to be any consensus for that.

> OTOH, “Resource temporarily unavailable” isn’t *that* bad, so if you
> don’t want to, I won’t push for it.

Other than that it's just more code (which in general is not good), I
don't have a strong opinion.

dme.
-- 
Facts don't do what I want them to.


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

* Re: [PATCH v2 2/2] tests: Collapse echoed JSON input to a single line
  2021-01-06  9:49   ` Max Reitz
@ 2021-01-06 17:20     ` David Edmondson
  0 siblings, 0 replies; 8+ messages in thread
From: David Edmondson @ 2021-01-06 17:20 UTC (permalink / raw)
  To: Max Reitz; +Cc: David Edmondson, Kevin Wolf, qemu-devel, qemu-block

On Wednesday, 2021-01-06 at 10:49:06 +01, Max Reitz wrote:

> On 21.12.20 14:49, David Edmondson wrote:
>> When sending JSON to running qemu, qemu-io, etc. instances, flatten
>> the echoed input to a single line to ensure that comparisons with the
>> expected input (which is always a single line) are successful.
>> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
>> ---
>>   tests/qemu-iotests/common.filter | 6 ++++++
>>   tests/qemu-iotests/common.qemu   | 2 +-
>>   2 files changed, 7 insertions(+), 1 deletion(-)
>
> I think this is superseded now by commit 0e72078128229bf9efb54.

Yes, agreed.

dme.
-- 
Here I am, a rabbit-hearted girl.


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

end of thread, other threads:[~2021-01-06 17:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-21 13:49 [PATCH v2 0/2] block: report errno when flock fcntl fails David Edmondson
2020-12-21 13:49 ` [PATCH v2 1/2] " David Edmondson
2020-12-22 14:31   ` Philippe Mathieu-Daudé
2021-01-06  9:48   ` Max Reitz
2021-01-06 11:58     ` David Edmondson
2020-12-21 13:49 ` [PATCH v2 2/2] tests: Collapse echoed JSON input to a single line David Edmondson
2021-01-06  9:49   ` Max Reitz
2021-01-06 17:20     ` David Edmondson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.