commit 65b8fcf3bc5b754b720a04fa7efed6fdcd472a6a Author: Glauber de Oliveira Costa Date: Fri Feb 8 05:02:47 2008 -0200 [PATCH] boot a linux kernel from non-ide device Since it's now possible to use the -drive option, the test for something in the index 0 of the IDE bus is too restrictive. A better idea, IMHO, is to check if the user specified any bootable device, and only if not, fallback to the default, compatible behaviour of checking hda regardless of the presence of a boot=on arg. diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c index 5ce28ab..a9b0f71 100644 --- a/qemu/hw/pc.c +++ b/qemu/hw/pc.c @@ -398,11 +398,14 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) { uint8_t bootsect[512], *p; int i; - int hda; - - hda = drive_get_index(IF_IDE, 0, 0); - if (hda == -1) { - fprintf(stderr, "A disk image must be given for 'hda' when booting " + int hda = -1, boot_device; + + if (extboot_drive != -1) + boot_device = extboot_drive; + else if ((hda = drive_get_index(IF_IDE, 0, 0)) != -1) + boot_device = hda; + else { + fprintf(stderr, "A bootable disk image must be given when booting " "a Linux kernel\n"); exit(1); } @@ -410,7 +413,7 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) memset(bootsect, 0, sizeof(bootsect)); /* Copy the MSDOS partition table if possible */ - bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1); + bdrv_read(drives_table[boot_device].bdrv, 0, bootsect, 1); /* Make sure we have a partition signature */ bootsect[510] = 0x55; @@ -447,7 +450,7 @@ static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip) *p++ = segs[1]; /* CS */ *p++ = segs[1] >> 8; - bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect)); + bdrv_set_boot_sector(drives_table[boot_device].bdrv, bootsect, sizeof(bootsect)); } static int load_kernel(const char *filename, uint8_t *addr,