WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [qemu] Allow booting from more than one d

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [qemu] Allow booting from more than one device.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 21 Aug 2006 00:20:18 +0000
Delivery-date: Sun, 20 Aug 2006 17:20:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Christian Limpach <Christian.Limpach@xxxxxxxxxxxxx>
# Node ID fc3e7e65b9530bf1c0fe7a7f12320edd8a656185
# Parent  45a84091144e26ce326b32d8bb661a788ab2685e
[qemu] Allow booting from more than one device.
The rombios supports trying to boot from more than one device and then
falling back.  Set 'boot=dc' in your config file to try booting first
from the CD and then the hard drive.

Based on a patch from: Jeremy Katz <katzj@xxxxxxxxxx>
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxxx>
---
 tools/examples/xmexample.hvm |    4 ++-
 tools/examples/xmexample.vti |    4 ++-
 tools/ioemu/hw/pc.c          |   46 +++++++++++++++++++++++++------------------
 tools/ioemu/vl.c             |   19 ++++++++++-------
 tools/ioemu/vl.h             |    4 +--
 5 files changed, 46 insertions(+), 31 deletions(-)

diff -r 45a84091144e -r fc3e7e65b953 tools/examples/xmexample.hvm
--- a/tools/examples/xmexample.hvm      Sun Aug 20 17:55:33 2006 +0100
+++ b/tools/examples/xmexample.hvm      Sun Aug 20 23:33:28 2006 +0100
@@ -116,7 +116,9 @@ device_model = '/usr/' + arch_libdir + '
 
 #-----------------------------------------------------------------------------
 # boot on floppy (a), hard disk (c) or CD-ROM (d) 
-#boot=[a|c|d]
+# default: hard disk, cd-rom, floppy
+#boot="cda"
+
 #-----------------------------------------------------------------------------
 #  write to temporary files instead of disk image files
 #snapshot=1
diff -r 45a84091144e -r fc3e7e65b953 tools/examples/xmexample.vti
--- a/tools/examples/xmexample.vti      Sun Aug 20 17:55:33 2006 +0100
+++ b/tools/examples/xmexample.vti      Sun Aug 20 23:33:28 2006 +0100
@@ -75,7 +75,9 @@ memmap = '/usr/lib/xen/boot/mem-map.sxp'
 
 #-----------------------------------------------------------------------------
 # boot on floppy (a), hard disk (c) or CD-ROM (d) 
-#boot=[a|c|d]
+# default: hard disk, cd-rom, floppy
+#boot="cda"
+
 #-----------------------------------------------------------------------------
 #  write to temporary files instead of disk image files
 #snapshot=1
diff -r 45a84091144e -r fc3e7e65b953 tools/ioemu/hw/pc.c
--- a/tools/ioemu/hw/pc.c       Sun Aug 20 17:55:33 2006 +0100
+++ b/tools/ioemu/hw/pc.c       Sun Aug 20 23:33:28 2006 +0100
@@ -158,8 +158,23 @@ static void cmos_init_hd(int type_ofs, i
     rtc_set_memory(s, info_ofs + 8, sectors);
 }
 
+static int get_bios_disk(char *boot_device, int index) {
+
+    if (index < strlen(boot_device)) {
+        switch (boot_device[index]) {
+        case 'a':
+            return 0x01;            /* floppy */
+        case 'c':
+            return 0x02;            /* hard drive */
+        case 'd':
+            return 0x03;            /* cdrom */
+        }
+    }
+    return 0x00;                /* no device */
+}
+
 /* hd_table must contain 4 block drivers */
