Commit a11d070e38435e145c17f74889992972bccd66b7
1 parent
db380c06
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
Showing
3 changed files
with
30 additions
and
3 deletions
hw/usb-serial.c
... | ... | @@ -486,7 +486,7 @@ USBDevice *usb_serial_init(const char *filename) |
486 | 486 | { |
487 | 487 | USBSerialState *s; |
488 | 488 | CharDriverState *cdrv; |
489 | - unsigned short vendorid = 0x0403, productid = 0xFF00; | |
489 | + unsigned short vendorid = 0x0403, productid = 0x6001; | |
490 | 490 | |
491 | 491 | while (*filename && *filename != ':') { |
492 | 492 | const char *p; | ... | ... |
qemu-doc.texi
... | ... | @@ -1594,7 +1594,7 @@ Standard USB keyboard. Will override the PS/2 keyboard (if present). |
1594 | 1594 | Serial converter. This emulates an FTDI FT232BM chip connected to host character |
1595 | 1595 | device @var{dev}. The available character devices are the same as for the |
1596 | 1596 | @code{-serial} option. The @code{vendorid} and @code{productid} options can be |
1597 | -used to override the default 0403:FF00. For instance, | |
1597 | +used to override the default 0403:6001. For instance, | |
1598 | 1598 | @example |
1599 | 1599 | usb_add serial:productid=FA00:tcp:192.168.0.2:4444 |
1600 | 1600 | @end example | ... | ... |
vl.c
... | ... | @@ -2050,6 +2050,20 @@ static void fd_chr_update_read_handler(CharDriverState *chr) |
2050 | 2050 | } |
2051 | 2051 | } |
2052 | 2052 | |
2053 | +static void fd_chr_close(struct CharDriverState *chr) | |
2054 | +{ | |
2055 | + FDCharDriver *s = chr->opaque; | |
2056 | + | |
2057 | + if (s->fd_in >= 0) { | |
2058 | + if (nographic && s->fd_in == 0) { | |
2059 | + } else { | |
2060 | + qemu_set_fd_handler2(s->fd_in, NULL, NULL, NULL, NULL); | |
2061 | + } | |
2062 | + } | |
2063 | + | |
2064 | + qemu_free(s); | |
2065 | +} | |
2066 | + | |
2053 | 2067 | /* open a character device to a unix fd */ |
2054 | 2068 | static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) |
2055 | 2069 | { |
... | ... | @@ -2069,6 +2083,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) |
2069 | 2083 | chr->opaque = s; |
2070 | 2084 | chr->chr_write = fd_chr_write; |
2071 | 2085 | chr->chr_update_read_handler = fd_chr_update_read_handler; |
2086 | + chr->chr_close = fd_chr_close; | |
2072 | 2087 | |
2073 | 2088 | qemu_chr_reset(chr); |
2074 | 2089 | |
... | ... | @@ -2155,6 +2170,7 @@ static void stdio_read(void *opaque) |
2155 | 2170 | /* init terminal so that we can grab keys */ |
2156 | 2171 | static struct termios oldtty; |
2157 | 2172 | static int old_fd0_flags; |
2173 | +static int term_atexit_done; | |
2158 | 2174 | |
2159 | 2175 | static void term_exit(void) |
2160 | 2176 | { |
... | ... | @@ -2184,11 +2200,20 @@ static void term_init(void) |
2184 | 2200 | |
2185 | 2201 | tcsetattr (0, TCSANOW, &tty); |
2186 | 2202 | |
2187 | - atexit(term_exit); | |
2203 | + if (!term_atexit_done++) | |
2204 | + atexit(term_exit); | |
2188 | 2205 | |
2189 | 2206 | fcntl(0, F_SETFL, O_NONBLOCK); |
2190 | 2207 | } |
2191 | 2208 | |
2209 | +static void qemu_chr_close_stdio(struct CharDriverState *chr) | |
2210 | +{ | |
2211 | + term_exit(); | |
2212 | + stdio_nb_clients--; | |
2213 | + qemu_set_fd_handler2(0, NULL, NULL, NULL, NULL); | |
2214 | + fd_chr_close(chr); | |
2215 | +} | |
2216 | + | |
2192 | 2217 | static CharDriverState *qemu_chr_open_stdio(void) |
2193 | 2218 | { |
2194 | 2219 | CharDriverState *chr; |
... | ... | @@ -2196,6 +2221,7 @@ static CharDriverState *qemu_chr_open_stdio(void) |
2196 | 2221 | if (stdio_nb_clients >= STDIO_MAX_CLIENTS) |
2197 | 2222 | return NULL; |
2198 | 2223 | chr = qemu_chr_open_fd(0, 1); |
2224 | + chr->chr_close = qemu_chr_close_stdio; | |
2199 | 2225 | qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); |
2200 | 2226 | stdio_nb_clients++; |
2201 | 2227 | term_init(); |
... | ... | @@ -3418,6 +3444,7 @@ void qemu_chr_close(CharDriverState *chr) |
3418 | 3444 | { |
3419 | 3445 | if (chr->chr_close) |
3420 | 3446 | chr->chr_close(chr); |
3447 | + qemu_free(chr); | |
3421 | 3448 | } |
3422 | 3449 | |
3423 | 3450 | /***********************************************************/ | ... | ... |