Re: [Qemu-devel] [PATCH] pcnet32 driver change, please test
Paul Brook [EMAIL PROTECTED] writes: : I find this curious... C99 (6.7.2.1) says the allocation order of : bit-fields within a unit (high-order to low-order or low-order to : high-order) is implementation defined. I can't see any requirement : for this, so is it just convention that bitfields on big endian systems : start from the most significant bit, and those on little endian systems : start from the least significant bit? (My thinking is that endianness : usually refers to byte ordering and not so much bit ordering.) This is a convention that goes back a very long ways. It was this way in the mid 1980's, and has remained true through today. I've personally observed this to be the case on many different MIPS compilers, ARM compilers and SPARC compilers over the years. I'm fairly sure I've seen targets that use other bitfield orderings, though I can't remember offhand what they were. Bi-endian targets are examples of this. The bitfield ordering is normally independent of the selected byte order. For example, big-endian MIPS has little endian bit order. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 And now for something completely different. ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: [Qemu-devel] [PATCH] pcnet32 driver change, please test
In message: [EMAIL PROTECTED] Andreas Schwab [EMAIL PROTECTED] writes: : Paul Brook [EMAIL PROTECTED] writes: : : : I find this curious... C99 (6.7.2.1) says the allocation order of : : bit-fields within a unit (high-order to low-order or low-order to : : high-order) is implementation defined. I can't see any requirement : : for this, so is it just convention that bitfields on big endian systems : : start from the most significant bit, and those on little endian systems : : start from the least significant bit? (My thinking is that endianness : : usually refers to byte ordering and not so much bit ordering.) : : This is a convention that goes back a very long ways. It was this way : in the mid 1980's, and has remained true through today. I've : personally observed this to be the case on many different MIPS : compilers, ARM compilers and SPARC compilers over the years. : : I'm fairly sure I've seen targets that use other bitfield orderings, though I : can't remember offhand what they were. : : Bi-endian targets are examples of this. The bitfield ordering is normally : independent of the selected byte order. For example, big-endian MIPS has : little endian bit order. Except that compilers use the convention that was described above. Big endian MIPS definitely uses a different bit ordering for C bit fields than little endian MIPS. This is true for compilers from SGI, DEC and GNU and NetBSD, FreeBSD, Linux, Ultrix, OSF, and IRIX. All of them use the following, or variants for, say, the IP header: struct ip { #if BYTE_ORDER == LITTLE_ENDIAN unsigned int ip_hl:4, /* header length */ ip_v:4;/* version */ #endif #if BYTE_ORDER == BIG_ENDIAN unsigned int ip_v:4,/* version */ ip_hl:4; /* header length */ #endif ... Warner ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: [Qemu-devel] [PATCH] pcnet32 driver change, please test
M. Warner Losh [EMAIL PROTECTED] writes: Except that compilers use the convention that was described above. Big endian MIPS definitely uses a different bit ordering for C bit fields than little endian MIPS. There is actually a difference between *bitfield* ordering and *bit* ordering. The former always follows the byte ordering, whereas the latter is only a property of the ISA and has no influence on the ABI or API. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 And now for something completely different. ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: [Qemu-devel] QEMU/pc and scsi disks
Anthony Liguori wrote: I think most people agree that we need a config file. I haven't seen any comments on my config file patch though. So, any comments on that patch? Any requirements on a format? 1. Any option should be settable either in the config file or command line. In other words, the user should not be forced to use a config file. This is useful for management programs who keep all options in an internal database, and for users who can experiment via a ^P edit edit edit enter. 2. The %(blah)s syntax is a bit ugly. It's one of the few things in python I dislike. I'd prefer ${blah} and ${blah:modifier}. 3. It would be nice to be able to embed a config file in a qcow3 format so that one can ship an image with some default options in one file. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: [Qemu-devel] [PATCH] pcnet32 driver change, please test
Fabrice Bellard wrote: Thiemo Seufer wrote: Thiemo Seufer wrote: Hello All, I changed the pcnet32 driver to get rid of bitfields in its implementation, now it works also on big endian host systems. I tested only the 32 bit mode which is used by MIPS/Malta, and I'm not sure if it still works in Lance mode (as e.g. used on SPARC). So please test if it still works. I forgot to delete a line of debug output, updated. It seems that you made some unnecessary changes (why did you changed the code in pcnet_init ?). That code currently accesses initblk members (padr. ladrf) after the initblk structure went out of scope. I also wanted to keep the data acquisition with its byte swaps in the same place. Thiemo. ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: [Qemu-devel] FreeBSD Support
andrzej zaborowski wrote: Hi, On 20/02/07, Christopher Olsen [EMAIL PROTECTED] wrote: Ok FreeBSD Support round one.. Be gentle this is my first attempt at working with the rest of this community.. Files it modifies and the reasons are as follows configure - Adds HOST_FREEBSD type to alter included libraries FreeBSD does not need -ltr Makefile.target - Once again uses HOST_FREEBSD to avoid including -ltr See http://lists.gnu.org/archive/html/qemu-devel/2006-11/msg00166.html - I believe this is a more appropriate way to select -lrt. The solaris part there looked a bit inconsistent, is the appended version ok? Thiemo Index: qemu-work/Makefile === --- qemu-work.orig/Makefile 2007-02-11 16:10:55.0 + +++ qemu-work/Makefile 2007-03-02 21:07:26.0 + @@ -24,11 +24,7 @@ DOCS= endif -ifndef CONFIG_DARWIN -ifndef CONFIG_WIN32 -LIBS+=-lrt -endif -endif +LIBS+=$(AIOLIBS) all: $(TOOLS) $(DOCS) recurse-all Index: qemu-work/Makefile.target === --- qemu-work.orig/Makefile.target 2007-03-02 20:57:01.0 + +++ qemu-work/Makefile.target 2007-03-02 21:01:22.0 + @@ -436,6 +436,7 @@ endif VL_LDFLAGS= +VL_LIBS=$(AIOLIBS) # specific flags are needed for non soft mmu emulator ifdef CONFIG_STATIC VL_LDFLAGS+=-static @@ -446,7 +447,7 @@ ifndef CONFIG_DARWIN ifndef CONFIG_WIN32 ifndef CONFIG_SOLARIS -VL_LIBS=-lutil -lrt +VL_LIBS+=-lutil endif endif endif Index: qemu-work/configure === --- qemu-work.orig/configure2007-03-02 20:57:00.0 + +++ qemu-work/configure 2007-03-02 21:07:10.0 + @@ -159,6 +159,12 @@ fi fi +if [ $bsd = yes -o $darwin = yes -o $solaris = yes -o $mingw32 = yes ] ; then +AIOLIBS= +else +AIOLIBS=-lrt +fi + # find source path source_path=`dirname $0` if [ -z $source_path ]; then @@ -653,6 +659,7 @@ echo CFLAGS=$CFLAGS $config_mak echo LDFLAGS=$LDFLAGS $config_mak echo EXESUF=$EXESUF $config_mak +echo AIOLIBS=$AIOLIBS $config_mak if test $cpu = i386 ; then echo ARCH=i386 $config_mak echo #define HOST_I386 1 $config_h ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: [Qemu-devel] (no subject)
jeremy fenelon [EMAIL PROTECTED] wrote: Hey guys thanks for a great product. I don't know if its been documented already but I was able to install windows xp on qemu with a HP Laptop Restore disk. Lucky. I think the last time I tried that, it didn't work because of the way that HP locked the restore media to the BIOS identifier. Always wanted to be able to have the Bochs bios have an idenfier setting I coudl pass in so I could do something like that. I did need my key from the bottom. I hope this meets the EULA . Can't tell you if it meets the EULA. I picked up a key when a company trashed a laptop that still had the key on the bottom. My laptop did die last year and I have been wondering what I could do with that extra copy. Will Qemu boot a .iso file like ubuntu? Yes, it's a whole lot easrier than shuffling CD's and DVD's about. ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
Re: [Qemu-devel] QEMU/pc and scsi disks
Avi Kivity wrote: Anthony Liguori wrote: I think most people agree that we need a config file. I haven't seen any comments on my config file patch though. So, any comments on that patch? Any requirements on a format? 1. Any option should be settable either in the config file or command line. In other words, the user should not be forced to use a config file. This is useful for management programs who keep all options in an internal database, and for users who can experiment via a ^P edit edit edit enter. I think we should still provide the ability to set the most common options via the command line. I'm also fine with specifying single options on the command line. I suspect though that being able to do -config - is more useful for management tools than building large strings of command line options. 2. The %(blah)s syntax is a bit ugly. It's one of the few things in python I dislike. I'd prefer ${blah} and ${blah:modifier}. Yeah, I've never liked their printf syntax. I was interested in interpolation, the syntax really doesn't matter to me. sh is probably a bit easier on the eyes. 3. It would be nice to be able to embed a config file in a qcow3 format so that one can ship an image with some default options in one file. Yeah, definitely. Regards, Anthony Liguor ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
[Qemu-devel] qemu a.out.h dyngen.c
CVSROOT:/sources/qemu Module name:qemu Changes by: Paul Brook pbrook 07/03/04 00:52:16 Modified files: . : a.out.h dyngen.c Log message: 64bit-win32 cross build fix. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/qemu/a.out.h?cvsroot=qemur1=1.2r2=1.3 http://cvs.savannah.gnu.org/viewcvs/qemu/dyngen.c?cvsroot=qemur1=1.48r2=1.49 ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
[Qemu-devel] Problem Running QEMU, and passing new commands
Hi, I have successfully integrated the statistical simulation package SimPoint with QEMU. Now I wish to add some commands to QEMU so a user can start or stop simulation. The goal is that at the QEMU command prompt, the user could enter a command like start_simpoint or stop_simpoint. For example: (qemu) start_simpoint SimPoint started! (qemu) /*Time passes.. */ (qemu) stop_simpoint SimPoint stopped! I am curious where I would edit QEMU to look for such commands, some point in the code where I can see what command is passed to QEMU, and do something such as if strcmp(command, start_simpoint) == 0 Also, there is another problem, I am able to run QEMU if I tell it to load and boot a linux image. But I am not able to simply boot up to the (qemu) prompt and enter commands from there. I try running QEMU using the following commands: qemu-img create -f qcow c.img 3G ./i386-softmmu/qemu -hda c.img -L ./pc-bios/ -nographic and it loads up to the (qemu) prompt. However, at that point everything freezes. I am running QEMU on a linux host with a dual 64-bit AMD processors, and doing this over an SSH connection. If anyone has any advice on how I can get QEMU to boot to the point where I can enter commands, and how I can monitor these commands within the source code, I would very much appreciate the assistance. ~Shane Brennan UC Santa Cruz ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
[Qemu-devel] [PATCH] Add -name option
This option helps differentiate between guests when running more than one instance of QEMU. It adds a string to the SDL window title and to the VNC server title. Having a name associated with a guest is also terribly useful for management tools as it gives a standard way to identify guests to the user. Regards, Anthony Liguori diff -r 5b37ca9b68f9 monitor.c --- a/monitor.c Sun Mar 04 00:52:16 2007 + +++ b/monitor.c Sat Mar 03 20:59:23 2007 -0600 @@ -233,6 +233,12 @@ static void do_info_version(void) static void do_info_version(void) { term_printf(%s\n, QEMU_VERSION); +} + +static void do_info_name(void) +{ +if (qemu_name) + term_printf(%s\n, qemu_name); } static void do_info_block(void) @@ -1303,6 +1309,8 @@ static term_cmd_t info_cmds[] = { , show which guest mouse is receiving events }, { vnc, , do_info_vnc, , show the vnc server status}, +{ name, , do_info_name, + , show the current VM name }, { NULL, NULL, }, }; diff -r 5b37ca9b68f9 qemu-doc.texi --- a/qemu-doc.texi Sun Mar 04 00:52:16 2007 + +++ b/qemu-doc.texi Sat Mar 03 21:05:12 2007 -0600 @@ -330,6 +330,10 @@ slows down the IDE transfers). @item -option-rom file Load the contents of file as an option ROM. This option is useful to load things like EtherBoot. + [EMAIL PROTECTED] -name string +Sets the name of the guest. This name will be display in the SDL window +caption. The name will also be used for the VNC server. @end table diff -r 5b37ca9b68f9 sdl.c --- a/sdl.c Sun Mar 04 00:52:16 2007 + +++ b/sdl.c Sat Mar 03 20:58:51 2007 -0600 @@ -216,13 +216,19 @@ static void sdl_update_caption(void) static void sdl_update_caption(void) { char buf[1024]; -strcpy(buf, QEMU); -if (!vm_running) { -strcat(buf, [Stopped]); -} -if (gui_grab) { -strcat(buf, - Press Ctrl-Alt to exit grab); -} +const char *status = ; + +if (!vm_running) + status = [Stopped]; +else if (gui_grab) + status = - Press Ctrl-Alt to exit grab; + +if (qemu_name) + snprintf(buf, sizeof(buf), QEMU (%s)%s, + qemu_name, status); +else + snprintf(buf, sizeof(buf), QEMU%s, status); + SDL_WM_SetCaption(buf, QEMU); } diff -r 5b37ca9b68f9 vl.c --- a/vl.c Sun Mar 04 00:52:16 2007 + +++ b/vl.c Sat Mar 03 21:06:32 2007 -0600 @@ -189,6 +189,7 @@ int nb_option_roms; int nb_option_roms; int semihosting_enabled = 0; int autostart = 1; +const char *qemu_name; /***/ /* x86 ISA bus support */ @@ -6391,6 +6392,7 @@ void help(void) #if defined(TARGET_PPC) || defined(TARGET_SPARC) -g WxH[xDEPTH] Set the initial graphical resolution and depth\n #endif + -name stringset the name of the guest\n \n Network options:\n -net nic[,vlan=n][,macaddr=addr][,model=type]\n @@ -6548,7 +6550,8 @@ enum { QEMU_OPTION_no_reboot, QEMU_OPTION_daemonize, QEMU_OPTION_option_rom, -QEMU_OPTION_semihosting +QEMU_OPTION_semihosting, +QEMU_OPTION_name, }; typedef struct QEMUOption { @@ -6638,6 +6641,7 @@ const QEMUOption qemu_options[] = { #if defined(TARGET_ARM) { semihosting, 0, QEMU_OPTION_semihosting }, #endif +{ name, HAS_ARG, QEMU_OPTION_name }, { NULL }, }; @@ -7318,6 +7322,9 @@ int main(int argc, char **argv) case QEMU_OPTION_semihosting: semihosting_enabled = 1; break; +case QEMU_OPTION_name: +qemu_name = optarg; +break; } } } diff -r 5b37ca9b68f9 vl.h --- a/vl.h Sun Mar 04 00:52:16 2007 + +++ b/vl.h Sat Mar 03 20:58:51 2007 -0600 @@ -114,6 +114,7 @@ extern const char *bios_dir; extern const char *bios_dir; extern int vm_running; +extern const char *qemu_name; typedef struct vm_change_state_entry VMChangeStateEntry; typedef void VMChangeStateHandler(void *opaque, int running); diff -r 5b37ca9b68f9 vnc.c --- a/vnc.c Sun Mar 04 00:52:16 2007 + +++ b/vnc.c Sat Mar 03 20:58:51 2007 -0600 @@ -1056,6 +1056,8 @@ static int protocol_client_init(VncState static int protocol_client_init(VncState *vs, char *data, size_t len) { char pad[3] = { 0, 0, 0 }; +char buf[1024]; +int size; vs-width = vs-ds-width; vs-height = vs-ds-height; @@ -1100,8 +1102,13 @@ static int protocol_client_init(VncState vnc_write(vs, pad, 3); /* padding */ -vnc_write_u32(vs, 4); -vnc_write(vs, QEMU, 4); +if (qemu_name) + size = snprintf(buf, sizeof(buf), QEMU (%s), qemu_name); +else + size = snprintf(buf, sizeof(buf), QEMU); + +vnc_write_u32(vs, size); +vnc_write(vs, buf, size); vnc_flush(vs); vnc_read_when(vs, protocol_client_msg, 1); ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
[Qemu-devel] [PATCH] Improve -pidfile option
Howdy, The following patch improves the -pidfile a fair bit. -pidfile isn't terribly usable at the moment with -daemonize as the wrong pid gets written to the file. Furthermore, there's a race in -pidfile between the stat() and initial create. For a management tool, there's no 100% reliable way to know whether there's a stale pidfile or whether another QEMU process is running. The attached patch uses a common technique for dealing with pidfiles. An advisory lock is taken once the pidfile is opened. The nice thing about advisory locks is that the file is unlocked if a process dies. This allows for a truly atomic pidfile to be implemented. AFAIK, lockf() exists on Windows. I do not know if it works as one would expect though. Regards, Anthony Liguori diff -r 58621c427a39 vl.c --- a/vl.c Sat Mar 03 21:06:59 2007 -0600 +++ b/vl.c Sat Mar 03 21:15:21 2007 -0600 @@ -4387,44 +4387,24 @@ void usb_info(void) } } -/***/ -/* pid file */ - -static char *pid_filename; - -/* Remove PID file. Called on normal exit */ - -static void remove_pidfile(void) -{ -unlink (pid_filename); -} - -static void create_pidfile(const char *filename) -{ -struct stat pidstat; -FILE *f; - -/* Try to write our PID to the named file */ -if (stat(filename, pidstat) 0) { -if (errno == ENOENT) { -if ((f = fopen (filename, w)) == NULL) { -perror(Opening pidfile); -exit(1); -} -fprintf(f, %d\n, getpid()); -fclose(f); -pid_filename = qemu_strdup(filename); -if (!pid_filename) { -fprintf(stderr, Could not save PID filename); -exit(1); -} -atexit(remove_pidfile); -} -} else { -fprintf(stderr, %s already exists. Remove it and try again.\n, -filename); -exit(1); -} +static int create_pidfile(const char *filename) +{ +int fd; +char buffer[128]; +int len; + +fd = open(filename, O_RDWR | O_CREAT, 0600); +if (fd == -1) + return -1; + +if (lockf(fd, F_TLOCK, 0) == -1) + return -1; + +len = snprintf(buffer, sizeof(buffer), %ld\n, (long)getpid()); +if (write(fd, buffer, len) != len) + return -1; + +return 0; } /***/ @@ -6874,6 +6854,7 @@ int main(int argc, char **argv) char usb_devices[MAX_USB_CMDLINE][128]; int usb_devices_index; int fds[2]; +const char *pid_file = NULL; LIST_INIT (vm_change_state_head); #ifndef _WIN32 @@ -7263,7 +7244,7 @@ int main(int argc, char **argv) break; #endif case QEMU_OPTION_pidfile: -create_pidfile(optarg); + pid_file = optarg; break; #ifdef TARGET_I386 case QEMU_OPTION_win2k_hack: @@ -7353,9 +7334,12 @@ int main(int argc, char **argv) if (len == -1 (errno == EINTR)) goto again; - if (len != 1 || status != 0) + if (len != 1) exit(1); - else + else if (status == 1) { + fprintf(stderr, Could not acquire pidfile\n); + exit(1); + } else exit(0); } else if (pid 0) exit(1); @@ -7376,6 +7360,15 @@ int main(int argc, char **argv) signal(SIGTTIN, SIG_IGN); } #endif + +if (pid_file create_pidfile(pid_file) != 0) { + if (daemonize) { + uint8_t status = 1; + write(fds[1], status, 1); + } else + fprintf(stderr, Could not acquire pid file\n); + exit(1); +} #ifdef USE_KQEMU if (smp_cpus 1) ___ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel
[Qemu-devel] [PATCH] Add info commands for serial/parallel devices
Howdy, The following patch adds an info serial and an info parallel command. Besides providing useful information (especially for the serial port), it provides a method for management tools to connect to a running VM and what character devices the serial/parallel ports have been redirected to. The format of the info is similar to that of info block. Regards, Anthony Liguori diff -r 18e99d1e8814 hw/parallel.c --- a/hw/parallel.c Sat Mar 03 21:18:48 2007 -0600 +++ b/hw/parallel.c Sat Mar 03 21:33:07 2007 -0600 @@ -73,6 +73,11 @@ struct ParallelState { uint32_t last_read_offset; /* For debugging */ }; +void do_info_parallel_device(ParallelState *s) +{ +term_printf( filename=%s, s-chr-filename); +} + static void parallel_update_irq(ParallelState *s) { if (s-irq_pending) diff -r 18e99d1e8814 hw/pc.c --- a/hw/pc.c Sat Mar 03 21:18:48 2007 -0600 +++ b/hw/pc.c Sat Mar 03 21:33:07 2007 -0600 @@ -442,6 +442,34 @@ static void pc_init_ne2k_isa(NICInfo *nd nb_ne2k++; } +static SerialState *serial_devices[MAX_SERIAL_PORTS]; + +void do_info_serial(void) +{ +int i; +for (i = 0; i MAX_SERIAL_PORTS; i++) { + if (serial_devices[i]) { + term_printf(serial%d:, i); + do_info_serial_device(serial_devices[i]); + term_printf(\n); + } +} +} + +static ParallelState *parallel_devices[MAX_PARALLEL_PORTS]; + +void do_info_parallel(void) +{ +int i; +for (i = 0; i MAX_PARALLEL_PORTS; i++) { + if (parallel_devices[i]) { + term_printf(parallel%d:, i); + do_info_parallel_device(parallel_devices[i]); + term_printf(\n); + } +} +} + /* PC hardware initialisation */ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, DisplayState *ds, const char **fd_filename, int snapshot, @@ -668,14 +696,14 @@ static void pc_init1(int ram_size, int v for(i = 0; i MAX_SERIAL_PORTS; i++) { if (serial_hds[i]) { -serial_init(pic_set_irq_new, isa_pic, -serial_io[i], serial_irq[i], serial_hds[i]); +serial_devices[i] = serial_init(pic_set_irq_new, isa_pic, + serial_io[i], serial_irq[i], serial_hds[i]); } } for(i = 0; i MAX_PARALLEL_PORTS; i++) { if (parallel_hds[i]) { -parallel_init(parallel_io[i], parallel_irq[i], parallel_hds[i]); +parallel_devices[i] = parallel_init(parallel_io[i], parallel_irq[i], parallel_hds[i]); } } diff -r 18e99d1e8814 hw/serial.c --- a/hw/serial.c Sat Mar 03 21:18:48 2007 -0600 +++ b/hw/serial.c Sat Mar 03 21:33:07 2007 -0600 @@ -92,6 +92,31 @@ struct SerialState { int it_shift; }; +void do_info_serial_device(SerialState *s) +{ +int parity; + +if (!s) + return; + +term_printf( filename=); +term_print_filename(s-chr-filename); + +if (s-lcr 0x08) { + if (s-lcr 0x10) + parity = 'E'; + else + parity = 'O'; +} else + parity = 'N'; + +if (s-divider) + term_printf( speed=%d, 115200 / s-divider); +term_printf( parity=%c, parity); +term_printf( data bits=%d, (s-lcr 0x03) + 5); +term_printf( stop bits=%d, (s-lcr 0x04) ? 2 : 1); +} + static void serial_update_irq(SerialState *s) { if ((s-lsr UART_LSR_DR) (s-ier UART_IER_RDI)) { diff -r 18e99d1e8814 monitor.c --- a/monitor.c Sat Mar 03 21:18:48 2007 -0600 +++ b/monitor.c Sat Mar 03 21:33:07 2007 -0600 @@ -1311,6 +1311,10 @@ static term_cmd_t info_cmds[] = { , show the vnc server status}, { name, , do_info_name, , show the current VM name }, +{ serial, , do_info_serial, + , show serial device information }, +{ parallel, , do_info_parallel, + , show parallel device information }, { NULL, NULL, }, }; diff -r 18e99d1e8814 vl.c --- a/vl.c Sat Mar 03 21:18:48 2007 -0600 +++ b/vl.c Sat Mar 03 21:33:07 2007 -0600 @@ -2884,66 +2884,73 @@ CharDriverState *qemu_chr_open(const cha CharDriverState *qemu_chr_open(const char *filename) { const char *p; +CharDriverState *chr; if (!strcmp(filename, vc)) { -return text_console_init(display_state); +chr = text_console_init(display_state); } else if (!strcmp(filename, null)) { -return qemu_chr_open_null(); +chr = qemu_chr_open_null(); } else if (strstart(filename, tcp:, p)) { -return qemu_chr_open_tcp(p, 0, 0); +chr = qemu_chr_open_tcp(p, 0, 0); } else if (strstart(filename, telnet:, p)) { -return qemu_chr_open_tcp(p, 1, 0); +chr = qemu_chr_open_tcp(p, 1, 0); } else if (strstart(filename, udp:, p)) { -return qemu_chr_open_udp(p); +chr = qemu_chr_open_udp(p); } else if (strstart(filename, mon:, p)) { CharDriverState *drv = qemu_chr_open(p); if (drv) { drv = qemu_chr_open_mux(drv); monitor_init(drv, !nographic); -return drv; -} -printf(Unable to open driver: %s\n, p); -
[Qemu-devel] [PATCH] Enhance monitor change command
Howdy, The following patch allows the change monitor command to be used with vnc, serial, and parallel devices. It depends on my previously posted patches. The patch implements: 1) A vnc null display 2) The ability to reopen character devices 3) Appropriate tab expansions for devices This patch is quite useful for management tools as it allows much more flexibility in allowing the user to configure running instances. Regards, Anthony Liguori diff -r 6b23d9afec55 console.c --- a/console.c Sat Mar 03 21:35:55 2007 -0600 +++ b/console.c Sat Mar 03 21:42:27 2007 -0600 @@ -1155,16 +1155,12 @@ int is_graphic_console(void) return !active_console-text_console; } -CharDriverState *text_console_init(DisplayState *ds) -{ -CharDriverState *chr; +CharDriverState *text_console_init(CharDriverState *chr, DisplayState *ds) +{ TextConsole *s; int i,j; static int color_inited; -chr = qemu_mallocz(sizeof(CharDriverState)); -if (!chr) -return NULL; s = new_console(ds, 1); if (!s) { free(chr); diff -r 6b23d9afec55 monitor.c --- a/monitor.c Sat Mar 03 21:35:55 2007 -0600 +++ b/monitor.c Sat Mar 03 21:58:55 2007 -0600 @@ -372,7 +372,7 @@ static void do_eject(int force, const ch eject_device(bs, force); } -static void do_change(const char *device, const char *filename) +static void do_change_block(const char *device, const char *filename) { BlockDriverState *bs; int i; @@ -395,6 +395,33 @@ static void do_change(const char *device term_printf(invalid password\n); } } +} + +static void do_change(const char *device, const char *target) +{ +const char *p; + +if (strcmp(device, vnc) == 0) { + if (vnc_display_open(NULL, target) == -1) + term_printf(could not start VNC server on %s\n, target); +} else if (strstart(device, serial, p)) { + int index = atoi(p); + if (index 0 || index = MAX_SERIAL_PORTS) { + term_printf(Invalid serial device %d\n, index); + return; + } + if (qemu_chr_open2(serial_hds[index], target) == NULL) + term_printf(Could not reopen serial device\n); +} else if (strstart(device, parallel, p)) { + int index = atoi(p); + if (index 0 || index = MAX_PARALLEL_PORTS) { + term_printf(Invalid parallel device %d\n, index); + return; + } + if (qemu_chr_open2(parallel_hds[index], target) == NULL) + term_printf(Could not reopen serial device\n); +} else + do_change_block(device, target); } static void do_screen_dump(const char *filename) @@ -1205,8 +1232,8 @@ static term_cmd_t term_cmds[] = { , quit the emulator }, { eject, -fB, do_eject, [-f] device, eject a removable media (use -f to force it) }, -{ change, BF, do_change, - device filename, change a removable media }, +{ change, DF, do_change, + device filename, change a device target }, { screendump, F, do_screen_dump, filename, save screen into PPM image 'filename' }, { log, s, do_log, @@ -1988,6 +2015,7 @@ static void monitor_handle_command(const switch(c) { case 'F': case 'B': + case 'D': case 's': { int ret; @@ -2012,6 +2040,9 @@ static void monitor_handle_command(const case 'B': term_printf(%s: block device name expected\n, cmdname); break; + case 'D': + term_printf(%s: device name expected\n, cmdname); + break; default: term_printf(%s: string expected\n, cmdname); break; @@ -2312,7 +2343,7 @@ static void file_completion(const char * closedir(ffs); } -static void block_completion_it(void *opaque, const char *name) +static void device_completion_it(void *opaque, const char *name) { const char *input = opaque; @@ -2320,6 +2351,26 @@ static void block_completion_it(void *op !strncmp(name, (char *)input, strlen(input))) { add_completion(name); } +} + +static void device_iterate(void (*it)(void *opaque, const char *name), void *opaque) +{ +char buf[128]; +int i; + +bdrv_iterate(it, opaque); + +for (i = 0; i MAX_SERIAL_PORTS; i++) { + snprintf(buf, sizeof(buf), serial%d, i); + it(opaque, buf); +} + +for (i = 0; i MAX_SERIAL_PORTS; i++) { + snprintf(buf, sizeof(buf), parallel%d, i); + it(opaque, buf); +} + +it(opaque, vnc); } /* NOTE: this parser is an approximate form of the real command parser */ @@ -2408,8 +2459,13 @@ void readline_find_completion(const char case 'B': /* block device name completion */ completion_index = strlen(str); -bdrv_iterate(block_completion_it, (void *)str); -break; +bdrv_iterate(device_completion_it, (void *)str); +break; + case 'D': + /* device name completion */ + completion_index = strlen(str); + device_iterate(device_completion_it, (void