On Wed, 26 Feb 2014 13:00:03 +0800 Hu Tao <hu...@cn.fujitsu.com> wrote:
> On Tue, Feb 25, 2014 at 03:15:53PM +0100, Paolo Bonzini wrote: > > Il 25/02/2014 11:20, Hu Tao ha scritto: > > >There is a problem that user_creatable_complete() is called before > > >adding object to "/objects" (see object_create()), which triggers a > > >assert failure when calling object_get_canonical_path() in > > >ram_backend_memory_init(). Any ideas? > > > > You can call object_property_add_child before calling > > user_creatable_complete, and then call object_unparent (in addition > > to object_unref) if creation fails. > > > > Paolo > > Something like this? > > From 59c999c840e4305bb2b95389bbea32e07c1c14c0 Mon Sep 17 00:00:00 2001 > From: Hu Tao <hu...@cn.fujitsu.com> > Date: Wed, 26 Feb 2014 12:54:34 +0800 > Subject: [PATCH] call user_creatable_complete() after adding object to > "/objects" > > This makes it possible to get the path of object by calling > object_get_canonical_path() in the complete callback if > someone wants it. > > Signed-off-by: Hu Tao <hu...@cn.fujitsu.com> > --- > vl.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/vl.c b/vl.c > index 1d27b34..30b4297 100644 > --- a/vl.c > +++ b/vl.c > @@ -2770,14 +2770,15 @@ static int object_create(QemuOpts *opts, void *opaque) > goto out; > } > > + object_property_add_child(container_get(object_get_root(), "/objects"), > + id, obj, &local_err); > + > user_creatable_complete(obj, &local_err); > if (local_err) { > + object_unparent(obj); > goto out; > } > > - object_property_add_child(container_get(object_get_root(), "/objects"), > - id, obj, &local_err); > - > out: > object_unref(obj); > if (local_err) { Failure case is not handled properly, I'm sorry that I've forgotten to mention prerequisite path https://github.com/imammedo/qemu/commit/72a079b88e055fc690c8895a99ccbcce36f6fc1f in stage tree https://github.com/imammedo/qemu/commits/memory-hotplug-v8