* [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option
@ 2023-06-30 15:01 Thomas Huth
2023-06-30 15:18 ` Claudio Imbrenda
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Thomas Huth @ 2023-06-30 15:01 UTC (permalink / raw)
To: qemu-devel, Paolo Bonzini
Cc: libvir-list, Claudio Imbrenda, Markus Armbruster
We recently introduced "-run-with" for options that influence the
runtime behavior of QEMU. This option has the big advantage that it
can group related options (so that it is easier for the users to spot
them) and that the options become introspectable via QMP this way.
So let's start moving more switches into this option group, starting
with "-chroot" now.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
docs/about/deprecated.rst | 5 +++++
os-posix.c | 35 ++++++++++++++++++++++++++++++++++-
util/async-teardown.c | 21 ---------------------
qemu-options.hx | 18 +++++++++++++-----
4 files changed, 52 insertions(+), 27 deletions(-)
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 0743459862..1cf53b86ce 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -116,6 +116,11 @@ Use "whpx" (on Windows) or "hvf" (on macOS) instead.
Use ``-run-with async-teardown=on`` instead.
+``-chroot`` (since 8.1)
+'''''''''''''''''''''''
+
+Use ``-run-with chroot=dir`` instead.
+
``-singlestep`` (since 8.1)
'''''''''''''''''''''''''''
diff --git a/os-posix.c b/os-posix.c
index 90ea71725f..0ae1fb2347 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -38,6 +38,7 @@
#include "qemu/cutils.h"
#include "qemu/config-file.h"
#include "qemu/option.h"
+#include "qemu/module.h"
#ifdef CONFIG_LINUX
#include <sys/prctl.h>
@@ -148,6 +149,7 @@ int os_parse_cmd_args(int index, const char *optarg)
}
break;
case QEMU_OPTION_chroot:
+ warn_report("option is deprecated, use '-run-with chroot=...' instead");
chroot_dir = optarg;
break;
case QEMU_OPTION_daemonize:
@@ -158,18 +160,25 @@ int os_parse_cmd_args(int index, const char *optarg)
case QEMU_OPTION_asyncteardown:
init_async_teardown();
break;
+#endif
case QEMU_OPTION_run_with: {
+ const char *str;
QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("run-with"),
optarg, false);
if (!opts) {
exit(1);
}
+#if defined(CONFIG_LINUX)
if (qemu_opt_get_bool(opts, "async-teardown", false)) {
init_async_teardown();
}
+#endif
+ str = qemu_opt_get(opts, "chroot");
+ if (str) {
+ chroot_dir = str;
+ }
break;
}
-#endif
default:
return -1;
}
@@ -348,3 +357,27 @@ int os_mlock(void)
return -ENOSYS;
#endif
}
+
+static QemuOptsList qemu_run_with_opts = {
+ .name = "run-with",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head),
+ .desc = {
+#if defined(CONFIG_LINUX)
+ {
+ .name = "async-teardown",
+ .type = QEMU_OPT_BOOL,
+ },
+#endif
+ {
+ .name = "chroot",
+ .type = QEMU_OPT_STRING,
+ },
+ { /* end of list */ }
+ },
+};
+
+static void register_teardown(void)
+{
+ qemu_add_opts(&qemu_run_with_opts);
+}
+opts_init(register_teardown);
diff --git a/util/async-teardown.c b/util/async-teardown.c
index 3ab19c8740..62cdeb0f20 100644
--- a/util/async-teardown.c
+++ b/util/async-teardown.c
@@ -12,9 +12,6 @@
*/
#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>
@@ -147,21 +144,3 @@ 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);
diff --git a/qemu-options.hx b/qemu-options.hx
index b57489d7ca..f49d4c0e3c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4670,11 +4670,12 @@ ERST
#ifndef _WIN32
DEF("chroot", HAS_ARG, QEMU_OPTION_chroot, \
- "-chroot dir chroot to dir just before starting the VM\n",
+ "-chroot dir chroot to dir just before starting the VM (deprecated)\n",
QEMU_ARCH_ALL)
#endif
SRST
``-chroot dir``
+ Deprecated, use '-run-with chroot=...' instead.
Immediately before starting guest execution, chroot to the specified
directory. Especially useful in combination with -runas.
ERST
@@ -4861,13 +4862,16 @@ SRST
This option is deprecated and should no longer be used. The new option
``-run-with async-teardown=on`` is a replacement.
ERST
+#endif
+#ifdef CONFIG_POSIX
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",
+ "-run-with [async-teardown=on|off][,chroot=dir]\n"
+ " Set miscellaneous QEMU process lifecycle options:\n"
+ " async-teardown=on enables asynchronous teardown (Linux only)\n"
+ " chroot=dir chroot to dir just before starting the VM\n",
QEMU_ARCH_ALL)
SRST
-``-run-with``
+``-run-with [async-teardown=on|off][,chroot=dir]``
Set QEMU process lifecycle options.
``async-teardown=on`` enables asynchronous teardown. A new process called
@@ -4880,6 +4884,10 @@ SRST
performed correctly. This only works if the cleanup process is not
forcefully killed with SIGKILL before the main QEMU process has
terminated completely.
+
+ ``chroot=dir`` can be used for doing a chroot to the specified directory
+ immediately before starting the guest execution. This is especially useful
+ in combination with -runas.
ERST
#endif
--
2.39.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option
2023-06-30 15:01 [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option Thomas Huth
@ 2023-06-30 15:18 ` Claudio Imbrenda
2023-06-30 15:56 ` Michael Tokarev
2023-06-30 19:14 ` Ján Tomko
2 siblings, 0 replies; 5+ messages in thread
From: Claudio Imbrenda @ 2023-06-30 15:18 UTC (permalink / raw)
To: Thomas Huth; +Cc: qemu-devel, Paolo Bonzini, libvir-list, Markus Armbruster
On Fri, 30 Jun 2023 17:01:12 +0200
Thomas Huth <thuth@redhat.com> wrote:
> We recently introduced "-run-with" for options that influence the
> runtime behavior of QEMU. This option has the big advantage that it
> can group related options (so that it is easier for the users to spot
> them) and that the options become introspectable via QMP this way.
> So let's start moving more switches into this option group, starting
> with "-chroot" now.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> ---
> docs/about/deprecated.rst | 5 +++++
> os-posix.c | 35 ++++++++++++++++++++++++++++++++++-
> util/async-teardown.c | 21 ---------------------
> qemu-options.hx | 18 +++++++++++++-----
> 4 files changed, 52 insertions(+), 27 deletions(-)
>
> diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
> index 0743459862..1cf53b86ce 100644
> --- a/docs/about/deprecated.rst
> +++ b/docs/about/deprecated.rst
> @@ -116,6 +116,11 @@ Use "whpx" (on Windows) or "hvf" (on macOS) instead.
>
> Use ``-run-with async-teardown=on`` instead.
>
> +``-chroot`` (since 8.1)
> +'''''''''''''''''''''''
> +
> +Use ``-run-with chroot=dir`` instead.
> +
> ``-singlestep`` (since 8.1)
> '''''''''''''''''''''''''''
>
> diff --git a/os-posix.c b/os-posix.c
> index 90ea71725f..0ae1fb2347 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -38,6 +38,7 @@
> #include "qemu/cutils.h"
> #include "qemu/config-file.h"
> #include "qemu/option.h"
> +#include "qemu/module.h"
>
> #ifdef CONFIG_LINUX
> #include <sys/prctl.h>
> @@ -148,6 +149,7 @@ int os_parse_cmd_args(int index, const char *optarg)
> }
> break;
> case QEMU_OPTION_chroot:
> + warn_report("option is deprecated, use '-run-with chroot=...' instead");
> chroot_dir = optarg;
> break;
> case QEMU_OPTION_daemonize:
> @@ -158,18 +160,25 @@ int os_parse_cmd_args(int index, const char *optarg)
> case QEMU_OPTION_asyncteardown:
> init_async_teardown();
> break;
> +#endif
> case QEMU_OPTION_run_with: {
> + const char *str;
> QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("run-with"),
> optarg, false);
> if (!opts) {
> exit(1);
> }
> +#if defined(CONFIG_LINUX)
> if (qemu_opt_get_bool(opts, "async-teardown", false)) {
> init_async_teardown();
> }
> +#endif
> + str = qemu_opt_get(opts, "chroot");
> + if (str) {
> + chroot_dir = str;
> + }
> break;
> }
> -#endif
> default:
> return -1;
> }
> @@ -348,3 +357,27 @@ int os_mlock(void)
> return -ENOSYS;
> #endif
> }
> +
> +static QemuOptsList qemu_run_with_opts = {
> + .name = "run-with",
> + .head = QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head),
> + .desc = {
> +#if defined(CONFIG_LINUX)
> + {
> + .name = "async-teardown",
> + .type = QEMU_OPT_BOOL,
> + },
> +#endif
> + {
> + .name = "chroot",
> + .type = QEMU_OPT_STRING,
> + },
> + { /* end of list */ }
> + },
> +};
> +
> +static void register_teardown(void)
> +{
> + qemu_add_opts(&qemu_run_with_opts);
> +}
> +opts_init(register_teardown);
> diff --git a/util/async-teardown.c b/util/async-teardown.c
> index 3ab19c8740..62cdeb0f20 100644
> --- a/util/async-teardown.c
> +++ b/util/async-teardown.c
> @@ -12,9 +12,6 @@
> */
>
> #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>
> @@ -147,21 +144,3 @@ 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);
> diff --git a/qemu-options.hx b/qemu-options.hx
> index b57489d7ca..f49d4c0e3c 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -4670,11 +4670,12 @@ ERST
>
> #ifndef _WIN32
> DEF("chroot", HAS_ARG, QEMU_OPTION_chroot, \
> - "-chroot dir chroot to dir just before starting the VM\n",
> + "-chroot dir chroot to dir just before starting the VM (deprecated)\n",
> QEMU_ARCH_ALL)
> #endif
> SRST
> ``-chroot dir``
> + Deprecated, use '-run-with chroot=...' instead.
> Immediately before starting guest execution, chroot to the specified
> directory. Especially useful in combination with -runas.
> ERST
> @@ -4861,13 +4862,16 @@ SRST
> This option is deprecated and should no longer be used. The new option
> ``-run-with async-teardown=on`` is a replacement.
> ERST
> +#endif
> +#ifdef CONFIG_POSIX
> 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",
> + "-run-with [async-teardown=on|off][,chroot=dir]\n"
> + " Set miscellaneous QEMU process lifecycle options:\n"
> + " async-teardown=on enables asynchronous teardown (Linux only)\n"
> + " chroot=dir chroot to dir just before starting the VM\n",
> QEMU_ARCH_ALL)
> SRST
> -``-run-with``
> +``-run-with [async-teardown=on|off][,chroot=dir]``
> Set QEMU process lifecycle options.
>
> ``async-teardown=on`` enables asynchronous teardown. A new process called
> @@ -4880,6 +4884,10 @@ SRST
> performed correctly. This only works if the cleanup process is not
> forcefully killed with SIGKILL before the main QEMU process has
> terminated completely.
> +
> + ``chroot=dir`` can be used for doing a chroot to the specified directory
> + immediately before starting the guest execution. This is especially useful
> + in combination with -runas.
> ERST
> #endif
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option
2023-06-30 15:01 [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option Thomas Huth
2023-06-30 15:18 ` Claudio Imbrenda
@ 2023-06-30 15:56 ` Michael Tokarev
2023-06-30 16:11 ` Thomas Huth
2023-06-30 19:14 ` Ján Tomko
2 siblings, 1 reply; 5+ messages in thread
From: Michael Tokarev @ 2023-06-30 15:56 UTC (permalink / raw)
To: Thomas Huth, qemu-devel, Paolo Bonzini
Cc: libvir-list, Claudio Imbrenda, Markus Armbruster
30.06.2023 18:01, Thomas Huth wrote:
> We recently introduced "-run-with" for options that influence the
> runtime behavior of QEMU. This option has the big advantage that it
> can group related options (so that it is easier for the users to spot
> them) and that the options become introspectable via QMP this way.
> So let's start moving more switches into this option group, starting
> with "-chroot" now.
...
> +static QemuOptsList qemu_run_with_opts = {
> + .name = "run-with",
> + .head = QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head),
> + .desc = {
> +#if defined(CONFIG_LINUX)
> + {
> + .name = "async-teardown",
> + .type = QEMU_OPT_BOOL,
> + },
> +#endif
> + {
> + .name = "chroot",
> + .type = QEMU_OPT_STRING,
> + },
> + { /* end of list */ }
> + },
> +};
> +
> +static void register_teardown(void)
> +{
> + qemu_add_opts(&qemu_run_with_opts);
> +}
> +opts_init(register_teardown);
Hmm.. Is it still register_teardown? :)
Other than that,
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
/mjt
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option
2023-06-30 15:56 ` Michael Tokarev
@ 2023-06-30 16:11 ` Thomas Huth
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Huth @ 2023-06-30 16:11 UTC (permalink / raw)
To: Michael Tokarev, qemu-devel, Paolo Bonzini
Cc: libvir-list, Claudio Imbrenda, Markus Armbruster
On 30/06/2023 17.56, Michael Tokarev wrote:
> 30.06.2023 18:01, Thomas Huth wrote:
>> We recently introduced "-run-with" for options that influence the
>> runtime behavior of QEMU. This option has the big advantage that it
>> can group related options (so that it is easier for the users to spot
>> them) and that the options become introspectable via QMP this way.
>> So let's start moving more switches into this option group, starting
>> with "-chroot" now.
> ...
>> +static QemuOptsList qemu_run_with_opts = {
>> + .name = "run-with",
>> + .head = QTAILQ_HEAD_INITIALIZER(qemu_run_with_opts.head),
>> + .desc = {
>> +#if defined(CONFIG_LINUX)
>> + {
>> + .name = "async-teardown",
>> + .type = QEMU_OPT_BOOL,
>> + },
>> +#endif
>> + {
>> + .name = "chroot",
>> + .type = QEMU_OPT_STRING,
>> + },
>> + { /* end of list */ }
>> + },
>> +};
>> +
>> +static void register_teardown(void)
>> +{
>> + qemu_add_opts(&qemu_run_with_opts);
>> +}
>> +opts_init(register_teardown);
>
> Hmm.. Is it still register_teardown? :)
Drat. Should be something like "register_runwith" now, of course. Thanks for
spotting it!
Thomas
> Other than that,
>
> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
>
> /mjt
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option
2023-06-30 15:01 [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option Thomas Huth
2023-06-30 15:18 ` Claudio Imbrenda
2023-06-30 15:56 ` Michael Tokarev
@ 2023-06-30 19:14 ` Ján Tomko
2 siblings, 0 replies; 5+ messages in thread
From: Ján Tomko @ 2023-06-30 19:14 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-devel, Paolo Bonzini, libvir-list, Claudio Imbrenda,
Markus Armbruster
[-- Attachment #1: Type: text/plain, Size: 816 bytes --]
On a Friday in 2023, Thomas Huth wrote:
>We recently introduced "-run-with" for options that influence the
>runtime behavior of QEMU. This option has the big advantage that it
>can group related options (so that it is easier for the users to spot
>them) and that the options become introspectable via QMP this way.
>So let's start moving more switches into this option group, starting
>with "-chroot" now.
>
>Signed-off-by: Thomas Huth <thuth@redhat.com>
>---
> docs/about/deprecated.rst | 5 +++++
> os-posix.c | 35 ++++++++++++++++++++++++++++++++++-
> util/async-teardown.c | 21 ---------------------
> qemu-options.hx | 18 +++++++++++++-----
> 4 files changed, 52 insertions(+), 27 deletions(-)
>
For libvirt:
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Jano
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-06-30 19:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-30 15:01 [PATCH] os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option Thomas Huth
2023-06-30 15:18 ` Claudio Imbrenda
2023-06-30 15:56 ` Michael Tokarev
2023-06-30 16:11 ` Thomas Huth
2023-06-30 19:14 ` Ján Tomko
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).