From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J02Oy-0000Q1-1R for qemu-devel@nongnu.org; Wed, 05 Dec 2007 17:07:32 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J02Ow-0000Ok-FH for qemu-devel@nongnu.org; Wed, 05 Dec 2007 17:07:31 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J02Ov-0000Ob-I6 for qemu-devel@nongnu.org; Wed, 05 Dec 2007 17:07:29 -0500 Received: from e2.ny.us.ibm.com ([32.97.182.142]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1J02Ov-00082x-4z for qemu-devel@nongnu.org; Wed, 05 Dec 2007 17:07:29 -0500 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e2.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id lB5M7Fhr024518 for ; Wed, 5 Dec 2007 17:07:15 -0500 Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v8.7) with ESMTP id lB5M7FQW1323148 for ; Wed, 5 Dec 2007 17:07:15 -0500 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id lB5M759I016292 for ; Wed, 5 Dec 2007 15:07:05 -0700 Received: from [9.53.41.166] (squirrel-009053041166.austin.ibm.com [9.53.41.166]) by d03av03.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id lB5M759t016275 for ; Wed, 5 Dec 2007 15:07:05 -0700 Message-ID: <47572108.70603@us.ibm.com> Date: Wed, 05 Dec 2007 16:07:04 -0600 From: Anthony Liguori MIME-Version: 1.0 References: <4757209E.4020102@us.ibm.com> In-Reply-To: <4757209E.4020102@us.ibm.com> Content-Type: multipart/mixed; boundary="------------000900050609020602070304" Subject: [Qemu-devel] [PATCH 2/2] Use extboot to support -kernel Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------000900050609020602070304 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------000900050609020602070304 Content-Type: text/x-patch; name="extboot-kernel.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="extboot-kernel.diff" 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); } --------------000900050609020602070304--