aboutsummaryrefslogtreecommitdiff
path: root/qom
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-02-02 10:51:57 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2012-02-07 13:52:41 +0100
commit1d9c5a12cefcd914d99c32de9aac72966a4788ae (patch)
tree586b68028e04ca7cf3cb3a95fec94a3024f0384a /qom
parenta1e7efdcef38f7cba4a46e836f433c73d45d926f (diff)
downloadqemu-1d9c5a12cefcd914d99c32de9aac72966a4788ae.zip
qemu-1d9c5a12cefcd914d99c32de9aac72966a4788ae.tar.gz
qemu-1d9c5a12cefcd914d99c32de9aac72966a4788ae.tar.bz2
qom: add property get/set wrappers for links
These can set a link to any object, as long as it is included in the composition tree. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qom')
-rw-r--r--qom/object.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/qom/object.c b/qom/object.c
index 686cca0..5e5b261 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -696,6 +696,30 @@ char *object_property_get_str(Object *obj, const char *name,
return retval;
}
+void object_property_set_link(Object *obj, Object *value,
+ const char *name, Error **errp)
+{
+ object_property_set_str(obj, object_get_canonical_path(value),
+ name, errp);
+}
+
+Object *object_property_get_link(Object *obj, const char *name,
+ Error **errp)
+{
+ char *str = object_property_get_str(obj, name, errp);
+ Object *target = NULL;
+
+ if (str && *str) {
+ target = object_resolve_path(str, NULL);
+ if (!target) {
+ error_set(errp, QERR_DEVICE_NOT_FOUND, str);
+ }
+ }
+
+ g_free(str);
+ return target;
+}
+
void object_property_set_bool(Object *obj, bool value,
const char *name, Error **errp)
{