Skip to contentSkip to conversation

tests/qtest: Enable running qtest on Windows

PATCH In review Bin Meng 7 participants 32 messages Oct 28, 2022 – Nov 25, 2022 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

v6 cover tests/qtest: Enable running qtest on Windows

In preparation to adding virtio-9p support on Windows, this series enables running qtest on Windows, so that we can run the virtio-9p tests on Windows to make sure it does not break accidently.

Changes in v6:
- drop patches that are already in Alex and Daniel's tree
- remove CONFIG_POSIX from meson.build
- include <qemu/sockets.h> in libqtest.c
- move documentation comments of qemu_send_full() from util/osdep.c
to qemu/sockets.h
- save the "exit_code" in struct QTestState
- new patch: "tests/qtest: device-plug-test: Reverse the usage of double/single quotes"
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"
- change to use qtest_wait_qemu() API
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

Changes in v5:
- restore to v1 version which does not touch the posix implementation
- Drop patches that are already merged

Changes in v3:
- Add a usleep(1) in the busy wait loop
- Drop the host test

Changes in v2:
- Introduce qemu_send_full() and use it
- Move the enabling of building qtests on Windows to a separate patch to keep bisectablity
- Call socket_init() unconditionally
- Add a missing CloseHandle() call
- Change to a busy wait after migration is canceled
- Change the timeout limit to 90 minutes
- new patch: "tests/qtest: Enable qtest build on Windows"

Bin Meng (8):
tests/qtest: Support libqtest to build and run on Windows tests/qtest: device-plug-test: Reverse the usage of double/single
quotes
tests/qtest: Use EXIT_FAILURE instead of magic number tests/qtest: libqtest: Introduce qtest_wait_qemu() tests/qtest: libqos: Do not build virtio-9p unconditionally tests/qtest: libqtest: Correct the timeout unit of blocking receive
calls for win32
.gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes tests/qtest: Enable qtest build on Windows

Xuzhou Cheng (3):
accel/qtest: Support qtest accelerator for Windows tests/qtest: Use send/recv for socket communication tests/qtest: migration-test: Make sure QEMU process "to" exited after
migration is canceled

 include/hw/core/cpu.h           |   1 +
 include/qemu/sockets.h          |  13 +++
 tests/qtest/libqtest.h          |   9 ++
 accel/dummy-cpus.c              |  14 ++-
 softmmu/cpus.c                  |   9 +-
 tests/qtest/dbus-vmstate-test.c |   2 +-
 tests/qtest/device-plug-test.c  |  16 ++--
 tests/qtest/libqmp.c            |   5 +-
 tests/qtest/libqtest.c          | 151 ++++++++++++++++++++++++++++----
 tests/qtest/migration-test.c    |   8 +-
 util/osdep.c                    |  22 +++++
 .gitlab-ci.d/windows.yml        |   4 +-
 accel/meson.build               |   2 +-
 accel/qtest/meson.build         |   3 +-
 tests/qtest/libqos/meson.build  |   6 +-
 tests/qtest/meson.build         |   6 --
 16 files changed, 221 insertions(+), 50 deletions(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v6 1/11 accel/qtest: Support qtest accelerator for Windows

From: Xuzhou Cheng <[email protected]>

Currently signal SIGIPI [=SIGUSR1] is used to kick the dummy CPU when qtest accelerator is used. However SIGUSR1 is unsupported on Windows. To support Windows, we add a QemuSemaphore CPUState::sem to kick the dummy CPU instead for Windows.

---

Changes in v6:
- remove CONFIG_POSIX from meson.build

Changes in v5:
- restore to v1 version which does not touch the posix implementation

 include/hw/core/cpu.h   |  1 +
 accel/dummy-cpus.c      | 14 ++++++++++++--
 softmmu/cpus.c          |  9 +++++----
 accel/meson.build       |  2 +-
 accel/qtest/meson.build |  3 +--
 5 files changed, 20 insertions(+), 9 deletions(-)
include/hw/core/cpu.h +1 -0
index f9b58773f7..8830546121 100644
@@ -333,6 +333,7 @@ struct CPUState {
     struct QemuThread *thread;
 #ifdef _WIN32
     HANDLE hThread;
+    QemuSemaphore sem;
 #endif
     int thread_id;
     bool running, has_waiter;
accel/dummy-cpus.c +12 -2
index 10429fdfb2..d6a1b8d0a2 100644
@@ -21,8 +21,6 @@
 static void *dummy_cpu_thread_fn(void *arg)
 {
     CPUState *cpu = arg;
-    sigset_t waitset;
-    int r;
 
     rcu_register_thread();
 
@@ -32,8 +30,13 @@ static void *dummy_cpu_thread_fn(void *arg)
     cpu->can_do_io = 1;
     current_cpu = cpu;
 
+#ifndef _WIN32
+    sigset_t waitset;
+    int r;
+
     sigemptyset(&waitset);
     sigaddset(&waitset, SIG_IPI);
+#endif
 
     /* signal CPU creation */
     cpu_thread_signal_created(cpu);
@@ -41,6 +44,7 @@ static void *dummy_cpu_thread_fn(void *arg)
 
     do {
         qemu_mutex_unlock_iothread();
+#ifndef _WIN32
         do {
             int sig;
             r = sigwait(&waitset, &sig);
@@ -49,6 +53,9 @@ static void *dummy_cpu_thread_fn(void *arg)
             perror("sigwait");
             exit(1);
         }
+#else
+        qemu_sem_wait(&cpu->sem);
+#endif
         qemu_mutex_lock_iothread();
         qemu_wait_io_event(cpu);
     } while (!cpu->unplug);
@@ -69,4 +76,7 @@ void dummy_start_vcpu_thread(CPUState *cpu)
              cpu->cpu_index);
     qemu_thread_create(cpu->thread, thread_name, dummy_cpu_thread_fn, cpu,
                        QEMU_THREAD_JOINABLE);
+#ifdef _WIN32
+    qemu_sem_init(&cpu->sem, 0);
+#endif
 }
softmmu/cpus.c +5 -4
index 61b27ff59d..9dd1a4dc17 100644
@@ -437,18 +437,19 @@ void qemu_wait_io_event(CPUState *cpu)
 
 void cpus_kick_thread(CPUState *cpu)
 {
-#ifndef _WIN32
-    int err;
-
     if (cpu->thread_kicked) {
         return;
     }
     cpu->thread_kicked = true;
-    err = pthread_kill(cpu->thread->thread, SIG_IPI);
+
+#ifndef _WIN32
+    int err = pthread_kill(cpu->thread->thread, SIG_IPI);
     if (err && err != ESRCH) {
         fprintf(stderr, "qemu:%s: %s", __func__, strerror(err));
         exit(1);
     }
+#else
+    qemu_sem_post(&cpu->sem);
 #endif
 }
 
accel/meson.build +1 -1
index b9a963cf80..259c35c4c8 100644
@@ -16,5 +16,5 @@ dummy_ss.add(files(
   'dummy-cpus.c',
 ))
 
-specific_ss.add_all(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'], if_true: dummy_ss)
+specific_ss.add_all(when: ['CONFIG_SOFTMMU'], if_true: dummy_ss)
 specific_ss.add_all(when: ['CONFIG_XEN'], if_true: dummy_ss)
accel/qtest/meson.build +1 -2
index 4c65600293..176d990ae1 100644
@@ -1,2 +1 @@
-qtest_module_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_POSIX'],
-                    if_true: files('qtest.c'))
+qtest_module_ss.add(when: ['CONFIG_SOFTMMU'], if_true: files('qtest.c'))
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH v6 2/11 tests/qtest: Use send/recv for socket communication

In reply to Bin Meng

From: Xuzhou Cheng <[email protected]>

Socket communication in the libqtest and libqmp codes uses read() and write() which work on any file descriptor on *nix, and sockets in *nix are an example of a file descriptor.

However sockets on Windows do not use *nix-style file descriptors, so read() and write() cannot be used on sockets on Windows. Switch over to use send() and recv() instead which work on both Windows and *nix.

---

Changes in v6:
- include <qemu/sockets.h> in libqtest.c
- move documentation comments of qemu_send_full() from util/osdep.c to qemu/sockets.h

Changes in v2:
- Introduce qemu_send_full() and use it

 include/qemu/sockets.h | 13 +++++++++++++
 tests/qtest/libqmp.c   |  5 +++--
 tests/qtest/libqtest.c |  5 +++--
 util/osdep.c           | 22 ++++++++++++++++++++++
 4 files changed, 41 insertions(+), 4 deletions(-)
include/qemu/sockets.h +13 -0
index 036745e586..61648f3f3c 100644
@@ -33,6 +33,19 @@ int qemu_socketpair(int domain, int type, int protocol, int sv[2]);
 #endif
 
 int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
+/*
+ * A variant of send(2) which handles partial send.
+ *
+ * Return the number of bytes transferred over the socket.
+ * Set errno if fewer than `count' bytes are sent.
+ *
+ * This function don't work with non-blocking socket's.
+ * Any of the possibilities with non-blocking socket's is bad:
+ *   - return a short write (then name is wrong)
+ *   - busy wait adding (errno == EAGAIN) to the loop
+ */
+ssize_t qemu_send_full(int s, const void *buf, size_t count)
+    G_GNUC_WARN_UNUSED_RESULT;
 int socket_set_cork(int fd, int v);
 int socket_set_nodelay(int fd);
 void qemu_socket_set_block(int fd);
tests/qtest/libqmp.c +3 -2
index ade26c15f0..2b08382e5d 100644
@@ -23,6 +23,7 @@
 #endif
 
 #include "qemu/cutils.h"
+#include "qemu/sockets.h"
 #include "qapi/error.h"
 #include "qapi/qmp/json-parser.h"
 #include "qapi/qmp/qjson.h"
@@ -36,7 +37,7 @@ typedef struct {
 
 static void socket_send(int fd, const char *buf, size_t size)
 {
-    size_t res = qemu_write_full(fd, buf, size);
+    ssize_t res = qemu_send_full(fd, buf, size);
 
     assert(res == size);
 }
@@ -69,7 +70,7 @@ QDict *qmp_fd_receive(int fd)
         ssize_t len;
         char c;
 
-        len = read(fd, &c, 1);
+        len = recv(fd, &c, 1, 0);
         if (len == -1 && errno == EINTR) {
             continue;
         }
tests/qtest/libqtest.c +3 -2
index b23eb3edc3..b01846fd98 100644
@@ -27,6 +27,7 @@
 #include "libqmp.h"
 #include "qemu/ctype.h"
 #include "qemu/cutils.h"
+#include "qemu/sockets.h"
 #include "qapi/qmp/qdict.h"
 #include "qapi/qmp/qjson.h"
 #include "qapi/qmp/qlist.h"
@@ -428,7 +429,7 @@ void qtest_quit(QTestState *s)
 
 static void socket_send(int fd, const char *buf, size_t size)
 {
-    size_t res = qemu_write_full(fd, buf, size);
+    ssize_t res = qemu_send_full(fd, buf, size);
 
     assert(res == size);
 }
@@ -460,7 +461,7 @@ static GString *qtest_client_socket_recv_line(QTestState *s)
         ssize_t len;
         char buffer[1024];
 
-        len = read(s->fd, buffer, sizeof(buffer));
+        len = recv(s->fd, buffer, sizeof(buffer), 0);
         if (len == -1 && errno == EINTR) {
             continue;
         }
util/osdep.c +22 -0
index 746d5f7d71..77c1a6c562 100644
@@ -502,6 +502,28 @@ int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
     return ret;
 }
 
+ssize_t qemu_send_full(int s, const void *buf, size_t count)
+{
+    ssize_t ret = 0;
+    ssize_t total = 0;
+
+    while (count) {
+        ret = send(s, buf, count, 0);
+        if (ret < 0) {
+            if (errno == EINTR) {
+                continue;
+            }
+            break;
+        }
+
+        count -= ret;
+        buf += ret;
+        total += ret;
+    }
+
+    return total;
+}
+
 void qemu_set_hw_version(const char *version)
 {
     hw_version = version;
Signature · 1 line
2.25.1
author
#3 lore raw

PATCH v6 3/11 tests/qtest: Support libqtest to build and run on Windows

In reply to Bin Meng

At present the libqtest codes were written to depend on several POSIX APIs, including fork(), kill() and waitpid(). Unfortunately these APIs are not available on Windows.

This commit implements the corresponding functionalities using win32 native APIs. With this change, all qtest cases can build successfully on a Windows host, and we can start qtest testing on Windows now.

---

Changes in v6:
- save the "exit_code" in struct QTestState

Changes in v2:
- Move the enabling of building qtests on Windows to a separate patch to keep bisectablity
- Call socket_init() unconditionally
- Add a missing CloseHandle() call

 tests/qtest/libqtest.c | 96 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 94 insertions(+), 2 deletions(-)
tests/qtest/libqtest.c +94 -2
index b01846fd98..d12a604d78 100644
@@ -16,9 +16,11 @@
 
 #include "qemu/osdep.h"
 
+#ifndef _WIN32
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <sys/un.h>
+#endif /* _WIN32 */
 #ifdef __linux__
 #include <sys/prctl.h>
 #endif /* __linux__ */
@@ -36,6 +38,16 @@
 #define MAX_IRQ 256
 #define SOCKET_TIMEOUT 50
 
+#ifndef _WIN32
+# define CMD_EXEC   "exec "
+# define DEV_STDERR "/dev/fd/2"
+# define DEV_NULL   "/dev/null"
+#else
+# define CMD_EXEC   ""
+# define DEV_STDERR "2"
+# define DEV_NULL   "nul"
+#endif
+
 typedef void (*QTestSendFn)(QTestState *s, const char *buf);
 typedef void (*ExternalSendFn)(void *s, const char *buf);
 typedef GString* (*QTestRecvFn)(QTestState *);
@@ -58,6 +70,9 @@ struct QTestState
     int qmp_fd;
     pid_t qemu_pid;  /* our child QEMU process */
     int wstatus;
+#ifdef _WIN32
+    DWORD exit_code;
+#endif
     int expected_status;
     bool big_endian;
     bool irq_level[MAX_IRQ];
@@ -119,10 +134,18 @@ bool qtest_probe_child(QTestState *s)
     pid_t pid = s->qemu_pid;
 
     if (pid != -1) {
+#ifndef _WIN32
         pid = waitpid(pid, &s->wstatus, WNOHANG);
         if (pid == 0) {
             return true;
         }
+#else
+        GetExitCodeProcess((HANDLE)pid, &s->exit_code);
+        if (s->exit_code == STILL_ACTIVE) {
+            return true;
+        }
+        CloseHandle((HANDLE)pid);
+#endif
         s->qemu_pid = -1;
     }
     return false;
@@ -136,13 +159,25 @@ void qtest_set_expected_status(QTestState *s, int status)
 void qtest_kill_qemu(QTestState *s)
 {
     pid_t pid = s->qemu_pid;
+#ifndef _WIN32
     int wstatus;
+#else
+    DWORD ret;
+#endif
 
     /* Skip wait if qtest_probe_child already reaped.  */
     if (pid != -1) {
+#ifndef _WIN32
         kill(pid, SIGTERM);
         TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0));
         assert(pid == s->qemu_pid);
+#else
+        TerminateProcess((HANDLE)pid, s->expected_status);
+        ret = WaitForSingleObject((HANDLE)pid, INFINITE);
+        assert(ret == WAIT_OBJECT_0);
+        GetExitCodeProcess((HANDLE)pid, &s->exit_code);
+        CloseHandle((HANDLE)pid);
+#endif
         s->qemu_pid = -1;
     }
 
@@ -150,6 +185,7 @@ void qtest_kill_qemu(QTestState *s)
      * Check whether qemu exited with expected exit status; anything else is
      * fishy and should be logged with as much detail as possible.
      */
+#ifndef _WIN32
     wstatus = s->wstatus;
     if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != s->expected_status) {
         fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU "
@@ -166,6 +202,14 @@ void qtest_kill_qemu(QTestState *s)
                 __FILE__, __LINE__, sig, signame, dump);
         abort();
     }
