From patchwork Wed Dec 26 10:52:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 208162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D80172C00C1 for ; Wed, 26 Dec 2012 22:13:33 +1100 (EST) Received: from localhost ([::1]:41195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnoYx-0000pV-PB for incoming@patchwork.ozlabs.org; Wed, 26 Dec 2012 05:50:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52929) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnoYD-0007cn-9h for qemu-devel@nongnu.org; Wed, 26 Dec 2012 05:49:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TnoYA-0004f6-Sw for qemu-devel@nongnu.org; Wed, 26 Dec 2012 05:49:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12242) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnoYA-0004ez-Lq for qemu-devel@nongnu.org; Wed, 26 Dec 2012 05:49:26 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBQAnQLt019868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 26 Dec 2012 05:49:26 -0500 Received: from redhat.com (vpn1-4-149.ams2.redhat.com [10.36.4.149]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id qBQAnNX4025973; Wed, 26 Dec 2012 05:49:24 -0500 Date: Wed, 26 Dec 2012 12:52:39 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, asias@redhat.com, stefanha@redhat.com Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 6/8] virtio-net: set/clear vhost_started in reverse order X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org As vhost started is cleared last thing on stop, set it first things on start. This makes it possible to use vhost_started while start is in progress which is used by follow-up patches. Signed-off-by: Michael S. Tsirkin --- hw/virtio-net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 5d03b31..b756d57 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -126,12 +126,12 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) if (!vhost_net_query(tap_get_vhost_net(n->nic->nc.peer), &n->vdev)) { return; } + n->vhost_started = 1; r = vhost_net_start(tap_get_vhost_net(n->nic->nc.peer), &n->vdev); if (r < 0) { error_report("unable to start vhost net: %d: " "falling back on userspace virtio", -r); - } else { - n->vhost_started = 1; + n->vhost_started = 0; } } else { vhost_net_stop(tap_get_vhost_net(n->nic->nc.peer), &n->vdev);