libxl: Implement QEMU command line probe
cover libxl: Implement QEMU command line probe
Patch series available in this git branch:
https://xenbits.xen.org/git-http/people/aperard/xen-unstable.git br.libxl-qemu-cmdline-probe-v1
Starting with QEMU 9.0, the option "-chroot", that we use for the "dmrestrict" feature, is removed. We need to find out which to use between "-chroot" and "-run-with chroot=dir".
Also, "-runas" is deprecated in QEMU 9.1 and will be remove in a future release, it's replaced with "-run-with user=user".
To find out which command line option we can use, we'll spawn QEMU, and run the QMP command "query-command-line-options".
Some example of running these patches:
with qemu-xen (8.0):
http://logs.test-lab.xenproject.org/osstest/logs/187352/
with QEMU (upstream, 9.1-rc3):
http://logs.test-lab.xenproject.org/osstest/logs/187353/Anthony PERARD (3):
libxl: Implement QEMU command line probe
libxl: Probe QEMU for -run-with chroot=dir and use it
libxl: Probe QEMU for -run-with user=user and use it
tools/libs/light/libxl_dm.c | 297 +++++++++++++++++++++++++++--- tools/libs/light/libxl_internal.h | 7 + 2 files changed, 278 insertions(+), 26 deletions(-)
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
PATCH 1/3 libxl: Implement QEMU command line probe
From: Anthony PERARD <[email protected]>
Starting with QEMU 9.0, the option "-chroot", that we use for the "dmrestrict" feature, is removed. We need to find out which to use between "-chroot" and "-run-with chroot=dir".
This patch implement the machinery to spawn QEMU, and to run the QMP command "query-command-line-options" but doesn't yet look at the actual result. Whether or not to use "-run-with chroot=dir" will be implemented in a follow up patch.
The command line used to spawn the qemu we want to probe is mostly similar to the one we already use for the device model, "-machine none" comes from libvirt.
This patch implement the probing on qemu-xen, even if we probably not going to use the result. We could check the feature wanted for the domain been created, but this could get complicated fairly quickly. We already need to check the options "b_info->dm_restrict" for "-chroot" and "state->dm_runas" for "-runas" (which is deprecated).
--- tools/libs/light/libxl_dm.c | 207 ++++++++++++++++++++++++++++-- tools/libs/light/libxl_internal.h | 1 + 2 files changed, 198 insertions(+), 10 deletions(-)
tools/libs/light/libxl_dm.c +197 -10
@@ -2858,6 +2858,20 @@ static void device_model_qmp_cb(libxl__egc *egc, libxl__ev_qmp *ev,static void device_model_spawn_outcome (libxl__egc *egc,libxl__dm_spawn_state *dmss,int rc); +static void device_model_probe_startup_failed (libxl__egc *egc, +libxl__spawn_state *spawn,int rc); +static void device_model_probe_confirm (libxl__egc *egc, +libxl__spawn_state *spawn,const char *xsdata); +static void device_model_probe_detached (libxl__egc *egc, +libxl__spawn_state *spawn); +static void device_model_probe_cmdline (libxl__egc *egc, +libxl__ev_qmp *qmp,const libxl__json_object *response,int rc); +static void device_model_probe_quit (libxl__egc *egc, +libxl__ev_qmp *qmp,const libxl__json_object *response,int rc); +static void device_model_probe_spawn_outcome (libxl__egc *egc, +libxl__dm_spawn_state *dmss,int rc); +static void device_model_launch (libxl__egc *egc, +libxl__dm_spawn_state *dmss,int rc);static void device_model_postconfig_chardev (libxl__egc *egc,libxl__ev_qmp *qmp,const libxl__json_object *response,int rc); static void device_model_postconfig_vnc(libxl__egc *egc,
@@ -2873,25 +2887,18 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) {/* convenience aliases */ const int domid = dmss->guest_domid; -libxl__domain_build_state *const state = dmss->build_state;libxl__spawn_state *const spawn = &dmss->spawn;STATE_AO_GC (dmss->spawn.ao); -libxl_ctx *ctx =CTX ;libxl_domain_config *guest_config = dmss->guest_config;const libxl_domain_create_info *c_info = &guest_config->c_info;const libxl_domain_build_info *b_info = &guest_config->b_info; -const libxl_vnc_info *vnc =libxl__dm_vnc (guest_config); -char *path; -int logfile_w, null;int rc; -char **args, **arg, **envs; -xs_transaction_t t; -char *vm_path; -char **pass_stuff;const char *dm; -int dm_state_fd =-1 ; +int logfile_w =-1 , null =-1 ; +int qmp_probe_fd =-1 ; +bool probe_spawned = false;dmss_init (dmss);
@@ -2904,6 +2911,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) rc =ERROR_FAIL ; goto out; } + dmss->dm = dm;if (access (dm,X_OK ) <0 ) {LOGED (ERROR , domid,"device model %s is not executable" , dm); rc =ERROR_FAIL ;
@@ -2911,6 +2919,185 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss) } rc =libxl__domain_get_device_model_uid (gc, dmss); +if (rc) + goto out; + +/* probe QEMU's available command line options */ +if (b_info->device_model_version + ==LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ) { + + logfile_w =libxl__create_qemu_logfile ( + gc,GCSPRINTF ("qemu-probe-%s" , c_info->name)); +if (logfile_w <0 ) { + rc = logfile_w; + goto out; + } + null =open ("/dev/null" ,O_RDONLY ); +if (null <0 ) { +LOGED (ERROR , domid,"unable to open /dev/null" ); + rc =ERROR_FAIL ; + goto out; + } + + rc =libxl__pre_open_qmp_socket (gc, domid, &qmp_probe_fd); +if (rc) goto out; + +flexarray_t *dm_args =flexarray_make (gc,16 ,1 ); +flexarray_vappend (dm_args, dm, +"-S" , +"-no-user-config" , +"-nodefaults" , +"-nographic" , +"-machine" ,"none,accel=xen" , +NULL ); +flexarray_vappend (dm_args, +"-chardev" , +GCSPRINTF ("socket,id=libxl-cmd,fd=%d,server=on,wait=off" , + qmp_probe_fd), +"-mon" ,"chardev=libxl-cmd,mode=control" , +NULL ); +flexarray_append (dm_args,NULL ); +char **exec_args = (char **)flexarray_contents (dm_args); + +const char *dom_path =libxl__xs_get_dompath (gc, domid); + + spawn->what =GCSPRINTF ("domain %d qemu command line probe" , domid); + spawn->xspath ="/dev/null" ;/* No path to watch */ + spawn->timeout_ms =LIBXL_DEVICE_MODEL_START_TIMEOUT *1000 ; + spawn->pidpath =GCSPRINTF ("%s/image/device-model-pid" , dom_path); + spawn->midproc_cb = libxl__spawn_record_pid; + spawn->confirm_cb = device_model_probe_confirm; + spawn->failure_cb = device_model_probe_startup_failed; + spawn->detached_cb = device_model_probe_detached; + + dmss->qmp.ao = ao; + dmss->qmp.callback = device_model_probe_cmdline; + dmss->qmp.domid = domid; + dmss->qmp.payload_fd =-1 ; + rc =libxl__ev_qmp_send (egc, &dmss->qmp,"query-command-line-options" ,NULL ); +if (rc) goto out; + + rc =libxl__spawn_spawn (egc, spawn); +if (rc <0 ) + goto out; +if (!rc) {/* inner child */ +setsid (); +libxl__exec (gc, null, logfile_w, logfile_w, dm, exec_args,NULL ); + } + probe_spawned = true; + }else { +/* Continue with launching DM instead of probing it */ + probe_spawned = false; + } + rc =0 ; +out: +if (qmp_probe_fd >=0 ) +close (qmp_probe_fd); +if (null >=0 ) +close (null); +if (logfile_w >=0 ) +close (logfile_w); +if (rc || !probe_spawned) +device_model_launch (egc, dmss, rc); +} + +static void device_model_probe_startup_failed (libxl__egc *egc, +libxl__spawn_state *spawn,int rc) +{ +libxl__dm_spawn_state *dmss =CONTAINER_OF (spawn, *dmss, spawn); +device_model_probe_spawn_outcome (egc, dmss, rc); +} + +static void device_model_probe_confirm (libxl__egc *egc, +libxl__spawn_state *spawn,const char *xsdata) +{ +/* Nothing to do, confirmation is done via QMP instead */ +} + +static void device_model_probe_detached (libxl__egc *egc, +libxl__spawn_state *spawn) +{ +libxl__dm_spawn_state *dmss =CONTAINER_OF (spawn, *dmss, spawn); +device_model_probe_spawn_outcome (egc, dmss,0 ); +} + +static void device_model_probe_cmdline (libxl__egc *egc, +libxl__ev_qmp *qmp,const libxl__json_object *response,int rc) +{ +libxl__dm_spawn_state *dmss =CONTAINER_OF (qmp, *dmss, qmp); + +if (rc) + goto out; + +/* +* query-command-line-options response: +* [ { 'option': 'str', 'parameters': [{ 'name': 'str', ... }] } ] +*/ + + qmp->callback = device_model_probe_quit; + rc =libxl__ev_qmp_send (egc, qmp,"quit" ,NULL ); +if (rc) goto out; +return ; + +out: +libxl__spawn_initiate_failure (egc, &dmss->spawn, rc); +} + +static void device_model_probe_quit (libxl__egc *egc, +libxl__ev_qmp *qmp,const libxl__json_object *response,int rc) +{ +EGC_GC ; +libxl__dm_spawn_state *dmss =CONTAINER_OF (qmp, *dmss, qmp); + +libxl__ev_qmp_dispose (gc, qmp); +libxl__spawn_initiate_detach (gc, &dmss->spawn); +} + +static void device_model_probe_spawn_outcome (libxl__egc *egc, +libxl__dm_spawn_state *dmss,int rc) +{ +EGC_GC ; +libxl__ev_qmp_dispose (gc, &dmss->qmp); + +/* Ensure our QEMU command line probe is killed. */ + rc =libxl__kill_xs_path (gc, dmss->spawn.pidpath, +"qemu command-line probe" ); +if (rc) { +LOGD (WARN , dmss->guest_domid, +"Killing qemu command-line probe pid from path %s" , + dmss->spawn.pidpath); + } + +/* +* Ignore all failure from the QEMU command line probe, start the +* device model in any case. +*/ +device_model_launch (egc, dmss,0 ); +} + +static void device_model_launch (libxl__egc *egc, +libxl__dm_spawn_state *dmss,int rc) +{ +STATE_AO_GC (dmss->spawn.ao); +libxl_ctx *ctx =CTX ; +libxl_domain_config *guest_config = dmss->guest_config; +const libxl_domain_create_info *c_info = &guest_config->c_info; +const libxl_domain_build_info *b_info = &guest_config->b_info; +const libxl_vnc_info *vnc =libxl__dm_vnc (guest_config); +char *path; +int logfile_w, null; +char **args, **arg, **envs; +xs_transaction_t t; +char *vm_path; +char **pass_stuff; +int dm_state_fd =-1 ; + +/* convenience aliases */ +const int domid = dmss->guest_domid; +libxl__domain_build_state *const state = dmss->build_state; +libxl__spawn_state *const spawn = &dmss->spawn; +const char *const dm = dmss->dm; +if (rc) goto out;
tools/libs/light/libxl_internal.h +1 -0
@@ -4154,6 +4154,7 @@ struct libxl__dm_spawn_state {libxl__ev_qmp qmp;libxl__ev_time timeout;libxl__dm_resume_state dmrs; +const char *dm;/* filled in by user, must remain valid: */ uint32_t guest_domid;/* domain being served */ libxl_domain_config *guest_config;
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Quoted 11 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Starting with QEMU 9.0, the option "-chroot", that we use for the "dmrestrict" feature, is removed. We need to find out which to use between "-chroot" and "-run-with chroot=dir".
This patch implement the machinery to spawn QEMU, and to run the QMP command "query-command-line-options" but doesn't yet look at the actual result. Whether or not to use "-run-with chroot=dir" will be implemented in a follow up patch.
Quoted 7 lines
The command line used to spawn the qemu we want to probe is mostly similar to the one we already use for the device model, "-machine none" comes from libvirt.
This patch implement the probing on qemu-xen, even if we probably not going to use the result. We could check the feature wanted for the domain been created, but this could get complicated fairly quickly.
"domain being created"?
Quoted 4 lines
We already need to check the options "
b_info->dm_restrict" for "-chroot" and "state->dm_runas" for "-runas" (which is deprecated).Signed-off-by Anthony PERARD <[email protected]>
Quoted 16 lines · Jason Andryuk
Quoted 15 lines · Anthony PERARD
From: Anthony PERARD <[email protected]>
Starting with QEMU 9.0, the option "-chroot", that we use for the "dmrestrict" feature, is removed. We need to find out which to use between "-chroot" and "-run-with chroot=dir".
This patch implement the machinery to spawn QEMU, and to run the QMP command "query-command-line-options" but doesn't yet look at the actual result. Whether or not to use "-run-with chroot=dir" will be implemented in a follow up patch.
The command line used to spawn the qemu we want to probe is mostly similar to the one we already use for the device model, "-machine none" comes from libvirt.
Quoted 5 lines
Quoted 3 lines
This patch implement the probing on qemu-xen, even if we probably not going to use the result. We could check the feature wanted for the domain been created, but this could get complicated fairly quickly.
"domain being created"?
Yes.
Quoted 6 lines
Quoted 4 lines
We already need to check the options "
b_info->dm_restrict" for "-chroot" and "state->dm_runas" for "-runas" (which is deprecated).Signed-off-by Anthony PERARD <[email protected]>Reviewed-by Jason Andryuk <[email protected]>
Thanks,
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
PATCH 2/3 libxl: Probe QEMU for -run-with chroot=dir and use it
In reply to Anthony PERARDQEMU 9.0 have removed "-chroot" command line option, which have been deprecated since QEMU 8.1 in favor of "-run-with chroot=dir".
Look into the result of the QMP command "query-command-line-options" to find out if "-run-with chroot=dir" is available. Then use it in place of "-chroot".
Resolves: xen-project/xen#187
--- tools/libs/light/libxl_dm.c | 78 +++++++++++++++++++++++++------ tools/libs/light/libxl_internal.h | 5 ++ 2 files changed, 69 insertions(+), 14 deletions(-)
tools/libs/light/libxl_dm.c +64 -14
@@ -1183,11 +1183,12 @@ static int libxl__pre_open_qmp_socket(libxl__gc *gc, libxl_domid domid, }static int libxl__build_device_model_args_new (libxl__gc *gc, -const char *dm,int guest_domid, -const libxl_domain_config *guest_config, -char ***args,char ***envs, -const libxl__domain_build_state *state, -int *dm_state_fd) +const char *dm,int guest_domid, +const libxl_domain_config *guest_config, +char ***args,char ***envs, +const libxl__domain_build_state *state, +const libxl__qemu_available_cmd_line *qemu_cmdline, +int *dm_state_fd) {const libxl_domain_create_info *c_info = &guest_config->c_info;const libxl_domain_build_info *b_info = &guest_config->b_info;
@@ -1778,8 +1779,13 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, }/* Add "-chroot [dir]" to command-line */ -flexarray_append (dm_args,"-chroot" ); -flexarray_append (dm_args, chroot_dir); +if (qemu_cmdline->have_runwith_chroot) { +flexarray_append_pair (dm_args,"-run-with" , +GCSPRINTF ("chroot=%s" , chroot_dir)); + }else { +flexarray_append (dm_args,"-chroot" ); +flexarray_append (dm_args, chroot_dir); + } }if (state->saved_state) {
@@ -2059,11 +2065,12 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, }static int libxl__build_device_model_args (libxl__gc *gc, -const char *dm,int guest_domid, -const libxl_domain_config *guest_config, -char ***args,char ***envs, -const libxl__domain_build_state *state, -int *dm_state_fd) +const char *dm,int guest_domid, +const libxl_domain_config *guest_config, +char ***args,char ***envs, +const libxl__domain_build_state *state, +const libxl__qemu_available_cmd_line *qemu_cmdline, +int *dm_state_fd)/* dm_state_fd may be NULL iff caller knows we are using stubdom * and therefore will be passing a filename rather than a fd. */ {
@@ -2081,7 +2088,9 @@ static int libxl__build_device_model_args(libxl__gc *gc,return libxl__build_device_model_args_new (gc, dm, guest_domid, guest_config, args, envs, - state, dm_state_fd); + state, + qemu_cmdline, + dm_state_fd);default :LOGED (ERROR , guest_domid,"unknown device model version %d" , guest_config->b_info.device_model_version);
@@ -2403,7 +2412,9 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss) ret =libxl__build_device_model_args (gc,"stubdom-dm" , guest_domid, guest_config, &args,NULL , - d_state,NULL ); + d_state, + &sdss->dm.qemu_cmdline, +NULL );if (ret) { ret =ERROR_FAIL ; goto out;
@@ -3024,6 +3035,7 @@ static void device_model_probe_detached(libxl__egc *egc,static void device_model_probe_cmdline (libxl__egc *egc,libxl__ev_qmp *qmp,const libxl__json_object *response,int rc) { +EGC_GC ;libxl__dm_spawn_state *dmss =CONTAINER_OF (qmp, *dmss, qmp);if (rc)
@@ -3033,6 +3045,43 @@ static void device_model_probe_cmdline(libxl__egc *egc,* query-command-line-options response: * [ { 'option': 'str', 'parameters': [{ 'name': 'str', ... }] } ] */ +const libxl__json_object *option; +for (int i_option =0 ; + (option =libxl__json_array_get (response, i_option)); + i_option++) { +const libxl__json_object *o; +const char *opt_str; + + o =libxl__json_map_get ("option" , option,JSON_STRING ); +if (!o) { + rc =ERROR_QEMU_API ; + goto out; + } + opt_str =libxl__json_object_get_string (o); + +if (!strcmp ("run-with" , opt_str)) { +const libxl__json_object *params; +const libxl__json_object *item; + + params =libxl__json_map_get ("parameters" , option,JSON_ARRAY ); +for (int i =0 ; (item =libxl__json_array_get (params, i)); i++) { + o =libxl__json_map_get ("name" , item,JSON_STRING ); +if (!o) { + rc =ERROR_QEMU_API ; + goto out; + } +if (!strcmp ("chroot" ,libxl__json_object_get_string (o))) { + dmss->qemu_cmdline.have_runwith_chroot = true; + } + } + +/* +* No need to parse more options, we are only interested with +* -run-with at the moment. +*/ +break ; + } + } qmp->callback = device_model_probe_quit; rc =libxl__ev_qmp_send (egc, qmp,"quit" ,NULL );
@@ -3113,6 +3162,7 @@ static void device_model_launch(libxl__egc *egc, rc =libxl__build_device_model_args (gc, dm, domid, guest_config, &args, &envs, state, + &dmss->qemu_cmdline, &dm_state_fd);if (rc) goto out;
tools/libs/light/libxl_internal.h +5 -0
@@ -4142,6 +4142,10 @@ _hidden void libxl__add_nics(libxl__egc *egc, libxl__ao *ao, uint32_t domid,/* First layer; wraps libxl__spawn_spawn. */ typedef struct libxl__dm_spawn_state libxl__dm_spawn_state ; +typedef struct libxl__qemu_available_cmd_line libxl__qemu_available_cmd_line ; +struct libxl__qemu_available_cmd_line { +bool have_runwith_chroot; +};typedef void libxl__dm_spawn_cb (libxl__egc *egc,libxl__dm_spawn_state *,int rc/* if !0, error was logged */ );
@@ -4154,6 +4158,7 @@ struct libxl__dm_spawn_state {libxl__ev_qmp qmp;libxl__ev_time timeout;libxl__dm_resume_state dmrs; +libxl__qemu_available_cmd_line qemu_cmdline;const char *dm;/* filled in by user, must remain valid: */ uint32_t guest_domid;/* domain being served */
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Re: [XEN PATCH 2/3] libxl: Probe QEMU for -run-with chroot=dir and use it
Quoted 9 lines · Anthony PERARD
QEMU 9.0 have removed "-chroot" command line option, which have been deprecated since QEMU 8.1 in favor of "-run-with chroot=dir".
Look into the result of the QMP command "query-command-line-options" to find out if "-run-with chroot=dir" is available. Then use it in place of "-chroot".
Resolves: xen-project/xen#187
Signed-off-by Anthony PERARD <[email protected]>
though one suggestion below.
Quoted 13 lines
--- tools/libs/light/libxl_dm.c | 78 +++++++++++++++++++++++++------ tools/libs/light/libxl_internal.h | 5 ++ 2 files changed, 69 insertions(+), 14 deletions(-)tools/libs/light/libxl_dm.c +0
-0@@ -1183,11 +1183,12 @@ static int libxl__pre_open_qmp_socket(libxl__gc *gc, libxl_domid domid, } static int libxl__build_device_model_args_new(libxl__gc *gc,
tools/libs/light/libxl_dm.c static int libxl__pre_open_qmp_socket(libxl__gc *gc, libxl_domid domid, · line 1190
Quoted 10 lines
tools/libs/light/libxl_dm.c +5
-5- const char *dm, int guest_domid, - const libxl_domain_config *guest_config, - char ***args, char ***envs, - const libxl__domain_build_state *state, - int *dm_state_fd) + const char *dm, int guest_domid, + const libxl_domain_config *guest_config, + char ***args, char ***envs, + const libxl__domain_build_state *state, + const libxl__qemu_available_cmd_line *qemu_cmdline,
cmd_line/cmdline makes me think of command line strings. qemu_opts/qemu_cli_opts is a little more generic, to me at least. But not a big deal if you want to keep it as is.
Thanks,
Jason
Quoted 4 lines
tools/libs/light/libxl_dm.c +1
-0+ int *dm_state_fd) {const libxl_domain_create_info *c_info = &guest_config->c_info;const libxl_domain_build_info *b_info = &guest_config->b_info;
Re: [XEN PATCH 2/3] libxl: Probe QEMU for -run-with chroot=dir and use it
Quoted 33 lines · Jason Andryuk
Quoted 9 lines · Anthony PERARD
QEMU 9.0 have removed "-chroot" command line option, which have been deprecated since QEMU 8.1 in favor of "-run-with chroot=dir".
Look into the result of the QMP command "query-command-line-options" to find out if "-run-with chroot=dir" is available. Then use it in place of "-chroot".
Resolves: xen-project/xen#187
Signed-off-by Anthony PERARD <[email protected]>Reviewed-by Jason Andryuk <[email protected]>though one suggestion below.
Quoted 18 lines
--- tools/libs/light/libxl_dm.c | 78 +++++++++++++++++++++++++------ tools/libs/light/libxl_internal.h | 5 ++ 2 files changed, 69 insertions(+), 14 deletions(-)tools/libs/light/libxl_dm.c +1
-5@@ -1183,11 +1183,12 @@ static int libxl__pre_open_qmp_socket(libxl__gc *gc, libxl_domid domid, } static int libxl__build_device_model_args_new(libxl__gc *gc, -const char *dm,int guest_domid, -const libxl_domain_config *guest_config, -char ***args,char ***envs, -const libxl__domain_build_state *state, -int *dm_state_fd) + const char *dm, int guest_domid,
Quoted 8 lines
tools/libs/light/libxl_dm.c static int libxl__pre_open_qmp_socket(libxl__gc *gc, libxl_domid domid, · line 1190
Quoted 4 lines
tools/libs/light/libxl_dm.c +4
-0+const libxl_domain_config *guest_config, + char ***args, char ***envs, + const libxl__domain_build_state *state, + const libxl__qemu_available_cmd_line *qemu_cmdline,cmd_line/cmdline makes me think of command line strings. qemu_opts/qemu_cli_opts is a little more generic, to me at least. But not a big deal if you want to keep it as is.
Yes, "opts" sounds better than "cmdline" in this context.
I'll rename "libxl__qemu_available_cmd_line" to
"libxl__qemu_available_opts".
And "qemu_cmdline" to "qemu_opts", both in the struct libxl__dm_spawn_state and as argument of functions.
Thanks,
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
PATCH 3/3 libxl: Probe QEMU for -run-with user=user and use it
In reply to Anthony PERARD"-runas" is deprecated since QEMU 9.1 and will be remove in a future release.
--- tools/libs/light/libxl_dm.c | 12 ++++++++++-- tools/libs/light/libxl_internal.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)
tools/libs/light/libxl_dm.c +10 -2
@@ -2052,8 +2052,13 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, }if (state->dm_runas) { -flexarray_append (dm_args,"-runas" ); -flexarray_append (dm_args, state->dm_runas); +if (qemu_cmdline->have_runwith_user) { +flexarray_append_pair (dm_args,"-run-with" , +GCSPRINTF ("user=%s" , state->dm_runas)); + }else { +flexarray_append (dm_args,"-runas" ); +flexarray_append (dm_args, state->dm_runas); + } } }flexarray_append (dm_args,NULL );
@@ -3073,6 +3078,9 @@ static void device_model_probe_cmdline(libxl__egc *egc,if (!strcmp ("chroot" ,libxl__json_object_get_string (o))) { dmss->qemu_cmdline.have_runwith_chroot = true; } +else if (!strcmp ("user" ,libxl__json_object_get_string (o))) { + dmss->qemu_cmdline.have_runwith_user = true; + } }/*
tools/libs/light/libxl_internal.h +1 -0
@@ -4145,6 +4145,7 @@ typedef struct libxl__dm_spawn_state libxl__dm_spawn_state;typedef struct libxl__qemu_available_cmd_line libxl__qemu_available_cmd_line ;struct libxl__qemu_available_cmd_line {bool have_runwith_chroot; +bool have_runwith_user; }; typedef void libxl__dm_spawn_cb(libxl__egc *egc, libxl__dm_spawn_state*,
Signature · 5 lines
Anthony Perard | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech
Re: [XEN PATCH 3/3] libxl: Probe QEMU for -run-with user=user and use it
Quoted 4 lines · Anthony PERARD
"-runas" is deprecated since QEMU 9.1 and will be remove in a future release.
Signed-off-by Anthony PERARD <[email protected]>