[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 0/24] [xen-unstable.hg] support for xenstore stubdom



Hi,

I'd like to append a 25th patch to this patchqueue.

The attached patch causes all syslog to be redirected to the console when xenstore is running in a mini-OS stubdomain. The console messages can be viewed using xenconsole_dump, or with "/etc/init.d/xenstored console" which just calls xenconsole_dump with the appropriate parameters.

Without this patch all syslog messages are just lost when running in a 
stubdomain.

Regards,

Alex

Alex Zeffertt wrote:
These are the xen/ tools/ and stubdom/ patches that enable the option of
starting xenstored in a seperate stub domain.

Applying these patches does not change the behaviour unless 'STUBDOM=yes' is
written into /etc/sysconfig/xenstore.  If you do this then you need to also
apply the previous set of patches to the linux-2.6.18-xen kernel and reboot.

Please consider these patches for application into xen-unstable.

Regards,

Alex Zeffertt



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


Redirect syslog to console if running in mini-OS stub domain 
instead of just disabling syslog.

Signed-off-by: <alex.zeffertt@xxxxxxxxxxxxx>

diff -r 64e700f5429a tools/xenstore/Makefile
--- a/tools/xenstore/Makefile   Wed May 06 15:16:53 2009 +0100
+++ b/tools/xenstore/Makefile   Thu May 07 10:46:48 2009 +0100
@@ -27,7 +27,7 @@
 endif
 
 ifdef CONFIG_STUBDOM
-CFLAGS += -DNO_SOCKETS=1 -DNO_LOCAL_XENBUS=1 -DNO_SYSLOG=1 -DNO_REOPEN_LOG=1
+CFLAGS += -DNO_SOCKETS=1 -DNO_LOCAL_XENBUS=1 -DNO_TRACEFILE=1
 endif
 
 ALL_TARGETS = libxenstore.so libxenstore.a clients xs_tdb_dump 
diff -r 64e700f5429a tools/xenstore/xenstored_core.c
--- a/tools/xenstore/xenstored_core.c   Wed May 06 15:16:53 2009 +0100
+++ b/tools/xenstore/xenstored_core.c   Thu May 07 10:46:48 2009 +0100
@@ -32,8 +32,8 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
-#ifndef NO_SYSLOG
-#include <syslog.h>
+#ifndef __MINIOS__
+# include <syslog.h>
 #endif
 #include <string.h>
 #include <errno.h>
@@ -64,32 +64,31 @@
 
 static bool verbose = false;
 LIST_HEAD(connections);
-static int tracefd = -1;
 static bool recovery = true;
 static bool remove_local = true;
-#ifndef NO_REOPEN_LOG
-static int reopen_log_pipe[2];
+#ifndef NO_TRACEFILE
+static int reopen_tracefile_pipe[2];
+static char *tracefile = NULL;
+static int tracefd = -1;
 #endif
-static char *tracefile = NULL;
 static TDB_CONTEXT *tdb_ctx;
 
 static void corrupt(struct connection *conn, const char *fmt, ...);
 static void check_store(void);
 
 #ifdef __MINIOS__
-#define lockf(...) (-ENOSYS)
-#endif
-
-#ifdef NO_SYSLOG
-#define openlog(...) ((void) 0)
-#define syslog(...)  ((void) 0)
+# define log_init() do {} while(0)
+# define __log(s) printf("%s\n",  s);
+#else
+# define log_init() openlog("xenstored", 0, LOG_DAEMON)
+# define __log(s) syslog(LOG_ERR, "%s",  s);
 #endif
 
 #define log(...)                                                       \
        do {                                                            \
                char *s = talloc_asprintf(NULL, __VA_ARGS__);           \
                trace("%s\n", s);                                       \
-               syslog(LOG_ERR, "%s",  s);                              \
+               __log(s)                                                \
                talloc_free(s);                                         \
        } while (0)
 
@@ -146,6 +145,15 @@
        }
 }
 
+#ifdef NO_TRACEFILE
+void trace(const char *fmt, ...) {}
+static void trace_io(const struct connection *conn,
+                    const struct buffered_data *data,
+                    int out) {}
+void trace_create(const void *data, const char *type) {}
+void trace_destroy(const void *data, const char *type) {}
+
+#else
 void trace(const char *fmt, ...)
 {
        va_list arglist;
@@ -213,21 +221,20 @@
        trace("DESTROY %s %p\n", type, data);
 }
 
-#ifndef NO_REOPEN_LOG
 /**
  * Signal handler for SIGHUP, which requests that the trace log is reopened
- * (in the main loop).  A single byte is written to reopen_log_pipe, to awaken
+ * (in the main loop).  A single byte is written to reopen_tracefile_pipe, to 
awaken
  * the select() in the main loop.
  */
-static void trigger_reopen_log(int signal __attribute__((unused)))
+static void trigger_reopen_tracefile(int signal __attribute__((unused)))
 {
        char c = 'A';
        int dummy;
-       dummy = write(reopen_log_pipe[1], &c, 1);
+       dummy = write(reopen_tracefile_pipe[1], &c, 1);
 }
 
 
-static void reopen_log(void)
+static void reopen_tracefile(void)
 {
        if (tracefile) {
                if (tracefd > 0)
@@ -241,7 +248,7 @@
                        trace("\n***\n");
        }
 }
