From patchwork Tue Oct 26 16:43:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 69290 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EF3A4B70D1 for ; Wed, 27 Oct 2010 07:13:11 +1100 (EST) Received: from localhost ([127.0.0.1]:60536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAnj2-0006Py-8T for incoming@patchwork.ozlabs.org; Tue, 26 Oct 2010 13:54:20 -0400 Received: from [140.186.70.92] (port=44654 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAngi-00056W-QY for qemu-devel@nongnu.org; Tue, 26 Oct 2010 13:53:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAng2-0006zt-NR for qemu-devel@nongnu.org; Tue, 26 Oct 2010 13:51:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33731) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAng2-0006zd-Go for qemu-devel@nongnu.org; Tue, 26 Oct 2010 13:51:14 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9QHp9sQ030898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Oct 2010 13:51:12 -0400 Received: from localhost6.localdomain6 (vpn-227-200.phx2.redhat.com [10.3.227.200]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9QGhqVY031291; Tue, 26 Oct 2010 12:43:53 -0400 To: mst@redhat.com From: Jason Wang Date: Wed, 27 Oct 2010 00:43:51 +0800 Message-ID: <20101026164351.12358.73838.stgit@localhost6.localdomain6> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] vhost-net: Do not set features for backend when peer was deleted X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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) {