From patchwork Wed May 7 23:14:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 888125 Delivered-To: patch@linaro.org Received: by 2002:a5d:4683:0:b0:38f:210b:807b with SMTP id u3csp625159wrq; Wed, 7 May 2025 16:17:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUDZuZR7W/t65t6MDJmJFfVRAY4QjinMarFAa5JXpMUnTewhDyHkvUr4hMyzyOeiogppnV4Sg==@linaro.org X-Google-Smtp-Source: AGHT+IHc4MdRChJFS50EwSl/6ojSV/Y7Dy04+VEA+gFe73U6hGO6gxks4Oi9/N2dxfp0su7BmVJH X-Received: by 2002:ad4:5b84:0:b0:6e8:fa72:be49 with SMTP id 6a1803df08f44-6f542a02006mr63646616d6.12.1746659837140; Wed, 07 May 2025 16:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1746659837; cv=none; d=google.com; s=arc-20240605; b=hPH1XHgB86ZYXLhp5v3/ctSfZmT/x8DpzYOwUb82GsqqM4DaP1vBg6OYSh8wb3ydw/ Mii5LYNelkxiZb2ZFFWtIVjivPjhfwdjEKSpq+jlLC9JgxjXfUScp/T8InzXKuWh47SX j3gIWvWmY/of0ZxFLS3mximktmEh0ijREZJkYs4MVW1bqDNbwwKFGyHEkj6pPfmIh950 GLHov1IG/6/3q/PFc5GwLaqCHv+6jlFKXRa/7QX4H+9gsCL5whMW9nQIT5tNUij/ZqVo 6ApTZqI4OKgUwBENMWI+or0Ov5rnVzQegO/Qvn2YJ5dYMp4w472jqCy8dtx04NICJY50 C11Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hmVgZ2T/BR9KDwjoUJTnrLXEqdGiV/GeYJSs5v9aKiI=; fh=C3ex6Ep0JlVVkO8k9Lw7rcozgcHcGXw85BZvhIOfcrk=; b=Ifyew/Lq0mUFwqPxrgzUpE8Bb9OBseuxanWaXyjXfs2DQ+U3+Q1JqVirZs2ToZ94eQ Gg2yz3WV6CJk2ArI4sHdgFXOEo7jPmeHNaPpyF3s4HGcsKbY+cMjpj4CKRz0t38DkPQW t+RJTi/jLw+C/VGAa0hjB7KlOA5cNGBP2I65TBd4I1jxMtmVpTZlMiZOBt3dB3CLPGn3 8/8AqfqL1Imn686Gu8puHdKUTmZ763jCeAvSGYHWs8FOqrxD2qDHVn8T1x6zqEqQ5S8c zu3TqD8s1Yq56hRMh7wUbAQN8jqB7CdKV0CbZtl7CCezko8TQ9AXQdm2gy5WcWEFMnNz Vqkw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fXmHNQ9n; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6f54278ca43si28860216d6.190.2025.05.07.16.17.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 May 2025 16:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fXmHNQ9n; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uCnye-0000eY-1x; Wed, 07 May 2025 19:15:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uCnyc-0000dg-1S for qemu-devel@nongnu.org; Wed, 07 May 2025 19:14:58 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uCnyY-00079W-OR for qemu-devel@nongnu.org; Wed, 07 May 2025 19:14:57 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-b0b2d0b2843so229821a12.2 for ; Wed, 07 May 2025 16:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1746659693; x=1747264493; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hmVgZ2T/BR9KDwjoUJTnrLXEqdGiV/GeYJSs5v9aKiI=; b=fXmHNQ9nUXJt/3Ai9Da6fTB5b+Jw8UZz7YPehttkWh7TdDu0xNhvgJ40XYFVMa+u8F MZnONw04g3Su6CSFbgx+aus65C21k+UCTiX3vfrC58AXYw7xzXQ2SdqmSQxZfn83ZuOx 4EdA1i8I0uBP4MtNc5ruVPCaOAZaJSwqGF5eKVmQ4wlnFs48yeTke8jLK050OUQtC+IQ IDoPRCg1/CWBOTxJkM3AqIDLOGD197orkcUTsRbt2kFrDq0uXge+e07HRwDOep5ujnkT StIXJk1NWqtwnYyFHaPWJOdkIq+EbhL1XbFmLywAcZK8CQpYIBLm2exdPoEJyY6OKM52 HXTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746659693; x=1747264493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hmVgZ2T/BR9KDwjoUJTnrLXEqdGiV/GeYJSs5v9aKiI=; b=Twkk7ntKYAlVpIhFO2gZKwEQXd1/9jy/A+S85jD1TVwokOd+ten7owqLmJLg82VNzZ w9J36bG062ZKx2IrDJuZ6cSnYa8sndQV0Bn0LpbtVkmis5tzssc1lwIRw/fqDozy2/x/ vmqv4PlEaNzsDohqZuqmXUG1IFrF+YqX3UrlznDuSXS5Pleg4TKTHHf8BHc9uiujUXkD OonuManvNe/JBmRAmpBuhqfjnCWI/T8mXz57YIwFl5umIqa/NCMLBttIU49vIk6nQEcO eQZgjUsvlsl/cd81tffe7Q504X4a8CjiFsAwcCLxG+f81mpWqqivwv23aKaNZT6PFUKs wdLA== X-Gm-Message-State: AOJu0YzrcGuEOaph/iKaiFuBJvBEQ2Nl94HXOldcNa85mbBsoZNSaUpw +WXAn2/8z14VrSqO+5+e/xDgP304WtjECxchd1buZK75LVtewtVTbXSFI4kBqcH5PjG+vQ61jKr dFhgzDA== X-Gm-Gg: ASbGncvsKtDX3Im4U+txRNlOrIga5/oLZt6VQh0Gk1XUZqCxoUvNM43CZV9t+7E2cdB j1w0Y/vD3hy8q8T5qULz0TS39qmb+0WV7I3OPIVqGAFdhIV7nLRNmuukZLi1TL4GmrGYySAZ7Ps kPFDdVHkPpyFN5EePVNFBTZi8fP4O5obPTtGBE2tzeBsplwud5hDG4QzGipFxhYxV4pPskms2Lg IaNK5L7D8fMEK58jJbOzLReXDyn95XsXvJhjBWqGVro9aCPCzCFma5t1I6eadb3Zp9SxUcKy4Q/ Q80HKLuBXsWSquVXVHORu8IbK7qbOFW8iF4+IscnKPc2bJtjmtc= X-Received: by 2002:a17:903:22cd:b0:224:26fd:82e5 with SMTP id d9443c01a7336-22e5ee1d5a3mr77165335ad.48.1746659693218; Wed, 07 May 2025 16:14:53 -0700 (PDT) Received: from pc.. ([38.41.223.211]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22e421a7dafsm40103205ad.69.2025.05.07.16.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 16:14:52 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , alex.bennee@linaro.org, stefanha@redhat.com, peter.maydell@linaro.org, Markus Armbruster , richard.henderson@linaro.org, pbonzini@redhat.com, jsnow@redhat.com, philmd@linaro.org, berrange@redhat.com, thuth@redhat.com, Michael Roth Subject: [PATCH 02/13] qapi/introspect: generate schema as a QObject directly Date: Wed, 7 May 2025 16:14:32 -0700 Message-ID: <20250507231442.879619-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250507231442.879619-1-pierrick.bouvier@linaro.org> References: <20250507231442.879619-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pg1-x533.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Instead of defining a const QLitObject, we implement a function to directly return the QObject associated. The benefit is that we can now have a non static definition for the QLitObject, and so we can assign it using non static initializer. This will be used in next commits to initialize a .hidden field per element, at runtime. Signed-off-by: Pierrick Bouvier --- monitor/qmp-cmds-control.c | 2 +- tests/unit/test-qobject-input-visitor.c | 6 +++--- scripts/qapi/introspect.py | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/monitor/qmp-cmds-control.c b/monitor/qmp-cmds-control.c index 150ca9f5cb6..1d52d4ca8e9 100644 --- a/monitor/qmp-cmds-control.c +++ b/monitor/qmp-cmds-control.c @@ -203,7 +203,7 @@ static SchemaInfoList *zap_deprecated(SchemaInfoList *schema) SchemaInfoList *qmp_query_qmp_schema(Error **errp) { - QObject *obj = qobject_from_qlit(&qmp_schema_qlit); + QObject *obj = qmp_schema_qobject(); Visitor *v = qobject_input_visitor_new(obj); SchemaInfoList *schema = NULL; diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobject-input-visitor.c index 84bdcdf702e..5d961325f95 100644 --- a/tests/unit/test-qobject-input-visitor.c +++ b/tests/unit/test-qobject-input-visitor.c @@ -1184,10 +1184,10 @@ static void test_visitor_in_fail_alternate(TestInputVisitorData *data, } static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data, - const QLitObject *qlit) + QObject *qlit) { g_autoptr(SchemaInfoList) schema = NULL; - QObject *obj = qobject_from_qlit(qlit); + QObject *obj = qlit; Visitor *v; v = qobject_input_visitor_new(obj); @@ -1202,7 +1202,7 @@ static void do_test_visitor_in_qmp_introspect(TestInputVisitorData *data, static void test_visitor_in_qmp_introspect(TestInputVisitorData *data, const void *unused) { - do_test_visitor_in_qmp_introspect(data, &test_qmp_schema_qlit); + do_test_visitor_in_qmp_introspect(data, test_qmp_schema_qobject()); } int main(int argc, char **argv) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 89ee5d5f176..e0269bef0ce 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -193,15 +193,18 @@ def visit_end(self) -> None: for typ in self._used_types: typ.visit(self) # generate C - name = c_name(self._prefix, protect=False) + 'qmp_schema_qlit' + name = c_name(self._prefix, protect=False) + 'qmp_schema_qobject' self._genh.add(mcgen(''' #include "qobject/qlit.h" -extern const QLitObject %(c_name)s; +QObject *%(c_name)s(void); ''', c_name=c_name(name))) self._genc.add(mcgen(''' -const QLitObject %(c_name)s = %(c_string)s; +QObject *%(c_name)s(void) { + const QLitObject res = %(c_string)s; + return qobject_from_qlit(&res); +} ''', c_name=c_name(name), c_string=_tree_to_qlit(self._trees)))