Skip to contentSkip to conversation

virtio-serial device

RFC New Amit Shah 9 participants 19 messages Jun 9, 2009 – Jun 12, 2009

Subsystems (3)
lore
Share & tools
lore

Amit Shah

author
#0 lore raw

Hello,

These patches implement a virtio-serial pci device that can expose multiple serial ports over one pci device.

It's still under development and hacky but I'm sending out for early review comments.

Thanks,
Amit

author
#1 lore raw

PATCH 1/1 pci: add define for communication class devices

---
 hw/pci_ids.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
hw/pci_ids.h +2 -0
index 427fcd5..3afe674 100644
@@ -35,6 +35,8 @@
 #define PCI_CLASS_BRIDGE_PCI             0x0604
 #define PCI_CLASS_BRIDGE_OTHER           0x0680
 
+#define PCI_CLASS_COMMUNICATION_OTHER    0x0780
+
 #define PCI_CLASS_PROCESSOR_CO           0x0b40
 #define PCI_CLASS_PROCESSOR_POWERPC      0x0b20
 
Signature · 1 line
1.6.0.6
author
#2 lore raw

PATCH 1/1 qdev: add virtserial char drv init hacks

---
 hw/qdev.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
hw/qdev.c +5 -1
index 689cf4c..661bcde 100644
@@ -172,9 +172,13 @@ CharDriverState *qdev_init_chardev(DeviceState *dev)
 {
     static int next_serial;
     static int next_virtconsole;
+    static int next_virtserial;
+
     /* FIXME: This is a nasty hack that needs to go away.  */
-    if (strncmp(dev->type->name, "virtio", 6) == 0) {
+    if (strncmp(dev->name, "virtio-console", 14) == 0) {
         return virtcon_hds[next_virtconsole++];
+    } else if (strncmp(dev->name, "virtio-serial", 13) == 0) {
+        return virtio_serial_hds[next_virtserial++];
     } else {
         return serial_hds[next_serial++];
     }
Signature · 1 line
1.6.0.6
author
#3 lore raw

PATCH 1/1 virtio-serial: PCI device for simple host <-> guest communication

This interface presents a char device from which bits can be sent and read.

Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage.

---
 Makefile.target    |    2 +-
 hw/pc.c            |   17 +++
 hw/pci.h           |    1 +
 hw/virtio-pci.c    |   15 +++
 hw/virtio-serial.c |  320 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio-serial.h |   31 +++++
 hw/virtio.h        |    1 +
 qemu-options.hx    |    8 ++
 sysemu.h           |   11 ++
 vl.c               |   62 ++++++++++
 10 files changed, 467 insertions(+), 1 deletions(-)
 create mode 100644 hw/virtio-serial.c
 create mode 100644 hw/virtio-serial.h
Makefile.target +1 -1
index 27de4b9..d8ad787 100644
@@ -497,7 +497,7 @@ OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o \
      gdbstub.o gdbstub-xml.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
-OBJS+=virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o
+OBJS+=virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o virtio-serial.o
 ifdef CONFIG_KVM
 OBJS+=kvm.o kvm-all.o
 endif
hw/pc.c +17 -0
index 0934778..b4136a0 100644
@@ -37,6 +37,8 @@
 #include "watchdog.h"
 #include "smbios.h"
 
+void *virtio_serial_new_port(PCIDevice *dev, int idx, char *name);
+
 /* output Bochs bios info messages */
 //#define DEBUG_BIOS
 
@@ -1164,6 +1166,21 @@ static void pc_init1(ram_addr_t ram_size,
             }
         }
     }
