All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	qemu-devel@nongnu.org,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH qemu] RFC: memory/hmp: Print owners/parents in "info mtree"
Date: Tue, 17 Apr 2018 14:18:03 +0200	[thread overview]
Message-ID: <20180417141803.2d588b97@redhat.com> (raw)
In-Reply-To: <13008b1f-4b59-c6e1-69d2-98f8280f6f34@redhat.com>

On Mon, 16 Apr 2018 17:29:23 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:

> On 16/04/2018 16:27, Igor Mammedov wrote:
> > On Mon, 16 Apr 2018 15:30:39 +0200
> > Paolo Bonzini <pbonzini@redhat.com> wrote:
> >   
> >> On 16/04/2018 15:20, Igor Mammedov wrote:  
> >>> Generally object doesn't need to know its own name,
> >>> we use it only for debugging and nice error reporting so far.
> >>> I'd rather have 'id' property at Object level so we won't have
> >>> to fish out ID from parent /which we aren't supposed to do and
> >>> which doesn't work in some cases/ when it's needed within
> >>> object itself.    
> >>
> >> Having an 'id' at object level is also a mess, because that id is
> >> invalid after unparent.  
> > I'd just consider 'id' as object name which is valid even if there
> > is no parent (during whole object lifecycle).  
> 
> What's the point of an object name if it cannot be unique?
It should be sufficient for it to be unique within parent's
scope and object_property_add_child() should make sure that
added object is unique within its parent's namespace.
Having named object from starters is useful as object
won't have to piggyback on parent (object_get_canonical_path_component)
when it need its own name. Then named object could use its name
freely anywhere including initfn, property setters/getters and
let object_property_add_child() take care of possible name
conflict.
From debugging/error reporting pov 'id' might be ambiguous
sometimes but it's way better than unanimous "NULL" string
or crash due to no set parent.

It sort of relates to discussion Peter started with

https://patchwork.kernel.org/patch/10224775/
"
Code that used to look like this:
    object_initialize(&s->ic, sizeof(s->ic), TYPE_BCM2835_IC);
    object_property_add_child(obj, "ic", OBJECT(&s->ic), NULL);
    qdev_set_parent_bus(DEVICE(&s->ic), sysbus_get_default());
can now look like this:
    sysbus_init_child(obj, "ic", &s->ic, sizeof(s->ic), TYPE_BCM2835_IC);
" 

Considering that in most cases where named objects are used
we parent them. We might be better of with API like

named_object_new(TYPE, NAME, PARENT, ERROR)
named_object_initialize(PTR, SIZE, TYPE, NAME, PARENT, ERROR)


> Paolo
> 
> > That would allow for object to have a reachable name vs getting NULL
> > when parent isn't set.
> > Maybe Object::id is overkill, but we probably could use NamedObject
> > where it's needed and avoid reverse engineering id from path.
> >    
> >> Since this is just for debugging use,
> >> object_get_canonical_path_component is the right function.  We can just
> >> make it return NULL if there is no parent.  
> >
> > looking at current use it out-grew just debugging usecases
> > and it's rather messy right now:
> > 
> > ram_backend_memory_alloc, throttle_group_obj_complete,
> > xlnx_zynqmp_create_rpu, spapr_drc.c:realize, iothread_complete,
> > memory_region_name  
> 
> I agree, _but_ it's definitely okay for debugging usecases.
yep, since there isn't other way to do it now,
it's fine to use object_get_canonical_path_component()


> 
> Paolo

  reply	other threads:[~2018-04-17 12:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29  3:21 [Qemu-devel] [PATCH qemu] RFC: memory/hmp: Print owners/parents in "info mtree" Alexey Kardashevskiy
2018-04-11 18:57 ` Dr. David Alan Gilbert
2018-04-12  9:15 ` Paolo Bonzini
2018-04-16 13:20   ` Igor Mammedov
2018-04-16 13:30     ` Paolo Bonzini
2018-04-16 14:27       ` Igor Mammedov
2018-04-16 15:29         ` Paolo Bonzini
2018-04-17 12:18           ` Igor Mammedov [this message]
2018-04-17 16:31             ` Paolo Bonzini
2018-04-18  6:32               ` Markus Armbruster
2018-04-18  9:23                 ` Paolo Bonzini
2018-04-19  2:41   ` Alexey Kardashevskiy
2018-04-19 10:33     ` Paolo Bonzini
2018-04-20  6:31       ` Alexey Kardashevskiy

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=20180417141803.2d588b97@redhat.com \
    --to=imammedo@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.