From nobody Mon Feb 9 11:30:42 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635351454801940.1609260410605; Wed, 27 Oct 2021 09:17:34 -0700 (PDT) Received: from localhost ([::1]:40602 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mflcL-0001TE-Jw for importer@patchew.org; Wed, 27 Oct 2021 12:17:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfl6K-000509-DZ for qemu-devel@nongnu.org; Wed, 27 Oct 2021 11:44:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mfl6G-00044v-Ur for qemu-devel@nongnu.org; Wed, 27 Oct 2021 11:44:28 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-MRiciOYGPKOo1zh4m4nXdw-1; Wed, 27 Oct 2021 11:44:20 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B2BC2100CCC5; Wed, 27 Oct 2021 15:44:19 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 819B26A904; Wed, 27 Oct 2021 15:44:08 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 19F9A11380AA; Wed, 27 Oct 2021 17:44:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635349464; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KL956w+yp3eR386KeAsK0GFBU7bupGQLvSnSu6w2Ivw=; b=VISPBUHTBz65SAdCQiQ5ymus05uIzU685tVttq4UVSlLXsMN5GugJPcn+CX8RSxOQslqP1 truS2fwQQ3nc8YkgMpmD0ya1zi73bqAA4Rno5BN9v5jC/UX4Y1S3kxnGHCsKJPDvba8yAy 55JYumtME/HBuVzBHuwSi2JBWKgdbdk= X-MC-Unique: MRiciOYGPKOo1zh4m4nXdw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PULL 1/5] qapi: Improve input_type_enum()'s error message Date: Wed, 27 Oct 2021 17:44:03 +0200 Message-Id: <20211027154407.214122-2-armbru@redhat.com> In-Reply-To: <20211027154407.214122-1-armbru@redhat.com> References: <20211027154407.214122-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , richard.henderson@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1635351456373100001 The error message claims the parameter is invalid: $ qemu-system-x86_64 -object qom-type=3Dnonexistent qemu-system-x86_64: -object qom-type=3Dnonexistent: Invalid parameter '= nonexistent' What's wrong is actually the *value* 'nonexistent'. Improve the message to qemu-system-x86_64: -object qom-type=3Dnonexistent: Parameter 'qom-type= ' does not accept value 'nonexistent' Fixes: https://gitlab.com/qemu-project/qemu/-/issues/608 Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20211020180231.434071-1-armbru@redhat.com> Reviewed-by: Kevin Wolf --- qapi/qapi-visit-core.c | 3 ++- tests/unit/check-qom-proplist.c | 2 +- tests/qemu-iotests/049.out | 6 +++--- tests/qemu-iotests/206.out | 2 +- tests/qemu-iotests/237.out | 6 +++--- tests/qemu-iotests/245 | 2 +- tests/qemu-iotests/287 | 2 +- tests/qemu-iotests/308 | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index a641adec51..7310f0a0ca 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -392,7 +392,8 @@ static bool input_type_enum(Visitor *v, const char *nam= e, int *obj, =20 value =3D qapi_enum_parse(lookup, enum_str, -1, NULL); if (value < 0) { - error_setg(errp, QERR_INVALID_PARAMETER, enum_str); + error_setg(errp, "Parameter '%s' does not accept value '%s'", + name ? name : "null", enum_str); g_free(enum_str); return false; } diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplis= t.c index 48503e0dff..ed341088d3 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -488,7 +488,7 @@ static void test_dummy_badenum(void) g_assert(dobj =3D=3D NULL); g_assert(err !=3D NULL); g_assert_cmpstr(error_get_pretty(err), =3D=3D, - "Invalid parameter 'yeti'"); + "Parameter 'av' does not accept value 'yeti'"); =20 g_assert(object_resolve_path_component(parent, "dummy0") =3D=3D NULL); diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index 01f7b1f240..8719c91b48 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -174,11 +174,11 @@ Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_si= ze=3D65536 extended_l2=3Doff comp =20 qemu-img create -f qcow2 -o compat=3D0.42 TEST_DIR/t.qcow2 64M Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 extended_l= 2=3Doff compression_type=3Dzlib size=3D67108864 compat=3D0.42 lazy_refcount= s=3Doff refcount_bits=3D16 -qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42' +qemu-img: TEST_DIR/t.qcow2: Parameter 'version' does not accept value '0.4= 2' =20 qemu-img create -f qcow2 -o compat=3Dfoobar TEST_DIR/t.qcow2 64M Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 extended_l= 2=3Doff compression_type=3Dzlib size=3D67108864 compat=3Dfoobar lazy_refcou= nts=3Doff refcount_bits=3D16 -qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar' +qemu-img: TEST_DIR/t.qcow2: Parameter 'version' does not accept value 'foo= bar' =20 =3D=3D Check preallocation option =3D=3D =20 @@ -190,7 +190,7 @@ Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size= =3D65536 extended_l2=3Doff prea =20 qemu-img create -f qcow2 -o preallocation=3D1234 TEST_DIR/t.qcow2 64M Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 cluster_size=3D65536 extended_l= 2=3Doff preallocation=3D1234 compression_type=3Dzlib size=3D67108864 lazy_r= efcounts=3Doff refcount_bits=3D16 -qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234' +qemu-img: TEST_DIR/t.qcow2: Parameter 'preallocation' does not accept valu= e '1234' =20 =3D=3D Check encryption option =3D=3D =20 diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out index b68c443867..3593e8e9c2 100644 --- a/tests/qemu-iotests/206.out +++ b/tests/qemu-iotests/206.out @@ -192,7 +192,7 @@ Job failed: Could not resize image: Failed to grow the = L1 table: File too large =20 =3D=3D=3D Invalid version =3D=3D=3D {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "qcow2", "file": "node0", "size": 67108864, "version": "v1"}}} -{"error": {"class": "GenericError", "desc": "Invalid parameter 'v1'"}} +{"error": {"class": "GenericError", "desc": "Parameter 'version' does not = accept value 'v1'"}} =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"driver": "qcow2", "file": "node0", "lazy-refcounts": true, "size": 671088= 64, "version": "v2"}}} {"return": {}} diff --git a/tests/qemu-iotests/237.out b/tests/qemu-iotests/237.out index aa94986803..2f09ff5512 100644 --- a/tests/qemu-iotests/237.out +++ b/tests/qemu-iotests/237.out @@ -116,13 +116,13 @@ Job failed: Cannot find device=3D'this doesn't exist'= nor node-name=3D'this doesn't =3D=3D Invalid adapter types =3D=3D =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"adapter-type": "foo", "driver": "vmdk", "file": "node0", "size": 33554432= }}} -{"error": {"class": "GenericError", "desc": "Invalid parameter 'foo'"}} +{"error": {"class": "GenericError", "desc": "Parameter 'adapter-type' does= not accept value 'foo'"}} =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"adapter-type": "IDE", "driver": "vmdk", "file": "node0", "size": 33554432= }}} -{"error": {"class": "GenericError", "desc": "Invalid parameter 'IDE'"}} +{"error": {"class": "GenericError", "desc": "Parameter 'adapter-type' does= not accept value 'IDE'"}} =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"adapter-type": "legacyesx", "driver": "vmdk", "file": "node0", "size": 33= 554432}}} -{"error": {"class": "GenericError", "desc": "Invalid parameter 'legacyesx'= "}} +{"error": {"class": "GenericError", "desc": "Parameter 'adapter-type' does= not accept value 'legacyesx'"}} =20 {"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": = {"adapter-type": 1, "driver": "vmdk", "file": "node0", "size": 33554432}}} {"error": {"class": "GenericError", "desc": "Invalid parameter type for 'o= ptions.adapter-type', expected: string"}} diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245 index 9b12b42eed..24ac43f70e 100755 --- a/tests/qemu-iotests/245 +++ b/tests/qemu-iotests/245 @@ -149,7 +149,7 @@ class TestBlockdevReopen(iotests.QMPTestCase): self.reopen(opts, {'node-name': ''}, "Failed to find node with nod= e-name=3D''") self.reopen(opts, {'node-name': None}, "Invalid parameter type for= 'options[0].node-name', expected: string") self.reopen(opts, {'driver': 'raw'}, "Cannot change the option 'dr= iver'") - self.reopen(opts, {'driver': ''}, "Invalid parameter ''") + self.reopen(opts, {'driver': ''}, "Parameter 'driver' does not acc= ept value ''") self.reopen(opts, {'driver': None}, "Invalid parameter type for 'o= ptions[0].driver', expected: string") self.reopen(opts, {'file': 'not-found'}, "Cannot find device=3D'' = nor node-name=3D'not-found'") self.reopen(opts, {'file': ''}, "Cannot find device=3D'' nor node-= name=3D''") diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287 index 22ce9ff0e4..2d5334e8bf 100755 --- a/tests/qemu-iotests/287 +++ b/tests/qemu-iotests/287 @@ -53,7 +53,7 @@ CLUSTER_SIZE=3D65536 =20 # Check if we can run this test. output=3D$(_make_test_img -o 'compression_type=3Dzstd' 64M; _cleanup_test_= img) -if echo "$output" | grep -q "Invalid parameter 'zstd'"; then +if echo "$output" | grep -q "Parameter 'compression-type' does not accept = value 'zstd'"; then _notrun "ZSTD is disabled" fi =20 diff --git a/tests/qemu-iotests/308 b/tests/qemu-iotests/308 index 6b386bd523..2e3f8f4282 100755 --- a/tests/qemu-iotests/308 +++ b/tests/qemu-iotests/308 @@ -148,7 +148,7 @@ rmdir "$EXT_MP" 2>/dev/null rm -f "$EXT_MP" output=3D$(fuse_export_add 'export-err' "'mountpoint': '$EXT_MP'" error) =20 -if echo "$output" | grep -q "Invalid parameter 'fuse'"; then +if echo "$output" | grep -q "Parameter 'type' does not accept value 'fuse'= "; then _notrun 'No FUSE support' fi =20 --=20 2.31.1