Allow -serial chardev:<name>
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 10 Sep 2009 08:58:52 +0000 (10:58 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 11 Sep 2009 15:19:49 +0000 (10:19 -0500)
Lets put -chardev into use now.  With this patch applied chardev:name is
accepted as chardev specification everywhere, i.e. now you can:

-chardev stdio,id=ttyS0
-serial chardev:ttyS0

which does the same as '-serial stdio".

Muxing can be done this way:

-chardev stdio,id=mux,mux=on
-serial chardev:mux
-monitor chardev:mux

You can mux more than two streams.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

qemu-char.c
qemu-char.h
qemu-config.c

index ef73afe..ce2799e 100644 (file)
@@ -2416,6 +2416,10 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i
     CharDriverState *chr;
     QemuOpts *opts;
 
+    if (strstart(filename, "chardev:", &p)) {
+        return qemu_chr_find(p);
+    }
+
     opts = qemu_chr_parse_compat(label, filename);
     if (!opts)
         return NULL;
@@ -2445,3 +2449,15 @@ void qemu_chr_info(Monitor *mon)
         monitor_printf(mon, "%s: filename=%s\n", chr->label, chr->filename);
     }
 }
+
+CharDriverState *qemu_chr_find(const char *name)
+{
+    CharDriverState *chr;
+
+    TAILQ_FOREACH(chr, &chardevs, next) {
+        if (strcmp(chr->label, name) != 0)
+            continue;
+        return chr;
+    }
+    return NULL;
+}
index 9bff0c7..0bf8944 100644 (file)
@@ -90,6 +90,7 @@ void qemu_chr_read(CharDriverState *s, uint8_t *buf, int len);
 int qemu_chr_get_msgfd(CharDriverState *s);
 void qemu_chr_accept_input(CharDriverState *s);
 void qemu_chr_info(Monitor *mon);
+CharDriverState *qemu_chr_find(const char *name);
 
 extern int term_escape_char;
 
index 8404f1b..f6f4cb4 100644 (file)
@@ -130,6 +130,9 @@ QemuOptsList qemu_chardev_opts = {
         },{
             .name = "rows",
             .type = QEMU_OPT_NUMBER,
+        },{
+            .name = "mux",
+            .type = QEMU_OPT_BOOL,
         },
         { /* end if list */ }
     },