summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-01-19 13:00:43 +0000
committerbalrog <balrog@c046a42c-6fe2-441c-8c8c-71466251a162>2008-01-19 13:00:43 +0000
commita11d070e38435e145c17f74889992972bccd66b7 (patch)
tree110bd1522831d1e4c8eae33a3a13731977948908
parentdb380c066db9ddbc2b57ac2e394aaa3a170d08ab (diff)
downloadfocaccia-qemu-a11d070e38435e145c17f74889992972bccd66b7.tar.gz
focaccia-qemu-a11d070e38435e145c17f74889992972bccd66b7.zip
Change the usb-serial product ID to a more widely recognised value (Samuel Thibault).
Implement chr_close callback for "stdio" so that it can be closed and reopened.
Free chr devices after they're closed.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3927 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--hw/usb-serial.c2
-rw-r--r--qemu-doc.texi2
-rw-r--r--vl.c29
3 files changed, 30 insertions, 3 deletions
diff --git a/hw/usb-serial.c b/hw/usb-serial.c
index 378d751260..b666c99be7 100644
--- a/hw/usb-serial.c
+++ b/hw/usb-serial.c
@@ -486,7 +486,7 @@ USBDevice *usb_serial_init(const char *filename)
 {
     USBSerialState *s;
     CharDriverState *cdrv;
-    unsigned short vendorid = 0x0403, productid = 0xFF00;
+    unsigned short vendorid = 0x0403, productid = 0x6001;
 
     while (*filename && *filename != ':') {
         const char *p;
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 6fe7945486..4b9ea606db 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -1594,7 +1594,7 @@ Standard USB keyboard.  Will override the PS/2 keyboard (if present).
 Serial converter. This emulates an FTDI FT232BM chip connected to host character
 device @var{dev}. The available character devices are the same as for the
 @code{-serial} option. The @code{vendorid} and @code{productid} options can be
-used to override the default 0403:FF00. For instance, 
+used to override the default 0403:6001. For instance, 
 @example
 usb_add serial:productid=FA00:tcp:192.168.0.2:4444
 @end example
diff --git a/vl.c b/vl.c
index 8cbcd38c21..19cd928d76 100644
--- a/vl.c
+++ b/vl.c
@@ -2050,6 +2050,20 @@ static void fd_chr_update_read_handler(CharDriverState *chr)
     }
 }
 
+static void fd_chr_close(struct CharDriverState *chr)
+{
+    FDCharDriver *s = chr->opaque;
+
+    if (s->fd_in >= 0) {
+        if (nographic && s->fd_in == 0) {
+        } else {
+            qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL);
+        }
+    }
+
+    qemu_free(s);
+}
+
 /* open a character device to a unix fd */
 static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
 {
@@ -2069,6 +2083,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
     chr->opaque = s;
     chr->chr_write = fd_chr_write;
     chr->chr_update_read_handler = fd_chr_update_read_handler;
+    chr->chr_close = fd_chr_close;
 
     qemu_chr_reset(chr);
 
@@ -2155,6 +2170,7 @@ static void stdio_read(void *opaque)
 /* init terminal so that we can grab keys */
 static struct termios oldtty;
 static int old_fd0_flags;
+static int term_atexit_done;
 
 static void term_exit(void)
 {
@@ -2184,11 +2200,20 @@ static void term_init(void)
 
     tcsetattr (0, TCSANOW, &tty);
 
-    atexit(term_exit);
+    if (!term_atexit_done++)
+        atexit(term_exit);
 
     fcntl(0, F_SETFL, O_NONBLOCK);
 }
 
+static void qemu_chr_close_stdio(struct CharDriverState *chr)
+{
+    term_exit();
+    stdio_nb_clients--;
+    qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL);
+    fd_chr_close(chr);
+}
+
 static CharDriverState *qemu_chr_open_stdio(void)
 {
     CharDriverState *chr;
@@ -2196,6 +2221,7 @@ static CharDriverState *qemu_chr_open_stdio(void)
     if (stdio_nb_clients >= STDIO_MAX_CLIENTS)
         return NULL;
     chr = qemu_chr_open_fd(0, 1);
+    chr->chr_close = qemu_chr_close_stdio;
     qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr);
     stdio_nb_clients++;
     term_init();
@@ -3418,6 +3444,7 @@ void qemu_chr_close(CharDriverState *chr)
 {
     if (chr->chr_close)
         chr->chr_close(chr);
+    qemu_free(chr);
 }
 
 /***********************************************************/