From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] Use extboot to support -kernel
Date: Wed, 05 Dec 2007 16:07:04 -0600 [thread overview]
Message-ID: <47572108.70603@us.ibm.com> (raw)
In-Reply-To: <4757209E.4020102@us.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 376 bytes --]
This patch uses the extboot option ROM to support -kernel. Instead of
hijacking the first boot sector of the first IDE drive, we use extboot
to read the boot sector from an in-memory block device. This eliminates
the need to have an IDE device (or any device) configured when using
-kernel.
This depends on the extboot series I posted today.
Regards,
Anthony Liguori
[-- Attachment #2: extboot-kernel.diff --]
[-- Type: text/x-patch, Size: 1927 bytes --]
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c 2007-12-05 15:53:35.000000000 -0600
+++ qemu/hw/pc.c 2007-12-05 15:59:32.000000000 -0600
@@ -383,20 +383,26 @@
static void generate_bootsect(uint32_t gpr[8], uint16_t segs[6], uint16_t ip)
{
uint8_t bootsect[512], *p;
- int i;
- int hda;
+ BlockDriverState *bs;
+ int i, cyls, heads, secs;
- hda = drive_get_index(IF_IDE, 0, 0);
- if (hda == -1) {
- fprintf(stderr, "A disk image must be given for 'hda' when booting "
- "a Linux kernel\n");
+ /* Create a device with at least one cylinder */
+ bs = bdrv_new("mem");
+ if (bdrv_mem_open(bs, 63 * 512) == -1) {
+ fprintf(stderr, "Error initializing memory block device\n");
exit(1);
}
- memset(bootsect, 0, sizeof(bootsect));
-
/* Copy the MSDOS partition table if possible */
- bdrv_read(drives_table[hda].bdrv, 0, bootsect, 1);
+ bdrv_read(bs, 0, bootsect, 1);
+
+ /* Setup extboot to boot from the memory block device */
+ bdrv_guess_geometry(bs, &cyls, &heads, &secs);
+ bdrv_set_geometry_hint(bs, cyls, heads, secs);
+ extboot_init(bs, 1);
+
+ /* Prevent double initialization */
+ extboot_drive = -1;
/* Make sure we have a partition signature */
bootsect[510] = 0x55;
@@ -433,7 +439,7 @@
*p++ = segs[1]; /* CS */
*p++ = segs[1] >> 8;
- bdrv_set_boot_sector(drives_table[hda].bdrv, bootsect, sizeof(bootsect));
+ bdrv_write(bs, 0, bootsect, 1);
}
static int load_kernel(const char *filename, uint8_t *addr,
@@ -834,7 +840,7 @@
for (i = 0; i < nb_option_roms; i++)
opt_rom_offset += load_option_rom(option_rom[i], opt_rom_offset);
- if (extboot_drive != -1) {
+ if (extboot_drive != -1 || linux_boot) {
snprintf(buf, sizeof(buf), "%s/%s", bios_dir, EXTBOOT_FILENAME);
opt_rom_offset += load_option_rom(buf, opt_rom_offset);
}
prev parent reply other threads:[~2007-12-05 22:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-05 22:05 [Qemu-devel] [PATCH 1/2] Add an in-memory block device Anthony Liguori
2007-12-05 22:07 ` Anthony Liguori [this message]
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=47572108.70603@us.ibm.com \
--to=aliguori@us.ibm.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 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.