+#else
+    if (s->exit_code != s->expected_status) {
+        fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU "
+                "process but encountered exit status %ld (expected %d)\n",
+                __FILE__, __LINE__, s->exit_code, s->expected_status);
+        abort();
+    }
+#endif
 }
 
 static void kill_qemu_hook_func(void *s)
@@ -244,6 +288,38 @@ static const char *qtest_qemu_binary(void)
     return qemu_bin;
 }
 
+#ifdef _WIN32
+static pid_t qtest_create_process(char *cmd)
+{
+    STARTUPINFO si;
+    PROCESS_INFORMATION pi;
+    BOOL ret;
+
+    ZeroMemory(&si, sizeof(si));
+    si.cb = sizeof(si);
+    ZeroMemory(&pi, sizeof(pi));
+
+    ret = CreateProcess(NULL,   /* module name */
+                        cmd,    /* command line */
+                        NULL,   /* process handle not inheritable */
+                        NULL,   /* thread handle not inheritable */
+                        FALSE,  /* set handle inheritance to FALSE */
+                        0,      /* No creation flags */
+                        NULL,   /* use parent's environment block */
+                        NULL,   /* use parent's starting directory */
+                        &si,    /* pointer to STARTUPINFO structure */
+                        &pi     /* pointer to PROCESS_INFORMATION structure */
+                        );
+    if (ret == 0) {
+        fprintf(stderr, "%s:%d: unable to create a new process (%s)\n",
+                __FILE__, __LINE__, strerror(GetLastError()));
+        abort();
+    }
+
+    return (pid_t)pi.hProcess;
+}
+#endif /* _WIN32 */
+
 QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
 {
     QTestState *s;
@@ -271,6 +347,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     unlink(socket_path);
     unlink(qmp_socket_path);
 
+    socket_init();
     sock = init_socket(socket_path);
     qmpsock = init_socket(qmp_socket_path);
 
@@ -279,7 +356,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
 
     qtest_add_abrt_handler(kill_qemu_hook_func, s);
 
-    command = g_strdup_printf("exec %s %s"
+    command = g_strdup_printf(CMD_EXEC "%s %s"
                               "-qtest unix:%s "
                               "-qtest-log %s "
                               "-chardev socket,path=%s,id=char0 "
@@ -288,7 +365,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
                               "%s"
                               " -accel qtest",
                               qemu_binary, tracearg, socket_path,
-                              getenv("QTEST_LOG") ? "/dev/fd/2" : "/dev/null",
+                              getenv("QTEST_LOG") ? DEV_STDERR : DEV_NULL,
                               qmp_socket_path,
                               extra_args ?: "");
 
@@ -297,6 +374,7 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
     s->pending_events = NULL;
     s->wstatus = 0;
     s->expected_status = 0;
+#ifndef _WIN32
     s->qemu_pid = fork();
     if (s->qemu_pid == 0) {
 #ifdef __linux__
@@ -319,6 +397,9 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
         execlp("/bin/sh", "sh", "-c", command, NULL);
         exit(1);
     }
+#else
+    s->qemu_pid = qtest_create_process(command);
+#endif /* _WIN32 */
 
     g_free(command);
     s->fd = socket_accept(sock);
@@ -337,9 +418,19 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
         s->irq_level[i] = false;
     }
 
+    /*
+     * Stopping QEMU for debugging is not supported on Windows.
+     *
+     * Using DebugActiveProcess() API can suspend the QEMU process,
+     * but gdb cannot attach to the process. Using the undocumented
+     * NtSuspendProcess() can suspend the QEMU process and gdb can
+     * attach to the process, but gdb cannot resume it.
+     */
+#ifndef _WIN32
     if (getenv("QTEST_STOP")) {
         kill(s->qemu_pid, SIGSTOP);
     }
+#endif
 
     /* ask endianness of the target */
 
@@ -393,6 +484,7 @@ QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd)
     g_assert_true(sock_dir != NULL);
     sock_path = g_strdup_printf("%s/sock", sock_dir);
 
