aboutsummaryrefslogtreecommitdiff
path: root/os-posix.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2023-07-03 09:44:47 +0200
committerThomas Huth <thuth@redhat.com>2023-07-10 15:34:57 +0200
commit9ffcbe2a60d24fc20b98f010dbca244df1fe82c5 (patch)
tree41b33bef6f241e72f65941a138ee38f16599057f /os-posix.c
parentbc55e2eaa6d662f10a1f4cff0d285d77dbc9362a (diff)
os-posix: Allow 'chroot' via '-run-with' and deprecate the old '-chroot' option
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. Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Ján Tomko <jtomko@redhat.com> Message-Id: <20230703074447.17044-1-thuth@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'os-posix.c')
-rw-r--r--os-posix.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/os-posix.c b/os-posix.c
index 90ea71725f..cfcb96533c 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_runwith(void)
+{
+ qemu_add_opts(&qemu_run_with_opts);
+}
+opts_init(register_runwith);