Skip to contentSkip to conversation

chardev: make chardevs specified in config file work.

PATCH In review Gerd Hoffmann 2 participants 2 messages Nov 25, 2009 – Dec 1, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 chardev: make chardevs specified in config file work.

The patch decuples the -chardev switch and the actual chardev initialization. Without this patch qemu ignores chardev entries coming via -readconfig.

---
 vl.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
vl.c +13 -3
index d188fc6..524b496 100644
@@ -4573,6 +4573,16 @@ static int device_init_func(QemuOpts *opts, void *opaque)
     return 0;
 }
 
+static int chardev_init_func(QemuOpts *opts, void *opaque)
+{
+    CharDriverState *chr;
+
+    chr = qemu_chr_open_opts(opts, NULL);
+    if (!chr)
+        return -1;
+    return 0;
+}
+
 struct device_config {
     enum {
         DEV_USB,       /* -usbdevice   */
@@ -5193,9 +5203,6 @@ int main(int argc, char **argv, char **envp)
                     fprintf(stderr, "parse error: %s\n", optarg);
                     exit(1);
                 }
-                if (qemu_chr_open_opts(opts, NULL) == NULL) {
-                    exit(1);
-                }
                 break;
             case QEMU_OPTION_serial:
                 add_device_config(DEV_SERIAL, optarg);
@@ -5506,6 +5513,9 @@ int main(int argc, char **argv, char **envp)
 
     qemu_opts_foreach(&qemu_device_opts, default_driver_check, NULL, 0);
 
+    if (qemu_opts_foreach(&qemu_chardev_opts, chardev_init_func, NULL, 1) != 0)
+        exit(1);
+
     if (display_type == DT_NOGRAPHIC) {
         if (default_parallel)
             add_device_config(DEV_PARALLEL, "null");
Signature · 1 line
1.6.2.5
#1 lore raw
Quoted 5 lines · Gerd Hoffmann

The patch decuples the -chardev switch and the actual chardev initialization. Without this patch qemu ignores chardev entries coming via -readconfig.

Makes sense to me.