Amit Shah <amit.s...@redhat.com> writes: > To discard throttled data as well as maintain statistics of bytes > received and discarded, discard_vq_data() will need the port associated > with the vq. > > Signed-off-by: Amit Shah <amit.s...@redhat.com> > --- > hw/virtio-serial-bus.c | 9 +++++---- > 1 files changed, 5 insertions(+), 4 deletions(-) > > diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c > index a4825b9..6838d73 100644 > --- a/hw/virtio-serial-bus.c > +++ b/hw/virtio-serial-bus.c > @@ -114,7 +114,8 @@ static size_t write_to_port(VirtIOSerialPort *port, > return offset; > } > > -static void discard_vq_data(VirtQueue *vq, VirtIODevice *vdev) > +static void discard_vq_data(VirtIOSerialPort *port, VirtQueue *vq, > + VirtIODevice *vdev) > { > VirtQueueElement elem; >
Two of three callers pass port, port->ovq, &port->vser->vdev. Third one isn't as obvious, but could be the same (didn't check thoroughly). Makes me wonder whether parameters vq and vdev are really needed. > @@ -248,7 +249,7 @@ int virtio_serial_close(VirtIOSerialPort *port) > * consume, reset the throttling flag and discard the data. > */ > port->throttled = false; > - discard_vq_data(port->ovq, &port->vser->vdev); > + discard_vq_data(port, port->ovq, &port->vser->vdev); > > send_control_event(port, VIRTIO_CONSOLE_PORT_OPEN, 0); > > @@ -473,7 +474,7 @@ static void handle_output(VirtIODevice *vdev, VirtQueue > *vq) > info = port ? DO_UPCAST(VirtIOSerialPortInfo, qdev, port->dev.info) : > NULL; > > if (!port || !port->host_connected || !info->have_data) { > - discard_vq_data(vq, vdev); > + discard_vq_data(port, vq, vdev); > return; > } > > @@ -730,7 +731,7 @@ static void remove_port(VirtIOSerial *vser, uint32_t > port_id) > > port = find_port_by_id(vser, port_id); > /* Flush out any unconsumed buffers first */ > - discard_vq_data(port->ovq, &port->vser->vdev); > + discard_vq_data(port, port->ovq, &port->vser->vdev); > > send_control_event(port, VIRTIO_CONSOLE_PORT_REMOVE, 1); > }