public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/qemu-kvm:qemu-kvm-0.14.1-gentoo commit in: hw/
@ 2011-07-21 20:19 Doug Goldstein
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Goldstein @ 2011-07-21 20:19 UTC (permalink / raw
  To: gentoo-commits

commit:     be687955b9e2620508169c9cdb19fb49f85432b2
Author:     Amit Shah <amit.shah <AT> redhat <DOT> com>
AuthorDate: Mon Mar 21 21:06:41 2011 +0000
Commit:     Doug Goldstein <cardoe <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 20:18:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qemu-kvm.git;a=commit;h=be687955

virtio-console: Enable port throttling when chardev is slow to consume data

When a chardev indicates it can't accept more data, we tell the
virtio-serial code to stop sending us any more data till we tell
otherwise.  This helps in guests continuing to run normally while the vq
keeps getting full and eventually the guest stops queueing more data.
As soon as the chardev indicates it can accept more data, start pushing!

Signed-off-by: Amit Shah <amit.shah <AT> redhat.com>

---
 hw/virtio-console.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 22cf28c..eecbdf7 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -18,6 +18,16 @@ typedef struct VirtConsole {
     CharDriverState *chr;
 } VirtConsole;
 
+/*
+ * Callback function that's called from chardevs when backend becomes
+ * writable.
+ */
+static void chr_write_unblocked(void *opaque)
+{
+    VirtConsole *vcon = opaque;
+
+    virtio_serial_throttle_port(&vcon->port, false);
+}
 
 /* Callback function that's called when the guest sends us data */
 static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
@@ -61,6 +71,7 @@ static const QemuChrHandlers chr_handlers = {
     .fd_can_read = chr_can_read,
     .fd_read = chr_read,
     .fd_event = chr_event,
+    .fd_write_unblocked = chr_write_unblocked,
 };
 
 static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev)



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

* [gentoo-commits] proj/qemu-kvm:qemu-kvm-0.14.1-gentoo commit in: hw/
@ 2011-07-21 20:19 Doug Goldstein
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Goldstein @ 2011-07-21 20:19 UTC (permalink / raw
  To: gentoo-commits

commit:     909db97aac97750c207c30c3b77e6bb3f9604107
Author:     Hans de Goede <hdegoede <AT> redhat <DOT> com>
AuthorDate: Fri Mar 18 14:30:45 2011 +0000
Commit:     Doug Goldstein <cardoe <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 20:18:45 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qemu-kvm.git;a=commit;h=909db97a

virtio-console: notify backend of guest open / close

Signed-off-by: Hans de Goede <hdegoede <AT> redhat.com>

---
 hw/virtio-console.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index eecbdf7..828a1a3 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -37,6 +37,22 @@ static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
     return qemu_chr_write(vcon->chr, buf, len);
 }
 
+/* Callback function that's called when the guest opens the port */
+static void guest_open(VirtIOSerialPort *port)
+{
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+    qemu_chr_guest_open(vcon->chr);
+}
+
+/* Callback function that's called when the guest closes the port */
+static void guest_close(VirtIOSerialPort *port)
+{
+    VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
+
+    qemu_chr_guest_close(vcon->chr);
+}
+
 /* Readiness of the guest to accept data on a port */
 static int chr_can_read(void *opaque)
 {
@@ -81,6 +97,8 @@ static int generic_port_init(VirtConsole *vcon, VirtIOSerialDevice *dev)
     if (vcon->chr) {
         qemu_chr_add_handlers(vcon->chr, &chr_handlers, vcon);
         vcon->port.info->have_data = flush_buf;
+        vcon->port.info->guest_open = guest_open;
+        vcon->port.info->guest_close = guest_close;
     }
     return 0;
 }



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

* [gentoo-commits] proj/qemu-kvm:qemu-kvm-0.14.1-gentoo commit in: hw/
@ 2011-07-21 20:22 Doug Goldstein
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Goldstein @ 2011-07-21 20:22 UTC (permalink / raw
  To: gentoo-commits

commit:     35e17b6a41b1d1126f7f68b835b227805404440d
Author:     Nelson Elhage <&lt;nelhage <AT> ksplice <DOT> com&gt>
AuthorDate: Thu May 19 17:23:17 2011 +0000
Commit:     Doug Goldstein <cardoe <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 20:22:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qemu-kvm.git;a=commit;h=35e17b6a

virtqueue: Sanity-check the length of indirect descriptors.

We were previously allowing arbitrarily-long descriptors, which could lead to a
buffer overflow in the qemu-kvm process.

---
 hw/virtio.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/hw/virtio.c b/hw/virtio.c
index 31bd9e3..a91a28b 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -336,6 +336,11 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes)
             max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
             num_bufs = i = 0;
             desc_pa = vring_desc_addr(desc_pa, i);
+
+            if (max &gt; VIRTQUEUE_MAX_SIZE) {
+                error_report(&quot;Too-large indirect descriptor&quot;);
+                exit(1);
+            }
         }
 
         do {
@@ -406,6 +411,11 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
         max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
         desc_pa = vring_desc_addr(desc_pa, i);
         i = 0;
+
+        if (max &gt; VIRTQUEUE_MAX_SIZE) {
+            error_report(&quot;Too-large indirect descriptor&quot;);
+            exit(1);
+        }
     }
 
     /* Collect all the descriptors */



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

* [gentoo-commits] proj/qemu-kvm:qemu-kvm-0.14.1-gentoo commit in: hw/
@ 2011-07-26 17:16 Doug Goldstein
  0 siblings, 0 replies; 4+ messages in thread
From: Doug Goldstein @ 2011-07-26 17:16 UTC (permalink / raw
  To: gentoo-commits

commit:     f3c2a669593d5f4bfa7aa002ccbbaaca013f8e2f
Author:     Nelson Elhage <&lt;nelhage <AT> ksplice <DOT> com&gt>
AuthorDate: Thu May 19 17:23:17 2011 +0000
Commit:     Doug Goldstein <cardoe <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 20:39:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qemu-kvm.git;a=commit;h=f3c2a669

virtqueue: Sanity-check the length of indirect descriptors.

We were previously allowing arbitrarily-long descriptors, which could lead to a
buffer overflow in the qemu-kvm process.

---
 hw/virtio.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/hw/virtio.c b/hw/virtio.c
index 31bd9e3..1ad8573 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -336,6 +336,11 @@ int virtqueue_avail_bytes(VirtQueue *vq, int in_bytes, int out_bytes)
             max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
             num_bufs = i = 0;
             desc_pa = vring_desc_addr(desc_pa, i);
+
+            if (max > VIRTQUEUE_MAX_SIZE) {
+                error_report("Too-large indirect descriptor");
+                exit(1);
+            }
         }
 
         do {
@@ -406,6 +411,11 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem)
         max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc);
         desc_pa = vring_desc_addr(desc_pa, i);
         i = 0;
+
+        if (max > VIRTQUEUE_MAX_SIZE) {
+            error_report("Too-large indirect descriptor");
+            exit(1);
+        }
     }
 
     /* Collect all the descriptors */



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

end of thread, other threads:[~2011-07-26 17:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-21 20:22 [gentoo-commits] proj/qemu-kvm:qemu-kvm-0.14.1-gentoo commit in: hw/ Doug Goldstein
  -- strict thread matches above, loose matches on Subject: below --
2011-07-26 17:16 Doug Goldstein
2011-07-21 20:19 Doug Goldstein
2011-07-21 20:19 Doug Goldstein

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox