qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL (resend, rebase) 0/3] virtio-serial fixes, ioeventfd support
@ 2011-02-28 11:12 Amit Shah
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 1/3] virtio-serial: Use a struct to pass config information from proxy Amit Shah
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Amit Shah @ 2011-02-28 11:12 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah

Rebased version from last week:

The following changes since commit 417131fb9ad3f6dd7177a338cc5f143dec4d75f0:

  HACKING: Update status of format checking (2011-02-25 16:31:05 -0600)

are available in the git repository at:
  git://git.kernel.org/pub/scm/virt/qemu/amit/virtio-serial.git for-anthony


Amit Shah (3):
  virtio-serial: Use a struct to pass config information from proxy
  virtio-serial: Disallow generic ports at id 0
  virtio-serial: Enable ioeventfd

 hw/virtio-console.c    |   11 ++++++++++-
 hw/virtio-pci.c        |   15 +++++++++------
 hw/virtio-serial-bus.c |   16 ++++++++--------
 hw/virtio-serial.h     |    5 +++++
 hw/virtio.h            |    3 ++-
 5 files changed, 34 insertions(+), 16 deletions(-)

-- 
1.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH (resend, rebase) 1/3] virtio-serial: Use a struct to pass config information from proxy
  2011-02-28 11:12 [Qemu-devel] [PULL (resend, rebase) 0/3] virtio-serial fixes, ioeventfd support Amit Shah
@ 2011-02-28 11:12 ` Amit Shah
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 2/3] virtio-serial: Disallow generic ports at id 0 Amit Shah
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd Amit Shah
  2 siblings, 0 replies; 7+ messages in thread
From: Amit Shah @ 2011-02-28 11:12 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah

Instead of using a single variable to pass to the virtio_serial_init
function, use a struct so that expanding the number of variables to be
passed on later is easier.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-pci.c        |   12 ++++++------
 hw/virtio-serial-bus.c |   16 ++++++++--------
 hw/virtio-serial.h     |    5 +++++
 hw/virtio.h            |    3 ++-
 4 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 3911b09..952b5d2 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -18,6 +18,7 @@
 #include "virtio.h"
 #include "virtio-blk.h"
 #include "virtio-net.h"
+#include "virtio-serial.h"
 #include "pci.h"
 #include "qemu-error.h"
 #include "msix.h"
@@ -109,8 +110,7 @@ typedef struct {
 #ifdef CONFIG_LINUX
     V9fsConf fsconf;
 #endif
-    /* Max. number of ports we can have for a the virtio-serial device */
-    uint32_t max_virtserial_ports;
+    virtio_serial_conf serial;
     virtio_net_conf net;
     bool ioeventfd_disabled;
     bool ioeventfd_started;
@@ -770,12 +770,12 @@ static int virtio_serial_init_pci(PCIDevice *pci_dev)
         proxy->class_code != PCI_CLASS_OTHERS)          /* qemu-kvm  */
         proxy->class_code = PCI_CLASS_COMMUNICATION_OTHER;
 
-    vdev = virtio_serial_init(&pci_dev->qdev, proxy->max_virtserial_ports);
+    vdev = virtio_serial_init(&pci_dev->qdev, &proxy->serial);
     if (!vdev) {
         return -1;
     }
     vdev->nvectors = proxy->nvectors == DEV_NVECTORS_UNSPECIFIED
-                                        ? proxy->max_virtserial_ports + 1
+                                        ? proxy->serial.max_virtserial_ports + 1
                                         : proxy->nvectors;
     virtio_init_pci(proxy, vdev,
                     PCI_VENDOR_ID_REDHAT_QUMRANET,
@@ -902,8 +902,8 @@ static PCIDeviceInfo virtio_info[] = {
                                DEV_NVECTORS_UNSPECIFIED),
             DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
             DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
-            DEFINE_PROP_UINT32("max_ports", VirtIOPCIProxy, max_virtserial_ports,
-                               31),
+            DEFINE_PROP_UINT32("max_ports", VirtIOPCIProxy,
+                               serial.max_virtserial_ports, 31),
             DEFINE_PROP_END_OF_LIST(),
         },
         .qdev.reset = virtio_pci_reset,
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 8446bc2..c6feb43 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -811,19 +811,19 @@ void virtio_serial_port_qdev_register(VirtIOSerialPortInfo *info)
     qdev_register(&info->qdev);
 }
 
-VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
+VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf)
 {
     VirtIOSerial *vser;
     VirtIODevice *vdev;
     uint32_t i, max_supported_ports;
 
-    if (!max_nr_ports)
+    if (!conf->max_virtserial_ports)
         return NULL;
 
     /* Each port takes 2 queues, and one pair is for the control queue */
     max_supported_ports = VIRTIO_PCI_QUEUE_MAX / 2 - 1;
 
-    if (max_nr_ports > max_supported_ports) {
+    if (conf->max_virtserial_ports > max_supported_ports) {
         error_report("maximum ports supported: %u", max_supported_ports);
         return NULL;
     }
@@ -839,9 +839,9 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
     vser->bus->vser = vser;
     QTAILQ_INIT(&vser->ports);
 
-    vser->bus->max_nr_ports = max_nr_ports;
-    vser->ivqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
-    vser->ovqs = qemu_malloc(max_nr_ports * sizeof(VirtQueue *));
+    vser->bus->max_nr_ports = conf->max_virtserial_ports;
+    vser->ivqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
+    vser->ovqs = qemu_malloc(conf->max_virtserial_ports * sizeof(VirtQueue *));
 
     /* Add a queue for host to guest transfers for port 0 (backward compat) */
     vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
@@ -866,8 +866,8 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
         vser->ovqs[i] = virtio_add_queue(vdev, 128, handle_output);
     }
 
-    vser->config.max_nr_ports = max_nr_ports;
-    vser->ports_map = qemu_mallocz(((max_nr_ports + 31) / 32)
+    vser->config.max_nr_ports = conf->max_virtserial_ports;
+    vser->ports_map = qemu_mallocz(((conf->max_virtserial_ports + 31) / 32)
         * sizeof(vser->ports_map[0]));
     /*
      * Reserve location 0 for a console port for backward compat
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index 8cb9fbe..87cd7a1 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -45,6 +45,11 @@ struct virtio_console_control {
     uint16_t value;		/* Extra information for the key */
 };
 
+struct virtio_serial_conf {
+    /* Max. number of ports we can have for a the virtio-serial device */
+    uint32_t max_virtserial_ports;
+};
+
 /* Some events for the internal messages (control packets) */
 #define VIRTIO_CONSOLE_DEVICE_READY	0
 #define VIRTIO_CONSOLE_PORT_ADD		1
diff --git a/hw/virtio.h b/hw/virtio.h
index 31d16e1..d0920a8 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -195,7 +195,8 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf);
 struct virtio_net_conf;
 VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
                               struct virtio_net_conf *net);
-VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports);
+typedef struct virtio_serial_conf virtio_serial_conf;
+VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *serial);
 VirtIODevice *virtio_balloon_init(DeviceState *dev);
 #ifdef CONFIG_LINUX
 VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf);
-- 
1.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH (resend, rebase) 2/3] virtio-serial: Disallow generic ports at id 0
  2011-02-28 11:12 [Qemu-devel] [PULL (resend, rebase) 0/3] virtio-serial fixes, ioeventfd support Amit Shah
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 1/3] virtio-serial: Use a struct to pass config information from proxy Amit Shah
@ 2011-02-28 11:12 ` Amit Shah
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd Amit Shah
  2 siblings, 0 replies; 7+ messages in thread
