util/async-teardown: wire up query-command-line-options
Add new -run-with option with an async-teardown=on|off parameter. It is
visible in the output of query-command-line-options QMP command, so it
can be discovered and used by libvirt.
The option -async-teardown is now redundant, deprecate it.
Reported-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Fixes: c891c24b1a
("os-posix: asynchronous teardown for shutdown on Linux")
Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Message-Id: <20230505120051.36605-2-imbrenda@linux.ibm.com>
[thuth: Add curly braces to fix error with GCC 8.5, fix bug in deprecated.rst]
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
parent
da9000784c
commit
80bd81cadd
@ -111,6 +111,11 @@ Use ``-machine acpi=off`` instead.
|
|||||||
The HAXM project has been retired (see https://github.com/intel/haxm#status).
|
The HAXM project has been retired (see https://github.com/intel/haxm#status).
|
||||||
Use "whpx" (on Windows) or "hvf" (on macOS) instead.
|
Use "whpx" (on Windows) or "hvf" (on macOS) instead.
|
||||||
|
|
||||||
|
``-async-teardown`` (since 8.1)
|
||||||
|
'''''''''''''''''''''''''''''''
|
||||||
|
|
||||||
|
Use ``-run-with async-teardown=on`` instead.
|
||||||
|
|
||||||
``-singlestep`` (since 8.1)
|
``-singlestep`` (since 8.1)
|
||||||
'''''''''''''''''''''''''''
|
'''''''''''''''''''''''''''
|
||||||
|
|
||||||
|
14
os-posix.c
14
os-posix.c
@ -36,6 +36,8 @@
|
|||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
#include "sysemu/runstate.h"
|
#include "sysemu/runstate.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
|
#include "qemu/config-file.h"
|
||||||
|
#include "qemu/option.h"
|
||||||
|
|
||||||
#ifdef CONFIG_LINUX
|
#ifdef CONFIG_LINUX
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
@ -152,9 +154,21 @@ int os_parse_cmd_args(int index, const char *optarg)
|
|||||||
daemonize = 1;
|
daemonize = 1;
|
||||||
break;
|
break;
|
||||||
#if defined(CONFIG_LINUX)
|
#if defined(CONFIG_LINUX)
|
||||||
|
/* deprecated */
|
||||||
case QEMU_OPTION_asyncteardown:
|
case QEMU_OPTION_asyncteardown:
|
||||||
init_async_teardown();
|
init_async_teardown();
|
||||||
break;
|
break;
|
||||||
|
case QEMU_OPTION_run_with: {
|
||||||
|
QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("run-with"),
|
||||||
|
optarg, false);
|
||||||
|
if (!opts) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (qemu_opt_get_bool(opts, "async-teardown", false)) {
|
||||||
|
init_async_teardown();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -4828,20 +4828,32 @@ DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "", QEMU_ARCH_ALL)
|
|||||||
DEF("async-teardown", 0, QEMU_OPTION_asyncteardown,
|
DEF("async-teardown", 0, QEMU_OPTION_asyncteardown,
|
||||||
"-async-teardown enable asynchronous teardown\n",
|
"-async-teardown enable asynchronous teardown\n",
|
||||||
QEMU_ARCH_ALL)
|
QEMU_ARCH_ALL)
|
||||||
#endif
|
|
||||||
SRST
|
SRST
|
||||||
``-async-teardown``
|
``-async-teardown``
|
||||||
Enable asynchronous teardown. A new process called "cleanup/<QEMU_PID>"
|
This option is deprecated and should no longer be used. The new option
|
||||||
will be created at startup sharing the address space with the main qemu
|
``-run-with async-teardown=on`` is a replacement.
|
||||||
process, using clone. It will wait for the main qemu process to
|
|
||||||
terminate completely, and then exit.
|
|
||||||
This allows qemu to terminate very quickly even if the guest was
|
|
||||||
huge, leaving the teardown of the address space to the cleanup
|
|
||||||
process. Since the cleanup process shares the same cgroups as the
|
|
||||||
main qemu process, accounting is performed correctly. This only
|
|
||||||
works if the cleanup process is not forcefully killed with SIGKILL
|
|
||||||
before the main qemu process has terminated completely.
|
|
||||||
ERST
|
ERST
|
||||||
|
DEF("run-with", HAS_ARG, QEMU_OPTION_run_with,
|
||||||
|
"-run-with async-teardown[=on|off]\n"
|
||||||
|
" misc QEMU process lifecycle options\n"
|
||||||
|
" async-teardown=on enables asynchronous teardown\n",
|
||||||
|
QEMU_ARCH_ALL)
|
||||||
|
SRST
|
||||||
|
``-run-with``
|
||||||
|
Set QEMU process lifecycle options.
|
||||||
|
|
||||||
|
``async-teardown=on`` enables asynchronous teardown. A new process called
|
||||||
|
"cleanup/<QEMU_PID>" will be created at startup sharing the address
|
||||||
|
space with the main QEMU process, using clone. It will wait for the
|
||||||
|
main QEMU process to terminate completely, and then exit. This allows
|
||||||
|
QEMU to terminate very quickly even if the guest was huge, leaving the
|
||||||
|
teardown of the address space to the cleanup process. Since the cleanup
|
||||||
|
process shares the same cgroups as the main QEMU process, accounting is
|
||||||
|
performed correctly. This only works if the cleanup process is not
|
||||||
|
forcefully killed with SIGKILL before the main QEMU process has
|
||||||
|
terminated completely.
|
||||||
|
ERST
|
||||||
|
#endif
|
||||||
|
|
||||||
DEF("msg", HAS_ARG, QEMU_OPTION_msg,
|
DEF("msg", HAS_ARG, QEMU_OPTION_msg,
|
||||||
"-msg [timestamp[=on|off]][,guest-name=[on|off]]\n"
|
"-msg [timestamp[=on|off]][,guest-name=[on|off]]\n"
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
|
#include "qemu/config-file.h"
|
||||||
|
#include "qemu/option.h"
|
||||||
|
#include "qemu/module.h"
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
@ -144,3 +147,21 @@ void init_async_teardown(void)
|
|||||||
clone(async_teardown_fn, new_stack_for_clone(), CLONE_VM, NULL);
|
clone(async_teardown_fn, new_stack_for_clone(), CLONE_VM, NULL);
|
||||||
sigprocmask(SIG_SETMASK, &old_signals, NULL);
|
sigprocmask(SIG_SETMASK, &old_signals, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QemuOptsList qemu_run_with_opts = {
|
||||||
|
.name = "run-with",
|
||||||
|
.head = QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head),
|
||||||
|
.desc = {
|
||||||
|
{
|
||||||
|
.name = "async-teardown",
|
||||||
|
.type = QEMU_OPT_BOOL,
|
||||||
|
},
|
||||||
|
{ /* end of list */ }
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static void register_teardown(void)
|
||||||
|
{
|
||||||
|
qemu_add_opts(&qemu_run_with_opts);
|
||||||
|
}
|
||||||
|
opts_init(register_teardown);
|
||||||
|
Loading…
Reference in New Issue
Block a user