aboutsummaryrefslogtreecommitdiff
path: root/include/qemu/compiler.h
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2015-05-13 17:14:06 +0100
committerAndreas Färber <afaerber@suse.de>2015-06-19 18:42:18 +0200
commita31bdae5a76ecc060c1eb8a66be1896072c1e8b2 (patch)
treef09410fa5d0fbdb196e461be8662c57ec4e9ff6f /include/qemu/compiler.h
parentbc2256c4ae86308a1521c89456b599d441119418 (diff)
downloadqemu-a31bdae5a76ecc060c1eb8a66be1896072c1e8b2.zip
qemu-a31bdae5a76ecc060c1eb8a66be1896072c1e8b2.tar.gz
qemu-a31bdae5a76ecc060c1eb8a66be1896072c1e8b2.tar.bz2
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>
Diffstat (limited to 'include/qemu/compiler.h')
-rw-r--r--include/qemu/compiler.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index ac7c4c4..df9dd51 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -24,6 +24,12 @@
#define QEMU_WARN_UNUSED_RESULT
#endif
+#if QEMU_GNUC_PREREQ(4, 0)
+#define QEMU_SENTINEL __attribute__((sentinel))
+#else
+#define QEMU_SENTINEL
+#endif
+
#if QEMU_GNUC_PREREQ(4, 3)
#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
#else