Patchwork [v2,21/23] qdev: add parser for chardev properties

login
register
mail settings
Submitter Gerd Hoffmann
Date Sept. 10, 2009, 8:58 a.m.
Message ID <1252573135-27688-22-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/33287/
State Superseded
Headers show

Comments

Gerd Hoffmann - Sept. 10, 2009, 8:58 a.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/qdev-properties.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 12ff46b..0e5e5b5 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -170,6 +170,16 @@  PropertyInfo qdev_prop_drive = {
 
 /* --- character device --- */
 
+static int parse_chr(DeviceState *dev, Property *prop, const char *str)
+{
+    CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
+
+    *ptr = qemu_chr_find(str);
+    if (*ptr == NULL)
+        return -1;
+    return 0;
+}
+
 static int print_chr(DeviceState *dev, Property *prop, char *dest, size_t len)
 {
     CharDriverState **ptr = qdev_get_prop_ptr(dev, prop);
@@ -185,6 +195,7 @@  PropertyInfo qdev_prop_chr = {
     .name  = "chr",
     .type  = PROP_TYPE_CHR,
     .size  = sizeof(CharDriverState*),
+    .parse = parse_chr,
     .print = print_chr,
 };