diff options
author | Amit Shah | 2012-09-24 20:35:16 +0200 |
---|---|---|
committer | Michael S. Tsirkin | 2012-09-28 12:16:27 +0200 |
commit | ad3005ad8c70a69705149d3ce6d1e51fb76edb15 (patch) | |
tree | 2db5b511c56f2e04ae2aa73adb6717d4ce1817d8 /hw | |
parent | virtio: Introduce virtqueue_get_avail_bytes() (diff) | |
download | qemu-ad3005ad8c70a69705149d3ce6d1e51fb76edb15.tar.gz qemu-ad3005ad8c70a69705149d3ce6d1e51fb76edb15.tar.xz qemu-ad3005ad8c70a69705149d3ce6d1e51fb76edb15.zip |
virtio-serial-bus: let chardev know the exact number of bytes requested
Using the virtqueue_avail_bytes() function had an unnecessarily
crippling effect on the number of bytes needed by the guest as reported
to the chardev layer in the can_read() callback.
Using the new virtqueue_get_avail_bytes() function will let us advertise
the exact number of bytes we can send to the guest.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/virtio-serial-bus.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 82073f5dc2..d20bd8bf75 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -287,6 +287,7 @@ ssize_t virtio_serial_write(VirtIOSerialPort *port, const uint8_t *buf, size_t virtio_serial_guest_ready(VirtIOSerialPort *port) { VirtQueue *vq = port->ivq; + unsigned int bytes; if (!virtio_queue_ready(vq) || !(port->vser->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK) || @@ -296,14 +297,8 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port) if (use_multiport(port->vser) && !port->guest_connected) { return 0; } - - if (virtqueue_avail_bytes(vq, 4096, 0)) { - return 4096; - } - if (virtqueue_avail_bytes(vq, 1, 0)) { - return 1; - } - return 0; + virtqueue_get_avail_bytes(vq, &bytes, NULL); + return bytes; } static void flush_queued_data_bh(void *opaque) |