--- loader/Makefile.am | 4 +- loader/init.c | 55 +++++++++++++++++++++++++++++++++++++++++++-------- scripts/mk-images | 1 + 3 files changed, 49 insertions(+), 11 deletions(-) diff --git a/loader/Makefile.am b/loader/Makefile.am index ec65d97..e7532d5 100644 --- a/loader/Makefile.am +++ b/loader/Makefile.am @@ -57,8 +57,8 @@ loader_SOURCES = loader.c copy.c moduleinfo.c loadermisc.c \ rpmextract.c init_CFLAGS = $(COMMON_CFLAGS) $(GLIB_CFLAGS) -init_LDADD = $(GLIB_LIBS) -init_SOURCES = init.c undomounts.c shutdown.c copy.c +init_LDADD = $(GLIB_LIBS) $(top_srcdir)/pyanaconda/isys/libisys.la +init_SOURCES = init.c undomounts.c shutdown.c copy.c modules.c shutdown_CFLAGS = $(COMMON_CFLAGS) -DAS_SHUTDOWN=1 shutdown_SOURCES = shutdown.c undomounts.c diff --git a/loader/init.c b/loader/init.c index 1a38df3..be89b77 100644 --- a/loader/init.c +++ b/loader/init.c @@ -60,6 +60,7 @@ #include "copy.h" #include "devt.h" #include "devices.h" +#include "modules.h" #endif @@ -114,7 +115,7 @@ char * env[] = { void shutDown(int doKill, reboot_action rebootAction); static int getKillPolicy(void); -static void getSyslog(char*); +static void getSyslog(char *, char *); struct termios ts; static int expected_exit = 0; @@ -145,23 +146,45 @@ static void startSyslog(void) { int conf_fd; int ret; char addr[128]; - char forwardtcp[] = "*.* @@"; + char virtiolog[128]; + const char *forward_tcp = "*.* @@"; + const char *forward_format_tcp = "\n"; + const char *forward_virtio = "*.* /dev/virtio-ports/"; + const char *forward_format_virtio = ";virtio_ForwardFormat\n"; /* update the config file with command line arguments first */ - getSyslog(addr); - if (strlen(addr) > 0) { + getSyslog(addr, virtiolog); + if (strlen(addr) > 0 || strlen(virtiolog) > 0) { conf_fd = open("/etc/rsyslog.conf", O_WRONLY|O_APPEND); if (conf_fd < 0) { printf("error opening /etc/rsyslog.conf: %d\n", errno); printf("syslog forwarding will not be enabled\n"); sleep(5); } else { - ret = write(conf_fd, forwardtcp, strlen(forwardtcp)); - ret = write(conf_fd, addr, strlen(addr)); - ret = write(conf_fd, "\n", 1); + if (strlen(addr) > 0) { + ret = write(conf_fd, forward_tcp, strlen(forward_tcp)); + ret = write(conf_fd, addr, strlen(addr)); + ret = write(conf_fd, forward_format_tcp, strlen(forward_format_tcp)); + } + if (strlen(virtiolog) > 0) { + ret = write(conf_fd, forward_virtio, strlen(forward_virtio)); + ret = write(conf_fd, virtiolog, strlen(virtiolog)); + ret = write(conf_fd, forward_format_virtio, strlen(forward_format_virtio)); + } close(conf_fd); } } + + if (strlen(virtiolog)) { + printf("Loading virtio_pci module... "); + if (mlLoadModule("virtio_pci", NULL)) { + printf("Error loading virtio_pci module. "); + printf("Virtio logging will not work.\n."); + sleep(5); + } else { + printf("done.\n"); + } + } /* rsyslog is going to take care of things, so disable console logging */ klogctl(8, NULL, 1); @@ -318,13 +341,14 @@ static int getKillPolicy(void) { } /* Looks through /proc/cmdline for remote syslog paramters. */ -static void getSyslog(char *addr) { +static void getSyslog(char *addr, char *virtiolog) { int fd; int len; char buf[1024]; /* assume nothing gets found */ addr[0] = '\0'; + virtiolog[0] = '\0'; if ((fd = open("/proc/cmdline", O_RDONLY,0)) <= 0) { return; } @@ -346,7 +370,12 @@ static void getSyslog(char *addr) { if (!strncmp(argv[i], "syslog=", 7)) { strncpy(addr, argv[i] + 7, 127); addr[127] = '\0'; - break; + continue; + } + if (!strncmp(argv[i], "virtiolog=", 10)) { + strncpy(virtiolog, argv[i] + 10, 127); + virtiolog[127] = '\0'; + continue; } } g_strfreev(argv); @@ -362,6 +391,14 @@ static void getSyslog(char *addr) { sleep(5); } + /* virtiolog can only be letters and digits, dots, dashes and underscores */ + if (!g_regex_match_simple("^[\\w.-_]*$", addr, 0, 0)) { + /* the parameter is malformed, disable its use */ + virtiolog[0] = '\0'; + printf("The virtiolog= command line parameter is malformed and will\n"); + printf("be ignored by the installer.\n"); + sleep(5); + } } static int getInitPid(void) { diff --git a/scripts/mk-images b/scripts/mk-images index 1125c9b..d263b25 100755 --- a/scripts/mk-images +++ b/scripts/mk-images @@ -812,6 +812,7 @@ $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat $template anaconda_tty4, "%syslogseverity-text:::uppercase% %programname%:%msg%\n" $template anaconda_syslog, "%timestamp:8:$:date-rfc3164%,%timestamp:1:3:date-subseconds% %syslogseverity-text:::uppercase% %programname%:%msg%\n" +$template virtio_ForwardFormat, "<%PRI%>%TIMESTAMP:::date-rfc3339% %syslogtag:1:32%%msg:::sp-if-no-1st-sp%%msg%" #### RULES #### # log everything except anaconda-specific records from local1 (those are stored -- 1.7.1.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list