+    socket_init();
     sock_fd_init = init_socket(sock_path);
 
     qts = qtest_initf("-chardev socket,id=s0,path=%s -serial chardev:s0 %s",
Signature · 1 line
2.25.1
author
#4 lore raw

PATCH v6 4/11 tests/qtest: device-plug-test: Reverse the usage of double/single quotes

In reply to Bin Meng

The usage of double/single quotes in test_q35_pci_unplug_json_request() should be reversed to work on both win32 and non-win32 platforms:

- The value of -device parameter needs to be surrounded by "" as Windows does not drop '' when passing it to QEMU which causes QEMU command line option parser failure.
- The JSON key/value pairs need to be surrounded by '' to make the JSON parser happy on Windows.

Fixes a12f1a7e56b7 ("tests/x86: Add subtest with 'q35' machine type to device-plug-test")

---

Changes in v6:
- new patch: "tests/qtest: device-plug-test: Reverse the usage of double/single quotes"

 tests/qtest/device-plug-test.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
tests/qtest/device-plug-test.c +8 -8
index 3f44f731d1..5a6afa2b57 100644
@@ -112,16 +112,16 @@ static void test_pci_unplug_json_request(void)
 
 static void test_q35_pci_unplug_json_request(void)
 {
-    const char *port = "-device '{\"driver\": \"pcie-root-port\", "
-                                      "\"id\": \"p1\"}'";
+    const char *port = "-device \"{'driver': 'pcie-root-port', "
+                                  "'id': 'p1'}\"";
 
-    const char *bridge = "-device '{\"driver\": \"pcie-pci-bridge\", "
-                                   "\"id\": \"b1\", "
-                                   "\"bus\": \"p1\"}'";
+    const char *bridge = "-device \"{'driver': 'pcie-pci-bridge', "
+                                    "'id': 'b1', "
+                                    "'bus': 'p1'}\"";
 
-    const char *device = "-device '{\"driver\": \"virtio-mouse-pci\", "
-                                   "\"bus\": \"b1\", "
-                                   "\"id\": \"dev0\"}'";
+    const char *device = "-device \"{'driver': 'virtio-mouse-pci', "
+                                    "'bus': 'b1', "
+                                    "'id': 'dev0'}\"";
 
     QTestState *qtest = qtest_initf("-machine q35 %s %s %s",
                                     port, bridge, device);
Signature · 1 line
2.25.1
Reviewed-by on v6 4/11
#5 lore raw

Re: [PATCH v6 04/11] tests/qtest: device-plug-test: Reverse the usage of double/single quotes

Quoted 39 lines · Bin Meng

The usage of double/single quotes in test_q35_pci_unplug_json_request() should be reversed to work on both win32 and non-win32 platforms:

- The value of -device parameter needs to be surrounded by "" as Windows does not drop '' when passing it to QEMU which causes QEMU command line option parser failure.
- The JSON key/value pairs need to be surrounded by '' to make the JSON parser happy on Windows.

Fixes a12f1a7e56b7 ("tests/x86: Add subtest with 'q35' machine type to device-plug-test")

---

Changes in v6:
- new patch: "tests/qtest: device-plug-test: Reverse the usage of double/single quotes"

  tests/qtest/device-plug-test.c | 16 ++++++++--------
  1 file changed, 8 insertions(+), 8 deletions(-)
tests/qtest/device-plug-test.c +5 -5
index 3f44f731d1..5a6afa2b57 100644
@@ -112,16 +112,16 @@ static void test_pci_unplug_json_request(void)
 
  static void test_q35_pci_unplug_json_request(void)
  {
-    const char *port = "-device '{\"driver\": \"pcie-root-port\", "
-                                      "\"id\": \"p1\"}'";
+    const char *port = "-device \"{'driver': 'pcie-root-port', "
+                                  "'id': 'p1'}\"";
 
-    const char *bridge = "-device '{\"driver\": \"pcie-pci-bridge\", "
-                                   "\"id\": \"b1\", "
-                                   "\"bus\": \"p1\"}'";
+    const char *bridge = "-device \"{'driver': 'pcie-pci-bridge', "
+                                    "'id': 'b1', "
+                                    "'bus': 'p1'}\"";

tests/qtest/device-plug-test.c static void test_pci_unplug_json_request(void) · line 127

Quoted 10 lines
tests/qtest/device-plug-test.c +3 -3
 
-    const char *device = "-device '{\"driver\": \"virtio-mouse-pci\", "
-                                   "\"bus\": \"b1\", "
-                                   "\"id\": \"dev0\"}'";
+    const char *device = "-device \"{'driver': 'virtio-mouse-pci', "
+                                    "'bus': 'b1', "
+                                    "'id': 'dev0'}\"";
 
      QTestState *qtest = qtest_initf("-machine q35 %s %s %s",
                                      port, bridge, device);
author
#6 lore raw

PATCH v6 5/11 tests/qtest: Use EXIT_FAILURE instead of magic number

In reply to Bin Meng

When migration fails, QEMU exits with a status code EXIT_FAILURE. Change qtests to use the well-defined macro instead of magic number.

---

Changes in v6:
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"

 tests/qtest/dbus-vmstate-test.c | 2 +-
 tests/qtest/migration-test.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tests/qtest/dbus-vmstate-test.c +1 -1
index 74ede651f6..6c990864e3 100644
@@ -233,7 +233,7 @@ test_dbus_vmstate(Test *test)
     test->src_qemu = src_qemu;
     if (test->migrate_fail) {
         wait_for_migration_fail(src_qemu, true);
-        qtest_set_expected_status(dst_qemu, 1);
+        qtest_set_expected_status(dst_qemu, EXIT_FAILURE);
     } else {
         wait_for_migration_complete(src_qemu);
     }
tests/qtest/migration-test.c +2 -2
index aa1ba179fa..28a06d8170 100644
@@ -1342,7 +1342,7 @@ static void test_precopy_common(MigrateCommon *args)
         wait_for_migration_fail(from, allow_active);
 
         if (args->result == MIG_TEST_FAIL_DEST_QUIT_ERR) {
-            qtest_set_expected_status(to, 1);
+            qtest_set_expected_status(to, EXIT_FAILURE);
         }
     } else {
         if (args->iterations) {
@@ -1738,7 +1738,7 @@ static void do_test_validate_uuid(MigrateStart *args, bool should_fail)
     migrate_qmp(from, uri, "{}");
 
     if (should_fail) {
-        qtest_set_expected_status(to, 1);
+        qtest_set_expected_status(to, EXIT_FAILURE);
         wait_for_migration_fail(from, true);
     } else {
         wait_for_migration_complete(from);
Signature · 1 line
2.25.1
Reviewed-by on v6 5/11
#7 lore raw

Re: [PATCH v6 05/11] tests/qtest: Use EXIT_FAILURE instead of magic number

Quoted 5 lines · Bin Meng

When migration fails, QEMU exits with a status code EXIT_FAILURE. Change qtests to use the well-defined macro instead of magic number.

Quoted 8 lines

---

Changes in v6:
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"

  tests/qtest/dbus-vmstate-test.c | 2 +-
  tests/qtest/migration-test.c    | 4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
Reviewed-by on v6 5/11
#8 lore raw

Re: [PATCH v6 05/11] tests/qtest: Use EXIT_FAILURE instead of magic number

In reply to Bin Meng
Quoted 4 lines · Bin Meng

When migration fails, QEMU exits with a status code EXIT_FAILURE. Change qtests to use the well-defined macro instead of magic number.

Quoted 45 lines

---

Changes in v6:
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"

 tests/qtest/dbus-vmstate-test.c | 2 +-
 tests/qtest/migration-test.c    | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tests/qtest/dbus-vmstate-test.c +1 -1
index 74ede651f6..6c990864e3 100644
@@ -233,7 +233,7 @@ test_dbus_vmstate(Test *test)
     test->src_qemu = src_qemu;
     if (test->migrate_fail) {
         wait_for_migration_fail(src_qemu, true);
-        qtest_set_expected_status(dst_qemu, 1);
+        qtest_set_expected_status(dst_qemu, EXIT_FAILURE);
     } else {
         wait_for_migration_complete(src_qemu);
     }
tests/qtest/migration-test.c +2 -2
index aa1ba179fa..28a06d8170 100644
@@ -1342,7 +1342,7 @@ static void test_precopy_common(MigrateCommon *args)
         wait_for_migration_fail(from, allow_active);
 
         if (args->result == MIG_TEST_FAIL_DEST_QUIT_ERR) {
-            qtest_set_expected_status(to, 1);
+            qtest_set_expected_status(to, EXIT_FAILURE);
         }
     } else {
         if (args->iterations) {
@@ -1738,7 +1738,7 @@ static void do_test_validate_uuid(MigrateStart *args, bool should_fail)
     migrate_qmp(from, uri, "{}");
 
     if (should_fail) {
-        qtest_set_expected_status(to, 1);
+        qtest_set_expected_status(to, EXIT_FAILURE);
         wait_for_migration_fail(from, true);
     } else {
         wait_for_migration_complete(from);
author
#9 lore raw

PATCH v6 6/11 tests/qtest: libqtest: Introduce qtest_wait_qemu()

In reply to Bin Meng

Introduce an API for qtest to wait for the QEMU process to terminate.

---

Changes in v6:
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"

 tests/qtest/libqtest.h |  9 ++++++
 tests/qtest/libqtest.c | 63 +++++++++++++++++++++++++-----------------
 2 files changed, 47 insertions(+), 25 deletions(-)
tests/qtest/libqtest.h +9 -0
index 65c040e504..91a5f7edd9 100644
@@ -75,6 +75,15 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
  */
 QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
 
+/**
+ * qtest_wait_qemu:
+ * @s: #QTestState instance to operate on.
+ *
+ * Wait for the QEMU process to terminate. It is safe to call this function
+ * multiple times.
+ */
+void qtest_wait_qemu(QTestState *s);
+
 /**
  * qtest_kill_qemu:
  * @s: #QTestState instance to operate on.
tests/qtest/libqtest.c +38 -25

81 lines not on this page · raw message

Signature · 1 line
2.25.1
#10 lore raw

Re: [PATCH v6 06/11] tests/qtest: libqtest: Introduce qtest_wait_qemu()

Quoted 79 lines · Bin Meng

Introduce an API for qtest to wait for the QEMU process to terminate.

---

Changes in v6:
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"

  tests/qtest/libqtest.h |  9 ++++++
  tests/qtest/libqtest.c | 63 +++++++++++++++++++++++++-----------------
  2 files changed, 47 insertions(+), 25 deletions(-)
tests/qtest/libqtest.h +9 -0
index 65c040e504..91a5f7edd9 100644
@@ -75,6 +75,15 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args);
   */
  QTestState *qtest_init_with_serial(const char *extra_args, int *sock_fd);
 
+/**
+ * qtest_wait_qemu:
+ * @s: #QTestState instance to operate on.
+ *
+ * Wait for the QEMU process to terminate. It is safe to call this function
+ * multiple times.
+ */
+void qtest_wait_qemu(QTestState *s);
+
  /**
   * qtest_kill_qemu:
   * @s: #QTestState instance to operate on.
tests/qtest/libqtest.c +2 -25
index d12a604d78..e1e2d39a6e 100644
@@ -156,37 +156,14 @@ void qtest_set_expected_status(QTestState *s, int status)
      s->expected_status = status;
  }
 
-void qtest_kill_qemu(QTestState *s)
+static void qtest_check_status(QTestState *s)
  {
-    pid_t pid = s->qemu_pid;
-#ifndef _WIN32
-    int wstatus;
-#else
-    DWORD ret;
-#endif
-
-    /* Skip wait if qtest_probe_child already reaped.  */
-    if (pid != -1) {
-#ifndef _WIN32
-        kill(pid, SIGTERM);
-        TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0));
-        assert(pid == s->qemu_pid);
-#else
-        TerminateProcess((HANDLE)pid, s->expected_status);
-        ret = WaitForSingleObject((HANDLE)pid, INFINITE);
-        assert(ret == WAIT_OBJECT_0);
-        GetExitCodeProcess((HANDLE)pid, &s->exit_code);
-        CloseHandle((HANDLE)pid);
-#endif
-        s->qemu_pid = -1;
-    }
-
      /*
       * Check whether qemu exited with expected exit status; anything else is
       * fishy and should be logged with as much detail as possible.
       */
  #ifndef _WIN32
-    wstatus = s->wstatus;
+    int wstatus = s->wstatus;
      if (WIFEXITED(wstatus) && WEXITSTATUS(wstatus) != s->expected_status) {
          fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU "
                  "process but encountered exit status %d (expected %d)\n",

tests/qtest/libqtest.c void qtest_kill_qemu(QTestState *s) · line 195

Quoted 7 lines
tests/qtest/libqtest.c +4 -0
@@ -212,6 +189,42 @@ void qtest_kill_qemu(QTestState *s)
  #endif
  }
 
+void qtest_wait_qemu(QTestState *s)
+{
+#ifndef _WIN32
+    pid_t pid;

Should we have a check for s->qemu_pid != -1 here ?

Quoted 24 lines
tests/qtest/libqtest.c +24 -0
+    TFR(pid = waitpid(s->qemu_pid, &s->wstatus, 0));
+    assert(pid == s->qemu_pid);
+#else
+    DWORD ret;
+
+    ret = WaitForSingleObject((HANDLE)s->qemu_pid, INFINITE);
+    assert(ret == WAIT_OBJECT_0);
+    GetExitCodeProcess((HANDLE)s->qemu_pid, &s->exit_code);
+    CloseHandle((HANDLE)s->qemu_pid);
+#endif
+
+    qtest_check_status(s);
+}
+
+void qtest_kill_qemu(QTestState *s)
+{
+    /* Skip wait if qtest_probe_child() already reaped */
+    if (s->qemu_pid != -1) {
+#ifndef _WIN32
+        kill(s->qemu_pid, SIGTERM);
+#else
+        TerminateProcess((HANDLE)s->qemu_pid, s->expected_status);
+#endif
+        qtest_wait_qemu(s);

tests/qtest/libqtest.c void qtest_kill_qemu(QTestState *s) · line 230

Quoted 10 lines
tests/qtest/libqtest.c +7 -0
+        s->qemu_pid = -1;
+        return;
+    }
+
+    qtest_check_status(s);
+}
+
  static void kill_qemu_hook_func(void *s)
  {
      qtest_kill_qemu(s);

Thomas

author
#11 lore raw

PATCH v6 7/11 tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled

In reply to Bin Meng

From: Xuzhou Cheng <[email protected]>

Make sure QEMU process "to" exited before launching another target for migration in the test_multifd_tcp_cancel case.

---

Changes in v6:
- change to use qtest_wait_qemu() API

Changes in v3:
- Add a usleep(1) in the busy wait loop

Changes in v2:
- Change to a busy wait after migration is canceled

 tests/qtest/migration-test.c | 4 ++++
 1 file changed, 4 insertions(+)
tests/qtest/migration-test.c +4 -0
index 28a06d8170..d2eb107f0c 100644
@@ -2141,6 +2141,10 @@ static void test_multifd_tcp_cancel(void)
 
     migrate_cancel(from);
 
+    /* Make sure QEMU process "to" exited */
+    qtest_set_expected_status(to, EXIT_FAILURE);
+    qtest_wait_qemu(to);
+
     args = (MigrateStart){
         .only_target = true,
     };
Signature · 1 line
2.25.1
Reviewed-by on v6 7/11
#12 lore raw

Re: [PATCH v6 07/11] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled

Quoted 13 lines · Bin Meng

From: Xuzhou Cheng <[email protected]>

Make sure QEMU process "to" exited before launching another target for migration in the test_multifd_tcp_cancel case.

---

Changes in v6:
- change to use qtest_wait_qemu() API

Quoted 8 lines

Changes in v3:
- Add a usleep(1) in the busy wait loop

Changes in v2:
- Change to a busy wait after migration is canceled

 tests/qtest/migration-test.c | 4 ++++
 1 file changed, 4 insertions(+)
author
#13 lore raw

PATCH v6 8/11 tests/qtest: libqos: Do not build virtio-9p unconditionally

In reply to Bin Meng

At present the virtio-9p related codes are built into libqos unconditionally. Change to build them conditionally by testing the 'virtfs' config option.

---

Changes in v6:
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

 tests/qtest/libqos/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/qtest/libqos/meson.build +4 -2
index 113c80b4e4..32f028872c 100644
@@ -33,8 +33,6 @@ libqos_srcs = files(
         'sdhci.c',
         'tpci200.c',
         'virtio.c',
-        'virtio-9p.c',
-        'virtio-9p-client.c',
         'virtio-balloon.c',
         'virtio-blk.c',
         'vhost-user-blk.c',
@@ -62,6 +60,10 @@ libqos_srcs = files(
         'x86_64_pc-machine.c',
 )
 
+if have_virtfs
+  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
+endif
+
 libqos = static_library('qos', libqos_srcs + genh,
                         name_suffix: 'fa',
                         build_by_default: false)
Signature · 1 line
2.25.1
Reviewed-by on v6 8/11
#14 lore raw

Re: [PATCH v6 08/11] tests/qtest: libqos: Do not build virtio-9p unconditionally

Quoted 5 lines · Bin Meng

At present the virtio-9p related codes are built into libqos unconditionally. Change to build them conditionally by testing the 'virtfs' config option.

#15 lore raw

Re: [PATCH v6 08/11] tests/qtest: libqos: Do not build virtio-9p unconditionally

In reply to Bin Meng
Quoted 29 lines · CEST Bin Meng

At present the virtio-9p related codes are built into libqos unconditionally. Change to build them conditionally by testing the 'virtfs' config option.

---

Changes in v6:
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

 tests/qtest/libqos/meson.build | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/qtest/libqos/meson.build +0 -2
index 113c80b4e4..32f028872c 100644
@@ -33,8 +33,6 @@ libqos_srcs = files(
         'sdhci.c',
         'tpci200.c',
         'virtio.c',
-        'virtio-9p.c',
-        'virtio-9p-client.c',
         'virtio-balloon.c',
         'virtio-blk.c',
         'vhost-user-blk.c',

tests/qtest/libqos/meson.build libqos_srcs = files( · line 69

Quoted 10 lines
tests/qtest/libqos/meson.build +4 -0
@@ -62,6 +60,10 @@ libqos_srcs = files(
         'x86_64_pc-machine.c',
 )
 
+if have_virtfs
+  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
+endif
+
 libqos = static_library('qos', libqos_srcs + genh,
                         name_suffix: 'fa',
                         build_by_default: false)

I wondered why this change would no longer execute the 9p tests here. Apparently because it changes the order of tests being executed, i.e. 9p tests would then be scheduled after:

# Start of vhost-user-blk-pci tests
# Start of vhost-user-blk-pci-tests tests Environment variable QTEST_QEMU_STORAGE_DAEMON_BINARY required [EXIT]

and I never cared about QEMU storage binary. Can we make a hack like the following to not change the order of the tests?

tests/qtest/libqos/meson.build +6 -4
index 32f028872c..389bca9804 100644
@@ -1,7 +1,13 @@
 libqos_srcs = files(
         '../libqtest.c',
         '../libqmp.c',
+)
 
+if have_virtfs
+  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
+endif
+
+libqos_srcs += files(
         'qgraph.c',
         'qos_external.c',
         'pci.c',
@@ -60,10 +66,6 @@ libqos_srcs = files(
         'x86_64_pc-machine.c',
 )
 
-if have_virtfs
-  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
-endif
-
 libqos = static_library('qos', libqos_srcs + genh,
                         name_suffix: 'fa',
                         build_by_default: false)

Too ugly?

Best regards,
Christian Schoenebeck

#16 lore raw

Re: [PATCH v6 08/11] tests/qtest: libqos: Do not build virtio-9p unconditionally

Quoted 83 lines · Christian Schoenebeck
Quoted 29 lines · CEST Bin Meng

At present the virtio-9p related codes are built into libqos unconditionally. Change to build them conditionally by testing the 'virtfs' config option.

---

Changes in v6:
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

  tests/qtest/libqos/meson.build | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tests/qtest/libqos/meson.build +0 -2
index 113c80b4e4..32f028872c 100644
@@ -33,8 +33,6 @@ libqos_srcs = files(
          'sdhci.c',
          'tpci200.c',
          'virtio.c',
-        'virtio-9p.c',
-        'virtio-9p-client.c',
          'virtio-balloon.c',
          'virtio-blk.c',
          'vhost-user-blk.c',

tests/qtest/libqos/meson.build libqos_srcs = files( · line 69

Quoted 10 lines
tests/qtest/libqos/meson.build +4 -0
@@ -62,6 +60,10 @@ libqos_srcs = files(
          'x86_64_pc-machine.c',
  )
 
+if have_virtfs
+  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
+endif
+
  libqos = static_library('qos', libqos_srcs + genh,
                          name_suffix: 'fa',
                          build_by_default: false)

I wondered why this change would no longer execute the 9p tests here. Apparently because it changes the order of tests being executed, i.e. 9p tests would then be scheduled after:

# Start of vhost-user-blk-pci tests
# Start of vhost-user-blk-pci-tests tests Environment variable QTEST_QEMU_STORAGE_DAEMON_BINARY required [EXIT]

and I never cared about QEMU storage binary. Can we make a hack like the following to not change the order of the tests?

tests/qtest/libqos/meson.build +6 -4
index 32f028872c..389bca9804 100644
@@ -1,7 +1,13 @@
  libqos_srcs = files(
          '../libqtest.c',
          '../libqmp.c',
+)
 
+if have_virtfs
+  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
+endif
+
+libqos_srcs += files(
          'qgraph.c',
          'qos_external.c',
          'pci.c',
@@ -60,10 +66,6 @@ libqos_srcs = files(
          'x86_64_pc-machine.c',
  )
 
-if have_virtfs
-  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
-endif
-
  libqos = static_library('qos', libqos_srcs + genh,
                          name_suffix: 'fa',
                          build_by_default: false)
Quoted 1 line

Too ugly?

Looks a little bit ugly, indeed. What about marking the vhost-user-blk-pci test as skipped instead of exiting? (i.e. use g_test_skip() instead of exit()). Would that work for you?

Thomas

#17 lore raw

Re: [PATCH v6 08/11] tests/qtest: libqos: Do not build virtio-9p unconditionally

Quoted 84 lines · CEST Thomas Huth
Quoted 83 lines · Christian Schoenebeck
Quoted 29 lines · CEST Bin Meng

At present the virtio-9p related codes are built into libqos unconditionally. Change to build them conditionally by testing the 'virtfs' config option.

---

Changes in v6:
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

  tests/qtest/libqos/meson.build | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
tests/qtest/libqos/meson.build +0 -2
index 113c80b4e4..32f028872c 100644
@@ -33,8 +33,6 @@ libqos_srcs = files(
          'sdhci.c',
          'tpci200.c',
          'virtio.c',
-        'virtio-9p.c',
-        'virtio-9p-client.c',
          'virtio-balloon.c',
          'virtio-blk.c',
          'vhost-user-blk.c',

tests/qtest/libqos/meson.build libqos_srcs = files( · line 69

Quoted 10 lines
tests/qtest/libqos/meson.build +4 -0
@@ -62,6 +60,10 @@ libqos_srcs = files(
          'x86_64_pc-machine.c',
  )
 
+if have_virtfs
+  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
+endif
+
  libqos = static_library('qos', libqos_srcs + genh,
                          name_suffix: 'fa',
                          build_by_default: false)

I wondered why this change would no longer execute the 9p tests here. Apparently because it changes the order of tests being executed, i.e. 9p tests would then be scheduled after:

# Start of vhost-user-blk-pci tests
# Start of vhost-user-blk-pci-tests tests Environment variable QTEST_QEMU_STORAGE_DAEMON_BINARY required [EXIT]

and I never cared about QEMU storage binary. Can we make a hack like the following to not change the order of the tests?

tests/qtest/libqos/meson.build +6 -4
index 32f028872c..389bca9804 100644
@@ -1,7 +1,13 @@
  libqos_srcs = files(
          '../libqtest.c',
          '../libqmp.c',
+)
 
+if have_virtfs
+  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
+endif
+
+libqos_srcs += files(
          'qgraph.c',
          'qos_external.c',
          'pci.c',
@@ -60,10 +66,6 @@ libqos_srcs = files(
          'x86_64_pc-machine.c',
  )
 
-if have_virtfs
-  libqos_srcs += files('virtio-9p.c', 'virtio-9p-client.c')
-endif
-
  libqos = static_library('qos', libqos_srcs + genh,
                          name_suffix: 'fa',
                          build_by_default: false)
Quoted 5 lines
Quoted 1 line

Too ugly?

Looks a little bit ugly, indeed. What about marking the vhost-user-blk-pci test as skipped instead of exiting? (i.e. use g_test_skip() instead of exit()). Would that work for you?

In general, sure!

But it seems it needs a bit more tweaking, simply placing

  g_test_skip(...);
  return NULL;

there causes a hang.

Best regards,
Christian Schoenebeck

author
#18 lore raw

PATCH v6 9/11 tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32

In reply to Bin Meng

Some qtest cases don't get response from the QEMU executable under test in time on Windows. It turns out that the socket receive call got timeout before it receive the complete response.

The timeout value is supposed to be set to 50 seconds via the setsockopt() call, but there is a difference among platforms. The timeout unit of blocking receive calls is measured in seconds on non-Windows platforms but milliseconds on Windows.

---

(no changes since v1)

 tests/qtest/libqtest.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
tests/qtest/libqtest.c +10 -1
index e1e2d39a6e..2fbc3b88f3 100644
@@ -36,13 +36,14 @@
 #include "qapi/qmp/qstring.h"
 
 #define MAX_IRQ 256
-#define SOCKET_TIMEOUT 50
 
 #ifndef _WIN32
+# define SOCKET_TIMEOUT 50
 # define CMD_EXEC   "exec "
 # define DEV_STDERR "/dev/fd/2"
 # define DEV_NULL   "/dev/null"
 #else
+# define SOCKET_TIMEOUT 50000
 # define CMD_EXEC   ""
 # define DEV_STDERR "2"
 # define DEV_NULL   "nul"
@@ -106,8 +107,16 @@ static int socket_accept(int sock)
     struct sockaddr_un addr;
     socklen_t addrlen;
     int ret;
+    /*
+     * timeout unit of blocking receive calls is different among platfoms.
+     * It's in seconds on non-Windows platforms but milliseconds on Windows.
+     */
+#ifndef _WIN32
     struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT,
                                .tv_usec = 0 };
+#else
+    DWORD timeout = SOCKET_TIMEOUT;
+#endif
 
     if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
                    (void *)&timeout, sizeof(timeout))) {
Signature · 1 line
2.25.1
author
#19 lore raw

PATCH v6 10/11 .gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes

In reply to Bin Meng

commit 9f8e6cad65a6 ("gitlab-ci: Speed up the msys2-64bit job by using --without-default-devices" changed to compile QEMU with the --without-default-devices switch for
the msys2-64bit job, due to the build could not complete within the
project timeout (1h), and also mentioned that a bigger timeout was
getting ignored on the shared Gitlab-CI Windows runners.

However as of today it seems the shared Gitlab-CI Windows runners does honor the job timeout, and the runner has the timeout limit of 2h, so let's increase the timeout to 90 minutes and drop the configure switch "--without-default-devices" to get a larger build coverage.

---

(no changes since v2)

Changes in v2:
- Change the timeout limit to 90 minutes

 .gitlab-ci.d/windows.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
.gitlab-ci.d/windows.yml +2 -2
index a3e7a37022..093276ddbc 100644
@@ -10,7 +10,7 @@
       - ${CI_PROJECT_DIR}/msys64/var/cache
   needs: []
   stage: build
-  timeout: 70m
+  timeout: 90m
   before_script:
   - If ( !(Test-Path -Path msys64\var\cache ) ) {
       mkdir msys64\var\cache
@@ -60,7 +60,7 @@ msys2-64bit:
   - $env:MSYSTEM = 'MINGW64'     # Start a 64 bit Mingw environment
   - $env:MSYS = 'winsymlinks:native' # Enable native Windows symlink
   - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu
-      --enable-capstone --without-default-devices'
+      --enable-capstone'
   - .\msys64\usr\bin\bash -lc 'make'
   - .\msys64\usr\bin\bash -lc 'make check || { cat build/meson-logs/testlog.txt; exit 1; } ;'
 
Signature · 1 line
2.25.1
author
#20 lore raw

PATCH v6 11/11 tests/qtest: Enable qtest build on Windows

In reply to Bin Meng

Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows.

---

Changes in v5:
- Drop patches that are already merged

Changes in v3:
- Drop the host test

Changes in v2:
- new patch: "tests/qtest: Enable qtest build on Windows"

 tests/qtest/meson.build | 6 ------
 1 file changed, 6 deletions(-)
tests/qtest/meson.build +0 -6
index c07a5b1a5f..f0ebb5fac6 100644
@@ -1,9 +1,3 @@
-# All QTests for now are POSIX-only, but the dependencies are
-# really in libqtest, not in the testcases themselves.
-if not config_host.has_key('CONFIG_POSIX')
-  subdir_done()
-endif
-
 slow_qtests = {
   'ahci-test' : 60,
   'bios-tables-test' : 120,
Signature · 1 line
2.25.1
#21 lore raw

Re: [PATCH v6 11/11] tests/qtest: Enable qtest build on Windows

Hi Bin

Quoted 6 lines · Bin Meng

Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows.

We haven't solved the CI timing out or eating all the CPU time, right?

Can we simply exclude it from CI for now, ie add to this patch

.gitlab-ci.d/windows.yml +0 -1
index 093276ddbc..ba9045ec38 100644
@@ -62,7 +62,7 @@ msys2-64bit:
   - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu
       --enable-capstone'
   - .\msys64\usr\bin\bash -lc 'make'
-  - .\msys64\usr\bin\bash -lc 'make check || { cat

build/meson-logs/testlog.txt; exit 1; } ;'
+ - .\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat build/meson-logs/testlog.txt; exit 1; } ;'

msys2-32bit:
extends: .shared_msys2_builder
@@ -96,4 +96,4 @@ msys2-32bit:
- cd output
- ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu"
- ..\msys64\usr\bin\bash -lc 'make'
- - ..\msys64\usr\bin\bash -lc 'make check || { cat meson-logs/testlog.txt; exit 1; } ;'
+ - ..\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat meson-logs/testlog.txt; exit 1; } ;'

Could you resubmit your missing win test patches and check if gitlab is happy?

thanks

Quoted 33 lines

---

Changes in v5:
- Drop patches that are already merged

Changes in v3:
- Drop the host test

Changes in v2:
- new patch: "tests/qtest: Enable qtest build on Windows"

 tests/qtest/meson.build | 6 ------
 1 file changed, 6 deletions(-)
tests/qtest/meson.build +0 -7
index c07a5b1a5f..f0ebb5fac6 100644
@@ -1,9 +1,3 @@
-# All QTests for now are POSIX-only, but the dependencies are
-# really in libqtest, not in the testcases themselves.
-if not config_host.has_key('CONFIG_POSIX')
-  subdir_done()
-endif
-
 slow_qtests = {
   'ahci-test' : 60,
   'bios-tables-test' : 120,
--

2.25.1

Signature · 1 line
Marc-André Lureau
#22 lore raw

Re: [PATCH v6 11/11] tests/qtest: Enable qtest build on Windows

Quoted 34 lines · Marc-André Lureau

Hi Bin

Quoted 6 lines · Bin Meng

Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows.

We haven't solved the CI timing out or eating all the CPU time, right?

Can we simply exclude it from CI for now, ie add to this patch

.gitlab-ci.d/windows.yml +0 -1
index 093276ddbc..ba9045ec38 100644
@@ -62,7 +62,7 @@ msys2-64bit:
    - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu
        --enable-capstone'
    - .\msys64\usr\bin\bash -lc 'make'
-  - .\msys64\usr\bin\bash -lc 'make check || { cat

build/meson-logs/testlog.txt; exit 1; } ;'
+ - .\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat build/meson-logs/testlog.txt; exit 1; } ;'

msys2-32bit:
extends: .shared_msys2_builder

.gitlab-ci.d/windows.yml +0 -1
@@ -96,4 +96,4 @@ msys2-32bit:
    - cd output
    - ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu"
    - ..\msys64\usr\bin\bash -lc 'make'
-  - ..\msys64\usr\bin\bash -lc 'make check || { cat
Quoted 3 lines

meson-logs/testlog.txt; exit 1; } ;'
+ - ..\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat meson-logs/testlog.txt; exit 1; } ;'

I think it's only the 64-bit job that is really problematic, so we could still run the qtests in the 32-bit job?

Alternatively, what about switching the 64-bit to another target that does not have so many qtests enabled? Some mips-softmmu or riscv-softmmu maybe? ... we still check x86_64-softmmu in the .cirrus.yml builds, so this is hopefully not such a big loss...

Thomas

#23 lore raw

Re: [PATCH v6 11/11] tests/qtest: Enable qtest build on Windows

Hi Thomas

Quoted 43 lines · Thomas Huth
Quoted 34 lines · Marc-André Lureau

Hi Bin

Quoted 6 lines · Bin Meng

Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows.

We haven't solved the CI timing out or eating all the CPU time, right?

Can we simply exclude it from CI for now, ie add to this patch

.gitlab-ci.d/windows.yml +0 -1
index 093276ddbc..ba9045ec38 100644
@@ -62,7 +62,7 @@ msys2-64bit:
    - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu
        --enable-capstone'
    - .\msys64\usr\bin\bash -lc 'make'
-  - .\msys64\usr\bin\bash -lc 'make check || { cat

build/meson-logs/testlog.txt; exit 1; } ;'
+ - .\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat build/meson-logs/testlog.txt; exit 1; } ;'

msys2-32bit:
extends: .shared_msys2_builder

.gitlab-ci.d/windows.yml +0 -1
@@ -96,4 +96,4 @@ msys2-32bit:
    - cd output
    - ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu"
    - ..\msys64\usr\bin\bash -lc 'make'
-  - ..\msys64\usr\bin\bash -lc 'make check || { cat
Quoted 3 lines

meson-logs/testlog.txt; exit 1; } ;'
+ - ..\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat meson-logs/testlog.txt; exit 1; } ;'

I think it's only the 64-bit job that is really problematic, so we could still run the qtests in the 32-bit job?

Quoted 5 lines

Alternatively, what about switching the 64-bit to another target that does not have so many qtests enabled? Some mips-softmmu or riscv-softmmu maybe? ... we still check x86_64-softmmu in the .cirrus.yml builds, so this is hopefully not such a big loss...

The change I propose above is to simply skip the qtests on msys CI builds. They are not running today on !POSIX.

Signature · 1 line
Marc-André Lureau
#24 lore raw

Re: [PATCH v6 11/11] tests/qtest: Enable qtest build on Windows

Quoted 46 lines · Marc-André Lureau

Hi Thomas

Quoted 43 lines · Thomas Huth
Quoted 34 lines · Marc-André Lureau

Hi Bin

Quoted 6 lines · Bin Meng

Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows.

We haven't solved the CI timing out or eating all the CPU time, right?

Can we simply exclude it from CI for now, ie add to this patch

.gitlab-ci.d/windows.yml +0 -1
index 093276ddbc..ba9045ec38 100644
@@ -62,7 +62,7 @@ msys2-64bit:
     - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu
         --enable-capstone'
     - .\msys64\usr\bin\bash -lc 'make'
-  - .\msys64\usr\bin\bash -lc 'make check || { cat

build/meson-logs/testlog.txt; exit 1; } ;'
+ - .\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat build/meson-logs/testlog.txt; exit 1; } ;'

   msys2-32bit:
     extends: .shared_msys2_builder
.gitlab-ci.d/windows.yml +0 -1
@@ -96,4 +96,4 @@ msys2-32bit:
     - cd output
     - ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu"
     - ..\msys64\usr\bin\bash -lc 'make'
-  - ..\msys64\usr\bin\bash -lc 'make check || { cat
Quoted 3 lines

meson-logs/testlog.txt; exit 1; } ;'
+ - ..\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat meson-logs/testlog.txt; exit 1; } ;'

I think it's only the 64-bit job that is really problematic, so we could still run the qtests in the 32-bit job?

Quoted 8 lines
Quoted 5 lines

Alternatively, what about switching the 64-bit to another target that does not have so many qtests enabled? Some mips-softmmu or riscv-softmmu maybe? ... we still check x86_64-softmmu in the .cirrus.yml builds, so this is hopefully not such a big loss...

The change I propose above is to simply skip the qtests on msys CI builds. They are not running today on !POSIX.

Sure ... question is what would be more valuable in the gitlab-CI ... only compile-testing x86_64-softmmu on msys2 (since that also compile-tests the HAX and WHPX stuff), but without qtests, or also run a (limited) set of qtests with another smaller softmmu target? I don't mind either way, I just wanted to suggest an alternative to consider.

Thomas

#25 lore raw

Re: [PATCH v6 11/11] tests/qtest: Enable qtest build on Windows

Hi

Quoted 54 lines · Thomas Huth
Quoted 52 lines · Marc-André Lureau

Hi Thomas

Quoted 48 lines · Thomas Huth
Quoted 34 lines · Marc-André Lureau

Hi Bin

Quoted 6 lines · Bin Meng

Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows.

We haven't solved the CI timing out or eating all the CPU time, right?

Can we simply exclude it from CI for now, ie add to this patch

.gitlab-ci.d/windows.yml +0 -1
index 093276ddbc..ba9045ec38 100644
@@ -62,7 +62,7 @@ msys2-64bit:
     - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu
         --enable-capstone'
     - .\msys64\usr\bin\bash -lc 'make'
-  - .\msys64\usr\bin\bash -lc 'make check || { cat

build/meson-logs/testlog.txt; exit 1; } ;'
+ - .\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat build/meson-logs/testlog.txt; exit 1; } ;'

   msys2-32bit:
     extends: .shared_msys2_builder
.gitlab-ci.d/windows.yml +0 -1
@@ -96,4 +96,4 @@ msys2-32bit:
     - cd output
     - ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu"
     - ..\msys64\usr\bin\bash -lc 'make'
-  - ..\msys64\usr\bin\bash -lc 'make check || { cat
Quoted 3 lines

meson-logs/testlog.txt; exit 1; } ;'
+ - ..\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat meson-logs/testlog.txt; exit 1; } ;'

