[5575] Implement "info chardev" command.
Revision: 5575
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5575 Author: aliguori Date: 2008-10-31 17:31:29 +0000 (Fri, 31 Oct 2008)
Log Message:
-----------
Implement "info chardev" command. (Gerd Hoffmann)
This patch makes qemu keep track of the character devices in use and implements a "info chardev" monitor command to print a list.
qemu_chr_open() sticks the devices into a linked list now. It got a new argument (label), so there is a name for each device. It also assigns a filename to each character device. By default it just copyes the filename passed in. Individual drivers can fill in something else though. qemu_chr_open_pty() sets the filename to name of the pseudo tty allocated.
Output looks like this:
(qemu) info chardev
monitor: filename=unix:/tmp/run.sh-26827/monitor,server,nowait
serial0: filename=unix:/tmp/run.sh-26827/console,server
serial1: filename=pty:/dev/pts/5
parallel0: filename=vc:640x480
Modified Paths:
--------------
trunk/gdbstub.c
trunk/hw/usb-serial.c
trunk/monitor.c
trunk/qemu-char.h
trunk/vl.c
Modified: trunk/gdbstub.c
===================================================================
gdbstub.c +1 -1
@@ -1852,7 +1852,7 @@ port = gdbstub_port_name; } - chr =qemu_chr_open (port); + chr =qemu_chr_open ("gdb" , port);if (!chr)return -1 ;
Modified: trunk/hw/usb-serial.c
===================================================================
hw/usb-serial.c +4 -1
@@ -521,6 +521,8 @@USBSerialState *s;CharDriverState *cdrv;unsigned short vendorid =0x0403 , productid =0x6001 ; +char label[32 ]; +static int index;while (*filename && *filename !=':' ) {const char *p;
@@ -555,7 +557,8 @@if (!s)return NULL ; - cdrv =qemu_chr_open (filename); +snprintf (label,sizeof (label),"usbserial%d" , index++); + cdrv =qemu_chr_open (label, filename);if (!cdrv) goto fail; s->cs = cdrv;
Modified: trunk/monitor.c
===================================================================
monitor.c +2 -0
@@ -1469,6 +1469,8 @@ "", "show the version of qemu" }, {"network" ,"" , do_info_network, "", "show the network state" }, + { "chardev", "", qemu_chr_info, + "", "show the character devices" }, { "block", "", do_info_block, "", "show the block devices" }, { "blockstats", "", do_info_blockstats,
Modified: trunk/qemu-char.h
===================================================================
qemu-char.h +6 -1
@@ -1,6 +1,7 @@#ifndef QEMU_CHAR_H #define QEMU_CHAR_H +#include "sys-queue.h" /* character device */ #define CHR_EVENT_BREAK 0/* serial break char */
@@ -55,9 +56,12 @@void *opaque;int focus;QEMUBH *bh; +char *label; +char *filename; +TAILQ_ENTRY (CharDriverState) next; }; -CharDriverState *qemu_chr_open (const char *filename); +CharDriverState *qemu_chr_open (const char *label,const char *filename);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);
@@ -72,6 +76,7 @@int qemu_chr_can_read (CharDriverState *s);void qemu_chr_read (CharDriverState *s,uint8_t *buf,int len);void qemu_chr_accept_input (CharDriverState *s); +void qemu_chr_info (void );/* async I/O support */
Modified: trunk/vl.c
===================================================================
vl.c +65 -33
189 lines not on this page · raw message