From nobody Sun Apr 28 12:59:49 2024 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 16347532771085.700016677979079; Wed, 20 Oct 2021 11:07:57 -0700 (PDT) Received: from localhost ([::1]:35844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mdG0J-0002xS-Vp for importer@patchew.org; Wed, 20 Oct 2021 14:07:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdFvH-0005VT-TZ for qemu-devel@nongnu.org; Wed, 20 Oct 2021 14:02:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42772) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mdFvD-0001q0-AH for qemu-devel@nongnu.org; Wed, 20 Oct 2021 14:02:41 -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-162-RroXKA7AMt67SdjXShnOpQ-1; Wed, 20 Oct 2021 14:02:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53739806668; Wed, 20 Oct 2021 18:02:33 +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 F13A3ADCD; Wed, 20 Oct 2021 18:02:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 80B8B11380A7; Wed, 20 Oct 2021 20:02:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634752957; 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; bh=qzOXBxLCYJpjtssZ+9RTI0mGEjGG71mElYTKjYL6U2w=; b=a3BelmKI5FYXPk6zwfSSdYANiwdxaMXgjkdyqge+dI/y2Zg1/cxF+Kfjv2G35eg7pdw4LO RRsW5Jc+40pxOTjUzQQInYjSHDNYDHgd1wJztW4tdV4aTC70uik1/yZAKkRmEkdtNKmH8a 67fjM9HwgOTZVaY8HACqbYqbGe+hjGI= X-MC-Unique: RroXKA7AMt67SdjXShnOpQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Subject: [PATCH v2] qapi: Improve input_type_enum()'s error message Date: Wed, 20 Oct 2021 20:02:31 +0200 Message-Id: <20211020180231.434071-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: kwolf@redhat.com, berrange@redhat.com, ehabkost@redhat.com, michael.roth@amd.com, hreitz@redhat.com, pbonzini@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= 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: 1634753279257100001 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' Signed-off-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v2: iotests 287 and 308 updated [Kevin] 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