summaryrefslogtreecommitdiff
path: root/hw/qdev-properties.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2009-08-03 17:35:18 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-08-10 13:05:49 -0500
commit313feaabc600b0eaf4e60d591b9a1f6bdf680efc (patch)
treed72b884cae2048f2de0d5497d104721352bca6b7 /hw/qdev-properties.c
parentcf12b95bf5a2f30b37c4b91011fb6a9ab70c920d (diff)
downloadqemu-313feaabc600b0eaf4e60d591b9a1f6bdf680efc.tar.gz
qemu-313feaabc600b0eaf4e60d591b9a1f6bdf680efc.tar.bz2
qemu-313feaabc600b0eaf4e60d591b9a1f6bdf680efc.zip
qdev/prop: add CharDriverState property.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> Message-Id:
Diffstat (limited to 'hw/qdev-properties.c')
-rw-r--r--hw/qdev-properties.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 5a3d10d6f0..df3d20902a 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -168,6 +168,21 @@ PropertyInfo qdev_prop_drive = {
.print = print_drive,
};
+/* --- character device --- */
+
+static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+ CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
+ return snprintf(dest, len, "%s", (*ptr)->label);
+}
+
+PropertyInfo qdev_prop_chr = {
+ .name = "chr",
+ .type = PROP_TYPE_CHR,
+ .size = sizeof(CharDriverState*),
+ .print = print_chr,
+};
+
/* --- pointer --- */
static int print_ptr(DeviceState *dev, Property *prop, char *dest, size_t len)
@@ -357,6 +372,11 @@ void qdev_prop_set_drive(DeviceState *dev, const char *name, DriveInfo *value)
qdev_prop_set(dev, name, &value, PROP_TYPE_DRIVE);
}
+void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *value)
+{
+ qdev_prop_set(dev, name, &value, PROP_TYPE_CHR);
+}
+
void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
{
qdev_prop_set(dev, name, &value, PROP_TYPE_PTR);