I think it's only the 64-bit job that is really problematic, so we could still run the qtests in the 32-bit job?

Alternatively, what about switching the 64-bit to another target that does not have so many qtests enabled? Some mips-softmmu or riscv-softmmu maybe? ... we still check x86_64-softmmu in the .cirrus.yml builds, so this is hopefully not such a big loss...

Quoted 9 lines
Quoted 2 lines

The change I propose above is to simply skip the qtests on msys CI builds. They are not running today on !POSIX.

Sure ... question is what would be more valuable in the gitlab-CI ... only compile-testing x86_64-softmmu on msys2 (since that also compile-tests the HAX and WHPX stuff), but without qtests, or also run a (limited) set of qtests with another smaller softmmu target?
I don't mind either way, I just wanted to suggest an alternative to consider.

Yes, we can do that on top though. I would want qtest to run on my local msys build first, hence Bin's patch :)

Signature · 1 line
Marc-André Lureau
#26 lore raw

Re: [PATCH v6 11/11] tests/qtest: Enable qtest build on Windows

In reply to Marc-André Lureau

Hi Marc-André,

Quoted 5 lines · Marc-André Lureau

Hi Bin

Quoted 1 line · Bin Meng
Quoted 7 lines
Quoted 5 lines

Now that we have fixed various test case issues as seen when running on Windows, let's enable the qtest build on Windows.

