From 92babc88f67ed0ef3dc575a8b9534040274678ee Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 23 Feb 2024 18:49:33 +0000 Subject: [PATCH] Revert stubdom+xenstore 9pfs changes to unblock CI. It turns out there are still issues in some configurations. https://gitlab.com/xen-project/xen/-/pipelines/1188660609 This reverts commit f5e1c527d0a0d09ca0cb1dcd8d4ab4a1a5261e91. This reverts commit a76f8809f10f1764d4627844461906dac93e68df. This reverts commit 93892648ffaf78a682edef48ea2d108650b3b547. This reverts commit 297a2587e6b5ab2edbadce90cec0d5192625973c. This reverts commit 0b761781c4de2e6637203d0f51273a5a1f8873df. Signed-off-by: Andrew Cooper --- 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 +-- 11 files changed, 30 insertions(+), 107 deletions(-) diff --git a/stubdom/xenstore-minios.cfg b/stubdom/xenstore-minios.cfg index 239da519b995..a41704bb6bab 100644 --- a/stubdom/xenstore-minios.cfg +++ b/stubdom/xenstore-minios.cfg @@ -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__ diff --git a/stubdom/xenstorepvh-minios.cfg b/stubdom/xenstorepvh-minios.cfg index 752b90d7d36a..6af51f575345 100644 --- a/stubdom/xenstorepvh-minios.cfg +++ b/stubdom/xenstorepvh-minios.cfg @@ -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__ diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in index 1bdd830d8a6f..433e4849af1b 100644 --- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in +++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in @@ -58,6 +58,7 @@ XENSTORED_ARGS= ## Default: Not defined, tracing off # # Log xenstored messages +# Only evaluated if XENSTORETYPE is "daemon". #XENSTORED_TRACE=[yes|on|1] ## Type: integer diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in index da4eeca7c53e..e854ca1eb895 100644 --- a/tools/hotplug/Linux/launch-xenstore.in +++ b/tools/hotplug/Linux/launch-xenstore.in @@ -98,7 +98,6 @@ 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 diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c index 956128917942..b2f64d674f7b 100644 --- a/tools/xenstored/control.c +++ b/tools/xenstored/control.c @@ -201,6 +201,19 @@ 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) { @@ -209,7 +222,7 @@ static int do_control_logfile(const void *ctx, struct connection *conn, close_log(); talloc_free(tracefile); - tracefile = absolute_filename(NULL, vec[0]); + tracefile = talloc_strdup(NULL, vec[0]); reopen_log(); send_ack(conn, XS_CONTROL); @@ -220,7 +233,6 @@ 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) @@ -243,12 +255,8 @@ static int do_control_memreport(const void *ctx, struct connection *conn, if (!fp) close(fd); } - } else { - filename = absolute_filename(ctx, vec[0]); - if (!filename) - return ENOMEM; - fp = fopen(filename, "a"); - } + } else + fp = fopen(vec[0], "a"); if (!fp) return EBADF; @@ -259,6 +267,7 @@ 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) @@ -300,8 +309,12 @@ static struct cmd_s cmds[] = { "[-c ] [-F] [-t ] \n" " Default timeout is 60 seconds.", 5 }, #endif +#ifdef __MINIOS__ + { "memreport", do_control_memreport, "" }, +#else { "logfile", do_control_logfile, "" }, { "memreport", do_control_memreport, "[]" }, +#endif { "print", do_control_print, "" }, { "quota", do_control_quota, "[set ||max [-r]]" }, diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c index bada1ad9a23f..48fc787ac176 100644 --- a/tools/xenstored/core.c +++ b/tools/xenstored/core.c @@ -63,7 +63,7 @@ char **orig_argv; LIST_HEAD(connections); int tracefd = -1; bool keep_orphans = false; -const char *tracefile = NULL; +char *tracefile = NULL; static struct hashtable *nodes; unsigned int trace_flags = TRACE_OBJ | TRACE_IO; @@ -137,17 +137,6 @@ 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) @@ -2770,7 +2759,7 @@ int main(int argc, char *argv[]) #endif if (tracefile) - tracefile = absolute_filename(NULL, tracefile); + tracefile = talloc_strdup(NULL, tracefile); #ifndef NO_LIVE_UPDATE /* Read state in case of live update. */ diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h index e58779e88c82..f6af086f0108 100644 --- a/tools/xenstored/core.h +++ b/tools/xenstored/core.h @@ -36,8 +36,6 @@ #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. */ @@ -341,7 +339,7 @@ void close_log(void); extern int orig_argc; extern char **orig_argv; -extern const char *tracefile; +extern char *tracefile; extern int tracefd; /* Trace flag values must be kept in sync with trace_switches[] contents. */ @@ -401,13 +399,6 @@ void handle_special_fds(void); int get_socket_fd(void); void set_socket_fd(int fd); -#ifdef __MINIOS__ -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); diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c index 64c8fd0cc35b..1a7d5e975688 100644 --- a/tools/xenstored/domain.c +++ b/tools/xenstored/domain.c @@ -1236,8 +1236,6 @@ void stubdom_init(void) barf_perror("Failed to initialize stubdom"); xenevtchn_notify(xce_handle, stubdom->port); - - mount_9pfs(); #endif } diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c index 6351111ab0e8..71bcabadd31f 100644 --- a/tools/xenstored/lu_daemon.c +++ b/tools/xenstored/lu_daemon.c @@ -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_rundir()); + xenstore_daemon_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_rundir()); + xenstore_daemon_rundir()); if (!filename) return NULL; diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c index a229954cf4b8..22ac8defbdea 100644 --- a/tools/xenstored/minios.c +++ b/tools/xenstored/minios.c @@ -17,20 +17,10 @@ */ #include #include -#include -#include "talloc.h" #include "core.h" #include "utils.h" #include #include -#include -#include -#include -#include - -#define P9_STATE_PATH "device/9pfs/0/state" - -static void *p9_device; void finish_daemonize(void) { @@ -84,55 +74,3 @@ int get_socket_fd(void) void set_socket_fd(int fd) { } - -static void mount_thread(void *p) -{ - xenbus_event_queue events = NULL; - char *err; - char *dummy; - - err = xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events); - if (err) { - log("error \"%s\" when setting watch on \"%s\"\n", err, - P9_STATE_PATH); - free(err); - return; - } - - for (;;) { - xenbus_wait_for_watch(&events); - - /* - * We only care for existence of the state node. - * State changes are handled in init_9pfront(). - */ - err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy); - if (!err) - break; - free(err); - } - - free(dummy); - - err = xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs"); - if (err) { - log("error \"%s\" when unwatching \"%s\", leaking watch\n", - err, P9_STATE_PATH); - free(err); - } - - p9_device = init_9pfront(0, XENSTORE_LIB_DIR); - - /* Start logging if selected. */ - reopen_log(); -} - -void mount_9pfs(void) -{ - create_thread("mount-9pfs", mount_thread, NULL); -} - -const char *xenstore_rundir(void) -{ - return XENSTORE_LIB_DIR; -} diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c index d88c82d972d7..496329dfd182 100644 --- a/tools/xenstored/posix.c +++ b/tools/xenstored/posix.c @@ -326,10 +326,9 @@ void early_init(bool live_update, bool dofork, const char *pidfile) { reopen_log(); - /* Make sure xenstored directories exist. */ + /* Make sure xenstored directory exists. */ /* 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); @@ -407,8 +406,3 @@ void set_socket_fd(int fd) { sock = fd; } - -const char *xenstore_rundir(void) -{ - return xenstore_daemon_rundir(); -}