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: 49533 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4100F24612 for ; Thu, 4 Jun 2015 16:20:59 +0000 (UTC) Received: by wibbk2 with SMTP id bk2sf14968875wib.2 for ; Thu, 04 Jun 2015 09:20:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=wgNYlGewRU/96Rqd9nbd6nkrqCWHa2WVTUSGUPpZtxQ=; b=NO7bxoKRsri8uhROtSFYz8eBh8rBUrkPZAkoybZ1dgmxH613K7s/oDwHPAXA5hEPqQ H1+DR7VddF9V1jwlO4tvjExvGDLOcjEkTetSIXDTZlU6fBIY0wLZ/AQy3Fp4h+2x+tgr BfkiLxg6bd0PO1PrsBzr1bNrVUAoQeIHIVEQWjqNh+Hr+l2E/SSJTfxaw2u8g4zpgYg+ TH/KnlXYlrhXLSf+FJg1JhoP4+cQxcwgwnw/wJiN+HuqA/iOTPdXvG6HhW38fCqoKo7T Rx5NIDLGyeluVJIKif5z6+gU6ezvvJB2ekBtxwQfQenv+xrLsFPY7SLsbKuNixTBTvns MQbA== X-Gm-Message-State: ALoCoQnZgzo4xf+wFf+OCHLRuQGrs7RORvFLeISRsauZNxLdywKK0uTweHd8za7ke4C6jqJFiFaW X-Received: by 10.112.13.200 with SMTP id j8mr36084898lbc.14.1433434858497; Thu, 04 Jun 2015 09:20:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.138 with SMTP id am10ls202073lac.67.gmail; Thu, 04 Jun 2015 09:20:58 -0700 (PDT) X-Received: by 10.152.18.163 with SMTP id x3mr31920607lad.70.1433434858358; Thu, 04 Jun 2015 09:20:58 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id h8si2261393lbc.56.2015.06.04.09.20.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2015 09:20:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lbcmx3 with SMTP id mx3so30523801lbc.1 for ; Thu, 04 Jun 2015 09:20:58 -0700 (PDT) X-Received: by 10.112.140.231 with SMTP id rj7mr38092838lbb.76.1433434858229; Thu, 04 Jun 2015 09:20:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp729063lbb; Thu, 4 Jun 2015 09:20:57 -0700 (PDT) X-Received: by 10.194.143.4 with SMTP id sa4mr1267809wjb.22.1433434856115; Thu, 04 Jun 2015 09:20:56 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id zb2si8139814wjc.128.2015.06.04.09.20.55 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 04 Jun 2015 09:20:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; 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 Cc: patches@linaro.org, Markus Armbruster , Kevin Wolf , qemu-block@nongnu.org, Christian Borntraeger , Cornelia Huck , Alexander Graf Subject: [PATCH 2/4] blockdev: Don't call create_implicit_virtio_device() when it has no effect 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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); }