aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-04 20:11:34 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2008-05-04 20:11:34 +0000
commit0ecdffbb60a2723779a37fa17b717d919d670336 (patch)
tree17aff64cd35df25fee555574ee67af87c5e48ff2
parent4001a81e8e1af1e4bda63baa404a8ebb4919d1f9 (diff)
downloadqemu-0ecdffbb60a2723779a37fa17b717d919d670336.zip
qemu-0ecdffbb60a2723779a37fa17b717d919d670336.tar.gz
qemu-0ecdffbb60a2723779a37fa17b717d919d670336.tar.bz2
Allow bootdevice change from the monitor
(Gildas Le Nadan) git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4333 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--hw/hw.h6
-rw-r--r--hw/pc.c29
-rw-r--r--monitor.c17
-rw-r--r--qemu-doc.texi8
-rw-r--r--vl.c8
5 files changed, 68 insertions, 0 deletions
diff --git a/hw/hw.h b/hw/hw.h
index 3589ade..2a46102 100644
--- a/hw/hw.h
+++ b/hw/hw.h
@@ -92,6 +92,12 @@ typedef void QEMUResetHandler(void *opaque);
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);
diff --git a/hw/pc.c b/hw/pc.c
index 5d5a764..265ced4 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -189,6 +189,33 @@ static int boot_device2nibble(char boot_device)
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 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
below_4g_mem_size = ram_size;
}
+ qemu_register_boot_set(pc_boot_set);
+
linux_boot = (kernel_filename != NULL);
/* init CPUs */
diff --git a/monitor.c b/monitor.c
index fab3f71..236b827 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1019,6 +1019,21 @@ static void do_ioport_read(int count, int format, int size, int addr, int has_in
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 @@ static term_cmd_t term_cmds[] = {
"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", },
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 1f409f4..527d3b6 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -1259,6 +1259,14 @@ intercepts at low level, such as @code{ctrl-alt-f1} in X Window.
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
diff --git a/vl.c b/vl.c
index 1795db3..30d31cc 100644
--- a/vl.c
+++ b/vl.c
@@ -6855,6 +6855,14 @@ void qemu_system_powerdown_request(void)
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;