Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JskYc-0007hq-WF for qemu-devel@nongnu.org; Sun, 04 May 2008 16:11:39 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JskYc-0007hZ-AQ for qemu-devel@nongnu.org; Sun, 04 May 2008 16:11:38 -0400 Received: from [199.232.76.173] (port=33702 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JskYc-0007hU-7D for qemu-devel@nongnu.org; Sun, 04 May 2008 16:11:38 -0400 Received: from savannah.gnu.org ([199.232.41.3] helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JskYb-0005kp-UL for qemu-devel@nongnu.org; Sun, 04 May 2008 16:11:38 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1JskYb-0006Y4-0L for qemu-devel@nongnu.org; Sun, 04 May 2008 20:11:37 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1JskYa-0006Y0-6v for qemu-devel@nongnu.org; Sun, 04 May 2008 20:11:36 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Sun, 04 May 2008 20:11:36 +0000 Subject: [Qemu-devel] [4333] Allow bootdevice change from the monitor Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 4333 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4333 Author: aurel32 Date: 2008-05-04 20:11:34 +0000 (Sun, 04 May 2008) Log Message: ----------- Allow bootdevice change from the monitor (Gildas Le Nadan) Modified Paths: -------------- trunk/hw/hw.h trunk/hw/pc.c trunk/monitor.c trunk/qemu-doc.texi trunk/vl.c Modified: trunk/hw/hw.h =================================================================== --- trunk/hw/hw.h 2008-05-04 15:47:15 UTC (rev 4332) +++ trunk/hw/hw.h 2008-05-04 20:11:34 UTC (rev 4333) @@ -92,6 +92,12 @@ void qemu_register_reset(QEMUResetHandler *func, void *opaque); +/* handler to set the boot_device for a specific type of QEMUMachine */ +/* return 0 if success */ +typedef int QEMUBootSetHandler(const char *boot_device); +extern QEMUBootSetHandler *qemu_boot_set_handler; +void qemu_register_boot_set(QEMUBootSetHandler *func); + /* These should really be in isa.h, but are here to make pc.h happy. */ typedef void (IOPortWriteFunc)(void *opaque, uint32_t address, uint32_t data); typedef uint32_t (IOPortReadFunc)(void *opaque, uint32_t address); Modified: trunk/hw/pc.c =================================================================== --- trunk/hw/pc.c 2008-05-04 15:47:15 UTC (rev 4332) +++ trunk/hw/pc.c 2008-05-04 20:11:34 UTC (rev 4333) @@ -189,6 +189,33 @@ return 0; } +/* copy/pasted from cmos_init, should be made a general function + and used there as well */ +int pc_boot_set(const char *boot_device) +{ +#define PC_MAX_BOOT_DEVICES 3 + RTCState *s = rtc_state; + int nbds, bds[3] = { 0, }; + int i; + + nbds = strlen(boot_device); + if (nbds > PC_MAX_BOOT_DEVICES) { + term_printf("Too many boot devices for PC\n"); + return(1); + } + for (i = 0; i < nbds; i++) { + bds[i] = boot_device2nibble(boot_device[i]); + if (bds[i] == 0) { + term_printf("Invalid boot device for PC: '%c'\n", + boot_device[i]); + return(1); + } + } + rtc_set_memory(s, 0x3d, (bds[1] << 4) | bds[0]); + rtc_set_memory(s, 0x38, (bds[2] << 4)); + return(0); +} + /* hd_table must contain 4 block drivers */ static void cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, BlockDriverState **hd_table) @@ -713,6 +740,8 @@ below_4g_mem_size = ram_size; } + qemu_register_boot_set(pc_boot_set); + linux_boot = (kernel_filename != NULL); /* init CPUs */ Modified: trunk/monitor.c =================================================================== --- trunk/monitor.c 2008-05-04 15:47:15 UTC (rev 4332) +++ trunk/monitor.c 2008-05-04 20:11:34 UTC (rev 4333) @@ -1019,6 +1019,21 @@ suffix, addr, size * 2, val); } +static void do_boot_set(const char *bootdevice) +{ + int res; + + if (qemu_boot_set_handler) { + res = qemu_boot_set_handler(bootdevice); + if (res == 0) + term_printf("boot device list now set to %s\n", bootdevice); + else + term_printf("setting boot device list failed with error %i\n", res); + } else { + term_printf("no function defined to set boot device list for this architecture\n"); + } +} + static void do_system_reset(void) { qemu_system_reset_request(); @@ -1369,6 +1384,8 @@ "addr size file", "save to disk virtual memory dump starting at 'addr' of size 'size'", }, { "pmemsave", "lis", do_physical_memory_save, "addr size file", "save to disk physical memory dump starting at 'addr' of size 'size'", }, + { "boot_set", "s", do_boot_set, + "bootdevice", "define new values for the boot device list" }, #if defined(TARGET_I386) { "nmi", "i", do_inject_nmi, "cpu", "inject an NMI on the given CPU", }, Modified: trunk/qemu-doc.texi =================================================================== --- trunk/qemu-doc.texi 2008-05-04 15:47:15 UTC (rev 4332) +++ trunk/qemu-doc.texi 2008-05-04 20:11:34 UTC (rev 4333) @@ -1259,6 +1259,14 @@ Reset the system. +@item boot_set @var{bootdevicelist} + +Define new values for the boot device list. Those values will override +the values specified on the command line through the @code{-boot} option. + +The values that can be specified here depend on the machine type, but are +the same that can be specified in the @code{-boot} command line option. + @item usb_add @var{devname} Add the USB device @var{devname}. For details of available devices see Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-05-04 15:47:15 UTC (rev 4332) +++ trunk/vl.c 2008-05-04 20:11:34 UTC (rev 4333) @@ -6855,6 +6855,14 @@ cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT); } +/* boot_set handler */ +QEMUBootSetHandler *qemu_boot_set_handler = NULL; + +void qemu_register_boot_set(QEMUBootSetHandler *func) +{ + qemu_boot_set_handler = func; +} + void main_loop_wait(int timeout) { IOHandlerRecord *ioh;