qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] boot a linux kernel from non-ide device
@ 2008-02-08  7:05 Glauber de Oliveira Costa
  2008-02-08 14:55 ` Anthony Liguori
  0 siblings, 1 reply; 2+ messages in thread
From: Glauber de Oliveira Costa @ 2008-02-08  7:05 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 461 bytes --]

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.

-- 
Glauber de Oliveira Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qemu.patch --]
[-- Type: text/x-patch; name=qemu.patch, Size: 2048 bytes --]

commit 65b8fcf3bc5b754b720a04fa7efed6fdcd472a6a
Author: Glauber de Oliveira Costa <gcosta@redhat.com>
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,

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

* Re: [Qemu-devel] [PATCH] boot a linux kernel from non-ide device
  2008-02-08  7:05 [Qemu-devel] [PATCH] boot a linux kernel from non-ide device Glauber de Oliveira Costa
@ 2008-02-08 14:55 ` Anthony Liguori
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Liguori @ 2008-02-08 14:55 UTC (permalink / raw)
  To: qemu-devel

Glauber de Oliveira Costa wrote:
> 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.
>   

extboot isn't in upstream QEMU yet so this patch won't apply.

Regards,

Anthony LIguori

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

end of thread, other threads:[~2008-02-08 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-08  7:05 [Qemu-devel] [PATCH] boot a linux kernel from non-ide device Glauber de Oliveira Costa
2008-02-08 14:55 ` Anthony Liguori

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).