qemu-patch-raspberry4/qom
Daniel P. Berrange a31bdae5a7 qom: Add object_new_with_props() / object_new_withpropv() helpers
It is reasonably common to want to create an object, set a
number of properties, register it in the hierarchy and then
mark it as complete (if a user creatable type). This requires
quite a lot of error prone, verbose, boilerplate code to achieve.

First a pair of functions object_set_props() / object_set_propv()
are added which allow for a list of objects to be set in
one single API call.

Then object_new_with_props() / object_new_with_propv() constructors
are added which simplify the sequence of calls to create an
object, populate properties, register in the object composition
tree and mark the object complete, into a single method call.

Usage would be:

   Error *err = NULL;
   Object *obj;
   obj = object_new_with_propv(TYPE_MEMORY_BACKEND_FILE,
                               object_get_objects_root(),
                               "hostmem0",
                               &err,
                               "share", "yes",
                               "mem-path", "/dev/shm/somefile",
                               "prealloc", "yes",
                               "size", "1048576",
                               NULL);

Note all property values are passed in string form and will
be parsed into their required data types, using normal QOM
semantics for parsing from string format.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
2015-06-19 18:42:18 +02:00
..
container.c Make all static TypeInfos const 2013-01-10 15:11:53 -06:00
cpu.c qom: Fix warning from Sparse 2015-03-19 11:11:55 +03:00
Makefile.objs add optional 2nd stage initialization to -object/object-add commands 2014-01-28 12:47:02 -05:00
object.c qom: Add object_new_with_props() / object_new_withpropv() helpers 2015-06-19 18:42:18 +02:00
object_interfaces.c qom: Add can_be_deleted callback to UserCreatableClass 2015-04-01 10:06:38 +02:00
qom-qobject.c qom: move include files to include/qom/ 2012-12-19 08:31:32 +01:00