-static void cmos_init(uint64_t ram_size, int boot_device, BlockDriverState 
**hd_table, time_t timeoffset)
+static void cmos_init(uint64_t ram_size, char *boot_device, BlockDriverState 
**hd_table, time_t timeoffset)
 {
     RTCState *s = rtc_state;
     int val;
@@ -205,21 +220,14 @@ static void cmos_init(uint64_t ram_size,
     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 */
-        if (!fd_bootchk)
-            rtc_set_memory(s, 0x38, 0x01); /* disable signature check */
-        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;
-    }
+    if (boot_device == NULL) {
+        /* default to hd, then cd, then floppy. */
+        boot_device = "cda";
+    }
+    rtc_set_memory(s, 0x3d, get_bios_disk(boot_device, 0) |
+                   (get_bios_disk(boot_device, 1) << 4));
+    rtc_set_memory(s, 0x38, (get_bios_disk(boot_device, 2) << 4) |
+                   (!fd_bootchk ? 0x01 : 0x00));
 
     /* floppy type */
 
@@ -617,7 +625,7 @@ static void pc_init_ne2k_isa(NICInfo *nd
 #define NOBIOS 1
 
 /* PC hardware initialisation */
-static void pc_init1(uint64_t ram_size, int vga_ram_size, int boot_device,
+static void pc_init1(uint64_t ram_size, int vga_ram_size, char *boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, time_t timeoffset,
@@ -919,7 +927,7 @@ static void pc_init1(uint64_t ram_size, 
     }
 }
 
-static void pc_init_pci(uint64_t ram_size, int vga_ram_size, int boot_device,
+static void pc_init_pci(uint64_t ram_size, int vga_ram_size, char *boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 
@@ -933,7 +941,7 @@ static void pc_init_pci(uint64_t ram_siz
              initrd_filename, timeoffset, 1);
 }
 
-static void pc_init_isa(uint64_t ram_size, int vga_ram_size, int boot_device,
+static void pc_init_isa(uint64_t ram_size, int vga_ram_size, char *boot_device,
                         DisplayState *ds, const char **fd_filename, 
                         int snapshot, 
                         const char *kernel_filename, 
diff -r 45a84091144e -r fc3e7e65b953 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Sun Aug 20 17:55:33 2006 +0100
+++ b/tools/ioemu/vl.c  Sun Aug 20 23:33:28 2006 +0100
@@ -124,7 +124,7 @@ int vncunused;
 int vncunused;
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
-int boot_device = 'c';
+char *boot_device = NULL;
 uint64_t ram_size;
 int pit_min_timer_count = 0;
 int nb_nics;
@@ -6057,14 +6057,14 @@ int main(int argc, char **argv)
                 break;
 #endif /* !CONFIG_DM */
             case QEMU_OPTION_boot:
-                boot_device = optarg[0];
-                if (boot_device != 'a' && 
+                boot_device = strdup(optarg);
+                if (strspn(boot_device, "acd"
 #ifdef TARGET_SPARC
-                   // Network boot
-                   boot_device != 'n' &&
-#endif
-                    boot_device != 'c' && boot_device != 'd') {
-                    fprintf(stderr, "qemu: invalid boot device '%c'\n", 
boot_device);
+                           "n"
+#endif
+                        ) != strlen(boot_device)) {
+                    fprintf(stderr, "qemu: invalid boot device in '%s'\n",
+                            boot_device);
                     exit(1);
                 }
                 break;
@@ -6328,6 +6328,7 @@ int main(int argc, char **argv)
         fd_filename[0] == '\0')
         help();
     
+#if 0
     /* boot to cd by default if no hard disk */
     if (hd_filename[0] == '\0' && boot_device == 'c') {
         if (fd_filename[0] != '\0')
@@ -6335,6 +6336,7 @@ int main(int argc, char **argv)
         else
             boot_device = 'd';
     }
+#endif
 #endif /* !CONFIG_DM */
 
     setvbuf(stdout, NULL, _IOLBF, 0);
@@ -6593,6 +6595,7 @@ int main(int argc, char **argv)
                   ds, fd_filename, snapshot,
                   kernel_filename, kernel_cmdline, initrd_filename,
                   timeoffset);
+    free(boot_device);
 
     /* init USB devices */
     if (usb_enabled) {
diff -r 45a84091144e -r fc3e7e65b953 tools/ioemu/vl.h
--- a/tools/ioemu/vl.h  Sun Aug 20 17:55:33 2006 +0100
+++ b/tools/ioemu/vl.h  Sun Aug 20 23:33:28 2006 +0100
@@ -575,7 +575,7 @@ int qcow_compress_cluster(BlockDriverSta
 #ifndef QEMU_TOOL
 
 typedef void QEMUMachineInitFunc(uint64_t ram_size, int vga_ram_size, 
-                                 int boot_device,
+                                 char *boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
              const char *initrd_filename, time_t timeoffset);
@@ -1020,7 +1020,7 @@ void NVRAM_set_crc (m48t59_t *nvram, uin
                     uint32_t start, uint32_t count);
 int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
                           const unsigned char *arch,
-                          uint32_t RAM_size, int boot_device,
+                          uint32_t RAM_size, char *boot_device,
                           uint32_t kernel_image, uint32_t kernel_size,
                           const char *cmdline,
                           uint32_t initrd_image, uint32_t initrd_size,

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [qemu] Allow booting from more than one device., Xen patchbot-unstable <=