646cd8897b
Updated block-dmmd script - fate#310510 - fix xenpaging restore changes to integrate paging into xm/xend xenpaging.autostart.patch xenpaging.doc.patch - bnc#787163 - VUL-0: CVE-2012-4544: xen: Domain builder Out-of- memory due to malicious kernel/ramdisk (XSA 25) CVE-2012-4544-xsa25.patch - bnc#779212 - VUL-0: CVE-2012-4411: XEN / qemu: guest administrator can access qemu monitor console (XSA-19) CVE-2012-4411-xsa19.patch - bnc#786516 - VUL-0: CVE-2012-4535: xen: Timer overflow DoS vulnerability CVE-2012-4535-xsa20.patch - bnc#786518 - VUL-0: CVE-2012-4536: xen: pirq range check DoS vulnerability CVE-2012-4536-xsa21.patch - bnc#786517 - VUL-0: CVE-2012-4537: xen: Memory mapping failure DoS vulnerability CVE-2012-4537-xsa22.patch - bnc#786519 - VUL-0: CVE-2012-4538: xen: Unhooking empty PAE entries DoS vulnerability CVE-2012-4538-xsa23.patch - bnc#786520 - VUL-0: CVE-2012-4539: xen: Grant table hypercall infinite loop DoS vulnerability CVE-2012-4539-xsa24.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=212
143 lines
4.1 KiB
Diff
143 lines
4.1 KiB
Diff
Add code to support logging xen-domU console, as what xenconsoled does. Log info
|
|
will be saved in /var/log/xen/console/guest-domUname.log.
|
|
|
|
Signed-off-by: Chunyan Liu <cyliu@novell.com>
|
|
---
|
|
hw/xen_console.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
1 files changed, 71 insertions(+), 0 deletions(-)
|
|
|
|
Index: xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c
|
|
===================================================================
|
|
--- xen-4.2.0-testing.orig/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c
|
|
+++ xen-4.2.0-testing/tools/qemu-xen-traditional-dir-remote/hw/xen_console.c
|
|
@@ -38,6 +38,8 @@
|
|
#include "qemu-char.h"
|
|
#include "xen_backend.h"
|
|
|
|
+static int log_guest = 0;
|
|
+
|
|
struct buffer {
|
|
uint8_t *data;
|
|
size_t consumed;
|
|
@@ -54,8 +56,24 @@ struct XenConsole {
|
|
void *sring;
|
|
CharDriverState *chr;
|
|
int backlog;
|
|
+ int log_fd;
|
|
};
|
|
|
|
+static int write_all(int fd, const char* buf, size_t len)
|
|
+{
|
|
+ while (len) {
|
|
+ ssize_t ret = write(fd, buf, len);
|
|
+ if (ret == -1 && errno == EINTR)
|
|
+ continue;
|
|
+ if (ret < 0)
|
|
+ return -1;
|
|
+ len -= ret;
|
|
+ buf += ret;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static void buffer_append(struct XenConsole *con)
|
|
{
|
|
struct buffer *buffer = &con->buffer;
|
|
@@ -83,6 +101,15 @@ static void buffer_append(struct XenCons
|
|
intf->out_cons = cons;
|
|
xen_be_send_notify(&con->xendev);
|
|
|
|
+ if (con->log_fd != -1) {
|
|
+ int logret;
|
|
+ logret = write_all(con->log_fd, buffer->data + buffer->size - size, size);
|
|
+ if (logret < 0) {
|
|
+ xen_be_printf(&con->xendev, 1, "Write to log failed on domain %d: %d (%s)\n",
|
|
+ con->xendev.dom, errno, strerror(errno));
|
|
+ }
|
|
+ }
|
|
+
|
|
if (buffer->max_capacity &&
|
|
buffer->size > buffer->max_capacity) {
|
|
/* Discard the middle of the data. */
|
|
@@ -176,6 +203,37 @@ static void xencons_send(struct XenConso
|
|
}
|
|
}
|
|
|
|
+static int create_domain_log(struct XenConsole *con)
|
|
+{
|
|
+ char *logfile;
|
|
+ char *path, *domname;
|
|
+ int fd;
|
|
+ const char *logdir = "/var/log/xen/console";
|
|
+
|
|
+ path = xs_get_domain_path(xenstore, con->xendev.dom);
|
|
+ domname = xenstore_read_str(path, "name");
|
|
+ free(path);
|
|
+ if (!domname)
|
|
+ return -1;
|
|
+
|
|
+ if (mkdir(logdir, 0755) && errno != EEXIST)
|
|
+ {
|
|
+ xen_be_printf(&con->xendev, 1, "Directory %s does not exist and fail to create it!", logdir);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ if (asprintf(&logfile, "%s/guest-%s.log", logdir, domname) < 0)
|
|
+ return -1;
|
|
+ qemu_free(domname);
|
|
+
|
|
+ fd = open(logfile, O_WRONLY|O_CREAT|O_APPEND, 0644);
|
|
+ free(logfile);
|
|
+ if (fd == -1)
|
|
+ xen_be_printf(&con->xendev, 1, "Failed to open log %s: %d (%s)", logfile, errno, strerror(errno));
|
|
+
|
|
+ return fd;
|
|
+}
|
|
+
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
static int con_init(struct XenDevice *xendev)
|
|
@@ -183,6 +241,7 @@ static int con_init(struct XenDevice *xe
|
|
struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
|
|
char *type, *dom, label[32];
|
|
const char *output;
|
|
+ char *logenv = NULL;
|
|
|
|
/* setup */
|
|
dom = xs_get_domain_path(xenstore, con->xendev.dom);
|
|
@@ -209,6 +268,10 @@ static int con_init(struct XenDevice *xe
|
|
con->chr = qemu_chr_open(label, output, NULL);
|
|
xenstore_store_pv_console_info(con->xendev.dev, con->chr, output);
|
|
|
|
+ logenv = getenv("XENCONSOLED_TRACE");
|
|
+ if (logenv != NULL && strlen(logenv) == strlen("guest") && !strcmp(logenv, "guest")) {
|
|
+ log_guest = 1;
|
|
+ }
|
|
return 0;
|
|
}
|
|
|
|
@@ -246,6 +309,9 @@ static int con_initialise(struct XenDevi
|
|
con->xendev.remote_port,
|
|
con->xendev.local_port,
|
|
con->buffer.max_capacity);
|
|
+ con->log_fd = -1;
|
|
+ if (log_guest)
|
|
+ con->log_fd = create_domain_log(con);
|
|
return 0;
|
|
}
|
|
|
|
@@ -266,6 +332,12 @@ static void con_disconnect(struct XenDev
|
|
xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1);
|
|
con->sring = NULL;
|
|
}
|
|
+
|
|
+ if (con->log_fd != -1) {
|
|
+ close(con->log_fd);
|
|
+ con->log_fd = -1;
|
|
+ }
|
|
+
|
|
}
|
|
|
|
static void con_event(struct XenDevice *xendev)
|