We haven't solved the CI timing out or eating all the CPU time, right?

Correct

Quoted 2 lines

Can we simply exclude it from CI for now, ie add to this patch

Thanks for your suggestion!

Quoted 10 lines
.gitlab-ci.d/windows.yml +0 -1
index 093276ddbc..ba9045ec38 100644
@@ -62,7 +62,7 @@ msys2-64bit:
   - .\msys64\usr\bin\bash -lc './configure --target-list=x86_64-softmmu
       --enable-capstone'
   - .\msys64\usr\bin\bash -lc 'make'
-  - .\msys64\usr\bin\bash -lc 'make check || { cat
Quoted 3 lines

build/meson-logs/testlog.txt; exit 1; } ;'
+ - .\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat build/meson-logs/testlog.txt; exit 1; } ;'

The double quote should be escaped.

Quoted 11 lines

msys2-32bit:
extends: .shared_msys2_builder

.gitlab-ci.d/windows.yml +0 -1
@@ -96,4 +96,4 @@ msys2-32bit:
   - cd output
   - ..\msys64\usr\bin\bash -lc "../configure --target-list=ppc64-softmmu"
   - ..\msys64\usr\bin\bash -lc 'make'
-  - ..\msys64\usr\bin\bash -lc 'make check || { cat

meson-logs/testlog.txt; exit 1; } ;'
+ - ..\msys64\usr\bin\bash -lc 'make check MTESTARGS="--no-suite qtest" || { cat meson-logs/testlog.txt; exit 1; } ;'

