qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/9] chardev: add greeting


From: Gerd Hoffmann
Subject: [Qemu-devel] [PATCH 1/9] chardev: add greeting
Date: Tue, 17 Nov 2009 10:38:11 +0100

Add a greeting string to CharDriverState which is printed after
initialization.  Used to have the qemu vc consoles labeled.  This
way we can avoid walking all the chardevs a second time after
initialization just to print the greeting.

Signed-off-by: Gerd Hoffmann <address@hidden>
---
 qemu-char.c |    2 ++
 qemu-char.h |    1 +
 vl.c        |   36 ++++++++++++------------------------
 3 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 40bd7e8..19be58f 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -132,6 +132,8 @@ void qemu_chr_initial_reset(void)
 
     QTAILQ_FOREACH(chr, &chardevs, next) {
         qemu_chr_reset(chr);
+        if (chr->greeting)
+            qemu_chr_printf(chr, "%s", chr->greeting);
     }
 }
 
diff --git a/qemu-char.h b/qemu-char.h
index 05fe15d..e50a4f3 100644
--- a/qemu-char.h
+++ b/qemu-char.h
@@ -66,6 +66,7 @@ struct CharDriverState {
     QEMUBH *bh;
     char *label;
     char *filename;
+    char *greeting;
     QTAILQ_ENTRY(CharDriverState) next;
 };
 
diff --git a/vl.c b/vl.c
index fff8e8d..095aff6 100644
--- a/vl.c
+++ b/vl.c
@@ -5657,6 +5657,10 @@ int main(int argc, char **argv, char **envp)
                         devname, strerror(errno));
                 exit(1);
             }
+            if (strstart(devname, "vc", 0)) {
+                snprintf(label, sizeof(label), "serial%d console\r\n", i);
+                serial_hds[i]->greeting = qemu_strdup(label);
+            }
         }
     }
 
@@ -5671,6 +5675,10 @@ int main(int argc, char **argv, char **envp)
                         devname, strerror(errno));
                 exit(1);
             }
+            if (strstart(devname, "vc", 0)) {
+                snprintf(label, sizeof(label), "parallel%d console\r\n", i);
+                parallel_hds[i]->greeting = qemu_strdup(label);
+            }
         }
     }
 
@@ -5685,6 +5693,10 @@ int main(int argc, char **argv, char **envp)
                         devname, strerror(errno));
                 exit(1);
             }
+            if (strstart(devname, "vc", 0)) {
+                snprintf(label, sizeof(label), "virtio console%d\r\n", i);
+                virtcon_hds[i]->greeting = qemu_strdup(label);
+            }
         }
     }
 
@@ -5800,30 +5812,6 @@ int main(int argc, char **argv, char **envp)
         }
     }
 
-    for(i = 0; i < MAX_SERIAL_PORTS; i++) {
-        const char *devname = serial_devices[i];
-        if (devname && strcmp(devname, "none")) {
-            if (strstart(devname, "vc", 0))
-                qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i);
-        }
-    }
-
-    for(i = 0; i < MAX_PARALLEL_PORTS; i++) {
-        const char *devname = parallel_devices[i];
-        if (devname && strcmp(devname, "none")) {
-            if (strstart(devname, "vc", 0))
-                qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i);
-        }
-    }
-
-    for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) {
-        const char *devname = virtio_consoles[i];
-        if (virtcon_hds[i] && devname) {
-            if (strstart(devname, "vc", 0))
-                qemu_chr_printf(virtcon_hds[i], "virtio console%d\r\n", i);
-        }
-    }
-
     if (gdbstub_dev && gdbserver_start(gdbstub_dev) < 0) {
         fprintf(stderr, "qemu: could not open gdbserver on device '%s'\n",
                 gdbstub_dev);
-- 
1.6.2.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]