xref: /openbmc/qemu/qom/qom-qobject.c (revision f0513d2c)
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-common.h"
13 #include "qom/object.h"
14 #include "qom/qom-qobject.h"
15 #include "qapi/visitor.h"
16 #include "qapi/qmp-input-visitor.h"
17 #include "qapi/qmp-output-visitor.h"
18 
19 void object_property_set_qobject(Object *obj, QObject *value,
20                                  const char *name, Error **errp)
21 {
22     QmpInputVisitor *mi;
23     mi = qmp_input_visitor_new(value);
24     object_property_set(obj, qmp_input_get_visitor(mi), name, errp);
25 
26     qmp_input_visitor_cleanup(mi);
27 }
28 
29 QObject *object_property_get_qobject(Object *obj, const char *name,
30                                      Error **errp)
31 {
32     QObject *ret = NULL;
33     Error *local_err = NULL;
34     QmpOutputVisitor *mo;
35 
36     mo = qmp_output_visitor_new();
37     object_property_get(obj, qmp_output_get_visitor(mo), name, &local_err);
38     if (!local_err) {
39         ret = qmp_output_get_qobject(mo);
40     }
41     error_propagate(errp, local_err);
42     qmp_output_visitor_cleanup(mo);
43     return ret;
44 }
45