Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44A6BCA9ED5 for ; Mon, 12 Oct 2026 07:12:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xGACO-0001Zb-Fs; Mon, 12 Oct 2026 03:11:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGACL-0001YS-Tn for qemu-arm@nongnu.org; Mon, 12 Oct 2026 03:11:50 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xGACJ-0000Y6-AP for qemu-arm@nongnu.org; Mon, 12 Oct 2026 03:11:49 -0400 Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69C55gpX750872 for ; Mon, 12 Oct 2026 07:11:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= 5l10d9x9fvzddju+W7LPcPBGIAylYTIZpW+rF3OMxmQ=; b=jFPBY1HjFeJhH2g7 d+vFst+ew6b3Tc1lfp5VyTfA1MBeorwUiQNo9Bb/JngQU+ess9TMF942CuGvidIG RkzUbvAUQ8eNqBUEluGZ7KBS0RpvlaW2ULfsxg9B3yG5EshoNwJZ32eiBZzVd6Pv 8amEUHWwD0U6ZjeVMd1i456g3aJ2EkvG+PNSnxu/4yuJBYLvRbgrjSUF7LzcD/HD dRc2LKkqzbnrNSeqRCTC/8FIiZuod5gDbe5yloRZrnihrKRW8/gr9a3uZ5CtDUw3 T8L44wAnW2pLnxnjiaYSIFaFYPe5Me5peoeF2MRiLkQkqmAbCEnnJnFG1xszMNHo D0LXbg== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4h7e4ed63d-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 12 Oct 2026 07:11:45 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-3a6d30f66c9so2264795a91.0 for ; Mon, 12 Oct 2026 00:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1791789104; x=1792393904; darn=nongnu.org; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to:content-type; bh=5l10d9x9fvzddju+W7LPcPBGIAylYTIZpW+rF3OMxmQ=; b=I1ZPqGrArViqeJdIbo53Y28nAnRXlTRxteguN/M4r42hs4Kmh+Aawl6hyOsra5LPhh wvo5OiwxY43FiXEg3Of9q5tki/G6X5T1Q483d1rCerGJqGw8rc/zICZes2+Etm5hra+F 7O99Fu8cMEjR8/Ucx2ziiBNrHk6vmbQgavTqxYBtezfYGyLv+XrUH/MSE+ppwf4SrxaF tP+8YIzuhq3aZr9S7/nZviK3D5ufOtDRlGuBYcfgfLUqbefembYNuKe38gz09jFD7ieq /SXg2uVb8a4U/PxY9+gTh9T34ZbfrOb9UYi7SJCA69xMiY2v9/nuBwK5skq7PU/971lx Fyew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791789104; x=1792393904; h=content-transfer-encoding:content-type:in-reply-to:content-language :from:references:cc:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5l10d9x9fvzddju+W7LPcPBGIAylYTIZpW+rF3OMxmQ=; b=vTY8Dcb7y2mfROsTnsfG+FxF3sK/OaOsasSjBjbrXumnFjyHUOwWqDVpIt5NQVfrUJ bhTfBPM/lpydtzmaYnNiZkkaD8VLZN56SOiCJS5Mo6x6JLnMsaQ0zmzS5lJpscxtc+pE YMrxMx/nVcISBODRXXbm1jhW74Q1BrQiB4mkTWHT5/rSwIZjiuLjKTH3sxdnQ5MXlWpp 6oXHZDHzY3w19a8GNq+OCjG1TofPmUSZpgF9k47z9puk3xFAv4wZ/q7P3o6+R/ccTX6g r3ExRvAaGYKCz9kEclAnAipsKNIb1RYiwuqwhoMmWVv1WZGlVJoGB6L0qQoJlI+MmYCK CgFA== X-Forwarded-Encrypted: i=1; AKwUvBzWhkM7/4Vwxy+F2hi6IY9Pw5+fzLGpqX4RJa+lm5FXZO1xckm+3PeTeSFuCmXDr5zzdWIHqQz8UQ==@nongnu.org X-Gm-Message-State: AFq9FYLJgt0hHvolWBVwNgDoUNN5IVq4r+wV0SQYrYh4rzdP17gEmCNL TzFdZEgu9qIQ6s9uXlgziMWItPlCQ7LnKmtqUpanXoxeDnecupiRv+Q4kmmNveRgrhYm54VF56w PoiDv+S0JVl8MWdtvS5y0lyBKWD6RbG2h3OxL5Qv7fnJP1up4ZeBywH8= X-Gm-Gg: AYBFou1/16Iu35PysP4kx4l/KF3bhP3wB9phd3TMxHvTT7djvRcUDt4cAz+QsNTqclj 7VdafRUuLnSqgeRWcV2Wnpx3Ia5AoIzcFkCQlpHp7WCaGL0Kb+sQCYMSat0AiXyKGfSTDiLT44A 7HeidVxoUoKA2ijOYruYwa2PJnohq6JEhcDBlpLCzSMIIHUsbKj6TrQFxVudrfo+/9H3FLb7j2Y 3tsx1E+FYnXmlFSjGesvgzZU1e588loUJgs7XROdww/VBj5U22NUHGN7PiN34Jfc+Mc7vzky7vV iaMF2PTqUfDlBqslgbY8A2kNpn+yFFmqIAea9yeBT/6KeTzN41F6Ciymt8gzk0efZmgntWxbZfa sINKskvev3BhPWAGYqc+IWEO2ftU/SxgGZ3uPk1ye7Flfnq2nU28ROy1P X-Received: by 2002:a17:90a:d44d:b0:3a2:bb9f:f87d with SMTP id 98e67ed59e1d1-3ab3a9f2d87mr5014185a91.21.1791789104271; Mon, 12 Oct 2026 00:11:44 -0700 (PDT) X-Received: by 2002:a17:90a:d44d:b0:3a2:bb9f:f87d with SMTP id 98e67ed59e1d1-3ab3a9f2d87mr5014152a91.21.1791789103638; Mon, 12 Oct 2026 00:11:43 -0700 (PDT) Received: from [192.168.1.169] (192-80-163-190.dyn.novuscom.net. [192.80.163.190]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ac05cac83bsm2658825a91.10.2026.10.12.00.11.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Oct 2026 00:11:43 -0700 (PDT) Message-ID: Date: Mon, 12 Oct 2026 00:11:41 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/8] qom: pass TargetInfo to the is_available callback To: luoyonggang@gmail.com Cc: =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , qemu-devel@nongnu.org, Cleber Rosa , Stefan Hajnoczi , =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Laurent Vivier , Zhao Liu , John Snow , Laurent Vivier , Richard Henderson , Joel Stanley , Fabiano Rosas , Kane Chen , Andrew Jeffery , Troy Lee , Jamin Lin , Stafford Horne , qemu-arm@nongnu.org, Philippe Mathieu-Daude , Peter Maydell , Paolo Bonzini , =?UTF-8?Q?Philippe_Mathieu-Daud=C3=A9?= , =?UTF-8?Q?Marc-Andr=C3=A9_Lureau?= , Steven Lee , Alexander Bulekov , Darren Kenny References: <20261007115253.328-1-luoyonggang@gmail.com> <2390b3d7-6918-41e3-8532-c19de4cdd1ff@oss.qualcomm.com> <42fd67c0-c20d-4bc4-bede-79073e4be4a1@oss.qualcomm.com> <3034c146-0697-4db7-acd4-8076b317a09e@oss.qualcomm.com> <8cb24445-b659-4bd4-9497-888ce152e82d@oss.qualcomm.com> <1a477877-516a-41b8-8548-598bfad74f25@oss.qualcomm.com> From: Pierrick Bouvier Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDEyMDAyOCBTYWx0ZWRfX/b0oNYkh4+Cv Bgrg+8FopUDg+xhYL8CeQEqLG/b+FNwtASWMgrw2UIORjMvhC5L2QXCpE79+Gi6TrVqgtUH6R4w QpILwjl9XMLm1yeBNYZpE198u+nmJb/fSQuXoKSNEusFrSDzpBMAgoe1oeHcWfWVExvV4aOurtT /cvQ93HJl9FEUN5vGIP0BatIs84wYUT9+HIsltheSBzWt64H8cRA/GdWXZUQNR3YfwU+49VvbKF 6RBh4iRGlIMZaFHQJ0MfNAigsr34n0FNaOlaeLFscl4uOvgH4hJkvB9YMpGdpikxf3o/2p9x3YP lB0WiF++6wphffiUNEbhCc76nd8wq+XY3iTasTxn++n2YXK0Zu345ZIr7LKbuprRpAPfWiipHRJ 8MsgKXkKWx8xtPe08KFvdNQht5lNLQljQ7e5PEMKYm4SMqUw0SuXWLpEwvW+htiLUXykBxSuI++ 9xl0OrLj9er3khmV+gw== X-Proofpoint-ORIG-GUID: JsPRITah63yE_eKSlybe71YhDVaVvIXq X-Proofpoint-GUID: JsPRITah63yE_eKSlybe71YhDVaVvIXq X-Authority-Analysis: v=2.4 cv=W5utxhWk c=1 sm=1 tr=0 ts=6acc8831 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=9852oil1ID9t5xBSyQ/BEA==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=VwQbUJbxAAAA:8 a=20KFwNOVAAAA:8 a=EUspDBNiAAAA:8 a=XeT34wHY2xQq_wk8a9EA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDEyMDAyOCBTYWx0ZWRfXzcGWZFir72OU AeUbPXeAtjvf2pJBRJi+aTBs+vACT6IACpXx06rokwQ2+m2lJkk7hJSj8Bc44MRrlCDvCr3oYuB KYjNPXXDkjzCnY2RpWvONXf48r394EU= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-10-12_02,2026-10-09_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 phishscore=0 malwarescore=0 impostorscore=0 bulkscore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610080000 definitions=main-2610120028 Received-SPF: pass client-ip=205.220.168.131; envelope-from=pierrick.bouvier@oss.qualcomm.com; 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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@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-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org On 10/11/26 9:26 PM, Yonggang Luo wrote: > On Mon, Oct 12, 2026 at 10:25 AM Pierrick Bouvier > wrote: >> >> On 10/11/26 7:13 PM, Pierrick Bouvier wrote: >>> On 10/11/26 1:22 PM, Yonggang Luo wrote: >>>> On Fri, Oct 9, 2026 at 2:34 AM Pierrick Bouvier >>>> wrote: >>>>> >>>>> On 10/8/2026 10:13 AM, Yonggang Luo wrote: >>>>>> On Fri, Oct 9, 2026 at 12:06 AM Pierrick Bouvier >>>>>> wrote: >>>>>>> >>>>>>> On 10/8/2026 2:46 AM, Yonggang Luo wrote: >>>>>>>> On Thu, Oct 8, 2026 at 5:42 PM Daniel P. Berrangé wrote: >>>>>>>>> >>>>>>>>> On Wed, Oct 07, 2026 at 01:25:46PM -0700, Pierrick Bouvier wrote: >>>>>>>>>> On 10/7/2026 4:47 AM, Yonggang Luo wrote: >>>>>>>>>>> This allows a combined binary to register machine types from all its targets. >>>>>>>>>>> Consequently, QMP `query-machines` can return machine entries from every >>>>>>>>>>> target, even when `none` is selected. For example, a client can query the >>>>>>>>>>> combined machine list with: >>>>>>>>>>> >>>>>>>>>>> ```json >>>>>>>>>>> { "execute": "query-machines" } >>>>>>>>>>> ``` >>>>>>>>>>> >>>>>>>>>>> The returned list includes the registered machine classes from all linked >>>>>>>>>>> targets. This is separate from selecting a machine: with `-target none`, >>>>>>>>>>> `-M virt` reports the targets that provide `virt` instead of choosing one >>>>>>>>>>> arbitrarily: >>>>>>>>>>> >>>>>>>>>>> ```text >>>>>>>>>>> qemu-system -target none -M virt >>>>>>>>>>> unsupported machine type: "virt" for target "none" >>>>>>>>>>> Available for targets: >>>>>>>>>>> aarch64 >>>>>>>>>>> arm >>>>>>>>>>> ``` >>>>>>>>>>> >>>>>>>>>> >>>>>>>>>> From the long conversation on a previous thread, I thought we reached >>>>>>>>>> the conclusion that if we didn't expose any ambiguous name, then -target >>>>>>>>>> option is unnecessary, or maybe I got lost on track of this thread. >>>>>>>>>> >>>>>>>>>> https://lore.kernel.org/qemu-devel/ar_coT44h5-zJPVV@redhat.com/ >>>>>>>>>> >>>>>>>>>> I'm not sure which semantic we want to have with -target none. If there >>>>>>>>>> is no ambiguous name registered, we just don't need it at all. It's a >>>>>>>>>> win-win IMHO. >>>>>>>>> >>>>>>>>> Yes, if we expose unique names for every machine, then -target is then >>>>>>>>> redundant. >>>>>>>> >>>>>>>> so how to diff riscv32-virt and risv64-virt? oh so for this machine we >>>>>>>> needs two name? >>>>>>>> "virt" needs register twice for it? or register only a single time, >>>>>>>> but we prefix the target_name() >>>>>>>> automatically? for example machine::name === "virt", but we can use >>>>>>>> "riscv32-virt" "risv64-virt" to reach it? >>>>>>>> >>>>>>> >>>>>>> Yes, ideally we should have different variant of virt for 32/64 bit. >>>>>>> Same goes for cpu max types. >>>>>>> >>>>>>> QOM type is always registered unambiguously ("$arch-virt"). Then, for >>>>>>> the "alias" name, which is virt, in case multiple matches are found, >>>>>>> command line can return an error with list of unambiguous names to call it. >>>>>>> >>>>>>> $ qemu-system -M virt >>>>>>> Multiple virt machines are available. Please choose one of them: >>>>>>> - aarch64-virt >>>>>>> - riscv64-virt >>>>>>> >>>>>>> There is no "parsing" of the argument, it's just the real QOM type. Then >>>>>>> we can find which target it implements from mc->targets. >>>>>>> And then, we can automatically choose which cpus should be available >>>>>>> based on that, thanks to cpu->targets. >>>>>>> >>>>>>> For existing binaries, nothing change. >>>>>> >>>>>> Good, I think we found a clean way now, is_available should be >>>>>> removed, and TypeInfo::targets and TypeImpl::targets should be added. >>>>> >>>>> It goes into MachineClass only for now. >>>>> >>>>>> I think >>>>>> for "virt" we can add a shared hw/machine-virt.c instead, and forwarding to >>>>>> the $arch specific virt. so that we only have a single "virt" registered. >>>>>> And it's >>>>>> targets is >>>>>> QEMU_ARCH_I386 | >>>>>> QEMU_ARCH_ARM | >>>>>> QEMU_ARCH_RISCV | >>>>>> QEMU_ARCH_LOONGARCH | >>>>>> QEMU_ARCH_M68K | >>>>>> QEMU_ARCH_OR1K | >>>>>> QEMU_ARCH_XTENSA | >>>>>> QEMU_ARCH_HEXAGON >>>>>> >>>>>> So that we won't have a list of conflict QOM names for "virt" machines. >>>>>> As now we indeed have only a single "virt" machine that redirects to >>>>>> different targets. >>>>>> >>>>> >>>>> The idea looks appealing, but I don't think it solves the problem to >>>>> have multiple virt variants available at the same time. >>>>> >>>>> The "alias" idea you introduced before is good, we just need to add a >>>>> check if an alias is really unique, else return an error, as explained >>>>> previously. >>>>> >>>>> If "-M aarch64-virt" works for both the new and existing binary, and -M >>>>> virt only for existing binaries (and ambiguous for new one), I think >>>>> that's a safe approach. >>>>> >>>>>> >>>>>> For other types also conflict can be handled in the same way, such as >>>>>> "-cpu host" "-cpu max" >>>>>> maybe others, but I think they all have the same way to deal with. >>>>>> >>>>>> >>>>>> That's why TypeInfo::targets and TypeImpl::targets better than sole >>>>>> Machine::targets >>>>>> >>>>> >>>>> One step at a time. >>>>> Let's keep focused on declaring targets for a single machine first. >>>>> Then we can iterate to solve the "virt" problem. >>>>> Then convert all the existing machines and add a check in machine-target.c >>>>> Then, and only then, we can see what happens with cpus. >>>> >>>> I tried this idea, but I faced a fatal error, because the >>>> target_info() is not available until >>>> the machine selected(the target arch will be select just along with >>>> the machine selected), so basically >>>> all calls to target_info() would raise an error(null pointer), how to >>>> deal with it? >>>> >>> >>> I see. Indeed, since we can't set a target before registering all types, >>> it implies that all the types class_init can't use target_* functions. >>> >>> >>> - register_accel_target_type >>> - cpu_max_v8_register_type >>> >> >> Sorry, mail sent to early. >> >> For the is_available callback usage, it should be easy to do the switch, >> since it's basically the same information that what we are trying to do >> - we can leave them for now. >> >> Some types (like accel and max mentioned above), explicitly change their >> definition depending on the target. It's a behavior we can't rely on >> anymore, and it means we need proper distinct types instead of a single >> one with dynamic definition driven by target-info. >> >> I think that's the preliminary work needed, before being able to go >> further: convert all existing usage in class_init with distinct types + >> is_available, and then we can do the switch from is_available to the new >> .targets approach. > > Hi Pierrick, > I have already tried that introducing new QOM names just to make class_init > target-independent is too broad(means all usage of it should be handled) > and could complicate compatibility(changed too much code). > Can we avoid new names by some new means(ideas welcome)? > We can use is_available as an intermediate step. The good thing is that removing target_* from class_init can be done as much incrementally as we want: there is no need to do all the changes at once. Once we get to the point where there is no target_* in class_init and all types are properly defined with is_available filters, we can see how to deal with the duplication. My point of view after our discussions is that we should keep current name for existing binaries, and should be free to force user to deal with ambiguity with new single-binary (machine type "X" is ambiguous, please choose among arch-X, arch-Y, ...). > >> >> It's probably worth having the conversion in its own series (only >> cleanup usage of target_* in class_init), before trying to get rid of >> is_available. > >> >> For the implementation, you can use the multi-targets.c binary test to >> drive the change. Remove the module init for target info (leaving no >> target set), and add a hacky patch to skip call to is_available (and >> return true instead) and allow double definition (which will rely on >> is_available). Then, fix all the segfault. Once it compiles and runs, >> only double definition will be left, which can be handled by inserting >> the right is_available callbacks. Then in a subsequent series, the >> switch to .targets can be made. > > > Still have no clean clue about how to remove is_available , as we have many > "virt" machines. Do you means all "virt" machines with "virt-machine" QOM names > are inserted to the table? How to get it working because the "key" is string. > The alias series you posted initially was good, with the addition to detect when multiple machines have the same alias (and report an error in this case). I triggered the conversation we are having now because things have not been defined properly, and the direction to have -target + arch:machine was not really satisfactory. Now we settled on excluding -target, and embedding all types, I think it's clearer. > >> >> It's a work we'll need to do for heterogeneous anyway, I was just hoping >> to delay that until there, but seems we need to deal with it now. >> A good thing is that it means target-info won't have to be registered >> before all QOM types anymore, so it's worth the effort IMHO. >> >> Thanks, >> Pierrick > > >