From patchwork Wed Dec 26 10:52:42 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: 208165 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 A35202C007E for ; Wed, 26 Dec 2012 22:41:59 +1100 (EST) Received: from localhost ([::1]:40460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnoYt-0000Qx-Cl for incoming@patchwork.ozlabs.org; Wed, 26 Dec 2012 05:50:11 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnoYG-0007nm-To for qemu-devel@nongnu.org; Wed, 26 Dec 2012 05:49:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TnoYE-0004fz-2K for qemu-devel@nongnu.org; Wed, 26 Dec 2012 05:49:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:12058) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnoYD-0004fc-Ri for qemu-devel@nongnu.org; Wed, 26 Dec 2012 05:49:30 -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 qBQAnT1W019879 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 26 Dec 2012 05:49:29 -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 qBQAnRB4025982; Wed, 26 Dec 2012 05:49:27 -0500 Date: Wed, 26 Dec 2012 12:52:42 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, asias@redhat.com, stefanha@redhat.com Message-ID: <9cce4f7971df53927ff787635a1b909f79507af6.1356519046.git.mst@redhat.com> 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 7/8] vhost: set started flag while start is in progress 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 This makes it possible to use started flag for sanity checking of callbacks that happen during start/stop. Signed-off-by: Michael S. Tsirkin --- hw/vhost.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index b6d73ca..4fa5007 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -873,6 +873,9 @@ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) { int i, r; + + hdev->started = true; + if (!vdev->binding->set_guest_notifiers) { fprintf(stderr, "binding does not support guest notifiers\n"); r = -ENOSYS; @@ -918,8 +921,6 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) } } - hdev->started = true; - return 0; fail_log: fail_vq: @@ -934,6 +935,8 @@ fail_features: vdev->binding->set_guest_notifiers(vdev->binding_opaque, hdev->nvqs, false); fail_notifiers: fail: + + hdev->started = false; return r; }