From patchwork Thu Jun 4 16:20:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 480810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B5ED2140218 for ; Fri, 5 Jun 2015 02:23:30 +1000 (AEST) Received: from localhost ([::1]:43263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0XvU-0002cX-EY for incoming@patchwork.ozlabs.org; Thu, 04 Jun 2015 12:23:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0XtE-0006id-Fs for qemu-devel@nongnu.org; Thu, 04 Jun 2015 12:21:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0XtA-0004qc-Bn for qemu-devel@nongnu.org; Thu, 04 Jun 2015 12:21:08 -0400 Received: from mnementh.archaic.org.uk ([81.2.115.146]:56921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0XtA-0004pC-5S for qemu-devel@nongnu.org; Thu, 04 Jun 2015 12:21:04 -0400 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Z0Xsz-00050k-T4; Thu, 04 Jun 2015 17:20:53 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 4 Jun 2015 17:20:51 +0100 Message-Id: <1433434853-19229-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1433434853-19229-1-git-send-email-peter.maydell@linaro.org> References: <1433434853-19229-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 81.2.115.146 Cc: Kevin Wolf , qemu-block@nongnu.org, patches@linaro.org, Markus Armbruster , Alexander Graf , Christian Borntraeger , Cornelia Huck Subject: [Qemu-devel] [PATCH 2/4] blockdev: Don't call create_implicit_virtio_device() when it has no effect 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 create_implicit_virtio_device() just adds a device to the "device" QEMU options list. This means that it only has an effect if it is called before vl.c processes that list to create all the devices. If it is called after that (ie for hotplug drives created from the monitor) then it has no effect. To avoid confusion, don't call the code at all if it isn't going to do anything. Signed-off-by: Peter Maydell --- blockdev.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 9cf6123..177b285 100644 --- a/blockdev.c +++ b/blockdev.c @@ -78,6 +78,11 @@ static int if_max_devs[IF_COUNT] = { [IF_SCSI] = 7, }; +/* True once we've created all the command line drives and run + * drive_check_orphaned(). + */ +static bool done_orphan_check; + /** * Boards may call this to offer board-by-board overrides * of the default, global values. @@ -239,6 +244,8 @@ bool drive_check_orphaned(void) DriveInfo *dinfo; bool rs = false; + done_orphan_check = true; + for (blk = blk_next(NULL); blk; blk = blk_next(blk)) { dinfo = blk_legacy_dinfo(blk); /* If dinfo->bdrv->dev is NULL, it has no device attached. */ @@ -949,7 +956,10 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) goto fail; } - if (type == IF_VIRTIO) { + if (type == IF_VIRTIO && !done_orphan_check) { + /* Drives created via the monitor (hotplugged) do not get the + * magic implicit device created for them. + */ create_implicit_virtio_device(qdict_get_str(bs_opts, "id"), devaddr); }