qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Eduardo Habkost" <eduardo@habkost.net>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	peterx@redhat.com, "Daniel P . Berrangé" <berrange@redhat.com>,
	"Juraj Marcin" <jmarcin@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	qemu-ppc@nongnu.org
Subject: [PATCH 06/12] hw/ppc: Explicitly create the drc container
Date: Wed, 20 Nov 2024 16:56:57 -0500	[thread overview]
Message-ID: <20241120215703.3918445-7-peterx@redhat.com> (raw)
In-Reply-To: <20241120215703.3918445-1-peterx@redhat.com>

QEMU will start to not rely on implicit creations of containers soon.  Make
PPC drc devices follow by explicitly create the container whenever a drc
device is realized, dropping container_get() calls.

No functional change intended.

Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>
Cc: Harsh Prateek Bora <harshpb@linux.ibm.com>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 hw/ppc/spapr_drc.c | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 1484e3209d..3d6ef26b38 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -27,7 +27,7 @@
 #include "sysemu/reset.h"
 #include "trace.h"
 
-#define DRC_CONTAINER_PATH "/dr-connector"
+#define DRC_CONTAINER_PATH "dr-connector"
 #define DRC_INDEX_TYPE_SHIFT 28
 #define DRC_INDEX_ID_MASK ((1ULL << DRC_INDEX_TYPE_SHIFT) - 1)
 
@@ -514,6 +514,26 @@ static const VMStateDescription vmstate_spapr_drc = {
     }
 };
 
