Paolo Bonzini | 9f5f135 | 2012-02-01 16:58:47 +0100 | [diff] [blame] | 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 | |
Peter Maydell | 9bbc853 | 2016-01-29 17:50:02 +0000 | [diff] [blame] | 12 | #include "qemu/osdep.h" |
Markus Armbruster | da34e65 | 2016-03-14 09:01:28 +0100 | [diff] [blame] | 13 | #include "qapi/error.h" |
Paolo Bonzini | 14cccb6 | 2012-12-17 18:19:50 +0100 | [diff] [blame] | 14 | #include "qom/object.h" |
| 15 | #include "qom/qom-qobject.h" |
Paolo Bonzini | 7b1b5d1 | 2012-12-17 18:19:43 +0100 | [diff] [blame] | 16 | #include "qapi/visitor.h" |
Daniel P. Berrange | b3db211 | 2016-09-30 15:45:27 +0100 | [diff] [blame] | 17 | #include "qapi/qobject-input-visitor.h" |
| 18 | #include "qapi/qobject-output-visitor.h" |
Paolo Bonzini | 9f5f135 | 2012-02-01 16:58:47 +0100 | [diff] [blame] | 19 | |
Markus Armbruster | 6fd5bef | 2020-07-07 18:05:55 +0200 | [diff] [blame] | 20 | bool object_property_set_qobject(Object *obj, |
Markus Armbruster | 5325cc3 | 2020-07-07 18:05:54 +0200 | [diff] [blame] | 21 | const char *name, QObject *value, |
| 22 | Error **errp) |
Paolo Bonzini | 9f5f135 | 2012-02-01 16:58:47 +0100 | [diff] [blame] | 23 | { |
Eric Blake | b70ce10 | 2016-06-09 10:48:38 -0600 | [diff] [blame] | 24 | Visitor *v; |
Markus Armbruster | 6fd5bef | 2020-07-07 18:05:55 +0200 | [diff] [blame] | 25 | bool ok; |
Markus Armbruster | 05601ed | 2017-03-03 13:32:37 +0100 | [diff] [blame] | 26 | |
Markus Armbruster | 048abb7 | 2017-03-03 13:32:39 +0100 | [diff] [blame] | 27 | v = qobject_input_visitor_new(value); |
Markus Armbruster | 6fd5bef | 2020-07-07 18:05:55 +0200 | [diff] [blame] | 28 | ok = object_property_set(obj, name, v, errp); |
Eric Blake | b70ce10 | 2016-06-09 10:48:38 -0600 | [diff] [blame] | 29 | visit_free(v); |
Markus Armbruster | 6fd5bef | 2020-07-07 18:05:55 +0200 | [diff] [blame] | 30 | return ok; |
Paolo Bonzini | 9f5f135 | 2012-02-01 16:58:47 +0100 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | QObject *object_property_get_qobject(Object *obj, const char *name, |
| 34 | Error **errp) |
| 35 | { |
| 36 | QObject *ret = NULL; |
Eric Blake | 3b098d5 | 2016-06-09 10:48:43 -0600 | [diff] [blame] | 37 | Visitor *v; |
Paolo Bonzini | 9f5f135 | 2012-02-01 16:58:47 +0100 | [diff] [blame] | 38 | |
Daniel P. Berrange | 7d5e199 | 2016-09-30 15:45:28 +0100 | [diff] [blame] | 39 | v = qobject_output_visitor_new(&ret); |
Markus Armbruster | 992861f | 2020-07-07 18:06:04 +0200 | [diff] [blame] | 40 | if (object_property_get(obj, name, v, errp)) { |
Eric Blake | 3b098d5 | 2016-06-09 10:48:43 -0600 | [diff] [blame] | 41 | visit_complete(v, &ret); |
Paolo Bonzini | 9f5f135 | 2012-02-01 16:58:47 +0100 | [diff] [blame] | 42 | } |
Eric Blake | 3b098d5 | 2016-06-09 10:48:43 -0600 | [diff] [blame] | 43 | visit_free(v); |
Paolo Bonzini | 9f5f135 | 2012-02-01 16:58:47 +0100 | [diff] [blame] | 44 | return ret; |
| 45 | } |