block: Convert bdrv_aio_discard() to byte-based
[qemu/kevin.git] / qom / qom-qobject.c
blobc225abcbadb6eff2ccee3a1f63aa21d445e53d40
1 /*
2 * QEMU Object Model - QObject wrappers
4 * Copyright (C) 2012 Red Hat, Inc.
6 * Author: Paolo Bonzini <pbonzini@redhat.com>
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.
12 #include "qemu/osdep.h"
13 #include "qapi/error.h"
14 #include "qemu-common.h"
15 #include "qom/object.h"
16 #include "qom/qom-qobject.h"
17 #include "qapi/visitor.h"
18 #include "qapi/qmp-input-visitor.h"
19 #include "qapi/qmp-output-visitor.h"
21 void object_property_set_qobject(Object *obj, QObject *value,
22 const char *name, Error **errp)
24 Visitor *v;
25 /* TODO: Should we reject, rather than ignore, excess input? */
26 v = qmp_input_visitor_new(value, false);
27 object_property_set(obj, v, name, errp);
28 visit_free(v);
31 QObject *object_property_get_qobject(Object *obj, const char *name,
32 Error **errp)
34 QObject *ret = NULL;
35 Error *local_err = NULL;
36 Visitor *v;
38 v = qmp_output_visitor_new(&ret);
39 object_property_get(obj, v, name, &local_err);
40 if (!local_err) {
41 visit_complete(v, &ret);
43 error_propagate(errp, local_err);
44 visit_free(v);
45 return ret;