All of lore.kernel.org
 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
       [not found] ` <5d6222a80802072305t2d536595q97d169df9dc00a48-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 2 replies; 4+ 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] 4+ 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
       [not found] ` <5d6222a80802072305t2d536595q97d169df9dc00a48-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  1 sibling, 0 replies; 4+ 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] 4+ messages in thread

* Fwd: [PATCH] boot a linux kernel from non-ide device
       [not found] ` <5d6222a80802072305t2d536595q97d169df9dc00a48-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-02-08 15:42   ` Glauber de Oliveira Costa
       [not found]     ` <5d6222a80802080742t3dfca5bs7894648af5d528a3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Glauber de Oliveira Costa @ 2008-02-08 15:42 UTC (permalink / raw)
  To: kvm-devel, Anthony Liguori

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

Reposting to kvm-devel, since aliguori notices that I'm relying on
non-upstream features of qemu

---------- Forwarded message ----------
From: Glauber de Oliveira Costa <glommer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Feb 8, 2008 5:05 AM
Subject: [PATCH] boot a linux kernel from non-ide device
To: qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org


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



-- 
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,

[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

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

* Re: Fwd: [PATCH] boot a linux kernel from non-ide device
       [not found]     ` <5d6222a80802080742t3dfca5bs7894648af5d528a3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2008-02-08 16:30       ` Anthony Liguori
  0 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2008-02-08 16:30 UTC (permalink / raw)
  To: Glauber de Oliveira Costa; +Cc: kvm-devel

This patch seems reasonable to me.

But FWIW, with extboot, it's possible to implement the -kernel option in 
a saner way.  extboot already has code to take over int19 and load a 
kernel from memory on boot.  It was based on the old -kernel support in 
QEMU (prior to hpa's rewrite) so it's not enabled at the moment.  It 
should be pretty easy to update it though.

This approach would allow -kernel to be used without any disk (which 
also solves your problem, but in a different way).  We can also 
eliminate all the boot sector hijacking silliness.

Regards,

Anthony Liguori

Glauber de Oliveira Costa wrote:
> Reposting to kvm-devel, since aliguori notices that I'm relying on
> non-upstream features of qemu
>
> ---------- Forwarded message ----------
> From: Glauber de Oliveira Costa <glommer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Date: Feb 8, 2008 5:05 AM
> Subject: [PATCH] boot a linux kernel from non-ide device
> To: qemu-devel-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
>
>
> 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."
>
>
>
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

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

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

Thread overview: 4+ 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
     [not found] ` <5d6222a80802072305t2d536595q97d169df9dc00a48-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-02-08 15:42   ` Fwd: " Glauber de Oliveira Costa
     [not found]     ` <5d6222a80802080742t3dfca5bs7894648af5d528a3-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-02-08 16:30       ` Anthony Liguori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.