qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/1] util/async-teardown: wire up query-command-line-options
@ 2023-03-27 12:03 Claudio Imbrenda
  2023-03-27 12:03 ` [PATCH v4 1/1] " Claudio Imbrenda
  0 siblings, 1 reply; 3+ messages in thread
From: Claudio Imbrenda @ 2023-03-27 12:03 UTC (permalink / raw)
  To: pbonzini
  Cc: qemu-devel, david, thuth, borntraeger, frankja, fiuczy, pasic,
	nsg, berrange, alex.bennee, armbru

The recently introduced -async-teardown commandline option was not
wired up properly and did not show up in the output of the QMP command
query-command-line-options. This means that libvirt will have no way to
discover whether the feature is supported.

This patch fixes the issue by adding a new -teardown commandline option
with an async=on|off parameter, correctly wired up so that it appears
in the output of query-command-line-options.

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

 os-posix.c            | 15 +++++++++++++--
 qemu-options.hx       | 33 +++++++++++++++++++--------------
 util/async-teardown.c | 21 +++++++++++++++++++++
 3 files changed, 53 insertions(+), 16 deletions(-)

-- 
2.39.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v4 1/1] util/async-teardown: wire up query-command-line-options
  2023-03-27 12:03 [PATCH v4 0/1] util/async-teardown: wire up query-command-line-options Claudio Imbrenda
@ 2023-03-27 12:03 ` Claudio Imbrenda
  2023-03-27 12:59   ` Markus Armbruster
  0 siblings, 1 reply; 3+ messages in thread
From: Claudio Imbrenda @ 2023-03-27 12:03 UTC (permalink / raw)
  To: pbonzini
  Cc: qemu-devel, david, thuth, borntraeger, frankja, fiuczy, pasic,
	nsg, berrange, alex.bennee, armbru

The recently introduced -async-teardown commandline option was not
wired up properly and did not show up in the output of the QMP command
query-command-line-options. This means that libvirt had no way to
discover whether the feature was supported.

This patch fixes the issue by replacing the -async-teardown option with
a new -teardown option with a new async=on|off parameter.
The new option is correctly wired up so that it appears in the output
of query-command-line-options.

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>
---
 os-posix.c            | 15 +++++++++++++--
 qemu-options.hx       | 33 +++++++++++++++++++--------------
 util/async-teardown.c | 21 +++++++++++++++++++++
 3 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/os-posix.c b/os-posix.c
index 5adc69f560..c1ca7b1cb3 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,8 +156,15 @@ int os_parse_cmd_args(int index, const char *optarg)
         daemonize = 1;
         break;
 #if defined(CONFIG_LINUX)
-    case QEMU_OPTION_asyncteardown:
-        init_async_teardown();
+    case QEMU_OPTION_teardown:
+        opts = qemu_opts_parse_noisily(qemu_find_opts("teardown"),
+                                       optarg, false);
+        if (!opts) {
+            exit(1);
+        }
+        if (qemu_opt_get_bool(opts, "async", false)) {
+            init_async_teardown();
+        }
         break;
 #endif
     default:
diff --git a/qemu-options.hx b/qemu-options.hx
index d42f60fb91..6a69b84f3c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4763,23 +4763,28 @@ DEF("qtest", HAS_ARG, QEMU_OPTION_qtest, "", QEMU_ARCH_ALL)
 DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "", QEMU_ARCH_ALL)
 
 #ifdef __linux__
-DEF("async-teardown", 0, QEMU_OPTION_asyncteardown,
-    "-async-teardown enable asynchronous teardown\n",
+DEF("teardown", HAS_ARG, QEMU_OPTION_teardown,
+    "-teardown async[=on|off]\n"
+    "                process teardown options\n"
+    "                async=on enables 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.
+``-teardown``
+    Set process teardown options.
+
+    ``async=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..4a5dbce958 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_teardown_opts = {
+    .name = "teardown",
+    .head = QTAILQ_HEAD_INITIALIZER(qemu_teardown_opts.head),
+    .desc = {
+        {
+            .name = "async",
+            .type = QEMU_OPT_BOOL,
+        },
+        { /* end of list */ }
+    },
+};
+
+static void register_teardown(void)
+{
+    qemu_add_opts(&qemu_teardown_opts);
+}
+opts_init(register_teardown);
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v4 1/1] util/async-teardown: wire up query-command-line-options
  2023-03-27 12:03 ` [PATCH v4 1/1] " Claudio Imbrenda
@ 2023-03-27 12:59   ` Markus Armbruster
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2023-03-27 12:59 UTC (permalink / raw)
  To: Claudio Imbrenda
  Cc: pbonzini, qemu-devel, david, thuth, borntraeger, frankja, fiuczy,
	pasic, nsg, berrange, alex.bennee

Claudio Imbrenda <imbrenda@linux.ibm.com> writes:

> The recently introduced -async-teardown commandline option was not
> wired up properly and did not show up in the output of the QMP command
> query-command-line-options. This means that libvirt had no way to
> discover whether the feature was supported.

Excuse the pedantry...  The option *was* wired up correctly, just in a
way that isn't visible in query-command-line-options.  Suggest "The
recently introduced -async-teardown command line option -async-teardown
is not visible in query-command-line-options."

> This patch fixes the issue by replacing the -async-teardown option with
> a new -teardown option with a new async=on|off parameter.

Why we can drop -async-teardown right away, without a deprecating it
first?  The commit message needs to make the argument.

If we can drop it right away, you need to update
about/removed-features.rst.

Else, you need to update docs/about/deprecated.rst, and emit a warning
when the option is used.  Something like

    warn_reportf("-async-teardown is deprecated, use -teardown async=on instead");

> The new option is correctly wired up so that it appears in the output
> of query-command-line-options.

Suggest

  Add new -teardown option with an async=on|off parameter.  It is
  visible in query-command-line-options.

Then either

  Option -async-teardown is now redundant.  We'd normally deprecate it
  and remove it after a grace period, but <argument goes here...>
  Drop it.

or

  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>



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-27 12:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 12:03 [PATCH v4 0/1] util/async-teardown: wire up query-command-line-options Claudio Imbrenda
2023-03-27 12:03 ` [PATCH v4 1/1] " Claudio Imbrenda
2023-03-27 12:59   ` Markus Armbruster

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).