+
+    /* Add virtio serial devices */
+    if (pci_enabled && virtio_serial_index) {
+        void *dev;
+
+        dev = pci_create_simple(pci_bus, -1, "virtio-serial-pci");
+        if (!dev) {
+            fprintf(stderr, "qemu: could not create virtio serial pci device\n");
+            exit(1);
+        }
+
+        for (i = 0; i < virtio_serial_index; i++) {
+                virtio_serial_new_port(dev, i, virtio_serial_names[i]);
+        }
+    }
 }
 
 static void pc_init_pci(ram_addr_t ram_size,
hw/pci.h +1 -0
index 0405837..ab06008 100644
@@ -69,6 +69,7 @@ extern target_phys_addr_t pci_mem_base;
 #define PCI_DEVICE_ID_VIRTIO_BLOCK       0x1001
 #define PCI_DEVICE_ID_VIRTIO_BALLOON     0x1002
 #define PCI_DEVICE_ID_VIRTIO_CONSOLE     0x1003
+#define PCI_DEVICE_ID_VIRTIO_SERIAL      0x1004
 
 typedef void PCIConfigWriteFunc(PCIDevice *pci_dev,
                                 uint32_t address, uint32_t data, int len);
hw/virtio-pci.c +15 -0
index c072423..30e56e1 100644
@@ -334,6 +334,19 @@ static void virtio_balloon_init_pci(PCIDevice *pci_dev)
                     0x00);
 }
 
+static void virtio_serial_init_pci(PCIDevice *pci_dev)
+{
+    VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+    VirtIODevice *vdev;
+
+    vdev = virtio_serial_init(&pci_dev->qdev);
+    virtio_init_pci(proxy, vdev,
+                    PCI_VENDOR_ID_REDHAT_QUMRANET,
+                    PCI_DEVICE_ID_VIRTIO_SERIAL,
+                    PCI_CLASS_COMMUNICATION_OTHER,
+                    0x00);
+}
+
 static void virtio_pci_register_devices(void)
 {
     pci_qdev_register("virtio-blk-pci", sizeof(VirtIOPCIProxy),
@@ -344,6 +357,8 @@ static void virtio_pci_register_devices(void)
                       virtio_console_init_pci);
     pci_qdev_register("virtio-balloon-pci", sizeof(VirtIOPCIProxy),
                       virtio_balloon_init_pci);
+    pci_qdev_register("virtio-serial-pci", sizeof(VirtIOPCIProxy),
+                      virtio_serial_init_pci);
 }
 
 device_init(virtio_pci_register_devices)
hw/virtio-serial.c new file +320 -0

320 lines not on this page · raw message

hw/virtio-serial.h new file +31 -0
new file mode 100644
index 0000000..7d46c1f
@@ -0,0 +1,31 @@
+/*
+ * Virtio Serial Support
+ *
+ * Copyright (C) 2009, Red Hat, Inc.
+ *
+ * Author(s): Amit Shah <[email protected]>
+ *
+ * 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_SERIAL_H
+#define _QEMU_VIRTIO_SERIAL_H
+
+/* The ID for virtio serial */
+#define VIRTIO_ID_SERIAL 7
+
+struct virtio_serial_config
+{
+    uint8_t nr_ports;
+    uint16_t status;
+} __attribute__((packed));
+
+#define VIRTIO_SERIAL_GET_PORT_NAME 1
+
+
+void *virtio_serial_new_port(PCIDevice *dev, int idx, char *name);
+void virtio_serial_send_input(const char *command,
+			      const char *key, const char *value);
+
+#endif
hw/virtio.h +1 -0
index 425727e..d2b50c3 100644
@@ -151,5 +151,6 @@ VirtIODevice *virtio_blk_init(DeviceState *dev);
 VirtIODevice *virtio_net_init(DeviceState *dev);
 VirtIODevice *virtio_console_init(DeviceState *dev);
 VirtIODevice *virtio_balloon_init(DeviceState *dev);
+VirtIODevice *virtio_serial_init(DeviceState *dev);
 
 #endif
qemu-options.hx +8 -0
index 87af798..857d8f1 100644
@@ -1523,6 +1523,14 @@ STEXI
 Set virtio console.
 ETEXI
 
+DEF("virtioserial", HAS_ARG, QEMU_OPTION_virtioserial, \
+    "-virtioserial c\n" \
+    "                define virtio serial device\n")
+STEXI
+@item -virtserial @var{c}
+Set virtio serial device.
+ETEXI
+
 DEF("show-cursor", 0, QEMU_OPTION_show_cursor, \
     "-show-cursor    show cursor\n")
 STEXI
sysemu.h +11 -0
index 658aeec..4f2b5af 100644
@@ -229,6 +229,17 @@ extern CharDriverState *parallel_hds[MAX_PARALLEL_PORTS];
 
 extern CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES];
 
