Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DRJgO-0003RZ-W2 for qemu-devel@nongnu.org; Thu, 28 Apr 2005 20:48:41 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DRJgN-0003RN-H6 for qemu-devel@nongnu.org; Thu, 28 Apr 2005 20:48:40 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DRJgN-0003EZ-Fj for qemu-devel@nongnu.org; Thu, 28 Apr 2005 20:48:39 -0400 Received: from [82.36.124.90] (helo=lucy.axe.homelinux.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DRJjI-00073U-LH for qemu-devel@nongnu.org; Thu, 28 Apr 2005 20:51:41 -0400 Received: from [192.168.0.3] (purplehaze [192.168.0.3]) by lucy.axe.homelinux.net (Postfix) with ESMTP id 090C024349 for ; Fri, 29 Apr 2005 01:47:20 +0100 (BST) Message-ID: <42718404.1030107@axe.homelinux.net> Date: Fri, 29 Apr 2005 01:47:00 +0100 From: Ross Kendall Axe MIME-Version: 1.0 Subject: Re: [Qemu-devel] [patch] Remove requirement for -hda with -kernel References: <426EFED4.8090002@blueyonder.co.uk> <42713F2E.9070505@bellard.org> In-Reply-To: <42713F2E.9070505@bellard.org> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig2019A6B3379E58DE0F66307A" 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 an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2019A6B3379E58DE0F66307A Content-Type: multipart/mixed; boundary="------------070204010007070306000302" This is a multi-part message in MIME format. --------------070204010007070306000302 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Fabrice Bellard wrote: > > Ross Kendall Axe wrote: > >> The requirement to provide an -hda argument when doing a direct boot of >> a linux kernel has irritated me for some time. This patch removes that >> requirement by creating a temporary 1 sector hda as needed. >> >> Ross > > I like the idea, but your patch may not compile for win32. Maybe > creating a generic "dummy:[size]" block device would be interesting > instead ? > > Fabrice. Good point. It wouldn't compile, and, even if it did, it wouldn't run correctly. Attached is a patch that *should* work. The dummy block device idea is interesting. I'll see if I can implement that; hopefully it won't be too difficult. However, IHMO a better, albeit more ambitious solution would be to load the Linux boot code into an emulated boot PROM. Ross --------------070204010007070306000302 Content-Type: text/x-patch; name="qemu-linux-nohda-v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-linux-nohda-v2.patch" Index: hw/pc.c =================================================================== RCS file: /cvsroot/qemu/qemu/hw/pc.c,v retrieving revision 1.35 diff -u -p -r1.35 pc.c --- hw/pc.c 15 Jan 2005 12:02:56 -0000 1.35 +++ hw/pc.c 28 Apr 2005 23:36:13 -0000 @@ -446,8 +446,40 @@ void pc_init(int ram_size, int vga_ram_s uint8_t old_bootsect[512]; if (bs_table[0] == NULL) { - fprintf(stderr, "A disk image must be given for 'hda' when booting a Linux kernel\n"); - exit(1); +#ifdef WIN32 + char tmpfilename[L_tmpnam]; +#else + char tmpfilename[] = "/tmp/qemu.XXXXXX"; + int tmpfilefd; +#endif + FILE *tmpfile; + + fprintf(stderr, "qemu: Disk image not given for 'hda' when booting" + " a Linux kernel; inventing one\n"); +#ifdef WIN32 + tmpnam(tmpfilename); + tmpfile = fopen(tmpfilename, "wb"); +#else + tmpfilefd = mkstemp(tmpfilename); + tmpfile = (tmpfilefd == -1) ? NULL : fdopen(tmpfilefd, "wb"); +#endif + if(!tmpfile) { + fprintf(stderr, "qemu: couldn't create temporary diskimage\n"); + exit(1); + } + fseek(tmpfile, 511, SEEK_SET); + fputc('0', tmpfile); + fclose(tmpfile); + bs_table[0] = bdrv_new("hda"); + if (bdrv_open(bs_table[0], tmpfilename, 0) < 0) { + fprintf(stderr, "qemu: could not load temporary diskimage '%s'\n", + tmpfilename); + exit(1); + } +#ifndef WIN32 + unlink(tmpfilename); +#endif + boot_device = 'c'; } snprintf(buf, sizeof(buf), "%s/%s", bios_dir, LINUX_BOOT_FILENAME); ret = load_image(buf, bootsect); --------------070204010007070306000302-- --------------enig2019A6B3379E58DE0F66307A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.7 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCcYQX9bR4xmappRARAvunAKCEbbXDUhXZUYF9dVLdQCdVP18qLwCg2nDY 2nPc+H+P+/yscWX+khkF8gk= =g2BB -----END PGP SIGNATURE----- --------------enig2019A6B3379E58DE0F66307A--