{"id":2231556,"url":"http://patchwork.ozlabs.org/api/patches/2231556/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430203842.29156-6-pierrick.bouvier@oss.qualcomm.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260430203842.29156-6-pierrick.bouvier@oss.qualcomm.com>","list_archive_url":null,"date":"2026-04-30T20:38:39","name":"[v3,5/8] target-info: introduce TargetInfo in QOM","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1edb0c90d68e4068150025430b3d7d1fc33ac8c8","submitter":{"id":93152,"url":"http://patchwork.ozlabs.org/api/people/93152/?format=json","name":"Pierrick Bouvier","email":"pierrick.bouvier@oss.qualcomm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260430203842.29156-6-pierrick.bouvier@oss.qualcomm.com/mbox/","series":[{"id":502380,"url":"http://patchwork.ozlabs.org/api/series/502380/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=502380","date":"2026-04-30T20:38:36","name":"single-binary: deduplicate target_info()","version":3,"mbox":"http://patchwork.ozlabs.org/series/502380/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2231556/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2231556/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=FmsCf6ix;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=Hd/6cy6y;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g65d33mMRz1yHZ\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 01 May 2026 06:39:35 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wIYA8-0002ud-8Q; Thu, 30 Apr 2026 16:39:08 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pierrick.bouvier@oss.qualcomm.com>)\n id 1wIYA1-0002nB-FW\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 16:39:02 -0400","from mx0a-0031df01.pphosted.com ([205.220.168.131])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pierrick.bouvier@oss.qualcomm.com>)\n id 1wIY9x-0000u5-Dt\n for qemu-devel@nongnu.org; Thu, 30 Apr 2026 16:39:00 -0400","from pps.filterd (m0279863.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 63UKIDvp1854109\n for <qemu-devel@nongnu.org>; Thu, 30 Apr 2026 20:38:55 GMT","from mail-dy1-f198.google.com (mail-dy1-f198.google.com\n [74.125.82.198])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dve0g01ww-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <qemu-devel@nongnu.org>; Thu, 30 Apr 2026 20:38:55 +0000 (GMT)","by mail-dy1-f198.google.com with SMTP id\n 5a478bee46e88-2cc75e79b97so4724770eec.1\n for <qemu-devel@nongnu.org>; Thu, 30 Apr 2026 13:38:55 -0700 (PDT)","from hu-pbouvier-lv.qualcomm.com (Global_NAT1.qualcomm.com.\n [129.46.96.20]) by smtp.gmail.com with ESMTPSA id\n 5a478bee46e88-2ee3889d628sm2202341eec.6.2026.04.30.13.38.53\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 30 Apr 2026 13:38:53 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:date:from:in-reply-to:message-id\n :mime-version:references:subject:to; s=qcppdkim1; bh=kdYb4dp22kf\n FuJHASL+X2gyJ+4ROfhuXXuPO3RoA9Zc=; b=FmsCf6ixyVtWfqLjCPR+oGwIVkv\n dhb4fFgmacULvCKbhofb04OtuRZ+UXXKUUP1+Qb6iNawwTdL8HYZG9t8vHbIg0nq\n 3SId9gtJ/3AFwXfb8xw0Oh0FD7hZcbzYM4+rd9yJlIXSgyTZJL0jeD5yygmYB4uY\n gb8YJl3batf9a4fKKy4P+FbRUBi+MLAttmnHQfBjw/1e8mBODtW0DdqMvtsYjLwa\n w14cGtEKSzj7C2YnHdz+ygFmZl3nGEjXCndchVsAOcRBx2HR7Z8SYnerBKwrRZyv\n ojXwNJtYfwWND90jrhPJ0SNeAopSKeIqZwXG4Pa0XKRtT1hdiXG15AfcU3Q==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1777581535; x=1778186335; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=kdYb4dp22kfFuJHASL+X2gyJ+4ROfhuXXuPO3RoA9Zc=;\n b=Hd/6cy6yMyDeBpWhjLVZb9RUUuwgYgIy5e2nMmGAfMVMRv8NeDjn1ceH5x/Y4C2js9\n bWzjDRy5AApPnHV6OAZRCiq3WA3NXkiEma0I2fUbLrkktQ3ua0kCXmT84fk3WG1Cz9th\n /yY4lrr36kYANdiKTX8fXu2gGVX6zGKs+JQHtwwS1ymBHqPYj4pTLTAkijcR+WN+EiYK\n QWvybjWbuNRr9qQ8Q+6zZ/FueG8NrStaK9Knc6o9AOU2m6uj2m7KRG6sMsT8pyGUOvuO\n 0479LcNuKI91Ta3WTDGicCDcYtOLFUXPfvquD82B39vGz9VVsimOE6a/enAcfs7M0fGz\n 1D2A=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777581535; x=1778186335;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=kdYb4dp22kfFuJHASL+X2gyJ+4ROfhuXXuPO3RoA9Zc=;\n b=hncGwvHylRbBNo4qahTilBryuqjDxIqptI0uReZTyNnuKy9D/OsrrjgeL5oGs8d+24\n 1eqfHC3xnGHEu0e+5TPbvPOU+u17aMT+eaaD0QHSfo79ABGVgHmNs1Xmu5Apa/ldC2hg\n 4tg5QxZH4CKc0aP2omH6yGZJ4O7A6hfs/r78ItmHHKpb0Mw621CYAm2Evzy2VQv05IMe\n uzzA3nZ5KvkT5df66JC/3TMcsvSAH/ULYeR/0EqWkERIL1anRZnz6/oJK87IjUfCH7eA\n +5N8JZ0ai7hELADsBPH9Fygb9Iq9jgtkLYzJrWp9siMv4pDKR0VpDbKiVhN41HERpc8X\n NKoQ==","X-Gm-Message-State":"AOJu0YyqwAr46EuDDQup7OvlIs9O6YE4kH+AbAFQi8AEw3SRie21fKPy\n 5HWULjnJvpSB794vlwRGMl/voFzQb2lU1jsEbrXnTFMYyACNmlxngIlETubKSUgpSGnd3Yg+EGq\n 9/o+ZjirnDIo96UffOo0EqIHc/wNrJH3abOdG0VLrtOOuRu/pJ2iwo/OKsZZkIPndnWak","X-Gm-Gg":"AeBDievjr6mPY/1cd0PTT6if2cQ06UeihH7eDIJlep25E0+WjnoAv/5A58064Du243r\n ngHz56Crvn9n2BEzy6N9f8LAd+QZbed648FMOLrQMxs6Nt8Q1xQouloAEF+bMbjXb0bxHZHUCBg\n 40rXdQ9nUZfFUI3KYQGEWi7vtYxO5teLSUl2X2zMTbff6xI7BABgDvBiO2wYpt2Uuz9n3PQWjOs\n RYs1zoUNvnSFFjWW1nEgXNV74iG3Fsv/aIeL/Z8uXisw1MevVYYZvJtthBAU0YqVReHflk0IFVp\n tn8XLDfanoiGoLC7UqylYYlVKIGY4pZOgrV44G0BjGdEO5NFWYlEaxXI5V/nSyTlwrvG+lkfpi0\n 18wjiRgQbf/PnTl839ksxQInXuww8Mb8sA460173AIcJn03JZwBc4E5NbK29I/wFabGp5vzbe1b\n YsPfX0hV6CT5FxnhBn","X-Received":["by 2002:a05:7300:e827:b0:2ea:5057:a304 with SMTP id\n 5a478bee46e88-2ed3ba12a42mr2501600eec.2.1777581534547;\n Thu, 30 Apr 2026 13:38:54 -0700 (PDT)","by 2002:a05:7300:e827:b0:2ea:5057:a304 with SMTP id\n 5a478bee46e88-2ed3ba12a42mr2501577eec.2.1777581533978;\n Thu, 30 Apr 2026 13:38:53 -0700 (PDT)"],"From":"Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>","To":"qemu-devel@nongnu.org","Cc":"=?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n marcandre.lureau@redhat.com, Markus Armbruster <armbru@redhat.com>,\n Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,\n Paolo Bonzini <pbonzini@redhat.com>, Anton Johansson <anjo@rev.ng>,\n\t=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>,\n Max Filippov <jcmvbkbc@gmail.com>,\n Richard Henderson <richard.henderson@linaro.org>","Subject":"[PATCH v3 5/8] target-info: introduce TargetInfo in QOM","Date":"Thu, 30 Apr 2026 13:38:39 -0700","Message-ID":"<20260430203842.29156-6-pierrick.bouvier@oss.qualcomm.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260430203842.29156-1-pierrick.bouvier@oss.qualcomm.com>","References":"<20260430203842.29156-1-pierrick.bouvier@oss.qualcomm.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Authority-Analysis":"v=2.4 cv=EpHiaycA c=1 sm=1 tr=0 ts=69f3bddf cx=c_pps\n a=wEP8DlPgTf/vqF+yE6f9lg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17\n a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8\n a=ifg725Mek7oY8M_gCSsA:9 a=bBxd6f-gb0O0v-kibOvt:22","X-Proofpoint-GUID":"i475GTnKDvddYBwN1qyxIa0B4dQRCNHt","X-Proofpoint-ORIG-GUID":"i475GTnKDvddYBwN1qyxIa0B4dQRCNHt","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDMwMDIxMyBTYWx0ZWRfX9LYGdDCxNjBA\n edu1QZTJoFw0sQJyDUAsRpnRIRW67m0QMgTOoeOwBPjBxqrHdxjmxRKPUMTljZUoqACuReq1urR\n RVx2vq8gfTdHSxC/rRDdfaYVvgvCBMK2u9PSAT7IaNqXJhT/E5QnT605kP6t/MvGVT7gO3iILnp\n lB92KGu3IxLAOQgpXH2SYQ6EKlunRdqbj6hjCAN1oZMAzqTHAa9GcH4pZX9DjSTlMVlhZ8D90Ww\n a+ChAMDPeDbGRACF+ENuEQUak5f+z89wGWgxxlcmbztuz2Q9PFBseWF7ke5CKiEuNtsnRkCU0rw\n 1Nbf/XzubxDC81oQ61mHECLlgmrcVhmDcuIVkWFhlrECK/3hau2uhSxLxU75vzZt+YQdkutVVQo\n Yo2hzt68mkyE+prszFmA+k4+EZzS6Wvmiy2i5A1HidH2WYcFE3LwB4SSUWt/BejjoHG79+khKyk\n bw+eGDja986yFHJdI3A==","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-30_06,2026-04-30_02,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n malwarescore=0 clxscore=1015 impostorscore=0 bulkscore=0 suspectscore=0\n adultscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0\n classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0\n reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604300213","Received-SPF":"pass client-ip=205.220.168.131;\n envelope-from=pierrick.bouvier@oss.qualcomm.com;\n helo=mx0a-0031df01.pphosted.com","X-Spam_score_int":"-27","X-Spam_score":"-2.8","X-Spam_bar":"--","X-Spam_report":"(-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001,\n 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":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"For the single-binary, we want to be able to retrieve at runtime the\ncurrent target among the different ones available.\nA consequence is that we can't rely on existing target_info() definition\nsince it will create a conflict once more than one target is available.\n\nTo solve this, we add TargetInfo in QOM, with this hierarchy.\nWe define one class \"target-info-X\" per target, that inherits from\nabstract class \"target-info\". Using concrete vs abstract class ensure we\ncan easily filter \"target-info-X\" from all QOM types.\nAssociated TargetInfo is directly set through class initialization,\nwithout relying on any instance.\n\nFor user mode, we simply define target_info() like it was done\npreviously. In this patch, we keep the same definition for system-mode\nalso, and it will be replaced in next commits.\n\nWe will introduce detection of target from QOM, so we need to make sure\nthose types are registered early.\n\nSigned-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>\n---\n include/qemu/target-info-init.h | 57 +++++++++++++++++++++++++++++++++\n include/qemu/target-info-qom.h  | 28 ++++++++++++++++\n target-info-qom.c               | 14 ++++++++\n 3 files changed, 99 insertions(+)\n create mode 100644 include/qemu/target-info-qom.h","diff":"diff --git a/include/qemu/target-info-init.h b/include/qemu/target-info-init.h\nindex c781cfc0590..7e6f5d90ec4 100644\n--- a/include/qemu/target-info-init.h\n+++ b/include/qemu/target-info-init.h\n@@ -12,10 +12,67 @@\n #ifndef TARGET_INFO_DEF_H\n #define TARGET_INFO_DEF_H\n \n+#define DEFINE_TARGET_INFO_TYPE(info)                                       \\\n+static void do_qemu_init_target_info(void)                                  \\\n+{                                                                           \\\n+    type_register_static(&info);                                            \\\n+}                                                                           \\\n+type_init_early(do_qemu_init_target_info)\n+\n+#ifdef COMPILING_PER_TARGET\n+#ifdef CONFIG_USER_ONLY\n+\n+/*\n+ * User mode does not support multiple targets in the same binary, so just\n+ * define target_info().\n+ */\n #define target_info_init(ti_var)        \\\n const TargetInfo *target_info(void)     \\\n {                                       \\\n     return &ti_var;                     \\\n }\n \n+#else /* CONFIG_USER_ONLY */\n+\n+#include \"qemu/target-info-qom.h\"\n+#include \"qom/object.h\"\n+\n+#define TYPE_TARGET_INFO_TARGET TYPE_TARGET_INFO\"-\"TARGET_NAME\n+\n+typedef struct TargetInfoQomTarget {\n+    TargetInfoQom parent;\n+} TargetInfoQomTarget;\n+\n+typedef struct TargetInfoQomTargetClass {\n+    TargetInfoQomClass parent_class;\n+} TargetInfoQomTargetClass;\n+\n+OBJECT_DECLARE_TYPE(TargetInfoQomTarget, TargetInfoQomTargetClass, TARGET_INFO_TARGET)\n+\n+#define target_info_init(ti_var)                                            \\\n+const TargetInfo *target_info(void)                                         \\\n+{                                                                           \\\n+    return &ti_var;                                                         \\\n+}                                                                           \\\n+                                                                            \\\n+static void target_info_qom_class_init(ObjectClass *oc, const void * data)  \\\n+{                                                                           \\\n+    TargetInfoQomTargetClass *klass = TARGET_INFO_TARGET_CLASS(oc);         \\\n+    klass->parent_class.target_info = &ti_var;                              \\\n+}                                                                           \\\n+                                                                            \\\n+static const TypeInfo target_info_qom_target_type_info = {                  \\\n+    .name = TYPE_TARGET_INFO_TARGET,                                        \\\n+    .parent = TYPE_TARGET_INFO,                                             \\\n+    .instance_size = sizeof(TargetInfoQomTarget),                           \\\n+    .class_size = sizeof(TargetInfoQomTargetClass),                         \\\n+    .class_init = target_info_qom_class_init,                               \\\n+    .abstract = false,                                                      \\\n+};                                                                          \\\n+                                                                            \\\n+DEFINE_TARGET_INFO_TYPE(target_info_qom_target_type_info)\n+\n+#endif /* CONFIG_USER_ONLY */\n+#endif /* COMPILING_PER_TARGET */\n+\n #endif /* TARGET_INFO_DEF_H */\ndiff --git a/include/qemu/target-info-qom.h b/include/qemu/target-info-qom.h\nnew file mode 100644\nindex 00000000000..585995c7ad0\n--- /dev/null\n+++ b/include/qemu/target-info-qom.h\n@@ -0,0 +1,28 @@\n+/*\n+ * QEMU target info QOM types\n+ *\n+ * Copyright (c) Qualcomm\n+ *\n+ * SPDX-License-Identifier: GPL-2.0-or-later\n+ */\n+\n+#ifndef QEMU_TARGET_INFO_QOM_H\n+#define QEMU_TARGET_INFO_QOM_H\n+\n+#include \"qemu/target-info-impl.h\"\n+#include \"qom/object.h\"\n+\n+#define TYPE_TARGET_INFO \"target-info\"\n+\n+typedef struct TargetInfoQom {\n+    Object parent_obj;\n+} TargetInfoQom;\n+\n+typedef struct TargetInfoQomClass {\n+    ObjectClass parent_class;\n+    const TargetInfo *target_info;\n+} TargetInfoQomClass;\n+\n+OBJECT_DECLARE_TYPE(TargetInfoQom, TargetInfoQomClass, TARGET_INFO)\n+\n+#endif /* QEMU_TARGET_INFO_QOM_H */\ndiff --git a/target-info-qom.c b/target-info-qom.c\nindex 7fd58d24818..ba2c7923760 100644\n--- a/target-info-qom.c\n+++ b/target-info-qom.c\n@@ -7,7 +7,11 @@\n  */\n \n #include \"qemu/osdep.h\"\n+#include \"qapi/error.h\"\n #include \"qom/object.h\"\n+#include \"qemu/target-info-impl.h\"\n+#include \"qemu/target-info-init.h\"\n+#include \"qemu/target-info-qom.h\"\n #include \"hw/arm/machines-qom.h\"\n \n static const TypeInfo target_info_types[] = {\n@@ -22,3 +26,13 @@ static const TypeInfo target_info_types[] = {\n };\n \n DEFINE_TYPES(target_info_types)\n+\n+static const TypeInfo target_info_parent_type = {\n+    .name = TYPE_TARGET_INFO,\n+    .parent = TYPE_OBJECT,\n+    .instance_size = sizeof(TargetInfoQom),\n+    .class_size = sizeof(TargetInfoQomClass),\n+    .abstract = true,\n+};\n+\n+DEFINE_TARGET_INFO_TYPE(target_info_parent_type)\n","prefixes":["v3","5/8"]}