+/* virtio serial ports */
+
+#define MAX_VIRTIO_SERIAL_PORTS 4
+#define VIRTIO_SERIAL_NAME_MAX_LEN 30
+
+
+extern CharDriverState *virtio_serial_hds[MAX_VIRTIO_SERIAL_PORTS];
+extern char virtio_serial_names[MAX_VIRTIO_SERIAL_PORTS][VIRTIO_SERIAL_NAME_MAX_LEN];
+extern int virtio_serial_index;
+
+
 #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR)
 
 #ifdef NEED_CPU_H
vl.c +62 -0

98 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#4 lore raw

[Qemu-devel] Re: [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 7 lines · Amit Shah

This interface presents a char device from which bits can be sent and read.

Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage.

Out of curiosity: What is the advantage over instantiating a multiport 16550A PCI card? Will those channels be so performance critical?

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#5 lore raw

Re: [Qemu-devel] Re: [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 11 lines · Jan Kiszka
Quoted 7 lines · Amit Shah

This interface presents a char device from which bits can be sent and read.

Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage.

Out of curiosity: What is the advantage over instantiating a multiport 16550A PCI card? Will those channels be so performance critical?

16550A has a couple of problems: The fixed sized FIFO (16 bytes) can cause problems if you send data too quickly. (I've seen this problem when sending too much data from host to the guest, but I can't find the bug report right now ...). Secondly UARTs are complicated to emulate compared to a clean virtio device. Would we be happy with the address space taken up and amount of emulation going on once we had, say, 16 emulated ports?

On the other hand, multiport cards don't require special drivers in the guest ...

Rich.

Signature · 4 lines
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 75 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
#6 lore raw

[Qemu-devel] Re: [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 9 lines · Richard W.M. Jones
Quoted 8 lines · Jan Kiszka
Quoted 7 lines · Amit Shah

This interface presents a char device from which bits can be sent and read.

Sample uses for such a device can be obtaining info from the guest like the file systems used, apps installed, etc. for offline usage and logged-in users, clipboard copy-paste, etc. for online usage.

Quoted 7 lines
Quoted 2 lines

Out of curiosity: What is the advantage over instantiating a multiport 16550A PCI card? Will those channels be so performance critical?

16550A has a couple of problems: The fixed sized FIFO (16 bytes) can cause problems if you send data too quickly. (I've seen this problem when sending too much data from host to the guest, but I can't find the bug report right now ...).

If you buy a real 16550A card with high-speed support (eg. 1 MBit/s), you get larger FIFOs (eg. 256 byte). Thresholds are scaled correspondingly by such cards. So there would be no problem in extending this in QEMU as well, ie. making it a parameter to the init function.

Quoted 4 lines

Secondly UARTs are complicated to
emulate compared to a clean virtio device. Would we be happy with the address space taken up and amount of emulation going on once we had, say, 16 emulated ports?

Memory-mapped 16550As do not suffer from such a limitation.

Quoted 3 lines

On the other hand, multiport cards don't require special drivers in the guest ...

That's what raised my interest: What benefit of a virtio-serial can over-compensate this advantage of standard hardware?

Jan

#7 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

In reply to Amit Shah

On Tue, Jun 09, 2009 at 10:12:48PM +0530, Amit Shah wrote:
[...]

Are you going to post the virtio driver for the Linux kernel later?

qemu-options.hx STEXI · line 1528

Quoted 3 lines
qemu-options.hx +3 -0
+DEF("virtioserial", HAS_ARG, QEMU_OPTION_virtioserial, \
+    "-virtioserial c\n" \
+    "                define virtio serial device\n")

Can it be made to look like a real serial port, ie. '-serial dev,model=virtio' ?

Rich.

Signature · 4 lines
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
#8 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 2 lines · Richard W.M. Jones

Can it be made to look like a real serial port, ie. '-serial dev,model=virtio' ?

A rather pedantic point, perhaps, but this doesn't really look like a serial device to me (in the same way that it doesn't look like a parallel device, either).

But then I might as well argue that flash-based storage devices aren't "disks", etc., etc... :-)

Cheers,

Signature · 1 line
Stuart Brady
#9 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

In reply to Richard W.M. Jones
Quoted 5 lines · Richard W.M. Jones

On Tue, Jun 09, 2009 at 10:12:48PM +0530, Amit Shah wrote:
[...]

Are you going to post the virtio driver for the Linux kernel later?

Yeah, I'd like to see the Linux driver before drawing conclusions.

Plus, having a virtio serial device and a virtio console seems unfortunate to me. Anyway we can unify the two? Maybe make virtio serial support hvc with a feature flag or something instead of ttyS?

Regards,

Anthony Liguori

#10 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 3 lines

Plus, having a virtio serial device and a virtio console seems unfortunate to me. Anyway we can unify the two? Maybe make virtio serial support hvc with a feature flag or something instead of ttyS?

I agree. virtio-console and virtio-serial seem to be duplicating the exact same functionality. If you really are that short of PCI devices then I suggest you enhance virtio-console to support multiple channels.

Paul

author
#11 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Richard W.M. Jones

On Tue, Jun 09, 2009 at 10:12:48PM +0530, Amit Shah wrote:
[...]

Are you going to post the virtio driver for the Linux kernel later?

Yeah, I'd like to see the Linux driver before drawing conclusions.

OK; will send in a while.

Quoted 3 lines

Plus, having a virtio serial device and a virtio console seems unfortunate to me. Anyway we can unify the two? Maybe make virtio serial support hvc with a feature flag or something instead of ttyS?

Yes, it's possible. I'll look into that once I reach a point where virtio-serial is ready to be merged. I'll also have to look at making sure existing guest kernels work with the new, unified device.

Amit

#12 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 7 lines · Amit Shah
Quoted 3 lines

Plus, having a virtio serial device and a virtio console seems unfortunate to me. Anyway we can unify the two? Maybe make virtio serial support hvc with a feature flag or something instead of ttyS?

Yes, it's possible. I'll look into that once I reach a point where virtio-serial is ready to be merged. I'll also have to look at making sure existing guest kernels work with the new, unified device.

One of the most useful things about a serial port is that it's so easy for basic OS components like debuggers and bootloaders and BIOSes to use it, with very little code, and without having to do very complex things like initialise and enumerate PCI buses etc., and without interference by an OS so they are useful for things like kernel debugging and reliable debugging output.

For this reason, virtually every real machine has a simple serial port, even if it isn't exposed on an external connector.

Are virtio-serial/virtio-console very simple to drive from guest code, without PCI enumeration, or do they require complex initialisation and OS cooperation?

-- Jamie

author
#13 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 16 lines · Jamie Lokier
Quoted 7 lines · Amit Shah
Quoted 3 lines

Plus, having a virtio serial device and a virtio console seems unfortunate to me. Anyway we can unify the two? Maybe make virtio serial support hvc with a feature flag or something instead of ttyS?

Yes, it's possible. I'll look into that once I reach a point where virtio-serial is ready to be merged. I'll also have to look at making sure existing guest kernels work with the new, unified device.

One of the most useful things about a serial port is that it's so easy for basic OS components like debuggers and bootloaders and BIOSes to use it, with very little code, and without having to do very complex things like initialise and enumerate PCI buses etc., and without interference by an OS so they are useful for things like kernel debugging and reliable debugging output.

Quoted 6 lines

For this reason, virtually every real machine has a simple serial port, even if it isn't exposed on an external connector.

Are virtio-serial/virtio-console very simple to drive from guest code, without PCI enumeration, or do they require complex initialisation and OS cooperation?

OK, great question. I'll post my Linux driver that'll answer your question precisely, but this is what a guest userspace app will have to do to use it:

        fd = open("/dev/vmser0", O_RDWR);
        if (fd == -1) {
                perror("open");
                return -errno;
        }

        ret = read(fd, buf, 100);
        if (ret < 0) {
                perror("read");
        }

        ret = ioctl(fd, VIRTIO_SERIAL_IOCTL_GET_PORT_NAME, &port_name);
        if (ret) perror("ioctl");
        printf("string is %s\n", port_name.name);

So the guest driver exposes a simple char device to userspace.

The driver itself hooks up with the virtio code which abstracts away all the pci stuff. It just has to manage the rings and the queues.

Amit

#14 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 20 lines · Amit Shah
Quoted 19 lines · Jamie Lokier
Quoted 7 lines · Amit Shah
Quoted 3 lines

Plus, having a virtio serial device and a virtio console seems unfortunate to me. Anyway we can unify the two? Maybe make virtio serial support hvc with a feature flag or something instead of ttyS?

Yes, it's possible. I'll look into that once I reach a point where virtio-serial is ready to be merged. I'll also have to look at making sure existing guest kernels work with the new, unified device.

One of the most useful things about a serial port is that it's so easy for basic OS components like debuggers and bootloaders and BIOSes to use it, with very little code, and without having to do very complex things like initialise and enumerate PCI buses etc., and without interference by an OS so they are useful for things like kernel debugging and reliable debugging output.

For this reason, virtually every real machine has a simple serial port, even if it isn't exposed on an external connector.

Quoted 7 lines
Quoted 3 lines

Are virtio-serial/virtio-console very simple to drive from guest code, without PCI enumeration, or do they require complex initialisation and OS cooperation?

OK, great question. I'll post my Linux driver that'll answer your question precisely, but this is what a guest userspace app will have to do to use it:

Userspace doesn't matter so much - I'd assumed a simple char driver carrying a pipe of bytes, no matter how the emulated hardware works. But that's not relevant to the things I'm asking about, since they run outside userspace, sometimes without a kernel.

Quoted 2 lines

The driver itself hooks up with the virtio code which abstracts away all the pci stuff. It just has to manage the rings and the queues.

On the face of it, simply because virtio uses PCI, it looks a _lot_ more complicated than a serial port (UART) at a fixed I/O or MMIO address, for things like boot loaders, boot ROMS, BIOS debugging, kernel debuggers and minimal kernels.

I say on the face of it, because I don't know enough about how virtio generally is set up in the guest.

Can you make virtio-serial start enabled with fixed, known I/O or MMIO addresss, in a similar way to the way VGA cards and IDE ports are PCI devices but can be used without PCI enumeration?

Can you make it pollable, so it's usable without having to route interrupts, which can be quite complicated, or impossible when you're debugging something that thinks it is control?

-- Jamie

author
#15 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

In reply to Anthony Liguori
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Richard W.M. Jones

On Tue, Jun 09, 2009 at 10:12:48PM +0530, Amit Shah wrote:
[...]

Are you going to post the virtio driver for the Linux kernel later?

Yeah, I'd like to see the Linux driver before drawing conclusions.

Pasting here a slightly older version of the patch. I'm actively working on it; a few things might have changed but the basic idea remains the same.

Amit

drivers/char/Kconfig +6 -0
index 735bbe2..a023346 100644
@@ -666,6 +666,12 @@ config VIRTIO_CONSOLE
 	help
 	  Virtio console for use with lguest and other hypervisors.
 
+config VIRTIO_SERIAL
+	tristate "Virtio serial"
+	select VIRTIO
+	select VIRTIO_RING
+	help
+	  Virtio serial device driver for simple guest and host communication
 
 config HVCS
 	tristate "IBM Hypervisor Virtual Console Server support"
drivers/char/Makefile +1 -0
index 9caf5b5..e5bee21 100644
@@ -53,6 +53,7 @@ obj-$(CONFIG_HVC_XEN)		+= hvc_xen.o
 obj-$(CONFIG_HVC_IUCV)		+= hvc_iucv.o
 obj-$(CONFIG_HVC_UDBG)		+= hvc_udbg.o
 obj-$(CONFIG_VIRTIO_CONSOLE)	+= virtio_console.o
+obj-$(CONFIG_VIRTIO_SERIAL)	+= virtio_serial.o
 obj-$(CONFIG_RAW_DRIVER)	+= raw.o
 obj-$(CONFIG_SGI_SNSC)		+= snsc.o snsc_event.o
 obj-$(CONFIG_MSPEC)		+= mspec.o
drivers/char/virtio_serial.c new file +531 -0

531 lines not on this page · raw message

include/linux/virtio_serial.h new file +34 -0
new file mode 100644
index 0000000..5528b11
@@ -0,0 +1,34 @@
+#ifndef _LINUX_VIRTIO_SERIAL_H
+#define _LINUX_VIRTIO_SERIAL_H
+#include <linux/types.h>
+#include <linux/virtio_config.h>
+
+/* Guest kernel - Host interface */
+
+/* The ID for virtio serial */
+#define VIRTIO_ID_SERIAL	7
+
+struct virtio_serial_config {
+	__u8 nr_ports;
+	__u16 status;
+} __attribute__((packed));
+
+
+#define VIRTIO_SERIAL_NAME_MAX_LEN 30
+
+/* Some defines for the control channel key */
+#define VIRTIO_SERIAL_GET_PORT_NAME 1
+
+/* Guest kernel - Guest userspace interface */
+
+/* IOCTL-related */
+#define VIRTIO_SERIAL_IO 0xAF
+
+struct virtio_serial_port_name {
+	char name[VIRTIO_SERIAL_NAME_MAX_LEN];
+};
+
+#define VIRTIO_SERIAL_IOCTL_GET_PORT_NAME	_IOWR(VIRTIO_SERIAL_IO, 0x00, \
+			    struct virtio_serial_port_name)
+
+#endif /* _LINUX_VIRTIO_SERIAL_H */
#16 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 8 lines · Amit Shah
Quoted 7 lines · Anthony Liguori
Quoted 5 lines · Richard W.M. Jones

On Tue, Jun 09, 2009 at 10:12:48PM +0530, Amit Shah wrote:
[...]

Are you going to post the virtio driver for the Linux kernel later?

Quoted 8 lines
Quoted 1 line

Yeah, I'd like to see the Linux driver before drawing conclusions.

Pasting here a slightly older version of the patch. I'm actively working on it; a few things might have changed but the basic idea remains the same.

+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Old FSF address, the new one is on Franklin St.

Quoted 3 lines

+struct virtio_serial_port {

+ unsigned int read_len;

This limits the maximum transfer length to 4G, which is way too short on 64 bit hosts. ;-)

Quoted 4 lines

+struct virtio_serial_config {
+ __u8 nr_ports;
+ __u16 status;
+} __attribute__((packed));

The structure should be redesigned to work without packed attribute. status field is unaligned.

author
#17 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

Quoted 11 lines · Blue Swirl
Quoted 10 lines · Amit Shah
Quoted 8 lines · Anthony Liguori
Quoted 5 lines · Richard W.M. Jones

On Tue, Jun 09, 2009 at 10:12:48PM +0530, Amit Shah wrote:
[...]

Are you going to post the virtio driver for the Linux kernel later?

Yeah, I'd like to see the Linux driver before drawing conclusions.

Quoted 8 lines
Quoted 6 lines

Pasting here a slightly older version of the patch. I'm actively working on it; a few things might have changed but the basic idea remains the same.

+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Old FSF address, the new one is on Franklin St.

OK, will update.

Quoted 6 lines
Quoted 3 lines

+struct virtio_serial_port {

+ unsigned int read_len;

This limits the maximum transfer length to 4G, which is way too short on 64 bit hosts. ;-)

This is only valid for a single packet that's transmitted via the queue at a time and I doubt anyone's going to use bigger packets :-)

