* [PATCH v6 0/1] util/async-teardown: appear in query-command-line-options
@ 2023-04-28 11:12 Claudio Imbrenda
2023-04-28 11:12 ` [PATCH v6 1/1] util/async-teardown: wire up query-command-line-options Claudio Imbrenda
0 siblings, 1 reply; 4+ messages in thread
From: Claudio Imbrenda @ 2023-04-28 11:12 UTC (permalink / raw)
To: pbonzini
Cc: qemu-devel, david, thuth, borntraeger, frankja, fiuczy, pasic,
nsg, berrange, alex.bennee, armbru
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.
v5->v6
* deprecate the old -async-teardown option instead of removing it,
since it has now appeared in 2 QEMU releases
* use -run-with as a grab bag commandline option for the async-teardown
boolean parameter [paolo,markus,thomas]
v4->v5
* reword commit message [Markus]
* document the removal of the -async-teardown commandline option in
docs/about/removed-features.rst [Markus]
v3->v4
* completely remove the useless -async-teardown option, since it was
not wired up properly and it had no users [thomas]
* QEMU should be always uppercase in text and documentation [thomas]
* if the new -teardown option fails to parse, exit immediately instead
of returning an error [thomas]
v2->v3
* add a new teardown option with an async parameter [Markus]
* reworded documentation of existing -async-teardown option so that it
points to the new teardown option
v1->v2
* remove the unneeded .implied_opt_name initializer [Thomas]
Claudio Imbrenda (1):
util/async-teardown: wire up query-command-line-options
docs/about/deprecated.rst | 5 +++++
os-posix.c | 15 +++++++++++++++
qemu-options.hx | 34 +++++++++++++++++++++++-----------
util/async-teardown.c | 21 +++++++++++++++++++++
4 files changed, 64 insertions(+), 11 deletions(-)
--
2.40.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v6 1/1] util/async-teardown: wire up query-command-line-options
2023-04-28 11:12 [PATCH v6 0/1] util/async-teardown: appear in query-command-line-options Claudio Imbrenda
@ 2023-04-28 11:12 ` Claudio Imbrenda
2023-04-28 12:16 ` Thomas Huth
0 siblings, 1 reply; 4+ messages in thread
From: Claudio Imbrenda @ 2023-04-28 11:12 UTC (permalink / raw)
To: pbonzini
Cc: qemu-devel, david, thuth, borntraeger, frankja, fiuczy, pasic,
nsg, berrange, alex.bennee, armbru
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>
---
docs/about/deprecated.rst | 5 +++++
os-posix.c | 15 +++++++++++++++
qemu-options.hx | 34 +++++++++++++++++++++++-----------
util/async-teardown.c | 21 +++++++++++++++++++++
4 files changed, 64 insertions(+), 11 deletions(-)
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 1ca9dc33d6..0986db9a86 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -111,6 +111,11 @@ Use ``-machine acpi=off`` instead.
The HAXM project has been retired (see https://github.com/intel/haxm#status).
Use "whpx" (on Windows) or "hvf" (on macOS) instead.
+``-async-teardown`` (since 8.1)
+,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+
+Use ``-run-with async-teardown=on`` instead.
+
QEMU Machine Protocol (QMP) commands
------------------------------------
diff --git a/os-posix.c b/os-posix.c
index 5adc69f560..117ad2bdc1 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -36,6 +36,8 @@
#include "qemu/log.h"
#include "sysemu/runstate.h"
#include "qemu/cutils.h"
+#include "qemu/config-file.h"
+#include "qemu/option.h"
#ifdef CONFIG_LINUX
#include <sys/prctl.h>
@@ -132,6 +134,8 @@ static bool os_parse_runas_uid_gid(const char *optarg)
*/
int os_parse_cmd_args(int index, const char *optarg)
{
+ QemuOpts *opts;
+
switch (index) {
case QEMU_OPTION_runas:
user_pwd = getpwnam(optarg);
@@ -152,9 +156,20 @@ int os_parse_cmd_args(int index, const char *optarg)
daemonize = 1;
break;
#if defined(CONFIG_LINUX)
+ /* deprecated */
case QEMU_OPTION_asyncteardown:
init_async_teardown();
break;
+ case QEMU_OPTION_run_with:
+ 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
default:
return -1;
diff --git a/qemu-options.hx b/qemu-options.hx
index b5efa648ba..24a1d63bbe 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4799,20 +4799,32 @@ DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "", QEMU_ARCH_ALL)
DEF("async-teardown", 0, QEMU_OPTION_asyncteardown,
"-async-teardown enable asynchronous teardown\n",
QEMU_ARCH_ALL)
-#endif
SRST
``-async-teardown``
- Enable 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.
+ This option is deprecated and should no longer be used. The new option
+ ``-run-with async-teardown=on`` is a replacement.
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,
"-msg [timestamp[=on|off]][,guest-name=[on|off]]\n"
diff --git a/util/async-teardown.c b/util/async-teardown.c
index 62cdeb0f20..3ab19c8740 100644
--- a/util/async-teardown.c
+++ b/util/async-teardown.c
@@ -12,6 +12,9 @@
*/
#include "qemu/osdep.h"
+#include "qemu/config-file.h"
+#include "qemu/option.h"
+#include "qemu/module.h"
#include <dirent.h>
#include <sys/prctl.h>
#include <sched.h>
@@ -144,3 +147,21 @@ void init_async_teardown(void)
clone(async_teardown_fn, new_stack_for_clone(), CLONE_VM, 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);
--
2.40.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v6 1/1] util/async-teardown: wire up query-command-line-options
2023-04-28 11:12 ` [PATCH v6 1/1] util/async-teardown: wire up query-command-line-options Claudio Imbrenda
@ 2023-04-28 12:16 ` Thomas Huth
2023-04-28 12:36 ` Claudio Imbrenda
0 siblings, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2023-04-28 12:16 UTC (permalink / raw)
To: Claudio Imbrenda, pbonzini
Cc: qemu-devel, david, borntraeger, frankja, fiuczy, pasic, nsg,
berrange, alex.bennee, armbru
On 28/04/2023 13.12, Claudio Imbrenda wrote:
> 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>
> ---
> docs/about/deprecated.rst | 5 +++++
> os-posix.c | 15 +++++++++++++++
> qemu-options.hx | 34 +++++++++++++++++++++++-----------
> util/async-teardown.c | 21 +++++++++++++++++++++
> 4 files changed, 64 insertions(+), 11 deletions(-)
>
> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> index 1ca9dc33d6..0986db9a86 100644
> --- a/docs/about/deprecated.rst
> +++ b/docs/about/deprecated.rst
> @@ -111,6 +111,11 @@ Use ``-machine acpi=off`` instead.
> The HAXM project has been retired (see https://github.com/intel/haxm#status).
> Use "whpx" (on Windows) or "hvf" (on macOS) instead.
>
> +``-async-teardown`` (since 8.1)
> +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
> +
> +Use ``-run-with async-teardown=on`` instead.
> +
>
> QEMU Machine Protocol (QMP) commands
> ------------------------------------
> diff --git a/os-posix.c b/os-posix.c
> index 5adc69f560..117ad2bdc1 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -36,6 +36,8 @@
> #include "qemu/log.h"
> #include "sysemu/runstate.h"
> #include "qemu/cutils.h"
> +#include "qemu/config-file.h"
> +#include "qemu/option.h"
>
> #ifdef CONFIG_LINUX
> #include <sys/prctl.h>
> @@ -132,6 +134,8 @@ static bool os_parse_runas_uid_gid(const char *optarg)
> */
> int os_parse_cmd_args(int index, const char *optarg)
> {
> + QemuOpts *opts;
Fails to compile on FreeBSD:
../src/os-posix.c:137:15: error: unused variable 'opts'
[-Werror,-Wunused-variable]
QemuOpts *opts;
^
1 error generated.
Apart from that, the patch looks fine to me.
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v6 1/1] util/async-teardown: wire up query-command-line-options
2023-04-28 12:16 ` Thomas Huth
@ 2023-04-28 12:36 ` Claudio Imbrenda
0 siblings, 0 replies; 4+ messages in thread
From: Claudio Imbrenda @ 2023-04-28 12:36 UTC (permalink / raw)
To: Thomas Huth
Cc: pbonzini, qemu-devel, david, borntraeger, frankja, fiuczy, pasic,
nsg, berrange, alex.bennee, armbru
On Fri, 28 Apr 2023 14:16:42 +0200
Thomas Huth <thuth@redhat.com> wrote:
> On 28/04/2023 13.12, Claudio Imbrenda wrote:
> > 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>
> > ---
> > docs/about/deprecated.rst | 5 +++++
> > os-posix.c | 15 +++++++++++++++
> > qemu-options.hx | 34 +++++++++++++++++++++++-----------
> > util/async-teardown.c | 21 +++++++++++++++++++++
> > 4 files changed, 64 insertions(+), 11 deletions(-)
> >
> > diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> > index 1ca9dc33d6..0986db9a86 100644
> > --- a/docs/about/deprecated.rst
> > +++ b/docs/about/deprecated.rst
> > @@ -111,6 +111,11 @@ Use ``-machine acpi=off`` instead.
> > The HAXM project has been retired (see https://github.com/intel/haxm#status).
> > Use "whpx" (on Windows) or "hvf" (on macOS) instead.
> >
> > +``-async-teardown`` (since 8.1)
> > +,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
> > +
> > +Use ``-run-with async-teardown=on`` instead.
> > +
> >
> > QEMU Machine Protocol (QMP) commands
> > ------------------------------------
> > diff --git a/os-posix.c b/os-posix.c
> > index 5adc69f560..117ad2bdc1 100644
> > --- a/os-posix.c
> > +++ b/os-posix.c
> > @@ -36,6 +36,8 @@
> > #include "qemu/log.h"
> > #include "sysemu/runstate.h"
> > #include "qemu/cutils.h"
> > +#include "qemu/config-file.h"
> > +#include "qemu/option.h"
> >
> > #ifdef CONFIG_LINUX
> > #include <sys/prctl.h>
> > @@ -132,6 +134,8 @@ static bool os_parse_runas_uid_gid(const char *optarg)
> > */
> > int os_parse_cmd_args(int index, const char *optarg)
> > {
> > + QemuOpts *opts;
>
> Fails to compile on FreeBSD:
>
> ../src/os-posix.c:137:15: error: unused variable 'opts'
> [-Werror,-Wunused-variable]
> QemuOpts *opts;
> ^
> 1 error generated.
>
> Apart from that, the patch looks fine to me.
oops, I'll move the variable inside the ifdef
>
> Thomas
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-04-28 12:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-28 11:12 [PATCH v6 0/1] util/async-teardown: appear in query-command-line-options Claudio Imbrenda
2023-04-28 11:12 ` [PATCH v6 1/1] util/async-teardown: wire up query-command-line-options Claudio Imbrenda
2023-04-28 12:16 ` Thomas Huth
2023-04-28 12:36 ` Claudio Imbrenda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).