qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Glauber de Oliveira Costa" <glommer@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] boot a linux kernel from non-ide device
Date: Fri, 8 Feb 2008 05:05:13 -0200	[thread overview]
Message-ID: <5d6222a80802072305t2d536595q97d169df9dc00a48@mail.gmail.com> (raw)

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

             reply	other threads:[~2008-02-08  7:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-08  7:05 Glauber de Oliveira Costa [this message]
2008-02-08 14:55 ` [Qemu-devel] [PATCH] boot a linux kernel from non-ide device Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d6222a80802072305t2d536595q97d169df9dc00a48@mail.gmail.com \
    --to=glommer@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).