From: Amit Shah @ 2011-02-28 11:12 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah

It was found libvirt was using port 0 for generic ports.  It has been
fixed in libvirt commit 8e28c5d40200b4c5d483bd585d237b9d870372e5.

Port 0 is reserved for virtconsole devices for backward compatibility
with the old -virtioconsole (from qemu 0.12) device type.

Ensure we don't allow instantiating a port at id 0 as well.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-console.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index c235b27..699f190 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -11,6 +11,7 @@
  */
 
 #include "qemu-char.h"
+#include "qemu-error.h"
 #include "virtio-serial.h"
 
 typedef struct VirtConsole {
@@ -113,7 +114,15 @@ static int virtserialport_initfn(VirtIOSerialPort *port)
 {
     VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
 
-    return generic_port_init(vcon, port);
+    if (port->id == 0) {
+        /*
+         * Disallow a generic port at id 0, that's reserved for
+         * console ports.
+         */
+        error_report("Port number 0 on virtio-serial devices reserved for virtconsole devices for backward compatibility.");
+        return -1;
+    }
+    return generic_port_init(vcon, dev);
 }
 
 static VirtIOSerialPortInfo virtserialport_info = {
-- 
1.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd
  2011-02-28 11:12 [Qemu-devel] [PULL (resend, rebase) 0/3] virtio-serial fixes, ioeventfd support Amit Shah
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 1/3] virtio-serial: Use a struct to pass config information from proxy Amit Shah
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 2/3] virtio-serial: Disallow generic ports at id 0 Amit Shah
@ 2011-02-28 11:12 ` Amit Shah
  2011-02-28 15:28   ` Stefan Hajnoczi
  2 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2011-02-28 11:12 UTC (permalink / raw)
  To: qemu list; +Cc: Amit Shah

Enable ioeventfd for virtio-serial devices by default.  Commit
25db9ebe15125deb32958c6df74996f745edf1f9 lists the benefits of using
ioeventfd.

Copying a file from guest to host over a virtio-serial channel didn't
show much difference in time or io_exit rate.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-pci.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 952b5d2..ef65590 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -789,6 +789,7 @@ static int virtio_serial_exit_pci(PCIDevice *pci_dev)
 {
     VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
 
+    virtio_pci_stop_ioeventfd(proxy);
     virtio_serial_exit(proxy->vdev);
     return virtio_exit_pci(pci_dev);
 }
