[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3/3] qemu-xen: fixes to support the console based save/restore
The PV console backend for stubdoms is qemu-xen in dom0; we need to make sure it is able to support read/write to a file as console input/output. Unfortunately the current file: "char device" only opens the file O_WRONLY, so this patch adds a new "char device" called filerw: that opens the file O_RDWR. We need to issue reads with the exact number of bytes to read the qemu-xen save file, and to do that this patch disables buffering on all the savevm reads/writes for stubdoms. Finally this patch fixes a bug in the xen_console disconnect handler that causes qemu-xen to segfaults. Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx> diff --git a/hw/xen_console.c b/hw/xen_console.c index d7099c4..0a2374c 100644 --- a/hw/xen_console.c +++ b/hw/xen_console.c @@ -258,7 +258,7 @@ static void con_disconnect(struct XenDevice *xendev) xen_be_unbind_evtchn(&con->xendev); if (con->sring) { - if (!xendev->gnttabdev) + if (!xendev->dev) munmap(con->sring, XC_PAGE_SIZE); else xc_gnttab_munmap(xendev->gnttabdev, con->sring, 1); diff --git a/qemu-char.c b/qemu-char.c index 7a6a33d..22acfe6 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -594,6 +594,16 @@ static CharDriverState *qemu_chr_open_file_out(const char *file_out) return qemu_chr_open_fd(-1, fd_out); } +static CharDriverState *qemu_chr_open_file_rw(const char *file_rw) +{ + int fd_rw; + + TFR(fd_rw = open(file_rw, O_RDWR | O_CREAT | O_BINARY, 0666)); + if (fd_rw < 0) + return NULL; + return qemu_chr_open_fd(fd_rw, fd_rw); +} + static CharDriverState *qemu_chr_open_pipe(const char *filename) { int fd_in, fd_out; @@ -2164,6 +2174,8 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i chr = qemu_chr_open_tcp(p, 0, 1); } else if (strstart(filename, "file:", &p)) { chr = qemu_chr_open_file_out(p); + } else if (strstart(filename, "filerw:", &p)) { + chr = qemu_chr_open_file_rw(p); } else if (strstart(filename, "pipe:", &p)) { chr = qemu_chr_open_pipe(p); } else if (!strcmp(filename, "pty")) { diff --git a/savevm.c b/savevm.c index b66f7e2..71a57eb 100644 --- a/savevm.c +++ b/savevm.c @@ -133,7 +133,13 @@ void qemu_announce_self(void) /***********************************************************/ /* savevm/loadvm support */ +#ifdef CONFIG_STUBDOM +/* disable buffering for stubdoms because we need to issue reads for the + * exact number of bytes */ +#define IO_BUF_SIZE 1 +#else #define IO_BUF_SIZE 32768 +#endif struct QEMUFile { QEMUFilePutBufferFunc *put_buffer; @@ -303,6 +309,10 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode) if (!s->outfile) goto fail; +#ifdef CONFIG_STUBDOM + setvbuf(s->outfile, NULL, _IONBF, 0); +#endif + if (!strcmp(mode, "wb")) return qemu_fopen_ops(s, file_put_buffer, NULL, file_close, NULL); else if (!strcmp(mode, "rb")) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |