libxl: devd support for QEMU 9pfs
cover libxl: devd support for QEMU 9pfs
These two patches enable xl devd (in a service vm) to launch QEMU to provide 9pfs backends.
Jason Andryuk (2):
libxl: Fix segfault in device_model_spawn_outcome
libxl: devd: Spawn QEMU for 9pfs
tools/libs/light/libxl_device.c | 22 ++++++++++++---------- tools/libs/light/libxl_dm.c | 15 ++++++++------- tools/libs/light/libxl_internal.h | 4 ++-- 3 files changed, 22 insertions(+), 19 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 libxl: Fix segfault in device_model_spawn_outcome
libxl__spawn_qdisk_backend() explicitly sets guest_config to NULL when starting QEMU (the usual launch through libxl__spawn_local_dm() has a guest_config though).
Bail early on a NULL guest_config/d_config. This skips the QMP queries for chardevs and VNC, but this xenpv QEMU instance isn't expected to provide those - only qdisk (or 9pfs backends after an upcoming change).
--- tools/libs/light/libxl_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/libs/light/libxl_dm.c +2 -2
@@ -3161,8 +3161,8 @@ static void device_model_spawn_outcome(libxl__egc *egc,/* Check if spawn failed */ if (rc) goto out; - -if (d_config->b_info.device_model_version +/* d_config is NULL for xl devd/libxl__spawn_qemu_xenpv_backend(). */ +if (d_config && d_config->b_info.device_model_version ==LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ) { rc = libxl__ev_time_register_rel(ao, &dmss->timeout, devise_model_postconfig_timeout,
Signature · 1 line
2.43.0
Re: [PATCH 1/2] libxl: Fix segfault in device_model_spawn_outcome
Quoted 9 lines · Jason Andryuk
libxl__spawn_qdisk_backend()explicitly setsguest_configto NULL when starting QEMU (the usual launch throughlibxl__spawn_local_dm()has aguest_configthough).Bail early on a NULL guest_config/d_config. This skips the QMP queries for chardevs and VNC, but this xenpv QEMU instance isn't expected to provide those - only qdisk (or 9pfs backends after an upcoming change).
Signed-off-by Jason Andryuk <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
PATCH 2/2 libxl: devd: Spawn QEMU for 9pfs
In reply to Jason AndryukAdd support for xl devd to support 9pfs in a domU. devd need to spawn a pvqemu for the domain to service 9pfs as well as qdisk backends. Rename num_qdisks to pvqemu_refcnt to be more generic.
--- tools/libs/light/libxl_device.c | 22 ++++++++++++---------- tools/libs/light/libxl_dm.c | 11 ++++++----- tools/libs/light/libxl_internal.h | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-)
tools/libs/light/libxl_device.c +12 -10
@@ -1517,12 +1517,12 @@ static void device_complete(libxl__egc *egc, libxl__ao_device *aodev)libxl__nested_ao_free (aodev->ao); } -static void qdisk_spawn_outcome (libxl__egc *egc,libxl__dm_spawn_state *dmss, -int rc) +static void qemu_xenpv_spawn_outcome (libxl__egc *egc, +libxl__dm_spawn_state *dmss,int rc) {STATE_AO_GC (dmss->spawn.ao); -LOGD (DEBUG , dmss->guest_domid,"qdisk backend spawn %s" , +LOGD (DEBUG , dmss->guest_domid,"qemu xenpv backend spawn %s" , rc ?"failed" :"succeed" );libxl__nested_ao_free (dmss->spawn.ao);
@@ -1545,7 +1545,7 @@ typedef struct libxl__ddomain_device {*/ typedef struct libxl__ddomain_guest {uint32_t domid; -int num_qdisks; +int pvqemu_refcnt; XEN_SLIST_HEAD(, struct libxl__ddomain_device) devices;XEN_SLIST_ENTRY (struct libxl__ddomain_guest ) next; }libxl__ddomain_guest ;
@@ -1639,15 +1639,16 @@ static int add_device(libxl__egc *egc, libxl__ao *ao,switch (dev->backend_kind) {case LIBXL__DEVICE_KIND_QDISK : -if (dguest->num_qdisks ==0 ) { +case LIBXL__DEVICE_KIND_9PFS : +if (dguest->pvqemu_refcnt ==0 ) {GCNEW (dmss); dmss->guest_domid = dev->domid; dmss->spawn.ao = ao; - dmss->callback = qdisk_spawn_outcome; + dmss->callback = qemu_xenpv_spawn_outcome; -libxl__spawn_qdisk_backend (egc, dmss); +libxl__spawn_qemu_xenpv_backend (egc, dmss); } - dguest->num_qdisks++; + dguest->pvqemu_refcnt++;break ;default :GCNEW (aodev);
@@ -1678,8 +1679,9 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao,switch (ddev->dev->backend_kind) {case LIBXL__DEVICE_KIND_QDISK : -if (--dguest->num_qdisks ==0 ) { - rc =libxl__destroy_qdisk_backend (gc, dev->domid); +case LIBXL__DEVICE_KIND_9PFS : +if (--dguest->pvqemu_refcnt ==0 ) { + rc =libxl__destroy_qemu_xenpv_backend (gc, dev->domid);if (rc) goto out; }
tools/libs/light/libxl_dm.c +6 -5
@@ -3370,7 +3370,8 @@ static void device_model_postconfig_done(libxl__egc *egc, dmss->callback (egc, dmss, rc); } -void libxl__spawn_qdisk_backend (libxl__egc *egc,libxl__dm_spawn_state *dmss) +void libxl__spawn_qemu_xenpv_backend (libxl__egc *egc, +libxl__dm_spawn_state *dmss) {STATE_AO_GC (dmss->spawn.ao);flexarray_t *dm_args, *dm_envs;
@@ -3403,7 +3404,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)libxl__set_qemu_env_for_xsa_180 (gc, dm_envs); envs = (char **)flexarray_contents (dm_envs); - logfile_w =libxl__create_qemu_logfile (gc,GCSPRINTF ("qdisk-%u" , domid)); + logfile_w =libxl__create_qemu_logfile (gc,GCSPRINTF ("qemu-xenpv-%u" , domid));if (logfile_w <0 ) { rc = logfile_w; goto out;
@@ -3430,7 +3431,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)* because we will call this from unprivileged driver domains, * so save it in the current domain libxl private dir. */ - dmss->spawn.pidpath =GCSPRINTF ("libxl/%u/qdisk-backend-pid" , domid); + dmss->spawn.pidpath =GCSPRINTF ("libxl/%u/qemu-xenpv-backend-pid" , domid); dmss->spawn.midproc_cb = libxl__spawn_record_pid; dmss->spawn.confirm_cb = device_model_confirm; dmss->spawn.failure_cb = device_model_startup_failed;
@@ -3460,12 +3461,12 @@ static int kill_device_model(libxl__gc *gc, const char *xs_path_pid) }/* Helper to destroy a Qdisk backend */ -int libxl__destroy_qdisk_backend (libxl__gc *gc,uint32_t domid) +int libxl__destroy_qemu_xenpv_backend (libxl__gc *gc,uint32_t domid) {char *pid_path;int rc; - pid_path =GCSPRINTF ("libxl/%u/qdisk-backend-pid" , domid); + pid_path =GCSPRINTF ("libxl/%u/qemu-xenpv-backend-pid" , domid); rc =kill_device_model (gc, pid_path);if (rc)
tools/libs/light/libxl_internal.h +2 -2
@@ -4195,9 +4195,9 @@ _hidden char *libxl__stub_dm_name(libxl__gc *gc, const char * guest_name);/* Qdisk backend launch helpers */ -_hidden void libxl__spawn_qdisk_backend(libxl__egc *egc, +_hidden void libxl__spawn_qemu_xenpv_backend(libxl__egc *egc,libxl__dm_spawn_state *dmss); -_hidden int libxl__destroy_qdisk_backend(libxl__gc *gc, uint32_t domid); +_hidden int libxl__destroy_qemu_xenpv_backend(libxl__gc *gc, uint32_t domid);/*----- Domain creation -----*/
Signature · 1 line
2.43.0
Re: [PATCH 2/2] libxl: devd: Spawn QEMU for 9pfs
tools/libs/light/libxl_dm.c void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) · line 3434
Quoted 6 lines · Jason Andryuk
tools/libs/light/libxl_dm.c +1
-1@@ -3430,7 +3431,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)* because we will call this from unprivileged driver domains, * so save it in the current domain libxl private dir. */ - dmss->spawn.pidpath =GCSPRINTF ("libxl/%u/qdisk-backend-pid" , domid); + dmss->spawn.pidpath =GCSPRINTF ("libxl/%u/qemu-xenpv-backend-pid" , domid);
This path is documented in "docs/misc/xenstore-paths.pandoc", I'm not sure it's such a good idea to change it.
But maybe it's ok to change the path because xl devd is expected add then remove this path? And that pid isn't going to be useful to anything else?
I'd rather not change the path, but if you still think it's ok, we can go for it. Thought?
Thanks,
Signature · 1 line
Anthony PERARD
Re: [PATCH 2/2] libxl: devd: Spawn QEMU for 9pfs
Quoted 12 lines · Anthony PERARD
tools/libs/light/libxl_dm.c void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss) · line 3434
Quoted 6 lines · Jason Andryuk
tools/libs/light/libxl_dm.c +1
-1@@ -3430,7 +3431,7 @@ void libxl__spawn_qdisk_backend(libxl__egc *egc, libxl__dm_spawn_state *dmss)* because we will call this from unprivileged driver domains, * so save it in the current domain libxl private dir. */ - dmss->spawn.pidpath =GCSPRINTF ("libxl/%u/qdisk-backend-pid" , domid); + dmss->spawn.pidpath =GCSPRINTF ("libxl/%u/qemu-xenpv-backend-pid" , domid);This path is documented in "docs/misc/xenstore-paths.pandoc", I'm not sure it's such a good idea to change it.
Quoted 6 lines
But maybe it's ok to change the path because xl devd is expected add then remove this path? And that pid isn't going to be useful to anything else?
I'd rather not change the path, but if you still think it's ok, we can go for it. Thought?
I changed the path to keep it consistent with the internal libxl names. The node is for libxl's internal use, so it seemed okay to change. But it is externally visible, so there could be other software looking at it. I'm fine with leaving the xenstore name unchanged.
(I didn't want to rename all the qdisk stuff, but it seemed like it should be renamed since it would also handle 9pfs.)
Thanks,
Jason