From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239146960843.832786225371; Wed, 31 May 2017 06:59:06 -0700 (PDT) Received: from localhost ([::1]:59662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49P-0003n5-9i for importer@patchew.org; Wed, 31 May 2017 09:59:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG47r-0002im-Si for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG47q-0003nB-TN for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53498) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG47q-0003n0-Kg for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 989F880F95 for ; Wed, 31 May 2017 13:57:25 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69C9E7C8A7; Wed, 31 May 2017 13:57:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 989F880F95 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 989F880F95 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:25 +0400 Message-Id: <20170531135709.345-2-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 May 2017 13:57:25 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 01/45] qobject-input-visitor: Reject non-finite numbers with keyval X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster The QObject input visitor can produce only finite numbers when its input comes out of the JSON parser, because the the JSON parser implements RFC 7159, which provides no syntax for infinity and NaN. However, it can produce infinity and NaN when its input comes out of keyval_parse(), because we parse with strtod() then. The keyval variant should not be able to express things the JSON variant can't. Rejecting non-finite numbers there is the conservative fix. It's also minimally invasive. We could instead extend our JSON dialect to provide for infinity and NaN. Not today. Note that the JSON formatter can emit non-finite numbers (marked FIXME in commit 6e8e5cb). Signed-off-by: Markus Armbruster Message-Id: <1495471335-23707-2-git-send-email-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- qapi/qobject-input-visitor.c | 3 ++- tests/test-qobject-input-visitor.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index d0f0002317..eac40f618a 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -13,6 +13,7 @@ */ =20 #include "qemu/osdep.h" +#include #include "qapi/error.h" #include "qapi/qobject-input-visitor.h" #include "qapi/visitor-impl.h" @@ -568,7 +569,7 @@ static void qobject_input_type_number_keyval(Visitor *v= , const char *name, =20 errno =3D 0; *obj =3D strtod(str, &endp); - if (errno || endp =3D=3D str || *endp) { + if (errno || endp =3D=3D str || *endp || !isfinite(*obj)) { /* TODO report -ERANGE more nicely */ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, full_name(qiv, name), "number"); diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index f965743b6e..e2aabbe972 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -278,11 +278,17 @@ static void test_visitor_in_number_str_keyval(TestInp= utVisitorData *data, { double res =3D 0, value =3D 3.14; Visitor *v; + Error *err =3D NULL; =20 v =3D visitor_input_test_init_full(data, true, "\"3.14\""); =20 visit_type_number(v, NULL, &res, &error_abort); g_assert_cmpfloat(res, =3D=3D, value); + + v =3D visitor_input_test_init_full(data, true, "\"inf\""); + + visit_type_number(v, NULL, &res, &err); + error_free_or_abort(&err); } =20 static void test_visitor_in_number_str_fail(TestInputVisitorData *data, --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239358953930.3897638153835; Wed, 31 May 2017 07:02:38 -0700 (PDT) Received: from localhost ([::1]:59683 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Co-0007P4-Ss for importer@patchew.org; Wed, 31 May 2017 10:02:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG47z-0002ns-3O for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG47w-0003ox-GC for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52659) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG47w-0003om-AZ for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4FBF580E79 for ; Wed, 31 May 2017 13:57:31 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 635AA7C8A7; Wed, 31 May 2017 13:57:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4FBF580E79 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4FBF580E79 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:26 +0400 Message-Id: <20170531135709.345-3-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 13:57:31 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 02/45] qapi: Document visit_type_any() issues with keyval input X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster It's already documented in keyval.c (commit 0ee9ae7), but visitor.h can use a note, too. Signed-off-by: Markus Armbruster Message-Id: <1495471335-23707-3-git-send-email-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- include/qapi/visitor.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index b0e233df76..4721c39ae3 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -607,6 +607,10 @@ void visit_type_number(Visitor *v, const char *name, d= ouble *obj, * @obj must be non-NULL. Input visitors set *@obj to the value; * other visitors will leave *@obj unchanged. *@obj must be non-NULL * for output visitors. + * + * Note that some kinds of input can't express arbitrary QObject. + * E.g. the visitor returned by qobject_input_visitor_new_keyval() + * can't create numbers or booleans, only strings. */ void visit_type_any(Visitor *v, const char *name, QObject **obj, Error **e= rrp); =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239167981504.41468829294877; Wed, 31 May 2017 06:59:27 -0700 (PDT) Received: from localhost ([::1]:59663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49l-00045q-5t for importer@patchew.org; Wed, 31 May 2017 09:59:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG484-0002uF-R1 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG482-0003q1-UR for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43064) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG482-0003px-LY for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:38 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A05E2C0467C6 for ; Wed, 31 May 2017 13:57:37 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id A241384AAB; Wed, 31 May 2017 13:57:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A05E2C0467C6 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A05E2C0467C6 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:27 +0400 Message-Id: <20170531135709.345-4-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 31 May 2017 13:57:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 03/45] tests/qapi-schema: Avoid 'str' in alternate test cases X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster The next commit is going to make alternate members of type 'str' conflict with other scalar types. Would break a few test cases that don't actually require 'str'. Flip them from 'str' to 'bool' or 'EnumOne'. Signed-off-by: Markus Armbruster Message-Id: <1495471335-23707-4-git-send-email-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake --- tests/test-clone-visitor.c | 23 +++++----- tests/test-qobject-input-visitor.c | 56 ++++++++++++---------= ---- tests/test-qobject-output-visitor.c | 4 +- tests/qapi-schema/alternate-clash.json | 2 +- tests/qapi-schema/alternate-nested.json | 2 +- tests/qapi-schema/args-alternate.json | 2 +- tests/qapi-schema/doc-bad-alternate-member.json | 2 +- tests/qapi-schema/qapi-schema-test.json | 9 ++-- tests/qapi-schema/qapi-schema-test.out | 30 +++++++------ tests/qapi-schema/returns-alternate.json | 2 +- 10 files changed, 68 insertions(+), 64 deletions(-) diff --git a/tests/test-clone-visitor.c b/tests/test-clone-visitor.c index df0c045512..96982163e4 100644 --- a/tests/test-clone-visitor.c +++ b/tests/test-clone-visitor.c @@ -42,29 +42,28 @@ static void test_clone_struct(void) =20 static void test_clone_alternate(void) { - AltStrBool *b_src, *s_src, *b_dst, *s_dst; + AltEnumBool *b_src, *s_src, *b_dst, *s_dst; =20 - b_src =3D g_new0(AltStrBool, 1); + b_src =3D g_new0(AltEnumBool, 1); b_src->type =3D QTYPE_QBOOL; b_src->u.b =3D true; - s_src =3D g_new0(AltStrBool, 1); + s_src =3D g_new0(AltEnumBool, 1); s_src->type =3D QTYPE_QSTRING; - s_src->u.s =3D g_strdup("World"); + s_src->u.e =3D ENUM_ONE_VALUE1; =20 - b_dst =3D QAPI_CLONE(AltStrBool, b_src); + b_dst =3D QAPI_CLONE(AltEnumBool, b_src); g_assert(b_dst); g_assert_cmpint(b_dst->type, =3D=3D, b_src->type); g_assert_cmpint(b_dst->u.b, =3D=3D, b_src->u.b); - s_dst =3D QAPI_CLONE(AltStrBool, s_src); + s_dst =3D QAPI_CLONE(AltEnumBool, s_src); g_assert(s_dst); g_assert_cmpint(s_dst->type, =3D=3D, s_src->type); - g_assert_cmpstr(s_dst->u.s, =3D=3D, s_src->u.s); - g_assert(s_dst->u.s !=3D s_src->u.s); + g_assert_cmpint(s_dst->u.e, =3D=3D, s_src->u.e); =20 - qapi_free_AltStrBool(b_src); - qapi_free_AltStrBool(s_src); - qapi_free_AltStrBool(b_dst); - qapi_free_AltStrBool(s_dst); + qapi_free_AltEnumBool(b_src); + qapi_free_AltEnumBool(s_src); + qapi_free_AltEnumBool(b_dst); + qapi_free_AltEnumBool(s_dst); } =20 static void test_clone_native_list(void) diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index e2aabbe972..6b997a177d 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -537,10 +537,10 @@ static void test_visitor_in_alternate(TestInputVisito= rData *data, g_assert_cmpint(tmp->u.i, =3D=3D, 42); qapi_free_UserDefAlternate(tmp); =20 - v =3D visitor_input_test_init(data, "'string'"); + v =3D visitor_input_test_init(data, "'value1'"); visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort); g_assert_cmpint(tmp->type, =3D=3D, QTYPE_QSTRING); - g_assert_cmpstr(tmp->u.s, =3D=3D, "string"); + g_assert_cmpint(tmp->u.e, =3D=3D, ENUM_ONE_VALUE1); qapi_free_UserDefAlternate(tmp); =20 v =3D visitor_input_test_init(data, "{'integer':1, 'string':'str', " @@ -565,10 +565,10 @@ static void test_visitor_in_alternate(TestInputVisito= rData *data, g_assert_cmpint(wrap->alt->u.i, =3D=3D, 42); qapi_free_WrapAlternate(wrap); =20 - v =3D visitor_input_test_init(data, "{ 'alt': 'string' }"); + v =3D visitor_input_test_init(data, "{ 'alt': 'value1' }"); visit_type_WrapAlternate(v, NULL, &wrap, &error_abort); g_assert_cmpint(wrap->alt->type, =3D=3D, QTYPE_QSTRING); - g_assert_cmpstr(wrap->alt->u.s, =3D=3D, "string"); + g_assert_cmpint(wrap->alt->u.e, =3D=3D, ENUM_ONE_VALUE1); qapi_free_WrapAlternate(wrap); =20 v =3D visitor_input_test_init(data, "{ 'alt': {'integer':1, 'string':'= str', " @@ -588,37 +588,37 @@ static void test_visitor_in_alternate_number(TestInpu= tVisitorData *data, { Visitor *v; Error *err =3D NULL; - AltStrBool *asb; - AltStrNum *asn; - AltNumStr *ans; - AltStrInt *asi; + AltEnumBool *aeb; + AltEnumNum *aen; + AltNumEnum *ans; + AltEnumInt *asi; AltIntNum *ain; AltNumInt *ani; =20 /* Parsing an int */ =20 v =3D visitor_input_test_init(data, "42"); - visit_type_AltStrBool(v, NULL, &asb, &err); + visit_type_AltEnumBool(v, NULL, &aeb, &err); error_free_or_abort(&err); - qapi_free_AltStrBool(asb); + qapi_free_AltEnumBool(aeb); =20 v =3D visitor_input_test_init(data, "42"); - visit_type_AltStrNum(v, NULL, &asn, &error_abort); - g_assert_cmpint(asn->type, =3D=3D, QTYPE_QFLOAT); - g_assert_cmpfloat(asn->u.n, =3D=3D, 42); - qapi_free_AltStrNum(asn); + visit_type_AltEnumNum(v, NULL, &aen, &error_abort); + g_assert_cmpint(aen->type, =3D=3D, QTYPE_QFLOAT); + g_assert_cmpfloat(aen->u.n, =3D=3D, 42); + qapi_free_AltEnumNum(aen); =20 v =3D visitor_input_test_init(data, "42"); - visit_type_AltNumStr(v, NULL, &ans, &error_abort); + visit_type_AltNumEnum(v, NULL, &ans, &error_abort); g_assert_cmpint(ans->type, =3D=3D, QTYPE_QFLOAT); g_assert_cmpfloat(ans->u.n, =3D=3D, 42); - qapi_free_AltNumStr(ans); + qapi_free_AltNumEnum(ans); =20 v =3D visitor_input_test_init(data, "42"); - visit_type_AltStrInt(v, NULL, &asi, &error_abort); + visit_type_AltEnumInt(v, NULL, &asi, &error_abort); g_assert_cmpint(asi->type, =3D=3D, QTYPE_QINT); g_assert_cmpint(asi->u.i, =3D=3D, 42); - qapi_free_AltStrInt(asi); + qapi_free_AltEnumInt(asi); =20 v =3D visitor_input_test_init(data, "42"); visit_type_AltIntNum(v, NULL, &ain, &error_abort); @@ -635,26 +635,26 @@ static void test_visitor_in_alternate_number(TestInpu= tVisitorData *data, /* Parsing a double */ =20 v =3D visitor_input_test_init(data, "42.5"); - visit_type_AltStrBool(v, NULL, &asb, &err); + visit_type_AltEnumBool(v, NULL, &aeb, &err); error_free_or_abort(&err); - qapi_free_AltStrBool(asb); + qapi_free_AltEnumBool(aeb); =20 v =3D visitor_input_test_init(data, "42.5"); - visit_type_AltStrNum(v, NULL, &asn, &error_abort); - g_assert_cmpint(asn->type, =3D=3D, QTYPE_QFLOAT); - g_assert_cmpfloat(asn->u.n, =3D=3D, 42.5); - qapi_free_AltStrNum(asn); + visit_type_AltEnumNum(v, NULL, &aen, &error_abort); + g_assert_cmpint(aen->type, =3D=3D, QTYPE_QFLOAT); + g_assert_cmpfloat(aen->u.n, =3D=3D, 42.5); + qapi_free_AltEnumNum(aen); =20 v =3D visitor_input_test_init(data, "42.5"); - visit_type_AltNumStr(v, NULL, &ans, &error_abort); + visit_type_AltNumEnum(v, NULL, &ans, &error_abort); g_assert_cmpint(ans->type, =3D=3D, QTYPE_QFLOAT); g_assert_cmpfloat(ans->u.n, =3D=3D, 42.5); - qapi_free_AltNumStr(ans); + qapi_free_AltNumEnum(ans); =20 v =3D visitor_input_test_init(data, "42.5"); - visit_type_AltStrInt(v, NULL, &asi, &err); + visit_type_AltEnumInt(v, NULL, &asi, &err); error_free_or_abort(&err); - qapi_free_AltStrInt(asi); + qapi_free_AltEnumInt(asi); =20 v =3D visitor_input_test_init(data, "42.5"); visit_type_AltIntNum(v, NULL, &ain, &error_abort); diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 94b9518e40..4e8fdf1397 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -406,12 +406,12 @@ static void test_visitor_out_alternate(TestOutputVisi= torData *data, visitor_reset(data); tmp =3D g_new0(UserDefAlternate, 1); tmp->type =3D QTYPE_QSTRING; - tmp->u.s =3D g_strdup("hello"); + tmp->u.e =3D ENUM_ONE_VALUE1; =20 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); qstr =3D qobject_to_qstring(visitor_get(data)); g_assert(qstr); - g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, "hello"); + g_assert_cmpstr(qstring_get_str(qstr), =3D=3D, "value1"); =20 qapi_free_UserDefAlternate(tmp); =20 diff --git a/tests/qapi-schema/alternate-clash.json b/tests/qapi-schema/alt= ernate-clash.json index 6d73bc527b..9a59b88ced 100644 --- a/tests/qapi-schema/alternate-clash.json +++ b/tests/qapi-schema/alternate-clash.json @@ -5,4 +5,4 @@ # the implicit Alt1Kind enum, we would still have a collision with the # resulting C union trying to have two members named 'a_b'. { 'alternate': 'Alt1', - 'data': { 'a-b': 'str', 'a_b': 'int' } } + 'data': { 'a-b': 'bool', 'a_b': 'int' } } diff --git a/tests/qapi-schema/alternate-nested.json b/tests/qapi-schema/al= ternate-nested.json index 8e22186491..f2b9632f75 100644 --- a/tests/qapi-schema/alternate-nested.json +++ b/tests/qapi-schema/alternate-nested.json @@ -1,5 +1,5 @@ # we reject a nested alternate branch { 'alternate': 'Alt1', - 'data': { 'name': 'str', 'value': 'int' } } + 'data': { 'name': 'bool', 'value': 'int' } } { 'alternate': 'Alt2', 'data': { 'nested': 'Alt1', 'b': 'bool' } } diff --git a/tests/qapi-schema/args-alternate.json b/tests/qapi-schema/args= -alternate.json index 69e94d4819..824d69c1d5 100644 --- a/tests/qapi-schema/args-alternate.json +++ b/tests/qapi-schema/args-alternate.json @@ -1,3 +1,3 @@ # we do not allow alternate arguments -{ 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'str' } } +{ 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'bool' } } { 'command': 'oops', 'data': 'Alt' } diff --git a/tests/qapi-schema/doc-bad-alternate-member.json b/tests/qapi-s= chema/doc-bad-alternate-member.json index 738635ca8f..fa4143da4c 100644 --- a/tests/qapi-schema/doc-bad-alternate-member.json +++ b/tests/qapi-schema/doc-bad-alternate-member.json @@ -6,4 +6,4 @@ # @bb: b ## { 'alternate': 'AorB', - 'data': { 'a': 'str', 'b': 'int' } } + 'data': { 'a': 'bool', 'b': 'int' } } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 842ea3c5e3..303f2b23cd 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -93,16 +93,17 @@ { 'struct': 'WrapAlternate', 'data': { 'alt': 'UserDefAlternate' } } { 'alternate': 'UserDefAlternate', - 'data': { 'udfu': 'UserDefFlatUnion', 's': 'str', 'i': 'int' } } + 'data': { 'udfu': 'UserDefFlatUnion', 'e': 'EnumOne', 'i': 'int' } } =20 { 'struct': 'UserDefC', 'data': { 'string1': 'str', 'string2': 'str' } } =20 # for testing use of 'number' within alternates -{ 'alternate': 'AltStrBool', 'data': { 's': 'str', 'b': 'bool' } } -{ 'alternate': 'AltStrNum', 'data': { 's': 'str', 'n': 'number' } } +{ 'alternate': 'AltEnumBool', 'data': { 'e': 'EnumOne', 'b': 'bool' } } +{ 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } } { 'alternate': 'AltNumStr', 'data': { 'n': 'number', 's': 'str' } } -{ 'alternate': 'AltStrInt', 'data': { 's': 'str', 'i': 'int' } } +{ 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } } +{ 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } } { 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } } { 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } } =20 diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 9d99c4eebb..3081091818 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -1,7 +1,23 @@ +alternate AltEnumBool + tag type + case e: EnumOne + case b: bool +alternate AltEnumInt + tag type + case e: EnumOne + case i: int +alternate AltEnumNum + tag type + case e: EnumOne + case n: number alternate AltIntNum tag type case i: int case n: number +alternate AltNumEnum + tag type + case n: number + case e: EnumOne alternate AltNumInt tag type case n: number @@ -10,18 +26,6 @@ alternate AltNumStr tag type case n: number case s: str -alternate AltStrBool - tag type - case s: str - case b: bool -alternate AltStrInt - tag type - case s: str - case i: int -alternate AltStrNum - tag type - case s: str - case n: number event EVENT_A None boxed=3DFalse event EVENT_B None @@ -66,7 +70,7 @@ object UserDefA alternate UserDefAlternate tag type case udfu: UserDefFlatUnion - case s: str + case e: EnumOne case i: int object UserDefB member intb: int optional=3DFalse diff --git a/tests/qapi-schema/returns-alternate.json b/tests/qapi-schema/r= eturns-alternate.json index 972390c06b..f87371811b 100644 --- a/tests/qapi-schema/returns-alternate.json +++ b/tests/qapi-schema/returns-alternate.json @@ -1,3 +1,3 @@ # we reject returns if it is an alternate type -{ 'alternate': 'Alt', 'data': { 'a': 'int', 'b': 'str' } } +{ 'alternate': 'Alt', 'data': { 'a': 'int', 'b': 'bool' } } { 'command': 'oops', 'returns': 'Alt' } --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14962393232574.133937001510162; Wed, 31 May 2017 07:02:03 -0700 (PDT) Received: from localhost ([::1]:59682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4CB-0006sg-JV for importer@patchew.org; Wed, 31 May 2017 10:01:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG48H-00032Y-EY for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG48A-0003rw-0k for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34624) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG489-0003rk-O3 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB5B63680E for ; Wed, 31 May 2017 13:57:44 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id D08557C8A7; Wed, 31 May 2017 13:57:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AB5B63680E Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AB5B63680E From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:28 +0400 Message-Id: <20170531135709.345-5-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 13:57:44 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/45] qapi: Reject alternates that can't work with keyval_parse() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster Alternates are sum types like unions, but use the JSON type on the wire / QType in QObject instead of an explicit tag. That's why we require alternate members to have distinct QTypes. The recently introduced keyval_parse() (commit d454dbe) can only produce string scalars. The qobject_input_visitor_new_keyval() input visitor mostly hides the difference, so code using a QObject input visitor doesn't have to care whether its input was parsed from JSON or KEY=3DVALUE,... The difference leaks for alternates, as noted in commit 0ee9ae7: an non-string, non-enum scalar alternate value can't currently be expressed. In part, this is just our insufficiently sophisticated implementation. Consider alternate type 'GuestFileWhence'. It has an integer member and a 'QGASeek' member. The latter is an enumeration with values 'set', 'cur', 'end'. The meaning of b=3Dset, b=3Dcur, b=3Dend, b=3D0, b=3D= 1 and so forth is perfectly obvious. However, our current implementation falls apart at run time for b=3D0, b=3D1, and so forth. Fixable, but not today; add a test case and a TODO comment. Now consider an alternate type with a string and an integer member. What's the meaning of a=3D42? Is it the string "42" or the integer 42? Whichever meaning you pick makes the other inexpressible. This isn't just an implementation problem, it's fundamental. Our current implementation will pick string. So far, we haven't needed such alternates. To make sure we stop and think before we add one that cannot sanely work with keyval_parse(), let's require alternate members to have sufficiently district representation in KEY=3DVALUE,... syntax: * A string member clashes with any other scalar member * An enumeration member clashes with bool members when it has value 'on' or 'off'. * An enumeration member clashes with numeric members when it has a value that starts with '-', '+', '0' or '9'. This is a rather lazy approximation of the actual number syntax accepted by the visitor. Note that enumeration values starting with '-' and '+' are rejected elsewhere already, but better safe than sorry. Signed-off-by: Markus Armbruster Message-Id: <1495471335-23707-5-git-send-email-armbru@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 19 +++++++++++++++++= -- tests/test-keyval.c | 18 +++++++++++------- util/keyval.c | 10 +++++----- tests/Makefile.include | 2 ++ tests/qapi-schema/alternate-conflict-dict.json | 2 +- tests/qapi-schema/alternate-conflict-enum-bool.err | 1 + tests/qapi-schema/alternate-conflict-enum-bool.exit | 1 + tests/qapi-schema/alternate-conflict-enum-bool.json | 6 ++++++ tests/qapi-schema/alternate-conflict-enum-bool.out | 0 tests/qapi-schema/alternate-conflict-enum-int.err | 1 + tests/qapi-schema/alternate-conflict-enum-int.exit | 1 + tests/qapi-schema/alternate-conflict-enum-int.json | 6 ++++++ tests/qapi-schema/alternate-conflict-enum-int.out | 0 tests/qapi-schema/alternate-conflict-string.err | 2 +- tests/qapi-schema/alternate-conflict-string.json | 6 ++---- tests/qapi-schema/qapi-schema-test.json | 4 +++- tests/qapi-schema/qapi-schema-test.out | 4 ++-- 17 files changed, 60 insertions(+), 23 deletions(-) create mode 100644 tests/qapi-schema/alternate-conflict-enum-bool.err create mode 100644 tests/qapi-schema/alternate-conflict-enum-bool.exit create mode 100644 tests/qapi-schema/alternate-conflict-enum-bool.json create mode 100644 tests/qapi-schema/alternate-conflict-enum-bool.out create mode 100644 tests/qapi-schema/alternate-conflict-enum-int.err create mode 100644 tests/qapi-schema/alternate-conflict-enum-int.exit create mode 100644 tests/qapi-schema/alternate-conflict-enum-int.json create mode 100644 tests/qapi-schema/alternate-conflict-enum-int.out diff --git a/scripts/qapi.py b/scripts/qapi.py index 6c4d554165..b7a25e4759 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -812,11 +812,26 @@ def check_alternate(expr, info): if not qtype: raise QAPISemError(info, "Alternate '%s' member '%s' cannot us= e " "type '%s'" % (name, key, value)) - if qtype in types_seen: + conflicting =3D set([qtype]) + if qtype =3D=3D 'QTYPE_QSTRING': + enum_expr =3D enum_types.get(value) + if enum_expr: + for v in enum_expr['data']: + if v in ['on', 'off']: + conflicting.add('QTYPE_QBOOL') + if re.match(r'[-+0-9.]', v): # lazy, could be tightened + conflicting.add('QTYPE_QINT') + conflicting.add('QTYPE_QFLOAT') + else: + conflicting.add('QTYPE_QINT') + conflicting.add('QTYPE_QFLOAT') + conflicting.add('QTYPE_QBOOL') + if conflicting & set(types_seen): raise QAPISemError(info, "Alternate '%s' member '%s' can't " "be distinguished from member '%s'" % (name, key, types_seen[qtype])) - types_seen[qtype] =3D key + for qt in conflicting: + types_seen[qt] =3D key =20 =20 def check_enum(expr, info): diff --git a/tests/test-keyval.c b/tests/test-keyval.c index c556b1b117..c3be00524c 100644 --- a/tests/test-keyval.c +++ b/tests/test-keyval.c @@ -614,22 +614,26 @@ static void test_keyval_visit_alternate(void) Error *err =3D NULL; Visitor *v; QDict *qdict; - AltNumStr *ans; + AltStrObj *aso; AltNumInt *ani; + AltEnumBool *aeb; =20 /* * Can't do scalar alternate variants other than string. You get * the string variant if there is one, else an error. + * TODO make it work for unambiguous cases like AltEnumBool below */ - qdict =3D keyval_parse("a=3D1,b=3D2", NULL, &error_abort); + qdict =3D keyval_parse("a=3D1,b=3D2,c=3Don", NULL, &error_abort); v =3D qobject_input_visitor_new_keyval(QOBJECT(qdict)); QDECREF(qdict); visit_start_struct(v, NULL, NULL, 0, &error_abort); - visit_type_AltNumStr(v, "a", &ans, &error_abort); - g_assert_cmpint(ans->type, =3D=3D, QTYPE_QSTRING); - g_assert_cmpstr(ans->u.s, =3D=3D, "1"); - qapi_free_AltNumStr(ans); - visit_type_AltNumInt(v, "a", &ani, &err); + visit_type_AltStrObj(v, "a", &aso, &error_abort); + g_assert_cmpint(aso->type, =3D=3D, QTYPE_QSTRING); + g_assert_cmpstr(aso->u.s, =3D=3D, "1"); + qapi_free_AltStrObj(aso); + visit_type_AltNumInt(v, "b", &ani, &err); + error_free_or_abort(&err); + visit_type_AltEnumBool(v, "c", &aeb, &err); error_free_or_abort(&err); visit_end_struct(v, NULL); visit_free(v); diff --git a/util/keyval.c b/util/keyval.c index 93d5db6b59..7dbda62305 100644 --- a/util/keyval.c +++ b/util/keyval.c @@ -65,11 +65,11 @@ * denote numbers, true, false or null. The special QObject input * visitor returned by qobject_input_visitor_new_keyval() mostly hides * this by automatically converting strings to the type the visitor - * expects. Breaks down for alternate types and type 'any', where the - * visitor's expectation isn't clear. Code visiting such types needs - * to do the conversion itself, but only when using this keyval - * visitor. Awkward. Alternate types without a string member don't - * work at all. + * expects. Breaks down for type 'any', where the visitor's + * expectation isn't clear. Code visiting 'any' needs to do the + * conversion itself, but only when using this keyval visitor. + * Awkward. Note that we carefully restrict alternate types to avoid + * similar ambiguity. * * Additional syntax for use with an implied key: * diff --git a/tests/Makefile.include b/tests/Makefile.include index 75893838e5..f42f3dfa72 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -342,6 +342,8 @@ qapi-schema +=3D alternate-array.json qapi-schema +=3D alternate-base.json qapi-schema +=3D alternate-clash.json qapi-schema +=3D alternate-conflict-dict.json +qapi-schema +=3D alternate-conflict-enum-bool.json +qapi-schema +=3D alternate-conflict-enum-int.json qapi-schema +=3D alternate-conflict-string.json qapi-schema +=3D alternate-empty.json qapi-schema +=3D alternate-nested.json diff --git a/tests/qapi-schema/alternate-conflict-dict.json b/tests/qapi-sc= hema/alternate-conflict-dict.json index d566cca816..3d7881279c 100644 --- a/tests/qapi-schema/alternate-conflict-dict.json +++ b/tests/qapi-schema/alternate-conflict-dict.json @@ -1,4 +1,4 @@ -# we reject alternates with multiple object branches +# alternate branches of object type conflict with each other { 'struct': 'One', 'data': { 'name': 'str' } } { 'struct': 'Two', diff --git a/tests/qapi-schema/alternate-conflict-enum-bool.err b/tests/qap= i-schema/alternate-conflict-enum-bool.err new file mode 100644 index 0000000000..0dfc00242d --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-enum-bool.err @@ -0,0 +1 @@ +tests/qapi-schema/alternate-conflict-enum-bool.json:4: Alternate 'Alt' mem= ber 'two' can't be distinguished from member 'one' diff --git a/tests/qapi-schema/alternate-conflict-enum-bool.exit b/tests/qa= pi-schema/alternate-conflict-enum-bool.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-enum-bool.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/alternate-conflict-enum-bool.json b/tests/qa= pi-schema/alternate-conflict-enum-bool.json new file mode 100644 index 0000000000..bff25c3147 --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-enum-bool.json @@ -0,0 +1,6 @@ +# alternate branch of 'enum' type that conflicts with bool +{ 'enum': 'Enum', + 'data': [ 'aus', 'off' ] } +{ 'alternate': 'Alt', + 'data': { 'one': 'Enum', + 'two': 'bool' } } diff --git a/tests/qapi-schema/alternate-conflict-enum-bool.out b/tests/qap= i-schema/alternate-conflict-enum-bool.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/alternate-conflict-enum-int.err b/tests/qapi= -schema/alternate-conflict-enum-int.err new file mode 100644 index 0000000000..2cc8e7b9aa --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-enum-int.err @@ -0,0 +1 @@ +tests/qapi-schema/alternate-conflict-enum-int.json:4: Alternate 'Alt' memb= er 'two' can't be distinguished from member 'one' diff --git a/tests/qapi-schema/alternate-conflict-enum-int.exit b/tests/qap= i-schema/alternate-conflict-enum-int.exit new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-enum-int.exit @@ -0,0 +1 @@ +1 diff --git a/tests/qapi-schema/alternate-conflict-enum-int.json b/tests/qap= i-schema/alternate-conflict-enum-int.json new file mode 100644 index 0000000000..beb428c10b --- /dev/null +++ b/tests/qapi-schema/alternate-conflict-enum-int.json @@ -0,0 +1,6 @@ +# alternate branches of 'enum' type that conflicts with numbers +{ 'enum': 'Enum', + 'data': [ '1', '2', '3' ] } +{ 'alternate': 'Alt', + 'data': { 'one': 'Enum', + 'two': 'int' } } diff --git a/tests/qapi-schema/alternate-conflict-enum-int.out b/tests/qapi= -schema/alternate-conflict-enum-int.out new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/qapi-schema/alternate-conflict-string.err b/tests/qapi-s= chema/alternate-conflict-string.err index fc523b0879..fe2f188295 100644 --- a/tests/qapi-schema/alternate-conflict-string.err +++ b/tests/qapi-schema/alternate-conflict-string.err @@ -1 +1 @@ -tests/qapi-schema/alternate-conflict-string.json:4: Alternate 'Alt' member= 'two' can't be distinguished from member 'one' +tests/qapi-schema/alternate-conflict-string.json:2: Alternate 'Alt' member= 'two' can't be distinguished from member 'one' diff --git a/tests/qapi-schema/alternate-conflict-string.json b/tests/qapi-= schema/alternate-conflict-string.json index 72f04a820a..85adbd4adc 100644 --- a/tests/qapi-schema/alternate-conflict-string.json +++ b/tests/qapi-schema/alternate-conflict-string.json @@ -1,6 +1,4 @@ -# we reject alternates with multiple string-like branches -{ 'enum': 'Enum', - 'data': [ 'hello', 'world' ] } +# alternate branches of 'str' type conflict with all scalar types { 'alternate': 'Alt', 'data': { 'one': 'str', - 'two': 'Enum' } } + 'two': 'int' } } diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 303f2b23cd..17649c6398 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -101,12 +101,14 @@ # for testing use of 'number' within alternates { 'alternate': 'AltEnumBool', 'data': { 'e': 'EnumOne', 'b': 'bool' } } { 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } } -{ 'alternate': 'AltNumStr', 'data': { 'n': 'number', 's': 'str' } } { 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } } { 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } } { 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } } { 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } } =20 +# for testing use of 'str' within alternates +{ 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } } + # for testing native lists { 'union': 'UserDefNativeListUnion', 'data': { 'integer': ['int'], diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 3081091818..9f68610dc2 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -22,10 +22,10 @@ alternate AltNumInt tag type case n: number case i: int -alternate AltNumStr +alternate AltStrObj tag type - case n: number case s: str + case o: TestStruct event EVENT_A None boxed=3DFalse event EVENT_B None --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239527289860.689897798909; Wed, 31 May 2017 07:05:27 -0700 (PDT) Received: from localhost ([::1]:59693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4FX-0001NY-PP for importer@patchew.org; Wed, 31 May 2017 10:05:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG48L-00039X-PQ for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG48K-0003tN-Hh for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43828) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG48K-0003ss-9H for qemu-devel@nongnu.org; Wed, 31 May 2017 09:57:56 -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 mx1.redhat.com (Postfix) with ESMTPS id 0CBB7155E4 for ; Wed, 31 May 2017 13:57:53 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id A675D5DC1F; Wed, 31 May 2017 13:57:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0CBB7155E4 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0CBB7155E4 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:29 +0400 Message-Id: <20170531135709.345-6-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 31 May 2017 13:57:53 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 05/45] qdev: remove PropertyInfo.qtype field X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Remove dependency on qapi qtype, replace a field by a few PropertyInfo callbacks to set the default value type (introduced in commit 4f2d3d7). Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/qdev-core.h | 2 +- include/hw/qdev-properties.h | 5 ----- hw/core/qdev-properties.c | 35 ++++++++++++++++++++++++++++++++++- hw/core/qdev.c | 13 ++----------- 4 files changed, 37 insertions(+), 18 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index e69489ec6c..9523339762 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -226,7 +226,6 @@ struct Property { PropertyInfo *info; ptrdiff_t offset; uint8_t bitnr; - QType qtype; int64_t defval; int arrayoffset; PropertyInfo *arrayinfo; @@ -238,6 +237,7 @@ struct PropertyInfo { const char *description; const char * const *enum_table; int (*print)(DeviceState *dev, Property *prop, char *dest, size_t len); + void (*set_default_value)(Object *obj, const Property *prop); ObjectPropertyAccessor *get; ObjectPropertyAccessor *set; ObjectPropertyRelease *release; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index d206fc93dd..85e68998a9 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -42,7 +42,6 @@ extern PropertyInfo qdev_prop_arraylen; .info =3D &(_prop), \ .offset =3D offsetof(_state, _field) \ + type_check(_type,typeof_field(_state, _field)), \ - .qtype =3D QTYPE_QINT, \ .defval =3D (_type)_defval, \ } #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \ @@ -51,7 +50,6 @@ extern PropertyInfo qdev_prop_arraylen; .bitnr =3D (_bit), \ .offset =3D offsetof(_state, _field) \ + type_check(uint32_t,typeof_field(_state, _field)), \ - .qtype =3D QTYPE_QBOOL, \ .defval =3D (bool)_defval, \ } #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \ @@ -60,7 +58,6 @@ extern PropertyInfo qdev_prop_arraylen; .bitnr =3D (_bit), \ .offset =3D offsetof(_state, _field) \ + type_check(uint64_t, typeof_field(_state, _field)), \ - .qtype =3D QTYPE_QBOOL, \ .defval =3D (bool)_defval, \ } =20 @@ -69,7 +66,6 @@ extern PropertyInfo qdev_prop_arraylen; .info =3D &(qdev_prop_bool), \ .offset =3D offsetof(_state, _field) \ + type_check(bool, typeof_field(_state, _field)), \ - .qtype =3D QTYPE_QBOOL, \ .defval =3D (bool)_defval, \ } =20 @@ -105,7 +101,6 @@ extern PropertyInfo qdev_prop_arraylen; .info =3D &(qdev_prop_arraylen), \ .offset =3D offsetof(_state, _field) \ + type_check(uint32_t, typeof_field(_state, _field)), \ - .qtype =3D QTYPE_QINT, \ .arrayinfo =3D &(_arrayprop), \ .arrayfieldsize =3D sizeof(_arraytype), \ .arrayoffset =3D offsetof(_state, _arrayfield), \ diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index fa3617db2d..482efb2683 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -69,6 +69,12 @@ static void set_enum(Object *obj, Visitor *v, const char= *name, void *opaque, visit_type_enum(v, prop->name, ptr, prop->info->enum_table, errp); } =20 +static void set_default_value_enum(Object *obj, const Property *prop) +{ + object_property_set_str(obj, prop->info->enum_table[prop->defval], + prop->name, &error_abort); +} + /* Bit */ =20 static uint32_t qdev_get_prop_mask(Property *prop) @@ -120,11 +126,17 @@ static void prop_set_bit(Object *obj, Visitor *v, con= st char *name, bit_prop_set(dev, prop, value); } =20 +static void set_default_value_bool(Object *obj, const Property *prop) +{ + object_property_set_bool(obj, prop->defval, prop->name, &error_abort); +} + PropertyInfo qdev_prop_bit =3D { .name =3D "bool", .description =3D "on/off", .get =3D prop_get_bit, .set =3D prop_set_bit, + .set_default_value =3D set_default_value_bool, }; =20 /* Bit64 */ @@ -183,6 +195,7 @@ PropertyInfo qdev_prop_bit64 =3D { .description =3D "on/off", .get =3D prop_get_bit64, .set =3D prop_set_bit64, + .set_default_value =3D set_default_value_bool, }; =20 /* --- bool --- */ @@ -216,6 +229,7 @@ PropertyInfo qdev_prop_bool =3D { .name =3D "bool", .get =3D get_bool, .set =3D set_bool, + .set_default_value =3D set_default_value_bool, }; =20 /* --- 8bit integer --- */ @@ -245,10 +259,16 @@ static void set_uint8(Object *obj, Visitor *v, const = char *name, void *opaque, visit_type_uint8(v, name, ptr, errp); } =20 +static void set_default_value_int(Object *obj, const Property *prop) +{ + object_property_set_int(obj, prop->defval, prop->name, &error_abort); +} + PropertyInfo qdev_prop_uint8 =3D { .name =3D "uint8", .get =3D get_uint8, .set =3D set_uint8, + .set_default_value =3D set_default_value_int, }; =20 /* --- 16bit integer --- */ @@ -282,6 +302,7 @@ PropertyInfo qdev_prop_uint16 =3D { .name =3D "uint16", .get =3D get_uint16, .set =3D set_uint16, + .set_default_value =3D set_default_value_int, }; =20 /* --- 32bit integer --- */ @@ -340,12 +361,14 @@ PropertyInfo qdev_prop_uint32 =3D { .name =3D "uint32", .get =3D get_uint32, .set =3D set_uint32, + .set_default_value =3D set_default_value_int, }; =20 PropertyInfo qdev_prop_int32 =3D { .name =3D "int32", .get =3D get_int32, .set =3D set_int32, + .set_default_value =3D set_default_value_int, }; =20 /* --- 64bit integer --- */ @@ -379,6 +402,7 @@ PropertyInfo qdev_prop_uint64 =3D { .name =3D "uint64", .get =3D get_uint64, .set =3D set_uint64, + .set_default_value =3D set_default_value_int, }; =20 /* --- string --- */ @@ -526,6 +550,7 @@ PropertyInfo qdev_prop_on_off_auto =3D { .enum_table =3D OnOffAuto_lookup, .get =3D get_enum, .set =3D set_enum, + .set_default_value =3D set_default_value_enum, }; =20 /* --- lost tick policy --- */ @@ -537,6 +562,7 @@ PropertyInfo qdev_prop_losttickpolicy =3D { .enum_table =3D LostTickPolicy_lookup, .get =3D get_enum, .set =3D set_enum, + .set_default_value =3D set_default_value_enum, }; =20 /* --- Block device error handling policy --- */ @@ -550,6 +576,7 @@ PropertyInfo qdev_prop_blockdev_on_error =3D { .enum_table =3D BlockdevOnError_lookup, .get =3D get_enum, .set =3D set_enum, + .set_default_value =3D set_default_value_enum, }; =20 /* --- BIOS CHS translation */ @@ -563,6 +590,7 @@ PropertyInfo qdev_prop_bios_chs_trans =3D { .enum_table =3D BiosAtaTranslation_lookup, .get =3D get_enum, .set =3D set_enum, + .set_default_value =3D set_default_value_enum, }; =20 /* --- FDC default drive types */ @@ -573,7 +601,8 @@ PropertyInfo qdev_prop_fdc_drive_type =3D { "144/288/120/none/auto", .enum_table =3D FloppyDriveType_lookup, .get =3D get_enum, - .set =3D set_enum + .set =3D set_enum, + .set_default_value =3D set_default_value_enum, }; =20 /* --- pci address --- */ @@ -648,6 +677,7 @@ PropertyInfo qdev_prop_pci_devfn =3D { .print =3D print_pci_devfn, .get =3D get_int32, .set =3D set_pci_devfn, + .set_default_value =3D set_default_value_int, }; =20 /* --- blocksize --- */ @@ -695,6 +725,7 @@ PropertyInfo qdev_prop_blocksize =3D { .description =3D "A power of two between 512 and 32768", .get =3D get_uint16, .set =3D set_blocksize, + .set_default_value =3D set_default_value_int, }; =20 /* --- pci host address --- */ @@ -917,6 +948,7 @@ PropertyInfo qdev_prop_arraylen =3D { .name =3D "uint32", .get =3D get_uint32, .set =3D set_prop_arraylen, + .set_default_value =3D set_default_value_int, }; =20 /* --- public helpers --- */ @@ -1153,4 +1185,5 @@ PropertyInfo qdev_prop_size =3D { .name =3D "size", .get =3D get_size, .set =3D set_size, + .set_default_value =3D set_default_value_int, }; diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 71ff95fd71..6674e11840 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -794,17 +794,8 @@ void qdev_property_add_static(DeviceState *dev, Proper= ty *prop, prop->info->description, &error_abort); =20 - if (prop->qtype =3D=3D QTYPE_NONE) { - return; - } - - if (prop->qtype =3D=3D QTYPE_QBOOL) { - object_property_set_bool(obj, prop->defval, prop->name, &error_abo= rt); - } else if (prop->info->enum_table) { - object_property_set_str(obj, prop->info->enum_table[prop->defval], - prop->name, &error_abort); - } else if (prop->qtype =3D=3D QTYPE_QINT) { - object_property_set_int(obj, prop->defval, prop->name, &error_abor= t); + if (prop->info->set_default_value) { + prop->info->set_default_value(obj, prop); } } =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239215441703.1230671857762; Wed, 31 May 2017 07:00:15 -0700 (PDT) Received: from localhost ([::1]:59667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4AX-0005LK-3Z for importer@patchew.org; Wed, 31 May 2017 10:00:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG48V-0003Ie-PY for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG48T-0003vq-6U for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2173) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG48T-0003vQ-0d for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC8CF80F95 for ; Wed, 31 May 2017 13:58:03 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7868E7FB92; Wed, 31 May 2017 13:57:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC8CF80F95 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DC8CF80F95 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:30 +0400 Message-Id: <20170531135709.345-7-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 May 2017 13:58:04 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/45] object: fix potential leak in getters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If the property is not of the requested type, the getters will leak a QObject. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster --- qom/object.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qom/object.c b/qom/object.c index eb4bc924ff..c7b8079df6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1122,7 +1122,7 @@ char *object_property_get_str(Object *obj, const char= *name, retval =3D g_strdup(qstring_get_str(qstring)); } =20 - QDECREF(qstring); + qobject_decref(ret); return retval; } =20 @@ -1183,7 +1183,7 @@ bool object_property_get_bool(Object *obj, const char= *name, retval =3D qbool_get_bool(qbool); } =20 - QDECREF(qbool); + qobject_decref(ret); return retval; } =20 @@ -1214,7 +1214,7 @@ int64_t object_property_get_int(Object *obj, const ch= ar *name, retval =3D qint_get_int(qint); } =20 - QDECREF(qint); + qobject_decref(ret); return retval; } =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239486678172.21804013569567; Wed, 31 May 2017 07:04:46 -0700 (PDT) Received: from localhost ([::1]:59691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Eu-0000rv-3Y for importer@patchew.org; Wed, 31 May 2017 10:04:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51973) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG48a-0003NP-MN for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG48Z-0003y8-B8 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44898) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG48Z-0003xe-3N for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:11 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F36639D404 for ; Wed, 31 May 2017 13:58:09 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id D84FC80E64; Wed, 31 May 2017 13:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F36639D404 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F36639D404 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:31 +0400 Message-Id: <20170531135709.345-8-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 May 2017 13:58:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 07/45] tests: remove alt num-int cases X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster Marc-Andr=C3=A9 Lureau writes: > There are no real users of this case, and it's going to be invalid after > merging of QFloat and QInt use the same QNum type in the following patch. Invalid because our alternate code is insufficiently sophisticated. In other words fixable. See "[PATCH 4/4] qapi: Reject alternates that can't work with keyval_parse()" I just posted. My patch's commit message describes two related issues, one fixable and one unfixable. The fixable one already exists, but only in QGA. I intend to fix it, but it's not a priority. Fixing the issue you describe seems even less important. I considered outlawing it in my series (patch appended for your reading pleasure), but decided to leave it to yours. I don't expect you to replace your patch. Perhaps my patch helps you with rebasing yours should that become necessary. Message-Id: <87tw4cn7sh.fsf@dusky.pond.sub.org> Reviewed-by: Markus Armbruster --- scripts/qapi.py | 4 ++++ tests/test-keyval.c | 4 ++-- tests/test-qobject-input-visitor.c | 26 -------------------------- tests/qapi-schema/qapi-schema-test.json | 2 -- tests/qapi-schema/qapi-schema-test.out | 8 -------- 5 files changed, 6 insertions(+), 38 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index b7a25e4759..06e583d8c3 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -826,6 +826,10 @@ def check_alternate(expr, info): conflicting.add('QTYPE_QINT') conflicting.add('QTYPE_QFLOAT') conflicting.add('QTYPE_QBOOL') + elif qtype =3D=3D 'QTYPE_QINT': + conflicting.add('QTYPE_QFLOAT') + elif qtype =3D=3D 'QTYPE_QFLOAT': + conflicting.add('QTYPE_QINT') if conflicting & set(types_seen): raise QAPISemError(info, "Alternate '%s' member '%s' can't " "be distinguished from member '%s'" diff --git a/tests/test-keyval.c b/tests/test-keyval.c index c3be00524c..baf7e339ab 100644 --- a/tests/test-keyval.c +++ b/tests/test-keyval.c @@ -615,7 +615,7 @@ static void test_keyval_visit_alternate(void) Visitor *v; QDict *qdict; AltStrObj *aso; - AltNumInt *ani; + AltNumEnum *ane; AltEnumBool *aeb; =20 /* @@ -631,7 +631,7 @@ static void test_keyval_visit_alternate(void) g_assert_cmpint(aso->type, =3D=3D, QTYPE_QSTRING); g_assert_cmpstr(aso->u.s, =3D=3D, "1"); qapi_free_AltStrObj(aso); - visit_type_AltNumInt(v, "b", &ani, &err); + visit_type_AltNumEnum(v, "b", &ane, &err); error_free_or_abort(&err); visit_type_AltEnumBool(v, "c", &aeb, &err); error_free_or_abort(&err); diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index 6b997a177d..83d663d11d 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -592,8 +592,6 @@ static void test_visitor_in_alternate_number(TestInputV= isitorData *data, AltEnumNum *aen; AltNumEnum *ans; AltEnumInt *asi; - AltIntNum *ain; - AltNumInt *ani; =20 /* Parsing an int */ =20 @@ -620,18 +618,6 @@ static void test_visitor_in_alternate_number(TestInput= VisitorData *data, g_assert_cmpint(asi->u.i, =3D=3D, 42); qapi_free_AltEnumInt(asi); =20 - v =3D visitor_input_test_init(data, "42"); - visit_type_AltIntNum(v, NULL, &ain, &error_abort); - g_assert_cmpint(ain->type, =3D=3D, QTYPE_QINT); - g_assert_cmpint(ain->u.i, =3D=3D, 42); - qapi_free_AltIntNum(ain); - - v =3D visitor_input_test_init(data, "42"); - visit_type_AltNumInt(v, NULL, &ani, &error_abort); - g_assert_cmpint(ani->type, =3D=3D, QTYPE_QINT); - g_assert_cmpint(ani->u.i, =3D=3D, 42); - qapi_free_AltNumInt(ani); - /* Parsing a double */ =20 v =3D visitor_input_test_init(data, "42.5"); @@ -655,18 +641,6 @@ static void test_visitor_in_alternate_number(TestInput= VisitorData *data, visit_type_AltEnumInt(v, NULL, &asi, &err); error_free_or_abort(&err); qapi_free_AltEnumInt(asi); - - v =3D visitor_input_test_init(data, "42.5"); - visit_type_AltIntNum(v, NULL, &ain, &error_abort); - g_assert_cmpint(ain->type, =3D=3D, QTYPE_QFLOAT); - g_assert_cmpfloat(ain->u.n, =3D=3D, 42.5); - qapi_free_AltIntNum(ain); - - v =3D visitor_input_test_init(data, "42.5"); - visit_type_AltNumInt(v, NULL, &ani, &error_abort); - g_assert_cmpint(ani->type, =3D=3D, QTYPE_QFLOAT); - g_assert_cmpfloat(ani->u.n, =3D=3D, 42.5); - qapi_free_AltNumInt(ani); } =20 static void test_native_list_integer_helper(TestInputVisitorData *data, diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qa= pi-schema-test.json index 17649c6398..91ffb2648c 100644 --- a/tests/qapi-schema/qapi-schema-test.json +++ b/tests/qapi-schema/qapi-schema-test.json @@ -103,8 +103,6 @@ { 'alternate': 'AltEnumNum', 'data': { 'e': 'EnumOne', 'n': 'number' } } { 'alternate': 'AltNumEnum', 'data': { 'n': 'number', 'e': 'EnumOne' } } { 'alternate': 'AltEnumInt', 'data': { 'e': 'EnumOne', 'i': 'int' } } -{ 'alternate': 'AltIntNum', 'data': { 'i': 'int', 'n': 'number' } } -{ 'alternate': 'AltNumInt', 'data': { 'n': 'number', 'i': 'int' } } =20 # for testing use of 'str' within alternates { 'alternate': 'AltStrObj', 'data': { 's': 'str', 'o': 'TestStruct' } } diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index 9f68610dc2..e727a5a84c 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -10,18 +10,10 @@ alternate AltEnumNum tag type case e: EnumOne case n: number -alternate AltIntNum - tag type - case i: int - case n: number alternate AltNumEnum tag type case n: number case e: EnumOne -alternate AltNumInt - tag type - case n: number - case i: int alternate AltStrObj tag type case s: str --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239374996636.706861931157; Wed, 31 May 2017 07:02:54 -0700 (PDT) Received: from localhost ([::1]:59684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4D4-0007v4-2U for importer@patchew.org; Wed, 31 May 2017 10:02:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG48j-0003Wl-TI for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG48h-0003zw-9A for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG48h-0003zm-0S for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:19 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B82E2804EE for ; Wed, 31 May 2017 13:58:17 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C2DC8140D; Wed, 31 May 2017 13:58:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B82E2804EE Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B82E2804EE From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:32 +0400 Message-Id: <20170531135709.345-9-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 May 2017 13:58:18 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 08/45] tests: add more int/number ranges checks X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Suggested by Markus Armbruster: We should systematically cover the integers, in particular the boundaries (because that's where bugs like to hide): * Integers in [-2^63,0) can be visited with visit_type_int() and visit_type_number(). * Integers in [0,2^63) can be visited with visit_type_int(), visit_type_uint64() and visit_type_number(). * Integers in [2^63,2^64) can be visited with visit_type_uint64() and visit_type_number(). * Integers outside [-2^63,2^53) can be visited with visit_type_number(). In any case, visit_type_number() loses precision beyond 53 bits. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/test-qobject-input-visitor.c | 38 ++++++++++++++++++++++++++++++++++= ++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index 83d663d11d..f2ed3161af 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -102,11 +102,11 @@ static Visitor *visitor_input_test_init_raw(TestInput= VisitorData *data, { return visitor_input_test_init_internal(data, false, json_string, NULL= ); } - static void test_visitor_in_int(TestInputVisitorData *data, const void *unused) { int64_t res =3D 0; + double dbl; int value =3D -42; Visitor *v; =20 @@ -114,6 +114,9 @@ static void test_visitor_in_int(TestInputVisitorData *d= ata, =20 visit_type_int(v, NULL, &res, &error_abort); g_assert_cmpint(res, =3D=3D, value); + + visit_type_number(v, NULL, &dbl, &error_abort); + g_assert_cmpfloat(dbl, =3D=3D, -42.0); } =20 static void test_visitor_in_uint(TestInputVisitorData *data, @@ -121,6 +124,8 @@ static void test_visitor_in_uint(TestInputVisitorData *= data, { Error *err =3D NULL; uint64_t res =3D 0; + int64_t i64; + double dbl; int value =3D 42; Visitor *v; =20 @@ -129,8 +134,13 @@ static void test_visitor_in_uint(TestInputVisitorData = *data, visit_type_uint64(v, NULL, &res, &error_abort); g_assert_cmpuint(res, =3D=3D, (uint64_t)value); =20 - /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */ + visit_type_int(v, NULL, &i64, &error_abort); + g_assert_cmpint(i64, =3D=3D, value); =20 + visit_type_number(v, NULL, &dbl, &error_abort); + g_assert_cmpfloat(dbl, =3D=3D, value); + + /* BUG: value between INT64_MIN and -1 accepted modulo 2^64 */ v =3D visitor_input_test_init(data, "%d", -value); =20 visit_type_uint64(v, NULL, &res, &error_abort); @@ -142,6 +152,8 @@ static void test_visitor_in_uint(TestInputVisitorData *= data, =20 visit_type_uint64(v, NULL, &res, &err); error_free_or_abort(&err); + + visit_type_number(v, NULL, &dbl, &error_abort); } =20 static void test_visitor_in_int_overflow(TestInputVisitorData *data, @@ -260,6 +272,26 @@ static void test_visitor_in_number(TestInputVisitorDat= a *data, g_assert_cmpfloat(res, =3D=3D, value); } =20 +static void test_visitor_in_large_number(TestInputVisitorData *data, + const void *unused) +{ + Error *err =3D NULL; + double res =3D 0; + int64_t i64; + uint64_t u64; + Visitor *v; + + v =3D visitor_input_test_init(data, "-18446744073709551616"); /* -2^64= */ + + visit_type_number(v, NULL, &res, &error_abort); + + visit_type_int(v, NULL, &i64, &err); + error_free_or_abort(&err); + + visit_type_uint64(v, NULL, &u64, &err); + error_free_or_abort(&err); +} + static void test_visitor_in_number_keyval(TestInputVisitorData *data, const void *unused) { @@ -1253,6 +1285,8 @@ int main(int argc, char **argv) NULL, test_visitor_in_bool_str_fail); input_visitor_test_add("/visitor/input/number", NULL, test_visitor_in_number); + input_visitor_test_add("/visitor/input/large_number", + NULL, test_visitor_in_large_number); input_visitor_test_add("/visitor/input/number_keyval", NULL, test_visitor_in_number_keyval); input_visitor_test_add("/visitor/input/number_str_keyval", --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239553325880.2724298839039; Wed, 31 May 2017 07:05:53 -0700 (PDT) Received: from localhost ([::1]:59700 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Fv-0001kT-E8 for importer@patchew.org; Wed, 31 May 2017 10:05:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG48z-0003kR-7n for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG48r-00043f-PF for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG48r-00043M-7g for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 312F9C04B92D for ; Wed, 31 May 2017 13:58:28 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CA2B52796; Wed, 31 May 2017 13:58:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 312F9C04B92D Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 312F9C04B92D From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:33 +0400 Message-Id: <20170531135709.345-10-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 31 May 2017 13:58:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 09/45] qapi: merge QInt and QFloat in QNum X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We would like to use a same QObject type to represent numbers, whether they are int, uint, or floats. Getters will allow some compatibility between the various types if the number fits other representations. Signed-off-by: Marc-Andr=C3=A9 Lureau --- scripts/qapi.py | 40 ++++----- scripts/qapi-visit.py | 2 +- include/qapi/qmp/qdict.h | 3 +- include/qapi/qmp/qfloat.h | 29 ------- include/qapi/qmp/qint.h | 28 ------ include/qapi/qmp/qlist.h | 3 +- include/qapi/qmp/qnum.h | 44 ++++++++++ include/qapi/qmp/types.h | 3 +- include/qapi/qobject-input-visitor.h | 6 +- include/qapi/qobject-output-visitor.h | 8 +- block/blkdebug.c | 1 - block/nbd.c | 1 - block/nfs.c | 1 - block/qapi.c | 13 ++- block/quorum.c | 1 - block/sheepdog.c | 1 - block/ssh.c | 1 - block/vvfat.c | 1 - blockdev.c | 8 +- hw/acpi/pcihp.c | 1 - hw/i386/acpi-build.c | 41 +++++++-- hw/usb/xen-usb.c | 1 - monitor.c | 2 +- qapi/qobject-input-visitor.c | 41 +++------ qapi/qobject-output-visitor.c | 6 +- qga/commands.c | 2 +- qga/main.c | 1 - qobject/json-parser.c | 29 +++---- qobject/qdict.c | 43 +++++----- qobject/qfloat.c | 62 -------------- qobject/qint.c | 61 ------------- qobject/qjson.c | 37 +------- qobject/qnum.c | 141 +++++++++++++++++++++++++++= ++++ qobject/qobject.c | 3 +- qom/object.c | 16 ++-- target/i386/cpu.c | 6 +- tests/check-qdict.c | 30 ++++--- tests/check-qfloat.c | 53 ------------ tests/check-qint.c | 87 ------------------- tests/check-qjson.c | 91 +++++++++++--------- tests/check-qlist.c | 18 ++-- tests/check-qnum.c | 133 +++++++++++++++++++++++++++= ++ tests/test-qmp-commands.c | 8 +- tests/test-qmp-event.c | 9 +- tests/test-qobject-input-visitor.c | 33 ++++---- tests/test-qobject-output-visitor.c | 66 +++++++++------ tests/test-x86-cpuid-compat.c | 20 +++-- ui/spice-core.c | 1 - ui/vnc-enc-tight.c | 1 - util/qemu-option.c | 20 ++--- MAINTAINERS | 3 +- qobject/Makefile.objs | 2 +- scripts/coccinelle/qobject.cocci | 4 +- tests/.gitignore | 3 +- tests/Makefile.include | 13 ++- tests/qapi-schema/comments.out | 2 +- tests/qapi-schema/doc-good.out | 2 +- tests/qapi-schema/empty.out | 2 +- tests/qapi-schema/event-case.out | 2 +- tests/qapi-schema/ident-with-escape.out | 2 +- tests/qapi-schema/include-relpath.out | 2 +- tests/qapi-schema/include-repetition.out | 2 +- tests/qapi-schema/include-simple.out | 2 +- tests/qapi-schema/indented-expr.out | 2 +- tests/qapi-schema/qapi-schema-test.out | 2 +- 65 files changed, 637 insertions(+), 665 deletions(-) delete mode 100644 include/qapi/qmp/qfloat.h delete mode 100644 include/qapi/qmp/qint.h create mode 100644 include/qapi/qmp/qnum.h delete mode 100644 qobject/qfloat.c delete mode 100644 qobject/qint.c create mode 100644 qobject/qnum.c delete mode 100644 tests/check-qfloat.c delete mode 100644 tests/check-qint.c create mode 100644 tests/check-qnum.c diff --git a/scripts/qapi.py b/scripts/qapi.py index 06e583d8c3..0de809f56b 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -21,18 +21,18 @@ from ordereddict import OrderedDict =20 builtin_types =3D { 'str': 'QTYPE_QSTRING', - 'int': 'QTYPE_QINT', - 'number': 'QTYPE_QFLOAT', + 'int': 'QTYPE_QNUM', + 'number': 'QTYPE_QNUM', 'bool': 'QTYPE_QBOOL', - 'int8': 'QTYPE_QINT', - 'int16': 'QTYPE_QINT', - 'int32': 'QTYPE_QINT', - 'int64': 'QTYPE_QINT', - 'uint8': 'QTYPE_QINT', - 'uint16': 'QTYPE_QINT', - 'uint32': 'QTYPE_QINT', - 'uint64': 'QTYPE_QINT', - 'size': 'QTYPE_QINT', + 'int8': 'QTYPE_QNUM', + 'int16': 'QTYPE_QNUM', + 'int32': 'QTYPE_QNUM', + 'int64': 'QTYPE_QNUM', + 'uint8': 'QTYPE_QNUM', + 'uint16': 'QTYPE_QNUM', + 'uint32': 'QTYPE_QNUM', + 'uint64': 'QTYPE_QNUM', + 'size': 'QTYPE_QNUM', 'any': None, # any QType possible, actually 'QType': 'QTYPE_QSTRING', } @@ -820,16 +820,10 @@ def check_alternate(expr, info): if v in ['on', 'off']: conflicting.add('QTYPE_QBOOL') if re.match(r'[-+0-9.]', v): # lazy, could be tightened - conflicting.add('QTYPE_QINT') - conflicting.add('QTYPE_QFLOAT') + conflicting.add('QTYPE_QNUM') else: - conflicting.add('QTYPE_QINT') - conflicting.add('QTYPE_QFLOAT') + conflicting.add('QTYPE_QNUM') conflicting.add('QTYPE_QBOOL') - elif qtype =3D=3D 'QTYPE_QINT': - conflicting.add('QTYPE_QFLOAT') - elif qtype =3D=3D 'QTYPE_QFLOAT': - conflicting.add('QTYPE_QINT') if conflicting & set(types_seen): raise QAPISemError(info, "Alternate '%s' member '%s' can't " "be distinguished from member '%s'" @@ -1063,8 +1057,8 @@ class QAPISchemaType(QAPISchemaEntity): def alternate_qtype(self): json2qtype =3D { 'string': 'QTYPE_QSTRING', - 'number': 'QTYPE_QFLOAT', - 'int': 'QTYPE_QINT', + 'number': 'QTYPE_QNUM', + 'int': 'QTYPE_QNUM', 'boolean': 'QTYPE_QBOOL', 'object': 'QTYPE_QDICT' } @@ -1526,9 +1520,9 @@ class QAPISchema(object): self.the_empty_object_type =3D QAPISchemaObjectType( 'q_empty', None, None, None, [], None) self._def_entity(self.the_empty_object_type) - qtype_values =3D self._make_enum_members(['none', 'qnull', 'qint', + qtype_values =3D self._make_enum_members(['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist= ', - 'qfloat', 'qbool']) + 'qbool']) self._def_entity(QAPISchemaEnumType('QType', None, None, qtype_values, 'QTYPE')) =20 diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 5737aefa05..cc447ecacc 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -164,7 +164,7 @@ def gen_visit_alternate(name, variants): promote_int =3D 'true' ret =3D '' for var in variants.variants: - if var.type.alternate_qtype() =3D=3D 'QTYPE_QINT': + if var.type.alternate_qtype() =3D=3D 'QTYPE_QNUM': promote_int =3D 'false' =20 ret +=3D mcgen(''' diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 188440a6a8..363e431106 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -15,6 +15,7 @@ =20 #include "qapi/qmp/qobject.h" #include "qapi/qmp/qlist.h" +#include "qapi/qmp/qnum.h" #include "qemu/queue.h" =20 #define QDICT_BUCKET_MAX 512 @@ -54,7 +55,7 @@ void qdict_destroy_obj(QObject *obj); =20 /* Helpers for int, bool, and string */ #define qdict_put_int(qdict, key, value) \ - qdict_put(qdict, key, qint_from_int(value)) + qdict_put(qdict, key, qnum_from_int(value)) #define qdict_put_bool(qdict, key, value) \ qdict_put(qdict, key, qbool_from_bool(value)) #define qdict_put_str(qdict, key, value) \ diff --git a/include/qapi/qmp/qfloat.h b/include/qapi/qmp/qfloat.h deleted file mode 100644 index b5d15836b5..0000000000 --- a/include/qapi/qmp/qfloat.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * QFloat Module - * - * Copyright IBM, Corp. 2009 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. - * See the COPYING.LIB file in the top-level directory. - * - */ - -#ifndef QFLOAT_H -#define QFLOAT_H - -#include "qapi/qmp/qobject.h" - -typedef struct QFloat { - QObject base; - double value; -} QFloat; - -QFloat *qfloat_from_double(double value); -double qfloat_get_double(const QFloat *qi); -QFloat *qobject_to_qfloat(const QObject *obj); -void qfloat_destroy_obj(QObject *obj); - -#endif /* QFLOAT_H */ diff --git a/include/qapi/qmp/qint.h b/include/qapi/qmp/qint.h deleted file mode 100644 index 3aaff768dd..0000000000 --- a/include/qapi/qmp/qint.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * QInt Module - * - * Copyright (C) 2009 Red Hat Inc. - * - * Authors: - * Luiz Capitulino - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. - * See the COPYING.LIB file in the top-level directory. - */ - -#ifndef QINT_H -#define QINT_H - -#include "qapi/qmp/qobject.h" - -typedef struct QInt { - QObject base; - int64_t value; -} QInt; - -QInt *qint_from_int(int64_t value); -int64_t qint_get_int(const QInt *qi); -QInt *qobject_to_qint(const QObject *obj); -void qint_destroy_obj(QObject *obj); - -#endif /* QINT_H */ diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index 5dc4ed9616..c4b5fdad9b 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -14,6 +14,7 @@ #define QLIST_H =20 #include "qapi/qmp/qobject.h" +#include "qapi/qmp/qnum.h" #include "qemu/queue.h" =20 typedef struct QListEntry { @@ -31,7 +32,7 @@ typedef struct QList { =20 /* Helpers for int, bool, and string */ #define qlist_append_int(qlist, value) \ - qlist_append(qlist, qint_from_int(value)) + qlist_append(qlist, qnum_from_int(value)) #define qlist_append_bool(qlist, value) \ qlist_append(qlist, qbool_from_bool(value)) #define qlist_append_str(qlist, value) \ diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h new file mode 100644 index 0000000000..cc636fac5f --- /dev/null +++ b/include/qapi/qmp/qnum.h @@ -0,0 +1,44 @@ +/* + * QNum Module + * + * Copyright (C) 2009 Red Hat Inc. + * + * Authors: + * Luiz Capitulino + * Marc-Andr=C3=A9 Lureau + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + */ + +#ifndef QNUM_H +#define QNUM_H + +#include "qapi/qmp/qobject.h" + +typedef enum { + QNUM_I64, + QNUM_DOUBLE +} QNumKind; + +typedef struct QNum { + QObject base; + QNumKind kind; + union { + int64_t i64; + double dbl; + } u; +} QNum; + +QNum *qnum_from_int(int64_t value); +QNum *qnum_from_double(double value); + +bool qnum_get_int(const QNum *qn, int64_t *val); +double qnum_get_double(QNum *qn); + +char *qnum_to_string(QNum *qn); + +QNum *qobject_to_qnum(const QObject *obj); +void qnum_destroy_obj(QObject *obj); + +#endif /* QNUM_H */ diff --git a/include/qapi/qmp/types.h b/include/qapi/qmp/types.h index 27cfbd84e5..a4bc662bfb 100644 --- a/include/qapi/qmp/types.h +++ b/include/qapi/qmp/types.h @@ -14,8 +14,7 @@ #define QAPI_QMP_TYPES_H =20 #include "qapi/qmp/qobject.h" -#include "qapi/qmp/qint.h" -#include "qapi/qmp/qfloat.h" +#include "qapi/qmp/qnum.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qdict.h" diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-in= put-visitor.h index b399285c43..daee18c6ac 100644 --- a/include/qapi/qobject-input-visitor.h +++ b/include/qapi/qobject-input-visitor.h @@ -30,9 +30,9 @@ typedef struct QObjectInputVisitor QObjectInputVisitor; * visit_type_FOO() creates an instance of QAPI type FOO. The visited * QObject must match FOO. QDict matches struct/union types, QList * matches list types, QString matches type 'str' and enumeration - * types, QInt matches integer types, QFloat matches type 'number', - * QBool matches type 'bool'. Type 'any' is matched by QObject. A - * QAPI alternate type is matched when one of its member types is. + * types, QNum matches integer and float types, QBool matches type + * 'bool'. Type 'any' is matched by QObject. A QAPI alternate type + * is matched when one of its member types is. * * visit_start_struct() ... visit_end_struct() visits a QDict and * creates a QAPI struct/union. Visits in between visit the diff --git a/include/qapi/qobject-output-visitor.h b/include/qapi/qobject-o= utput-visitor.h index 9b990c318e..e5a3490812 100644 --- a/include/qapi/qobject-output-visitor.h +++ b/include/qapi/qobject-output-visitor.h @@ -28,10 +28,10 @@ typedef struct QObjectOutputVisitor QObjectOutputVisito= r; * * visit_type_FOO() creates a QObject for QAPI type FOO. It creates a * QDict for struct/union types, a QList for list types, QString for - * type 'str' and enumeration types, QInt for integer types, QFloat - * for type 'number', QBool for type 'bool'. For type 'any', it - * increments the QObject's reference count. For QAPI alternate - * types, it creates the QObject for the member that is in use. + * type 'str' and enumeration types, QNum for integer and float + * types, QBool for type 'bool'. For type 'any', it increments the + * QObject's reference count. For QAPI alternate types, it creates + * the QObject for the member that is in use. * * visit_start_struct() ... visit_end_struct() visits a QAPI * struct/union and creates a QDict. Visits in between visit the diff --git a/block/blkdebug.c b/block/blkdebug.c index a5196e889d..0618fc71c6 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -31,7 +31,6 @@ #include "qemu/module.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" #include "sysemu/qtest.h" =20 diff --git a/block/nbd.c b/block/nbd.c index 975faab2c5..e946ea944d 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -37,7 +37,6 @@ #include "qapi/qobject-output-visitor.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" #include "qemu/cutils.h" =20 diff --git a/block/nfs.c b/block/nfs.c index 848b2c0bb0..decefd15f1 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -36,7 +36,6 @@ #include "qemu/cutils.h" #include "sysemu/sysemu.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" #include "qapi-visit.h" #include "qapi/qobject-input-visitor.h" diff --git a/block/qapi.c b/block/qapi.c index a40922ea26..2050df29e4 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -595,9 +595,11 @@ static void dump_qobject(fprintf_function func_fprintf= , void *f, int comp_indent, QObject *obj) { switch (qobject_type(obj)) { - case QTYPE_QINT: { - QInt *value =3D qobject_to_qint(obj); - func_fprintf(f, "%" PRId64, qint_get_int(value)); + case QTYPE_QNUM: { + QNum *value =3D qobject_to_qnum(obj); + char *tmp =3D qnum_to_string(value); + func_fprintf(f, "%s", tmp); + g_free(tmp); break; } case QTYPE_QSTRING: { @@ -615,11 +617,6 @@ static void dump_qobject(fprintf_function func_fprintf= , void *f, dump_qlist(func_fprintf, f, comp_indent, value); break; } - case QTYPE_QFLOAT: { - QFloat *value =3D qobject_to_qfloat(obj); - func_fprintf(f, "%g", qfloat_get_double(value)); - break; - } case QTYPE_QBOOL: { QBool *value =3D qobject_to_qbool(obj); func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false"= ); diff --git a/block/quorum.c b/block/quorum.c index 1b2a8c3937..55ba916655 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -19,7 +19,6 @@ #include "qapi/qmp/qbool.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qlist.h" #include "qapi/qmp/qstring.h" diff --git a/block/sheepdog.c b/block/sheepdog.c index a18315a1ca..dea9000bdd 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -16,7 +16,6 @@ #include "qapi-visit.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qmp/qint.h" #include "qapi/qobject-input-visitor.h" #include "qemu/uri.h" #include "qemu/error-report.h" diff --git a/block/ssh.c b/block/ssh.c index 11203fc5a2..bac3453c3e 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -34,7 +34,6 @@ #include "qemu/sockets.h" #include "qemu/uri.h" #include "qapi-visit.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" #include "qapi/qobject-input-visitor.h" #include "qapi/qobject-output-visitor.h" diff --git a/block/vvfat.c b/block/vvfat.c index 426ca70e35..8ab647c0c6 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -29,7 +29,6 @@ #include "qemu/module.h" #include "qemu/bswap.h" #include "migration/blocker.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qemu/cutils.h" diff --git a/blockdev.c b/blockdev.c index 892d768574..be18271c11 100644 --- a/blockdev.c +++ b/blockdev.c @@ -334,9 +334,11 @@ static bool parse_stats_intervals(BlockAcctStats *stat= s, QList *intervals, break; } =20 - case QTYPE_QINT: { - int64_t length =3D qint_get_int(qobject_to_qint(entry->value)); - if (length > 0 && length <=3D UINT_MAX) { + case QTYPE_QNUM: { + int64_t length; + + if (qnum_get_int(qobject_to_qnum(entry->value), &length) && + length > 0 && length <=3D UINT_MAX) { block_acct_add_interval(stats, (unsigned) length); } else { error_setg(errp, "Invalid interval length: %" PRId64, leng= th); diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 2b0f3e1bfb..3a531a4416 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -37,7 +37,6 @@ #include "hw/pci/pci_bus.h" #include "qapi/error.h" #include "qom/qom-qobject.h" -#include "qapi/qmp/qint.h" =20 //#define DEBUG =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 82bd44f38e..1709efdf1c 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -57,7 +57,6 @@ =20 #include "hw/acpi/aml-build.h" =20 -#include "qapi/qmp/qint.h" #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" @@ -129,6 +128,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) Object *lpc =3D ich9_lpc_find(); Object *obj =3D NULL; QObject *o; + int64_t val; =20 pm->cpu_hp_io_base =3D 0; pm->pcihp_io_base =3D 0; @@ -150,21 +150,30 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) /* Fill in optional s3/s4 related properties */ o =3D object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL); if (o) { - pm->s3_disabled =3D qint_get_int(qobject_to_qint(o)); + if (!qnum_get_int(qobject_to_qnum(o), &val)) { + g_assert_not_reached(); + } + pm->s3_disabled =3D val; } else { pm->s3_disabled =3D false; } qobject_decref(o); o =3D object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL); if (o) { - pm->s4_disabled =3D qint_get_int(qobject_to_qint(o)); + if (!qnum_get_int(qobject_to_qnum(o), &val)) { + g_assert_not_reached(); + } + pm->s4_disabled =3D val; } else { pm->s4_disabled =3D false; } qobject_decref(o); o =3D object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL); if (o) { - pm->s4_val =3D qint_get_int(qobject_to_qint(o)); + if (!qnum_get_int(qobject_to_qnum(o), &val)) { + g_assert_not_reached(); + } + pm->s4_val =3D val; } else { pm->s4_val =3D false; } @@ -529,7 +538,11 @@ static void build_append_pci_bus_devices(Aml *parent_s= cope, PCIBus *bus, =20 bsel =3D object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL= , NULL); if (bsel) { - int64_t bsel_val =3D qint_get_int(qobject_to_qint(bsel)); + int64_t bsel_val; + + if (!qnum_get_int(qobject_to_qnum(bsel), &bsel_val)) { + g_assert_not_reached(); + } =20 aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val))); notify_method =3D aml_method("DVNT", 2, AML_NOTSERIALIZED); @@ -639,7 +652,12 @@ static void build_append_pci_bus_devices(Aml *parent_s= cope, PCIBus *bus, =20 /* If bus supports hotplug select it and notify about local events */ if (bsel) { - int64_t bsel_val =3D qint_get_int(qobject_to_qint(bsel)); + int64_t bsel_val; + + if (!qnum_get_int(qobject_to_qnum(bsel), &bsel_val)) { + g_assert_not_reached(); + } + aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM"))); aml_append(method, aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check= */) @@ -2607,6 +2625,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) { Object *pci_host; QObject *o; + int64_t val; =20 pci_host =3D acpi_get_i386_pci_host(); g_assert(pci_host); @@ -2615,12 +2634,18 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) if (!o) { return false; } - mcfg->mcfg_base =3D qint_get_int(qobject_to_qint(o)); + if (!qnum_get_int(qobject_to_qnum(o), &val)) { + g_assert_not_reached(); + } + mcfg->mcfg_base =3D val; qobject_decref(o); =20 o =3D object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL); assert(o); - mcfg->mcfg_size =3D qint_get_int(qobject_to_qint(o)); + if (!qnum_get_int(qobject_to_qnum(o), &val)) { + g_assert_not_reached(); + } + mcfg->mcfg_size =3D val; qobject_decref(o); return true; } diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c index fe62183fe3..584a6f2442 100644 --- a/hw/usb/xen-usb.c +++ b/hw/usb/xen-usb.c @@ -30,7 +30,6 @@ #include "hw/xen/xen_backend.h" #include "monitor/qdev.h" #include "qapi/qmp/qbool.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" =20 #include "hw/xen/io/ring.h" diff --git a/monitor.c b/monitor.c index baa73c98b7..a8ac971015 100644 --- a/monitor.c +++ b/monitor.c @@ -2971,7 +2971,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, monitor_printf(mon, "Unknown unit suffix\n"); goto fail; } - qdict_put(qdict, key, qfloat_from_double(val)); + qdict_put(qdict, key, qnum_from_double(val)); } break; case 'b': diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index eac40f618a..b32318c352 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -378,9 +378,6 @@ static void qobject_input_start_alternate(Visitor *v, c= onst char *name, } *obj =3D g_malloc0(size); (*obj)->type =3D qobject_type(qobj); - if (promote_int && (*obj)->type =3D=3D QTYPE_QINT) { - (*obj)->type =3D QTYPE_QFLOAT; - } } =20 static void qobject_input_type_int64(Visitor *v, const char *name, int64_t= *obj, @@ -388,22 +385,18 @@ static void qobject_input_type_int64(Visitor *v, cons= t char *name, int64_t *obj, { QObjectInputVisitor *qiv =3D to_qiv(v); QObject *qobj =3D qobject_input_get_object(qiv, name, true, errp); - QInt *qint; + QNum *qnum; =20 if (!qobj) { return; } - qint =3D qobject_to_qint(qobj); - if (!qint) { + qnum =3D qobject_to_qnum(qobj); + if (!qnum || !qnum_get_int(qnum, obj)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, full_name(qiv, name), "integer"); - return; } - - *obj =3D qint_get_int(qint); } =20 - static void qobject_input_type_int64_keyval(Visitor *v, const char *name, int64_t *obj, Error **errp) { @@ -424,22 +417,21 @@ static void qobject_input_type_int64_keyval(Visitor *= v, const char *name, static void qobject_input_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) { - /* FIXME: qobject_to_qint mishandles values over INT64_MAX */ + /* FIXME: qobject_to_qnum mishandles values over INT64_MAX */ QObjectInputVisitor *qiv =3D to_qiv(v); QObject *qobj =3D qobject_input_get_object(qiv, name, true, errp); - QInt *qint; + QNum *qnum; + int64_t val; =20 if (!qobj) { return; } - qint =3D qobject_to_qint(qobj); - if (!qint) { + qnum =3D qobject_to_qnum(qobj); + if (!qnum || !qnum_get_int(qnum, &val)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, full_name(qiv, name), "integer"); - return; } - - *obj =3D qint_get_int(qint); + *obj =3D val; } =20 static void qobject_input_type_uint64_keyval(Visitor *v, const char *name, @@ -534,21 +526,14 @@ static void qobject_input_type_number(Visitor *v, con= st char *name, double *obj, { QObjectInputVisitor *qiv =3D to_qiv(v); QObject *qobj =3D qobject_input_get_object(qiv, name, true, errp); - QInt *qint; - QFloat *qfloat; + QNum *qnum; =20 if (!qobj) { return; } - qint =3D qobject_to_qint(qobj); - if (qint) { - *obj =3D qint_get_int(qobject_to_qint(qobj)); - return; - } - - qfloat =3D qobject_to_qfloat(qobj); - if (qfloat) { - *obj =3D qfloat_get_double(qobject_to_qfloat(qobj)); + qnum =3D qobject_to_qnum(qobj); + if (qnum) { + *obj =3D qnum_get_double(qnum); return; } =20 diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 871127079d..2ca5093b22 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -144,7 +144,7 @@ static void qobject_output_type_int64(Visitor *v, const= char *name, int64_t *obj, Error **errp) { QObjectOutputVisitor *qov =3D to_qov(v); - qobject_output_add(qov, name, qint_from_int(*obj)); + qobject_output_add(qov, name, qnum_from_int(*obj)); } =20 static void qobject_output_type_uint64(Visitor *v, const char *name, @@ -152,7 +152,7 @@ static void qobject_output_type_uint64(Visitor *v, cons= t char *name, { /* FIXME values larger than INT64_MAX become negative */ QObjectOutputVisitor *qov =3D to_qov(v); - qobject_output_add(qov, name, qint_from_int(*obj)); + qobject_output_add(qov, name, qnum_from_int(*obj)); } =20 static void qobject_output_type_bool(Visitor *v, const char *name, bool *o= bj, @@ -177,7 +177,7 @@ static void qobject_output_type_number(Visitor *v, cons= t char *name, double *obj, Error **errp) { QObjectOutputVisitor *qov =3D to_qov(v); - qobject_output_add(qov, name, qfloat_from_double(*obj)); + qobject_output_add(qov, name, qnum_from_double(*obj)); } =20 static void qobject_output_type_any(Visitor *v, const char *name, diff --git a/qga/commands.c b/qga/commands.c index 3333ed50b2..ff89e805cf 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -485,7 +485,7 @@ int ga_parse_whence(GuestFileWhence *whence, Error **er= rp) { /* Exploit the fact that we picked values to match QGA_SEEK_*. */ if (whence->type =3D=3D QTYPE_QSTRING) { - whence->type =3D QTYPE_QINT; + whence->type =3D QTYPE_QNUM; whence->u.value =3D whence->u.name; } switch (whence->u.value) { diff --git a/qga/main.c b/qga/main.c index cc58d2b53d..405c1290f8 100644 --- a/qga/main.c +++ b/qga/main.c @@ -19,7 +19,6 @@ #endif #include "qapi/qmp/json-streamer.h" #include "qapi/qmp/json-parser.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qjson.h" #include "qga/guest-agent-core.h" #include "qemu/module.h" diff --git a/qobject/json-parser.c b/qobject/json-parser.c index c18e48ab94..b90b2fb45a 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -466,16 +466,16 @@ static QObject *parse_escape(JSONParserContext *ctxt,= va_list *ap) } else if (!strcmp(token->str, "%i")) { return QOBJECT(qbool_from_bool(va_arg(*ap, int))); } else if (!strcmp(token->str, "%d")) { - return QOBJECT(qint_from_int(va_arg(*ap, int))); + return QOBJECT(qnum_from_int(va_arg(*ap, int))); } else if (!strcmp(token->str, "%ld")) { - return QOBJECT(qint_from_int(va_arg(*ap, long))); + return QOBJECT(qnum_from_int(va_arg(*ap, long))); } else if (!strcmp(token->str, "%lld") || !strcmp(token->str, "%I64d")) { - return QOBJECT(qint_from_int(va_arg(*ap, long long))); + return QOBJECT(qnum_from_int(va_arg(*ap, long long))); } else if (!strcmp(token->str, "%s")) { return QOBJECT(qstring_from_str(va_arg(*ap, const char *))); } else if (!strcmp(token->str, "%f")) { - return QOBJECT(qfloat_from_double(va_arg(*ap, double))); + return QOBJECT(qnum_from_double(va_arg(*ap, double))); } return NULL; } @@ -491,24 +491,21 @@ static QObject *parse_literal(JSONParserContext *ctxt) case JSON_STRING: return QOBJECT(qstring_from_escaped_str(ctxt, token)); case JSON_INTEGER: { - /* A possibility exists that this is a whole-valued float where the - * fractional part was left out due to being 0 (.0). It's not a big - * deal to treat these as ints in the parser, so long as users of = the - * resulting QObject know to expect a QInt in place of a QFloat in - * cases like these. + /* + * Represent JSON_INTEGER as QNUM_I64 if possible, else as + * QNUM_DOUBLE. Note that strtoll() fails with ERANGE when + * it's not possible. * - * However, in some cases these values will overflow/underflow a - * QInt/int64 container, thus we should assume these are to be han= dled - * as QFloats/doubles rather than silently changing their values. - * - * strtoll() indicates these instances by setting errno to ERANGE + * qnum_get_int() will then work for any signed 64-bit + * JSON_INTEGER, and qnum_get_double both for any JSON_INTEGER + * and any JSON_FLOAT. */ int64_t value; =20 errno =3D 0; /* strtoll doesn't set errno on success */ value =3D strtoll(token->str, NULL, 10); if (errno !=3D ERANGE) { - return QOBJECT(qint_from_int(value)); + return QOBJECT(qnum_from_int(value)); } /* fall through to JSON_FLOAT */ } @@ -516,7 +513,7 @@ static QObject *parse_literal(JSONParserContext *ctxt) /* FIXME dependent on locale; a pervasive issue in QEMU */ /* FIXME our lexer matches RFC 7159 in forbidding Inf or NaN, * but those might be useful extensions beyond JSON */ - return QOBJECT(qfloat_from_double(strtod(token->str, NULL))); + return QOBJECT(qnum_from_double(strtod(token->str, NULL))); default: abort(); } diff --git a/qobject/qdict.c b/qobject/qdict.c index 88e2ecd658..f62625cbd6 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -11,8 +11,7 @@ */ =20 #include "qemu/osdep.h" -#include "qapi/qmp/qint.h" -#include "qapi/qmp/qfloat.h" +#include "qapi/qmp/qnum.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" @@ -180,37 +179,32 @@ size_t qdict_size(const QDict *qdict) /** * qdict_get_double(): Get an number mapped by 'key' * - * This function assumes that 'key' exists and it stores a - * QFloat or QInt object. + * This function assumes that 'key' exists and it stores a QNum. * * Return number mapped by 'key'. */ double qdict_get_double(const QDict *qdict, const char *key) { - QObject *obj =3D qdict_get(qdict, key); - - assert(obj); - switch (qobject_type(obj)) { - case QTYPE_QFLOAT: - return qfloat_get_double(qobject_to_qfloat(obj)); - case QTYPE_QINT: - return qint_get_int(qobject_to_qint(obj)); - default: - abort(); - } + return qnum_get_double(qobject_to_qnum(qdict_get(qdict, key))); } =20 /** * qdict_get_int(): Get an integer mapped by 'key' * * This function assumes that 'key' exists and it stores a - * QInt object. + * QNum representable as int. * * Return integer mapped by 'key'. */ int64_t qdict_get_int(const QDict *qdict, const char *key) { - return qint_get_int(qobject_to_qint(qdict_get(qdict, key))); + int64_t val; + + if (!qnum_get_int(qobject_to_qnum(qdict_get(qdict, key)), &val)) { + g_assert_not_reached(); + } + + return val; } =20 /** @@ -259,16 +253,21 @@ const char *qdict_get_str(const QDict *qdict, const c= har *key) /** * qdict_get_try_int(): Try to get integer mapped by 'key' * - * Return integer mapped by 'key', if it is not present in - * the dictionary or if the stored object is not of QInt type - * 'def_value' will be returned. + * Return integer mapped by 'key', if it is not present in the + * dictionary or if the stored object is not a QNum representing an + * integer, 'def_value' will be returned. */ int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value) { - QInt *qint =3D qobject_to_qint(qdict_get(qdict, key)); + QNum *qnum =3D qobject_to_qnum(qdict_get(qdict, key)); + int64_t val; + + if (!qnum || !qnum_get_int(qnum, &val)) { + return def_value; + } =20 - return qint ? qint_get_int(qint) : def_value; + return val; } =20 /** diff --git a/qobject/qfloat.c b/qobject/qfloat.c deleted file mode 100644 index d5da847701..0000000000 --- a/qobject/qfloat.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * QFloat Module - * - * Copyright IBM, Corp. 2009 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. - * See the COPYING.LIB file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include "qapi/qmp/qfloat.h" -#include "qapi/qmp/qobject.h" -#include "qemu-common.h" - -/** - * qfloat_from_int(): Create a new QFloat from a float - * - * Return strong reference. - */ -QFloat *qfloat_from_double(double value) -{ - QFloat *qf; - - qf =3D g_malloc(sizeof(*qf)); - qobject_init(QOBJECT(qf), QTYPE_QFLOAT); - qf->value =3D value; - - return qf; -} - -/** - * qfloat_get_double(): Get the stored float - */ -double qfloat_get_double(const QFloat *qf) -{ - return qf->value; -} - -/** - * qobject_to_qfloat(): Convert a QObject into a QFloat - */ -QFloat *qobject_to_qfloat(const QObject *obj) -{ - if (!obj || qobject_type(obj) !=3D QTYPE_QFLOAT) { - return NULL; - } - return container_of(obj, QFloat, base); -} - -/** - * qfloat_destroy_obj(): Free all memory allocated by a - * QFloat object - */ -void qfloat_destroy_obj(QObject *obj) -{ - assert(obj !=3D NULL); - g_free(qobject_to_qfloat(obj)); -} diff --git a/qobject/qint.c b/qobject/qint.c deleted file mode 100644 index d7d1b3021f..0000000000 --- a/qobject/qint.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * QInt Module - * - * Copyright (C) 2009 Red Hat Inc. - * - * Authors: - * Luiz Capitulino - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. - * See the COPYING.LIB file in the top-level directory. - */ - -#include "qemu/osdep.h" -#include "qapi/qmp/qint.h" -#include "qapi/qmp/qobject.h" -#include "qemu-common.h" - -/** - * qint_from_int(): Create a new QInt from an int64_t - * - * Return strong reference. - */ -QInt *qint_from_int(int64_t value) -{ - QInt *qi; - - qi =3D g_malloc(sizeof(*qi)); - qobject_init(QOBJECT(qi), QTYPE_QINT); - qi->value =3D value; - - return qi; -} - -/** - * qint_get_int(): Get the stored integer - */ -int64_t qint_get_int(const QInt *qi) -{ - return qi->value; -} - -/** - * qobject_to_qint(): Convert a QObject into a QInt - */ -QInt *qobject_to_qint(const QObject *obj) -{ - if (!obj || qobject_type(obj) !=3D QTYPE_QINT) { - return NULL; - } - return container_of(obj, QInt, base); -} - -/** - * qint_destroy_obj(): Free all memory allocated by a - * QInt object - */ -void qint_destroy_obj(QObject *obj) -{ - assert(obj !=3D NULL); - g_free(qobject_to_qint(obj)); -} diff --git a/qobject/qjson.c b/qobject/qjson.c index b2f3bfec53..2e0930884e 100644 --- a/qobject/qjson.c +++ b/qobject/qjson.c @@ -132,12 +132,11 @@ static void to_json(const QObject *obj, QString *str,= int pretty, int indent) case QTYPE_QNULL: qstring_append(str, "null"); break; - case QTYPE_QINT: { - QInt *val =3D qobject_to_qint(obj); - char buffer[1024]; - - snprintf(buffer, sizeof(buffer), "%" PRId64, qint_get_int(val)); + case QTYPE_QNUM: { + QNum *val =3D qobject_to_qnum(obj); + char *buffer =3D qnum_to_string(val); qstring_append(str, buffer); + g_free(buffer); break; } case QTYPE_QSTRING: { @@ -234,34 +233,6 @@ static void to_json(const QObject *obj, QString *str, = int pretty, int indent) qstring_append(str, "]"); break; } - case QTYPE_QFLOAT: { - QFloat *val =3D qobject_to_qfloat(obj); - char buffer[1024]; - int len; - - /* FIXME: snprintf() is locale dependent; but JSON requires - * numbers to be formatted as if in the C locale. Dependence - * on C locale is a pervasive issue in QEMU. */ - /* FIXME: This risks printing Inf or NaN, which are not valid - * JSON values. */ - /* FIXME: the default precision of 6 for %f often causes - * rounding errors; we should be using DBL_DECIMAL_DIG (17), - * and only rounding to a shorter number if the result would - * still produce the same floating point value. */ - len =3D snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(v= al)); - while (len > 0 && buffer[len - 1] =3D=3D '0') { - len--; - } - - if (len && buffer[len - 1] =3D=3D '.') { - buffer[len - 1] =3D 0; - } else { - buffer[len] =3D 0; - } - - qstring_append(str, buffer); - break; - } case QTYPE_QBOOL: { QBool *val =3D qobject_to_qbool(obj); =20 diff --git a/qobject/qnum.c b/qobject/qnum.c new file mode 100644 index 0000000000..f16864160a --- /dev/null +++ b/qobject/qnum.c @@ -0,0 +1,141 @@ +/* + * QNum Module + * + * Copyright (C) 2009 Red Hat Inc. + * + * Authors: + * Luiz Capitulino + * Marc-Andr=C3=A9 Lureau + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qapi/qmp/qnum.h" +#include "qapi/qmp/qobject.h" +#include "qemu-common.h" + +/** + * qnum_from_int(): Create a new QNum from an int64_t + * + * Return strong reference. + */ +QNum *qnum_from_int(int64_t value) +{ + QNum *qn =3D g_new(QNum, 1); + + qobject_init(QOBJECT(qn), QTYPE_QNUM); + qn->kind =3D QNUM_I64; + qn->u.i64 =3D value; + + return qn; +} + +/** + * qnum_from_double(): Create a new QNum from a double + * + * Return strong reference. + */ +QNum *qnum_from_double(double value) +{ + QNum *qn =3D g_new(QNum, 1); + + qobject_init(QOBJECT(qn), QTYPE_QNUM); + qn->kind =3D QNUM_DOUBLE; + qn->u.dbl =3D value; + + return qn; +} + +/** + * qnum_get_int(): Get an integer representation of the number + * + * Return true on success. + */ +bool qnum_get_int(const QNum *qn, int64_t *val) +{ + switch (qn->kind) { + case QNUM_I64: + *val =3D qn->u.i64; + return true; + case QNUM_DOUBLE: + return false; + } + + g_assert_not_reached(); + return false; +} + +/** + * qnum_get_double(): Get a float representation of the number + */ +double qnum_get_double(QNum *qn) +{ + switch (qn->kind) { + case QNUM_I64: + return qn->u.i64; + case QNUM_DOUBLE: + return qn->u.dbl; + } + + g_assert_not_reached(); +} + +char *qnum_to_string(QNum *qn) +{ + char *buffer; + int len; + + switch (qn->kind) { + case QNUM_I64: + return g_strdup_printf("%" PRId64, qn->u.i64); + case QNUM_DOUBLE: + /* FIXME: snprintf() is locale dependent; but JSON requires + * numbers to be formatted as if in the C locale. Dependence + * on C locale is a pervasive issue in QEMU. */ + /* FIXME: This risks printing Inf or NaN, which are not valid + * JSON values. */ + /* FIXME: the default precision of 6 for %f often causes + * rounding errors; we should be using DBL_DECIMAL_DIG (17), + * and only rounding to a shorter number if the result would + * still produce the same floating point value. */ + buffer =3D g_strdup_printf("%f" , qn->u.dbl); + len =3D strlen(buffer); + while (len > 0 && buffer[len - 1] =3D=3D '0') { + len--; + } + + if (len && buffer[len - 1] =3D=3D '.') { + buffer[len - 1] =3D 0; + } else { + buffer[len] =3D 0; + } + + return buffer; + } + + g_assert_not_reached(); +} + +/** + * qobject_to_qnum(): Convert a QObject into a QNum + */ +QNum *qobject_to_qnum(const QObject *obj) +{ + if (!obj || qobject_type(obj) !=3D QTYPE_QNUM) { + return NULL; + } + return container_of(obj, QNum, base); +} + +/** + * qnum_destroy_obj(): Free all memory allocated by a + * QNum object + */ +void qnum_destroy_obj(QObject *obj) +{ + assert(obj !=3D NULL); + g_free(qobject_to_qnum(obj)); +} diff --git a/qobject/qobject.c b/qobject/qobject.c index fe4fa10989..b0cafb66f1 100644 --- a/qobject/qobject.c +++ b/qobject/qobject.c @@ -14,11 +14,10 @@ static void (*qdestroy[QTYPE__MAX])(QObject *) =3D { [QTYPE_NONE] =3D NULL, /* No such object exists */ [QTYPE_QNULL] =3D NULL, /* qnull_ is indestructible */ - [QTYPE_QINT] =3D qint_destroy_obj, + [QTYPE_QNUM] =3D qnum_destroy_obj, [QTYPE_QSTRING] =3D qstring_destroy_obj, [QTYPE_QDICT] =3D qdict_destroy_obj, [QTYPE_QLIST] =3D qlist_destroy_obj, - [QTYPE_QFLOAT] =3D qfloat_destroy_obj, [QTYPE_QBOOL] =3D qbool_destroy_obj, }; =20 diff --git a/qom/object.c b/qom/object.c index c7b8079df6..cf0e64a625 100644 --- a/qom/object.c +++ b/qom/object.c @@ -27,7 +27,6 @@ #include "qom/qom-qobject.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp/qbool.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qstring.h" =20 #define MAX_INTERFACES 32 @@ -1190,28 +1189,27 @@ bool object_property_get_bool(Object *obj, const ch= ar *name, void object_property_set_int(Object *obj, int64_t value, const char *name, Error **errp) { - QInt *qint =3D qint_from_int(value); - object_property_set_qobject(obj, QOBJECT(qint), name, errp); + QNum *qnum =3D qnum_from_int(value); + object_property_set_qobject(obj, QOBJECT(qnum), name, errp); =20 - QDECREF(qint); + QDECREF(qnum); } =20 int64_t object_property_get_int(Object *obj, const char *name, Error **errp) { QObject *ret =3D object_property_get_qobject(obj, name, errp); - QInt *qint; + QNum *qnum; int64_t retval; =20 if (!ret) { return -1; } - qint =3D qobject_to_qint(ret); - if (!qint) { + + qnum =3D qobject_to_qnum(ret); + if (!qnum || !qnum_get_int(qnum, &retval)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int"); retval =3D -1; - } else { - retval =3D qint_get_int(qint); } =20 qobject_decref(ret); diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a41d595c23..12882f0774 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -29,11 +29,7 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "qapi/qmp/qerror.h" -#include "qapi/qmp/qstring.h" -#include "qapi/qmp/qdict.h" -#include "qapi/qmp/qbool.h" -#include "qapi/qmp/qint.h" -#include "qapi/qmp/qfloat.h" +#include "qapi/qmp/types.h" =20 #include "qapi-types.h" #include "qapi-visit.h" diff --git a/tests/check-qdict.c b/tests/check-qdict.c index be8d81f07b..5c70490e83 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -11,7 +11,6 @@ */ #include "qemu/osdep.h" =20 -#include "qapi/qmp/qint.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qstring.h" #include "qapi/error.h" @@ -39,10 +38,11 @@ static void qdict_new_test(void) =20 static void qdict_put_obj_test(void) { - QInt *qi; + QNum *qi; QDict *qdict; QDictEntry *ent; const int num =3D 42; + int64_t val; =20 qdict =3D qdict_new(); =20 @@ -51,8 +51,9 @@ static void qdict_put_obj_test(void) =20 g_assert(qdict_size(qdict) =3D=3D 1); ent =3D QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]); - qi =3D qobject_to_qint(ent->value); - g_assert(qint_get_int(qi) =3D=3D num); + qi =3D qobject_to_qnum(ent->value); + g_assert(qnum_get_int(qi, &val)); + g_assert_cmpint(val, =3D=3D, num); =20 // destroy doesn't exit yet QDECREF(qi); @@ -74,19 +75,21 @@ static void qdict_destroy_simple_test(void) =20 static void qdict_get_test(void) { - QInt *qi; + QNum *qi; QObject *obj; const int value =3D -42; const char *key =3D "test"; QDict *tests_dict =3D qdict_new(); + int64_t val; =20 qdict_put_int(tests_dict, key, value); =20 obj =3D qdict_get(tests_dict, key); g_assert(obj !=3D NULL); =20 - qi =3D qobject_to_qint(obj); - g_assert(qint_get_int(qi) =3D=3D value); + qi =3D qobject_to_qnum(obj); + g_assert(qnum_get_int(qi, &val)); + g_assert_cmpint(val, =3D=3D, value); =20 QDECREF(tests_dict); } @@ -329,8 +332,9 @@ static void qdict_array_split_test(void) { QDict *test_dict =3D qdict_new(); QDict *dict1, *dict2; - QInt *int1; + QNum *int1; QList *test_list; + int64_t val; =20 /* * Test the split of @@ -380,7 +384,7 @@ static void qdict_array_split_test(void) =20 dict1 =3D qobject_to_qdict(qlist_pop(test_list)); dict2 =3D qobject_to_qdict(qlist_pop(test_list)); - int1 =3D qobject_to_qint(qlist_pop(test_list)); + int1 =3D qobject_to_qnum(qlist_pop(test_list)); =20 g_assert(dict1); g_assert(dict2); @@ -402,7 +406,8 @@ static void qdict_array_split_test(void) =20 QDECREF(dict2); =20 - g_assert(qint_get_int(int1) =3D=3D 66); + g_assert(qnum_get_int(int1, &val)); + g_assert_cmpint(val, =3D=3D, 66); =20 QDECREF(int1); =20 @@ -447,14 +452,15 @@ static void qdict_array_split_test(void) =20 qdict_array_split(test_dict, &test_list); =20 - int1 =3D qobject_to_qint(qlist_pop(test_list)); + int1 =3D qobject_to_qnum(qlist_pop(test_list)); =20 g_assert(int1); g_assert(qlist_empty(test_list)); =20 QDECREF(test_list); =20 - g_assert(qint_get_int(int1) =3D=3D 42); + g_assert(qnum_get_int(int1, &val)); + g_assert_cmpint(val, =3D=3D, 42); =20 QDECREF(int1); =20 diff --git a/tests/check-qfloat.c b/tests/check-qfloat.c deleted file mode 100644 index 1da2cdae08..0000000000 --- a/tests/check-qfloat.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * QFloat unit-tests. - * - * Copyright IBM, Corp. 2009 - * - * Authors: - * Anthony Liguori - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. - * See the COPYING.LIB file in the top-level directory. - * - */ -#include "qemu/osdep.h" - -#include "qapi/qmp/qfloat.h" -#include "qemu-common.h" - -/* - * Public Interface test-cases - * - * (with some violations to access 'private' data) - */ - -static void qfloat_from_double_test(void) -{ - QFloat *qf; - const double value =3D -42.23423; - - qf =3D qfloat_from_double(value); - g_assert(qf !=3D NULL); - g_assert(qf->value =3D=3D value); - g_assert(qf->base.refcnt =3D=3D 1); - g_assert(qobject_type(QOBJECT(qf)) =3D=3D QTYPE_QFLOAT); - - // destroy doesn't exit yet - g_free(qf); -} - -static void qfloat_destroy_test(void) -{ - QFloat *qf =3D qfloat_from_double(0.0); - QDECREF(qf); -} - -int main(int argc, char **argv) -{ - g_test_init(&argc, &argv, NULL); - - g_test_add_func("/public/from_double", qfloat_from_double_test); - g_test_add_func("/public/destroy", qfloat_destroy_test); - - return g_test_run(); -} diff --git a/tests/check-qint.c b/tests/check-qint.c deleted file mode 100644 index b6e4555115..0000000000 --- a/tests/check-qint.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - * QInt unit-tests. - * - * Copyright (C) 2009 Red Hat Inc. - * - * Authors: - * Luiz Capitulino - * - * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. - * See the COPYING.LIB file in the top-level directory. - */ -#include "qemu/osdep.h" - -#include "qapi/qmp/qint.h" -#include "qemu-common.h" - -/* - * Public Interface test-cases - * - * (with some violations to access 'private' data) - */ - -static void qint_from_int_test(void) -{ - QInt *qi; - const int value =3D -42; - - qi =3D qint_from_int(value); - g_assert(qi !=3D NULL); - g_assert(qi->value =3D=3D value); - g_assert(qi->base.refcnt =3D=3D 1); - g_assert(qobject_type(QOBJECT(qi)) =3D=3D QTYPE_QINT); - - // destroy doesn't exit yet - g_free(qi); -} - -static void qint_destroy_test(void) -{ - QInt *qi =3D qint_from_int(0); - QDECREF(qi); -} - -static void qint_from_int64_test(void) -{ - QInt *qi; - const int64_t value =3D 0x1234567890abcdefLL; - - qi =3D qint_from_int(value); - g_assert((int64_t) qi->value =3D=3D value); - - QDECREF(qi); -} - -static void qint_get_int_test(void) -{ - QInt *qi; - const int value =3D 123456; - - qi =3D qint_from_int(value); - g_assert(qint_get_int(qi) =3D=3D value); - - QDECREF(qi); -} - -static void qobject_to_qint_test(void) -{ - QInt *qi; - - qi =3D qint_from_int(0); - g_assert(qobject_to_qint(QOBJECT(qi)) =3D=3D qi); - - QDECREF(qi); -} - -int main(int argc, char **argv) -{ - g_test_init(&argc, &argv, NULL); - - g_test_add_func("/public/from_int", qint_from_int_test); - g_test_add_func("/public/destroy", qint_destroy_test); - g_test_add_func("/public/from_int64", qint_from_int64_test); - g_test_add_func("/public/get_int", qint_get_int_test); - g_test_add_func("/public/to_qint", qobject_to_qint_test); - - return g_test_run(); -} diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 963dd46f07..8ec728a702 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -886,21 +886,23 @@ static void simple_number(void) }; =20 for (i =3D 0; test_cases[i].encoded; i++) { - QInt *qint; + QNum *qnum; + int64_t val; =20 - qint =3D qobject_to_qint(qobject_from_json(test_cases[i].encoded, + qnum =3D qobject_to_qnum(qobject_from_json(test_cases[i].encoded, &error_abort)); - g_assert(qint); - g_assert(qint_get_int(qint) =3D=3D test_cases[i].decoded); + g_assert(qnum); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, test_cases[i].decoded); if (test_cases[i].skip =3D=3D 0) { QString *str; =20 - str =3D qobject_to_json(QOBJECT(qint)); + str =3D qobject_to_json(QOBJECT(qnum)); g_assert(strcmp(qstring_get_str(str), test_cases[i].encoded) = =3D=3D 0); QDECREF(str); } =20 - QDECREF(qint); + QDECREF(qnum); } } =20 @@ -921,12 +923,12 @@ static void float_number(void) =20 for (i =3D 0; test_cases[i].encoded; i++) { QObject *obj; - QFloat *qfloat; + QNum *qnum; =20 obj =3D qobject_from_json(test_cases[i].encoded, &error_abort); - qfloat =3D qobject_to_qfloat(obj); - g_assert(qfloat); - g_assert(qfloat_get_double(qfloat) =3D=3D test_cases[i].decoded); + qnum =3D qobject_to_qnum(obj); + g_assert(qnum); + g_assert(qnum_get_double(qnum) =3D=3D test_cases[i].decoded); =20 if (test_cases[i].skip =3D=3D 0) { QString *str; @@ -936,29 +938,31 @@ static void float_number(void) QDECREF(str); } =20 - QDECREF(qfloat); + QDECREF(qnum); } } =20 static void vararg_number(void) { - QInt *qint; - QFloat *qfloat; + QNum *qnum; int value =3D 0x2342; long long value_ll =3D 0x2342342343LL; double valuef =3D 2.323423423; + int64_t val; =20 - qint =3D qobject_to_qint(qobject_from_jsonf("%d", value)); - g_assert(qint_get_int(qint) =3D=3D value); - QDECREF(qint); + qnum =3D qobject_to_qnum(qobject_from_jsonf("%d", value)); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, value); + QDECREF(qnum); =20 - qint =3D qobject_to_qint(qobject_from_jsonf("%lld", value_ll)); - g_assert(qint_get_int(qint) =3D=3D value_ll); - QDECREF(qint); + qnum =3D qobject_to_qnum(qobject_from_jsonf("%lld", value_ll)); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, value_ll); + QDECREF(qnum); =20 - qfloat =3D qobject_to_qfloat(qobject_from_jsonf("%f", valuef)); - g_assert(qfloat_get_double(qfloat) =3D=3D valuef); - QDECREF(qfloat); + qnum =3D qobject_to_qnum(qobject_from_jsonf("%f", valuef)); + g_assert(qnum_get_double(qnum) =3D=3D valuef); + QDECREF(qnum); } =20 static void keyword_literal(void) @@ -1019,7 +1023,7 @@ struct LiteralQObject { int type; union { - int64_t qint; + int64_t qnum; const char *qstr; LiteralQDictEntry *qdict; LiteralQObject *qlist; @@ -1032,7 +1036,7 @@ struct LiteralQDictEntry LiteralQObject value; }; =20 -#define QLIT_QINT(val) (LiteralQObject){.type =3D QTYPE_QINT, .value.qint = =3D (val)} +#define QLIT_QNUM(val) (LiteralQObject){.type =3D QTYPE_QNUM, .value.qnum = =3D (val)} #define QLIT_QSTR(val) (LiteralQObject){.type =3D QTYPE_QSTRING, .value.qs= tr =3D (val)} #define QLIT_QDICT(val) (LiteralQObject){.type =3D QTYPE_QDICT, .value.qdi= ct =3D (val)} #define QLIT_QLIST(val) (LiteralQObject){.type =3D QTYPE_QLIST, .value.qli= st =3D (val)} @@ -1064,13 +1068,16 @@ static void compare_helper(QObject *obj, void *opaq= ue) =20 static int compare_litqobj_to_qobj(LiteralQObject *lhs, QObject *rhs) { + int64_t val; + if (!rhs || lhs->type !=3D qobject_type(rhs)) { return 0; } =20 switch (lhs->type) { - case QTYPE_QINT: - return lhs->value.qint =3D=3D qint_get_int(qobject_to_qint(rhs)); + case QTYPE_QNUM: + g_assert(qnum_get_int(qobject_to_qnum(rhs), &val)); + return lhs->value.qnum =3D=3D val; case QTYPE_QSTRING: return (strcmp(lhs->value.qstr, qstring_get_str(qobject_to_qstring= (rhs))) =3D=3D 0); case QTYPE_QDICT: { @@ -1114,7 +1121,7 @@ static void simple_dict(void) { .encoded =3D "{\"foo\": 42, \"bar\": \"hello world\"}", .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ - { "foo", QLIT_QINT(42) }, + { "foo", QLIT_QNUM(42) }, { "bar", QLIT_QSTR("hello world") }, { } })), @@ -1126,7 +1133,7 @@ static void simple_dict(void) }, { .encoded =3D "{\"foo\": 43}", .decoded =3D QLIT_QDICT(((LiteralQDictEntry[]){ - { "foo", QLIT_QINT(43) }, + { "foo", QLIT_QNUM(43) }, { } })), }, @@ -1212,15 +1219,15 @@ static void simple_list(void) { .encoded =3D "[43,42]", .decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QINT(43), - QLIT_QINT(42), + QLIT_QNUM(43), + QLIT_QNUM(42), { } })), }, { .encoded =3D "[43]", .decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QINT(43), + QLIT_QNUM(43), { } })), }, @@ -1269,35 +1276,35 @@ static void simple_whitespace(void) { .encoded =3D " [ 43 , 42 ]", .decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QINT(43), - QLIT_QINT(42), + QLIT_QNUM(43), + QLIT_QNUM(42), { } })), }, { .encoded =3D " [ 43 , { 'h' : 'b' }, [ ], 42 ]", .decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QINT(43), + QLIT_QNUM(43), QLIT_QDICT(((LiteralQDictEntry[]){ { "h", QLIT_QSTR("b") }, { }})), QLIT_QLIST(((LiteralQObject[]){ { }})), - QLIT_QINT(42), + QLIT_QNUM(42), { } })), }, { .encoded =3D " [ 43 , { 'h' : 'b' , 'a' : 32 }, [ ], 42 ]", .decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QINT(43), + QLIT_QNUM(43), QLIT_QDICT(((LiteralQDictEntry[]){ { "h", QLIT_QSTR("b") }, - { "a", QLIT_QINT(32) }, + { "a", QLIT_QNUM(32) }, { }})), QLIT_QLIST(((LiteralQObject[]){ { }})), - QLIT_QINT(42), + QLIT_QNUM(42), { } })), }, @@ -1327,11 +1334,11 @@ static void simple_varargs(void) QObject *embedded_obj; QObject *obj; LiteralQObject decoded =3D QLIT_QLIST(((LiteralQObject[]){ - QLIT_QINT(1), - QLIT_QINT(2), + QLIT_QNUM(1), + QLIT_QNUM(2), QLIT_QLIST(((LiteralQObject[]){ - QLIT_QINT(32), - QLIT_QINT(42), + QLIT_QNUM(32), + QLIT_QNUM(42), {}})), {}})); =20 diff --git a/tests/check-qlist.c b/tests/check-qlist.c index 4983867c27..5bc8bb6756 100644 --- a/tests/check-qlist.c +++ b/tests/check-qlist.c @@ -11,8 +11,8 @@ */ #include "qemu/osdep.h" =20 -#include "qapi/qmp/qint.h" -#include "qapi/qmp/qlist.h" +#include "qapi/error.h" +#include "qapi/qmp/types.h" =20 /* * Public Interface test-cases @@ -35,11 +35,11 @@ static void qlist_new_test(void) =20 static void qlist_append_test(void) { - QInt *qi; + QNum *qi; QList *qlist; QListEntry *entry; =20 - qi =3D qint_from_int(42); + qi =3D qnum_from_int(42); =20 qlist =3D qlist_new(); qlist_append(qlist, qi); @@ -84,13 +84,17 @@ static const int iter_max =3D 42; =20 static void iter_func(QObject *obj, void *opaque) { - QInt *qi; + QNum *qi; + int64_t val; =20 g_assert(opaque =3D=3D NULL); =20 - qi =3D qobject_to_qint(obj); + qi =3D qobject_to_qnum(obj); g_assert(qi !=3D NULL); - g_assert((qint_get_int(qi) >=3D 0) && (qint_get_int(qi) <=3D iter_max)= ); + + g_assert(qnum_get_int(qi, &val)); + g_assert_cmpint(val, >=3D, 0); + g_assert_cmpint(val, <=3D, iter_max); =20 iter_called++; } diff --git a/tests/check-qnum.c b/tests/check-qnum.c new file mode 100644 index 0000000000..4b3fec050e --- /dev/null +++ b/tests/check-qnum.c @@ -0,0 +1,133 @@ +/* + * QNum unit-tests. + * + * Copyright (C) 2009 Red Hat Inc. + * + * Authors: + * Luiz Capitulino + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or l= ater. + * See the COPYING.LIB file in the top-level directory. + */ +#include "qemu/osdep.h" + +#include "qapi/qmp/qnum.h" +#include "qapi/error.h" +#include "qemu-common.h" + +/* + * Public Interface test-cases + * + * (with some violations to access 'private' data) + */ + +static void qnum_from_int_test(void) +{ + QNum *qi; + const int value =3D -42; + + qi =3D qnum_from_int(value); + g_assert(qi !=3D NULL); + g_assert_cmpint(qi->u.i64, =3D=3D, value); + g_assert_cmpint(qi->base.refcnt, =3D=3D, 1); + g_assert_cmpint(qobject_type(QOBJECT(qi)), =3D=3D, QTYPE_QNUM); + + // destroy doesn't exit yet + g_free(qi); +} + +static void qnum_from_double_test(void) +{ + QNum *qf; + const double value =3D -42.23423; + + qf =3D qnum_from_double(value); + g_assert(qf !=3D NULL); + g_assert_cmpfloat(qf->u.dbl, =3D=3D, value); + g_assert_cmpint(qf->base.refcnt, =3D=3D, 1); + g_assert_cmpint(qobject_type(QOBJECT(qf)), =3D=3D, QTYPE_QNUM); + + // destroy doesn't exit yet + g_free(qf); +} + +static void qnum_from_int64_test(void) +{ + QNum *qi; + const int64_t value =3D 0x1234567890abcdefLL; + + qi =3D qnum_from_int(value); + g_assert_cmpint((int64_t) qi->u.i64, =3D=3D, value); + + QDECREF(qi); +} + +static void qnum_get_int_test(void) +{ + QNum *qi; + const int value =3D 123456; + int64_t val; + + qi =3D qnum_from_int(value); + g_assert(qnum_get_int(qi, &val)); + g_assert_cmpint(val, =3D=3D, value); + + QDECREF(qi); +} + +static void qobject_to_qnum_test(void) +{ + QNum *qn; + + qn =3D qnum_from_int(0); + g_assert(qobject_to_qnum(QOBJECT(qn)) =3D=3D qn); + QDECREF(qn); + + qn =3D qnum_from_double(0); + g_assert(qobject_to_qnum(QOBJECT(qn)) =3D=3D qn); + QDECREF(qn); +} + +static void qnum_to_string_test(void) +{ + QNum *qn; + char *tmp; + + qn =3D qnum_from_int(123456); + tmp =3D qnum_to_string(qn); + g_assert_cmpstr(tmp, =3D=3D, "123456"); + g_free(tmp); + QDECREF(qn); + + qn =3D qnum_from_double(0.42); + tmp =3D qnum_to_string(qn); + g_assert_cmpstr(tmp, =3D=3D, "0.42"); + g_free(tmp); + QDECREF(qn); +} + +static void qnum_destroy_test(void) +{ + QNum *qn; + + qn =3D qnum_from_int(0); + QDECREF(qn); + + qn =3D qnum_from_double(0.42); + QDECREF(qn); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + + g_test_add_func("/qnum/from_int", qnum_from_int_test); + g_test_add_func("/qnum/from_double", qnum_from_double_test); + g_test_add_func("/qnum/destroy", qnum_destroy_test); + g_test_add_func("/qnum/from_int64", qnum_from_int64_test); + g_test_add_func("/qnum/get_int", qnum_get_int_test); + g_test_add_func("/qnum/to_qnum", qobject_to_qnum_test); + g_test_add_func("/qnum/to_string", qnum_to_string_test); + + return g_test_run(); +} diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index acdded4d67..9c69c98781 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -162,7 +162,8 @@ static void test_dispatch_cmd_io(void) QDict *ud1b =3D qdict_new(); QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef; QDict *ret_dict_dict2, *ret_dict_dict2_userdef; - QInt *ret3; + QNum *ret3; + int64_t val; =20 qdict_put_int(ud1a, "integer", 42); qdict_put_str(ud1a, "string", "hello"); @@ -194,8 +195,9 @@ static void test_dispatch_cmd_io(void) qdict_put(req, "arguments", args3); qdict_put_str(req, "execute", "guest-get-time"); =20 - ret3 =3D qobject_to_qint(test_qmp_dispatch(req)); - assert(qint_get_int(ret3) =3D=3D 66); + ret3 =3D qobject_to_qnum(test_qmp_dispatch(req)); + g_assert(qnum_get_int(ret3, &val)); + g_assert_cmpint(val, =3D=3D, 66); QDECREF(ret3); =20 QDECREF(req); diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 4c0f09601d..c6a5ff38d0 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -18,7 +18,6 @@ #include "test-qapi-visit.h" #include "test-qapi-event.h" #include "qapi/qmp/types.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qobject.h" #include "qapi/qmp-event.h" =20 @@ -41,6 +40,7 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1, = void *opaque) { QObject *obj2; QDictCmpData d_new, *d =3D opaque; + int64_t val1, val2; =20 if (!d->result) { return; @@ -62,9 +62,10 @@ void qdict_cmp_do_simple(const char *key, QObject *obj1,= void *opaque) d->result =3D (qbool_get_bool(qobject_to_qbool(obj1)) =3D=3D qbool_get_bool(qobject_to_qbool(obj2))); return; - case QTYPE_QINT: - d->result =3D (qint_get_int(qobject_to_qint(obj1)) =3D=3D - qint_get_int(qobject_to_qint(obj2))); + case QTYPE_QNUM: + g_assert(qnum_get_int(qobject_to_qnum(obj1), &val1)); + g_assert(qnum_get_int(qobject_to_qnum(obj2), &val2)); + d->result =3D val1 =3D=3D val2; return; case QTYPE_QSTRING: d->result =3D g_strcmp0(qstring_get_str(qobject_to_qstring(obj1)), diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index f2ed3161af..e6757727fd 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -164,7 +164,7 @@ static void test_visitor_in_int_overflow(TestInputVisit= orData *data, Visitor *v; =20 /* this will overflow a Qint/int64, so should be deserialized into - * a QFloat/double field instead, leading to an error if we pass it + * a QNum/double field instead, leading to an error if we pass it * to visit_type_int. confirm this. */ v =3D visitor_input_test_init(data, "%f", DBL_MAX); @@ -466,17 +466,19 @@ static void test_visitor_in_any(TestInputVisitorData = *data, { QObject *res =3D NULL; Visitor *v; - QInt *qint; + QNum *qnum; QBool *qbool; QString *qstring; QDict *qdict; QObject *qobj; + int64_t val; =20 v =3D visitor_input_test_init(data, "-42"); visit_type_any(v, NULL, &res, &error_abort); - qint =3D qobject_to_qint(res); - g_assert(qint); - g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); + qnum =3D qobject_to_qnum(res); + g_assert(qnum); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, -42); qobject_decref(res); =20 v =3D visitor_input_test_init(data, "{ 'integer': -42, 'boolean': true= , 'string': 'foo' }"); @@ -485,9 +487,10 @@ static void test_visitor_in_any(TestInputVisitorData *= data, g_assert(qdict && qdict_size(qdict) =3D=3D 3); qobj =3D qdict_get(qdict, "integer"); g_assert(qobj); - qint =3D qobject_to_qint(qobj); - g_assert(qint); - g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); + qnum =3D qobject_to_qnum(qobj); + g_assert(qnum); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, -42); qobj =3D qdict_get(qdict, "boolean"); g_assert(qobj); qbool =3D qobject_to_qbool(qobj); @@ -565,7 +568,7 @@ static void test_visitor_in_alternate(TestInputVisitorD= ata *data, =20 v =3D visitor_input_test_init(data, "42"); visit_type_UserDefAlternate(v, NULL, &tmp, &error_abort); - g_assert_cmpint(tmp->type, =3D=3D, QTYPE_QINT); + g_assert_cmpint(tmp->type, =3D=3D, QTYPE_QNUM); g_assert_cmpint(tmp->u.i, =3D=3D, 42); qapi_free_UserDefAlternate(tmp); =20 @@ -593,7 +596,7 @@ static void test_visitor_in_alternate(TestInputVisitorD= ata *data, =20 v =3D visitor_input_test_init(data, "{ 'alt': 42 }"); visit_type_WrapAlternate(v, NULL, &wrap, &error_abort); - g_assert_cmpint(wrap->alt->type, =3D=3D, QTYPE_QINT); + g_assert_cmpint(wrap->alt->type, =3D=3D, QTYPE_QNUM); g_assert_cmpint(wrap->alt->u.i, =3D=3D, 42); qapi_free_WrapAlternate(wrap); =20 @@ -634,19 +637,19 @@ static void test_visitor_in_alternate_number(TestInpu= tVisitorData *data, =20 v =3D visitor_input_test_init(data, "42"); visit_type_AltEnumNum(v, NULL, &aen, &error_abort); - g_assert_cmpint(aen->type, =3D=3D, QTYPE_QFLOAT); + g_assert_cmpint(aen->type, =3D=3D, QTYPE_QNUM); g_assert_cmpfloat(aen->u.n, =3D=3D, 42); qapi_free_AltEnumNum(aen); =20 v =3D visitor_input_test_init(data, "42"); visit_type_AltNumEnum(v, NULL, &ans, &error_abort); - g_assert_cmpint(ans->type, =3D=3D, QTYPE_QFLOAT); + g_assert_cmpint(ans->type, =3D=3D, QTYPE_QNUM); g_assert_cmpfloat(ans->u.n, =3D=3D, 42); qapi_free_AltNumEnum(ans); =20 v =3D visitor_input_test_init(data, "42"); visit_type_AltEnumInt(v, NULL, &asi, &error_abort); - g_assert_cmpint(asi->type, =3D=3D, QTYPE_QINT); + g_assert_cmpint(asi->type, =3D=3D, QTYPE_QNUM); g_assert_cmpint(asi->u.i, =3D=3D, 42); qapi_free_AltEnumInt(asi); =20 @@ -659,13 +662,13 @@ static void test_visitor_in_alternate_number(TestInpu= tVisitorData *data, =20 v =3D visitor_input_test_init(data, "42.5"); visit_type_AltEnumNum(v, NULL, &aen, &error_abort); - g_assert_cmpint(aen->type, =3D=3D, QTYPE_QFLOAT); + g_assert_cmpint(aen->type, =3D=3D, QTYPE_QNUM); g_assert_cmpfloat(aen->u.n, =3D=3D, 42.5); qapi_free_AltEnumNum(aen); =20 v =3D visitor_input_test_init(data, "42.5"); visit_type_AltNumEnum(v, NULL, &ans, &error_abort); - g_assert_cmpint(ans->type, =3D=3D, QTYPE_QFLOAT); + g_assert_cmpint(ans->type, =3D=3D, QTYPE_QNUM); g_assert_cmpfloat(ans->u.n, =3D=3D, 42.5); qapi_free_AltNumEnum(ans); =20 diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 4e8fdf1397..3180d8cbde 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -58,13 +58,15 @@ static void test_visitor_out_int(TestOutputVisitorData = *data, const void *unused) { int64_t value =3D -42; - QInt *qint; + int64_t val; + QNum *qnum; =20 visit_type_int(data->ov, NULL, &value, &error_abort); =20 - qint =3D qobject_to_qint(visitor_get(data)); - g_assert(qint); - g_assert_cmpint(qint_get_int(qint), =3D=3D, value); + qnum =3D qobject_to_qnum(visitor_get(data)); + g_assert(qnum); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, value); } =20 static void test_visitor_out_bool(TestOutputVisitorData *data, @@ -84,13 +86,13 @@ static void test_visitor_out_number(TestOutputVisitorDa= ta *data, const void *unused) { double value =3D 3.14; - QFloat *qfloat; + QNum *qnum; =20 visit_type_number(data->ov, NULL, &value, &error_abort); =20 - qfloat =3D qobject_to_qfloat(visitor_get(data)); - g_assert(qfloat); - g_assert(qfloat_get_double(qfloat) =3D=3D value); + qnum =3D qobject_to_qnum(visitor_get(data)); + g_assert(qnum); + g_assert(qnum_get_double(qnum) =3D=3D value); } =20 static void test_visitor_out_string(TestOutputVisitorData *data, @@ -329,16 +331,18 @@ static void test_visitor_out_any(TestOutputVisitorDat= a *data, const void *unused) { QObject *qobj; - QInt *qint; + QNum *qnum; QBool *qbool; QString *qstring; QDict *qdict; + int64_t val; =20 - qobj =3D QOBJECT(qint_from_int(-42)); + qobj =3D QOBJECT(qnum_from_int(-42)); visit_type_any(data->ov, NULL, &qobj, &error_abort); - qint =3D qobject_to_qint(visitor_get(data)); - g_assert(qint); - g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); + qnum =3D qobject_to_qnum(visitor_get(data)); + g_assert(qnum); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, -42); qobject_decref(qobj); =20 visitor_reset(data); @@ -351,9 +355,10 @@ static void test_visitor_out_any(TestOutputVisitorData= *data, qobject_decref(qobj); qdict =3D qobject_to_qdict(visitor_get(data)); g_assert(qdict); - qint =3D qobject_to_qint(qdict_get(qdict, "integer")); - g_assert(qint); - g_assert_cmpint(qint_get_int(qint), =3D=3D, -42); + qnum =3D qobject_to_qnum(qdict_get(qdict, "integer")); + g_assert(qnum); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, -42); qbool =3D qobject_to_qbool(qdict_get(qdict, "boolean")); g_assert(qbool); g_assert(qbool_get_bool(qbool) =3D=3D true); @@ -388,18 +393,20 @@ static void test_visitor_out_alternate(TestOutputVisi= torData *data, const void *unused) { UserDefAlternate *tmp; - QInt *qint; + QNum *qnum; QString *qstr; QDict *qdict; + int64_t val; =20 tmp =3D g_new0(UserDefAlternate, 1); - tmp->type =3D QTYPE_QINT; + tmp->type =3D QTYPE_QNUM; tmp->u.i =3D 42; =20 visit_type_UserDefAlternate(data->ov, NULL, &tmp, &error_abort); - qint =3D qobject_to_qint(visitor_get(data)); - g_assert(qint); - g_assert_cmpint(qint_get_int(qint), =3D=3D, 42); + qnum =3D qobject_to_qnum(visitor_get(data)); + g_assert(qnum); + g_assert(qnum_get_int(qnum, &val)); + g_assert_cmpint(val, =3D=3D, 42); =20 qapi_free_UserDefAlternate(tmp); =20 @@ -603,18 +610,21 @@ static void check_native_list(QObject *qobj, case USER_DEF_NATIVE_LIST_UNION_KIND_U16: case USER_DEF_NATIVE_LIST_UNION_KIND_U32: case USER_DEF_NATIVE_LIST_UNION_KIND_U64: - /* all integer elements in JSON arrays get stored into QInts when + /* all integer elements in JSON arrays get stored into QNums when * we convert to QObjects, so we can check them all in the same * fashion, so simply fall through here */ case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: for (i =3D 0; i < 32; i++) { QObject *tmp; - QInt *qvalue; + QNum *qvalue; + int64_t val; + tmp =3D qlist_peek(qlist); g_assert(tmp); - qvalue =3D qobject_to_qint(tmp); - g_assert_cmpint(qint_get_int(qvalue), =3D=3D, i); + qvalue =3D qobject_to_qnum(tmp); + g_assert(qnum_get_int(qvalue, &val)); + g_assert_cmpint(val, =3D=3D, i); qobject_decref(qlist_pop(qlist)); } break; @@ -645,15 +655,15 @@ static void check_native_list(QObject *qobj, case USER_DEF_NATIVE_LIST_UNION_KIND_NUMBER: for (i =3D 0; i < 32; i++) { QObject *tmp; - QFloat *qvalue; + QNum *qvalue; GString *double_expected =3D g_string_new(""); GString *double_actual =3D g_string_new(""); =20 tmp =3D qlist_peek(qlist); g_assert(tmp); - qvalue =3D qobject_to_qfloat(tmp); + qvalue =3D qobject_to_qnum(tmp); g_string_printf(double_expected, "%.6f", (double)i / 3); - g_string_printf(double_actual, "%.6f", qfloat_get_double(qvalu= e)); + g_string_printf(double_actual, "%.6f", qnum_get_double(qvalue)= ); g_assert_cmpstr(double_actual->str, =3D=3D, double_expected->s= tr); =20 qobject_decref(qlist_pop(qlist)); diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 6c71e46391..f30f2030a8 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -1,10 +1,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" -#include "qapi/qmp/qlist.h" -#include "qapi/qmp/qstring.h" -#include "qapi/qmp/qdict.h" -#include "qapi/qmp/qint.h" -#include "qapi/qmp/qbool.h" +#include "qapi/error.h" +#include "qapi/qmp/types.h" #include "libqtest.h" =20 static char *get_cpu0_qom_path(void) @@ -57,12 +54,14 @@ static void test_cpuid_prop(const void *data) { const CpuidTestArgs *args =3D data; char *path; - QInt *value; + QNum *value; + int64_t val; =20 qtest_start(args->cmdline); path =3D get_cpu0_qom_path(); - value =3D qobject_to_qint(qom_get(path, args->property)); - g_assert_cmpint(qint_get_int(value), =3D=3D, args->expected_value); + value =3D qobject_to_qnum(qom_get(path, args->property)); + g_assert(qnum_get_int(value, &val)); + g_assert_cmpint(val, =3D=3D, args->expected_value); qtest_end(); =20 QDECREF(value); @@ -109,12 +108,15 @@ static uint32_t get_feature_word(QList *features, uin= t32_t eax, uint32_t ecx, uint32_t reax =3D qdict_get_int(w, "cpuid-input-eax"); bool has_ecx =3D qdict_haskey(w, "cpuid-input-ecx"); uint32_t recx =3D 0; + int64_t val; =20 if (has_ecx) { recx =3D qdict_get_int(w, "cpuid-input-ecx"); } if (eax =3D=3D reax && (!has_ecx || ecx =3D=3D recx) && !strcmp(rr= eg, reg)) { - return qint_get_int(qobject_to_qint(qdict_get(w, "features"))); + g_assert(qnum_get_int(qobject_to_qnum(qdict_get(w, "features")= ), + &val)); + return val; } } return 0; diff --git a/ui/spice-core.c b/ui/spice-core.c index 804abc5c0f..561d0649cf 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -30,7 +30,6 @@ #include "qemu-x509.h" #include "qemu/sockets.h" #include "qmp-commands.h" -#include "qapi/qmp/qint.h" #include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index 1e53b1cf84..89ab12c0d8 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -44,7 +44,6 @@ #endif =20 #include "qemu/bswap.h" -#include "qapi/qmp/qint.h" #include "vnc.h" #include "vnc-enc-tight.h" #include "vnc-palette.h" diff --git a/util/qemu-option.c b/util/qemu-option.c index 5977bfc3e9..39b1e06225 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -941,9 +941,8 @@ typedef struct OptsFromQDictState { static void qemu_opts_from_qdict_1(const char *key, QObject *obj, void *op= aque) { OptsFromQDictState *state =3D opaque; - char buf[32]; + char buf[32], *tmp =3D NULL; const char *value; - int n; =20 if (!strcmp(key, "id") || *state->errp) { return; @@ -953,17 +952,9 @@ static void qemu_opts_from_qdict_1(const char *key, QO= bject *obj, void *opaque) case QTYPE_QSTRING: value =3D qstring_get_str(qobject_to_qstring(obj)); break; - case QTYPE_QINT: - n =3D snprintf(buf, sizeof(buf), "%" PRId64, - qint_get_int(qobject_to_qint(obj))); - assert(n < sizeof(buf)); - value =3D buf; - break; - case QTYPE_QFLOAT: - n =3D snprintf(buf, sizeof(buf), "%.17g", - qfloat_get_double(qobject_to_qfloat(obj))); - assert(n < sizeof(buf)); - value =3D buf; + case QTYPE_QNUM: + tmp =3D qnum_to_string(qobject_to_qnum(obj)); + value =3D tmp; break; case QTYPE_QBOOL: pstrcpy(buf, sizeof(buf), @@ -975,12 +966,13 @@ static void qemu_opts_from_qdict_1(const char *key, Q= Object *obj, void *opaque) } =20 qemu_opt_set(state->opts, key, value, state->errp); + g_free(tmp); } =20 /* * Create QemuOpts from a QDict. * Use value of key "id" as ID if it exists and is a QString. - * Only QStrings, QInts, QFloats and QBools are copied. Entries with + * Only QStrings, QNums and QBools are copied. Entries with * other types are silently ignored. */ QemuOpts *qemu_opts_from_qdict(QemuOptsList *list, const QDict *qdict, diff --git a/MAINTAINERS b/MAINTAINERS index 7df088259b..b53054111a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1412,8 +1412,7 @@ F: include/qapi/qmp/ X: include/qapi/qmp/dispatch.h F: scripts/coccinelle/qobject.cocci F: tests/check-qdict.c -F: tests/check-qfloat.c -F: tests/check-qint.c +F: tests/check-qnum.c F: tests/check-qjson.c F: tests/check-qlist.c F: tests/check-qstring.c diff --git a/qobject/Makefile.objs b/qobject/Makefile.objs index bed55084bb..fc8885c9a4 100644 --- a/qobject/Makefile.objs +++ b/qobject/Makefile.objs @@ -1,2 +1,2 @@ -util-obj-y =3D qnull.o qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o +util-obj-y =3D qnull.o qnum.o qstring.o qdict.o qlist.o qbool.o util-obj-y +=3D qjson.o qobject.o json-lexer.o json-streamer.o json-parser= .o diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.= cocci index 97703a438b..c3253deb1b 100644 --- a/scripts/coccinelle/qobject.cocci +++ b/scripts/coccinelle/qobject.cocci @@ -6,7 +6,7 @@ expression Obj, Key, E; - qdict_put_obj(Obj, Key, QOBJECT(E)); + qdict_put(Obj, Key, E); | -- qdict_put(Obj, Key, qint_from_int(E)); +- qdict_put(Obj, Key, qnum_from_int(E)); + qdict_put_int(Obj, Key, E); | - qdict_put(Obj, Key, qbool_from_bool(E)); @@ -24,7 +24,7 @@ expression Obj, E; - qlist_append_obj(Obj, QOBJECT(E)); + qlist_append(Obj, E); | -- qlist_append(Obj, qint_from_int(E)); +- qlist_append(Obj, qnum_from_int(E)); + qlist_append_int(Obj, E); | - qlist_append(Obj, qbool_from_bool(E)); diff --git a/tests/.gitignore b/tests/.gitignore index 40c2e3e757..8e01b004f1 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,7 +1,6 @@ atomic_add-bench check-qdict -check-qfloat -check-qint +check-qnum check-qjson check-qlist check-qnull diff --git a/tests/Makefile.include b/tests/Makefile.include index f42f3dfa72..fec5af765a 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -10,10 +10,8 @@ check-unit-y =3D tests/check-qdict$(EXESUF) gcov-files-check-qdict-y =3D qobject/qdict.c check-unit-y +=3D tests/test-char$(EXESUF) gcov-files-check-qdict-y =3D chardev/char.c -check-unit-y +=3D tests/check-qfloat$(EXESUF) -gcov-files-check-qfloat-y =3D qobject/qfloat.c -check-unit-y +=3D tests/check-qint$(EXESUF) -gcov-files-check-qint-y =3D qobject/qint.c +check-unit-y +=3D tests/check-qnum$(EXESUF) +gcov-files-check-qnum-y =3D qobject/qnum.c check-unit-y +=3D tests/check-qstring$(EXESUF) gcov-files-check-qstring-y =3D qobject/qstring.c check-unit-y +=3D tests/check-qlist$(EXESUF) @@ -506,8 +504,8 @@ GENERATED_FILES +=3D tests/test-qapi-types.h tests/test= -qapi-visit.h \ tests/test-qmp-commands.h tests/test-qapi-event.h \ tests/test-qmp-introspect.h =20 -test-obj-y =3D tests/check-qint.o tests/check-qstring.o tests/check-qdict.= o \ - tests/check-qlist.o tests/check-qfloat.o tests/check-qnull.o \ +test-obj-y =3D tests/check-qnum.o tests/check-qstring.o tests/check-qdict.= o \ + tests/check-qlist.o tests/check-qnull.o \ tests/check-qjson.o \ tests/test-coroutine.o tests/test-string-output-visitor.o \ tests/test-string-input-visitor.o tests/test-qobject-output-visitor.o \ @@ -535,11 +533,10 @@ test-crypto-obj-y =3D $(crypto-obj-y) $(test-qom-obj-= y) test-io-obj-y =3D $(io-obj-y) $(test-crypto-obj-y) test-block-obj-y =3D $(block-obj-y) $(test-io-obj-y) tests/iothread.o =20 -tests/check-qint$(EXESUF): tests/check-qint.o $(test-util-obj-y) +tests/check-qnum$(EXESUF): tests/check-qnum.o $(test-util-obj-y) tests/check-qstring$(EXESUF): tests/check-qstring.o $(test-util-obj-y) tests/check-qdict$(EXESUF): tests/check-qdict.o $(test-util-obj-y) tests/check-qlist$(EXESUF): tests/check-qlist.o $(test-util-obj-y) -tests/check-qfloat$(EXESUF): tests/check-qfloat.o $(test-util-obj-y) tests/check-qnull$(EXESUF): tests/check-qnull.o $(test-util-obj-y) tests/check-qjson$(EXESUF): tests/check-qjson.o $(test-util-obj-y) tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(test-qom= -obj-y) diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out index 5d7c13cad1..17e652535c 100644 --- a/tests/qapi-schema/comments.out +++ b/tests/qapi-schema/comments.out @@ -1,4 +1,4 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out index 70c1252408..63ca25a8b9 100644 --- a/tests/qapi-schema/doc-good.out +++ b/tests/qapi-schema/doc-good.out @@ -6,7 +6,7 @@ object Object tag base1 case one: Variant1 case two: Variant2 -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE object SugaredUnion member type: SugaredUnionKind optional=3DFalse diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out index 8a5b034424..40b886ddae 100644 --- a/tests/qapi-schema/empty.out +++ b/tests/qapi-schema/empty.out @@ -1,3 +1,3 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE object q_empty diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-cas= e.out index 5a0f2bf805..313c0fe7be 100644 --- a/tests/qapi-schema/event-case.out +++ b/tests/qapi-schema/event-case.out @@ -1,4 +1,4 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE event oops None boxed=3DFalse diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/id= ent-with-escape.out index 1d2722c02e..b5637cb2e0 100644 --- a/tests/qapi-schema/ident-with-escape.out +++ b/tests/qapi-schema/ident-with-escape.out @@ -1,4 +1,4 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE command fooA q_obj_fooA-arg -> None gen=3DTrue success_response=3DTrue boxed=3DFalse diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/incl= ude-relpath.out index 5d7c13cad1..17e652535c 100644 --- a/tests/qapi-schema/include-relpath.out +++ b/tests/qapi-schema/include-relpath.out @@ -1,4 +1,4 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/i= nclude-repetition.out index 5d7c13cad1..17e652535c 100644 --- a/tests/qapi-schema/include-repetition.out +++ b/tests/qapi-schema/include-repetition.out @@ -1,4 +1,4 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/inclu= de-simple.out index 5d7c13cad1..17e652535c 100644 --- a/tests/qapi-schema/include-simple.out +++ b/tests/qapi-schema/include-simple.out @@ -1,4 +1,4 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE enum Status ['good', 'bad', 'ugly'] object q_empty diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indent= ed-expr.out index e8171c935f..586795f44d 100644 --- a/tests/qapi-schema/indented-expr.out +++ b/tests/qapi-schema/indented-expr.out @@ -1,4 +1,4 @@ -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE command eins None -> None gen=3DTrue success_response=3DTrue boxed=3DFalse diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qap= i-schema-test.out index e727a5a84c..b88b8aae6f 100644 --- a/tests/qapi-schema/qapi-schema-test.out +++ b/tests/qapi-schema/qapi-schema-test.out @@ -50,7 +50,7 @@ object NestedEnumsOne member enum4: EnumOne optional=3DTrue enum QEnumTwo ['value1', 'value2'] prefix QENUM_TWO -enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat'= , 'qbool'] +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool'] prefix QTYPE object TestStruct member integer: int optional=3DFalse --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239304002782.2396203796352; Wed, 31 May 2017 07:01:44 -0700 (PDT) Received: from localhost ([::1]:59681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Bu-0006aI-9l for importer@patchew.org; Wed, 31 May 2017 10:01:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG48y-0003jn-Jk for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG48x-00044H-5M for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG48w-00044B-Sw for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:35 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C500236807 for ; Wed, 31 May 2017 13:58:33 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE5E67FDC4; Wed, 31 May 2017 13:58:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C500236807 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C500236807 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:34 +0400 Message-Id: <20170531135709.345-11-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 13:58:33 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 10/45] qapi: Remove visit_start_alternate() parameter promote_int X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Before the previous commit, parameter promote_int =3D true made visit_start_alternate() with an input visitor avoid QTYPE_QINT variants and create QTYPE_QFLOAT variants instead. This was used where QTYPE_QINT variants were invalid. The previous commit fused QTYPE_QINT with QTYPE_QFLOAT, rendering rendering promote_int useless and unused. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/visitor.h | 4 +--- include/qapi/visitor-impl.h | 2 +- scripts/qapi-visit.py | 12 +++--------- qapi/qapi-visit-core.c | 6 +++--- qapi/qapi-clone-visitor.c | 2 +- qapi/qapi-dealloc-visitor.c | 2 +- qapi/qobject-input-visitor.c | 2 +- tests/test-qobject-input-visitor.c | 2 +- qapi/trace-events | 2 +- 9 files changed, 13 insertions(+), 21 deletions(-) diff --git a/include/qapi/visitor.h b/include/qapi/visitor.h index 4721c39ae3..74768aabda 100644 --- a/include/qapi/visitor.h +++ b/include/qapi/visitor.h @@ -410,15 +410,13 @@ void visit_end_list(Visitor *v, void **list); * the qtype of the next thing to be visited, stored in (*@obj)->type. * Other visitors will leave @obj unchanged. * - * If @promote_int, treat integers as QTYPE_FLOAT. - * * If successful, this must be paired with visit_end_alternate() with * the same @obj to clean up, even if visiting the contents of the * alternate fails. */ void visit_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t size, - bool promote_int, Error **errp); + Error **errp); =20 /* * Finish visiting an alternate type. diff --git a/include/qapi/visitor-impl.h b/include/qapi/visitor-impl.h index e87709db5c..dcd656ab76 100644 --- a/include/qapi/visitor-impl.h +++ b/include/qapi/visitor-impl.h @@ -71,7 +71,7 @@ struct Visitor * optional for output visitors. */ void (*start_alternate)(Visitor *v, const char *name, GenericAlternate **obj, size_t size, - bool promote_int, Error **errp); + Error **errp); =20 /* Optional, needed for dealloc visitor */ void (*end_alternate)(Visitor *v, void **obj); diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index cc447ecacc..bd0b742236 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -161,20 +161,14 @@ void visit_type_%(c_name)s(Visitor *v, const char *na= me, %(c_name)s *obj, Error =20 =20 def gen_visit_alternate(name, variants): - promote_int =3D 'true' - ret =3D '' - for var in variants.variants: - if var.type.alternate_qtype() =3D=3D 'QTYPE_QNUM': - promote_int =3D 'false' - - ret +=3D mcgen(''' + ret =3D mcgen(''' =20 void visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj,= Error **errp) { Error *err =3D NULL; =20 visit_start_alternate(v, name, (GenericAlternate **)obj, sizeof(**obj), - %(promote_int)s, &err); + &err); if (err) { goto out; } @@ -183,7 +177,7 @@ void visit_type_%(c_name)s(Visitor *v, const char *name= , %(c_name)s **obj, Error } switch ((*obj)->type) { ''', - c_name=3Dc_name(name), promote_int=3Dpromote_int) + c_name=3Dc_name(name)) =20 for var in variants.variants: ret +=3D mcgen(''' diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index 43a09d147d..935a2c5bc9 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -106,15 +106,15 @@ void visit_end_list(Visitor *v, void **obj) =20 void visit_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t size, - bool promote_int, Error **errp) + Error **errp) { Error *err =3D NULL; =20 assert(obj && size >=3D sizeof(GenericAlternate)); assert(!(v->type & VISITOR_OUTPUT) || *obj); - trace_visit_start_alternate(v, name, obj, size, promote_int); + trace_visit_start_alternate(v, name, obj, size); if (v->start_alternate) { - v->start_alternate(v, name, obj, size, promote_int, &err); + v->start_alternate(v, name, obj, size, &err); } if (v->type & VISITOR_INPUT) { assert(v->start_alternate && !err !=3D !*obj); diff --git a/qapi/qapi-clone-visitor.c b/qapi/qapi-clone-visitor.c index de756bfb33..ed16d3a17f 100644 --- a/qapi/qapi-clone-visitor.c +++ b/qapi/qapi-clone-visitor.c @@ -70,7 +70,7 @@ static GenericList *qapi_clone_next_list(Visitor *v, Gene= ricList *tail, =20 static void qapi_clone_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t size, - bool promote_int, Error **errp) + Error **errp) { qapi_clone_start_struct(v, name, (void **)obj, size, errp); } diff --git a/qapi/qapi-dealloc-visitor.c b/qapi/qapi-dealloc-visitor.c index e39457bc79..fd6f9fb61c 100644 --- a/qapi/qapi-dealloc-visitor.c +++ b/qapi/qapi-dealloc-visitor.c @@ -38,7 +38,7 @@ static void qapi_dealloc_end_struct(Visitor *v, void **ob= j) =20 static void qapi_dealloc_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t si= ze, - bool promote_int, Error **errp) + Error **errp) { } =20 diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index b32318c352..74835ba339 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -367,7 +367,7 @@ static void qobject_input_end_list(Visitor *v, void **o= bj) =20 static void qobject_input_start_alternate(Visitor *v, const char *name, GenericAlternate **obj, size_t s= ize, - bool promote_int, Error **errp) + Error **errp) { QObjectInputVisitor *qiv =3D to_qiv(v); QObject *qobj =3D qobject_input_get_object(qiv, name, false, errp); diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index e6757727fd..983c59c474 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -1101,7 +1101,7 @@ static void test_visitor_in_fail_struct_missing(TestI= nputVisitorData *data, error_free_or_abort(&err); visit_start_list(v, "list", NULL, 0, &err); error_free_or_abort(&err); - visit_start_alternate(v, "alternate", &alt, sizeof(*alt), false, &err); + visit_start_alternate(v, "alternate", &alt, sizeof(*alt), &err); error_free_or_abort(&err); visit_optional(v, "optional", &present); g_assert(!present); diff --git a/qapi/trace-events b/qapi/trace-events index 339cacf0ad..3b57abaa37 100644 --- a/qapi/trace-events +++ b/qapi/trace-events @@ -11,7 +11,7 @@ visit_next_list(void *v, void *tail, size_t size) "v=3D%p= tail=3D%p size=3D%zu" visit_check_list(void *v) "v=3D%p" visit_end_list(void *v, void *obj) "v=3D%p obj=3D%p" =20 -visit_start_alternate(void *v, const char *name, void *obj, size_t size, b= ool promote_int) "v=3D%p name=3D%s obj=3D%p size=3D%zu promote_int=3D%d" +visit_start_alternate(void *v, const char *name, void *obj, size_t size) "= v=3D%p name=3D%s obj=3D%p size=3D%zu" visit_end_alternate(void *v, void *obj) "v=3D%p obj=3D%p" =20 visit_optional(void *v, const char *name, bool *present) "v=3D%p name=3D%s= present=3D%p" --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239701275964.3394630447624; Wed, 31 May 2017 07:08:21 -0700 (PDT) Received: from localhost ([::1]:59708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4IJ-0004Ah-IS for importer@patchew.org; Wed, 31 May 2017 10:08:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG498-0003s5-HO for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG495-00044z-Th for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48718) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG495-00044p-N7 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:43 -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 mx1.redhat.com (Postfix) with ESMTPS id A2280804EE for ; Wed, 31 May 2017 13:58:42 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACBCB18B9D; Wed, 31 May 2017 13:58:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A2280804EE Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A2280804EE From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:35 +0400 Message-Id: <20170531135709.345-12-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 May 2017 13:58:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 11/45] tests: remove /qnum/destroy test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The test isn't really useful. Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/check-qnum.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/tests/check-qnum.c b/tests/check-qnum.c index 4b3fec050e..7cc4262ee7 100644 --- a/tests/check-qnum.c +++ b/tests/check-qnum.c @@ -32,8 +32,7 @@ static void qnum_from_int_test(void) g_assert_cmpint(qi->base.refcnt, =3D=3D, 1); g_assert_cmpint(qobject_type(QOBJECT(qi)), =3D=3D, QTYPE_QNUM); =20 - // destroy doesn't exit yet - g_free(qi); + QDECREF(qi); } =20 static void qnum_from_double_test(void) @@ -47,8 +46,7 @@ static void qnum_from_double_test(void) g_assert_cmpint(qf->base.refcnt, =3D=3D, 1); g_assert_cmpint(qobject_type(QOBJECT(qf)), =3D=3D, QTYPE_QNUM); =20 - // destroy doesn't exit yet - g_free(qf); + QDECREF(qf); } =20 static void qnum_from_int64_test(void) @@ -106,24 +104,12 @@ static void qnum_to_string_test(void) QDECREF(qn); } =20 -static void qnum_destroy_test(void) -{ - QNum *qn; - - qn =3D qnum_from_int(0); - QDECREF(qn); - - qn =3D qnum_from_double(0.42); - QDECREF(qn); -} - int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); =20 g_test_add_func("/qnum/from_int", qnum_from_int_test); g_test_add_func("/qnum/from_double", qnum_from_double_test); - g_test_add_func("/qnum/destroy", qnum_destroy_test); g_test_add_func("/qnum/from_int64", qnum_from_int64_test); g_test_add_func("/qnum/get_int", qnum_get_int_test); g_test_add_func("/qnum/to_qnum", qobject_to_qnum_test); --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239847043828.5484045416964; Wed, 31 May 2017 07:10:47 -0700 (PDT) Received: from localhost ([::1]:59724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Kg-0006L7-BZ for importer@patchew.org; Wed, 31 May 2017 10:10:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49G-0003zv-Sc for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG49E-00046o-8s for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45798) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG49D-00046d-Vk for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4EE4448D7D for ; Wed, 31 May 2017 13:58:50 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58AB380723; Wed, 31 May 2017 13:58:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C4EE4448D7D Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C4EE4448D7D From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:36 +0400 Message-Id: <20170531135709.345-13-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 31 May 2017 13:58:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 12/45] qnum: add uint type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In order to store integer values superior to INT64_MAX, add a u64 internal representation. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qnum.h | 4 ++++ qobject/qnum.c | 51 +++++++++++++++++++++++++++++++++++++++++++++= ++++ tests/check-qnum.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h index cc636fac5f..549b2117ec 100644 --- a/include/qapi/qmp/qnum.h +++ b/include/qapi/qmp/qnum.h @@ -18,6 +18,7 @@ =20 typedef enum { QNUM_I64, + QNUM_U64, QNUM_DOUBLE } QNumKind; =20 @@ -26,14 +27,17 @@ typedef struct QNum { QNumKind kind; union { int64_t i64; + uint64_t u64; double dbl; } u; } QNum; =20 QNum *qnum_from_int(int64_t value); +QNum *qnum_from_uint(uint64_t value); QNum *qnum_from_double(double value); =20 bool qnum_get_int(const QNum *qn, int64_t *val); +bool qnum_get_uint(const QNum *qn, uint64_t *val); double qnum_get_double(QNum *qn); =20 char *qnum_to_string(QNum *qn); diff --git a/qobject/qnum.c b/qobject/qnum.c index f16864160a..4ad37ed5bc 100644 --- a/qobject/qnum.c +++ b/qobject/qnum.c @@ -34,6 +34,22 @@ QNum *qnum_from_int(int64_t value) } =20 /** + * qnum_from_uint(): Create a new QNum from an uint64_t + * + * Return strong reference. + */ +QNum *qnum_from_uint(uint64_t value) +{ + QNum *qn =3D g_new(QNum, 1); + + qobject_init(QOBJECT(qn), QTYPE_QNUM); + qn->kind =3D QNUM_U64; + qn->u.u64 =3D value; + + return qn; +} + +/** * qnum_from_double(): Create a new QNum from a double * * Return strong reference. @@ -60,6 +76,37 @@ bool qnum_get_int(const QNum *qn, int64_t *val) case QNUM_I64: *val =3D qn->u.i64; return true; + case QNUM_U64: + if (qn->u.u64 > INT64_MAX) { + return false; + } + *val =3D qn->u.u64; + return true; + case QNUM_DOUBLE: + return false; + } + + g_assert_not_reached(); + return false; +} + +/** + * qnum_get_uint(): Get an unsigned integer from the number + * + * Return true on success. + */ +bool qnum_get_uint(const QNum *qn, uint64_t *val) +{ + switch (qn->kind) { + case QNUM_I64: + if (qn->u.i64 < 0) { + return false; + } + *val =3D qn->u.i64; + return true; + case QNUM_U64: + *val =3D qn->u.u64; + return true; case QNUM_DOUBLE: return false; } @@ -76,6 +123,8 @@ double qnum_get_double(QNum *qn) switch (qn->kind) { case QNUM_I64: return qn->u.i64; + case QNUM_U64: + return qn->u.u64; case QNUM_DOUBLE: return qn->u.dbl; } @@ -91,6 +140,8 @@ char *qnum_to_string(QNum *qn) switch (qn->kind) { case QNUM_I64: return g_strdup_printf("%" PRId64, qn->u.i64); + case QNUM_U64: + return g_strdup_printf("%" PRIu64, qn->u.u64); case QNUM_DOUBLE: /* FIXME: snprintf() is locale dependent; but JSON requires * numbers to be formatted as if in the C locale. Dependence diff --git a/tests/check-qnum.c b/tests/check-qnum.c index 7cc4262ee7..234fd7fc82 100644 --- a/tests/check-qnum.c +++ b/tests/check-qnum.c @@ -35,6 +35,20 @@ static void qnum_from_int_test(void) QDECREF(qi); } =20 +static void qnum_from_uint_test(void) +{ + QNum *qu; + const int value =3D UINT_MAX; + + qu =3D qnum_from_int(value); + g_assert(qu !=3D NULL); + g_assert(qu->u.u64 =3D=3D value); + g_assert(qu->base.refcnt =3D=3D 1); + g_assert(qobject_type(QOBJECT(qu)) =3D=3D QTYPE_QNUM); + + QDECREF(qu); +} + static void qnum_from_double_test(void) { QNum *qf; @@ -73,6 +87,37 @@ static void qnum_get_int_test(void) QDECREF(qi); } =20 +static void qnum_get_uint_test(void) +{ + QNum *qn; + const int value =3D 123456; + uint64_t val; + int64_t ival; + + qn =3D qnum_from_uint(value); + g_assert(qnum_get_uint(qn, &val)); + g_assert_cmpuint(val, =3D=3D, value); + QDECREF(qn); + + qn =3D qnum_from_int(value); + g_assert(qnum_get_uint(qn, &val)); + g_assert_cmpuint(val, =3D=3D, value); + QDECREF(qn); + + /* invalid cases */ + qn =3D qnum_from_int(-1); + g_assert(!qnum_get_uint(qn, &val)); + QDECREF(qn); + + qn =3D qnum_from_uint(-1ULL); + g_assert(!qnum_get_int(qn, &ival)); + QDECREF(qn); + + qn =3D qnum_from_double(0.42); + g_assert(!qnum_get_uint(qn, &val)); + QDECREF(qn); +} + static void qobject_to_qnum_test(void) { QNum *qn; @@ -109,9 +154,11 @@ int main(int argc, char **argv) g_test_init(&argc, &argv, NULL); =20 g_test_add_func("/qnum/from_int", qnum_from_int_test); + g_test_add_func("/qnum/from_uint", qnum_from_uint_test); g_test_add_func("/qnum/from_double", qnum_from_double_test); g_test_add_func("/qnum/from_int64", qnum_from_int64_test); g_test_add_func("/qnum/get_int", qnum_get_int_test); + g_test_add_func("/qnum/get_uint", qnum_get_uint_test); g_test_add_func("/qnum/to_qnum", qobject_to_qnum_test); g_test_add_func("/qnum/to_string", qnum_to_string_test); =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239783002749.5602182262583; Wed, 31 May 2017 07:09:43 -0700 (PDT) Received: from localhost ([::1]:59716 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Jf-0005LY-70 for importer@patchew.org; Wed, 31 May 2017 10:09:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49M-000452-UU for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG49L-00049A-PK for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG49L-00048p-Gu for qemu-devel@nongnu.org; Wed, 31 May 2017 09:58:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 787127F6A4 for ; Wed, 31 May 2017 13:58:58 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id D211952795; Wed, 31 May 2017 13:58:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 787127F6A4 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 787127F6A4 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:37 +0400 Message-Id: <20170531135709.345-14-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 13:58:58 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 13/45] json: learn to parse uint64 numbers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Switch strtoll() usage to qemu_strtoi64() helper while at it. Add a few tests for large numbers. Signed-off-by: Marc-Andr=C3=A9 Lureau --- qobject/json-lexer.c | 4 ++++ qobject/json-parser.c | 30 ++++++++++++++++++++++++------ tests/check-qjson.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index af4a75e05b..980ba159d6 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -227,15 +227,18 @@ static const uint8_t json_lexer[][256] =3D { /* escape */ [IN_ESCAPE_LL] =3D { ['d'] =3D JSON_ESCAPE, + ['u'] =3D JSON_ESCAPE, }, =20 [IN_ESCAPE_L] =3D { ['d'] =3D JSON_ESCAPE, ['l'] =3D IN_ESCAPE_LL, + ['u'] =3D JSON_ESCAPE, }, =20 [IN_ESCAPE_I64] =3D { ['d'] =3D JSON_ESCAPE, + ['u'] =3D JSON_ESCAPE, }, =20 [IN_ESCAPE_I6] =3D { @@ -251,6 +254,7 @@ static const uint8_t json_lexer[][256] =3D { ['i'] =3D JSON_ESCAPE, ['p'] =3D JSON_ESCAPE, ['s'] =3D JSON_ESCAPE, + ['u'] =3D JSON_ESCAPE, ['f'] =3D JSON_ESCAPE, ['l'] =3D IN_ESCAPE_L, ['I'] =3D IN_ESCAPE_I, diff --git a/qobject/json-parser.c b/qobject/json-parser.c index b90b2fb45a..62dcac8128 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -12,6 +12,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/cutils.h" #include "qapi/error.h" #include "qemu-common.h" #include "qapi/qmp/types.h" @@ -472,6 +473,13 @@ static QObject *parse_escape(JSONParserContext *ctxt, = va_list *ap) } else if (!strcmp(token->str, "%lld") || !strcmp(token->str, "%I64d")) { return QOBJECT(qnum_from_int(va_arg(*ap, long long))); + } else if (!strcmp(token->str, "%u")) { + return QOBJECT(qnum_from_uint(va_arg(*ap, unsigned int))); + } else if (!strcmp(token->str, "%lu")) { + return QOBJECT(qnum_from_uint(va_arg(*ap, unsigned long))); + } else if (!strcmp(token->str, "%llu") || + !strcmp(token->str, "%I64u")) { + return QOBJECT(qnum_from_uint(va_arg(*ap, unsigned long long))); } else if (!strcmp(token->str, "%s")) { return QOBJECT(qstring_from_str(va_arg(*ap, const char *))); } else if (!strcmp(token->str, "%f")) { @@ -493,20 +501,30 @@ static QObject *parse_literal(JSONParserContext *ctxt) case JSON_INTEGER: { /* * Represent JSON_INTEGER as QNUM_I64 if possible, else as - * QNUM_DOUBLE. Note that strtoll() fails with ERANGE when - * it's not possible. + * QNUM_U64, else as QNUM_DOUBLE. Note that qemu_strtoi64() + * and qemu_strtou64 fail with ERANGE when it's not possible. * * qnum_get_int() will then work for any signed 64-bit - * JSON_INTEGER, and qnum_get_double both for any JSON_INTEGER + * JSON_INTEGER, qnum_get_uint() for any unsigned 64-bit + * integer, and qnum_get_double() both for any JSON_INTEGER * and any JSON_FLOAT. */ + int ret; int64_t value; + uint64_t uvalue; =20 - errno =3D 0; /* strtoll doesn't set errno on success */ - value =3D strtoll(token->str, NULL, 10); - if (errno !=3D ERANGE) { + ret =3D qemu_strtoi64(token->str, NULL, 10, &value); + if (!ret) { return QOBJECT(qnum_from_int(value)); } + assert(ret =3D=3D -ERANGE); + + if (token->str[0] !=3D '-') { + ret =3D qemu_strtou64(token->str, NULL, 10, &uvalue); + if (!ret) { + return QOBJECT(qnum_from_uint(uvalue)); + } + } /* fall through to JSON_FLOAT */ } case JSON_FLOAT: diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 8ec728a702..6fb14445a3 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -906,6 +906,42 @@ static void simple_number(void) } } =20 +static void large_number(void) +{ + const char *maxu64 =3D "18446744073709551615"; /* 2^64-1 */ + const char *gtu64 =3D "18446744073709551616"; /* 2^64 */ + const char *range =3D "-9223372036854775809"; + QNum *qnum; + QString *str; + uint64_t val; + + qnum =3D qobject_to_qnum(qobject_from_json(maxu64, &error_abort)); + g_assert(qnum); + g_assert(qnum_get_uint(qnum, &val)); + g_assert_cmpuint(val, =3D=3D, 18446744073709551615U); + + str =3D qobject_to_json(QOBJECT(qnum)); + g_assert_cmpstr(qstring_get_str(str), =3D=3D, maxu64); + QDECREF(str); + QDECREF(qnum); + + qnum =3D qobject_to_qnum(qobject_from_json(gtu64, &error_abort)); + g_assert(qnum); + g_assert_cmpfloat(qnum_get_double(qnum), >, 0); + g_assert(!qnum_get_uint(qnum, &val)); + + str =3D qobject_to_json(QOBJECT(qnum)); + g_assert_cmpstr(qstring_get_str(str), =3D=3D, gtu64); + QDECREF(str); + QDECREF(qnum); + + qnum =3D qobject_to_qnum(qobject_from_json(range, &error_abort)); + g_assert(qnum); + g_assert_cmpfloat(qnum_get_double(qnum), <, 0); + g_assert(!qnum_get_uint(qnum, &val)); + QDECREF(qnum); +} + static void float_number(void) { int i; @@ -1475,6 +1511,7 @@ int main(int argc, char **argv) g_test_add_func("/literals/string/vararg", vararg_string); =20 g_test_add_func("/literals/number/simple", simple_number); + g_test_add_func("/literals/number/large", large_number); g_test_add_func("/literals/number/float", float_number); g_test_add_func("/literals/number/vararg", vararg_number); =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239474238792.7143648554818; Wed, 31 May 2017 07:04:34 -0700 (PDT) Received: from localhost ([::1]:59690 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ec-0000f6-DI for importer@patchew.org; Wed, 31 May 2017 10:04:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49V-0004DG-Mo for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG49U-0004AV-Go for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59230) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG49U-0004AJ-85 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:08 -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 mx1.redhat.com (Postfix) with ESMTPS id 345DA80C15 for ; Wed, 31 May 2017 13:59:07 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id D56547F474; Wed, 31 May 2017 13:59:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 345DA80C15 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 345DA80C15 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:38 +0400 Message-Id: <20170531135709.345-15-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 13:59:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 14/45] qapi: update the qobject visitor to use QNUM_U64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Switch to use QNum/uint where appropriate to remove i64 limitation. The input visitor will cast i64 input to u64 for compatibility reasons (existing json QMP client already use negative i64 for large u64, and expect an implicit cast in qemu). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- hw/i386/acpi-build.c | 3 +-- qapi/qobject-input-visitor.c | 21 ++++++++++++++++----- qapi/qobject-output-visitor.c | 3 +-- tests/test-qobject-input-visitor.c | 7 ++----- tests/test-qobject-output-visitor.c | 28 +++++++++++++++++++++------- 5 files changed, 41 insertions(+), 21 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 1709efdf1c..ba2be1e9da 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2634,10 +2634,9 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) if (!o) { return false; } - if (!qnum_get_int(qobject_to_qnum(o), &val)) { + if (!qnum_get_uint(qobject_to_qnum(o), &mcfg->mcfg_base)) { g_assert_not_reached(); } - mcfg->mcfg_base =3D val; qobject_decref(o); =20 o =3D object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL); diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 74835ba339..7f9d6f57a1 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -417,7 +417,6 @@ static void qobject_input_type_int64_keyval(Visitor *v,= const char *name, static void qobject_input_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) { - /* FIXME: qobject_to_qnum mishandles values over INT64_MAX */ QObjectInputVisitor *qiv =3D to_qiv(v); QObject *qobj =3D qobject_input_get_object(qiv, name, true, errp); QNum *qnum; @@ -427,11 +426,23 @@ static void qobject_input_type_uint64(Visitor *v, con= st char *name, return; } qnum =3D qobject_to_qnum(qobj); - if (!qnum || !qnum_get_int(qnum, &val)) { - error_setg(errp, QERR_INVALID_PARAMETER_TYPE, - full_name(qiv, name), "integer"); + if (!qnum) { + goto err; + } + + if (qnum_get_uint(qnum, obj)) { + return; } - *obj =3D val; + + /* Need to accept negative values for backward compatibility */ + if (qnum_get_int(qnum, &val)) { + *obj =3D val; + return; + } + +err: + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, + full_name(qiv, name), "uint64"); } =20 static void qobject_input_type_uint64_keyval(Visitor *v, const char *name, diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 2ca5093b22..70be84ccb5 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -150,9 +150,8 @@ static void qobject_output_type_int64(Visitor *v, const= char *name, static void qobject_output_type_uint64(Visitor *v, const char *name, uint64_t *obj, Error **errp) { - /* FIXME values larger than INT64_MAX become negative */ QObjectOutputVisitor *qov =3D to_qov(v); - qobject_output_add(qov, name, qnum_from_int(*obj)); + qobject_output_add(qov, name, qnum_from_uint(*obj)); } =20 static void qobject_output_type_bool(Visitor *v, const char *name, bool *o= bj, diff --git a/tests/test-qobject-input-visitor.c b/tests/test-qobject-input-= visitor.c index 983c59c474..6f94fc677c 100644 --- a/tests/test-qobject-input-visitor.c +++ b/tests/test-qobject-input-visitor.c @@ -122,7 +122,6 @@ static void test_visitor_in_int(TestInputVisitorData *d= ata, static void test_visitor_in_uint(TestInputVisitorData *data, const void *unused) { - Error *err =3D NULL; uint64_t res =3D 0; int64_t i64; double dbl; @@ -146,12 +145,10 @@ static void test_visitor_in_uint(TestInputVisitorData= *data, visit_type_uint64(v, NULL, &res, &error_abort); g_assert_cmpuint(res, =3D=3D, (uint64_t)-value); =20 - /* BUG: value between INT64_MAX+1 and UINT64_MAX rejected */ - v =3D visitor_input_test_init(data, "18446744073709551574"); =20 - visit_type_uint64(v, NULL, &res, &err); - error_free_or_abort(&err); + visit_type_uint64(v, NULL, &res, &error_abort); + g_assert_cmpuint(res, =3D=3D, 18446744073709551574U); =20 visit_type_number(v, NULL, &dbl, &error_abort); } diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-outpu= t-visitor.c index 3180d8cbde..d9f106d52e 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -602,17 +602,31 @@ static void check_native_list(QObject *qobj, qlist =3D qlist_copy(qobject_to_qlist(qdict_get(qdict, "data"))); =20 switch (kind) { - case USER_DEF_NATIVE_LIST_UNION_KIND_S8: - case USER_DEF_NATIVE_LIST_UNION_KIND_S16: - case USER_DEF_NATIVE_LIST_UNION_KIND_S32: - case USER_DEF_NATIVE_LIST_UNION_KIND_S64: case USER_DEF_NATIVE_LIST_UNION_KIND_U8: case USER_DEF_NATIVE_LIST_UNION_KIND_U16: case USER_DEF_NATIVE_LIST_UNION_KIND_U32: case USER_DEF_NATIVE_LIST_UNION_KIND_U64: - /* all integer elements in JSON arrays get stored into QNums when - * we convert to QObjects, so we can check them all in the same - * fashion, so simply fall through here + for (i =3D 0; i < 32; i++) { + QObject *tmp; + QNum *qvalue; + uint64_t val; + + tmp =3D qlist_peek(qlist); + g_assert(tmp); + qvalue =3D qobject_to_qnum(tmp); + g_assert(qnum_get_uint(qvalue, &val)); + g_assert_cmpuint(val, =3D=3D, i); + qobject_decref(qlist_pop(qlist)); + } + break; + + case USER_DEF_NATIVE_LIST_UNION_KIND_S8: + case USER_DEF_NATIVE_LIST_UNION_KIND_S16: + case USER_DEF_NATIVE_LIST_UNION_KIND_S32: + case USER_DEF_NATIVE_LIST_UNION_KIND_S64: + /* All signed integer elements in JSON arrays get stored into + * QInts when we convert to QObjects, so we can check them all + * in the same fashion, so simply fall through here. */ case USER_DEF_NATIVE_LIST_UNION_KIND_INTEGER: for (i =3D 0; i < 32; i++) { --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239819737592.9072444816775; Wed, 31 May 2017 07:10:19 -0700 (PDT) Received: from localhost ([::1]:59717 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4KG-0005s0-36 for importer@patchew.org; Wed, 31 May 2017 10:10:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49g-0004Q1-SQ for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG49e-0004Cy-7X for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59612) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG49d-0004Cl-Vb for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E53B9C05972F for ; Wed, 31 May 2017 13:59:16 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC8D680E6E; Wed, 31 May 2017 13:59:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E53B9C05972F Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E53B9C05972F From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:39 +0400 Message-Id: <20170531135709.345-16-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 31 May 2017 13:59:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 15/45] object: add uint property setter/getter X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qom/object.h | 23 +++++++++++++++++++++++ qom/object.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index cd0f412ce9..abaeb8cf4e 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -1094,6 +1094,29 @@ int64_t object_property_get_int(Object *obj, const c= har *name, Error **errp); =20 /** + * object_property_set_uint: + * @value: the value to be written to the property + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Writes an unsigned integer value to a property. + */ +void object_property_set_uint(Object *obj, uint64_t value, + const char *name, Error **errp); + +/** + * object_property_get_uint: + * @obj: the object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Returns: the value of the property, converted to an unsigned integer, o= r 0 + * an error occurs (including when the property value is not an integer). + */ +uint64_t object_property_get_uint(Object *obj, const char *name, + Error **errp); + +/** * object_property_get_enum: * @obj: the object * @name: the name of the property diff --git a/qom/object.c b/qom/object.c index cf0e64a625..3adeb762ea 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1216,6 +1216,35 @@ int64_t object_property_get_int(Object *obj, const c= har *name, return retval; } =20 +void object_property_set_uint(Object *obj, uint64_t value, + const char *name, Error **errp) +{ + QNum *qnum =3D qnum_from_uint(value); + + object_property_set_qobject(obj, QOBJECT(qnum), name, errp); + QDECREF(qnum); +} + +uint64_t object_property_get_uint(Object *obj, const char *name, + Error **errp) +{ + QObject *ret =3D object_property_get_qobject(obj, name, errp); + QNum *qnum; + uint64_t retval; + + if (!ret) { + return 0; + } + qnum =3D qobject_to_qnum(ret); + if (!qnum || !qnum_get_uint(qnum, &retval)) { + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "uint"); + retval =3D 0; + } + + qobject_decref(ret); + return retval; +} + typedef struct EnumProperty { const char * const *strings; int (*get)(Object *, Error **); --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239966937950.672424413565; Wed, 31 May 2017 07:12:46 -0700 (PDT) Received: from localhost ([::1]:59730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ma-0008D1-FS for importer@patchew.org; Wed, 31 May 2017 10:12:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52434) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49t-0004ly-Vm for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG49n-0004GJ-Pz for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40014) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG49n-0004G1-K0 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91AED2D9FDE for ; Wed, 31 May 2017 13:59:26 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 168857C8DB; Wed, 31 May 2017 13:59:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 91AED2D9FDE Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 91AED2D9FDE From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:40 +0400 Message-Id: <20170531135709.345-17-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 13:59:26 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 16/45] q35: fix get_mmcfg_size to use uint64 visitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" e->size is hwaddr, i.e. uint64_t. We silently truncate. Fix suggested by Markus Armbruster. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- hw/pci-host/q35.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index cd5c49616e..e8a04d31d1 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -129,9 +129,8 @@ static void q35_host_get_mmcfg_size(Object *obj, Visito= r *v, const char *name, void *opaque, Error **errp) { PCIExpressHost *e =3D PCIE_HOST_BRIDGE(obj); - uint32_t value =3D e->size; =20 - visit_type_uint32(v, name, &value, errp); + visit_type_uint64(v, name, &e->size, errp); } =20 static Property mch_props[] =3D { --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240163406851.283727585165; Wed, 31 May 2017 07:16:03 -0700 (PDT) Received: from localhost ([::1]:59749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Po-0002qj-LJ for importer@patchew.org; Wed, 31 May 2017 10:16:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG49z-000561-ED for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG49y-0004Hq-8p for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44364) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG49y-0004HU-17 for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:38 -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 mx1.redhat.com (Postfix) with ESMTPS id ED69572492 for ; Wed, 31 May 2017 13:59:36 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1C927E3AA; Wed, 31 May 2017 13:59:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ED69572492 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ED69572492 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:41 +0400 Message-Id: <20170531135709.345-18-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 31 May 2017 13:59:37 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 17/45] object: use more specific property type names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the actual unsigned integer type name (this should't break since property type aren't directly accessed from outside it seems). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- backends/cryptodev.c | 2 +- hw/pci-host/piix.c | 8 ++++---- hw/pci-host/q35.c | 10 +++++----- hw/ppc/pnv.c | 2 +- net/dump.c | 2 +- net/filter-buffer.c | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/backends/cryptodev.c b/backends/cryptodev.c index 832f056266..1764c179fe 100644 --- a/backends/cryptodev.c +++ b/backends/cryptodev.c @@ -222,7 +222,7 @@ cryptodev_backend_can_be_deleted(UserCreatable *uc, Err= or **errp) =20 static void cryptodev_backend_instance_init(Object *obj) { - object_property_add(obj, "queues", "int", + object_property_add(obj, "queues", "uint32", cryptodev_backend_get_queues, cryptodev_backend_set_queues, NULL, NULL, NULL); diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c index 4ce201ea65..a2c1033dbe 100644 --- a/hw/pci-host/piix.c +++ b/hw/pci-host/piix.c @@ -273,19 +273,19 @@ static void i440fx_pcihost_initfn(Object *obj) memory_region_init_io(&s->data_mem, obj, &pci_host_data_le_ops, s, "pci-conf-data", 4); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32", i440fx_pcihost_get_pci_hole_start, NULL, NULL, NULL, NULL); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "uint32", i440fx_pcihost_get_pci_hole_end, NULL, NULL, NULL, NULL); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "uint64", i440fx_pcihost_get_pci_hole64_start, NULL, NULL, NULL, NULL); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "uint64", i440fx_pcihost_get_pci_hole64_end, NULL, NULL, NULL, NULL); } diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index e8a04d31d1..c2f2af5d9a 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -175,23 +175,23 @@ static void q35_host_initfn(Object *obj) qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32", q35_host_get_pci_hole_start, NULL, NULL, NULL, NULL); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_END, "uint32", q35_host_get_pci_hole_end, NULL, NULL, NULL, NULL); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_START, "uint64", q35_host_get_pci_hole64_start, NULL, NULL, NULL, NULL); =20 - object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "int", + object_property_add(obj, PCI_HOST_PROP_PCI_HOLE64_END, "uint64", q35_host_get_pci_hole64_end, NULL, NULL, NULL, NULL); =20 - object_property_add(obj, PCIE_HOST_MCFG_SIZE, "int", + object_property_add(obj, PCIE_HOST_MCFG_SIZE, "uint64", q35_host_get_mmcfg_size, NULL, NULL, NULL, NULL); =20 diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 231ed9735b..f2f2e98687 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1110,7 +1110,7 @@ static void powernv_machine_initfn(Object *obj) =20 static void powernv_machine_class_props_init(ObjectClass *oc) { - object_class_property_add(oc, "num-chips", "uint32_t", + object_class_property_add(oc, "num-chips", "uint32", pnv_get_num_chips, pnv_set_num_chips, NULL, NULL, NULL); object_class_property_set_description(oc, "num-chips", diff --git a/net/dump.c b/net/dump.c index 442eb532f9..15df9a4973 100644 --- a/net/dump.c +++ b/net/dump.c @@ -328,7 +328,7 @@ static void filter_dump_instance_init(Object *obj) =20 nfds->maxlen =3D 65536; =20 - object_property_add(obj, "maxlen", "int", filter_dump_get_maxlen, + object_property_add(obj, "maxlen", "uint32", filter_dump_get_maxlen, filter_dump_set_maxlen, NULL, NULL, NULL); object_property_add_str(obj, "file", file_dump_get_filename, file_dump_set_filename, NULL); diff --git a/net/filter-buffer.c b/net/filter-buffer.c index cc6bd94445..9ce96aaa35 100644 --- a/net/filter-buffer.c +++ b/net/filter-buffer.c @@ -191,7 +191,7 @@ out: =20 static void filter_buffer_init(Object *obj) { - object_property_add(obj, "interval", "int", + object_property_add(obj, "interval", "uint32", filter_buffer_get_interval, filter_buffer_set_interval, NULL, NULL, NULL); } --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 149623996765582.25362451097556; Wed, 31 May 2017 07:12:47 -0700 (PDT) Received: from localhost ([::1]:59731 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Mc-0008G3-4N for importer@patchew.org; Wed, 31 May 2017 10:12:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52529) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4A9-0005Ib-EI for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4A5-0004K2-8R for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50912) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4A4-0004Jt-VF for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:45 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3D0D61BAA for ; Wed, 31 May 2017 13:59:43 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id F27B295323; Wed, 31 May 2017 13:59:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E3D0D61BAA Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E3D0D61BAA From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:42 +0400 Message-Id: <20170531135709.345-19-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 May 2017 13:59:44 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 18/45] qdev: make default property int X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The following patch will add uint properties. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/qdev-core.h | 4 +++- include/hw/qdev-properties.h | 34 ++++++++++++++-------------- hw/block/fdc.c | 54 ++++++++++++++++++++++------------------= ---- hw/core/qdev-properties.c | 6 ++--- hw/net/e1000e.c | 14 ++++++------ 5 files changed, 57 insertions(+), 55 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 9523339762..784971b8d8 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -226,7 +226,9 @@ struct Property { PropertyInfo *info; ptrdiff_t offset; uint8_t bitnr; - int64_t defval; + union { + int64_t i; + } defval; int arrayoffset; PropertyInfo *arrayinfo; int arrayfieldsize; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 85e68998a9..6663a547ea 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -37,12 +37,12 @@ extern PropertyInfo qdev_prop_arraylen; .offset =3D offsetof(_state, _field) \ + type_check(_type, typeof_field(_state, _field)), \ } -#define DEFINE_PROP_DEFAULT(_name, _state, _field, _defval, _prop, _type) = { \ +#define DEFINE_PROP_INT(_name, _state, _field, _defval, _prop, _type) { \ .name =3D (_name), \ .info =3D &(_prop), \ .offset =3D offsetof(_state, _field) \ + type_check(_type,typeof_field(_state, _field)), \ - .defval =3D (_type)_defval, \ + .defval.i =3D (_type)_defval, \ } #define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \ .name =3D (_name), \ @@ -50,7 +50,7 @@ extern PropertyInfo qdev_prop_arraylen; .bitnr =3D (_bit), \ .offset =3D offsetof(_state, _field) \ + type_check(uint32_t,typeof_field(_state, _field)), \ - .defval =3D (bool)_defval, \ + .defval.i =3D (bool)_defval, \ } #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \ .name =3D (_name), \ @@ -58,7 +58,7 @@ extern PropertyInfo qdev_prop_arraylen; .bitnr =3D (_bit), \ .offset =3D offsetof(_state, _field) \ + type_check(uint64_t, typeof_field(_state, _field)), \ - .defval =3D (bool)_defval, \ + .defval.i =3D (bool)_defval, \ } =20 #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \ @@ -66,7 +66,7 @@ extern PropertyInfo qdev_prop_arraylen; .info =3D &(qdev_prop_bool), \ .offset =3D offsetof(_state, _field) \ + type_check(bool, typeof_field(_state, _field)), \ - .defval =3D (bool)_defval, \ + .defval.i =3D (bool)_defval, \ } =20 #define PROP_ARRAY_LEN_PREFIX "len-" @@ -107,19 +107,19 @@ extern PropertyInfo qdev_prop_arraylen; } =20 #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) #define DEFINE_PROP_INT32(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_int32, int32_t) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_int32, int32_t) #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_size, uint64_t) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_size, uint64_t) #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) =20 /* * Please avoid pointer properties. If you must use them, you must @@ -153,17 +153,17 @@ extern PropertyInfo qdev_prop_arraylen; #define DEFINE_PROP_MACADDR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_macaddr, MACAddr) #define DEFINE_PROP_ON_OFF_AUTO(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_on_off_auto, OnOffAuto) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy) #define DEFINE_PROP_BLOCKDEV_ON_ERROR(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \ + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_blockdev_on_error, \ BlockdevOnError) #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) + DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \ - DEFINE_PROP_DEFAULT(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t) + DEFINE_PROP_INT(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t) #define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddre= ss) =20 diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 2e629b398b..07ce4a0d20 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -511,9 +511,9 @@ typedef struct FloppyDrive { static Property floppy_drive_properties[] =3D { DEFINE_PROP_UINT32("unit", FloppyDrive, unit, -1), DEFINE_BLOCK_PROPERTIES(FloppyDrive, conf), - DEFINE_PROP_DEFAULT("drive-type", FloppyDrive, type, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), + DEFINE_PROP_INT("drive-type", FloppyDrive, type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -2805,15 +2805,15 @@ static Property isa_fdc_properties[] =3D { DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.qdev_for_drives[1].blk= ), DEFINE_PROP_BIT("check_media_rate", FDCtrlISABus, state.check_media_ra= te, 0, true), - DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlISABus, state.qdev_for_drives[0].= type, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].= type, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback, - FLOPPY_DRIVE_TYPE_288, qdev_prop_fdc_drive_type, - FloppyDriveType), + DEFINE_PROP_INT("fdtypeA", FDCtrlISABus, state.qdev_for_drives[0].type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_INT("fdtypeB", FDCtrlISABus, state.qdev_for_drives[1].type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_INT("fallback", FDCtrlISABus, state.fallback, + FLOPPY_DRIVE_TYPE_288, qdev_prop_fdc_drive_type, + FloppyDriveType), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -2862,15 +2862,15 @@ static const VMStateDescription vmstate_sysbus_fdc = =3D{ static Property sysbus_fdc_properties[] =3D { DEFINE_PROP_DRIVE("driveA", FDCtrlSysBus, state.qdev_for_drives[0].blk= ), DEFINE_PROP_DRIVE("driveB", FDCtrlSysBus, state.qdev_for_drives[1].blk= ), - DEFINE_PROP_DEFAULT("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].= type, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_DEFAULT("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].= type, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback, - FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, - FloppyDriveType), + DEFINE_PROP_INT("fdtypeA", FDCtrlSysBus, state.qdev_for_drives[0].type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_INT("fdtypeB", FDCtrlSysBus, state.qdev_for_drives[1].type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_INT("fallback", FDCtrlISABus, state.fallback, + FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, + FloppyDriveType), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -2891,12 +2891,12 @@ static const TypeInfo sysbus_fdc_info =3D { =20 static Property sun4m_fdc_properties[] =3D { DEFINE_PROP_DRIVE("drive", FDCtrlSysBus, state.qdev_for_drives[0].blk), - DEFINE_PROP_DEFAULT("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].t= ype, - FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, - FloppyDriveType), - DEFINE_PROP_DEFAULT("fallback", FDCtrlISABus, state.fallback, - FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, - FloppyDriveType), + DEFINE_PROP_INT("fdtype", FDCtrlSysBus, state.qdev_for_drives[0].type, + FLOPPY_DRIVE_TYPE_AUTO, qdev_prop_fdc_drive_type, + FloppyDriveType), + DEFINE_PROP_INT("fallback", FDCtrlISABus, state.fallback, + FLOPPY_DRIVE_TYPE_144, qdev_prop_fdc_drive_type, + FloppyDriveType), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 482efb2683..952cda7758 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char = *name, void *opaque, =20 static void set_default_value_enum(Object *obj, const Property *prop) { - object_property_set_str(obj, prop->info->enum_table[prop->defval], + object_property_set_str(obj, prop->info->enum_table[prop->defval.i], prop->name, &error_abort); } =20 @@ -128,7 +128,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const= char *name, =20 static void set_default_value_bool(Object *obj, const Property *prop) { - object_property_set_bool(obj, prop->defval, prop->name, &error_abort); + object_property_set_bool(obj, prop->defval.i, prop->name, &error_abort= ); } =20 PropertyInfo qdev_prop_bit =3D { @@ -261,7 +261,7 @@ static void set_uint8(Object *obj, Visitor *v, const ch= ar *name, void *opaque, =20 static void set_default_value_int(Object *obj, const Property *prop) { - object_property_set_int(obj, prop->defval, prop->name, &error_abort); + object_property_set_int(obj, prop->defval.i, prop->name, &error_abort); } =20 PropertyInfo qdev_prop_uint8 =3D { diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index 6e234938db..4e4cc9b52f 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -645,13 +645,13 @@ static PropertyInfo e1000e_prop_disable_vnet, =20 static Property e1000e_properties[] =3D { DEFINE_NIC_PROPERTIES(E1000EState, conf), - DEFINE_PROP_DEFAULT("disable_vnet_hdr", E1000EState, disable_vnet, fal= se, - e1000e_prop_disable_vnet, bool), - DEFINE_PROP_DEFAULT("subsys_ven", E1000EState, subsys_ven, - PCI_VENDOR_ID_INTEL, - e1000e_prop_subsys_ven, uint16_t), - DEFINE_PROP_DEFAULT("subsys", E1000EState, subsys, 0, - e1000e_prop_subsys, uint16_t), + DEFINE_PROP_INT("disable_vnet_hdr", E1000EState, disable_vnet, false, + e1000e_prop_disable_vnet, bool), + DEFINE_PROP_INT("subsys_ven", E1000EState, subsys_ven, + PCI_VENDOR_ID_INTEL, + e1000e_prop_subsys_ven, uint16_t), + DEFINE_PROP_INT("subsys", E1000EState, subsys, 0, + e1000e_prop_subsys, uint16_t), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239992530720.4554494145652; Wed, 31 May 2017 07:13:12 -0700 (PDT) Received: from localhost ([::1]:59733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4N0-0000Hs-SL for importer@patchew.org; Wed, 31 May 2017 10:13:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4AE-0005NF-LA for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4AD-0004OZ-Cw for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11226) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4AD-0004O5-4r for qemu-devel@nongnu.org; Wed, 31 May 2017 09:59:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 16B2861D11 for ; Wed, 31 May 2017 13:59:52 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C26F80E93; Wed, 31 May 2017 13:59:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 16B2861D11 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 16B2861D11 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:43 +0400 Message-Id: <20170531135709.345-20-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 31 May 2017 13:59:52 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 19/45] qdev: add unsigned properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add and use unsigned type for various properties. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/qdev-core.h | 1 + include/hw/qdev-properties.h | 51 +++++++++++++++++++++++++++-------------= ---- hw/core/qdev-properties.c | 23 ++++++++++++-------- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 784971b8d8..9d7c1c0e9b 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -228,6 +228,7 @@ struct Property { uint8_t bitnr; union { int64_t i; + uint64_t u; } defval; int arrayoffset; PropertyInfo *arrayinfo; diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 6663a547ea..16d3ada8df 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -37,6 +37,7 @@ extern PropertyInfo qdev_prop_arraylen; .offset =3D offsetof(_state, _field) \ + type_check(_type, typeof_field(_state, _field)), \ } + #define DEFINE_PROP_INT(_name, _state, _field, _defval, _prop, _type) { \ .name =3D (_name), \ .info =3D &(_prop), \ @@ -44,29 +45,39 @@ extern PropertyInfo qdev_prop_arraylen; + type_check(_type,typeof_field(_state, _field)), \ .defval.i =3D (_type)_defval, \ } -#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \ - .name =3D (_name), \ - .info =3D &(qdev_prop_bit), \ - .bitnr =3D (_bit), \ - .offset =3D offsetof(_state, _field) \ - + type_check(uint32_t,typeof_field(_state, _field)), \ - .defval.i =3D (bool)_defval, \ + +#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \ + .name =3D (_name), \ + .info =3D &(qdev_prop_bit), \ + .bitnr =3D (_bit), \ + .offset =3D offsetof(_state, _field) \ + + type_check(uint32_t, typeof_field(_state, _field)), \ + .defval.u =3D (bool)_defval, \ } + +#define DEFINE_PROP_UINT(_name, _state, _field, _defval, _prop, _type) { \ + .name =3D (_name), \ + .info =3D &(_prop), \ + .offset =3D offsetof(_state, _field) \ + + type_check(_type, typeof_field(_state, _field)), \ + .defval.u =3D (_type)_defval, \ + } + #define DEFINE_PROP_BIT64(_name, _state, _field, _bit, _defval) { \ .name =3D (_name), \ .info =3D &(qdev_prop_bit64), \ .bitnr =3D (_bit), \ .offset =3D offsetof(_state, _field) \ + type_check(uint64_t, typeof_field(_state, _field)), \ - .defval.i =3D (bool)_defval, \ + .defval.u =3D (bool)_defval, \ } =20 -#define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \ - .name =3D (_name), \ - .info =3D &(qdev_prop_bool), \ - .offset =3D offsetof(_state, _field) \ - + type_check(bool, typeof_field(_state, _field)), \ - .defval.i =3D (bool)_defval, \ +#define DEFINE_PROP_BOOL(_name, _state, _field, _defval) { \ + .name =3D (_name), \ + .info =3D &(qdev_prop_bool), \ + .offset =3D offsetof(_state, _field) \ + + type_check(bool, typeof_field(_state, _field)), \ + .defval.u =3D (bool)_defval, \ } =20 #define PROP_ARRAY_LEN_PREFIX "len-" @@ -107,17 +118,17 @@ extern PropertyInfo qdev_prop_arraylen; } =20 #define DEFINE_PROP_UINT8(_n, _s, _f, _d) \ - DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) + DEFINE_PROP_UINT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t) #define DEFINE_PROP_UINT16(_n, _s, _f, _d) \ - DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) + DEFINE_PROP_UINT(_n, _s, _f, _d, qdev_prop_uint16, uint16_t) #define DEFINE_PROP_UINT32(_n, _s, _f, _d) \ - DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) + DEFINE_PROP_UINT(_n, _s, _f, _d, qdev_prop_uint32, uint32_t) #define DEFINE_PROP_INT32(_n, _s, _f, _d) \ DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_int32, int32_t) #define DEFINE_PROP_UINT64(_n, _s, _f, _d) \ - DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) + DEFINE_PROP_UINT(_n, _s, _f, _d, qdev_prop_uint64, uint64_t) #define DEFINE_PROP_SIZE(_n, _s, _f, _d) \ - DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_size, uint64_t) + DEFINE_PROP_UINT(_n, _s, _f, _d, qdev_prop_size, uint64_t) #define DEFINE_PROP_PCI_DEVFN(_n, _s, _f, _d) \ DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_pci_devfn, int32_t) =20 @@ -163,7 +174,7 @@ extern PropertyInfo qdev_prop_arraylen; #define DEFINE_PROP_BIOS_CHS_TRANS(_n, _s, _f, _d) \ DEFINE_PROP_INT(_n, _s, _f, _d, qdev_prop_bios_chs_trans, int) #define DEFINE_PROP_BLOCKSIZE(_n, _s, _f) \ - DEFINE_PROP_INT(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t) + DEFINE_PROP_UINT(_n, _s, _f, 0, qdev_prop_blocksize, uint16_t) #define DEFINE_PROP_PCI_HOST_DEVADDR(_n, _s, _f) \ DEFINE_PROP(_n, _s, _f, qdev_prop_pci_host_devaddr, PCIHostDeviceAddre= ss) =20 diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 952cda7758..92fb43cb0d 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -71,7 +71,7 @@ static void set_enum(Object *obj, Visitor *v, const char = *name, void *opaque, =20 static void set_default_value_enum(Object *obj, const Property *prop) { - object_property_set_str(obj, prop->info->enum_table[prop->defval.i], + object_property_set_str(obj, prop->info->enum_table[prop->defval.u], prop->name, &error_abort); } =20 @@ -128,7 +128,7 @@ static void prop_set_bit(Object *obj, Visitor *v, const= char *name, =20 static void set_default_value_bool(Object *obj, const Property *prop) { - object_property_set_bool(obj, prop->defval.i, prop->name, &error_abort= ); + object_property_set_bool(obj, prop->defval.u, prop->name, &error_abort= ); } =20 PropertyInfo qdev_prop_bit =3D { @@ -264,11 +264,16 @@ static void set_default_value_int(Object *obj, const = Property *prop) object_property_set_int(obj, prop->defval.i, prop->name, &error_abort); } =20 +static void set_default_value_uint(Object *obj, const Property *prop) +{ + object_property_set_uint(obj, prop->defval.u, prop->name, &error_abort= ); +} + PropertyInfo qdev_prop_uint8 =3D { .name =3D "uint8", .get =3D get_uint8, .set =3D set_uint8, - .set_default_value =3D set_default_value_int, + .set_default_value =3D set_default_value_uint, }; =20 /* --- 16bit integer --- */ @@ -302,7 +307,7 @@ PropertyInfo qdev_prop_uint16 =3D { .name =3D "uint16", .get =3D get_uint16, .set =3D set_uint16, - .set_default_value =3D set_default_value_int, + .set_default_value =3D set_default_value_uint, }; =20 /* --- 32bit integer --- */ @@ -361,7 +366,7 @@ PropertyInfo qdev_prop_uint32 =3D { .name =3D "uint32", .get =3D get_uint32, .set =3D set_uint32, - .set_default_value =3D set_default_value_int, + .set_default_value =3D set_default_value_uint, }; =20 PropertyInfo qdev_prop_int32 =3D { @@ -402,7 +407,7 @@ PropertyInfo qdev_prop_uint64 =3D { .name =3D "uint64", .get =3D get_uint64, .set =3D set_uint64, - .set_default_value =3D set_default_value_int, + .set_default_value =3D set_default_value_uint, }; =20 /* --- string --- */ @@ -725,7 +730,7 @@ PropertyInfo qdev_prop_blocksize =3D { .description =3D "A power of two between 512 and 32768", .get =3D get_uint16, .set =3D set_blocksize, - .set_default_value =3D set_default_value_int, + .set_default_value =3D set_default_value_uint, }; =20 /* --- pci host address --- */ @@ -948,7 +953,7 @@ PropertyInfo qdev_prop_arraylen =3D { .name =3D "uint32", .get =3D get_uint32, .set =3D set_prop_arraylen, - .set_default_value =3D set_default_value_int, + .set_default_value =3D set_default_value_uint, }; =20 /* --- public helpers --- */ @@ -1185,5 +1190,5 @@ PropertyInfo qdev_prop_size =3D { .name =3D "size", .get =3D get_size, .set =3D set_size, - .set_default_value =3D set_default_value_int, + .set_default_value =3D set_default_value_uint, }; --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239624193231.6560741877596; Wed, 31 May 2017 07:07:04 -0700 (PDT) Received: from localhost ([::1]:59703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4H3-0002kL-Hx for importer@patchew.org; Wed, 31 May 2017 10:06:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52657) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4AP-0005Xi-M3 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4AL-0004RQ-EL for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42082) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4AL-0004Qr-6M for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:01 -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 mx1.redhat.com (Postfix) with ESMTPS id 1CC6E2D9FE9 for ; Wed, 31 May 2017 14:00:00 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 225B31865E; Wed, 31 May 2017 13:59:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1CC6E2D9FE9 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1CC6E2D9FE9 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:44 +0400 Message-Id: <20170531135709.345-21-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 14:00:00 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 20/45] apic-common: make "id" property a uint32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Change suggested by Markus Armbruster: This one's a bit of a mess. The getter and setter of TYPE_APIC_COMMON property "id" are apic_common_get_id() and apic_common_set_id(). apic_common_get_id() reads either APICCommonState member uint32_t initial_apic_id or uint8_t id into an int64_t local variable. It then passes this variable to visit_type_int(). apic_common_set_id() uses visit_type_int() to read the value into a local variable, which it then assigns both to initial_apic_id and id. While the state backing the property is two unsigned members, 8 and 32 bits wide, the actual visitor is 64 bits signed. cpu->apic_id is uint32_t. qdev_prop_set_uint32() isn't really wrong, because any uint32_t value is also a valid int64_t value. qdev_prop_set_int32() implicitly converts cpu->apic_id from uint32_t to int32_t. Perhaps that's even okay, but I don't care, I want this mess cleaned up Change getter and setter to use visit_type_uint32(). Then everything's uint32_t, except for @id. Signed-off-by: Marc-Andr=C3=A9 Lureau Suggested-by: Markus Armbruster --- hw/intc/apic_common.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c index 1ef56f8d10..e1ac33042f 100644 --- a/hw/intc/apic_common.c +++ b/hw/intc/apic_common.c @@ -450,10 +450,10 @@ static void apic_common_get_id(Object *obj, Visitor *= v, const char *name, void *opaque, Error **errp) { APICCommonState *s =3D APIC_COMMON(obj); - int64_t value; + uint32_t value; =20 value =3D s->apicbase & MSR_IA32_APICBASE_EXTD ? s->initial_apic_id : = s->id; - visit_type_int(v, name, &value, errp); + visit_type_uint32(v, name, &value, errp); } =20 static void apic_common_set_id(Object *obj, Visitor *v, const char *name, @@ -462,14 +462,14 @@ static void apic_common_set_id(Object *obj, Visitor *= v, const char *name, APICCommonState *s =3D APIC_COMMON(obj); DeviceState *dev =3D DEVICE(obj); Error *local_err =3D NULL; - int64_t value; + uint32_t value; =20 if (dev->realized) { qdev_prop_set_after_realize(dev, name, errp); return; } =20 - visit_type_int(v, name, &value, &local_err); + visit_type_uint32(v, name, &value, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -484,7 +484,7 @@ static void apic_common_initfn(Object *obj) APICCommonState *s =3D APIC_COMMON(obj); =20 s->id =3D s->initial_apic_id =3D -1; - object_property_add(obj, "id", "int", + object_property_add(obj, "id", "uint32", apic_common_get_id, apic_common_set_id, NULL, NULL, NULL); } --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240112623856.6361273192497; Wed, 31 May 2017 07:15:12 -0700 (PDT) Received: from localhost ([::1]:59741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ox-00020E-Kj for importer@patchew.org; Wed, 31 May 2017 10:15:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ad-0005pA-Go for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Ac-0004cc-H2 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44570) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Ac-0004bs-8N for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 323767F6A0 for ; Wed, 31 May 2017 14:00:17 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28E6C81427; Wed, 31 May 2017 14:00:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 323767F6A0 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 323767F6A0 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:45 +0400 Message-Id: <20170531135709.345-22-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 14:00:17 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 21/45] qdev: use appropriate getter/setters type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Based on underlying property type, use the appropriate getters/setters. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/acpi-build.c | 20 ++++++++++---------- hw/pci-host/gpex.c | 2 +- hw/pci-host/q35.c | 2 +- hw/pci-host/xilinx-pcie.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index ba2be1e9da..ba163e6df2 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -128,7 +128,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) Object *lpc =3D ich9_lpc_find(); Object *obj =3D NULL; QObject *o; - int64_t val; + uint64_t val; =20 pm->cpu_hp_io_base =3D 0; pm->pcihp_io_base =3D 0; @@ -150,7 +150,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) /* Fill in optional s3/s4 related properties */ o =3D object_property_get_qobject(obj, ACPI_PM_PROP_S3_DISABLED, NULL); if (o) { - if (!qnum_get_int(qobject_to_qnum(o), &val)) { + if (!qnum_get_uint(qobject_to_qnum(o), &val)) { g_assert_not_reached(); } pm->s3_disabled =3D val; @@ -160,7 +160,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) qobject_decref(o); o =3D object_property_get_qobject(obj, ACPI_PM_PROP_S4_DISABLED, NULL); if (o) { - if (!qnum_get_int(qobject_to_qnum(o), &val)) { + if (!qnum_get_uint(qobject_to_qnum(o), &val)) { g_assert_not_reached(); } pm->s4_disabled =3D val; @@ -170,7 +170,7 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) qobject_decref(o); o =3D object_property_get_qobject(obj, ACPI_PM_PROP_S4_VAL, NULL); if (o) { - if (!qnum_get_int(qobject_to_qnum(o), &val)) { + if (!qnum_get_uint(qobject_to_qnum(o), &val)) { g_assert_not_reached(); } pm->s4_val =3D val; @@ -538,9 +538,9 @@ static void build_append_pci_bus_devices(Aml *parent_sc= ope, PCIBus *bus, =20 bsel =3D object_property_get_qobject(OBJECT(bus), ACPI_PCIHP_PROP_BSEL= , NULL); if (bsel) { - int64_t bsel_val; + uint64_t bsel_val; =20 - if (!qnum_get_int(qobject_to_qnum(bsel), &bsel_val)) { + if (!qnum_get_uint(qobject_to_qnum(bsel), &bsel_val)) { g_assert_not_reached(); } =20 @@ -652,9 +652,9 @@ static void build_append_pci_bus_devices(Aml *parent_sc= ope, PCIBus *bus, =20 /* If bus supports hotplug select it and notify about local events */ if (bsel) { - int64_t bsel_val; + uint64_t bsel_val; =20 - if (!qnum_get_int(qobject_to_qnum(bsel), &bsel_val)) { + if (!qnum_get_uint(qobject_to_qnum(bsel), &bsel_val)) { g_assert_not_reached(); } =20 @@ -2625,7 +2625,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) { Object *pci_host; QObject *o; - int64_t val; + uint64_t val; =20 pci_host =3D acpi_get_i386_pci_host(); g_assert(pci_host); @@ -2641,7 +2641,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg) =20 o =3D object_property_get_qobject(pci_host, PCIE_HOST_MCFG_SIZE, NULL); assert(o); - if (!qnum_get_int(qobject_to_qnum(o), &val)) { + if (!qnum_get_uint(qobject_to_qnum(o), &val)) { g_assert_not_reached(); } mcfg->mcfg_size =3D val; diff --git a/hw/pci-host/gpex.c b/hw/pci-host/gpex.c index e2629ce70d..83084b9aab 100644 --- a/hw/pci-host/gpex.c +++ b/hw/pci-host/gpex.c @@ -94,7 +94,7 @@ static void gpex_host_initfn(Object *obj) =20 object_initialize(root, sizeof(*root), TYPE_GPEX_ROOT_DEVICE); object_property_add_child(obj, "gpex_root", OBJECT(root), NULL); - qdev_prop_set_uint32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); + qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(root), "multifunction", false); } =20 diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c index c2f2af5d9a..564f6cbb14 100644 --- a/hw/pci-host/q35.c +++ b/hw/pci-host/q35.c @@ -172,7 +172,7 @@ static void q35_host_initfn(Object *obj) =20 object_initialize(&s->mch, sizeof(s->mch), TYPE_MCH_PCI_DEVICE); object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL); - qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0)); + qdev_prop_set_int32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false); =20 object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32", diff --git a/hw/pci-host/xilinx-pcie.c b/hw/pci-host/xilinx-pcie.c index a968cea2af..2c78dcfc26 100644 --- a/hw/pci-host/xilinx-pcie.c +++ b/hw/pci-host/xilinx-pcie.c @@ -150,7 +150,7 @@ static void xilinx_pcie_host_init(Object *obj) =20 object_initialize(root, sizeof(*root), TYPE_XILINX_PCIE_ROOT); object_property_add_child(obj, "root", OBJECT(root), NULL); - qdev_prop_set_uint32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); + qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(root), "multifunction", false); } =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239764331114.54976588504735; Wed, 31 May 2017 07:09:24 -0700 (PDT) Received: from localhost ([::1]:59714 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4JL-00054w-Iq for importer@patchew.org; Wed, 31 May 2017 10:09:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Aq-00061v-LJ for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Ap-0004iz-Kd for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35116) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Ap-0004ig-EO for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:31 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62B9680C07 for ; Wed, 31 May 2017 14:00:30 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 533547770E; Wed, 31 May 2017 14:00:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 62B9680C07 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 62B9680C07 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:46 +0400 Message-Id: <20170531135709.345-23-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 14:00:30 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 22/45] isa: use get_uint() for "io-base" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The property is defined with DEFINE_PROP_UINT32(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/hw/isa/isa.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h index c2fdd70cdc..95593408ef 100644 --- a/include/hw/isa/isa.h +++ b/include/hw/isa/isa.h @@ -29,7 +29,7 @@ static inline uint16_t applesmc_port(void) Object *obj =3D object_resolve_path_type("", TYPE_APPLE_SMC, NULL); =20 if (obj) { - return object_property_get_int(obj, APPLESMC_PROP_IO_BASE, NULL); + return object_property_get_uint(obj, APPLESMC_PROP_IO_BASE, NULL); } return 0; } --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240480606840.6139442462083; Wed, 31 May 2017 07:21:20 -0700 (PDT) Received: from localhost ([::1]:59774 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ur-00079I-Ul for importer@patchew.org; Wed, 31 May 2017 10:21:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4B2-0006CG-Sj for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Ay-0004p7-Lb for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48166) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Ay-0004on-Cl for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 559446315E for ; Wed, 31 May 2017 14:00:39 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8C428140E; Wed, 31 May 2017 14:00:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 559446315E Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 559446315E From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:47 +0400 Message-Id: <20170531135709.345-24-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 31 May 2017 14:00:39 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 23/45] pc-dimm: use get_uint() for dimm properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_PC_DIMM's property PC_DIMM_ADDR_PROP is defined with DEFINE_PROP_UINT64(). TYPE_PC_DIMM's property PC_DIMM_NODE_PROP is defined with DEFINE_PROP_UINT32(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/acpi/memory_hotplug.c | 7 ++++--- hw/acpi/nvdimm.c | 10 +++++----- hw/mem/pc-dimm.c | 5 +++-- hw/ppc/spapr.c | 7 ++++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 210073d283..d2a96569ba 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -83,11 +83,12 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, = hwaddr addr, o =3D OBJECT(mdev->dimm); switch (addr) { case 0x0: /* Lo part of phys address where DIMM is mapped */ - val =3D o ? object_property_get_int(o, PC_DIMM_ADDR_PROP, NULL) : = 0; + val =3D o ? object_property_get_uint(o, PC_DIMM_ADDR_PROP, NULL) := 0; trace_mhp_acpi_read_addr_lo(mem_st->selector, val); break; case 0x4: /* Hi part of phys address where DIMM is mapped */ - val =3D o ? object_property_get_int(o, PC_DIMM_ADDR_PROP, NULL) >>= 32 : 0; + val =3D + o ? object_property_get_uint(o, PC_DIMM_ADDR_PROP, NULL) >> 32= : 0; trace_mhp_acpi_read_addr_hi(mem_st->selector, val); break; case 0x8: /* Lo part of DIMM size */ @@ -99,7 +100,7 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, h= waddr addr, trace_mhp_acpi_read_size_hi(mem_st->selector, val); break; case 0x10: /* node proximity for _PXM method */ - val =3D o ? object_property_get_int(o, PC_DIMM_NODE_PROP, NULL) : = 0; + val =3D o ? object_property_get_uint(o, PC_DIMM_NODE_PROP, NULL) := 0; trace_mhp_acpi_read_pxm(mem_st->selector, val); break; case 0x14: /* pack and return is_* fields */ diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 8e7d6ec034..e57027149d 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -236,14 +236,14 @@ static void nvdimm_build_structure_spa(GArray *structures, DeviceState *dev) { NvdimmNfitSpa *nfit_spa; - uint64_t addr =3D object_property_get_int(OBJECT(dev), PC_DIMM_ADDR_PR= OP, - NULL); + uint64_t addr =3D object_property_get_uint(OBJECT(dev), PC_DIMM_ADDR_P= ROP, + NULL); uint64_t size =3D object_property_get_int(OBJECT(dev), PC_DIMM_SIZE_PR= OP, NULL); - uint32_t node =3D object_property_get_int(OBJECT(dev), PC_DIMM_NODE_PR= OP, - NULL); + uint32_t node =3D object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_P= ROP, + NULL); int slot =3D object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, - NULL); + NULL); =20 nfit_spa =3D acpi_data_push(structures, sizeof(*nfit_spa)); =20 diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 9e8dab0e89..f6def8c239 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -46,7 +46,8 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugS= tate *hpms, uint64_t existing_dimms_capacity =3D 0; uint64_t addr; =20 - addr =3D object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &loc= al_err); + addr =3D object_property_get_uint(OBJECT(dimm), + PC_DIMM_ADDR_PROP, &local_err); if (local_err) { goto out; } @@ -73,7 +74,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotplugS= tate *hpms, goto out; } =20 - object_property_set_int(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_e= rr); + object_property_set_uint(OBJECT(dev), addr, PC_DIMM_ADDR_PROP, &local_= err); if (local_err) { goto out; } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index ab3aab1279..e87de730c7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2585,7 +2585,8 @@ static void spapr_memory_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, goto out; } =20 - addr =3D object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &loc= al_err); + addr =3D object_property_get_uint(OBJECT(dimm), + PC_DIMM_ADDR_PROP, &local_err); if (local_err) { pc_dimm_memory_unplug(dev, &ms->hotplug_memory, mr); goto out; @@ -2744,7 +2745,7 @@ static void spapr_memory_unplug_request(HotplugHandle= r *hotplug_dev, sPAPRDRConnectorClass *drck; sPAPRDIMMState *ds; =20 - addr_start =3D object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, + addr_start =3D object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PRO= P, &local_err); if (local_err) { goto out; @@ -2999,7 +3000,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, error_setg(errp, "Memory hotplug not supported for this machin= e"); return; } - node =3D object_property_get_int(OBJECT(dev), PC_DIMM_NODE_PROP, e= rrp); + node =3D object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_PROP, = errp); if (*errp) { return; } --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240140423133.98177093003665; Wed, 31 May 2017 07:15:40 -0700 (PDT) Received: from localhost ([::1]:59748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4PO-0002Rd-MF for importer@patchew.org; Wed, 31 May 2017 10:15:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52897) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4B7-0006G5-Le for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4B6-0004qZ-JP for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52376) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4B6-0004qO-AU for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38BBD15552 for ; Wed, 31 May 2017 14:00:47 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id E19C980E64; Wed, 31 May 2017 14:00:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 38BBD15552 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 38BBD15552 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:48 +0400 Message-Id: <20170531135709.345-25-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 31 May 2017 14:00:47 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 24/45] pc-dimm: make "size" property uint64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This carries the memory_region_size() value without implicit cast. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/acpi/memory_hotplug.c | 5 +++-- hw/acpi/nvdimm.c | 8 ++++---- hw/mem/pc-dimm.c | 18 +++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index d2a96569ba..cda2c9dd06 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -92,11 +92,12 @@ static uint64_t acpi_memory_hotplug_read(void *opaque, = hwaddr addr, trace_mhp_acpi_read_addr_hi(mem_st->selector, val); break; case 0x8: /* Lo part of DIMM size */ - val =3D o ? object_property_get_int(o, PC_DIMM_SIZE_PROP, NULL) : = 0; + val =3D o ? object_property_get_uint(o, PC_DIMM_SIZE_PROP, NULL) := 0; trace_mhp_acpi_read_size_lo(mem_st->selector, val); break; case 0xc: /* Hi part of DIMM size */ - val =3D o ? object_property_get_int(o, PC_DIMM_SIZE_PROP, NULL) >>= 32 : 0; + val =3D + o ? object_property_get_uint(o, PC_DIMM_SIZE_PROP, NULL) >> 32= : 0; trace_mhp_acpi_read_size_hi(mem_st->selector, val); break; case 0x10: /* node proximity for _PXM method */ diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index e57027149d..4e4cf1472f 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -238,8 +238,8 @@ nvdimm_build_structure_spa(GArray *structures, DeviceSt= ate *dev) NvdimmNfitSpa *nfit_spa; uint64_t addr =3D object_property_get_uint(OBJECT(dev), PC_DIMM_ADDR_P= ROP, NULL); - uint64_t size =3D object_property_get_int(OBJECT(dev), PC_DIMM_SIZE_PR= OP, - NULL); + uint64_t size =3D object_property_get_uint(OBJECT(dev), PC_DIMM_SIZE_P= ROP, + NULL); uint32_t node =3D object_property_get_uint(OBJECT(dev), PC_DIMM_NODE_P= ROP, NULL); int slot =3D object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, @@ -284,8 +284,8 @@ static void nvdimm_build_structure_memdev(GArray *structures, DeviceState *dev) { NvdimmNfitMemDev *nfit_memdev; - uint64_t size =3D object_property_get_int(OBJECT(dev), PC_DIMM_SIZE_PR= OP, - NULL); + uint64_t size =3D object_property_get_uint(OBJECT(dev), PC_DIMM_SIZE_P= ROP, + NULL); int slot =3D object_property_get_int(OBJECT(dev), PC_DIMM_SLOT_PROP, NULL); uint32_t handle =3D nvdimm_slot_to_handle(slot); diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index f6def8c239..b72258e28f 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -136,7 +136,7 @@ static int pc_existing_dimms_capacity_internal(Object *= obj, void *opaque) DeviceState *dev =3D DEVICE(obj); =20 if (dev->realized) { - (*size) +=3D object_property_get_int(obj, PC_DIMM_SIZE_PROP, + (*size) +=3D object_property_get_uint(obj, PC_DIMM_SIZE_PROP, cap->errp); } =20 @@ -182,8 +182,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque) di->addr =3D dimm->addr; di->slot =3D dimm->slot; di->node =3D dimm->node; - di->size =3D object_property_get_int(OBJECT(dimm), PC_DIMM_SIZ= E_PROP, - NULL); + di->size =3D object_property_get_uint(OBJECT(dimm), PC_DIMM_SI= ZE_PROP, + NULL); di->memdev =3D object_get_canonical_path(OBJECT(dimm->hostmem)= ); =20 info->u.dimm.data =3D di; @@ -314,9 +314,9 @@ uint64_t pc_dimm_get_free_addr(uint64_t address_space_s= tart, /* find address range that will fit new DIMM */ for (item =3D list; item; item =3D g_slist_next(item)) { PCDIMMDevice *dimm =3D item->data; - uint64_t dimm_size =3D object_property_get_int(OBJECT(dimm), - PC_DIMM_SIZE_PROP, - errp); + uint64_t dimm_size =3D object_property_get_uint(OBJECT(dimm), + PC_DIMM_SIZE_PROP, + errp); if (errp && *errp) { goto out; } @@ -356,7 +356,7 @@ static Property pc_dimm_properties[] =3D { static void pc_dimm_get_size(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - int64_t value; + uint64_t value; MemoryRegion *mr; PCDIMMDevice *dimm =3D PC_DIMM(obj); PCDIMMDeviceClass *ddc =3D PC_DIMM_GET_CLASS(obj); @@ -364,7 +364,7 @@ static void pc_dimm_get_size(Object *obj, Visitor *v, c= onst char *name, mr =3D ddc->get_memory_region(dimm); value =3D memory_region_size(mr); =20 - visit_type_int(v, name, &value, errp); + visit_type_uint64(v, name, &value, errp); } =20 static void pc_dimm_check_memdev_is_busy(Object *obj, const char *name, @@ -387,7 +387,7 @@ static void pc_dimm_init(Object *obj) { PCDIMMDevice *dimm =3D PC_DIMM(obj); =20 - object_property_add(obj, PC_DIMM_SIZE_PROP, "int", pc_dimm_get_size, + object_property_add(obj, PC_DIMM_SIZE_PROP, "uint64", pc_dimm_get_size, NULL, NULL, NULL, &error_abort); object_property_add_link(obj, PC_DIMM_MEMDEV_PROP, TYPE_MEMORY_BACKEND, (Object **)&dimm->hostmem, --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240290461677.6878745250622; Wed, 31 May 2017 07:18:10 -0700 (PDT) Received: from localhost ([::1]:59758 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Rs-0004Z1-06 for importer@patchew.org; Wed, 31 May 2017 10:18:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4BI-0006PE-PG for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4BE-0004rb-JN for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47056) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4BE-0004rV-CX for qemu-devel@nongnu.org; Wed, 31 May 2017 10:00:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BE877F6A0 for ; Wed, 31 May 2017 14:00:55 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1875E84AA1; Wed, 31 May 2017 14:00:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4BE877F6A0 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4BE877F6A0 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:49 +0400 Message-Id: <20170531135709.345-26-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 14:00:55 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 25/45] pcihp: use get_uint() for "bsel" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The property is defined with object_property_add_uint32_ptr() Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/acpi/pcihp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 3a531a4416..c420a388ea 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -62,10 +62,10 @@ typedef struct AcpiPciHpFind { static int acpi_pcihp_get_bsel(PCIBus *bus) { Error *local_err =3D NULL; - int64_t bsel =3D object_property_get_int(OBJECT(bus), ACPI_PCIHP_PROP_= BSEL, - &local_err); + uint64_t bsel =3D object_property_get_uint(OBJECT(bus), ACPI_PCIHP_PRO= P_BSEL, + &local_err); =20 - if (local_err || bsel < 0 || bsel >=3D ACPI_PCIHP_MAX_HOTPLUG_BUS) { + if (local_err || bsel >=3D ACPI_PCIHP_MAX_HOTPLUG_BUS) { if (local_err) { error_free(local_err); } --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496239910347829.9634344012975; Wed, 31 May 2017 07:11:50 -0700 (PDT) Received: from localhost ([::1]:59728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Lf-0007CV-OY for importer@patchew.org; Wed, 31 May 2017 10:11:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4BQ-0006Vh-59 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4BL-0004sK-I6 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53436) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4BL-0004sC-3P for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:03 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E40C637EEE for ; Wed, 31 May 2017 14:01:01 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id A031452795; Wed, 31 May 2017 14:00:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E40C637EEE Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E40C637EEE From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:50 +0400 Message-Id: <20170531135709.345-27-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 31 May 2017 14:01:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 26/45] aspeed: use {set, get}_uint() for "ram-size" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This property is an alias for device TYPE_ASPEED_SDMC's property "ram-size", which is defined with DEFINE_PROP_UINT64(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/arm/aspeed.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 283c038814..0c6cd17d0d 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -174,8 +174,8 @@ static void aspeed_board_init(MachineState *machine, =20 sc =3D ASPEED_SOC_GET_CLASS(&bmc->soc); =20 - object_property_set_int(OBJECT(&bmc->soc), ram_size, "ram-size", - &error_abort); + object_property_set_uint(OBJECT(&bmc->soc), ram_size, "ram-size", + &error_abort); object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1", &error_abort); object_property_set_int(OBJECT(&bmc->soc), cfg->num_cs, "num-cs", @@ -187,8 +187,8 @@ static void aspeed_board_init(MachineState *machine, * Allocate RAM after the memory controller has checked the size * was valid. If not, a default value is used. */ - ram_size =3D object_property_get_int(OBJECT(&bmc->soc), "ram-size", - &error_abort); + ram_size =3D object_property_get_uint(OBJECT(&bmc->soc), "ram-size", + &error_abort); =20 memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); memory_region_add_subregion(get_system_memory(), sc->info->sdram_base, --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240631055824.9143597028503; Wed, 31 May 2017 07:23:51 -0700 (PDT) Received: from localhost ([::1]:59784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4XN-0001ID-BN for importer@patchew.org; Wed, 31 May 2017 10:23:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4BU-0006aS-Ke for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4BT-0004ti-MD for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47782) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4BT-0004ta-Gb for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:11 -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 mx1.redhat.com (Postfix) with ESMTPS id 7A7447F6A0 for ; Wed, 31 May 2017 14:01:10 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC8887F491; Wed, 31 May 2017 14:01:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7A7447F6A0 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7A7447F6A0 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:51 +0400 Message-Id: <20170531135709.345-28-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 14:01:10 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 27/45] bcm2835_fb: use {get, set}_uint() for "vcram-size" and "vcram-base" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Both properties are defined with DEFINE_PROP_UINT32(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/arm/bcm2835_peripherals.c | 9 ++++----- hw/arm/raspi.c | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c index 369ef1e3bd..b168c6f83e 100644 --- a/hw/arm/bcm2835_peripherals.c +++ b/hw/arm/bcm2835_peripherals.c @@ -126,7 +126,7 @@ static void bcm2835_peripherals_realize(DeviceState *de= v, Error **errp) Object *obj; MemoryRegion *ram; Error *err =3D NULL; - uint32_t ram_size, vcram_size; + uint64_t ram_size, vcram_size; int n; =20 obj =3D object_property_get_link(OBJECT(dev), "ram", &err); @@ -208,15 +208,14 @@ static void bcm2835_peripherals_realize(DeviceState *= dev, Error **errp) INTERRUPT_ARM_MAILBOX)); =20 /* Framebuffer */ - vcram_size =3D (uint32_t)object_property_get_int(OBJECT(s), "vcram-siz= e", - &err); + vcram_size =3D object_property_get_uint(OBJECT(s), "vcram-size", &err); if (err) { error_propagate(errp, err); return; } =20 - object_property_set_int(OBJECT(&s->fb), ram_size - vcram_size, - "vcram-base", &err); + object_property_set_uint(OBJECT(&s->fb), ram_size - vcram_size, + "vcram-base", &err); if (err) { error_propagate(errp, err); return; diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 2b295f14c4..32cdc98c6d 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -153,8 +153,8 @@ static void raspi2_init(MachineState *machine) qdev_prop_set_drive(carddev, "drive", blk, &error_fatal); object_property_set_bool(OBJECT(carddev), true, "realized", &error_fat= al); =20 - vcram_size =3D object_property_get_int(OBJECT(&s->soc), "vcram-size", - &error_abort); + vcram_size =3D object_property_get_uint(OBJECT(&s->soc), "vcram-size", + &error_abort); setup_boot(machine, 2, machine->ram_size - vcram_size); } =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240783277444.5105530960668; Wed, 31 May 2017 07:26:23 -0700 (PDT) Received: from localhost ([::1]:59801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Zn-0003Qe-QL for importer@patchew.org; Wed, 31 May 2017 10:26:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Bb-0006hl-Cj for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4BZ-0004xC-EF for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36996) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4BZ-0004wl-8W for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:17 -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 mx1.redhat.com (Postfix) with ESMTPS id 39D1E80C1C for ; Wed, 31 May 2017 14:01:16 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C02E7F493; Wed, 31 May 2017 14:01:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 39D1E80C1C Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 39D1E80C1C From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:52 +0400 Message-Id: <20170531135709.345-29-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 14:01:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 28/45] platform-bus: use get_uint() for "addr" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is TYPE_MEMORY_REGION's property. Its getter memory_region_get_addr() uses visit_type_uint64(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/core/platform-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c index 329ac670c0..33d32fbf22 100644 --- a/hw/core/platform-bus.c +++ b/hw/core/platform-bus.c @@ -71,7 +71,7 @@ hwaddr platform_bus_get_mmio_addr(PlatformBusDevice *pbus= , SysBusDevice *sbdev, return -1; } =20 - return object_property_get_int(OBJECT(sbdev_mr), "addr", NULL); + return object_property_get_uint(OBJECT(sbdev_mr), "addr", NULL); } =20 static void platform_bus_count_irqs(SysBusDevice *sbdev, void *opaque) --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240927069548.2069692938861; Wed, 31 May 2017 07:28:47 -0700 (PDT) Received: from localhost ([::1]:59815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4c7-0005wt-Lh for importer@patchew.org; Wed, 31 May 2017 10:28:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Bh-0006nb-L6 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Bg-000504-Nc for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46564) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Bg-0004zq-HO for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:24 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 790DD3DBCA for ; Wed, 31 May 2017 14:01:23 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 159348072A; Wed, 31 May 2017 14:01:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 790DD3DBCA Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 790DD3DBCA From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:53 +0400 Message-Id: <20170531135709.345-30-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 14:01:23 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 29/45] acpi: use get_uint() for "acpi-pcihp-io*" properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Those are defined with object_property_add_uint16_ptr() Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/acpi-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index ba163e6df2..78cee47d39 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -137,9 +137,9 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) obj =3D piix; pm->cpu_hp_io_base =3D PIIX4_CPU_HOTPLUG_IO_BASE; pm->pcihp_io_base =3D - object_property_get_int(obj, ACPI_PCIHP_IO_BASE_PROP, NULL); + object_property_get_uint(obj, ACPI_PCIHP_IO_BASE_PROP, NULL); pm->pcihp_io_len =3D - object_property_get_int(obj, ACPI_PCIHP_IO_LEN_PROP, NULL); + object_property_get_uint(obj, ACPI_PCIHP_IO_LEN_PROP, NULL); } if (lpc) { obj =3D lpc; --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240049899341.10775958867885; Wed, 31 May 2017 07:14:09 -0700 (PDT) Received: from localhost ([::1]:59736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ny-00018B-4g for importer@patchew.org; Wed, 31 May 2017 10:14:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Bp-0006tT-Df for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Bl-000518-92 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46902) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Bl-00050z-0v for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC8C62D9FDE for ; Wed, 31 May 2017 14:01:27 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15B188140A; Wed, 31 May 2017 14:01:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EC8C62D9FDE Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EC8C62D9FDE From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:54 +0400 Message-Id: <20170531135709.345-31-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 14:01:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 30/45] acpi: use get_uint() for various acpi properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" PIIX4: piix4_pm_add_propeties() defines these with object_property_add_uint*_ptr(). Q35: ich9_lpc_add_properties() and ich9_pm_add_properties() define them similarly, except for ACPI_PM_PROP_GPE0_BLK(). That one's getter ich9_pm_get_gpe0_blk() uses visit_type_uint32(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/acpi-build.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 78cee47d39..8ae0373541 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -180,20 +180,21 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) qobject_decref(o); =20 /* Fill in mandatory properties */ - pm->sci_int =3D object_property_get_int(obj, ACPI_PM_PROP_SCI_INT, NUL= L); - - pm->acpi_enable_cmd =3D object_property_get_int(obj, - ACPI_PM_PROP_ACPI_ENABLE= _CMD, - NULL); - pm->acpi_disable_cmd =3D object_property_get_int(obj, - ACPI_PM_PROP_ACPI_DISABL= E_CMD, - NULL); - pm->io_base =3D object_property_get_int(obj, ACPI_PM_PROP_PM_IO_BASE, - NULL); - pm->gpe0_blk =3D object_property_get_int(obj, ACPI_PM_PROP_GPE0_BLK, + pm->sci_int =3D object_property_get_uint(obj, ACPI_PM_PROP_SCI_INT, NU= LL); + + pm->acpi_enable_cmd =3D object_property_get_uint(obj, + ACPI_PM_PROP_ACPI_ENABL= E_CMD, + NULL); + pm->acpi_disable_cmd =3D + object_property_get_uint(obj, + ACPI_PM_PROP_ACPI_DISABLE_CMD, + NULL); + pm->io_base =3D object_property_get_uint(obj, ACPI_PM_PROP_PM_IO_BASE, NULL); - pm->gpe0_blk_len =3D object_property_get_int(obj, ACPI_PM_PROP_GPE0_BL= K_LEN, - NULL); + pm->gpe0_blk =3D object_property_get_uint(obj, ACPI_PM_PROP_GPE0_BLK, + NULL); + pm->gpe0_blk_len =3D object_property_get_uint(obj, ACPI_PM_PROP_GPE0_B= LK_LEN, + NULL); pm->pcihp_bridge_en =3D object_property_get_bool(obj, "acpi-pci-hotplug-with-bridge-suppor= t", NULL); --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240356943500.1170224709351; Wed, 31 May 2017 07:19:16 -0700 (PDT) Received: from localhost ([::1]:59760 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Sv-0005NT-1I for importer@patchew.org; Wed, 31 May 2017 10:19:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4By-000716-SI for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Bt-00054v-Dp for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37816) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Bt-00054S-8G for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3968A80C0D for ; Wed, 31 May 2017 14:01:36 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A3E80E6E; Wed, 31 May 2017 14:01:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3968A80C0D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3968A80C0D From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:55 +0400 Message-Id: <20170531135709.345-32-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 14:01:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 31/45] acpi: use get_uint() for "pci-hole*" properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Those properties use visit_type_uint*() Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/acpi-build.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 8ae0373541..64a277b974 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -247,19 +247,19 @@ static void acpi_get_pci_holes(Range *hole, Range *ho= le64) g_assert(pci_host); =20 range_set_bounds1(hole, - object_property_get_int(pci_host, - PCI_HOST_PROP_PCI_HOLE_START, - NULL), - object_property_get_int(pci_host, - PCI_HOST_PROP_PCI_HOLE_END, - NULL)); + object_property_get_uint(pci_host, + PCI_HOST_PROP_PCI_HOLE_STAR= T, + NULL), + object_property_get_uint(pci_host, + PCI_HOST_PROP_PCI_HOLE_END, + NULL)); range_set_bounds1(hole64, - object_property_get_int(pci_host, - PCI_HOST_PROP_PCI_HOLE64_STA= RT, - NULL), - object_property_get_int(pci_host, - PCI_HOST_PROP_PCI_HOLE64_END, - NULL)); + object_property_get_uint(pci_host, + PCI_HOST_PROP_PCI_HOLE64_ST= ART, + NULL), + object_property_get_uint(pci_host, + PCI_HOST_PROP_PCI_HOLE64_EN= D, + NULL)); } =20 #define ACPI_PORT_SMI_CMD 0x00b2 /* TODO: this is APM_CNT_IOPORT= */ --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240519364946.392652491003; Wed, 31 May 2017 07:21:59 -0700 (PDT) Received: from localhost ([::1]:59776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4VY-0007oU-UO for importer@patchew.org; Wed, 31 May 2017 10:21:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4C5-00077S-JT for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Bz-00057f-SV for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47954) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Bz-00057R-M9 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 954603DBF5 for ; Wed, 31 May 2017 14:01:42 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id B629E80737; Wed, 31 May 2017 14:01:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 954603DBF5 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 954603DBF5 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:56 +0400 Message-Id: <20170531135709.345-33-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 14:01:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 32/45] pc: use get_uint() for "iobase" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_ISA_FDC's property "iobase" is defined with DEFINE_PROP_UINT32(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 107a34125b..3e8f8e83b2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -347,7 +347,7 @@ static int check_fdc(Object *obj, void *opaque) return 0; } =20 - iobase =3D object_property_get_int(obj, "iobase", &local_err); + iobase =3D object_property_get_uint(obj, "iobase", &local_err); if (local_err || iobase !=3D 0x3f0) { error_free(local_err); return 0; --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240193573945.8317035316089; Wed, 31 May 2017 07:16:33 -0700 (PDT) Received: from localhost ([::1]:59751 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4QJ-0003G5-UA for importer@patchew.org; Wed, 31 May 2017 10:16:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4CB-0007DQ-VE for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4C7-00059U-Ex for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50234) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4C7-00059E-9z for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B02C7F6A1 for ; Wed, 31 May 2017 14:01:50 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6696984AA1; Wed, 31 May 2017 14:01:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3B02C7F6A1 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3B02C7F6A1 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:57 +0400 Message-Id: <20170531135709.345-34-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 31 May 2017 14:01:50 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 33/45] pc: use get_uint() for "apic-id" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_X86_CPU's property "apic-id" is defined with DEFINE_PROP_UINT32(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 3e8f8e83b2..c31115a8f0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1100,7 +1100,7 @@ static void pc_new_cpu(const char *typename, int64_t = apic_id, Error **errp) =20 cpu =3D object_new(typename); =20 - object_property_set_int(cpu, apic_id, "apic-id", &local_err); + object_property_set_uint(cpu, apic_id, "apic-id", &local_err); object_property_set_bool(cpu, true, "realized", &local_err); =20 object_unref(cpu); --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240465404388.7555186742827; Wed, 31 May 2017 07:21:05 -0700 (PDT) Received: from localhost ([::1]:59773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ue-00070T-Pi for importer@patchew.org; Wed, 31 May 2017 10:21:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4CI-0007IQ-1U for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4CC-0005Al-3Z for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58156) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4CB-0005AN-VS for qemu-devel@nongnu.org; Wed, 31 May 2017 10:01:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB7B681138 for ; Wed, 31 May 2017 14:01:54 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBE338073B; Wed, 31 May 2017 14:01:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB7B681138 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EB7B681138 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:58 +0400 Message-Id: <20170531135709.345-35-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 May 2017 14:01:55 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 34/45] pc: use get_uint() for "hpet-intcap" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_HPET's property HPET_INTCAP is defined with DEFINE_PROP_UINT32(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c31115a8f0..e970d0c4e2 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1560,7 +1560,7 @@ void pc_basic_device_init(ISABus *isa_bus, qemu_irq *= gsi, * and earlier, use IRQ2 for compat. Otherwise, use IRQ16~23, * IRQ8 and IRQ2. */ - uint8_t compat =3D object_property_get_int(OBJECT(hpet), + uint8_t compat =3D object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL); if (!compat) { qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs); --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14962406231981013.0783146223844; Wed, 31 May 2017 07:23:43 -0700 (PDT) Received: from localhost ([::1]:59783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4XC-00017O-MB for importer@patchew.org; Wed, 31 May 2017 10:23:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4CM-0007L9-RV for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4CJ-0005C9-55 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52526) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4CI-0005Bz-VV for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:03 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E465A6316C for ; Wed, 31 May 2017 14:02:01 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id C57FB80F9B; Wed, 31 May 2017 14:01:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E465A6316C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E465A6316C From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:56:59 +0400 Message-Id: <20170531135709.345-36-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 31 May 2017 14:02:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 35/45] xen: use get_uint() for "max-ram-below-4g" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_PC_MACHINE's property PC_MACHINE_MAX_RAM_BELOW_4G's getter and setter pc_machine_get_max_ram_below_4g() and pc_machine_set_max_ram_below_4g() use visit_type_size() Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/i386/xen/xen-hvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 919f09b694..b9981b257b 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -183,9 +183,9 @@ static void xen_ram_init(PCMachineState *pcms, { MemoryRegion *sysmem =3D get_system_memory(); ram_addr_t block_len; - uint64_t user_lowmem =3D object_property_get_int(qdev_get_machine(), - PC_MACHINE_MAX_RAM_BELO= W_4G, - &error_abort); + uint64_t user_lowmem =3D object_property_get_uint(qdev_get_machine(), + PC_MACHINE_MAX_RAM_BEL= OW_4G, + &error_abort); =20 /* Handle the machine opt max-ram-below-4g. It is basically doing * min(xen limit, user limit). --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240775202318.2790373369272; Wed, 31 May 2017 07:26:15 -0700 (PDT) Received: from localhost ([::1]:59800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Zd-0003Hp-MV for importer@patchew.org; Wed, 31 May 2017 10:26:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Cd-0007t6-Gh for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4CX-0005E7-Q7 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59396) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4CX-0005E3-KS for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:17 -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 mx1.redhat.com (Postfix) with ESMTPS id 966DA80F9D for ; Wed, 31 May 2017 14:02:16 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDE9318A72; Wed, 31 May 2017 14:02:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 966DA80F9D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 966DA80F9D From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:00 +0400 Message-Id: <20170531135709.345-37-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 31 May 2017 14:02:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 36/45] arm: use get_uint() for "mp-affinity" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_ARM_CPU's property "mp-affinity" is defined with DEFINE_PROP_UINT64(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/intc/arm_gicv3_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c index c6493d6c07..e2064cd8c5 100644 --- a/hw/intc/arm_gicv3_common.c +++ b/hw/intc/arm_gicv3_common.c @@ -267,7 +267,7 @@ static void arm_gicv3_common_realize(DeviceState *dev, = Error **errp) * VLPIS =3D=3D 0 (virtual LPIs not supported) * PLPIS =3D=3D 0 (physical LPIs not supported) */ - cpu_affid =3D object_property_get_int(OBJECT(cpu), "mp-affinity", = NULL); + cpu_affid =3D object_property_get_uint(OBJECT(cpu), "mp-affinity",= NULL); last =3D (i =3D=3D s->num_cpu - 1); =20 /* The CPU mp-affinity property is in MPIDR register format; squash --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240358082226.19117518654582; Wed, 31 May 2017 07:19:18 -0700 (PDT) Received: from localhost ([::1]:59761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Sv-0005O3-MW for importer@patchew.org; Wed, 31 May 2017 10:19:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Cn-00081S-GF for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Cj-0005KR-CA for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51842) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Cj-0005K9-6Z for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:29 -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 mx1.redhat.com (Postfix) with ESMTPS id 3300F80465 for ; Wed, 31 May 2017 14:02:28 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id E775E18A75; Wed, 31 May 2017 14:02:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3300F80465 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3300F80465 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:01 +0400 Message-Id: <20170531135709.345-38-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 31 May 2017 14:02:28 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 37/45] auxbus: use get_uint() for "addr" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is TYPE_MEMORY_REGION's property. Its getter memory_region_get_addr() uses visit_type_uint64(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/misc/auxbus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/auxbus.c b/hw/misc/auxbus.c index e4a7ba41de..8a90ddda84 100644 --- a/hw/misc/auxbus.c +++ b/hw/misc/auxbus.c @@ -244,7 +244,7 @@ static void aux_slave_dev_print(Monitor *mon, DeviceSta= te *dev, int indent) =20 monitor_printf(mon, "%*smemory " TARGET_FMT_plx "/" TARGET_FMT_plx "\n= ", indent, "", - object_property_get_int(OBJECT(s->mmio), "addr", NULL), + object_property_get_uint(OBJECT(s->mmio), "addr", NULL), memory_region_size(s->mmio)); } =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496241202171236.67670782222774; Wed, 31 May 2017 07:33:22 -0700 (PDT) Received: from localhost ([::1]:59853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4gY-0001HK-LN for importer@patchew.org; Wed, 31 May 2017 10:33:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4D3-0008Dr-OD for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4D1-0005OG-L4 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51854) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4D1-0005OC-F3 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:02:47 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D6CB3D974 for ; Wed, 31 May 2017 14:02:46 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id D70658071F; Wed, 31 May 2017 14:02:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6D6CB3D974 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6D6CB3D974 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:02 +0400 Message-Id: <20170531135709.345-39-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 14:02:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 38/45] pvpanic: use get_uint() for "ioport" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_ISA_PVPANIC_DEVICE's property PVPANIC_IOPORT_PROP is defined with DEFINE_PROP_UINT16(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/misc/pvpanic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 57da7f2199..2b1e9a6450 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -111,7 +111,7 @@ uint16_t pvpanic_port(void) if (!o) { return 0; } - return object_property_get_int(o, PVPANIC_IOPORT_PROP, NULL); + return object_property_get_uint(o, PVPANIC_IOPORT_PROP, NULL); } =20 static Property pvpanic_isa_properties[] =3D { --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240671485526.6215134289912; Wed, 31 May 2017 07:24:31 -0700 (PDT) Received: from localhost ([::1]:59785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Y1-0001q5-La for importer@patchew.org; Wed, 31 May 2017 10:24:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53636) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4DM-0008Pn-1G for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4DG-0005Pv-JC for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56310) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4DG-0005Pr-D9 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:02 -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 mx1.redhat.com (Postfix) with ESMTPS id 64F846598C for ; Wed, 31 May 2017 14:03:01 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55F7F18B8E; Wed, 31 May 2017 14:02:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 64F846598C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 64F846598C From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:03 +0400 Message-Id: <20170531135709.345-40-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 31 May 2017 14:03:01 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 39/45] pnv-core: use get_uint() for "core-pir" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is an alias of TYPE_PNV_CORE's property "pir", which is defined with DEFINE_PROP_UINT32() Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/ppc/pnv_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c index 1b7ec70f03..142bad1e57 100644 --- a/hw/ppc/pnv_core.c +++ b/hw/ppc/pnv_core.c @@ -51,7 +51,7 @@ static void powernv_cpu_init(PowerPCCPU *cpu, Error **err= p) int thread_index =3D 0; /* TODO: TCG supports only one thread */ ppc_spr_t *pir =3D &env->spr_cb[SPR_PIR]; =20 - core_pir =3D object_property_get_int(OBJECT(cpu), "core-pir", &error_a= bort); + core_pir =3D object_property_get_uint(OBJECT(cpu), "core-pir", &error_= abort); =20 /* * The PIR of a thread is the core PIR + the thread index. We will --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496241331215359.7788847138672; Wed, 31 May 2017 07:35:31 -0700 (PDT) Received: from localhost ([::1]:59869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4iZ-00033A-Or for importer@patchew.org; Wed, 31 May 2017 10:35:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4DZ-000093-V9 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4DU-0005VE-G1 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53560) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4DU-0005Ut-Ai for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5740036807 for ; Wed, 31 May 2017 14:03:15 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 609988073D; Wed, 31 May 2017 14:03:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5740036807 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5740036807 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:04 +0400 Message-Id: <20170531135709.345-41-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 31 May 2017 14:03:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 40/45] numa: use get_uint() for "size" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" "size" is a property of TYPE_MEMORY_BACKEND. host_memory_backend_get_size() and host_memory_backend_set_size() use visit_type_size(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- numa.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/numa.c b/numa.c index ca731455e9..853f51d143 100644 --- a/numa.c +++ b/numa.c @@ -216,7 +216,7 @@ static void parse_numa_node(MachineState *ms, NumaNodeO= ptions *node, } =20 object_ref(o); - numa_info[nodenr].node_mem =3D object_property_get_int(o, "size", = NULL); + numa_info[nodenr].node_mem =3D object_property_get_uint(o, "size",= NULL); numa_info[nodenr].node_memdev =3D MEMORY_BACKEND(o); } numa_info[nodenr].present =3D true; @@ -651,8 +651,8 @@ static int query_memdev(Object *obj, void *opaque) m->value->id =3D object_property_get_str(obj, "id", NULL); m->value->has_id =3D !!m->value->id; =20 - m->value->size =3D object_property_get_int(obj, "size", - &error_abort); + m->value->size =3D object_property_get_uint(obj, "size", + &error_abort); m->value->merge =3D object_property_get_bool(obj, "merge", &error_abort); m->value->dump =3D object_property_get_bool(obj, "dump", --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240525720235.6762389418558; Wed, 31 May 2017 07:22:05 -0700 (PDT) Received: from localhost ([::1]:59777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Vb-0007rr-5g for importer@patchew.org; Wed, 31 May 2017 10:21:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4EB-0000dB-0D for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4EA-0005mO-8W for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4EA-0005mC-31 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:03:58 -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 mx1.redhat.com (Postfix) with ESMTPS id 03EA97248E for ; Wed, 31 May 2017 14:03:57 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id B549B18A75; Wed, 31 May 2017 14:03:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 03EA97248E Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 03EA97248E From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:05 +0400 Message-Id: <20170531135709.345-42-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 31 May 2017 14:03:57 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 41/45] i386/cpu: use get_uint() for "min-level"/"min-xlevel" properties X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" These are properties of TYPE_X86_CPU, defined with DEFINE_PROP_UINT32() Signed-off-by: Marc-Andr=C3=A9 Lureau --- target/i386/cpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 12882f0774..f9dba1bd62 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2324,8 +2324,8 @@ static void x86_cpu_load_def(X86CPU *cpu, X86CPUDefin= ition *def, Error **errp) */ =20 /* CPU models only set _minimum_ values for level/xlevel: */ - object_property_set_int(OBJECT(cpu), def->level, "min-level", errp); - object_property_set_int(OBJECT(cpu), def->xlevel, "min-xlevel", errp); + object_property_set_uint(OBJECT(cpu), def->level, "min-level", errp); + object_property_set_uint(OBJECT(cpu), def->xlevel, "min-xlevel", errp); =20 object_property_set_int(OBJECT(cpu), def->family, "family", errp); object_property_set_int(OBJECT(cpu), def->model, "model", errp); --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240673776305.0570059236426; Wed, 31 May 2017 07:24:33 -0700 (PDT) Received: from localhost ([::1]:59786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Y4-0001sb-2Z for importer@patchew.org; Wed, 31 May 2017 10:24:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54011) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ec-0000yr-3p for qemu-devel@nongnu.org; Wed, 31 May 2017 10:04:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4EZ-00068u-SY for qemu-devel@nongnu.org; Wed, 31 May 2017 10:04:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58614) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4EZ-000689-Mp for qemu-devel@nongnu.org; Wed, 31 May 2017 10:04:23 -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 mx1.redhat.com (Postfix) with ESMTPS id B473A8046E for ; Wed, 31 May 2017 14:04:22 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id D488A18A63; Wed, 31 May 2017 14:04:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B473A8046E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B473A8046E From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:06 +0400 Message-Id: <20170531135709.345-43-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 31 May 2017 14:04:22 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 42/45] console: use get_uint() for "head" property X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" TYPE_QEMU_CONSOLE property "head" is defined with object_property_add_uint*_ptr(). Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/console.c b/ui/console.c index ac66b3c910..ad3f7c6a2c 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1872,8 +1872,8 @@ QemuConsole *qemu_console_lookup_by_device(DeviceStat= e *dev, uint32_t head) if (DEVICE(obj) !=3D dev) { continue; } - h =3D object_property_get_int(OBJECT(consoles[i]), - "head", &error_abort); + h =3D object_property_get_uint(OBJECT(consoles[i]), + "head", &error_abort); if (h !=3D head) { continue; } --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496241429362479.2022299172511; Wed, 31 May 2017 07:37:09 -0700 (PDT) Received: from localhost ([::1]:59880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4kF-0004Cq-Tb for importer@patchew.org; Wed, 31 May 2017 10:37:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4Ey-0001FF-4T for qemu-devel@nongnu.org; Wed, 31 May 2017 10:04:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4Et-0006TG-J8 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:04:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47054) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4Et-0006TA-Da for qemu-devel@nongnu.org; Wed, 31 May 2017 10:04:43 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BD2C80C11 for ; Wed, 31 May 2017 14:04:42 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id E671B7EBCF; Wed, 31 May 2017 14:04:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5BD2C80C11 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5BD2C80C11 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:07 +0400 Message-Id: <20170531135709.345-44-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 14:04:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 43/45] tests/qdict: check more get_try_int() cases X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Suggested by Markus Armbruster. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- tests/check-qdict.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 5c70490e83..889b43b57d 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -117,10 +117,17 @@ static void qdict_get_try_int_test(void) QDict *tests_dict =3D qdict_new(); =20 qdict_put_int(tests_dict, key, value); + qdict_put_str(tests_dict, "string", "test"); =20 ret =3D qdict_get_try_int(tests_dict, key, 0); g_assert(ret =3D=3D value); =20 + ret =3D qdict_get_try_int(tests_dict, "missing", -42); + g_assert_cmpuint(ret, =3D=3D, -42); + + ret =3D qdict_get_try_int(tests_dict, "string", -42); + g_assert_cmpuint(ret, =3D=3D, -42); + QDECREF(tests_dict); } =20 --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240915473821.7987142868942; Wed, 31 May 2017 07:28:35 -0700 (PDT) Received: from localhost ([::1]:59813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4by-0005mV-20 for importer@patchew.org; Wed, 31 May 2017 10:28:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4FI-0001Um-BB for qemu-devel@nongnu.org; Wed, 31 May 2017 10:05:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4FD-0006W1-4k for qemu-devel@nongnu.org; Wed, 31 May 2017 10:05:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4FC-0006Vu-SB for qemu-devel@nongnu.org; Wed, 31 May 2017 10:05:03 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D747A15447 for ; Wed, 31 May 2017 14:05:01 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 869AD7C8AA; Wed, 31 May 2017 14:04:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D747A15447 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D747A15447 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:08 +0400 Message-Id: <20170531135709.345-45-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 31 May 2017 14:05:02 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 44/45] RFC: qdict: add uint X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Similar to int support, add uint support. Note this is RFC because this is currently unused in qemu, I haven't found a good user for it yet (kaslr qemu-ga code did use it though). Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Markus Armbruster --- include/qapi/qmp/qdict.h | 5 +++++ qobject/qdict.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/check-qdict.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 363e431106..8c7c2b762b 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -56,6 +56,8 @@ void qdict_destroy_obj(QObject *obj); /* Helpers for int, bool, and string */ #define qdict_put_int(qdict, key, value) \ qdict_put(qdict, key, qnum_from_int(value)) +#define qdict_put_uint(qdict, key, value) \ + qdict_put(qdict, key, qnum_from_uint(value)) #define qdict_put_bool(qdict, key, value) \ qdict_put(qdict, key, qbool_from_bool(value)) #define qdict_put_str(qdict, key, value) \ @@ -64,12 +66,15 @@ void qdict_destroy_obj(QObject *obj); /* High level helpers */ double qdict_get_double(const QDict *qdict, const char *key); int64_t qdict_get_int(const QDict *qdict, const char *key); +uint64_t qdict_get_uint(const QDict *qdict, const char *key); bool qdict_get_bool(const QDict *qdict, const char *key); QList *qdict_get_qlist(const QDict *qdict, const char *key); QDict *qdict_get_qdict(const QDict *qdict, const char *key); const char *qdict_get_str(const QDict *qdict, const char *key); int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value); +uint64_t qdict_get_try_uint(const QDict *qdict, const char *key, + uint64_t def_value); bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_valu= e); const char *qdict_get_try_str(const QDict *qdict, const char *key); =20 diff --git a/qobject/qdict.c b/qobject/qdict.c index f62625cbd6..b02dc6b745 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -208,6 +208,25 @@ int64_t qdict_get_int(const QDict *qdict, const char *= key) } =20 /** + * qdict_get_uint(): Get an unsigned integer mapped by 'key' + * + * This function assumes that 'key' exists and it stores a + * QNum int object. + * + * Return unsigned integer mapped by 'key'. + */ +uint64_t qdict_get_uint(const QDict *qdict, const char *key) +{ + uint64_t val; + + if (!qnum_get_uint(qobject_to_qnum(qdict_get(qdict, key)), &val)) { + g_assert_not_reached(); + } + + return val; +} + +/** * qdict_get_bool(): Get a bool mapped by 'key' * * This function assumes that 'key' exists and it stores a @@ -271,6 +290,26 @@ int64_t qdict_get_try_int(const QDict *qdict, const ch= ar *key, } =20 /** + * qdict_get_try_uint(): Try to get usigned integer mapped by 'key' + * + * Return unsigned integer mapped by 'key', if it is not present in + * the dictionary or if the stored object is not of QNum type + * 'def_value' will be returned. + */ +uint64_t qdict_get_try_uint(const QDict *qdict, const char *key, + uint64_t def_value) +{ + QNum *qnum =3D qobject_to_qnum(qdict_get(qdict, key)); + uint64_t val; + + if (!qnum || !qnum_get_uint(qnum, &val)) { + val =3D def_value; + } + + return val; +} + +/** * qdict_get_try_bool(): Try to get a bool mapped by 'key' * * Return bool mapped by 'key', if it is not present in the diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 889b43b57d..2a5b322509 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -109,6 +109,21 @@ static void qdict_get_int_test(void) QDECREF(tests_dict); } =20 +static void qdict_get_uint_test(void) +{ + uint64_t ret; + const uint64_t value =3D UINT64_MAX; + const char *key =3D "uint"; + QDict *tests_dict =3D qdict_new(); + + qdict_put_uint(tests_dict, key, value); + + ret =3D qdict_get_uint(tests_dict, key); + g_assert(ret =3D=3D value); + + QDECREF(tests_dict); +} + static void qdict_get_try_int_test(void) { int ret; @@ -131,6 +146,28 @@ static void qdict_get_try_int_test(void) QDECREF(tests_dict); } =20 +static void qdict_get_try_uint_test(void) +{ + uint64_t ret; + const uint64_t value =3D UINT64_MAX; + const char *key =3D "uint"; + QDict *tests_dict =3D qdict_new(); + + qdict_put_uint(tests_dict, key, value); + qdict_put_str(tests_dict, "string", "test"); + + ret =3D qdict_get_try_uint(tests_dict, key, 0); + g_assert_cmpuint(ret, =3D=3D, value); + + ret =3D qdict_get_try_uint(tests_dict, "missing", 42); + g_assert_cmpuint(ret, =3D=3D, 42); + + ret =3D qdict_get_try_uint(tests_dict, "string", 42); + g_assert_cmpuint(ret, =3D=3D, 42); + + QDECREF(tests_dict); +} + static void qdict_get_str_test(void) { const char *p; @@ -866,7 +903,9 @@ int main(int argc, char **argv) /* Continue, but now with fixtures */ g_test_add_func("/public/get", qdict_get_test); g_test_add_func("/public/get_int", qdict_get_int_test); + g_test_add_func("/public/get_uint", qdict_get_uint_test); g_test_add_func("/public/get_try_int", qdict_get_try_int_test); + g_test_add_func("/public/get_try_uint", qdict_get_try_uint_test); g_test_add_func("/public/get_str", qdict_get_str_test); g_test_add_func("/public/get_try_str", qdict_get_try_str_test); g_test_add_func("/public/defaults", qdict_defaults_test); --=20 2.13.0.91.g00982b8dd From nobody Sun Apr 28 04:05:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496240823684888.0081383106149; Wed, 31 May 2017 07:27:03 -0700 (PDT) Received: from localhost ([::1]:59803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4aT-00044z-2Y for importer@patchew.org; Wed, 31 May 2017 10:27:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG4FX-0001mn-P3 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:05:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG4FV-0006eZ-0m for qemu-devel@nongnu.org; Wed, 31 May 2017 10:05:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48754) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG4FU-0006eJ-O5 for qemu-devel@nongnu.org; Wed, 31 May 2017 10:05:20 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3FC280C1D for ; Wed, 31 May 2017 14:05:19 +0000 (UTC) Received: from localhost (ovpn-112-25.ams2.redhat.com [10.36.112.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id C46778140C; Wed, 31 May 2017 14:05:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C3FC280C1D Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=marcandre.lureau@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C3FC280C1D From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 17:57:09 +0400 Message-Id: <20170531135709.345-46-marcandre.lureau@redhat.com> In-Reply-To: <20170531135709.345-1-marcandre.lureau@redhat.com> References: <20170531135709.345-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 31 May 2017 14:05:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 45/45] qobject: move dump_qobject() from block/ to qobject/ X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , armbru@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The dump functions could be generally useful for any qobject user or for debugging etc. Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/qapi/qmp/qdict.h | 2 ++ include/qapi/qmp/qlist.h | 2 ++ include/qapi/qmp/qobject.h | 7 ++++ block/qapi.c | 90 +++---------------------------------------= ---- qobject/qdict.c | 30 ++++++++++++++++ qobject/qlist.c | 23 ++++++++++++ qobject/qobject.c | 19 ++++++++++ tests/check-qjson.c | 19 ++++++++++ 8 files changed, 106 insertions(+), 86 deletions(-) diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index 8c7c2b762b..1ef3bc8cda 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -91,4 +91,6 @@ QObject *qdict_crumple(const QDict *src, Error **errp); =20 void qdict_join(QDict *dest, QDict *src, bool overwrite); =20 +char *qdict_to_string(QDict *dict, int indent); + #endif /* QDICT_H */ diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index c4b5fdad9b..c93ac3e15b 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -60,6 +60,8 @@ size_t qlist_size(const QList *qlist); QList *qobject_to_qlist(const QObject *obj); void qlist_destroy_obj(QObject *obj); =20 +char *qlist_to_string(QList *list, int indent); + static inline const QListEntry *qlist_first(const QList *qlist) { return QTAILQ_FIRST(&qlist->head); diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index b8ddbca405..0d6ae5048a 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -101,4 +101,11 @@ static inline QObject *qnull(void) return &qnull_; } =20 +char *qobject_to_string_indent(QObject *obj, int indent); + +static inline char *qobject_to_string(QObject *obj) +{ + return qobject_to_string_indent(obj, 0); +} + #endif /* QOBJECT_H */ diff --git a/block/qapi.c b/block/qapi.c index 2050df29e4..9b7d42e50a 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -586,101 +586,19 @@ void bdrv_snapshot_dump(fprintf_function func_fprint= f, void *f, } } =20 -static void dump_qdict(fprintf_function func_fprintf, void *f, int indenta= tion, - QDict *dict); -static void dump_qlist(fprintf_function func_fprintf, void *f, int indenta= tion, - QList *list); - -static void dump_qobject(fprintf_function func_fprintf, void *f, - int comp_indent, QObject *obj) -{ - switch (qobject_type(obj)) { - case QTYPE_QNUM: { - QNum *value =3D qobject_to_qnum(obj); - char *tmp =3D qnum_to_string(value); - func_fprintf(f, "%s", tmp); - g_free(tmp); - break; - } - case QTYPE_QSTRING: { - QString *value =3D qobject_to_qstring(obj); - func_fprintf(f, "%s", qstring_get_str(value)); - break; - } - case QTYPE_QDICT: { - QDict *value =3D qobject_to_qdict(obj); - dump_qdict(func_fprintf, f, comp_indent, value); - break; - } - case QTYPE_QLIST: { - QList *value =3D qobject_to_qlist(obj); - dump_qlist(func_fprintf, f, comp_indent, value); - break; - } - case QTYPE_QBOOL: { - QBool *value =3D qobject_to_qbool(obj); - func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false"= ); - break; - } - default: - abort(); - } -} - -static void dump_qlist(fprintf_function func_fprintf, void *f, int indenta= tion, - QList *list) -{ - const QListEntry *entry; - int i =3D 0; - - for (entry =3D qlist_first(list); entry; entry =3D qlist_next(entry), = i++) { - QType type =3D qobject_type(entry->value); - bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); - func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); - if (!composite) { - func_fprintf(f, "\n"); - } - } -} - -static void dump_qdict(fprintf_function func_fprintf, void *f, int indenta= tion, - QDict *dict) -{ - const QDictEntry *entry; - - for (entry =3D qdict_first(dict); entry; entry =3D qdict_next(dict, en= try)) { - QType type =3D qobject_type(entry->value); - bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); - char *key =3D g_malloc(strlen(entry->key) + 1); - int i; - - /* replace dashes with spaces in key (variable) names */ - for (i =3D 0; entry->key[i]; i++) { - key[i] =3D entry->key[i] =3D=3D '-' ? ' ' : entry->key[i]; - } - key[i] =3D 0; - func_fprintf(f, "%*s%s:%c", indentation * 4, "", key, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); - if (!composite) { - func_fprintf(f, "\n"); - } - g_free(key); - } -} - void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, ImageInfoSpecific *info_spec) { QObject *obj, *data; Visitor *v =3D qobject_output_visitor_new(&obj); + char *tmp; =20 visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort); visit_complete(v, &obj); data =3D qdict_get(qobject_to_qdict(obj), "data"); - dump_qobject(func_fprintf, f, 1, data); + tmp =3D qobject_to_string_indent(data, 1); + func_fprintf(f, "%s", tmp); + g_free(tmp); qobject_decref(obj); visit_free(v); } diff --git a/qobject/qdict.c b/qobject/qdict.c index b02dc6b745..e2cde1255a 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -1067,3 +1067,33 @@ void qdict_join(QDict *dest, QDict *src, bool overwr= ite) entry =3D next; } } + +char *qdict_to_string(QDict *dict, int indent) +{ + const QDictEntry *entry; + GString *str =3D g_string_new(NULL); + + for (entry =3D qdict_first(dict); entry; entry =3D qdict_next(dict, en= try)) { + QType type =3D qobject_type(entry->value); + bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); + char *key =3D g_malloc(strlen(entry->key) + 1); + char *val =3D qobject_to_string_indent(entry->value, indent + 1); + int i; + + /* replace dashes with spaces in key (variable) names */ + for (i =3D 0; entry->key[i]; i++) { + key[i] =3D entry->key[i] =3D=3D '-' ? ' ' : entry->key[i]; + } + key[i] =3D 0; + g_string_append_printf(str, "%*s%s:", indent * 4, "", key); + g_string_append_c(str, composite ? '\n' : ' '); + g_string_append(str, val); + if (!composite) { + g_string_append_c(str, '\n'); + } + g_free(val); + g_free(key); + } + + return g_string_free(str, false); +} diff --git a/qobject/qlist.c b/qobject/qlist.c index 86b60cb88c..b769248290 100644 --- a/qobject/qlist.c +++ b/qobject/qlist.c @@ -158,3 +158,26 @@ void qlist_destroy_obj(QObject *obj) =20 g_free(qlist); } + +char *qlist_to_string(QList *list, int indent) +{ + GString *str =3D g_string_new(NULL); + const QListEntry *entry; + int i =3D 0; + + for (entry =3D qlist_first(list); entry; entry =3D qlist_next(entry), = i++) { + QType type =3D qobject_type(entry->value); + bool composite =3D (type =3D=3D QTYPE_QDICT || type =3D=3D QTYPE_Q= LIST); + char *val =3D qobject_to_string_indent(entry->value, indent + 1); + + g_string_append_printf(str, "%*s[%i]:", indent * 4, "", i); + g_string_append_c(str, composite ? '\n' : ' '); + g_string_append(str, val); + if (!composite) { + g_string_append_c(str, '\n'); + } + g_free(val); + } + + return g_string_free(str, false); +} diff --git a/qobject/qobject.c b/qobject/qobject.c index b0cafb66f1..64e959c54f 100644 --- a/qobject/qobject.c +++ b/qobject/qobject.c @@ -27,3 +27,22 @@ void qobject_destroy(QObject *obj) assert(QTYPE_QNULL < obj->type && obj->type < QTYPE__MAX); qdestroy[obj->type](obj); } + +char *qobject_to_string_indent(QObject *obj, int indent) +{ + switch (qobject_type(obj)) { + case QTYPE_QNUM: + return qnum_to_string(qobject_to_qnum(obj)); + case QTYPE_QSTRING: + return g_strdup(qstring_get_str(qobject_to_qstring(obj))); + case QTYPE_QDICT: + return qdict_to_string(qobject_to_qdict(obj), indent); + case QTYPE_QLIST: + return qlist_to_string(qobject_to_qlist(obj), indent); + case QTYPE_QBOOL: + return g_strdup(qbool_get_bool(qobject_to_qbool(obj)) ? + "true" : "false"); + default: + abort(); + } +} diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 6fb14445a3..d12daf39e9 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1365,6 +1365,23 @@ static void simple_whitespace(void) } } =20 +static void qobject_to_string_test(void) +{ + QObject *obj; + char *tmp; + + obj =3D qobject_from_json("[ 43, { 'c': { 'd' : 12 } }, [ 1, 2 ], 42 ]= ", + &error_abort); + tmp =3D qobject_to_string(obj); + g_assert_cmpstr(tmp, =3D=3D, + "[0]: 43\n" + "[1]:\n c:\n d: 12\n" + "[2]:\n [0]: 1\n [1]: 2\n" + "[3]: 42\n"); + g_free(tmp); + qobject_decref(obj); +} + static void simple_varargs(void) { QObject *embedded_obj; @@ -1538,5 +1555,7 @@ int main(int argc, char **argv) g_test_add_func("/errors/unterminated/literal", unterminated_literal); g_test_add_func("/errors/limits/nesting", limits_nesting); =20 + g_test_add_func("/qobject/to_string", qobject_to_string_test); + return g_test_run(); } --=20 2.13.0.91.g00982b8dd