From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=34096 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PB4BT-0006mu-GB for qemu-devel@nongnu.org; Wed, 27 Oct 2010 07:31:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PB49K-0005vW-Oi for qemu-devel@nongnu.org; Wed, 27 Oct 2010 07:28:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PB49K-0005v2-H0 for qemu-devel@nongnu.org; Wed, 27 Oct 2010 07:26:34 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9RBQWPG015794 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Oct 2010 07:26:33 -0400 Date: Wed, 27 Oct 2010 15:26:04 +0200 From: "Michael S. Tsirkin" Subject: Re: [Qemu-devel] Re: [PATCH] vhost-net: Do not set features for backend when peer was deleted Message-ID: <20101027132604.GB2376@redhat.com> References: <20101026164351.12358.73838.stgit@localhost6.localdomain6> <20101026172213.GA16645@redhat.com> <19655.52676.208132.158098@gargle.gargle.HOWL> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <19655.52676.208132.158098@gargle.gargle.HOWL> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: qemu-devel@nongnu.org On Wed, Oct 27, 2010 at 02:59:16PM +0800, Jason Wang wrote: > Michael S. Tsirkin writes: > > On Wed, Oct 27, 2010 at 12:43:51AM +0800, Jason Wang wrote: > > > When hot-unplug a virtio nic with vhost-net backend, guest may > > > continue to program the nic even if its peer have been deleted. We can > > > not set features at this time as vhost_net_ack_features() may still > > > try to use the tap related vhost_net structure which have been freed > > > in tap_cleanup(). And setting offload features for a deleted backend > > > is also meaningless in this situation > > > > > > Signed-off-by: Jason Wang > > > > Hmm. Actually, this is not enough. > > We really must stop and cleanup vhost net. > > > > But this patch just prevent the guest from programming a nic with its > vhost-net backend deleted. The vhost net was still stopped and cleaned > when the peer have been removed. No, I think it was cleanup but not stopped first. E.g. try to migrate at this point and see it crash. I suspect we also leak fds for notifiers and what not. > > Two issues are > > 1. vhost_net_stop needs virtio device pointer > > 2. virtio net has a vhost_started flag > > > > Two ways to fix it that I see: > > 1. add a callback in nic and invoke when peer_deleted is set > > 2. add vhost_started and virtio device pointers in vhost > > > > Path 1 seems easier ... > > > > MST > > > > > --- > > > hw/virtio-net.c | 3 +++ > > > 1 files changed, 3 insertions(+), 0 deletions(-) > > > > > > diff --git a/hw/virtio-net.c b/hw/virtio-net.c > > > index 7e1688c..68c8e48 100644 > > > --- a/hw/virtio-net.c > > > +++ b/hw/virtio-net.c > > > @@ -245,6 +245,9 @@ static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features) > > > { > > > VirtIONet *n = to_virtio_net(vdev); > > > > > > + if (n->nic->peer_deleted) > > > + return; > > > + > > > n->mergeable_rx_bufs = !!(features & (1 << VIRTIO_NET_F_MRG_RXBUF)); > > > > > > if (n->has_vnet_hdr) { > >