[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/21] accel/qtest: Support qtest accelerator for Windows
From: |
Thomas Huth |
Subject: |
[PULL 13/21] accel/qtest: Support qtest accelerator for Windows |
Date: |
Fri, 28 Oct 2022 15:22:56 +0200 |
From: Xuzhou Cheng <xuzhou.cheng@windriver.com>
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.
Signed-off-by: Xuzhou Cheng <xuzhou.cheng@windriver.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20221028045736.679903-2-bin.meng@windriver.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
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(-)
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index f9b58773f7..8830546121 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -333,6 +333,7 @@ struct CPUState {
struct QemuThread *thread;
#ifdef _WIN32
HANDLE hThread;
+ QemuSemaphore sem;
#endif
int thread_id;
bool running, has_waiter;
diff --git a/accel/dummy-cpus.c b/accel/dummy-cpus.c
index 10429fdfb2..d6a1b8d0a2 100644
--- a/accel/dummy-cpus.c
+++ b/accel/dummy-cpus.c
@@ -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
}
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 61b27ff59d..9dd1a4dc17 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -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
}
diff --git a/accel/meson.build b/accel/meson.build
index b9a963cf80..259c35c4c8 100644
--- a/accel/meson.build
+++ b/accel/meson.build
@@ -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)
diff --git a/accel/qtest/meson.build b/accel/qtest/meson.build
index 4c65600293..176d990ae1 100644
--- a/accel/qtest/meson.build
+++ b/accel/qtest/meson.build
@@ -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'))
--
2.31.1
- [PULL 05/21] target/s390x: Fix emulation of the VISTR instruction, (continued)
- [PULL 05/21] target/s390x: Fix emulation of the VISTR instruction, Thomas Huth, 2022/10/28
- [PULL 02/21] s390x: step down as general arch maintainer, Thomas Huth, 2022/10/28
- [PULL 07/21] MAINTAINERS: target/s390x/: add Ilya as reviewer, Thomas Huth, 2022/10/28
- [PULL 01/21] s390x/pv: remove semicolon from macro definition, Thomas Huth, 2022/10/28
- [PULL 06/21] tests/tcg/s390x: Add a test for the vistr instruction, Thomas Huth, 2022/10/28
- [PULL 09/21] tests/qtest/cxl-test: Remove temporary directories after testing, Thomas Huth, 2022/10/28
- [PULL 08/21] tests/qtest/tpm: Clean up remainders of swtpm, Thomas Huth, 2022/10/28
- [PULL 12/21] tests: Add sndio to the FreeBSD CI containers / VM, Thomas Huth, 2022/10/28
- [PULL 15/21] tests/qtest: Support libqtest to build and run on Windows, Thomas Huth, 2022/10/28
- [PULL 10/21] tests/qtest/libqos/e1000e: Use e1000_regs.h, Thomas Huth, 2022/10/28
- [PULL 13/21] accel/qtest: Support qtest accelerator for Windows,
Thomas Huth <=
- [PULL 16/21] tests/qtest: device-plug-test: Reverse the usage of double/single quotes, Thomas Huth, 2022/10/28
- [PULL 11/21] tests/vm: update openbsd to release 7.2, Thomas Huth, 2022/10/28
- [PULL 14/21] tests/qtest: Use send/recv for socket communication, Thomas Huth, 2022/10/28
- [PULL 18/21] tests/qtest: libqtest: Introduce qtest_wait_qemu(), Thomas Huth, 2022/10/28
- [PULL 19/21] tests/qtest: migration-test: Make sure QEMU process "to" exited after migration is canceled, Thomas Huth, 2022/10/28
- [PULL 20/21] tests/qtest: libqos: Do not build virtio-9p unconditionally, Thomas Huth, 2022/10/28
- [PULL 21/21] tests/qtest: libqtest: Correct the timeout unit of blocking receive calls for win32, Thomas Huth, 2022/10/28
- [PULL 17/21] tests/qtest: Use EXIT_FAILURE instead of magic number, Thomas Huth, 2022/10/28
- Re: [PULL 00/21] s390x and qtest patches, Stefan Hajnoczi, 2022/10/31
- Re: [PULL 00/21] s390x and qtest patches, Stefan Hajnoczi, 2022/10/31