[prev in list] [next in list] [prev in thread] [next in thread] 

List:       qemu-devel
Subject:    [Qemu-devel] [PATCH] Add -boot n option for x86 using PXE
From:       Anthony Liguori <aliguori () cs ! utexas ! edu>
Date:       2006-12-27 17:19:57
Message-ID: 4592AB3D.5000609 () cs ! utexas ! edu
[Download RAW message or body]

Howdy,

The following patch enables -boot n for x86 using etherboot PXE ROMs.  
It depends on my previous -option-rom patch.

Essentially, if -boot n is specified, the set of NICs is searched and 
the patch looks for a ROM named pxe-<model>.bin in the BIOS path.  When 
one is found, it is added as an option rom.

Besides applying this patch, three ROMs will have to be added to 
pc-bios/.  I'd suggest getting them from http://www.rom-o-matic.net.  
You'll need ROMs for:

pcnet32:pcnet32 -- [0x1022,0x2000]
ns8390:winbond940 -- [0x1050,0x0940]
rtl8139:rtl8139 -- [0x10ec,0x8139]

And they should be named:

pxe-pcnet.bin
pxe-ne2k_pci.bin
pxe-rtl8139.bin

Right now, I have it limited to TARGET_I386 as I'm not sure whether 
other platforms support PXE booting.  I also think this is a little 
hacky so if anyone has a better suggestion I'd appreciate hearing it.

Regards,

Anthony Liguori

["qemu-pxe.diff" (text/x-patch)]

diff -r a46a54f7808d Makefile
--- a/Makefile	Sat Dec 23 16:29:19 2006 -0600
+++ b/Makefile	Sat Dec 23 16:29:21 2006 -0600
@@ -79,7 +79,8 @@ install: all $(if $(BUILD_DOCS),install-
 	$(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
 	mkdir -p "$(DESTDIR)$(datadir)"
 	for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
-			video.x openbios-sparc32 linux_boot.bin; do \
+		video.x openbios-sparc32 linux_boot.bin pxe-ne2k_pci.bin \
+		pxe-rtl8139.bin pxe-pcnet.bin; do \
 		$(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
 	done
 ifndef CONFIG_WIN32
diff -r a46a54f7808d pc-bios/README
--- a/pc-bios/README	Sat Dec 23 16:29:19 2006 -0600
+++ b/pc-bios/README	Sat Dec 23 16:29:21 2006 -0600
@@ -14,3 +14,9 @@
 - OpenBIOS (http://www.openbios.org/) is a free (GPL v2) portable
   firmware implementation. The goal is to implement a 100% IEEE
   1275-1994 (referred to as Open Firmware) compliant firmware.
+
+- The PXE roms come from Rom-o-Matic etherboot 5.4.2.
+  pcnet32:pcnet32 -- [0x1022,0x2000]
+  ns8390:winbond940 -- [0x1050,0x0940]
+  rtl8139:rtl8139 -- [0x10ec,0x8139]
+  http://rom-o-matic.net/
diff -r a46a54f7808d qemu-doc.texi
--- a/qemu-doc.texi	Sat Dec 23 16:29:19 2006 -0600
+++ b/qemu-doc.texi	Sat Dec 23 16:29:21 2006 -0600
@@ -219,9 +219,9 @@ Use @var{file} as CD-ROM image (you cann
 @option{-cdrom} at the same time). You can use the host CD-ROM by
 using @file{/dev/cdrom} as filename (@pxref{host_drives}).
 
-@item -boot [a|c|d]
-Boot on floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is
-the default.
+@item -boot [a|c|d|n]
+Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard disk boot
+is the default.
 
 @item -disk ide,img=file[,hdx=a..dd][,type=disk|cdrom]
 Use @var{file} as the IDE disk/CD-ROM image. The defaults are: hdx=a,type=disk
diff -r a46a54f7808d vl.c
--- a/vl.c	Sat Dec 23 16:29:19 2006 -0600
+++ b/vl.c	Sat Dec 23 16:29:52 2006 -0600
@@ -6111,7 +6111,7 @@ void help(void)
            "-hda/-hdb file  use 'file' as IDE hard disk 0/1 image\n"
            "-hdc/-hdd file  use 'file' as IDE hard disk 2/3 image\n"
            "-cdrom file     use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
-           "-boot [a|c|d]   boot on floppy (a), hard disk (c) or CD-ROM (d)\n"
+           "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n"
            "-disk ide,img=file[,hdx=a..dd][,type=disk|cdrom] \n"
            "                defaults are: hdx=a,type=disk \n"
            "-disk scsi,img=file[,sdx=a..g][,type=disk|cdrom][,id=n]  \n"
@@ -6910,7 +6910,7 @@ int main(int argc, char **argv)
             case QEMU_OPTION_boot:
                 boot_device = optarg[0];
                 if (boot_device != 'a' && 
-#ifdef TARGET_SPARC
+#if defined(TARGET_SPARC) || defined(TARGET_I386)
 		    // Network boot
 		    boot_device != 'n' &&
 #endif
@@ -7231,6 +7231,28 @@ int main(int argc, char **argv)
             exit(1);
     }
 
+#ifdef TARGET_I386
+    if (boot_device == 'n') {
+	for (i = 0; i < nb_nics; i++) {
+	    const char *model = nd_table[i].model;
+	    char buf[1024];
+	    if (model == NULL)
+		model = "ne2k_pci";
+	    snprintf(buf, sizeof(buf), "%s/pxe-%s.bin", bios_dir, model);
+	    if (get_image_size(buf) > 0) {
+		option_rom[nb_option_roms] = strdup(buf);
+		nb_option_roms++;
+		break;
+	    }
+	}
+	if (i == nb_nics) {
+	    fprintf(stderr, "No valid PXE rom found for network device\n");
+	    exit(1);
+	}
+	boot_device = 'c'; /* to prevent confusion by the BIOS */
+    }
+#endif
+
     /* init the memory */
     phys_ram_size = ram_size + vga_ram_size + bios_size;
 


_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic