qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] change boot device in monitor
@ 2004-10-10  8:31 Anand Kumria
  2004-10-10 14:26 ` Johannes Schindelin
  0 siblings, 1 reply; 3+ messages in thread
From: Anand Kumria @ 2004-10-10  8:31 UTC (permalink / raw)
  To: qemu-devel


Hi,

Attached is a patch which allows you to change the boot device in the
monitor. The change won't take affect until the next 'system_reset' but
I've found it useful as I can specify a floppy, hard disk and cdrom and
switch between booting them without exiting.

This is against current CVS - I've only tested this on x86 but I've put in
what I think are the right hooks for PPC and Sparc.  When looking at this,
I was thinking that a struct vm_state might be useful.

As I'm now going to be working on a way to modify the memory amount within
the monitor. The struct_vm would basically be the what is used for
savevm/loadvm. Thoughts?

Regards,
Anand

diff -x qemu.pod -X dont-diff -urN upstream/hw/pc.c my-chg-boot/hw/pc.c
--- upstream/hw/pc.c	2004-10-10 02:47:59.000000000 +1000
+++ my-chg-boot/hw/pc.c	2004-10-10 17:02:39.000000000 +1000
@@ -101,6 +101,26 @@
     return val;
 }
 
+
+void boot_device_set(int boot_device)
+{
+  RTCState *s = rtc_state;
+
+  switch(boot_device) {
+  case 'a':
+  case 'b':
+    rtc_set_memory(s, 0x3d, 0x01); /* floppy boot */
+    break;
+  default:
+  case 'c':
+    rtc_set_memory(s, 0x3d, 0x02); /* hard drive boot */
+    break;
+  case 'd':
+    rtc_set_memory(s, 0x3d, 0x03); /* CD-ROM boot */
+    break;
+  }
+}
+
 static void cmos_init_hd(int type_ofs, int info_ofs, BlockDriverState *hd) 
 {
     RTCState *s = rtc_state;
@@ -163,21 +183,9 @@
         val = 65535;
     rtc_set_memory(s, 0x34, val);
     rtc_set_memory(s, 0x35, val >> 8);
-    
-    switch(boot_device) {
-    case 'a':
-    case 'b':
-        rtc_set_memory(s, 0x3d, 0x01); /* floppy boot */
-        break;
-    default:
-    case 'c':
-        rtc_set_memory(s, 0x3d, 0x02); /* hard drive boot */
-        break;
-    case 'd':
-        rtc_set_memory(s, 0x3d, 0x03); /* CD-ROM boot */
-        break;
-    }
-
+ 
+    boot_device_set(boot_device);
+   
     /* floppy type */
 
     fd0 = fdctrl_get_drive_type(floppy_controller, 0);
diff -x qemu.pod -X dont-diff -urN upstream/hw/ppc.c my-chg-boot/hw/ppc.c
--- upstream/hw/ppc.c	2004-06-22 02:53:42.000000000 +1000
+++ my-chg-boot/hw/ppc.c	2004-10-10 15:12:50.000000000 +1000
@@ -398,6 +398,11 @@
     return crc;
 }
 
+static void boot_device_set(m48t59_t *nvram, int boot_device)
+{
+    NVRAM_set_byte(nvram,   0x34, boot_device);
+}
+
 #define CMDLINE_ADDR 0x017ff000
 
 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
@@ -417,7 +422,7 @@
     NVRAM_set_word(nvram,   0x14, NVRAM_size);
     NVRAM_set_string(nvram, 0x20, arch, 16);
     NVRAM_set_lword(nvram,  0x30, RAM_size);
-    NVRAM_set_byte(nvram,   0x34, boot_device);
+    boot_device_set(nvram, boot_device);
     NVRAM_set_lword(nvram,  0x38, kernel_image);
     NVRAM_set_lword(nvram,  0x3C, kernel_size);
     if (cmdline) {
diff -x qemu.pod -X dont-diff -urN upstream/monitor.c my-chg-boot/monitor.c
--- upstream/monitor.c	2004-10-10 04:08:01.000000000 +1000
+++ my-chg-boot/monitor.c	2004-10-10 17:00:50.000000000 +1000
@@ -173,6 +173,28 @@
     }
 }
 
+static void do_boot(const char *boot_from)
+{
+  switch(boot_from[0]) {
+  case 'a':
+  case 'b':
+  case 'c':
+  case 'd':
+#ifdef TARGET_PPC    
+    term_printf("not implemented for PPC\n");
+#elif TARGET_SPARC
+    term_printf("not implemented for Sparc\n");
+#else
+    boot_device_set(boot_from[0]);
+#endif
+    break;
+  default:
+    term_printf("boot device must be one of: a, b, c or d\n");
+    break;
+  }
+
+}
+
 static void do_info(const char *item)
 {
     term_cmd_t *cmd;
@@ -821,6 +843,8 @@
 static term_cmd_t term_cmds[] = {
     { "help|?", "s?", do_help, 
       "[cmd]", "show the help" },
+    { "boot", "s", do_boot,
+      "device", "change the boot device (takes affect next system_reset)" },
     { "commit", "", do_commit, 
       "", "commit changes to the disk images (if -snapshot is used)" },
     { "info", "s?", do_info,
diff -x qemu.pod -X dont-diff -urN upstream/vl.h my-chg-boot/vl.h
--- upstream/vl.h	2004-10-05 07:23:09.000000000 +1000
+++ my-chg-boot/vl.h	2004-10-10 16:27:42.000000000 +1000
@@ -638,7 +638,16 @@
 int pit_get_gate(PITState *pit, int channel);
 int pit_get_out(PITState *pit, int channel, int64_t current_time);
 
+/* pc.c and ppc.c */
+#ifdef TARGET_PPC
+#include "hw/m48t59.h"
+void boot_device_set(m48t59_t *nvram, int boot_device);
+#else /* TARGET_PC */
+void boot_device_set(int boot_device);
+#endif 
+
 /* pc.c */
+
 void pc_init(int ram_size, int vga_ram_size, int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] change boot device in monitor
  2004-10-10  8:31 [Qemu-devel] change boot device in monitor Anand Kumria
@ 2004-10-10 14:26 ` Johannes Schindelin
  2004-10-10 16:05   ` [Qemu-devel] " Anand Kumria
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Schindelin @ 2004-10-10 14:26 UTC (permalink / raw)
  To: qemu-devel

Hi,

On Sun, 10 Oct 2004, Anand Kumria wrote:

> Attached is a patch which allows you to change the boot device in the
> monitor. The change won't take affect until the next 'system_reset' but
> I've found it useful as I can specify a floppy, hard disk and cdrom and
> switch between booting them without exiting.

I like this feature! (Also your "info version").

> As I'm now going to be working on a way to modify the memory amount within
> the monitor. The struct_vm would basically be the what is used for
> savevm/loadvm. Thoughts?

Well, I prefer to specify the memory on the command line. Of course, if
you loadvm with a different size, this does not work AFAIK, but IMHO it
does not make sense to support virtual hot-plugging of memory ;-)

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] Re: change boot device in monitor
  2004-10-10 14:26 ` Johannes Schindelin
