From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH 2/3] kvm: qemu: handle link status in qemu_sendv_packet() Date: Tue, 09 Dec 2008 08:57:33 -0600 Message-ID: <493E875D.3010803@codemonkey.ws> References: <> <1228821613-28724-1-git-send-email-markmc@redhat.com> <1228821613-28724-2-git-send-email-markmc@redhat.com> <1228821613-28724-3-git-send-email-markmc@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm@vger.kernel.org, Rusty Russell To: Mark McLoughlin Return-path: Received: from an-out-0708.google.com ([209.85.132.250]:54676 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753122AbYLIO5j (ORCPT ); Tue, 9 Dec 2008 09:57:39 -0500 Received: by an-out-0708.google.com with SMTP id d40so701688and.1 for ; Tue, 09 Dec 2008 06:57:38 -0800 (PST) In-Reply-To: <1228821613-28724-3-git-send-email-markmc@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Mark McLoughlin wrote: > Signed-off-by: Mark McLoughlin > --- > qemu/net.c | 18 +++++++++++++++++- > 1 files changed, 17 insertions(+), 1 deletions(-) > > diff --git a/qemu/net.c b/qemu/net.c > index 16a0990..f23a17f 100644 > --- a/qemu/net.c > +++ b/qemu/net.c > @@ -400,6 +400,17 @@ static ssize_t vc_sendv_compat(VLANClientState *vc, const struct iovec *iov, > return offset; > } > > +static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt) > +{ > + size_t offset = 0; > + int i; > + > + for (i = 0; i < iovcnt; i++) > + offset += iov[i].iov_len; > + > + return offset; > +} > + > ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, > int iovcnt) > { > @@ -407,13 +418,18 @@ ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, > VLANClientState *vc; > ssize_t max_len = 0; > > + if (vc1->link_down) > + return calc_iov_length(iov, iovcnt); > + > for (vc = vlan->first_client; vc != NULL; vc = vc->next) { > ssize_t len = 0; > > if (vc == vc1) > continue; > > - if (vc->fd_readv) > + if (vc->link_down) > + len = calc_iov_length(iov, iovcnt); > Instead of returning a success and silently dropping the packet, maybe it would be better to return an error and let the card deal with dropping the packet. In real hardware, the link down would mean the TX queue would fill up because packets aren't able to be sent. Regards, Anthony Liguori > + else if (vc->fd_readv) > len = vc->fd_readv(vc->opaque, iov, iovcnt); > else if (vc->fd_read) > len = vc_sendv_compat(vc, iov, iovcnt); >