-#endif
+#endif /* NO_TRACEFILE */
 
 static bool write_messages(struct connection *conn)
 {
@@ -348,8 +355,8 @@
        set_fd(sock,               inset, &max);
        set_fd(ro_sock,            inset, &max);
 #endif
-#ifndef NO_REOPEN_LOG
-       set_fd(reopen_log_pipe[0], inset, &max);
+#ifndef NO_TRACEFILE
+       set_fd(reopen_tracefile_pipe[0], inset, &max);
 #endif
 
        if (xce_handle != -1)
@@ -1313,8 +1320,7 @@
                        return;
 
                if (in->hdr.msg.len > XENSTORE_PAYLOAD_MAX) {
-                       syslog(LOG_ERR, "Client tried to feed us %i",
-                              in->hdr.msg.len);
+                       log("Client tried to feed us %i", in->hdr.msg.len);
                        goto bad_client;
                }
 
@@ -1694,7 +1700,7 @@
        check_store();
 }
 
-
+#ifndef __MINIOS__
 static void write_pidfile(const char *pidfile)
 {
        char buf[100];
@@ -1713,6 +1719,7 @@
        if (write(fd, buf, len) != len)
                barf_perror("Writing pid file %s", pidfile);
 }
+#endif
 
 /* Stevens. */
 static void daemonize(void)
@@ -1769,15 +1776,19 @@
 }
 
 
-static struct option options[] = {
+static struct option options_long[] = {
        { "no-domain-init", 0, NULL, 'D' },
        { "entry-nb", 1, NULL, 'E' },
+#ifndef __MINIOS__
        { "pid-file", 1, NULL, 'F' },
+#endif
        { "help", 0, NULL, 'H' },
        { "no-fork", 0, NULL, 'N' },
        { "output-pid", 0, NULL, 'P' },
        { "entry-size", 1, NULL, 'S' },
+#ifndef NO_TRACEFILE
        { "trace-file", 1, NULL, 'T' },
+#endif
        { "transaction", 1, NULL, 't' },
        { "no-recovery", 0, NULL, 'R' },
        { "preserve-local", 0, NULL, 'L' },
@@ -1788,6 +1799,16 @@
        { "dom0-port", 1, NULL, 'z' },
        { NULL, 0, NULL, 0 } };
 
+static const char *options_short = "DE:HNPS:t:RLVW:"
+#ifndef NO_TRACEFILE
+       "T:"
+#endif
+#ifndef __MINIOS__
+       "F:"
+#endif
+       ;
+       
+       
 extern void dump_conn(struct connection *conn); 
 
 int main(int argc, char *argv[])
@@ -1801,14 +1822,16 @@
        bool dofork = true;
        bool outputpid = false;
        bool no_domain_init = false;
+#ifndef __MINIOS__
        const char *pidfile = NULL;
+#endif
        int evtchn_fd = -1;
        struct timeval *timeout;
 
        sleep(5);
        fprintf(stderr, "xenstored_core.c:main()\n");
 
-       while ((opt = getopt_long(argc, argv, "DE:F:HNPS:t:T:RLVW:", options,
+       while ((opt = getopt_long(argc, argv, options_short, options_long,
                                  NULL)) != -1) {
                switch (opt) {
                case 'D':
@@ -1817,9 +1840,11 @@
                case 'E':
                        quota_nb_entry_per_domain = strtol(optarg, NULL, 10);
                        break;
+#ifndef __MINIOS__
                case 'F':
                        pidfile = optarg;
                        break;
+#endif
                case 'H':
                        usage();
                        return 0;
@@ -1841,9 +1866,11 @@
                case 't':
                        quota_max_transaction = strtol(optarg, NULL, 10);
                        break;
+#ifndef NO_TRACEFILE
                case 'T':
                        tracefile = optarg;
                        break;
+#endif
                case 'V':
                        verbose = true;
                        break;
@@ -1864,8 +1891,8 @@
        if (optind != argc)
                barf("%s: No arguments desired", argv[0]);
 
-#ifndef NO_REOPEN_LOG
-       reopen_log();
+#ifndef NO_TRACEFILE
+       reopen_tracefile();
 #endif
 
 #ifndef __MINIOS__
@@ -1886,12 +1913,13 @@
 #endif
 
        if (dofork) {
-               openlog("xenstored", 0, LOG_DAEMON);
+               log_init();
                daemonize();
        }
+#ifndef __MINIOS__
        if (pidfile)
                write_pidfile(pidfile);
-
+#endif
        /* Talloc leak reports go to stderr, which is closed if we fork. */
        if (!dofork)
                talloc_enable_leak_report_full();
@@ -1935,8 +1963,8 @@
                barf_perror("Could not listen on sockets");
 #endif
 
-#ifndef NO_REOPEN_LOG
-       if (pipe(reopen_log_pipe)) {
+#ifndef NO_TRACEFILE
+       if (pipe(reopen_tracefile_pipe)) {
                barf_perror("pipe");
        }
 #endif
@@ -1968,8 +1996,8 @@
                xprintf = trace;
        }
 
-#ifndef NO_REOPEN_LOG
-       signal(SIGHUP, trigger_reopen_log);
+#ifndef NO_TRACEFILE
+       signal(SIGHUP, trigger_reopen_tracefile);
 #endif
 
        if (xce_handle != -1)
@@ -1997,12 +2025,12 @@
                        barf_perror("Select failed");
                }
 
-#ifndef NO_REOPEN_LOG
-               if (FD_ISSET(reopen_log_pipe[0], &inset)) {
+#ifndef NO_TRACEFILE
+               if (FD_ISSET(reopen_tracefile_pipe[0], &inset)) {
                        char c;
-                       if (read(reopen_log_pipe[0], &c, 1) != 1)
+                       if (read(reopen_tracefile_pipe[0], &c, 1) != 1)
                                barf_perror("read failed");
-                       reopen_log();
+                       reopen_tracefile();
                }
 #endif
 
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.