(That size is also limited by the kernel -- and the current code only alloctes one PAGE_SIZE buffer for the transfer.)

Quoted 7 lines
Quoted 4 lines

+struct virtio_serial_config {
+ __u8 nr_ports;
+ __u16 status;
+} __attribute__((packed));

The structure should be redesigned to work without packed attribute. status field is unaligned.

I'll see how to untangle it.

Amit

author
#18 lore raw

Re: [Qemu-devel] [PATCH] virtio-serial: PCI device for simple host <-> guest communication

In reply to Richard W.M. Jones
Quoted 4 lines · Richard W.M. Jones

On Tue, Jun 09, 2009 at 10:12:48PM +0530, Amit Shah wrote:
[...]

Are you going to post the virtio driver for the Linux kernel later?

A few cleanups needed. I'll get to that right now.

Quoted 6 lines

qemu-options.hx STEXI · line 1528

Quoted 3 lines
qemu-options.hx +3 -0
+DEF("virtioserial", HAS_ARG, QEMU_OPTION_virtioserial, \
+    "-virtioserial c\n" \
+    "                define virtio serial device\n")

Can it be made to look like a real serial port, ie. '-serial dev,model=virtio' ?

Yes, this part is still in flux: there are a few more parameters that are going to be passed (like the name for the port). Also, I'm planning to add an API within qemu for data transfer over serial ports and a key-value pair will be suitable for that. So that'll require a separate parameter as well. This API will be useful to support migration better and also qemu to converse with the guest.

So extending the -serial option is certainly possible but I've to make sure the virtio serial-specific options don't apply to the others. I've not gotten to look into that yet.

Amit