@@ -898,6 +899,8 @@ static PCIDeviceInfo virtio_info[] = {
         .init      = virtio_serial_init_pci,
         .exit      = virtio_serial_exit_pci,
         .qdev.props = (Property[]) {
+            DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
+                            VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
             DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
                                DEV_NVECTORS_UNSPECIFIED),
             DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
-- 
1.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd
  2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd Amit Shah
@ 2011-02-28 15:28   ` Stefan Hajnoczi
  2011-03-01  6:41     ` Amit Shah
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2011-02-28 15:28 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu list

On Mon, Feb 28, 2011 at 11:12 AM, Amit Shah <amit.shah@redhat.com> wrote:
> Enable ioeventfd for virtio-serial devices by default.  Commit
> 25db9ebe15125deb32958c6df74996f745edf1f9 lists the benefits of using
> ioeventfd.
>
> Copying a file from guest to host over a virtio-serial channel didn't
> show much difference in time or io_exit rate.

The cost of enabling ioeventfd is one eventfd file descriptor and KVM
in-kernel device slot per virtqueue.  The current maximum number per
VM is 200, this is a kernel limit in
include/linux/kvm_host.h:NR_IOBUS_DEVS.

Do you really want to use ioeventfd for virtio-serial?  Perhaps this
is more useful for high-frequency device interfaces.

Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd
  2011-02-28 15:28   ` Stefan Hajnoczi
@ 2011-03-01  6:41     ` Amit Shah
  2011-03-01 10:23       ` Stefan Hajnoczi
  0 siblings, 1 reply; 7+ messages in thread
From: Amit Shah @ 2011-03-01  6:41 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu list

On (Mon) 28 Feb 2011 [15:28:49], Stefan Hajnoczi wrote:
> On Mon, Feb 28, 2011 at 11:12 AM, Amit Shah <amit.shah@redhat.com> wrote:
> > Enable ioeventfd for virtio-serial devices by default.  Commit
> > 25db9ebe15125deb32958c6df74996f745edf1f9 lists the benefits of using
> > ioeventfd.
> >
> > Copying a file from guest to host over a virtio-serial channel didn't
> > show much difference in time or io_exit rate.
> 
> The cost of enabling ioeventfd is one eventfd file descriptor and KVM
> in-kernel device slot per virtqueue.  The current maximum number per
> VM is 200, this is a kernel limit in
> include/linux/kvm_host.h:NR_IOBUS_DEVS.
> 
> Do you really want to use ioeventfd for virtio-serial?  Perhaps this
> is more useful for high-frequency device interfaces.

I guess virtio-serial is being used heavily -- by almost all guest
agents nowadays.  The primary use-case, though, is not for
high-bandwidth communication.

This setting could be default off, it didn't show any difference in my
test run, but depends on what people who use it see and think.

		Amit

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd
  2011-03-01  6:41     ` Amit Shah
@ 2011-03-01 10:23       ` Stefan Hajnoczi
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2011-03-01 10:23 UTC (permalink / raw)
  To: Amit Shah; +Cc: qemu list

On Tue, Mar 1, 2011 at 6:41 AM, Amit Shah <amit.shah@redhat.com> wrote:
> On (Mon) 28 Feb 2011 [15:28:49], Stefan Hajnoczi wrote:
>> On Mon, Feb 28, 2011 at 11:12 AM, Amit Shah <amit.shah@redhat.com> wrote:
>> > Enable ioeventfd for virtio-serial devices by default.  Commit
>> > 25db9ebe15125deb32958c6df74996f745edf1f9 lists the benefits of using
>> > ioeventfd.
>> >
>> > Copying a file from guest to host over a virtio-serial channel didn't
>> > show much difference in time or io_exit rate.
>>
>> The cost of enabling ioeventfd is one eventfd file descriptor and KVM
>> in-kernel device slot per virtqueue.  The current maximum number per
>> VM is 200, this is a kernel limit in
>> include/linux/kvm_host.h:NR_IOBUS_DEVS.
>>
>> Do you really want to use ioeventfd for virtio-serial?  Perhaps this
>> is more useful for high-frequency device interfaces.
>
> I guess virtio-serial is being used heavily -- by almost all guest
> agents nowadays.  The primary use-case, though, is not for
> high-bandwidth communication.
>
> This setting could be default off, it didn't show any difference in my
> test run, but depends on what people who use it see and think.

I don't have strong opinions about this but wanted to make you aware
that there is a limited number of ioeventfds to go around.

Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-03-01 10:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-28 11:12 [Qemu-devel] [PULL (resend, rebase) 0/3] virtio-serial fixes, ioeventfd support Amit Shah
2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 1/3] virtio-serial: Use a struct to pass config information from proxy Amit Shah
2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 2/3] virtio-serial: Disallow generic ports at id 0 Amit Shah
2011-02-28 11:12 ` [Qemu-devel] [PATCH (resend, rebase) 3/3] virtio-serial: Enable ioeventfd Amit Shah
2011-02-28 15:28   ` Stefan Hajnoczi
2011-03-01  6:41     ` Amit Shah
2011-03-01 10:23       ` Stefan Hajnoczi

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).