Received: from eggs.gnu.org ([2001:4830:134:3::10]:48443) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNLkI-0000mw-H5 for qemu-devel@nongnu.org; Tue, 11 Mar 2014 08:25:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WNLkE-0004Sk-5w for qemu-devel@nongnu.org; Tue, 11 Mar 2014 08:25:22 -0400 Received: from mail-ee0-x234.google.com ([2a00:1450:4013:c00::234]:54784) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WNLkD-0004SN-Ug for qemu-devel@nongnu.org; Tue, 11 Mar 2014 08:25:18 -0400 Received: by mail-ee0-f52.google.com with SMTP id e49so3694063eek.39 for ; Tue, 11 Mar 2014 05:25:17 -0700 (PDT) Date: Tue, 11 Mar 2014 13:25:14 +0100 From: Stefan Hajnoczi Message-ID: <20140311122514.GB7470@stefanha-thinkpad.redhat.com> References: <1394290843-18635-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1394290843-18635-1-git-send-email-stefanha@redhat.com> Subject: Re: [Qemu-devel] [PATCH] tap: avoid deadlocking rx List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, "Dr. David Alan Gilbert" On Sat, Mar 08, 2014 at 04:00:43PM +0100, Stefan Hajnoczi wrote: > The net subsystem has a control flow mechanism so peer NetClientStates > can tell each other to stop sending packets. This is used to stop > monitoring the tap file descriptor for incoming packets if the guest rx > ring has no spare buffers. > > There is a corner case when tap_can_send() is true at the beginning of > an event loop iteration but becomes false before the tap_send() fd > handler is invoked. > > tap_send() will read the packet from the tap file descriptor and attempt > to send it. The net queue will hold on to the packet and return 0, > indicating that further I/O is not possible. tap then stops monitoring > the file descriptor for reads. > > This is unlike the normal case where tap_can_send() is the same before > and during the event loop iteration. The event loop would simply not > monitor the file descriptor if tap_can_send() returns true. Upon next > iteration it would check tap_can_send() again and begin monitoring if we > can send. > > The deadlock happens because tap_send() explicitly disabled read_poll. > This is done with the expectation that the peer will call > qemu_net_queue_flush(). But hw/net/virtio-net.c does not monitor > vm_running transitions and issue the flush. Hence we're left with a > broken tap device. > > Cc: qemu-stable@nongnu.org > Reported-by: Neil Skrypuch > Signed-off-by: Stefan Hajnoczi > --- > net/tap.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) Applied to my net tree: https://github.com/stefanha/qemu/commits/net Stefan