ia64/xen-unstable

changeset 11227:fc3e7e65b953

[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@redhat.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author Christian Limpach <Christian.Limpach@xensource.com>
date Sun Aug 20 23:33:28 2006 +0100 (2006-08-20)
parents 45a84091144e
children 639c5eff0f5a
files tools/examples/xmexample.hvm tools/examples/xmexample.vti tools/ioemu/hw/pc.c tools/ioemu/vl.c tools/ioemu/vl.h
line diff
     1.1 --- a/tools/examples/xmexample.hvm	Sun Aug 20 17:55:33 2006 +0100
     1.2 +++ b/tools/examples/xmexample.hvm	Sun Aug 20 23:33:28 2006 +0100
     1.3 @@ -116,7 +116,9 @@ device_model = '/usr/' + arch_libdir + '
     1.4  
     1.5  #-----------------------------------------------------------------------------
     1.6  # boot on floppy (a), hard disk (c) or CD-ROM (d) 
     1.7 -#boot=[a|c|d]
     1.8 +# default: hard disk, cd-rom, floppy
     1.9 +#boot="cda"
    1.10 +
    1.11  #-----------------------------------------------------------------------------
    1.12  #  write to temporary files instead of disk image files
    1.13  #snapshot=1
     2.1 --- a/tools/examples/xmexample.vti	Sun Aug 20 17:55:33 2006 +0100
     2.2 +++ b/tools/examples/xmexample.vti	Sun Aug 20 23:33:28 2006 +0100
     2.3 @@ -75,7 +75,9 @@ memmap = '/usr/lib/xen/boot/mem-map.sxp'
     2.4  
     2.5  #-----------------------------------------------------------------------------
     2.6  # boot on floppy (a), hard disk (c) or CD-ROM (d) 
     2.7 -#boot=[a|c|d]
     2.8 +# default: hard disk, cd-rom, floppy
     2.9 +#boot="cda"
    2.10 +
    2.11  #-----------------------------------------------------------------------------
    2.12  #  write to temporary files instead of disk image files
    2.13  #snapshot=1
     3.1 --- a/tools/ioemu/hw/pc.c	Sun Aug 20 17:55:33 2006 +0100
     3.2 +++ b/tools/ioemu/hw/pc.c	Sun Aug 20 23:33:28 2006 +0100
     3.3 @@ -158,8 +158,23 @@ static void cmos_init_hd(int type_ofs, i
     3.4      rtc_set_memory(s, info_ofs + 8, sectors);
     3.5  }
     3.6  
     3.7 +static int get_bios_disk(char *boot_device, int index) {
     3.8 +
     3.9 +    if (index < strlen(boot_device)) {
    3.10 +        switch (boot_device[index]) {
    3.11 +        case 'a':
    3.12 +            return 0x01;            /* floppy */
    3.13 +        case 'c':
    3.14 +            return 0x02;            /* hard drive */
    3.15 +        case 'd':
    3.16 +            return 0x03;            /* cdrom */
    3.17 +        }
    3.18 +    }
    3.19 +    return 0x00;                /* no device */
    3.20 +}
    3.21 +
    3.22  /* hd_table must contain 4 block drivers */
    3.23 -static void cmos_init(uint64_t ram_size, int boot_device, BlockDriverState **hd_table, time_t timeoffset)
    3.24 +static void cmos_init(uint64_t ram_size, char *boot_device, BlockDriverState **hd_table, time_t timeoffset)
    3.25  {
    3.26      RTCState *s = rtc_state;
    3.27      int val;
    3.28 @@ -205,21 +220,14 @@ static void cmos_init(uint64_t ram_size,
    3.29      rtc_set_memory(s, 0x34, val);
    3.30      rtc_set_memory(s, 0x35, val >> 8);
    3.31      
    3.32 -    switch(boot_device) {
    3.33 -    case 'a':
    3.34 -    case 'b':
    3.35 -        rtc_set_memory(s, 0x3d, 0x01); /* floppy boot */
    3.36 -        if (!fd_bootchk)
    3.37 -            rtc_set_memory(s, 0x38, 0x01); /* disable signature check */
    3.38 -        break;
    3.39 -    default:
    3.40 -    case 'c':
    3.41 -        rtc_set_memory(s, 0x3d, 0x02); /* hard drive boot */
    3.42 -        break;
    3.43 -    case 'd':
    3.44 -        rtc_set_memory(s, 0x3d, 0x03); /* CD-ROM boot */
    3.45 -        break;
    3.46 +    if (boot_device == NULL) {
    3.47 +        /* default to hd, then cd, then floppy. */
    3.48 +        boot_device = "cda";
    3.49      }
    3.50 +    rtc_set_memory(s, 0x3d, get_bios_disk(boot_device, 0) |
    3.51 +                   (get_bios_disk(boot_device, 1) << 4));
    3.52 +    rtc_set_memory(s, 0x38, (get_bios_disk(boot_device, 2) << 4) |
    3.53 +                   (!fd_bootchk ? 0x01 : 0x00));
    3.54  
    3.55      /* floppy type */
    3.56  
    3.57 @@ -617,7 +625,7 @@ static void pc_init_ne2k_isa(NICInfo *nd
    3.58  #define NOBIOS 1
    3.59  
    3.60  /* PC hardware initialisation */
    3.61 -static void pc_init1(uint64_t ram_size, int vga_ram_size, int boot_device,
    3.62 +static void pc_init1(uint64_t ram_size, int vga_ram_size, char *boot_device,
    3.63                       DisplayState *ds, const char **fd_filename, int snapshot,
    3.64                       const char *kernel_filename, const char *kernel_cmdline,
    3.65                       const char *initrd_filename, time_t timeoffset,
    3.66 @@ -919,7 +927,7 @@ static void pc_init1(uint64_t ram_size, 
    3.67      }
    3.68  }
    3.69  
    3.70 -static void pc_init_pci(uint64_t ram_size, int vga_ram_size, int boot_device,
    3.71 +static void pc_init_pci(uint64_t ram_size, int vga_ram_size, char *boot_device,
    3.72                          DisplayState *ds, const char **fd_filename, 
    3.73                          int snapshot, 
    3.74                          const char *kernel_filename, 
    3.75 @@ -933,7 +941,7 @@ static void pc_init_pci(uint64_t ram_siz
    3.76               initrd_filename, timeoffset, 1);
    3.77  }
    3.78  
    3.79 -static void pc_init_isa(uint64_t ram_size, int vga_ram_size, int boot_device,
    3.80 +static void pc_init_isa(uint64_t ram_size, int vga_ram_size, char *boot_device,
    3.81                          DisplayState *ds, const char **fd_filename, 
    3.82                          int snapshot, 
    3.83                          const char *kernel_filename, 
     4.1 --- a/tools/ioemu/vl.c	Sun Aug 20 17:55:33 2006 +0100
     4.2 +++ b/tools/ioemu/vl.c	Sun Aug 20 23:33:28 2006 +0100
     4.3 @@ -124,7 +124,7 @@ int vncviewer;
     4.4  int vncunused;
     4.5  const char* keyboard_layout = NULL;
     4.6  int64_t ticks_per_sec;
     4.7 -int boot_device = 'c';
     4.8 +char *boot_device = NULL;
     4.9  uint64_t ram_size;
    4.10  int pit_min_timer_count = 0;
    4.11  int nb_nics;
    4.12 @@ -6057,14 +6057,14 @@ int main(int argc, char **argv)
    4.13                  break;
    4.14  #endif /* !CONFIG_DM */
    4.15              case QEMU_OPTION_boot:
    4.16 -                boot_device = optarg[0];
    4.17 -                if (boot_device != 'a' && 
    4.18 +                boot_device = strdup(optarg);
    4.19 +                if (strspn(boot_device, "acd"
    4.20  #ifdef TARGET_SPARC
    4.21 -		    // Network boot
    4.22 -		    boot_device != 'n' &&
    4.23 +                           "n"
    4.24  #endif
    4.25 -                    boot_device != 'c' && boot_device != 'd') {
    4.26 -                    fprintf(stderr, "qemu: invalid boot device '%c'\n", boot_device);
    4.27 +                        ) != strlen(boot_device)) {
    4.28 +                    fprintf(stderr, "qemu: invalid boot device in '%s'\n",
    4.29 +                            boot_device);
    4.30                      exit(1);
    4.31                  }
    4.32                  break;
    4.33 @@ -6328,6 +6328,7 @@ int main(int argc, char **argv)
    4.34          fd_filename[0] == '\0')
    4.35          help();
    4.36      
    4.37 +#if 0
    4.38      /* boot to cd by default if no hard disk */
    4.39      if (hd_filename[0] == '\0' && boot_device == 'c') {
    4.40          if (fd_filename[0] != '\0')
    4.41 @@ -6335,6 +6336,7 @@ int main(int argc, char **argv)
    4.42          else
    4.43              boot_device = 'd';
    4.44      }
    4.45 +#endif
    4.46  #endif /* !CONFIG_DM */
    4.47  
    4.48      setvbuf(stdout, NULL, _IOLBF, 0);
    4.49 @@ -6593,6 +6595,7 @@ int main(int argc, char **argv)
    4.50                    ds, fd_filename, snapshot,
    4.51                    kernel_filename, kernel_cmdline, initrd_filename,
    4.52                    timeoffset);
    4.53 +    free(boot_device);
    4.54  
    4.55      /* init USB devices */
    4.56      if (usb_enabled) {
     5.1 --- a/tools/ioemu/vl.h	Sun Aug 20 17:55:33 2006 +0100
     5.2 +++ b/tools/ioemu/vl.h	Sun Aug 20 23:33:28 2006 +0100
     5.3 @@ -575,7 +575,7 @@ int qcow_compress_cluster(BlockDriverSta
     5.4  #ifndef QEMU_TOOL
     5.5  
     5.6  typedef void QEMUMachineInitFunc(uint64_t ram_size, int vga_ram_size, 
     5.7 -                                 int boot_device,
     5.8 +                                 char *boot_device,
     5.9               DisplayState *ds, const char **fd_filename, int snapshot,
    5.10               const char *kernel_filename, const char *kernel_cmdline,
    5.11               const char *initrd_filename, time_t timeoffset);
    5.12 @@ -1020,7 +1020,7 @@ void NVRAM_set_crc (m48t59_t *nvram, uin
    5.13                      uint32_t start, uint32_t count);
    5.14  int PPC_NVRAM_set_params (m48t59_t *nvram, uint16_t NVRAM_size,
    5.15                            const unsigned char *arch,
    5.16 -                          uint32_t RAM_size, int boot_device,
    5.17 +                          uint32_t RAM_size, char *boot_device,
    5.18                            uint32_t kernel_image, uint32_t kernel_size,
    5.19                            const char *cmdline,
    5.20                            uint32_t initrd_image, uint32_t initrd_size,