[PATCH 05/12] ui/console: Explicitly create "/backend" container

Peter Xu posted 12 patches 2 days, 16 hours ago
There is a newer version of this series
[PATCH 05/12] ui/console: Explicitly create "/backend" container
Posted by Peter Xu 2 days, 16 hours ago
Follow the trend to explicitly create containers, do that for console.c on
"/backend" container.

Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 ui/console.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/console.c b/ui/console.c
index 5165f17125..36f8c6debb 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1154,14 +1154,14 @@ DisplayState *init_displaystate(void)
 {
     gchar *name;
     QemuConsole *con;
+    Object *backend = container_create(object_get_root(), "backend");
 
     QTAILQ_FOREACH(con, &consoles, next) {
         /* Hook up into the qom tree here (not in object_new()), once
          * all QemuConsoles are created and the order / numbering
          * doesn't change any more */
         name = g_strdup_printf("console[%d]", con->index);
-        object_property_add_child(container_get(object_get_root(), "/backend"),
-                                  name, OBJECT(con));
+        object_property_add_child(backend, name, OBJECT(con));
         g_free(name);
     }
 
-- 
2.45.0


Re: [PATCH 05/12] ui/console: Explicitly create "/backend" container
Posted by Daniel P. Berrangé 2 days, 4 hours ago
On Wed, Nov 20, 2024 at 04:56:56PM -0500, Peter Xu wrote:
> Follow the trend to explicitly create containers, do that for console.c on
> "/backend" container.
> 
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  ui/console.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ui/console.c b/ui/console.c
> index 5165f17125..36f8c6debb 100644
> --- a/ui/console.c
> +++ b/ui/console.c
> @@ -1154,14 +1154,14 @@ DisplayState *init_displaystate(void)
>  {
>      gchar *name;
>      QemuConsole *con;
> +    Object *backend = container_create(object_get_root(), "backend");

What's the rationale for keeping this in the console code ?

I'd consider this to be a similar situation to '/chardevs' and
'/objects', and be a common container rather than UI specific.
IOW, be created by your later patch.

>  
>      QTAILQ_FOREACH(con, &consoles, next) {
>          /* Hook up into the qom tree here (not in object_new()), once
>           * all QemuConsoles are created and the order / numbering
>           * doesn't change any more */
>          name = g_strdup_printf("console[%d]", con->index);
> -        object_property_add_child(container_get(object_get_root(), "/backend"),
> -                                  name, OBJECT(con));
> +        object_property_add_child(backend, name, OBJECT(con));
>          g_free(name);
>      }



With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH 05/12] ui/console: Explicitly create "/backend" container
Posted by Peter Xu 1 day, 22 hours ago
On Thu, Nov 21, 2024 at 10:26:34AM +0000, Daniel P. Berrangé wrote:
> On Wed, Nov 20, 2024 at 04:56:56PM -0500, Peter Xu wrote:
> > Follow the trend to explicitly create containers, do that for console.c on
> > "/backend" container.
> > 
> > Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  ui/console.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/ui/console.c b/ui/console.c
> > index 5165f17125..36f8c6debb 100644
> > --- a/ui/console.c
> > +++ b/ui/console.c
> > @@ -1154,14 +1154,14 @@ DisplayState *init_displaystate(void)
> >  {
> >      gchar *name;
> >      QemuConsole *con;
> > +    Object *backend = container_create(object_get_root(), "backend");
> 
> What's the rationale for keeping this in the console code ?
> 
> I'd consider this to be a similar situation to '/chardevs' and
> '/objects', and be a common container rather than UI specific.
> IOW, be created by your later patch.

I was trying to be careful on always create then on demand like
before. E.g. I was thinking maybe this container shouldn't exist when
there's no display at all.

But looks like init_displaystate() is indeed always invoked for system
code.. so yeah, perhaps I can move it over too, and drop this patch (below
will be part of last patch to use objects_get_container() instead, or part
of its splits).

> 
> >  
> >      QTAILQ_FOREACH(con, &consoles, next) {
> >          /* Hook up into the qom tree here (not in object_new()), once
> >           * all QemuConsoles are created and the order / numbering
> >           * doesn't change any more */
> >          name = g_strdup_printf("console[%d]", con->index);
> > -        object_property_add_child(container_get(object_get_root(), "/backend"),
> > -                                  name, OBJECT(con));
> > +        object_property_add_child(backend, name, OBJECT(con));
> >          g_free(name);
> >      }
> 
> 
> 
> With regards,
> Daniel
> -- 
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
> 

-- 
Peter Xu


Re: [PATCH 05/12] ui/console: Explicitly create "/backend" container
Posted by Philippe Mathieu-Daudé 2 days, 5 hours ago
On 20/11/24 22:56, Peter Xu wrote:
> Follow the trend to explicitly create containers, do that for console.c on
> "/backend" container.
> 
> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>   ui/console.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>