tools: enable xenstore-stubdom to use 9pfs
v9 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. CI-test has passed.
Changes in V9:
- new patch 1
- patches 1+2 and 4 of V8 have been applied
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 (6):
config: update Mini-OS commit
stubdom: extend xenstore stubdom configs 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()
Config.mk | 2 +- stubdom/xenstore-minios.cfg | 2 +- stubdom/xenstorepvh-minios.cfg | 2 +- .../Linux/init.d/sysconfig.xencommons.in | 1 - tools/hotplug/Linux/launch-xenstore.in | 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 ++- 12 files changed, 108 insertions(+), 31 deletions(-)
Signature · 1 line
2.35.3
PATCH v9 1/6 config: update Mini-OS commit
Update the Mini-OS upstream revision.
---
V9:
- new patch
--- Config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Config.mk +1 -1
@@ -224,7 +224,7 @@ QEMU_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/qemu-xen.git QEMU_UPSTREAM_REVISION ?= master MINIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/mini-os.git -MINIOS_UPSTREAM_REVISION ?= 2bc8dbb9b6111113d27455cbca318ea337309c04 +MINIOS_UPSTREAM_REVISION ?= b6a5b4d72b88e5c4faed01f5a44505de022860fc SEABIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/seabios.git SEABIOS_UPSTREAM_REVISION ?= rel-1.16.3
Signature · 1 line
2.35.3
PATCH v9 2/6 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
PATCH v9 3/6 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 v9 4/6 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 v9 5/6 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 v9 6/6 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
Re: [PATCH v9 1/6] config: update Mini-OS commit
In reply to Juergen GrossQuoted 3 lines · Juergen Gross
Update the Mini-OS upstream revision.
Signed-off-by Juergen Gross <[email protected]>
Re: [PATCH v9 2/6] stubdom: extend xenstore stubdom configs
In reply to Juergen GrossQuoted 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]>
Was an ack from Samuel lost here? Or was it dropped on purpose?
Jan
Re: [PATCH v9 2/6] stubdom: extend xenstore stubdom configs
Quoted 8 lines · Jan Beulich
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]>Was an ack from Samuel lost here? Or was it dropped on purpose?
Oh, I think I lost it.
Juergen