Skip to contentSkip to conversation

tests/qtest/vhost-user-blk-test: Check whether qemu-storage-daemon is available

PATCH In review Thomas Huth 3 participants 4 messages Aug 11, 2021 – Oct 14, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests/qtest/vhost-user-blk-test: Check whether qemu-storage-daemon is available

The vhost-user-blk-test currently hangs if QTEST_QEMU_STORAGE_DAEMON_BINARY points to a non-existing binary. Let's improve this situation by checking for the availability of the binary first, so we can fail gracefully if it is not accessible.

---
 tests/qtest/vhost-user-blk-test.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/qtest/vhost-user-blk-test.c +8 -0
index 8796c74ca4..6f108a1b62 100644
@@ -789,6 +789,14 @@ static const char *qtest_qemu_storage_daemon_binary(void)
         exit(0);
     }
 
+    /* If we've got a path to the binary, check whether we can access it */
+    if (strchr(qemu_storage_daemon_bin, '/') &&
+        access(qemu_storage_daemon_bin, X_OK) != 0) {
+        fprintf(stderr, "ERROR: '%s' is not accessible\n",
+                qemu_storage_daemon_bin);
+        exit(1);
+    }
+
     return qemu_storage_daemon_bin;
 }
 
Signature · 1 line
2.27.0
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · Thomas Huth

The vhost-user-blk-test currently hangs if QTEST_QEMU_STORAGE_DAEMON_BINARY points to a non-existing binary. Let's improve this situation by checking for the availability of the binary first, so we can fail gracefully if it is not accessible.

I manually removed ./storage-daemon/qemu-storage-daemon and re-ran qos-test. The test errored-out without hanging.

#2 lore raw
In reply to Thomas Huth
Quoted 16 lines · Thomas Huth

The vhost-user-blk-test currently hangs if QTEST_QEMU_STORAGE_DAEMON_BINARY points to a non-existing binary. Let's improve this situation by checking for the availability of the binary first, so we can fail gracefully if it is not accessible.

---
 tests/qtest/vhost-user-blk-test.c | 8 ++++++++
 1 file changed, 8 insertions(+)
tests/qtest/vhost-user-blk-test.c +0 -0
index 8796c74ca4..6f108a1b62 100644

tests/qtest/vhost-user-blk-test.c static const char *qtest_qemu_storage_daemon_binary(void) · line 798

Quoted 10 lines
tests/qtest/vhost-user-blk-test.c +7 -0
@@ -789,6 +789,14 @@ static const char *qtest_qemu_storage_daemon_binary(void)
         exit(0);
     }
 
+    /* If we've got a path to the binary, check whether we can access it */
+    if (strchr(qemu_storage_daemon_bin, '/') &&
+        access(qemu_storage_daemon_bin, X_OK) != 0) {
+        fprintf(stderr, "ERROR: '%s' is not accessible\n",
+                qemu_storage_daemon_bin);
+        exit(1);
+    }

It makes sense not to bother starting the test if the binary isn't even present, but why does the test hang? Shouldn't QEMU cleanly exit rather than hanging if it turns out that it can't contact the daemon ?

-- PMM

#3 lore raw
Quoted 20 lines · Peter Maydell
Quoted 19 lines · Thomas Huth

The vhost-user-blk-test currently hangs if QTEST_QEMU_STORAGE_DAEMON_BINARY points to a non-existing binary. Let's improve this situation by checking for the availability of the binary first, so we can fail gracefully if it is not accessible.

---
  tests/qtest/vhost-user-blk-test.c | 8 ++++++++
  1 file changed, 8 insertions(+)
tests/qtest/vhost-user-blk-test.c +0 -0
index 8796c74ca4..6f108a1b62 100644
@@ -789,6 +789,14 @@ static const char *qtest_qemu_storage_daemon_binary(void)
          exit(0);
      }
 
Quoted 12 lines

tests/qtest/vhost-user-blk-test.c static const char *qtest_qemu_storage_daemon_binary(void) · line 798

Quoted 7 lines
tests/qtest/vhost-user-blk-test.c +7 -0
+    /* If we've got a path to the binary, check whether we can access it */
+    if (strchr(qemu_storage_daemon_bin, '/') &&
+        access(qemu_storage_daemon_bin, X_OK) != 0) {
+        fprintf(stderr, "ERROR: '%s' is not accessible\n",
+                qemu_storage_daemon_bin);
+        exit(1);
+    }

It makes sense not to bother starting the test if the binary isn't even present, but why does the test hang? Shouldn't QEMU cleanly exit rather than hanging if it turns out that it can't contact the daemon ?

Sorry for the late reply: I think this happens due to the way we run that qtest: The test program forks to run the storage daemon. If that daemon binary is not available, or exits prematurely, the original program does not notice and hangs. Maybe we should intercept the SIGCHLD signal for such cases?

Thomas