qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [patch] Remove requirement for -hda with -kernel
@ 2005-04-27  2:54 Ross Kendall Axe
  2005-04-28 19:53 ` Fabrice Bellard
  0 siblings, 1 reply; 4+ messages in thread
From: Ross Kendall Axe @ 2005-04-27  2:54 UTC (permalink / raw)
  To: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 210 bytes --]

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

[-- Attachment #1.2: qemu-linux-nohda.patch --]
[-- Type: text/x-patch, Size: 1478 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	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);

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-05-01 17:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2005-04-29 21:56   ` Ross Kendall Axe

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).