Received: from eggs.gnu.org ([140.186.70.92]:46882) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3oxY-0007Ti-Ta for qemu-devel@nongnu.org; Wed, 14 Sep 2011 08:53:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3oxS-0007nc-L1 for qemu-devel@nongnu.org; Wed, 14 Sep 2011 08:53:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60730) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3oxS-0007nP-8j for qemu-devel@nongnu.org; Wed, 14 Sep 2011 08:52:54 -0400 From: Markus Armbruster References: <6e1dec08756974efdcc495462e620249c53bd1b5.1315985199.git.amit.shah@redhat.com> Date: Wed, 14 Sep 2011 14:52:50 +0200 In-Reply-To: <6e1dec08756974efdcc495462e620249c53bd1b5.1315985199.git.amit.shah@redhat.com> (Amit Shah's message of "Wed, 14 Sep 2011 12:59:05 +0530") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 1/3] virtio-serial-bus: add port arg to discard_vq_data() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Amit Shah Cc: qemu list , Juan Quintela Amit Shah 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 > --- > 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); > }