summaryrefslogtreecommitdiffstats
path: root/hw/core/qdev-properties.c
diff options
context:
space:
mode:
authorIgor Mammedov2013-03-07 17:16:18 +0100
committerAndreas Färber2013-04-16 01:19:46 +0200
commit72cc5137759ce1393c9eeac81b677947d618351d (patch)
tree009b093aa2961d0e2b1824cf89039c2ed72a2b03 /hw/core/qdev-properties.c
parenttarget-i386: Improve -cpu ? features output (diff)
downloadqemu-72cc5137759ce1393c9eeac81b677947d618351d.tar.gz
qemu-72cc5137759ce1393c9eeac81b677947d618351d.tar.xz
qemu-72cc5137759ce1393c9eeac81b677947d618351d.zip
qdev: Add qdev property for bool type
Signed-off-by: Igor Mammedov <imammedo@redhat.com> [AF: Use new qdev_prop_set_after_realize()] Signed-off-by: Andreas Färber <afaerber@suse.de>
Diffstat (limited to 'hw/core/qdev-properties.c')
-rw-r--r--hw/core/qdev-properties.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ddde18e6b4..ca1739ec84 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -120,6 +120,39 @@ PropertyInfo qdev_prop_bit = {
.set = set_bit,
};
+/* --- bool --- */
+
+static void get_bool(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ bool *ptr = qdev_get_prop_ptr(dev, prop);
+
+ visit_type_bool(v, ptr, name, errp);
+}
+
+static void set_bool(Object *obj, Visitor *v, void *opaque,
+ const char *name, Error **errp)
+{
+ DeviceState *dev = DEVICE(obj);
+ Property *prop = opaque;
+ bool *ptr = qdev_get_prop_ptr(dev, prop);
+
+ if (dev->realized) {
+ qdev_prop_set_after_realize(dev, name, errp);
+ return;
+ }
+
+ visit_type_bool(v, ptr, name, errp);
+}
+
+PropertyInfo qdev_prop_bool = {
+ .name = "boolean",
+ .get = get_bool,
+ .set = set_bool,
+};
+
/* --- 8bit integer --- */
static void get_uint8(Object *obj, Visitor *v, void *opaque,