mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
* block/iscsi: fix double-free on BUSY or similar statuses
* catch [accel] entry without accelerator * target/i386: various fixes for BMI and ADX instructions * make the contents of meson-buildoptions.sh stable -----BEGIN PGP SIGNATURE----- iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmPpDTcUHHBib256aW5p QHJlZGhhdC5jb20ACgkQv/vSX3jHroODWAgAhWi0XSBe91+34ahQqx6JoLStNX9e xy1Cm/5LPDrDquD/4T6gnzb1Min/X2AsVu9c+VIbuHbL/rFc7aNIEL6c7KzwSFLs vEDF7tSnlIMK0ClDsDYBz7HUIgBgqE2crAJmTJus2Cqd+Ef5bMxhQi5Imrk6qtmO HRdVYEGasJ7CO50oUB91AMrNInWQw0qBnBOB8TnwTLTcvE1txa+xnZuZgQA2HrGX OweLdKRcYPvRYvBB3wLMbwqEKbD1eYbdbNt7T2KkuVQpYcgfoCpayHIIMroD+hvu BImmG9wWieDKH4Brs765gH6/3VF5UZKbgDQo9Wz+W/5QqnqRSsOYBiMkmA== =G3PN -----END PGP SIGNATURE----- Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging * block/iscsi: fix double-free on BUSY or similar statuses * catch [accel] entry without accelerator * target/i386: various fixes for BMI and ADX instructions * make the contents of meson-buildoptions.sh stable # -----BEGIN PGP SIGNATURE----- # # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmPpDTcUHHBib256aW5p # QHJlZGhhdC5jb20ACgkQv/vSX3jHroODWAgAhWi0XSBe91+34ahQqx6JoLStNX9e # xy1Cm/5LPDrDquD/4T6gnzb1Min/X2AsVu9c+VIbuHbL/rFc7aNIEL6c7KzwSFLs # vEDF7tSnlIMK0ClDsDYBz7HUIgBgqE2crAJmTJus2Cqd+Ef5bMxhQi5Imrk6qtmO # HRdVYEGasJ7CO50oUB91AMrNInWQw0qBnBOB8TnwTLTcvE1txa+xnZuZgQA2HrGX # OweLdKRcYPvRYvBB3wLMbwqEKbD1eYbdbNt7T2KkuVQpYcgfoCpayHIIMroD+hvu # BImmG9wWieDKH4Brs765gH6/3VF5UZKbgDQo9Wz+W/5QqnqRSsOYBiMkmA== # =G3PN # -----END PGP SIGNATURE----- # gpg: Signature made Sun 12 Feb 2023 16:00:55 GMT # gpg: using RSA key F13338574B662389866C7682BFFBD25F78C7AE83 # gpg: issuer "pbonzini@redhat.com" # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [full] # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" [full] # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * tag 'for-upstream' of https://gitlab.com/bonzini/qemu: libqtest: ensure waitpid() is only called once libqtest: split qtest_spawn_qemu function target/i386: fix ADOX followed by ADCX target/i386: Fix C flag for BLSI, BLSMSK, BLSR target/i386: Fix BEXTR instruction tests/tcg/i386: Introduce and use reg_t consistently vl: catch [accel] entry without accelerator block/iscsi: fix double-free on BUSY or similar statuses remove unnecessary extern "C" blocks build: make meson-buildoptions.sh stable Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
003ba52a8b
15 changed files with 316 additions and 234 deletions
|
@ -158,6 +158,7 @@ bool qtest_probe_child(QTestState *s)
|
|||
CloseHandle((HANDLE)pid);
|
||||
#endif
|
||||
s->qemu_pid = -1;
|
||||
qtest_remove_abrt_handler(s);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -169,6 +170,8 @@ void qtest_set_expected_status(QTestState *s, int status)
|
|||
|
||||
static void qtest_check_status(QTestState *s)
|
||||
{
|
||||
assert(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.
|
||||
|
@ -202,36 +205,40 @@ static void qtest_check_status(QTestState *s)
|
|||
|
||||
void qtest_wait_qemu(QTestState *s)
|
||||
{
|
||||
if (s->qemu_pid != -1) {
|
||||
#ifndef _WIN32
|
||||
pid_t pid;
|
||||
uint64_t end;
|
||||
pid_t pid;
|
||||
uint64_t end;
|
||||
|
||||
/* poll for a while until sending SIGKILL */
|
||||
end = g_get_monotonic_time() + WAITPID_TIMEOUT * G_TIME_SPAN_SECOND;
|
||||
/* poll for a while until sending SIGKILL */
|
||||
end = g_get_monotonic_time() + WAITPID_TIMEOUT * G_TIME_SPAN_SECOND;
|
||||
|
||||
do {
|
||||
pid = waitpid(s->qemu_pid, &s->wstatus, WNOHANG);
|
||||
if (pid != 0) {
|
||||
break;
|
||||
do {
|
||||
pid = waitpid(s->qemu_pid, &s->wstatus, WNOHANG);
|
||||
if (pid != 0) {
|
||||
break;
|
||||
}
|
||||
g_usleep(100 * 1000);
|
||||
} while (g_get_monotonic_time() < end);
|
||||
|
||||
if (pid == 0) {
|
||||
kill(s->qemu_pid, SIGKILL);
|
||||
pid = RETRY_ON_EINTR(waitpid(s->qemu_pid, &s->wstatus, 0));
|
||||
}
|
||||
g_usleep(100 * 1000);
|
||||
} while (g_get_monotonic_time() < end);
|
||||
|
||||
if (pid == 0) {
|
||||
kill(s->qemu_pid, SIGKILL);
|
||||
pid = RETRY_ON_EINTR(waitpid(s->qemu_pid, &s->wstatus, 0));
|
||||
}
|
||||
|
||||
assert(pid == s->qemu_pid);
|
||||
assert(pid == s->qemu_pid);
|
||||
#else
|
||||
DWORD ret;
|
||||
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);
|
||||
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
|
||||
|
||||
s->qemu_pid = -1;
|
||||
qtest_remove_abrt_handler(s);
|
||||
}
|
||||
qtest_check_status(s);
|
||||
}
|
||||
|
||||
|
@ -245,7 +252,6 @@ void qtest_kill_qemu(QTestState *s)
|
|||
TerminateProcess((HANDLE)s->qemu_pid, s->expected_status);
|
||||
#endif
|
||||
qtest_wait_qemu(s);
|
||||
s->qemu_pid = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -307,6 +313,11 @@ void qtest_add_abrt_handler(GHookFunc fn, const void *data)
|
|||
void qtest_remove_abrt_handler(void *data)
|
||||
{
|
||||
GHook *hook = g_hook_find_data(&abrt_hooks, TRUE, data);
|
||||
|
||||
if (!hook) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_hook_destroy_link(&abrt_hooks, hook);
|
||||
|
||||
/* Uninstall SIGABRT handler on last instance */
|
||||
|
@ -360,60 +371,25 @@ static pid_t qtest_create_process(char *cmd)
|
|||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
|
||||
static QTestState *G_GNUC_PRINTF(1, 2) qtest_spawn_qemu(const char *fmt, ...)
|
||||
{
|
||||
QTestState *s;
|
||||
int sock, qmpsock, i;
|
||||
gchar *socket_path;
|
||||
gchar *qmp_socket_path;
|
||||
gchar *command;
|
||||
const char *qemu_binary = qtest_qemu_binary();
|
||||
va_list ap;
|
||||
QTestState *s = g_new0(QTestState, 1);
|
||||
const char *trace = g_getenv("QTEST_TRACE");
|
||||
g_autofree char *tracearg = trace ?
|
||||
g_strdup_printf("-trace %s ", trace) : g_strdup("");
|
||||
g_autoptr(GString) command = g_string_new("");
|
||||
|
||||
s = g_new(QTestState, 1);
|
||||
|
||||
socket_path = g_strdup_printf("%s/qtest-%d.sock",
|
||||
g_get_tmp_dir(), getpid());
|
||||
qmp_socket_path = g_strdup_printf("%s/qtest-%d.qmp",
|
||||
g_get_tmp_dir(), getpid());
|
||||
|
||||
/* It's possible that if an earlier test run crashed it might
|
||||
* have left a stale unix socket lying around. Delete any
|
||||
* stale old socket to avoid spurious test failures with
|
||||
* tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
|
||||
*/
|
||||
unlink(socket_path);
|
||||
unlink(qmp_socket_path);
|
||||
|
||||
socket_init();
|
||||
sock = init_socket(socket_path);
|
||||
qmpsock = init_socket(qmp_socket_path);
|
||||
|
||||
qtest_client_set_rx_handler(s, qtest_client_socket_recv_line);
|
||||
qtest_client_set_tx_handler(s, qtest_client_socket_send);
|
||||
va_start(ap, fmt);
|
||||
g_string_append_printf(command, CMD_EXEC "%s %s",
|
||||
qtest_qemu_binary(), tracearg);
|
||||
g_string_append_vprintf(command, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
qtest_add_abrt_handler(kill_qemu_hook_func, s);
|
||||
|
||||
command = g_strdup_printf(CMD_EXEC "%s %s"
|
||||
"-qtest unix:%s "
|
||||
"-qtest-log %s "
|
||||
"-chardev socket,path=%s,id=char0 "
|
||||
"-mon chardev=char0,mode=control "
|
||||
"-display none "
|
||||
"%s"
|
||||
" -accel qtest",
|
||||
qemu_binary, tracearg, socket_path,
|
||||
getenv("QTEST_LOG") ? DEV_STDERR : DEV_NULL,
|
||||
qmp_socket_path,
|
||||
extra_args ?: "");
|
||||
g_test_message("starting QEMU: %s", command->str);
|
||||
|
||||
g_test_message("starting QEMU: %s", command);
|
||||
|
||||
s->pending_events = NULL;
|
||||
s->wstatus = 0;
|
||||
s->expected_status = 0;
|
||||
#ifndef _WIN32
|
||||
s->qemu_pid = fork();
|
||||
if (s->qemu_pid == 0) {
|
||||
|
@ -434,14 +410,56 @@ QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
|
|||
if (!g_setenv("QEMU_AUDIO_DRV", "none", true)) {
|
||||
exit(1);
|
||||
}
|
||||
execlp("/bin/sh", "sh", "-c", command, NULL);
|
||||
execlp("/bin/sh", "sh", "-c", command->str, NULL);
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
s->qemu_pid = qtest_create_process(command);
|
||||
s->qemu_pid = qtest_create_process(command->str);
|
||||
#endif /* _WIN32 */
|
||||
|
||||
g_free(command);
|
||||
return s;
|
||||
}
|
||||
|
||||
QTestState *qtest_init_without_qmp_handshake(const char *extra_args)
|
||||
{
|
||||
QTestState *s;
|
||||
int sock, qmpsock, i;
|
||||
gchar *socket_path;
|
||||
gchar *qmp_socket_path;
|
||||
|
||||
socket_path = g_strdup_printf("%s/qtest-%d.sock",
|
||||
g_get_tmp_dir(), getpid());
|
||||
qmp_socket_path = g_strdup_printf("%s/qtest-%d.qmp",
|
||||
g_get_tmp_dir(), getpid());
|
||||
|
||||
/*
|
||||
* It's possible that if an earlier test run crashed it might
|
||||
* have left a stale unix socket lying around. Delete any
|
||||
* stale old socket to avoid spurious test failures with
|
||||
* tests/libqtest.c:70:init_socket: assertion failed (ret != -1): (-1 != -1)
|
||||
*/
|
||||
unlink(socket_path);
|
||||
unlink(qmp_socket_path);
|
||||
|
||||
socket_init();
|
||||
sock = init_socket(socket_path);
|
||||
qmpsock = init_socket(qmp_socket_path);
|
||||
|
||||
s = qtest_spawn_qemu("-qtest unix:%s "
|
||||
"-qtest-log %s "
|
||||
"-chardev socket,path=%s,id=char0 "
|
||||
"-mon chardev=char0,mode=control "
|
||||
"-display none "
|
||||
"%s"
|
||||
" -accel qtest",
|
||||
socket_path,
|
||||
getenv("QTEST_LOG") ? DEV_STDERR : DEV_NULL,
|
||||
qmp_socket_path,
|
||||
extra_args ?: "");
|
||||
|
||||
qtest_client_set_rx_handler(s, qtest_client_socket_recv_line);
|
||||
qtest_client_set_tx_handler(s, qtest_client_socket_send);
|
||||
|
||||
s->fd = socket_accept(sock);
|
||||
if (s->fd >= 0) {
|
||||
s->qmp_fd = socket_accept(qmpsock);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue