tools: enable xenstore-stubdom to use 9pfs
v8 cover tools: enable xenstore-stubdom to use 9pfs
This series is adding 9pfs support to Xenstore-stubdom, enabling it to do logging to a dom0 directory.
This is a prerequisite for the final goal to add live update support to Xenstore-stubdom, as it enables the stubdom to store its state in a dom0 file.
Reposting the rest series.
Changes in V8:
- patches 1-13 of V7 have been applied
Changes in V7:
- fixed V6 bugs
Changes in V6:
- patch 1 of V5 has been applied
- rebase
- addressed comments
Changes in V5:
- 10 patches have been applied already
- rename source directory to tools/9pfsd
- addressed comments
Changes in V4:
- patch 2 of V3 was applied
- added support of reading directories
- addressed review comments
Changes in V3:
- new patches 1, 23-25
- addressed review comments
Changes in V2:
- support of multiple rings per device
- xenlogd->xen-9pfsd rename
- addressed review comments
- fixed some bugs
Juergen Gross (8):
tools/libs/light: add backend type for 9pfs PV devices tools/xl: support new 9pfs backend xen_9pfsd
stubdom: extend xenstore stubdom configs
tools: add 9pfs device to xenstore-stubdom tools/xenstored: mount 9pfs device in stubdom tools/xenstored: add helpers for filename handling tools/xenstored: support complete log capabilities in stubdom tools/xenstored: have a single do_control_memreport()
docs/man/xl.cfg.5.pod.in | 36 +++- stubdom/xenstore-minios.cfg | 2 +- stubdom/xenstorepvh-minios.cfg | 2 +- tools/golang/xenlight/helpers.gen.go | 10 + tools/golang/xenlight/types.gen.go | 12 ++ tools/helpers/init-xenstore-domain.c | 7 + .../Linux/init.d/sysconfig.xencommons.in | 1 - tools/hotplug/Linux/launch-xenstore.in | 1 + tools/include/libxl.h | 22 ++ tools/libs/light/libxl_9pfs.c | 191 +++++++++++++++++- tools/libs/light/libxl_create.c | 4 +- tools/libs/light/libxl_dm.c | 2 +- tools/libs/light/libxl_types.idl | 11 + tools/libs/light/libxl_types_internal.idl | 1 + tools/xenstored/control.c | 29 +-- tools/xenstored/core.c | 15 +- tools/xenstored/core.h | 11 +- tools/xenstored/domain.c | 2 + tools/xenstored/lu_daemon.c | 4 +- tools/xenstored/minios.c | 62 ++++++ tools/xenstored/posix.c | 8 +- tools/xl/xl_parse.c | 23 ++- 22 files changed, 414 insertions(+), 42 deletions(-)
Signature · 1 line
2.35.3
PATCH v8 1/8 tools/libs/light: add backend type for 9pfs PV devices
Make the backend type of 9pfs PV devices configurable. The default is "qemu" with the related Xenstore backend-side directory being "9pfs".
Add another type "xen_9pfsd" with the related Xenstore backend-side directory "xen_9pfs".
As additional security features it is possible to specify:
- "max-space" for limiting the maximum space consumed on the filesystem in MBs
- "max-files" for limiting the maximum number of files in the filesystem
- "max-open-files" for limiting the maximum number of concurrent open files
For convenience "auto-delete" is available to let the backend delete the oldest file of the guest in case otherwise "max-space" or "max-files" would be violated.
The xen-9pfsd daemon will be started by libxenlight automatically when the first "xen_9pfs" device is being created.
---
V3:
- regenerate go bindings
V4:
- rename libxl_device_p9_dm_needed() to libxl__device_p9_dm_needed() (Anthony Perard)
- reorder span related functions (Anthony Perard)
- add comment for xen9pfsd_spawn() return values (Anthony Perard)
- add LIBXL_HAVE_XEN_9PFS to libxl.h (Anthony Perard)
- use a copy of 'p9' in xen9pfsd_spawn() (Anthony Perard) V6:
- rebase (Anthony Perard)
- drop callback from struct libxl__aop9_state (Anthony Perard)
--- tools/golang/xenlight/helpers.gen.go | 10 ++ tools/golang/xenlight/types.gen.go | 12 ++ tools/include/libxl.h | 7 + tools/libs/light/libxl_9pfs.c | 157 +++++++++++++++++++++- tools/libs/light/libxl_create.c | 4 +- tools/libs/light/libxl_dm.c | 2 +- tools/libs/light/libxl_types.idl | 11 ++ tools/libs/light/libxl_types_internal.idl | 1 + 8 files changed, 197 insertions(+), 7 deletions(-)
tools/golang/xenlight/helpers.gen.go +10 -0
@@ -2440,6 +2440,11 @@ x.Tag = C.GoString(xc.tag) x.Path = C.GoString(xc.path) x.SecurityModel = C.GoString(xc.security_model) x.Devid = Devid(xc.devid) +x.Type = P9Type(xc._type) +x.MaxSpace = int(xc.max_space) +x.MaxFiles = int(xc.max_files) +x.MaxOpenFiles = int(xc.max_open_files) +x.AutoDelete = bool(xc.auto_delete) return nil}
@@ -2458,6 +2463,11 @@ xc.path = C.CString(x.Path)} if x.SecurityModel != "" { xc.security_model = C.CString(x.SecurityModel)} xc.devid = C.libxl_devid(x.Devid) +xc._type = C.libxl_p9_type(x.Type) +xc.max_space = C.int(x.MaxSpace) +xc.max_files = C.int(x.MaxFiles) +xc.max_open_files = C.int(x.MaxOpenFiles) +xc.auto_delete = C.bool(x.AutoDelete) return nil }
tools/golang/xenlight/types.gen.go +12 -0
@@ -122,6 +122,13 @@ NicTypeVifIoemu NicType = 1 NicTypeVif NicType = 2 ) +type P9Type int +const( +P9TypeUnknown P9Type = 0 +P9TypeQemu P9Type = 1 +P9TypeXen9Pfsd P9Type = 2 +) + type ActionOnShutdown int const( ActionOnShutdownDestroy ActionOnShutdown = 1
@@ -889,6 +896,11 @@ Tag string Path string SecurityModel string Devid Devid +Type P9Type +MaxSpace int +MaxFiles int +MaxOpenFiles int +AutoDelete bool } type DevicePvcallsif struct {
tools/include/libxl.h +7 -0
@@ -615,6 +615,13 @@*/ #define LIBXL_HAVE_HVM_PIRQ 1 +/* +* LIBXL_HAVE_XEN_9PFS indicates the presence of the xen-9pfsd related +* fields in libxl_device_p9: type, max_space, max_files, max_open_files and +* auto_delete. +*/ +#define LIBXL_HAVE_XEN_9PFS 1 +/* * libxl memory management *
tools/libs/light/libxl_9pfs.c +154 -3
174 lines not on this page · raw message
tools/libs/light/libxl_create.c +1 -3
@@ -1761,9 +1761,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,libxl__device_console_dispose (&console); } -for (i =0 ; i < d_config->num_p9s; i++) -libxl__device_add (gc, domid, &libxl__p9_devtype, &d_config->p9s[i]); -for (i =0 ; i < d_config->num_pvcallsifs; i++)libxl__device_add (gc, domid, &libxl__pvcallsif_devtype, &d_config->pvcallsifs[i]);
@@ -1900,6 +1897,7 @@ const libxl__device_type *device_type_tbl[] = { &libxl__vdispl_devtype, &libxl__vsnd_devtype, &libxl__virtio_devtype, + &libxl__p9_devtype, NULL };
tools/libs/light/libxl_dm.c +1 -1
@@ -3761,7 +3761,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domain_config *d_config) goto out; } -if (d_config->num_vfbs >0 || d_config->num_p9s >0 ) { +if (d_config->num_vfbs >0 ) { ret =1 ; goto out; }
tools/libs/light/libxl_types.idl +11 -0
@@ -150,6 +150,12 @@ libxl_nic_type = Enumeration("nic_type", [ (2, "VIF"), ]) +libxl_p9_type = Enumeration("p9_type", [ + (0, "unknown"), + (1, "qemu"), + (2, "xen_9pfsd"), + ]) + libxl_action_on_shutdown = Enumeration("action_on_shutdown", [ (1, "DESTROY"),
@@ -943,6 +949,11 @@ libxl_device_p9 = Struct("device_p9", [ ("path", string), ("security_model", string), ("devid", libxl_devid), + ("type", libxl_p9_type), + ("max_space", integer), + ("max_files", integer), + ("max_open_files", integer), + ("auto_delete", bool), ]) libxl_device_pvcallsif = Struct("device_pvcallsif", [
tools/libs/light/libxl_types_internal.idl +1 -0
@@ -35,6 +35,7 @@ libxl__device_kind = Enumeration("device_kind", [ (17, "VIRTIO_DISK"), (18, "VIRTIO"), (19, "VBD3"), + (20, "XEN_9PFS"), ]) libxl__console_backend = Enumeration("console_backend", [
Signature · 1 line
2.35.3
PATCH v8 2/8 tools/xl: support new 9pfs backend xen_9pfsd
In reply to Juergen GrossAdd support for the new 9pfs backend "xen_9pfsd". For this backend type the tag defaults to "Xen" and the host side path to "/var/log/xen/guests/<dom-name>".
Do most of the default settings in libxl. Unfortunately the default path can't easily be set in libxl, as the domain name isn't available in the related 9pfs specific function.
Settings the defaults in libxl requires to move the sanity checking of 9pfs parameters from xl to libxl, too.
---
V2:
- test max_files and max_open_files, too (Jason Andryuk) V4:
- fix man page to use the "xen_9pfsd" type due to idl limitation (Jason Andryuk)
- set (most of) the defaults in libxl (Anthony Perard)
--- docs/man/xl.cfg.5.pod.in | 36 +++++++++++++++++++++++++++++++++-- tools/libs/light/libxl_9pfs.c | 18 ++++++++++++++++++ tools/xl/xl_parse.c | 23 +++++++++++++++++++--- 3 files changed, 72 insertions(+), 5 deletions(-)
docs/man/xl.cfg.5.pod.in +34 -2
@@ -772,10 +772,16 @@ settings, from the following list: =over 4 +=item B<type=TYPE> + +The backendtype for the PV device. Supported values are B<qemu> and +B<xen_9pfsd>. The default is B<qemu>. + =item B<tag=STRING> 9pfs tag to identify the filesystem share. The tag is needed on the -guest side to mount it. +guest side to mount it. For the backendtype of B<xen_9pfsd> the tag defaults to +"Xen". =item B<security_model="none">
@@ -785,12 +791,38 @@ squash or remap). =item B<path=STRING> -Filesystem path on the backend to export. +Filesystem path on the backend to export. For the backendtype of B<xen_9pfsd> +the path defaults to "@XEN_LOG_DIR@/guests/<guest-name>". =item B<backend=domain-id> Specify the backend domain name or id, defaults to dom0. +=item B<max-files=NUMBER> + +Specify the maximum number of files below B<path>. A value of 0 (which +is the default) doesn't limit the number of files. Only valid for +B<type=xen_9pfsd>. + +=item B<max-open-files=NUMBER> + +Specify the maximum number of concurrently opened files below B<path>. +Multiple opens of the same file are counted individually. Only valid for +B<type=xen_9pfsd>, which has a default of B<max-open-files=5>. + +=item B<max-space=NUMBER> + +Specify the maximum used disk space in MiB below B<path>. A value of 0 (which +is the default) doesn't limit the usable disk space. Only valid for +B<type=xen_9pfsd>. + +=item B<auto-delete=BOOLEAN> + +When set the backend will delete the oldest file which is currently not +opened by the guest in case the disk space limit set via B<max-space> or the +file limit set via B<max-files> is being reached. Only valid for +B<type=xen_9pfsd>. + =back =item B<pvcalls=[ "backend=domain-id", ... ]>
tools/libs/light/libxl_9pfs.c +18 -0
@@ -20,6 +20,24 @@static int libxl__device_p9_setdefault (libxl__gc *gc,uint32_t domid,libxl_device_p9 *p9,bool hotplug) { +if (p9->type ==LIBXL_P9_TYPE_UNKNOWN ) { + p9->type =LIBXL_P9_TYPE_QEMU ; + } +if (p9->type ==LIBXL_P9_TYPE_QEMU && + (p9->max_files || p9->max_open_files || p9->max_space || + p9->auto_delete)) { +LOGD (ERROR , domid,"Illegal 9pfs parameter combination" ); +return ERROR_INVAL ; + } +if (p9->type ==LIBXL_P9_TYPE_XEN_9PFSD && !p9->tag) { + p9->tag =libxl__strdup (NOGC ,"Xen" ); + } + +if (!p9->path || !p9->security_model || !p9->tag) { +LOGD (ERROR , domid,"9pfs spec missing required field!" ); +return ERROR_INVAL ; + } +return libxl__resolve_domid (gc, p9->backend_domname, &p9->backend_domid); }
tools/xl/xl_parse.c +20 -3
@@ -2233,6 +2233,20 @@ void parse_config_data(const char *config_source,replace_string (&p9->tag, value); }else if (!strcmp (key,"backend" )) {replace_string (&p9->backend_domname, value); + }else if (!strcmp (key,"type" )) { +if (libxl_p9_type_from_string (value, &p9->type)) { +fprintf (stderr,"failed to parse 9pfs type: %s\n" , + value); +exit (1 ); + } + }else if (!strcmp (key,"max-files" )) { + p9->max_files =parse_ulong (value); + }else if (!strcmp (key,"max-open-files" )) { + p9->max_open_files =parse_ulong (value); + }else if (!strcmp (key,"max-space" )) { + p9->max_space =parse_ulong (value); + }else if (!strcmp (key,"auto-delete" )) { + p9->auto_delete =strtoul (value,NULL ,0 ); }else {fprintf (stderr,"Unknown 9pfs parameter '%s'\n" , key);exit (1 );
@@ -2243,9 +2257,12 @@ void parse_config_data(const char *config_source,libxl_string_list_dispose (&pairs); -if (!p9->path || !p9->security_model || !p9->tag) { -fprintf (stderr,"9pfs spec missing required field!\n" ); -exit (1 ); +if (p9->type ==LIBXL_P9_TYPE_XEN_9PFSD && !p9->path) { +char *path; + +xasprintf (&path,XEN_LOG_DIR "/guests/%s" , c_info->name); +replace_string (&p9->path, path); +free (path); } } }
Signature · 1 line
2.35.3
PATCH v8 3/8 stubdom: extend xenstore stubdom configs
In reply to Juergen GrossExtend the config files of the Xenstore stubdoms to include XENBUS and 9PFRONT items in order to support file based logging.
--- stubdom/xenstore-minios.cfg | 2 +- stubdom/xenstorepvh-minios.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
stubdom/xenstore-minios.cfg +1 -1
@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n CONFIG_CONSFRONT=n -CONFIG_XENBUS=n CONFIG_LWIP=n +CONFIG_9PFRONT=y CONFIG_BALLOON=y XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
stubdom/xenstorepvh-minios.cfg +1 -1
@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n CONFIG_CONSFRONT=n -CONFIG_XENBUS=n CONFIG_LWIP=n +CONFIG_9PFRONT=y CONFIG_BALLOON=y XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
Signature · 1 line
2.35.3
Re: [PATCH v8 3/8] stubdom: extend xenstore stubdom configs
Quoted 5 lines · Juergen Gross
Extend the config files of the Xenstore stubdoms to include XENBUS and 9PFRONT items in order to support file based logging.
Signed-off-by Juergen Gross <[email protected]>Reviewed-by Jason Andryuk <[email protected]>
Samuel, are you fine with this patch?
Juergen
Quoted 31 lines
--- stubdom/xenstore-minios.cfg | 2 +- stubdom/xenstorepvh-minios.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)stubdom/xenstore-minios.cfg +1
-1@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n CONFIG_CONSFRONT=n -CONFIG_XENBUS=n CONFIG_LWIP=n +CONFIG_9PFRONT=y CONFIG_BALLOON=y XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__stubdom/xenstorepvh-minios.cfg +1
-1@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n CONFIG_CONSFRONT=n -CONFIG_XENBUS=n CONFIG_LWIP=n +CONFIG_9PFRONT=y CONFIG_BALLOON=y XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
Samuel Thibault
Acked-byRe: [PATCH v8 3/8] stubdom: extend xenstore stubdom configs
Juergen Gross, le jeu. 22 févr. 2024 17:06:09 +0100, a ecrit:
Quoted 8 lines · Juergen Gross
Quoted 5 lines
Extend the config files of the Xenstore stubdoms to include XENBUS and 9PFRONT items in order to support file based logging.
Signed-off-by Juergen Gross <[email protected]>Reviewed-by Jason Andryuk <[email protected]>Samuel, are you fine with this patch?
Yes!
Samuel
Quoted 36 lines
Juergen
Quoted 31 lines
--- stubdom/xenstore-minios.cfg | 2 +- stubdom/xenstorepvh-minios.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)stubdom/xenstore-minios.cfg +1
-1@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n CONFIG_CONSFRONT=n -CONFIG_XENBUS=n CONFIG_LWIP=n +CONFIG_9PFRONT=y CONFIG_BALLOON=y XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__stubdom/xenstorepvh-minios.cfg +1
-1@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n CONFIG_FBFRONT=n CONFIG_KBDFRONT=n CONFIG_CONSFRONT=n -CONFIG_XENBUS=n CONFIG_LWIP=n +CONFIG_9PFRONT=y CONFIG_BALLOON=y XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
PATCH v8 4/8 tools: add 9pfs device to xenstore-stubdom
In reply to Juergen GrossAdd 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"
- type = "xen_9pfsd"
- path = "/var/lib/xen/xenstore"
- security-model = "none"
For now don't limit allowed file space or number of files.
Add a new libxl function for adding it similar to the function for adding the console device.
---
V2:
- add security_model parameter to new libxl function (Jason Andryuk) V4:
- rename function to libxl_device_9pfs_add() (Anthony Perard)
- use a libxl_device_p9 pointer as parameter (Anthony Perard) V8:
- remove "_XENSTORE" suffix from define (Anthony Perard)
--- tools/helpers/init-xenstore-domain.c | 7 +++++++ tools/include/libxl.h | 15 +++++++++++++++ tools/libs/light/libxl_9pfs.c | 16 ++++++++++++++++ 3 files changed, 38 insertions(+)
tools/helpers/init-xenstore-domain.c +7 -0
@@ -433,6 +433,12 @@ int main(int argc, char** argv)int rv, fd;char *maxmem_str =NULL ;libxl_ctx *ctx; +libxl_device_p9 p9 = { .backend_domid =0 , + .tag ="Xen" , + .path =XEN_LIB_DIR "/xenstore" , + .security_model ="none" , + .type =LIBXL_P9_TYPE_XEN_9PFSD , + };while ( (opt =getopt_long (argc, argv,"v" , options,NULL )) !=-1 ) {
@@ -543,6 +549,7 @@ int main(int argc, char** argv) }libxl_console_add_xenstore (ctx, domid,0 , console_evtchn, console_gfn,NULL ); +libxl_device_9pfs_add (ctx, domid, &p9,NULL );libxl_ctx_free (ctx); fd =creat (XEN_RUN_DIR "/xenstored.pid" ,0666 );
tools/include/libxl.h +15 -0
@@ -583,6 +583,13 @@* libxl_console_add_xenstore() in libxl. */ #define LIBXL_HAVE_CONSOLE_ADD_XENSTORE 1 + +/* +* LIBXL_HAVE_P9_ADD indicates presence of the function +* libxl_device_9pfs_add() in libxl. +*/ +#define LIBXL_HAVE_P9_ADD 1 +/* * libxl ABI compatibility *
@@ -2074,6 +2081,14 @@ 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_device_9pfs_add writes the Xenstore entries for a domain's +* primary 9pfs device based on domid, and device parameters. +* If needed it will start the backend daemon. +*/ +int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 *p9, + 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). */
tools/libs/light/libxl_9pfs.c +16 -0
@@ -206,6 +206,22 @@ static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid, aodev->callback (egc, aodev); } +int libxl_device_9pfs_add (libxl_ctx *ctx,uint32_t domid,libxl_device_p9 *p9, +const libxl_asyncop_how *ao_how) +{ +AO_CREATE (ctx, domid, ao_how); +libxl__ao_device *aodev; + +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
Signature · 1 line
2.35.3
PATCH v8 5/8 tools/xenstored: mount 9pfs device in stubdom
In reply to Juergen GrossMount the 9pfs device in stubdom enabling it to use files.
This has to happen in a worker thread in order to allow the main thread handling the required Xenstore accesses in parallel.
---
V3:
- add logging in case of errors (Julien Grall)
--- tools/xenstored/core.h | 6 +++++ tools/xenstored/domain.c | 2 ++ tools/xenstored/minios.c | 54 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+)
tools/xenstored/core.h +6 -0
@@ -36,6 +36,8 @@#include "list.h" #include "hashtable.h" +#define XENSTORE_LIB_DIR XEN_LIB_DIR "/xenstore" +#ifndef O_CLOEXEC #define O_CLOEXEC 0/* O_CLOEXEC support is needed for Live Update in the daemon case. */
@@ -399,6 +401,10 @@ void handle_special_fds(void);int get_socket_fd (void );void set_socket_fd (int fd); +#ifdef __MINIOS__ +void mount_9pfs (void ); +#endif +/* Close stdin/stdout/stderr to complete daemonize */ void finish_daemonize (void );
tools/xenstored/domain.c +2 -0
@@ -1236,6 +1236,8 @@ void stubdom_init(void)barf_perror ("Failed to initialize stubdom" );xenevtchn_notify (xce_handle, stubdom->port); + +mount_9pfs ();#endif }
tools/xenstored/minios.c +54 -0
67 lines not on this page · raw message
Signature · 1 line
2.35.3
PATCH v8 6/8 tools/xenstored: add helpers for filename handling
In reply to Juergen GrossAdd some helpers for handling filenames which might need different implementations between stubdom and daemon environments:
- expansion of relative filenames (those are not really defined today, just expand them to be relative to /var/lib/xen/xenstore)
- expansion of xenstore_daemon_rundir() (used e.g. for saving the state file in case of live update - needs to be unchanged in the daemon case, but should result in /var/lib/xen/xenstore for stubdom)
---
V3:
- make absolute_filename() return a pointer to const (Julien Grall)
--- tools/xenstored/core.c | 15 +++++++++++++-- tools/xenstored/core.h | 5 ++++- tools/xenstored/lu_daemon.c | 4 ++-- tools/xenstored/minios.c | 5 +++++ tools/xenstored/posix.c | 8 +++++++- 5 files changed, 31 insertions(+), 6 deletions(-)
tools/xenstored/core.c +13 -2
@@ -63,7 +63,7 @@ char **orig_argv;LIST_HEAD (connections);int tracefd =-1 ;bool keep_orphans = false; -char *tracefile =NULL ; +const char *tracefile =NULL ;static struct hashtable *nodes;unsigned int trace_flags =TRACE_OBJ |TRACE_IO ;
@@ -137,6 +137,17 @@ void trace_destroy(const void *data, const char *type)trace ("obj: DESTROY %s %p\n" , type, data); } +/* +* Return an absolute filename. +* In case of a relative filename given as input, prepend XENSTORE_LIB_DIR. +*/ +const char *absolute_filename (const void *ctx,const char *filename) +{ +if (filename[0 ] !='/' ) +return talloc_asprintf (ctx,XENSTORE_LIB_DIR "/%s" , filename); +return talloc_strdup (ctx, filename); +} +void close_log (void ) {if (tracefd >=0 )
@@ -2759,7 +2770,7 @@ int main(int argc, char *argv[])#endif if (tracefile) - tracefile =talloc_strdup (NULL , tracefile); + tracefile =absolute_filename (NULL , tracefile);#ifndef NO_LIVE_UPDATE /* Read state in case of live update. */
tools/xenstored/core.h +4 -1
@@ -341,7 +341,7 @@ void close_log(void);extern int orig_argc;extern char **orig_argv; -extern char *tracefile; +extern const char *tracefile;extern int tracefd;/* Trace flag values must be kept in sync with trace_switches[] contents. */
@@ -405,6 +405,9 @@ void set_socket_fd(int fd);void mount_9pfs (void );#endif +const char *xenstore_rundir (void ); +const char *absolute_filename (const void *ctx,const char *filename); +/* Close stdin/stdout/stderr to complete daemonize */ void finish_daemonize (void );
tools/xenstored/lu_daemon.c +2 -2
@@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state) state->size =0 ; state->filename =talloc_asprintf (NULL ,"%s/state_dump" , -xenstore_daemon_rundir ()); +xenstore_rundir ());if (!state->filename)barf ("Allocation failure" );
@@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx)int fd; filename =talloc_asprintf (ctx,"%s/state_dump" , -xenstore_daemon_rundir ()); +xenstore_rundir ());if (!filename)return NULL ;
tools/xenstored/minios.c +5 -0
@@ -128,3 +128,8 @@ void mount_9pfs(void) {create_thread ("mount-9pfs" , mount_thread,NULL ); } + +const char *xenstore_rundir (void ) +{ +return XENSTORE_LIB_DIR ; +}
tools/xenstored/posix.c +7 -1
@@ -326,9 +326,10 @@ void early_init(bool live_update, bool dofork, const char *pidfile) {reopen_log (); -/* Make sure xenstored directory exists. */ +/* Make sure xenstored directories exist. */ /* Errors ignored here, will be reported when we open files */ mkdir (xenstore_daemon_rundir (),0755 ); +mkdir (XENSTORE_LIB_DIR ,0755 );if (dofork) {openlog ("xenstored" ,0 ,LOG_DAEMON );
@@ -406,3 +407,8 @@ void set_socket_fd(int fd) { sock = fd; } + +const char *xenstore_rundir (void ) +{ +return xenstore_daemon_rundir (); +}
Signature · 1 line
2.35.3
PATCH v8 7/8 tools/xenstored: support complete log capabilities in stubdom
In reply to Juergen GrossWith 9pfs being fully available in Xenstore-stubdom now, there is no reason to not fully support all logging capabilities in stubdom.
Open the logfile on stubdom only after the 9pfs file system has been mounted.
---
V3:
- remove now stale comment in sysconfig.xencommons.in (Julien Grall)
--- .../Linux/init.d/sysconfig.xencommons.in | 1 - tools/hotplug/Linux/launch-xenstore.in | 1 + tools/xenstored/control.c | 30 +++++++++---------- tools/xenstored/minios.c | 3 ++ 4 files changed, 19 insertions(+), 16 deletions(-)
tools/hotplug/Linux/init.d/sysconfig.xencommons.in +0 -1
@@ -58,7 +58,6 @@ XENSTORED_ARGS= ## Default: Not defined, tracing off # # Log xenstored messages -# Only evaluated if XENSTORETYPE is "daemon". #XENSTORED_TRACE=[yes|on|1] ## Type: integer
tools/hotplug/Linux/launch-xenstore.in +1 -0
@@ -98,6 +98,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF [ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=8 XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_SIZE" [ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE" + [ -z "$XENSTORED_TRACE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS -T xenstored-trace.log" echo -n Starting $XENSTORE_DOMAIN_KERNEL... ${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
tools/xenstored/control.c +15 -15
@@ -201,19 +201,6 @@ static int do_control_quota_s(const void *ctx, struct connection *conn,return EINVAL ; } -#ifdef __MINIOS__ -static int do_control_memreport (const void *ctx,struct connection *conn, -const char **vec,int num) -{ -if (num) -return EINVAL ; - -talloc_report_full (NULL , stdout); - -send_ack (conn,XS_CONTROL ); -return 0 ; -} -#else static int do_control_logfile (const void *ctx,struct connection *conn,const char **vec,int num) {
@@ -222,13 +209,26 @@ static int do_control_logfile(const void *ctx, struct connection *conn,close_log ();talloc_free (tracefile); - tracefile =talloc_strdup (NULL , vec[0 ]); + tracefile =absolute_filename (NULL , vec[0 ]);reopen_log ();send_ack (conn,XS_CONTROL );return 0 ; } +#ifdef __MINIOS__ +static int do_control_memreport (const void *ctx,struct connection *conn, +const char **vec,int num) +{ +if (num) +return EINVAL ; + +talloc_report_full (NULL , stdout); + +send_ack (conn,XS_CONTROL ); +return 0 ; +} +#else static int do_control_memreport (const void *ctx,struct connection *conn,const char **vec,int num) {
@@ -309,10 +309,10 @@ static struct cmd_s cmds[] = {"[-c <cmdline>] [-F] [-t <timeout>] <file>\n" " Default timeout is 60 seconds.", 5 }, #endif + { "logfile", do_control_logfile, "<file>" }, #ifdef __MINIOS__ { "memreport", do_control_memreport, "" }, #else - { "logfile", do_control_logfile, "<file>" }, { "memreport", do_control_memreport, "[<file>]" }, #endif { "print", do_control_print, "<string>" },
tools/xenstored/minios.c +3 -0
@@ -122,6 +122,9 @@ static void mount_thread(void *p) } p9_device =init_9pfront (0 ,XENSTORE_LIB_DIR ); + +/* Start logging if selected. */ +reopen_log (); }void mount_9pfs (void )
Signature · 1 line
2.35.3
PATCH v8 8/8 tools/xenstored: have a single do_control_memreport()
In reply to Juergen GrossWith 9pfs now available in Xenstore-stubdom, there is no reason to have distinct do_control_memreport() variants for the daemon and the stubdom implementations.
--- tools/xenstored/control.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-)
tools/xenstored/control.c +7 -20
@@ -216,23 +216,11 @@ static int do_control_logfile(const void *ctx, struct connection *conn,return 0 ; } -#ifdef __MINIOS__ -static int do_control_memreport (const void *ctx,struct connection *conn, -const char **vec,int num) -{ -if (num) -return EINVAL ; - -talloc_report_full (NULL , stdout); - -send_ack (conn,XS_CONTROL ); -return 0 ; -} -#else static int do_control_memreport (const void *ctx,struct connection *conn,const char **vec,int num) {FILE *fp; +const char *filename;int fd;if (num >1 )
@@ -255,8 +243,12 @@ static int do_control_memreport(const void *ctx, struct connection *conn,if (!fp)close (fd); } - }else - fp =fopen (vec[0 ],"a" ); + }else { + filename =absolute_filename (ctx, vec[0 ]); +if (!filename) +return ENOMEM ; + fp =fopen (filename,"a" ); + }if (!fp)return EBADF ;
@@ -267,7 +259,6 @@ static int do_control_memreport(const void *ctx, struct connection *conn,send_ack (conn,XS_CONTROL );return 0 ; } -#endif static int do_control_print (const void *ctx,struct connection *conn,const char **vec,int num)
@@ -310,11 +301,7 @@ static struct cmd_s cmds[] = { " Default timeout is 60 seconds.", 5 }, #endif { "logfile", do_control_logfile, "<file>" }, -#ifdef __MINIOS__ - { "memreport", do_control_memreport, "" }, -#else { "memreport", do_control_memreport, "[<file>]" }, -#endif { "print", do_control_print, "<string>" }, { "quota", do_control_quota, "[set <name> <val>|<domid>|max [-r]]" },
Signature · 1 line
2.35.3