From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DQchz-0006v8-94 for qemu-devel@nongnu.org; Tue, 26 Apr 2005 22:55:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DQchv-0006uv-OX for qemu-devel@nongnu.org; Tue, 26 Apr 2005 22:55:27 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DQchv-0006ud-Jl for qemu-devel@nongnu.org; Tue, 26 Apr 2005 22:55:23 -0400 Received: from [195.188.213.8] (helo=smtp-out5.blueyonder.co.uk) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DQckV-0004TF-4O for qemu-devel@nongnu.org; Tue, 26 Apr 2005 22:58:03 -0400 Message-ID: <426EFED4.8090002@blueyonder.co.uk> Date: Wed, 27 Apr 2005 03:54:12 +0100 From: Ross Kendall Axe MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig3A13230ADC44E02A63AE48B5" Subject: [Qemu-devel] [patch] Remove requirement for -hda with -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 an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig3A13230ADC44E02A63AE48B5 Content-Type: multipart/mixed; boundary="------------070208020302080001070603" This is a multi-part message in MIME format. --------------070208020302080001070603 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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 --------------070208020302080001070603 Content-Type: text/x-patch; name="qemu-linux-nohda.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qemu-linux-nohda.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 27 Apr 2005 02:29:20 -0000 @@ -446,8 +446,26 @@ 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); + char template[] = "/tmp/qemu.XXXXXX"; + int tmpfile = mkstemp(template); + + fprintf(stderr, "qemu: Disk image not given for 'hda' when booting" + " a Linux kernel; inventing one\n"); + if(tmpfile == -1) { + fprintf(stderr, "qemu: couldn't create temporary diskimage\n"); + exit(1); + } + lseek(tmpfile, 511, SEEK_SET); + write(tmpfile, "", 1); + bs_table[0] = bdrv_new("hda"); + if (bdrv_open(bs_table[0], template, snapshot) < 0) { + fprintf(stderr, "qemu: could not load temporary diskimage '%s'\n", + template); + exit(1); + } + close(tmpfile); + unlink(template); + boot_device = 'c'; } snprintf(buf, sizeof(buf), "%s/%s", bios_dir, LINUX_BOOT_FILENAME); ret = load_image(buf, bootsect); --------------070208020302080001070603-- --------------enig3A13230ADC44E02A63AE48B5 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 iD8DBQFCbv7Y9bR4xmappRARAhi+AKChcBEYruZpsiJRdXfSiVajzbiCWgCeMX80 CavG3DFp8ZKBgoioG6HWP8c= =/gVA -----END PGP SIGNATURE----- --------------enig3A13230ADC44E02A63AE48B5--