]> xenbits.xensource.com Git - xenclient/ioemu.git/commitdiff
add an init function parameter to qemu_chr_open()
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 10 Mar 2009 18:14:19 +0000 (18:14 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 10 Mar 2009 18:14:19 +0000 (18:14 +0000)
And use it for the malta emulation. Fix segfault introduced in
revision 6352.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6365 c046a42c-6fe2-441c-8c8c-71466251a162

As adapted by Stefano to qemu-xen-unstable in his posting:
 [Xen-devel] [PATCH 10 of 13] add an init function parameter to qemu_chr_open()

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
console.c
gdbstub.c
hw/usb-serial.c
qemu-char.h
vl.c

index 93243274afe0099b66a67aedf64a91dd79bf8e8c..db2ea53c9da239516a97565c0301a8346d41d3e1 100644 (file)
--- a/console.c
+++ b/console.c
@@ -1359,6 +1359,8 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, const c
     text_console_resize(s);
 
     qemu_chr_reset(chr);
+    if (chr->init)
+        chr->init(chr);
 }
 
 CharDriverState *text_console_init(const char *p)
index c54354cca6003f2848100b39e8ae1fdc3ebfa642..a499f7fb447119cf5fa2a64a702c4ed2491e7b15 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1852,7 +1852,7 @@ int gdbserver_start(const char *port)
         port = gdbstub_port_name;
     }
 
-    chr = qemu_chr_open("gdb", port);
+    chr = qemu_chr_open("gdb", port, NULL);
     if (!chr)
         return -1;
 
index a6a756d957f1f53ec2da9b1ca3d41c554556628d..9dd2c072d031e4b79d801f33361aa54e86fa62c3 100644 (file)
@@ -558,7 +558,7 @@ USBDevice *usb_serial_init(const char *filename)
         return NULL;
 
     snprintf(label, sizeof(label), "usbserial%d", index++);
-    cdrv = qemu_chr_open(label, filename);
+    cdrv = qemu_chr_open(label, filename, NULL);
     if (!cdrv)
         goto fail;
     s->cs = cdrv;
index 25feaae0ce991d87c25523f288e3c5e50f299a49..a139f07d11c49decce2f94cf5ace65c67b58e0d8 100644 (file)
@@ -43,6 +43,7 @@ typedef struct {
 typedef void IOEventHandler(void *opaque, int event);
 
 struct CharDriverState {
+    void (*init)(struct CharDriverState *s);
     int (*chr_write)(struct CharDriverState *s, const uint8_t *buf, int len);
     void (*chr_update_read_handler)(struct CharDriverState *s);
     int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
@@ -62,7 +63,7 @@ struct CharDriverState {
     TAILQ_ENTRY(CharDriverState) next;
 };
 
-CharDriverState *qemu_chr_open(const char *label, const char *filename);
+CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s));
 void qemu_chr_close(CharDriverState *chr);
 void qemu_chr_printf(CharDriverState *s, const char *fmt, ...);
 int qemu_chr_write(CharDriverState *s, const uint8_t *buf, int len);
diff --git a/vl.c b/vl.c
index e59a15f230519e3e0e6b15d761d319fcb18aa7c2..52836d1cc62dfa1f90536104e4d02e31a3fe49aa 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -3836,7 +3836,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
 static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs
 = TAILQ_HEAD_INITIALIZER(chardevs);
 
-CharDriverState *qemu_chr_open(const char *label, const char *filename)
+CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*init)(struct CharDriverState *s))
 {
     const char *p;
     CharDriverState *chr;
@@ -3860,7 +3860,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename)
         chr = qemu_chr_open_udp(p);
     } else
     if (strstart(filename, "mon:", &p)) {
-        chr = qemu_chr_open(label, p);
+        chr = qemu_chr_open(label, p, NULL);
         if (chr) {
             chr = qemu_chr_open_mux(chr);
             monitor_init(chr, !nographic);
@@ -3917,6 +3917,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename)
     if (chr) {
         if (!chr->filename)
             chr->filename = qemu_strdup(filename);
+        chr->init = init;
         chr->label = qemu_strdup(label);
         TAILQ_INSERT_TAIL(&chardevs, chr, next);
     }
@@ -10067,7 +10068,7 @@ int main(int argc, char **argv)
     }
 
     if (monitor_device) {
-        monitor_hd = qemu_chr_open("monitor", monitor_device);
+        monitor_hd = qemu_chr_open("monitor", monitor_device, NULL);
         if (!monitor_hd) {
             fprintf(stderr, "qemu: could not open monitor device '%s'\n", monitor_device);
             exit(1);
@@ -10079,7 +10080,7 @@ int main(int argc, char **argv)
         if (devname && strcmp(devname, "none")) {
             char label[32];
             snprintf(label, sizeof(label), "serial%d", i);
-            serial_hds[i] = qemu_chr_open(label, devname);
+            serial_hds[i] = qemu_chr_open(label, devname, NULL);
             if (!serial_hds[i]) {
                 fprintf(stderr, "qemu: could not open serial device '%s'\n",
                         devname);
@@ -10093,7 +10094,7 @@ int main(int argc, char **argv)
         if (devname && strcmp(devname, "none")) {
             char label[32];
             snprintf(label, sizeof(label), "parallel%d", i);
-            parallel_hds[i] = qemu_chr_open(label, devname);
+            parallel_hds[i] = qemu_chr_open(label, devname, NULL);
             if (!parallel_hds[i]) {
                 fprintf(stderr, "qemu: could not open parallel device '%s'\n",
                         devname);