From mboxrd@z Thu Jan 1 00:00:00 1970 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 27FE8C43458 for ; Fri, 10 Jul 2026 07:06:42 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wi5JR-0001cd-2S; Fri, 10 Jul 2026 03:06:17 -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 1wi5JP-0001c1-LF for qemu-arm@nongnu.org; Fri, 10 Jul 2026 03:06:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wi5JN-0002n1-Gb for qemu-arm@nongnu.org; Fri, 10 Jul 2026 03:06:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1783667172; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BA3zZUPyelCMWKs4FcfDK0ObJLwr6OM7SdxtcjefBws=; b=Ge284WmExa0FbzGr1UkwjJTyWhDht2sdofga2rdCuGx3By8plHoc4KEcta78K/vT+xjHET FuBD8PD7HT4I4zj035eIwIny1j7eNTAurEEV0IX4tN0jZJH+kb6scdjtKy9wKMTTH0pEDF sMTx3k8QPQAAuIRzaBMnVh9ef9lcQMU= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-616-6nRvkKPhNkCrIGKJnm5cjA-1; Fri, 10 Jul 2026 03:06:06 -0400 X-MC-Unique: 6nRvkKPhNkCrIGKJnm5cjA-1 X-Mimecast-MFC-AGG-ID: 6nRvkKPhNkCrIGKJnm5cjA_1783667161 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 887111955D5E; Fri, 10 Jul 2026 07:05:59 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.44.22.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3723E180029C; Fri, 10 Jul 2026 07:05:56 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C233521E6920; Fri, 10 Jul 2026 09:05:53 +0200 (CEST) From: Markus Armbruster To: BALATON Zoltan Cc: qemu-devel@nongnu.org, Aditya Gupta , Alexander Graf , Alexandre Iooss , Alexey Kardashevskiy , Alistair Francis , Alistair Francis , Antony Pavlov , Artyom Tarasenko , Bernhard Beschow , Bibo Mao , Brian Cain , Chao Liu , Christian Borntraeger , =?utf-8?Q?Cl=C3=A9ment?= Chigot , =?utf-8?Q?C=C3=A9dric?= Le Goater , Dorjoy Chowdhury , "Edgar E. Iglesias" , Eric Farman , Farhan Ali , Felipe Balbi , Francisco Iglesias , Frederic Konrad , Gaurav Sharma , Gautam Gala , Glenn Miles , Halil Pasic , Hao Wu , Harsh Prateek Bora , Helge Deller , Hendrik Brueckner , =?utf-8?Q?Herv=C3=A9?= Poussineau , Huacai Chen , Jan Kiszka , Jared Rossi , Joel Stanley , Laurent Vivier , Manos Pitsidianakis , Mark Cave-Ayland , Matthew Rosato , Max Filippov , Michael Rolnik , "Michael S. Tsirkin" , Nicholas Piggin , Niek Linnenbank , Palmer Dabbelt , Paolo Bonzini , Peter Maydell , Philippe =?utf-8?Q?Mathieu-Daud?= =?utf-8?Q?=C3=A9?= , Pierrick Bouvier , Ran Wang , Richard Henderson , Sai Pavan Boddu , Samuel Tardieu , Sergio Lopez , Song Gao <17746591750@163.com>, Stafford Horne , Subbaraya Sundeep , Thomas Huth , Tyrone Ting , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Subject: Re: Call to clean up QOM onboard devices lacking a parent In-Reply-To: <17c7f91b-8935-8ebf-a982-f91df755af81@eik.bme.hu> (BALATON Zoltan's message of "Thu, 9 Jul 2026 18:02:58 +0200 (CEST)") References: <87se5scipx.fsf@pond.sub.org> <17c7f91b-8935-8ebf-a982-f91df755af81@eik.bme.hu> Date: Fri, 10 Jul 2026 09:05:53 +0200 Message-ID: <87a4rzxr1q.fsf@pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-MFC-PROC-ID: fiQzSmXyM72FYYpqx_Q8DCKggAH45ootYXomIJcCRHk_1783667161 X-Mimecast-Originator: redhat.com Content-Type: text/plain Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 BALATON Zoltan writes: > On Thu, 9 Jul 2026, Markus Armbruster wrote: >> A QOM object must be the child of exactly one parent. This defines the >> QOM composition tree. The link from parent to child is a property of >> the parent, and therefore has a name that is unique within its parent. >> An object's canonical QOM path is these names on the path from root to >> object in the QOM composition tree separated by '/'. >> >> For devices: >> >> * If a device is plugged in with -device / device_add, and it has an ID, >> we make it a child of /machine/peripheral/ with name ID. If it >> doesn't have an ID, we make it a child of /machine/peripheral-anon/ >> with name device[N], where N counts up from zero. The canonical QOM >> path /machine/peripheral/ID is stable. The canonical QOM path >> /machine/peripheral-anon/device[N] isn't: it depends on the number of >> devices already there. >> >> * If a device is part of another device, it should be its child. The >> child's canonical QOM path is the parent's plus '/CHILD-NAME'. Stable >> as long as the parent's path and the child name are. >> >> * "Should" because we have a lot of code that fails to pick the parent. >> When such a device gets realized, we make it a child of >> /machine/unattached/ orphanage with name device[N], where N counts up >> from zero. The canonical QOM path /machine/unattached/device[N] >> depends on the number of children already in the orphanage, which >> makes it unstable. >> >> Letting code get away with not picking a parent was a mistake. I >> guess it "saved" us some thinking about what's part of what when >> converting existing devices to QOM. In other words, it enabled sloppy >> hardware modeling. We've been "saving" thinking ever since. >> >> I want /machine/unattached/ to be empty. If an onboard device isn't >> part of another device, put it into /machine/ with a sensible name. > > The last time this came up I've asked a few questions but did not get an answer: > > 1. What's the use of the QOM composition tree? I never needed it and apart from being able to admire it in info qom-tree I don't know if it's used for anything. For a long time I did not even know about info qom-tree because I only needed info qtree and info mtree and rarely if ever need to look at the qom-tree. If it has no real use I'm happy to not think about it. > > 2. What is a QOM parent? There were proposals to parent devices to their bus if they have any, that's what qtree shows anyway. If it's something else it should be better defined somewhere. > > Without getting answers for these questions I don't think I'm able to fix the machines I maintain. Unfortunately, I don't have the time to teach a class on QOM basics today. The text you quoted explains what QOM parent and canonical QOM path are, albeit briefly. It also explains how to pick the QOM parent properly, what happens when you neglect to pick one, and why that's undesirable. I'm going to elaborate a bit. A fully constructed QOM object is part of the QOM composition tree. This is a fundamental property of QOM's design. A QOM object can be composed of sub-objects. Its sub-objects are its children in the composition tree. That's why it's named *composition* tree. Canonical QOM paths are visible at external interfaces both as input and as output. A few quick examples: * QMP command query-cpus-fast reports a CPU's canonical QOM path. For some machines, we get something like "/machine/unattached/device[0]". Fine as long as the client treats it as an opaque handle. For other machines, we get something like "/machine/soc/cpu", which is clearly better. * Error messages use canonical QOM paths to identify devices. With properly modeled hardware, these paths are actually helpful for humans. Something like "/machine/unattached/device[7]" not so much. * QMP command device-sync-config accepts a QOM path argument. With properly modeled hardware, you can use a stable canonical QOM path. But when the device is in the /machine/unattached orphanage, its canonical QOM path is unstable. A client has to first search the orphanage to find today's path. Further questions?