mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 23:25:48 +00:00
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>
This commit is contained in:
35
os-posix.c
35
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);
|
||||
|
Reference in New Issue
Block a user