I don't think we need to touch 32-bit.

Quoted 2 lines

Could you resubmit your missing win test patches and check if gitlab is happy?

Sure, will do soon.

Regards,
Bin

Reviewed-by on the v6 series
#27 lore raw
In reply to Bin Meng

Hi

Quoted 73 lines · Bin Meng

In preparation to adding virtio-9p support on Windows, this series enables running qtest on Windows, so that we can run the virtio-9p tests on Windows to make sure it does not break accidently.

Changes in v6:
- drop patches that are already in Alex and Daniel's tree
- remove CONFIG_POSIX from meson.build
- include <qemu/sockets.h> in libqtest.c
- move documentation comments of qemu_send_full() from util/osdep.c to qemu/sockets.h
- save the "exit_code" in struct QTestState
- new patch: "tests/qtest: device-plug-test: Reverse the usage of double/single quotes"
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"
- change to use qtest_wait_qemu() API
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

Changes in v5:
- restore to v1 version which does not touch the posix implementation
- Drop patches that are already merged

Changes in v3:
- Add a usleep(1) in the busy wait loop
- Drop the host test

Changes in v2:
- Introduce qemu_send_full() and use it
- Move the enabling of building qtests on Windows to a separate patch to keep bisectablity
- Call socket_init() unconditionally
- Add a missing CloseHandle() call
- Change to a busy wait after migration is canceled
- Change the timeout limit to 90 minutes
- new patch: "tests/qtest: Enable qtest build on Windows"