+static GOnce drc_container_created = G_ONCE_INIT;
+
+static gpointer drc_container_create(gpointer unused G_GNUC_UNUSED)
+{
+    container_create(object_get_root(), DRC_CONTAINER_PATH);
+    return NULL;
+}
+
+static Object *drc_container_get(void)
+{
+    return object_resolve_path_component(
+        object_get_root(), DRC_CONTAINER_PATH);
+}
+
+/* TODO: create the container in an ppc init function */
+static void drc_container_create_once(void)
+{
+    g_once(&drc_container_created, drc_container_create, NULL);
+}
+
 static void drc_realize(DeviceState *d, Error **errp)
 {
     SpaprDrc *drc = SPAPR_DR_CONNECTOR(d);
@@ -521,6 +541,9 @@ static void drc_realize(DeviceState *d, Error **errp)
     Object *root_container;
     const char *child_name;
 
+    /* Whenever a DRC device is realized, create the container */
+    drc_container_create_once();
+
     trace_spapr_drc_realize(spapr_drc_index(drc));
     /* NOTE: we do this as part of realize/unrealize due to the fact
      * that the guest will communicate with the DRC via RTAS calls
@@ -529,7 +552,7 @@ static void drc_realize(DeviceState *d, Error **errp)
      * inaccessible by the guest, since lookups rely on this path
      * existing in the composition tree
      */
-    root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
+    root_container = drc_container_get();
     child_name = object_get_canonical_path_component(OBJECT(drc));
     trace_spapr_drc_realize_child(spapr_drc_index(drc), child_name);
     object_property_add_alias(root_container, link_name,
@@ -543,12 +566,10 @@ static void drc_unrealize(DeviceState *d)
 {
     SpaprDrc *drc = SPAPR_DR_CONNECTOR(d);
     g_autofree gchar *name = g_strdup_printf("%x", spapr_drc_index(drc));
-    Object *root_container;
 
     trace_spapr_drc_unrealize(spapr_drc_index(drc));
     vmstate_unregister(VMSTATE_IF(drc), &vmstate_spapr_drc, drc);
-    root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
-    object_property_del(root_container, name);
+    object_property_del(drc_container_get(), name);
 }
 
 SpaprDrc *spapr_dr_connector_new(Object *owner, const char *type,
@@ -796,9 +817,8 @@ static const TypeInfo spapr_drc_pmem_info = {
 SpaprDrc *spapr_drc_by_index(uint32_t index)
 {
     Object *obj;
-    g_autofree gchar *name = g_strdup_printf("%s/%x", DRC_CONTAINER_PATH,
-                                             index);
-    obj = object_resolve_path(name, NULL);
+    g_autofree gchar *name = g_strdup_printf("%x", index);
+    obj = object_resolve_path_component(drc_container_get(), name);
 
     return !obj ? NULL : SPAPR_DR_CONNECTOR(obj);
 }
@@ -860,7 +880,7 @@ int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_mask)
     /* aliases for all DRConnector objects will be rooted in QOM
      * composition tree at DRC_CONTAINER_PATH
      */
-    root_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
+    root_container = drc_container_get();
 
     object_property_iter_init(&iter, root_container);
     while ((prop = object_property_iter_next(&iter))) {
@@ -953,7 +973,7 @@ void spapr_drc_reset_all(SpaprMachineState *spapr)
     ObjectProperty *prop;
     ObjectPropertyIterator iter;
 
-    drc_container = container_get(object_get_root(), DRC_CONTAINER_PATH);
+    drc_container = drc_container_get();
 restart:
     object_property_iter_init(&iter, drc_container);
     while ((prop = object_property_iter_next(&iter))) {
-- 
2.45.0



  parent reply	other threads:[~2024-11-20 21:59 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20 21:56 [PATCH 00/12] QOM: container_get() removal Peter Xu
2024-11-20 21:56 ` [PATCH 01/12] qom: Add TYPE_CONTAINER macro Peter Xu
2024-11-21  9:20   ` Philippe Mathieu-Daudé
2024-11-21 10:04   ` Daniel P. Berrangé
2024-11-20 21:56 ` [PATCH 02/12] qom: New container_create() Peter Xu
2024-11-21 10:05   ` Daniel P. Berrangé
2024-11-21 13:20   ` Markus Armbruster
2024-11-21 16:18     ` Peter Xu
2024-11-20 21:56 ` [PATCH 03/12] tests: Fix test-qdev-global-props on anonymous qdev realize() Peter Xu
2024-11-21  9:20   ` Philippe Mathieu-Daudé
2024-11-21 10:16   ` Daniel P. Berrangé
2024-11-20 21:56 ` [PATCH 04/12] tests: Explicitly create containers in test_qom_partial_path() Peter Xu
2024-11-21  9:19   ` Philippe Mathieu-Daudé
2024-11-21 10:16   ` Daniel P. Berrangé
2024-11-20 21:56 ` [PATCH 05/12] ui/console: Explicitly create "/backend" container Peter Xu
2024-11-21  9:19   ` Philippe Mathieu-Daudé
2024-11-21 10:26   ` Daniel P. Berrangé
2024-11-21 16:27     ` Peter Xu
2024-11-20 21:56 ` Peter Xu [this message]
2024-11-21  9:35   ` [PATCH 06/12] hw/ppc: Explicitly create the drc container Philippe Mathieu-Daudé
2024-11-21 16:36     ` Peter Xu
2024-11-21 17:14       ` Philippe Mathieu-Daudé
2024-11-20 21:56 ` [PATCH 07/12] ppc/e500: Avoid abuse of container_get() Peter Xu
2024-11-21  9:38   ` Cédric Le Goater
2024-11-21  9:48     ` Cédric Le Goater
2024-11-21 16:41       ` Peter Xu
2024-11-21 17:17         ` Philippe Mathieu-Daudé
2024-11-21 10:28   ` Daniel P. Berrangé
2024-11-20 21:56 ` [PATCH 08/12] qdev: Make qdev_get_machine() not use container_get() Peter Xu
2024-11-21 10:21   ` Daniel P. Berrangé
2024-11-21 16:48     ` Peter Xu
2024-11-20 21:57 ` [PATCH 09/12] qdev: Add machine_get_container() Peter Xu
2024-11-21  9:23   ` Philippe Mathieu-Daudé
2024-11-21 10:23   ` Daniel P. Berrangé
2024-11-21 13:23   ` Markus Armbruster
2024-11-20 21:57 ` [PATCH 10/12] qom: Create system containers explicitly Peter Xu
2024-11-21  9:13   ` Philippe Mathieu-Daudé
2024-11-21 10:30   ` Daniel P. Berrangé
2024-11-21 13:01     ` Philippe Mathieu-Daudé
2024-11-21 17:17       ` Peter Xu
2024-11-21 17:29         ` Philippe Mathieu-Daudé
2024-11-21 18:03           ` Peter Xu
2024-11-21 19:03             ` Philippe Mathieu-Daudé
2024-11-21 13:31   ` Markus Armbruster
2024-11-21 17:24     ` Peter Xu
2024-11-20 21:57 ` [PATCH 11/12] qom: Add object_get_container() Peter Xu
2024-11-21  9:23   ` Philippe Mathieu-Daudé
2024-11-21 10:30   ` Daniel P. Berrangé
2024-11-20 21:57 ` [PATCH 12/12] qom: Drop container_get() Peter Xu
2024-11-21 10:32   ` Daniel P. Berrangé
2024-11-21  9:18 ` [PATCH 00/12] QOM: container_get() removal Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241120215703.3918445-7-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=clg@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=eduardo@habkost.net \
    --cc=farosas@suse.de \
    --cc=harshpb@linux.ibm.com \
    --cc=jmarcin@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).