From patchwork Tue Jun 23 14:01:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 50224 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B5FC21575 for ; Tue, 23 Jun 2015 14:01:51 +0000 (UTC) Received: by lbcui10 with SMTP id ui10sf3183052lbc.0 for ; Tue, 23 Jun 2015 07:01:50 -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=+geRPlhcCf24zfqpJkEtq6FEoB+mYN1d1fB+D5PvbVU=; b=b2KMq5cZEl6IuFGxFqrjXpYFIe5VYYusFIAeA2QisqzCCoUjoCHjito48ANyTGTAUQ sILj97W0eoeNZzbqGxoJvLUKsiM55QfTIVGJf8pEPFM9TOK3WXxHHNOUOO9OgGszjW1C 070DUTxtt6WnlEiyhhKvXNconzUHkAP/nFeqHDIMIMZT0peZ+7mlL5bg+apBlroTUrvz cUmV7t0SEVq0Gw39DOxFbpYC+eVj16XfyFFn7bjSXF30lKjXDIHY5FhRzB92PXa2k0C7 NpcOxbx8yj0jNdw0pRcCvZmk607Sk9lp99hmQS+hCjk5j2UP4ZUqnXISgW6gmRVbDDAX TN/w== X-Gm-Message-State: ALoCoQmwhHV8Sa3r+Kr4Uy5Lsu54iAES8vgwY+YMqUaXYtTQfBbMCGQs1lKkHlybzMKYMiwAmYMf X-Received: by 10.112.189.131 with SMTP id gi3mr32167619lbc.6.1435068110467; Tue, 23 Jun 2015 07:01:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.71 with SMTP id la7ls50639lab.25.gmail; Tue, 23 Jun 2015 07:01:50 -0700 (PDT) X-Received: by 10.112.30.133 with SMTP id s5mr35807663lbh.31.1435068110312; Tue, 23 Jun 2015 07:01:50 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id i6si19369923laa.144.2015.06.23.07.01.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jun 2015 07:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by lagx9 with SMTP id x9so7236762lag.1 for ; Tue, 23 Jun 2015 07:01:50 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr34517694lbc.41.1435068110200; Tue, 23 Jun 2015 07:01:50 -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 hn6csp3096819lbb; Tue, 23 Jun 2015 07:01:49 -0700 (PDT) X-Received: by 10.180.106.137 with SMTP id gu9mr3911244wib.54.1435068109295; Tue, 23 Jun 2015 07:01:49 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id fj6si26019599wib.55.2015.06.23.07.01.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 23 Jun 2015 07:01:49 -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 1Z7Oln-0003Hj-Fi; Tue, 23 Jun 2015 15:01:47 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Markus Armbruster , Kevin Wolf , qemu-block@nongnu.org Subject: [PATCH v2 for-2.4 2/3] qdev-properties-system: Improve error message for drive assignment conflict Date: Tue, 23 Jun 2015 15:01:46 +0100 Message-Id: <1435068107-12594-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1435068107-12594-1-git-send-email-peter.maydell@linaro.org> References: <1435068107-12594-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.215.43 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: , If the user forgot if=none on their drive specification they're likely to get an error message because the drive is assigned once automatically by QEMU and once by the manual id=/drive= user command line specification. Improve the error message produced in this case to explicitly guide the user towards if=none. We rephrase the "drive conflict but not for an if=something" error as well to keep the wording in line. The two cases that change are: (1) Drive specified as to be auto-connected and also manually connected (and the board does handle this if= type): qemu-system-x86_64 -nodefaults -display none \ -drive if=scsi,file=tmp.qcow2,id=foo -device ide-hd,drive=foo Previously: qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive' can't take value 'foo', it's in use Now: qemu-system-x86_64: -device ide-hd,drive=foo: Drive 'foo' is already in use because it has been automatically connected to another device (did you need 'if=none' in the drive options?) (2) Drive specified to be manually connected in two different ways: qemu-system-x86_64 -nodefaults -display none \ -drive if=none,file=tmp.qcow2,id=foo -device ide-hd,drive=foo \ -device ide-hd,drive=foo Previously: qemu-system-x86_64: -device ide-hd,drive=foo: Property 'ide-hd.drive' can't take value 'foo', it's in use Now: qemu-system-x86_64: -device ide-hd,drive=foo: Drive 'foo' is already in use by another device Signed-off-by: Peter Maydell --- hw/core/qdev-properties-system.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c index 56954b4..820cd14 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -78,8 +78,17 @@ static void parse_drive(DeviceState *dev, const char *str, void **ptr, return; } if (blk_attach_dev(blk, dev) < 0) { - error_setg(errp, "Property '%s.%s' can't take value '%s', it's in use", - object_get_typename(OBJECT(dev)), propname, str); + DriveInfo *dinfo = blk_legacy_dinfo(blk); + + if (dinfo->type != IF_NONE) { + error_setg(errp, "Drive '%s' is already in use because " + "it has been automatically connected to another " + "device (did you need 'if=none' in the drive options?)", + str); + } else { + error_setg(errp, "Drive '%s' is already in use by another device", + str); + } return; } *ptr = blk;