| 1 | /* |
| 2 | * QEMU Object Model - QObject wrappers |
| 3 | * |
| 4 | * Copyright (C) 2012 Red Hat, Inc. |
| 5 | * |
| 6 | * Author: Paolo Bonzini <pbonzini@redhat.com> |
| 7 | * |
| 8 | * This work is licensed under the terms of the GNU GPL, version 2 or later. |
| 9 | * See the COPYING file in the top-level directory. |
| 10 | */ |
| 11 | |
| 12 | #include "qemu/osdep.h" |
| 13 | #include "qapi/error.h" |
| 14 | #include "qom/object.h" |
| 15 | #include "qom/qom-qobject.h" |
| 16 | #include "qapi/visitor.h" |
| 17 | #include "qapi/qobject-input-visitor.h" |
| 18 | #include "qapi/qobject-output-visitor.h" |
| 19 | |
| 20 | bool object_property_set_qobject(Object *obj, |
| 21 | const char *name, QObject *value, |
| 22 | Error **errp) |
| 23 | { |
| 24 | Visitor *v; |
| 25 | bool ok; |
| 26 | |
| 27 | v = qobject_input_visitor_new(value); |
| 28 | ok = object_property_set(obj, name, v, errp); |
| 29 | visit_free(v); |
| 30 | return ok; |
| 31 | } |
| 32 | |
| 33 | QObject *object_property_get_qobject(Object *obj, const char *name, |
| 34 | Error **errp) |
| 35 | { |
| 36 | QObject *ret = NULL; |
| 37 | Visitor *v; |
| 38 | |
| 39 | v = qobject_output_visitor_new(&ret); |
| 40 | if (object_property_get(obj, name, v, errp)) { |
| 41 | visit_complete(v, &ret); |
| 42 | } |
| 43 | visit_free(v); |
| 44 | return ret; |
| 45 | } |