From: Ross Kendall Axe <ross@axe.homelinux.net>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [patch] Remove requirement for -hda with -kernel
Date: Fri, 29 Apr 2005 01:47:00 +0100 [thread overview]
Message-ID: <42718404.1030107@axe.homelinux.net> (raw)
In-Reply-To: <42713F2E.9070505@bellard.org>
[-- Attachment #1.1: Type: text/plain, Size: 809 bytes --]
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
[-- Attachment #1.2: qemu-linux-nohda-v2.patch --]
[-- Type: text/x-patch, Size: 1758 bytes --]
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);
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]
next prev parent reply other threads:[~2005-04-29 0:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-27 2:54 [Qemu-devel] [patch] Remove requirement for -hda with -kernel Ross Kendall Axe
2005-04-28 19:53 ` Fabrice Bellard
2005-04-29 0:47 ` Ross Kendall Axe [this message]
2005-04-29 21:56 ` Ross Kendall Axe
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=42718404.1030107@axe.homelinux.net \
--to=ross@axe.homelinux.net \
--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).