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 void object_property_set_qobject(Object *obj, QObject *value, 21 const char *name, Error **errp) 22 { 23 Visitor *v; 24 25 v = qobject_input_visitor_new(value); 26 object_property_set(obj, v, name, errp); 27 visit_free(v); 28 } 29 30 QObject *object_property_get_qobject(Object *obj, const char *name, 31 Error **errp) 32 { 33 QObject *ret = NULL; 34 Error *local_err = NULL; 35 Visitor *v; 36 37 v = qobject_output_visitor_new(&ret); 38 object_property_get(obj, v, name, &local_err); 39 if (!local_err) { 40 visit_complete(v, &ret); 41 } 42 error_propagate(errp, local_err); 43 visit_free(v); 44 return ret; 45 } 46