[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/1] virtio: serial: expose a 'guest_writable' c
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 1/1] virtio: serial: expose a 'guest_writable' callback for users |
Date: |
Tue, 30 Sep 2014 17:05:59 +0100 |
On 30 September 2014 17:02, Amit Shah <address@hidden> wrote:
> Users of virtio-serial may want to know when a port becomes writable. A
> port can stop accepting writes if the guest port is open but not being
> read from. In this case, data gets queued up in the virtqueue, and
> after the vq is full, writes to the port do not succeed.
>
> When the guest reads off a vq element, and adds a new one for the host
> to put data in, we can tell users the port is available for more writes,
> via the new ->guest_writable() callback.
>
> Signed-off-by: Amit Shah <address@hidden>
> ---
> hw/char/virtio-serial-bus.c | 23 +++++++++++++++++++++++
> include/hw/virtio/virtio-serial.h | 3 +++
> 2 files changed, 26 insertions(+)
>
> diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
> index 3931085..45f117c 100644
> --- a/hw/char/virtio-serial-bus.c
> +++ b/hw/char/virtio-serial-bus.c
> @@ -465,6 +465,29 @@ static void handle_output(VirtIODevice *vdev, VirtQueue
> *vq)
>
> static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
> {
> + /*
> + * Users of virtio-serial would like to know when guest becomes
> + * writable again -- i.e. if a vq had stuff queued up and the
> + * guest wasn't reading at all, the host would not be able to
> + * write to the vq anymore. Once the guest reads off something,
> + * we can start queueing things up again.
> + */
> + VirtIOSerial *vser;
> + VirtIOSerialPort *port;
> + VirtIOSerialPortClass *vsc;
> +
> + vser = VIRTIO_SERIAL(vdev);
> + port = find_port_by_vq(vser, vq);
We need to check for port being NULL here, right?
> + vsc = VIRTIO_SERIAL_PORT_GET_CLASS(port);
thanks
-- PMM