Message ID | 20240104090055.27323-22-jgross@suse.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | tools: enable xenstore-stubdom to use 9pfs | expand |
On Thu, Jan 04, 2024 at 10:00:43AM +0100, Juergen Gross wrote: > Add a 9pfs device to Xenstore stubdom in order to allow it to do e.g. > logging into a dom0 file. > > Use the following parameters for the new device: > > - tag = "xen" Is it ok to have here tag "xen" when the default tag is "Xen" ? > diff --git a/tools/include/libxl.h b/tools/include/libxl.h > index 907aa0a330..00693264f7 100644 > --- a/tools/include/libxl.h > +++ b/tools/include/libxl.h > @@ -2060,6 +2067,16 @@ int libxl_console_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, > const libxl_asyncop_how *ao_how) > LIBXL_EXTERNAL_CALLERS_ONLY; > > +/* libxl_p9_add_xenstore writes the Xenstore entries for a domain's > + * primary 9pfs device based on domid, backend type and device parameters. > + */ > +int libxl_p9_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, > + libxl_p9_type type, char *tag, char *path, > + char *security_model, unsigned int max_space, > + unsigned int max_files, unsigned int max_open_files, > + bool auto_delete, const libxl_asyncop_how *ao_how) Could we simply pass a "libxl_device_p9*" instead of all these parameters? It would also mean that we can update the list of parameters without having to change the function prototype. These functions tend to be called "libxl_device_*_add()", is it possible to follow the same schema? In particular, I don't see anything xenstore specific in the function. Thanks,
On 15.01.24 16:31, Anthony PERARD wrote: > On Thu, Jan 04, 2024 at 10:00:43AM +0100, Juergen Gross wrote: >> Add a 9pfs device to Xenstore stubdom in order to allow it to do e.g. >> logging into a dom0 file. >> >> Use the following parameters for the new device: >> >> - tag = "xen" > > Is it ok to have here tag "xen" when the default tag is "Xen" ? It is okay, but I agree it should be "Xen". I'll change it. > >> diff --git a/tools/include/libxl.h b/tools/include/libxl.h >> index 907aa0a330..00693264f7 100644 >> --- a/tools/include/libxl.h >> +++ b/tools/include/libxl.h >> @@ -2060,6 +2067,16 @@ int libxl_console_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, >> const libxl_asyncop_how *ao_how) >> LIBXL_EXTERNAL_CALLERS_ONLY; >> >> +/* libxl_p9_add_xenstore writes the Xenstore entries for a domain's >> + * primary 9pfs device based on domid, backend type and device parameters. >> + */ >> +int libxl_p9_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, >> + libxl_p9_type type, char *tag, char *path, >> + char *security_model, unsigned int max_space, >> + unsigned int max_files, unsigned int max_open_files, >> + bool auto_delete, const libxl_asyncop_how *ao_how) > > Could we simply pass a "libxl_device_p9*" instead of all these > parameters? It would also mean that we can update the list of parameters > without having to change the function prototype. Fine with me. > These functions tend to be called "libxl_device_*_add()", is it possible > to follow the same schema? In particular, I don't see anything xenstore > specific in the function. It was meant to be similar to libxl_console_add_xenstore(), which just writes the Xenstore contents of the device. I think you are right that libxl_device_9pfs_add() is a better name. Juergen
diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c index 140ed610ae..591cb3766d 100644 --- a/tools/helpers/init-xenstore-domain.c +++ b/tools/helpers/init-xenstore-domain.c @@ -543,6 +543,8 @@ int main(int argc, char** argv) } libxl_console_add_xenstore(ctx, domid, 0, console_evtchn, console_gfn, NULL); + libxl_p9_add_xenstore(ctx, domid, 0, LIBXL_P9_TYPE_XEN_9PFSD, "xen", + XEN_LIB_DIR"/xenstore", "none", 0, 0, 0, 0, NULL); libxl_ctx_free(ctx); fd = creat(XEN_RUN_DIR "/xenstored.pid", 0666); diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 907aa0a330..00693264f7 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -583,6 +583,13 @@ * libxl_console_add_xenstore() in libxl. */ #define LIBXL_HAVE_CONSOLE_ADD_XENSTORE 1 + +/* + * LIBXL_HAVE_P9_ADD_XENSTORE indicates presence of the function + * libxl_p9_add_xenstore() in libxl. + */ +#define LIBXL_HAVE_P9_ADD_XENSTORE 1 + /* * libxl ABI compatibility * @@ -2060,6 +2067,16 @@ int libxl_console_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; +/* libxl_p9_add_xenstore writes the Xenstore entries for a domain's + * primary 9pfs device based on domid, backend type and device parameters. + */ +int libxl_p9_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, + libxl_p9_type type, char *tag, char *path, + char *security_model, unsigned int max_space, + unsigned int max_files, unsigned int max_open_files, + bool auto_delete, const libxl_asyncop_how *ao_how) + LIBXL_EXTERNAL_CALLERS_ONLY; + /* May be called with info_r == NULL to check for domain's existence. * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return * ERROR_INVAL for this scenario). */ diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c index 486bc4326e..17501c3eaa 100644 --- a/tools/libs/light/libxl_9pfs.c +++ b/tools/libs/light/libxl_9pfs.c @@ -176,6 +176,35 @@ static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid, aodev->callback(egc, aodev); } +int libxl_p9_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend, + libxl_p9_type type, char *tag, char *path, + char *security_model, unsigned int max_space, + unsigned int max_files, unsigned int max_open_files, + bool auto_delete, const libxl_asyncop_how *ao_how) +{ + AO_CREATE(ctx, domid, ao_how); + libxl__ao_device *aodev; + libxl_device_p9 p9 = { .backend_domid = backend, + .tag = tag, + .path = path, + .security_model = security_model, + .type = type, + .max_space = max_space, + .max_files = max_files, + .max_open_files = max_open_files, + .auto_delete = auto_delete, + }; + + GCNEW(aodev); + libxl__prepare_ao_device(ao, aodev); + aodev->action = LIBXL__DEVICE_ACTION_ADD; + aodev->callback = device_addrm_aocomplete; + + libxl__device_p9_add(egc, domid, &p9, aodev); + + return AO_INPROGRESS; +} + #define libxl_device_p9_list NULL #define libxl_device_p9_compare NULL