Bin Meng (8):
tests/qtest: Support libqtest to build and run on Windows tests/qtest: device-plug-test: Reverse the usage of double/single
quotes
tests/qtest: Use EXIT_FAILURE instead of magic number tests/qtest: libqtest: Introduce qtest_wait_qemu() tests/qtest: libqos: Do not build virtio-9p unconditionally tests/qtest: libqtest: Correct the timeout unit of blocking receive
calls for win32
.gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes tests/qtest: Enable qtest build on Windows

Xuzhou Cheng (3):
accel/qtest: Support qtest accelerator for Windows tests/qtest: Use send/recv for socket communication tests/qtest: migration-test: Make sure QEMU process "to" exited after
migration is canceled

 include/hw/core/cpu.h           |   1 +
 include/qemu/sockets.h          |  13 +++
 tests/qtest/libqtest.h          |   9 ++
 accel/dummy-cpus.c              |  14 ++-
 softmmu/cpus.c                  |   9 +-
 tests/qtest/dbus-vmstate-test.c |   2 +-
 tests/qtest/device-plug-test.c  |  16 ++--
 tests/qtest/libqmp.c            |   5 +-
 tests/qtest/libqtest.c          | 151 ++++++++++++++++++++++++++++----
 tests/qtest/migration-test.c    |   8 +-
 util/osdep.c                    |  22 +++++
 .gitlab-ci.d/windows.yml        |   4 +-
 accel/meson.build               |   2 +-
 accel/qtest/meson.build         |   3 +-
 tests/qtest/libqos/meson.build  |   6 +-
 tests/qtest/meson.build         |   6 --
 16 files changed, 221 insertions(+), 50 deletions(-)
Quoted 4 lines

--
2.25.1

Series looks good to me:

However, many qtests are flaky on Windows. I get a number of "broken pipe" exit code 3 & timeout. Should gitlab ignore windows test failures ? Or perhaps have a new "ignored" job for the windows qtests. What's your experience running gitlab CI with this series? Can you share results? (I kicked off one here
https://gitlab.com/marcandre.lureau/qemu/-/pipelines/679511572)

#28 lore raw
Quoted 80 lines · Marc-André Lureau

Hi

Quoted 72 lines · Bin Meng

In preparation to adding virtio-9p support on Windows, this series enables running qtest on Windows, so that we can run the virtio-9p tests on Windows to make sure it does not break accidently.

Changes in v6:
- drop patches that are already in Alex and Daniel's tree
- remove CONFIG_POSIX from meson.build
- include <qemu/sockets.h> in libqtest.c
- move documentation comments of qemu_send_full() from util/osdep.c
to qemu/sockets.h
- save the "exit_code" in struct QTestState
- new patch: "tests/qtest: device-plug-test: Reverse the usage of double/single quotes"
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"
- change to use qtest_wait_qemu() API
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

Changes in v5:
- restore to v1 version which does not touch the posix implementation
- Drop patches that are already merged

Changes in v3:
- Add a usleep(1) in the busy wait loop
- Drop the host test

Changes in v2:
- Introduce qemu_send_full() and use it
- Move the enabling of building qtests on Windows to a separate patch to keep bisectablity
- Call socket_init() unconditionally
- Add a missing CloseHandle() call
- Change to a busy wait after migration is canceled
- Change the timeout limit to 90 minutes
- new patch: "tests/qtest: Enable qtest build on Windows"

Bin Meng (8):
tests/qtest: Support libqtest to build and run on Windows tests/qtest: device-plug-test: Reverse the usage of double/single
quotes
tests/qtest: Use EXIT_FAILURE instead of magic number tests/qtest: libqtest: Introduce qtest_wait_qemu() tests/qtest: libqos: Do not build virtio-9p unconditionally tests/qtest: libqtest: Correct the timeout unit of blocking receive
calls for win32
.gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes tests/qtest: Enable qtest build on Windows

Xuzhou Cheng (3):
accel/qtest: Support qtest accelerator for Windows tests/qtest: Use send/recv for socket communication tests/qtest: migration-test: Make sure QEMU process "to" exited after
migration is canceled

 include/hw/core/cpu.h           |   1 +
 include/qemu/sockets.h          |  13 +++
 tests/qtest/libqtest.h          |   9 ++
 accel/dummy-cpus.c              |  14 ++-
 softmmu/cpus.c                  |   9 +-
 tests/qtest/dbus-vmstate-test.c |   2 +-
 tests/qtest/device-plug-test.c  |  16 ++--
 tests/qtest/libqmp.c            |   5 +-
 tests/qtest/libqtest.c          | 151 ++++++++++++++++++++++++++++----
 tests/qtest/migration-test.c    |   8 +-
 util/osdep.c                    |  22 +++++
 .gitlab-ci.d/windows.yml        |   4 +-
 accel/meson.build               |   2 +-
 accel/qtest/meson.build         |   3 +-
 tests/qtest/libqos/meson.build  |   6 +-
 tests/qtest/meson.build         |   6 --
 16 files changed, 221 insertions(+), 50 deletions(-)
Quoted 3 lines

--
2.25.1

Quoted 6 lines

Series looks good to me:

However, many qtests are flaky on Windows. I get a number of "broken pipe" exit code 3 & timeout. Should gitlab ignore windows test failures ? Or perhaps have a new "ignored" job for the windows qtests. What's your experience running gitlab CI with this series? Can you share results? (I kicked off one here https://gitlab.com/marcandre.lureau/qemu/-/pipelines/679511572)

This "broken pipe" error was fixed by [1] which is currently in Daniel's tree. Please apply it in your tree and it should have a 100% pass rate.