@ 2004-10-10 16:05   ` Anand Kumria
  0 siblings, 0 replies; 3+ messages in thread
From: Anand Kumria @ 2004-10-10 16:05 UTC (permalink / raw)
  To: qemu-devel

On Sun, 10 Oct 2004 16:26:43 +0200, Johannes Schindelin wrote:

> Hi,
> 
> On Sun, 10 Oct 2004, Anand Kumria wrote:
> 
>> Attached is a patch which allows you to change the boot device in the
>> monitor. The change won't take affect until the next 'system_reset' but
>> I've found it useful as I can specify a floppy, hard disk and cdrom and
>> switch between booting them without exiting.
> 
> I like this feature! (Also your "info version").

Thanks - I hope Fabrice does also.

>> As I'm now going to be working on a way to modify the memory amount within
>> the monitor. The struct_vm would basically be the what is used for
>> savevm/loadvm. Thoughts?
> 
> Well, I prefer to specify the memory on the command line. Of course, if
> you loadvm with a different size, this does not work AFAIK, but IMHO it
> does not make sense to support virtual hot-plugging of memory ;-)

The reason I want to be able to do this is to support testing installer
disks and operating systems with varying amounts of memory.  Since qemu
can be forked and have the monitor available to another process as
stdin/stdout it means I can setup regressions test for memory points.

Cheers,
Anand

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-10-10 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-10  8:31 [Qemu-devel] change boot device in monitor Anand Kumria
2004-10-10 14:26 ` Johannes Schindelin
2004-10-10 16:05   ` [Qemu-devel] " Anand Kumria

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).