* [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu @ 2009-01-13 15:37 Christian Ehrhardt 2009-01-13 15:37 ` [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support Christian Ehrhardt ` (5 more replies) 0 siblings, 6 replies; 16+ messages in thread From: Christian Ehrhardt @ 2009-01-13 15:37 UTC (permalink / raw) To: aliguori; +Cc: ehrhardt, qemu-devel, borntraeger To complete qemu virtio device support this patch series add virtio-console infrastructure to qemu in patch 1/2. Patch 3/4 initializes virtio-console on the tested architectures x86 and powerpc. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support 2009-01-13 15:37 [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Christian Ehrhardt @ 2009-01-13 15:37 ` Christian Ehrhardt 2009-01-15 19:55 ` Anthony Liguori 2009-01-19 10:09 ` Mark McLoughlin 2009-01-13 15:37 ` [Qemu-devel] [PATCH 2 of 4] kvm-userpace: add virtio-console cmdline option Christian Ehrhardt ` (4 subsequent siblings) 5 siblings, 2 replies; 16+ messages in thread From: Christian Ehrhardt @ 2009-01-13 15:37 UTC (permalink / raw) To: aliguori; +Cc: ehrhardt, qemu-devel, borntraeger # HG changeset patch # User Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> # Date 1231855865 -3600 # Node ID 50f40bc14f793a5f4ce6d91c36a3f3b19b507d42 # Parent 89ed96e77993639b89d41a1a113ccbef979adfb9 kvm-userpace: add virtio-console support This patch adds the virtio console to qemu. This console can be found after the serial and parallel outputs as another virtual console. In the -nographic case it is redirected to the null output by default. Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> --- Makefile.target | 2 hw/virtio-console.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-console.h | 22 +++++++ sysemu.h | 6 ++ vl.c | 26 +++++++++ 5 files changed, 202 insertions(+), 1 deletion(-) diff --git a/Makefile.target b/Makefile.target --- a/Makefile.target +++ b/Makefile.target @@ -559,7 +559,7 @@ OBJS=vl.o osdep.o monitor.o pci.o loader OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o # virtio has to be here due to weird dependency between PCI and virtio-net. # need to fix this properly -OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o +OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o OBJS+=fw_cfg.o ifdef CONFIG_KVM OBJS+=kvm.o kvm-all.o diff --git a/hw/virtio-console.c b/hw/virtio-console.c new file mode 100644 --- /dev/null +++ b/hw/virtio-console.c @@ -0,0 +1,147 @@ +/* + * Virtio Console Device + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ + +#include "hw.h" +#include "qemu-char.h" +#include "virtio.h" +#include "virtio-console.h" + + +typedef struct VirtIOConsole +{ + VirtIODevice vdev; + VirtQueue *ivq, *dvq; + CharDriverState *chr; +} VirtIOConsole; + +static VirtIOConsole *to_virtio_console(VirtIODevice *vdev) +{ + return (VirtIOConsole *)vdev; +} + +static void virtio_console_handle_output(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIOConsole *s = to_virtio_console(vdev); + VirtQueueElement elem; + + while (virtqueue_pop(vq, &elem)) { + ssize_t len = 0; + int d; + + for (d=0; d < elem.out_num; d++) + len += qemu_chr_write(s->chr, elem.out_sg[d].iov_base,elem.out_sg[d].iov_len); + virtqueue_push(vq, &elem, len); + virtio_notify(vdev, vq); + } +} + +static void virtio_console_handle_input(VirtIODevice *vdev, VirtQueue *vq) +{ +} + +static uint32_t virtio_console_get_features(VirtIODevice *vdev) +{ + return 0; +} + +static int vcon_can_read(void *opaque) +{ + VirtIOConsole *s = (VirtIOConsole *) opaque; + + if (!virtio_queue_ready(s->ivq) || + !(s->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) || + virtio_queue_empty(s->ivq)) + return 0; + + /* current implementations have a page sized buffer. + * We fall back to a one byte per read if there is not enough room. + * It would be cool to have a function that returns the available byte + * instead of checking for a limit */ + if (virtqueue_avail_bytes(s->ivq, TARGET_PAGE_SIZE, 0)) + return TARGET_PAGE_SIZE; + if (virtqueue_avail_bytes(s->ivq, 1, 0)) + return 1; + return 0; +} + +static void vcon_read(void *opaque, const uint8_t *buf, int size) +{ + VirtIOConsole *s = (VirtIOConsole *) opaque; + VirtQueueElement elem; + int offset = 0; + + /* The current kernel implementation has only one outstanding input + * buffer of PAGE_SIZE. Nevertheless, this function is prepared to + * handle multiple buffers with multiple sg element for input */ + while (offset < size) { + int i = 0; + if (!virtqueue_pop(s->ivq, &elem)) + break; + while (offset < size && i < elem.in_num) { + int len = MIN(elem.in_sg[i].iov_len, size - offset); + memcpy(elem.in_sg[i].iov_base, buf + offset, len); + offset += len; + i++; + } + virtqueue_push(s->ivq, &elem, size); + } + virtio_notify(&s->vdev, s->ivq); +} + +static void vcon_event(void *opaque, int event) +{ + /* we will ignore any event for the time being */ +} + +static void virtio_console_save(QEMUFile *f, void *opaque) +{ + VirtIOConsole *s = opaque; + + virtio_save(&s->vdev, f); +} + +static int virtio_console_load(QEMUFile *f, void *opaque, int version_id) +{ + VirtIOConsole *s = opaque; + + if (version_id != 1) + return -EINVAL; + + virtio_load(&s->vdev, f); + return 0; +} + +void *virtio_console_init(PCIBus *bus, CharDriverState *chr) +{ + VirtIOConsole *s; + + s = (VirtIOConsole *)virtio_init_pci(bus, "virtio-console", + 6900, 0x1003, + 0, VIRTIO_ID_CONSOLE, + 0x03, 0x80, 0x00, + 0, sizeof(VirtIOConsole)); + if (s == NULL) + return NULL; + + s->vdev.get_features = virtio_console_get_features; + + s->ivq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_input); + s->dvq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_output); + + s->chr = chr; + qemu_chr_add_handlers(chr, vcon_can_read, vcon_read, vcon_event, s); + + register_savevm("virtio-console", -1, 1, virtio_console_save, virtio_console_load, s); + + return &s->vdev; +} diff --git a/hw/virtio-console.h b/hw/virtio-console.h new file mode 100644 --- /dev/null +++ b/hw/virtio-console.h @@ -0,0 +1,22 @@ +/* + * Virtio Console Support + * + * Copyright IBM, Corp. 2008 + * + * Authors: + * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + * + */ +#ifndef _QEMU_VIRTIO_CONSOLE_H +#define _QEMU_VIRTIO_CONSOLE_H + +/* The ID for virtio console */ +#define VIRTIO_ID_CONSOLE 3 + +/* Creates a virtio console */ +void *virtio_console_init(PCIBus *bus, CharDriverState *chr); + +#endif diff --git a/sysemu.h b/sysemu.h --- a/sysemu.h +++ b/sysemu.h @@ -158,6 +158,12 @@ extern CharDriverState *serial_hds[MAX_S extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; +/* virtio consoles */ + +#define MAX_VIRTIO_CONSOLES 1 + +extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; + #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) #ifdef NEED_CPU_H diff --git a/vl.c b/vl.c --- a/vl.c +++ b/vl.c @@ -209,6 +209,7 @@ int no_quit = 0; int no_quit = 0; CharDriverState *serial_hds[MAX_SERIAL_PORTS]; CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; +CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; #ifdef TARGET_I386 int win2k_install_hack = 0; #endif @@ -4502,6 +4503,8 @@ int main(int argc, char **argv, char **e int serial_device_index; const char *parallel_devices[MAX_PARALLEL_PORTS]; int parallel_device_index; + const char *virtio_consoles[MAX_VIRTIO_CONSOLES]; + int virtio_console_index; const char *loadvm = NULL; QEMUMachine *machine; const char *cpu_model; @@ -4574,6 +4577,11 @@ int main(int argc, char **argv, char **e for(i = 1; i < MAX_PARALLEL_PORTS; i++) parallel_devices[i] = NULL; parallel_device_index = 0; + + virtio_consoles[0] = "vc:80Cx24C"; + for(i = 1; i < MAX_VIRTIO_CONSOLES; i++) + virtio_consoles[i] = NULL; + virtio_console_index = 0; usb_devices_index = 0; @@ -5170,6 +5178,8 @@ int main(int argc, char **argv, char **e parallel_devices[0] = "null"; if (strncmp(monitor_device, "vc", 2) == 0) monitor_device = "stdio"; + if (virtio_console_index == 0) + virtio_consoles[0] = "null"; } #ifndef _WIN32 @@ -5464,6 +5474,22 @@ int main(int argc, char **argv, char **e } } + for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { + const char *devname = virtio_consoles[i]; + if (devname && strcmp(devname, "none")) { + char label[32]; + snprintf(label, sizeof(label), "virtcon%d", i); + virtcon_hds[i] = qemu_chr_open(label, devname); + if (!virtcon_hds[i]) { + fprintf(stderr, "qemu: could not open virtio console '%s'\n", + devname); + exit(1); + } + if (strstart(devname, "vc", 0)) + qemu_chr_printf(virtcon_hds[i], "virtio console%d\r\n", i); + } + } + if (kvm_enabled()) { int ret; ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support 2009-01-13 15:37 ` [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support Christian Ehrhardt @ 2009-01-15 19:55 ` Anthony Liguori 2009-01-19 10:09 ` Mark McLoughlin 1 sibling, 0 replies; 16+ messages in thread From: Anthony Liguori @ 2009-01-15 19:55 UTC (permalink / raw) To: qemu-devel; +Cc: ehrhardt, aliguori, borntraeger Christian Ehrhardt wrote: > # HG changeset patch > # User Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> > # Date 1231855865 -3600 > # Node ID 50f40bc14f793a5f4ce6d91c36a3f3b19b507d42 > # Parent 89ed96e77993639b89d41a1a113ccbef979adfb9 > kvm-userpace: add virtio-console support > > This patch adds the virtio console to qemu. This console can be found after the > serial and parallel outputs as another virtual console. In the -nographic case > it is redirected to the null output by default. > > Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> > Please submit this against QEMU, not kvm-userspace. Regards, Anthony Liguori > --- > Makefile.target | 2 > hw/virtio-console.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > hw/virtio-console.h | 22 +++++++ > sysemu.h | 6 ++ > vl.c | 26 +++++++++ > 5 files changed, 202 insertions(+), 1 deletion(-) > > diff --git a/Makefile.target b/Makefile.target > --- a/Makefile.target > +++ b/Makefile.target > @@ -559,7 +559,7 @@ OBJS=vl.o osdep.o monitor.o pci.o loader > OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o > # virtio has to be here due to weird dependency between PCI and virtio-net. > # need to fix this properly > -OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o > +OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o > OBJS+=fw_cfg.o > ifdef CONFIG_KVM > OBJS+=kvm.o kvm-all.o > diff --git a/hw/virtio-console.c b/hw/virtio-console.c > new file mode 100644 > --- /dev/null > +++ b/hw/virtio-console.c > @@ -0,0 +1,147 @@ > +/* > + * Virtio Console Device > + * > + * Copyright IBM, Corp. 2008 > + * > + * Authors: > + * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + */ > + > +#include "hw.h" > +#include "qemu-char.h" > +#include "virtio.h" > +#include "virtio-console.h" > + > + > +typedef struct VirtIOConsole > +{ > + VirtIODevice vdev; > + VirtQueue *ivq, *dvq; > + CharDriverState *chr; > +} VirtIOConsole; > + > +static VirtIOConsole *to_virtio_console(VirtIODevice *vdev) > +{ > + return (VirtIOConsole *)vdev; > +} > + > +static void virtio_console_handle_output(VirtIODevice *vdev, VirtQueue *vq) > +{ > + VirtIOConsole *s = to_virtio_console(vdev); > + VirtQueueElement elem; > + > + while (virtqueue_pop(vq, &elem)) { > + ssize_t len = 0; > + int d; > + > + for (d=0; d < elem.out_num; d++) > + len += qemu_chr_write(s->chr, elem.out_sg[d].iov_base,elem.out_sg[d].iov_len); > + virtqueue_push(vq, &elem, len); > + virtio_notify(vdev, vq); > + } > +} > + > +static void virtio_console_handle_input(VirtIODevice *vdev, VirtQueue *vq) > +{ > +} > + > +static uint32_t virtio_console_get_features(VirtIODevice *vdev) > +{ > + return 0; > +} > + > +static int vcon_can_read(void *opaque) > +{ > + VirtIOConsole *s = (VirtIOConsole *) opaque; > + > + if (!virtio_queue_ready(s->ivq) || > + !(s->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) || > + virtio_queue_empty(s->ivq)) > + return 0; > + > + /* current implementations have a page sized buffer. > + * We fall back to a one byte per read if there is not enough room. > + * It would be cool to have a function that returns the available byte > + * instead of checking for a limit */ > + if (virtqueue_avail_bytes(s->ivq, TARGET_PAGE_SIZE, 0)) > + return TARGET_PAGE_SIZE; > + if (virtqueue_avail_bytes(s->ivq, 1, 0)) > + return 1; > + return 0; > +} > + > +static void vcon_read(void *opaque, const uint8_t *buf, int size) > +{ > + VirtIOConsole *s = (VirtIOConsole *) opaque; > + VirtQueueElement elem; > + int offset = 0; > + > + /* The current kernel implementation has only one outstanding input > + * buffer of PAGE_SIZE. Nevertheless, this function is prepared to > + * handle multiple buffers with multiple sg element for input */ > + while (offset < size) { > + int i = 0; > + if (!virtqueue_pop(s->ivq, &elem)) > + break; > + while (offset < size && i < elem.in_num) { > + int len = MIN(elem.in_sg[i].iov_len, size - offset); > + memcpy(elem.in_sg[i].iov_base, buf + offset, len); > + offset += len; > + i++; > + } > + virtqueue_push(s->ivq, &elem, size); > + } > + virtio_notify(&s->vdev, s->ivq); > +} > + > +static void vcon_event(void *opaque, int event) > +{ > + /* we will ignore any event for the time being */ > +} > + > +static void virtio_console_save(QEMUFile *f, void *opaque) > +{ > + VirtIOConsole *s = opaque; > + > + virtio_save(&s->vdev, f); > +} > + > +static int virtio_console_load(QEMUFile *f, void *opaque, int version_id) > +{ > + VirtIOConsole *s = opaque; > + > + if (version_id != 1) > + return -EINVAL; > + > + virtio_load(&s->vdev, f); > + return 0; > +} > + > +void *virtio_console_init(PCIBus *bus, CharDriverState *chr) > +{ > + VirtIOConsole *s; > + > + s = (VirtIOConsole *)virtio_init_pci(bus, "virtio-console", > + 6900, 0x1003, > + 0, VIRTIO_ID_CONSOLE, > + 0x03, 0x80, 0x00, > + 0, sizeof(VirtIOConsole)); > + if (s == NULL) > + return NULL; > + > + s->vdev.get_features = virtio_console_get_features; > + > + s->ivq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_input); > + s->dvq = virtio_add_queue(&s->vdev, 128, virtio_console_handle_output); > + > + s->chr = chr; > + qemu_chr_add_handlers(chr, vcon_can_read, vcon_read, vcon_event, s); > + > + register_savevm("virtio-console", -1, 1, virtio_console_save, virtio_console_load, s); > + > + return &s->vdev; > +} > diff --git a/hw/virtio-console.h b/hw/virtio-console.h > new file mode 100644 > --- /dev/null > +++ b/hw/virtio-console.h > @@ -0,0 +1,22 @@ > +/* > + * Virtio Console Support > + * > + * Copyright IBM, Corp. 2008 > + * > + * Authors: > + * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> > + * > + * This work is licensed under the terms of the GNU GPL, version 2. See > + * the COPYING file in the top-level directory. > + * > + */ > +#ifndef _QEMU_VIRTIO_CONSOLE_H > +#define _QEMU_VIRTIO_CONSOLE_H > + > +/* The ID for virtio console */ > +#define VIRTIO_ID_CONSOLE 3 > + > +/* Creates a virtio console */ > +void *virtio_console_init(PCIBus *bus, CharDriverState *chr); > + > +#endif > diff --git a/sysemu.h b/sysemu.h > --- a/sysemu.h > +++ b/sysemu.h > @@ -158,6 +158,12 @@ extern CharDriverState *serial_hds[MAX_S > > extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; > > +/* virtio consoles */ > + > +#define MAX_VIRTIO_CONSOLES 1 > + > +extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; > + > #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) > > #ifdef NEED_CPU_H > diff --git a/vl.c b/vl.c > --- a/vl.c > +++ b/vl.c > @@ -209,6 +209,7 @@ int no_quit = 0; > int no_quit = 0; > CharDriverState *serial_hds[MAX_SERIAL_PORTS]; > CharDriverState *parallel_hds[MAX_PARALLEL_PORTS]; > +CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES]; > #ifdef TARGET_I386 > int win2k_install_hack = 0; > #endif > @@ -4502,6 +4503,8 @@ int main(int argc, char **argv, char **e > int serial_device_index; > const char *parallel_devices[MAX_PARALLEL_PORTS]; > int parallel_device_index; > + const char *virtio_consoles[MAX_VIRTIO_CONSOLES]; > + int virtio_console_index; > const char *loadvm = NULL; > QEMUMachine *machine; > const char *cpu_model; > @@ -4574,6 +4577,11 @@ int main(int argc, char **argv, char **e > for(i = 1; i < MAX_PARALLEL_PORTS; i++) > parallel_devices[i] = NULL; > parallel_device_index = 0; > + > + virtio_consoles[0] = "vc:80Cx24C"; > + for(i = 1; i < MAX_VIRTIO_CONSOLES; i++) > + virtio_consoles[i] = NULL; > + virtio_console_index = 0; > > usb_devices_index = 0; > > @@ -5170,6 +5178,8 @@ int main(int argc, char **argv, char **e > parallel_devices[0] = "null"; > if (strncmp(monitor_device, "vc", 2) == 0) > monitor_device = "stdio"; > + if (virtio_console_index == 0) > + virtio_consoles[0] = "null"; > } > > #ifndef _WIN32 > @@ -5464,6 +5474,22 @@ int main(int argc, char **argv, char **e > } > } > > + for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { > + const char *devname = virtio_consoles[i]; > + if (devname && strcmp(devname, "none")) { > + char label[32]; > + snprintf(label, sizeof(label), "virtcon%d", i); > + virtcon_hds[i] = qemu_chr_open(label, devname); > + if (!virtcon_hds[i]) { > + fprintf(stderr, "qemu: could not open virtio console '%s'\n", > + devname); > + exit(1); > + } > + if (strstart(devname, "vc", 0)) > + qemu_chr_printf(virtcon_hds[i], "virtio console%d\r\n", i); > + } > + } > + > if (kvm_enabled()) { > int ret; > > > > ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support 2009-01-13 15:37 ` [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support Christian Ehrhardt 2009-01-15 19:55 ` Anthony Liguori @ 2009-01-19 10:09 ` Mark McLoughlin 1 sibling, 0 replies; 16+ messages in thread From: Mark McLoughlin @ 2009-01-19 10:09 UTC (permalink / raw) To: qemu-devel; +Cc: ehrhardt, aliguori, borntraeger On Tue, 2009-01-13 at 16:37 +0100, Christian Ehrhardt wrote: > + virtio_consoles[0] = "vc:80Cx24C"; > + for(i = 1; i < MAX_VIRTIO_CONSOLES; i++) > + virtio_consoles[i] = NULL; > + virtio_console_index = 0; Hmm, why do we have virtio console enabled by default on x86? Does it make sense for it to only be available if it's explicitly configured, except for platforms that don't have serial? There's a good chance this is going to confuse the hell out of Fedora's installer, for example. And how does the likes of "virsh console" know to connect to the virtio console rather than the serial console? Cheers, Mark. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 2 of 4] kvm-userpace: add virtio-console cmdline option 2009-01-13 15:37 [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Christian Ehrhardt 2009-01-13 15:37 ` [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support Christian Ehrhardt @ 2009-01-13 15:37 ` Christian Ehrhardt 2009-01-19 10:11 ` Mark McLoughlin 2009-01-13 15:37 ` [Qemu-devel] [PATCH 3 of 4] kvm-userpace: add virtio-console initializer for x86 Christian Ehrhardt ` (3 subsequent siblings) 5 siblings, 1 reply; 16+ messages in thread From: Christian Ehrhardt @ 2009-01-13 15:37 UTC (permalink / raw) To: aliguori; +Cc: ehrhardt, qemu-devel, borntraeger # HG changeset patch # User Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> # Date 1231855940 -3600 # Node ID fe40d92b5aea81b22c493e23ca5dc53a1b514c9a # Parent 50f40bc14f793a5f4ce6d91c36a3f3b19b507d42 kvm-userpace: add virtio-console cmdline option This patch adds the typical qemu console command line switch to the virtio console. using -virtioconsole ARG it can now be specified what output a guest hvc should be redirected to. Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> --- vl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c --- a/vl.c +++ b/vl.c @@ -4062,6 +4062,7 @@ enum { QEMU_OPTION_echr, QEMU_OPTION_monitor, QEMU_OPTION_serial, + QEMU_OPTION_virtiocon, QEMU_OPTION_parallel, QEMU_OPTION_loadvm, QEMU_OPTION_full_screen, @@ -4171,6 +4172,7 @@ static const QEMUOption qemu_options[] = { "echr", HAS_ARG, QEMU_OPTION_echr }, { "monitor", HAS_ARG, QEMU_OPTION_monitor }, { "serial", HAS_ARG, QEMU_OPTION_serial }, + { "virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon }, { "parallel", HAS_ARG, QEMU_OPTION_parallel }, { "loadvm", HAS_ARG, QEMU_OPTION_loadvm }, { "full-screen", 0, QEMU_OPTION_full_screen }, @@ -4968,6 +4970,14 @@ int main(int argc, char **argv, char **e } serial_devices[serial_device_index] = optarg; serial_device_index++; + break; + case QEMU_OPTION_virtiocon: + if (virtio_console_index >= MAX_VIRTIO_CONSOLES) { + fprintf(stderr, "qemu: too many virtio consoles\n"); + exit(1); + } + virtio_consoles[virtio_console_index] = optarg; + virtio_console_index++; break; case QEMU_OPTION_parallel: if (parallel_device_index >= MAX_PARALLEL_PORTS) { ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 2 of 4] kvm-userpace: add virtio-console cmdline option 2009-01-13 15:37 ` [Qemu-devel] [PATCH 2 of 4] kvm-userpace: add virtio-console cmdline option Christian Ehrhardt @ 2009-01-19 10:11 ` Mark McLoughlin 0 siblings, 0 replies; 16+ messages in thread From: Mark McLoughlin @ 2009-01-19 10:11 UTC (permalink / raw) To: Christian Borntraeger; +Cc: ehrhardt, aliguori, qemu-devel Hi Christian, On Tue, 2009-01-13 at 16:37 +0100, Christian Ehrhardt wrote: > kvm-userpace: add virtio-console cmdline option > > This patch adds the typical qemu console command line switch to the virtio > console. using -virtioconsole ARG it can now be specified what output a guest > hvc should be redirected to. Could you add some documentation for this to the -help output and the man page? Thanks, Mark. ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 3 of 4] kvm-userpace: add virtio-console initializer for x86 2009-01-13 15:37 [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Christian Ehrhardt 2009-01-13 15:37 ` [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support Christian Ehrhardt 2009-01-13 15:37 ` [Qemu-devel] [PATCH 2 of 4] kvm-userpace: add virtio-console cmdline option Christian Ehrhardt @ 2009-01-13 15:37 ` Christian Ehrhardt 2009-01-13 15:37 ` [Qemu-devel] [PATCH 4 of 4] kvm-userpace: add virtio-console initializer for powerpc Christian Ehrhardt ` (2 subsequent siblings) 5 siblings, 0 replies; 16+ messages in thread From: Christian Ehrhardt @ 2009-01-13 15:37 UTC (permalink / raw) To: aliguori; +Cc: ehrhardt, qemu-devel, borntraeger # HG changeset patch # User Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> # Date 1231856025 -3600 # Node ID 75e548434dfe284787222f10704987f202c3e5ee # Parent fe40d92b5aea81b22c493e23ca5dc53a1b514c9a kvm-userpace: add virtio-console initializer for x86 This adds an intialization of virtio console for pc style hardware. Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> --- pc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/pc.c b/hw/pc.c --- a/hw/pc.c +++ b/hw/pc.c @@ -35,6 +35,7 @@ #include "fw_cfg.h" #include "virtio-blk.h" #include "virtio-balloon.h" +#include "virtio-console.h" #include "hpet_emul.h" /* output Bochs bios info messages */ @@ -1113,6 +1114,14 @@ static void pc_init1(ram_addr_t ram_size /* Add virtio balloon device */ if (pci_enabled) virtio_balloon_init(pci_bus); + + /* Add virtio console devices */ + if (pci_enabled) { + for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { + if (virtcon_hds[i]) + virtio_console_init(pci_bus, virtcon_hds[i]); + } + } } static void pc_init_pci(ram_addr_t ram_size, int vga_ram_size, ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 4 of 4] kvm-userpace: add virtio-console initializer for powerpc 2009-01-13 15:37 [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Christian Ehrhardt ` (2 preceding siblings ...) 2009-01-13 15:37 ` [Qemu-devel] [PATCH 3 of 4] kvm-userpace: add virtio-console initializer for x86 Christian Ehrhardt @ 2009-01-13 15:37 ` Christian Ehrhardt 2009-01-13 20:27 ` [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Avi Kivity 2009-01-15 20:08 ` Anthony Liguori 5 siblings, 0 replies; 16+ messages in thread From: Christian Ehrhardt @ 2009-01-13 15:37 UTC (permalink / raw) To: aliguori; +Cc: ehrhardt, qemu-devel, borntraeger # HG changeset patch # User Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> # Date 1231856031 -3600 # Node ID e07b13e46e0f33cf337fa24b9ab619718cbc2a38 # Parent 75e548434dfe284787222f10704987f202c3e5ee kvm-userpace: add virtio-console initializer for powerpc This adds an intialization of virtio console for powerpc. Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> --- ppc440_bamboo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/ppc440_bamboo.c b/hw/ppc440_bamboo.c --- a/hw/ppc440_bamboo.c +++ b/hw/ppc440_bamboo.c @@ -17,6 +17,7 @@ #include "hw.h" #include "pci.h" #include "virtio-blk.h" +#include "virtio-console.h" #include "boards.h" #include "sysemu.h" #include "ppc440.h" @@ -116,6 +117,12 @@ static void bamboo_init(ram_addr_t ram_s unit_id++; } + /* Add virtio console devices */ + for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { + if (virtcon_hds[i]) + virtio_console_init(pcibus, virtcon_hds[i]); + } + /* Register network interfaces. */ for (i = 0; i < nb_nics; i++) { nd = &nd_table[i]; ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 15:37 [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Christian Ehrhardt ` (3 preceding siblings ...) 2009-01-13 15:37 ` [Qemu-devel] [PATCH 4 of 4] kvm-userpace: add virtio-console initializer for powerpc Christian Ehrhardt @ 2009-01-13 20:27 ` Avi Kivity 2009-01-13 20:34 ` Anthony Liguori 2009-01-13 20:41 ` Christian Borntraeger 2009-01-15 20:08 ` Anthony Liguori 5 siblings, 2 replies; 16+ messages in thread From: Avi Kivity @ 2009-01-13 20:27 UTC (permalink / raw) To: qemu-devel; +Cc: ehrhardt, aliguori, borntraeger Christian Ehrhardt wrote: > To complete qemu virtio device support this patch series add virtio-console > infrastructure to qemu in patch 1/2. > Patch 3/4 initializes virtio-console on the tested architectures x86 and > powerpc. > What is the advantage of virtio-console, compared to the standard serial port? -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 20:27 ` [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Avi Kivity @ 2009-01-13 20:34 ` Anthony Liguori 2009-01-13 20:39 ` Avi Kivity 2009-01-13 20:41 ` Christian Borntraeger 1 sibling, 1 reply; 16+ messages in thread From: Anthony Liguori @ 2009-01-13 20:34 UTC (permalink / raw) To: Avi Kivity; +Cc: ehrhardt, qemu-devel, borntraeger Avi Kivity wrote: > Christian Ehrhardt wrote: >> To complete qemu virtio device support this patch series add >> virtio-console >> infrastructure to qemu in patch 1/2. >> Patch 3/4 initializes virtio-console on the tested architectures x86 and >> powerpc. >> > > What is the advantage of virtio-console, compared to the standard > serial port? Certain platforms have instructions for anything you can think of but no uart. Regards, Anthony Liguori ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 20:34 ` Anthony Liguori @ 2009-01-13 20:39 ` Avi Kivity 2009-01-13 20:44 ` Anthony Liguori 0 siblings, 1 reply; 16+ messages in thread From: Avi Kivity @ 2009-01-13 20:39 UTC (permalink / raw) To: Anthony Liguori; +Cc: ehrhardt, qemu-devel, borntraeger Anthony Liguori wrote: >> What is the advantage of virtio-console, compared to the standard >> serial port? > > Certain platforms have instructions for anything you can think of but > no uart. Wouldn't these platforms want to emulate their native console, whatever that looks like? That might be extra handy if they have some virtualization heritage. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 20:39 ` Avi Kivity @ 2009-01-13 20:44 ` Anthony Liguori 0 siblings, 0 replies; 16+ messages in thread From: Anthony Liguori @ 2009-01-13 20:44 UTC (permalink / raw) To: Avi Kivity; +Cc: ehrhardt, qemu-devel, borntraeger Avi Kivity wrote: > Anthony Liguori wrote: >>> What is the advantage of virtio-console, compared to the standard >>> serial port? >> >> Certain platforms have instructions for anything you can think of but >> no uart. > > Wouldn't these platforms want to emulate their native console, > whatever that looks like? That might be extra handy if they have some > virtualization heritage. I'm pretty sure the native console is 3270. I suspect that would be something that would be nice to move away from :-) Regards, Anthony Liguori ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 20:27 ` [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Avi Kivity 2009-01-13 20:34 ` Anthony Liguori @ 2009-01-13 20:41 ` Christian Borntraeger 2009-01-13 20:58 ` Avi Kivity 2009-01-13 21:00 ` Avi Kivity 1 sibling, 2 replies; 16+ messages in thread From: Christian Borntraeger @ 2009-01-13 20:41 UTC (permalink / raw) To: Avi Kivity; +Cc: ehrhardt, aliguori, qemu-devel Am Dienstag 13 Januar 2009 schrieb Avi Kivity: > Christian Ehrhardt wrote: > > To complete qemu virtio device support this patch series add virtio-console > > infrastructure to qemu in patch 1/2. > > Patch 3/4 initializes virtio-console on the tested architectures x86 and > > powerpc. > > > > What is the advantage of virtio-console, compared to the standard serial > port? I cannot talk about the qemu version, but looking at kuli (the experimental kvm userspace for s390) these things come into my mind: - it is not limited to to serial speed settings (9600..115200 etc.) - the kernel driver of virtio_console has console resizing support. Adding resize support into qemu should be an easy addon patch, it was quite easy in kuli. This would be really cool. Running kvm with nographic and virtio console on stdio would allow vim or mc to get notifications about resizes of the underlying console - like running native. - will work on platforms without a serial port (like s390) Maybe we can also use this to move existing lguest guests into kvm Christian ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 20:41 ` Christian Borntraeger @ 2009-01-13 20:58 ` Avi Kivity 2009-01-13 21:00 ` Avi Kivity 1 sibling, 0 replies; 16+ messages in thread From: Avi Kivity @ 2009-01-13 20:58 UTC (permalink / raw) To: Christian Borntraeger; +Cc: ehrhardt, aliguori, qemu-devel Christian Borntraeger wrote: >> What is the advantage of virtio-console, compared to the standard serial >> port? >> > > I cannot talk about the qemu version, but looking at kuli (the experimental > kvm userspace for s390) these things come into my mind: > > - it is not limited to to serial speed settings (9600..115200 etc.) > Neither is the emulated serial port :) > - the kernel driver of virtio_console has console resizing support. Adding > resize support into qemu should be an easy addon patch, it was quite easy in > kuli. This would be really cool. Running kvm with nographic and virtio > console on stdio would allow vim or mc to get notifications about resizes of > the underlying console - like running native. > That's good to have, certainly. > - will work on platforms without a serial port (like s390) > I'm looking forward to the emulated punch card device. > Maybe we can also use this to move existing lguest guests into kvm > Won't work due to lguest's abilessness. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 20:41 ` Christian Borntraeger 2009-01-13 20:58 ` Avi Kivity @ 2009-01-13 21:00 ` Avi Kivity 1 sibling, 0 replies; 16+ messages in thread From: Avi Kivity @ 2009-01-13 21:00 UTC (permalink / raw) To: Christian Borntraeger; +Cc: ehrhardt, aliguori, qemu-devel Christian Borntraeger wrote: >> What is the advantage of virtio-console, compared to the standard serial >> port? >> > > I cannot talk about the qemu version, but looking at kuli (the experimental > kvm userspace for s390) these things come into my mind: > > - it is not limited to to serial speed settings (9600..115200 etc.) > Neither is the emulated serial port :) > - the kernel driver of virtio_console has console resizing support. Adding > resize support into qemu should be an easy addon patch, it was quite easy in > kuli. This would be really cool. Running kvm with nographic and virtio > console on stdio would allow vim or mc to get notifications about resizes of > the underlying console - like running native. > That's good to have, certainly. > - will work on platforms without a serial port (like s390) > I'm looking forward to the emulated punch card device. > Maybe we can also use this to move existing lguest guests into kvm > Won't work due to lguest's abilessness. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu 2009-01-13 15:37 [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Christian Ehrhardt ` (4 preceding siblings ...) 2009-01-13 20:27 ` [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Avi Kivity @ 2009-01-15 20:08 ` Anthony Liguori 5 siblings, 0 replies; 16+ messages in thread From: Anthony Liguori @ 2009-01-15 20:08 UTC (permalink / raw) To: qemu-devel; +Cc: ehrhardt, aliguori, borntraeger Christian Ehrhardt wrote: > To complete qemu virtio device support this patch series add virtio-console > infrastructure to qemu in patch 1/2. > Patch 3/4 initializes virtio-console on the tested architectures x86 and > powerpc. > Applied all four. Thanks. Disregard my other note. The kvm-userspace prefix on some of the patches confused me. Regards, Anthony Liguori ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2009-01-19 10:12 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-01-13 15:37 [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Christian Ehrhardt 2009-01-13 15:37 ` [Qemu-devel] [PATCH 1 of 4] kvm-userpace: add virtio-console support Christian Ehrhardt 2009-01-15 19:55 ` Anthony Liguori 2009-01-19 10:09 ` Mark McLoughlin 2009-01-13 15:37 ` [Qemu-devel] [PATCH 2 of 4] kvm-userpace: add virtio-console cmdline option Christian Ehrhardt 2009-01-19 10:11 ` Mark McLoughlin 2009-01-13 15:37 ` [Qemu-devel] [PATCH 3 of 4] kvm-userpace: add virtio-console initializer for x86 Christian Ehrhardt 2009-01-13 15:37 ` [Qemu-devel] [PATCH 4 of 4] kvm-userpace: add virtio-console initializer for powerpc Christian Ehrhardt 2009-01-13 20:27 ` [Qemu-devel] [PATCH 0 of 4] Add virtio-console support to qemu Avi Kivity 2009-01-13 20:34 ` Anthony Liguori 2009-01-13 20:39 ` Avi Kivity 2009-01-13 20:44 ` Anthony Liguori 2009-01-13 20:41 ` Christian Borntraeger 2009-01-13 20:58 ` Avi Kivity 2009-01-13 21:00 ` Avi Kivity 2009-01-15 20:08 ` Anthony Liguori
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).