[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

Regards,
Bin

#29 lore raw

Hi

Quoted 96 lines · Bin Meng
Quoted 17 lines · Marc-André Lureau

Hi

Quoted 13 lines · Bin Meng

In preparation to adding virtio-9p support on Windows, this series enables running qtest on Windows, so that we can run the virtio-9p tests on Windows to make sure it does not break accidently.

Changes in v6:
- drop patches that are already in Alex and Daniel's tree
- remove CONFIG_POSIX from meson.build
- include <qemu/sockets.h> in libqtest.c
- move documentation comments of qemu_send_full() from util/osdep.c to qemu/sockets.h
- save the "exit_code" in struct QTestState
- new patch: "tests/qtest: device-plug-test: Reverse the usage of

double/single quotes"

Quoted 4 lines
Quoted 4 lines

- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"
- change to use qtest_wait_qemu() API
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p

unconditionally"

Quoted 59 lines
Quoted 55 lines

Changes in v5:
- restore to v1 version which does not touch the posix implementation
- Drop patches that are already merged

Changes in v3:
- Add a usleep(1) in the busy wait loop
- Drop the host test

Changes in v2:
- Introduce qemu_send_full() and use it
- Move the enabling of building qtests on Windows to a separate patch to keep bisectablity
- Call socket_init() unconditionally
- Add a missing CloseHandle() call
- Change to a busy wait after migration is canceled
- Change the timeout limit to 90 minutes
- new patch: "tests/qtest: Enable qtest build on Windows"

Bin Meng (8):
tests/qtest: Support libqtest to build and run on Windows tests/qtest: device-plug-test: Reverse the usage of double/single
quotes
tests/qtest: Use EXIT_FAILURE instead of magic number tests/qtest: libqtest: Introduce qtest_wait_qemu() tests/qtest: libqos: Do not build virtio-9p unconditionally tests/qtest: libqtest: Correct the timeout unit of blocking receive
calls for win32
.gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes tests/qtest: Enable qtest build on Windows

Xuzhou Cheng (3):
accel/qtest: Support qtest accelerator for Windows tests/qtest: Use send/recv for socket communication tests/qtest: migration-test: Make sure QEMU process "to" exited after
migration is canceled

 include/hw/core/cpu.h           |   1 +
 include/qemu/sockets.h          |  13 +++
 tests/qtest/libqtest.h          |   9 ++
 accel/dummy-cpus.c              |  14 ++-
 softmmu/cpus.c                  |   9 +-
 tests/qtest/dbus-vmstate-test.c |   2 +-
 tests/qtest/device-plug-test.c  |  16 ++--
 tests/qtest/libqmp.c            |   5 +-
 tests/qtest/libqtest.c          | 151 ++++++++++++++++++++++++++++----
 tests/qtest/migration-test.c    |   8 +-
 util/osdep.c                    |  22 +++++
 .gitlab-ci.d/windows.yml        |   4 +-
 accel/meson.build               |   2 +-
 accel/qtest/meson.build         |   3 +-
 tests/qtest/libqos/meson.build  |   6 +-
 tests/qtest/meson.build         |   6 --
 16 files changed, 221 insertions(+), 50 deletions(-)
Quoted 3 lines

--
2.25.1

Quoted 5 lines

Series looks good to me:

However, many qtests are flaky on Windows. I get a number of "broken

pipe" exit code 3 & timeout. Should gitlab ignore windows test failures ? Or perhaps have a new "ignored" job for the windows qtests. What's your experience running gitlab CI with this series? Can you share results? (I kicked off one here
https://gitlab.com/marcandre.lureau/qemu/-/pipelines/679511572)

Quoted 1 line
Quoted 8 lines

This "broken pipe" error was fixed by [1] which is currently in Daniel's tree. Please apply it in your tree and it should have a 100% pass rate.

[1]
http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

Ok I have seen other tests randomly failing. Furthermore:
https://gitlab.com/marcandre.lureau/qemu/-/jobs/3241465230
ERROR: Job failed: execution took longer than 1h30m0s seconds

I think we should drop the last 2 patches for now, until CI testing is under control...

#30 lore raw
Quoted 101 lines · Marc-André Lureau

Hi

Quoted 87 lines · Bin Meng
Quoted 84 lines · Marc-André Lureau

Hi

Quoted 72 lines · Bin Meng

In preparation to adding virtio-9p support on Windows, this series enables running qtest on Windows, so that we can run the virtio-9p tests on Windows to make sure it does not break accidently.

Changes in v6:
- drop patches that are already in Alex and Daniel's tree
- remove CONFIG_POSIX from meson.build
- include <qemu/sockets.h> in libqtest.c
- move documentation comments of qemu_send_full() from util/osdep.c
to qemu/sockets.h
- save the "exit_code" in struct QTestState
- new patch: "tests/qtest: device-plug-test: Reverse the usage of double/single quotes"
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"
- change to use qtest_wait_qemu() API
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

Changes in v5:
- restore to v1 version which does not touch the posix implementation
- Drop patches that are already merged

Changes in v3:
- Add a usleep(1) in the busy wait loop
- Drop the host test

Changes in v2:
- Introduce qemu_send_full() and use it
- Move the enabling of building qtests on Windows to a separate patch to keep bisectablity
- Call socket_init() unconditionally
- Add a missing CloseHandle() call
- Change to a busy wait after migration is canceled
- Change the timeout limit to 90 minutes
- new patch: "tests/qtest: Enable qtest build on Windows"

Bin Meng (8):
tests/qtest: Support libqtest to build and run on Windows tests/qtest: device-plug-test: Reverse the usage of double/single
quotes
tests/qtest: Use EXIT_FAILURE instead of magic number tests/qtest: libqtest: Introduce qtest_wait_qemu() tests/qtest: libqos: Do not build virtio-9p unconditionally tests/qtest: libqtest: Correct the timeout unit of blocking receive
calls for win32
.gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes tests/qtest: Enable qtest build on Windows

Xuzhou Cheng (3):
accel/qtest: Support qtest accelerator for Windows tests/qtest: Use send/recv for socket communication tests/qtest: migration-test: Make sure QEMU process "to" exited after
migration is canceled

 include/hw/core/cpu.h           |   1 +
 include/qemu/sockets.h          |  13 +++
 tests/qtest/libqtest.h          |   9 ++
 accel/dummy-cpus.c              |  14 ++-
 softmmu/cpus.c                  |   9 +-
 tests/qtest/dbus-vmstate-test.c |   2 +-
 tests/qtest/device-plug-test.c  |  16 ++--
 tests/qtest/libqmp.c            |   5 +-
 tests/qtest/libqtest.c          | 151 ++++++++++++++++++++++++++++----
 tests/qtest/migration-test.c    |   8 +-
 util/osdep.c                    |  22 +++++
 .gitlab-ci.d/windows.yml        |   4 +-
 accel/meson.build               |   2 +-
 accel/qtest/meson.build         |   3 +-
 tests/qtest/libqos/meson.build  |   6 +-
 tests/qtest/meson.build         |   6 --
 16 files changed, 221 insertions(+), 50 deletions(-)
Quoted 3 lines

--
2.25.1

Series looks good to me:

Quoted 9 lines
Quoted 2 lines

However, many qtests are flaky on Windows. I get a number of "broken pipe" exit code 3 & timeout. Should gitlab ignore windows test failures ? Or perhaps have a new "ignored" job for the windows qtests. What's your experience running gitlab CI with this series? Can you share results? (I kicked off one here https://gitlab.com/marcandre.lureau/qemu/-/pipelines/679511572)

This "broken pipe" error was fixed by [1] which is currently in Daniel's tree. Please apply it in your tree and it should have a 100% pass rate.

[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

Quoted 6 lines

Ok I have seen other tests randomly failing. Furthermore:
https://gitlab.com/marcandre.lureau/qemu/-/jobs/3241465230
ERROR: Job failed: execution took longer than 1h30m0s seconds

I think we should drop the last 2 patches for now, until CI testing is under control...

2 hours is the maximum time supported by the gitlab shared runners which should be enough.

However people may feel that it takes too long ...

Regards,
Bin

#31 lore raw
Quoted 108 lines · Bin Meng
Quoted 106 lines · Marc-André Lureau

Hi

Quoted 87 lines · Bin Meng
Quoted 84 lines · Marc-André Lureau

Hi

Quoted 72 lines · Bin Meng

In preparation to adding virtio-9p support on Windows, this series enables running qtest on Windows, so that we can run the virtio-9p tests on Windows to make sure it does not break accidently.

Changes in v6:
- drop patches that are already in Alex and Daniel's tree
- remove CONFIG_POSIX from meson.build
- include <qemu/sockets.h> in libqtest.c
- move documentation comments of qemu_send_full() from util/osdep.c
to qemu/sockets.h
- save the "exit_code" in struct QTestState
- new patch: "tests/qtest: device-plug-test: Reverse the usage of double/single quotes"
- new patch: "tests/qtest: Use EXIT_FAILURE instead of magic number"
- new patch: "tests/qtest: libqtest: Introduce qtest_wait_qemu()"
- change to use qtest_wait_qemu() API
- new patch: "test/qtest/libqos: meson.build: Do not build virtio-9p unconditionally"

Changes in v5:
- restore to v1 version which does not touch the posix implementation
- Drop patches that are already merged

Changes in v3:
- Add a usleep(1) in the busy wait loop
- Drop the host test

Changes in v2:
- Introduce qemu_send_full() and use it
- Move the enabling of building qtests on Windows to a separate patch to keep bisectablity
- Call socket_init() unconditionally
- Add a missing CloseHandle() call
- Change to a busy wait after migration is canceled
- Change the timeout limit to 90 minutes
- new patch: "tests/qtest: Enable qtest build on Windows"

Bin Meng (8):
tests/qtest: Support libqtest to build and run on Windows tests/qtest: device-plug-test: Reverse the usage of double/single
quotes
tests/qtest: Use EXIT_FAILURE instead of magic number tests/qtest: libqtest: Introduce qtest_wait_qemu() tests/qtest: libqos: Do not build virtio-9p unconditionally tests/qtest: libqtest: Correct the timeout unit of blocking receive
calls for win32
.gitlab-ci.d/windows.yml: Increase the timeout to 90 minutes tests/qtest: Enable qtest build on Windows

Xuzhou Cheng (3):
accel/qtest: Support qtest accelerator for Windows tests/qtest: Use send/recv for socket communication tests/qtest: migration-test: Make sure QEMU process "to" exited after
migration is canceled

  include/hw/core/cpu.h           |   1 +
  include/qemu/sockets.h          |  13 +++
  tests/qtest/libqtest.h          |   9 ++
  accel/dummy-cpus.c              |  14 ++-
  softmmu/cpus.c                  |   9 +-
  tests/qtest/dbus-vmstate-test.c |   2 +-
  tests/qtest/device-plug-test.c  |  16 ++--
  tests/qtest/libqmp.c            |   5 +-
  tests/qtest/libqtest.c          | 151 ++++++++++++++++++++++++++++----
  tests/qtest/migration-test.c    |   8 +-
  util/osdep.c                    |  22 +++++
  .gitlab-ci.d/windows.yml        |   4 +-
  accel/meson.build               |   2 +-
  accel/qtest/meson.build         |   3 +-
  tests/qtest/libqos/meson.build  |   6 +-
  tests/qtest/meson.build         |   6 --
  16 files changed, 221 insertions(+), 50 deletions(-)
Quoted 3 lines

--
2.25.1

Series looks good to me:

Quoted 9 lines
Quoted 2 lines

However, many qtests are flaky on Windows. I get a number of "broken pipe" exit code 3 & timeout. Should gitlab ignore windows test failures ? Or perhaps have a new "ignored" job for the windows qtests. What's your experience running gitlab CI with this series? Can you share results? (I kicked off one here https://gitlab.com/marcandre.lureau/qemu/-/pipelines/679511572)

This "broken pipe" error was fixed by [1] which is currently in Daniel's tree. Please apply it in your tree and it should have a 100% pass rate.

[1] http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/

Ok I have seen other tests randomly failing. Furthermore:
https://gitlab.com/marcandre.lureau/qemu/-/jobs/3241465230
ERROR: Job failed: execution took longer than 1h30m0s seconds

Quoted 6 lines
Quoted 1 line

I think we should drop the last 2 patches for now, until CI testing is under control...

2 hours is the maximum time supported by the gitlab shared runners which should be enough.

However people may feel that it takes too long ...

Most jobs run fine within the default timeout of 60 minutes, we've got some few exceptions where we bumped it to 70, 80 or even 90 minutes. But I think that should really be the uppermost limit - using even more than 90 minutes for the slow-running Windows job just feels wrong.

Aren't there other possibilities to cut the run time again? Maybe compile with --disable-tools? ... searching for "mingw compilation slow" in the internet also reveals that a lot of other people are seeing problems with the compilation speed of MinGW ... but there does not seem to be one ultimate solution that worked for everybody to speed it up...

I'll queue patches 1-9 for now so that we get the important parts in before the soft freeze starts ... if we finally figure out how to deal with the slow CI jobs best, I think it's also still OK if we enable it later before the hard freeze starts.

Thomas