* [Qemu-devel] [PATCH] Add -option-rom option to allow loading of PCI option ROMs
@ 2006-12-27 3:27 Anthony Liguori
2006-12-27 13:30 ` Fabrice Bellard
0 siblings, 1 reply; 3+ messages in thread
From: Anthony Liguori @ 2006-12-27 3:27 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 916 bytes --]
Howdy,
The following patch adds an -option-rom option to allow loading of PCI
option ROMs. This is useful for loading things like etherboot or VMI.
For instance, using an etherboot ROM[1] from http://rom-o-matic.net/,
one can use the following command line to PXE boot QEMU:
qemu -hda ~/mydisk.img -option-rom ~/eb-5.4.2-winbond940.zrom
This is also useful for loading a VMI option ROM for experimenting with
paravirtualization. Not terribly useful ATM of course.
BTW, I have another patch that would add the etherboot ROMs to the QEMU
distribution for all the NICs and then plumb up -boot n to allow PXE
booting. Is there any interest in a patch like this? This would
increase the QEMU distribution size by 96k.
[1]
http://rom-o-matic.net/5.4.2/build.php?version=5.4.2&F=&arch=i386&nic=ns830:winbond940%20--%20[0x1050,0x0940]&ofmt=Binary%20ROM%20Image(.zrom)&A=Get%20ROM
Regards,
Anthony Liguori
[-- Attachment #2: qemu-option-rom.diff --]
[-- Type: text/x-patch, Size: 4295 bytes --]
diff -r 0a200f17f93e hw/pc.c
--- a/hw/pc.c Sat Dec 23 16:28:52 2006 -0600
+++ b/hw/pc.c Sat Dec 23 16:28:54 2006 -0600
@@ -451,7 +451,7 @@ static void pc_init1(int ram_size, int v
{
char buf[1024];
int ret, linux_boot, initrd_size, i;
- unsigned long bios_offset, vga_bios_offset;
+ unsigned long bios_offset, vga_bios_offset, option_rom_offset;
int bios_size, isa_bios_size;
PCIBus *pci_bus;
int piix3_devfn = -1;
@@ -518,6 +518,23 @@ static void pc_init1(int ram_size, int v
cpu_register_physical_memory(0x100000 - isa_bios_size,
isa_bios_size,
(bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
+
+ option_rom_offset = 0;
+ for (i = 0; i < nb_option_roms; i++) {
+ int offset = bios_offset + bios_size + option_rom_offset;
+ int size;
+
+ size = load_image(option_rom[i], phys_ram_base + offset);
+ if ((size + option_rom_offset) > 0x10000) {
+ fprintf(stderr, "Too many option ROMS\n");
+ exit(1);
+ }
+ cpu_register_physical_memory(0xd0000 + option_rom_offset,
+ size, offset | IO_MEM_ROM);
+ option_rom_offset += size + 2047;
+ option_rom_offset -= (option_rom_offset % 2048);
+ }
+
/* map all the bios at the top of memory */
cpu_register_physical_memory((uint32_t)(-bios_size),
bios_size, bios_offset | IO_MEM_ROM);
diff -r 0a200f17f93e qemu-doc.texi
--- a/qemu-doc.texi Sat Dec 23 16:28:52 2006 -0600
+++ b/qemu-doc.texi Sat Dec 23 16:28:54 2006 -0600
@@ -325,6 +325,10 @@ Use it when installing Windows 2000 to a
Use it when installing Windows 2000 to avoid a disk full bug. After
Windows 2000 is installed, you no longer need this option (this option
slows down the IDE transfers).
+
+@item -option-rom file
+Load the contents of file as an option ROM. This option is useful to load
+things like EtherBoot.
@end table
diff -r 0a200f17f93e vl.c
--- a/vl.c Sat Dec 23 16:28:52 2006 -0600
+++ b/vl.c Sat Dec 23 16:29:15 2006 -0600
@@ -169,6 +169,8 @@ int fd_bootchk = 1;
int fd_bootchk = 1;
int no_reboot = 0;
int daemonize = 0;
+const char *option_rom[MAX_OPTION_ROMS];
+int nb_option_roms;
/***********************************************************/
/* x86 ISA bus support */
@@ -6213,6 +6215,7 @@ void help(void)
#ifndef _WIN32
"-daemonize daemonize QEMU after initializing\n"
#endif
+ "-option-rom rom load a file, rom, into the option ROM space\n"
"\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f toggle full screen\n"
@@ -6295,6 +6298,7 @@ enum {
QEMU_OPTION_no_reboot,
QEMU_OPTION_daemonize,
QEMU_OPTION_disk,
+ QEMU_OPTION_option_rom,
};
typedef struct QEMUOption {
@@ -6377,6 +6381,7 @@ const QEMUOption qemu_options[] = {
{ "no-acpi", 0, QEMU_OPTION_no_acpi },
{ "no-reboot", 0, QEMU_OPTION_no_reboot },
{ "daemonize", 0, QEMU_OPTION_daemonize },
+ { "option-rom", HAS_ARG, QEMU_OPTION_option_rom },
{ NULL },
};
@@ -7130,6 +7135,14 @@ int main(int argc, char **argv)
case QEMU_OPTION_daemonize:
daemonize = 1;
break;
+ case QEMU_OPTION_option_rom:
+ if (nb_option_roms >= MAX_OPTION_ROMS) {
+ fprintf(stderr, "Too many option ROMs\n");
+ exit(1);
+ }
+ option_rom[nb_option_roms] = optarg;
+ nb_option_roms++;
+ break;
}
}
}
@@ -7220,6 +7233,15 @@ int main(int argc, char **argv)
/* init the memory */
phys_ram_size = ram_size + vga_ram_size + bios_size;
+
+ for (i = 0; i < nb_option_roms; i++) {
+ int ret = get_image_size(option_rom[i]);
+ if (ret == -1) {
+ fprintf(stderr, "Could not load option rom '%s'\n", option_rom[i]);
+ exit(1);
+ }
+ phys_ram_size += ret;
+ }
phys_ram_base = qemu_vmalloc(phys_ram_size);
if (!phys_ram_base) {
diff -r 0a200f17f93e vl.h
--- a/vl.h Sat Dec 23 16:28:52 2006 -0600
+++ b/vl.h Sat Dec 23 16:28:54 2006 -0600
@@ -153,6 +153,10 @@ extern int usb_enabled;
extern int usb_enabled;
extern int smp_cpus;
extern int no_quit;
+
+#define MAX_OPTION_ROMS 16
+extern const char *option_rom[MAX_OPTION_ROMS];
+extern int nb_option_roms;
/* XXX: make it dynamic */
#if defined (TARGET_PPC) || defined (TARGET_SPARC64)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] Add -option-rom option to allow loading of PCI option ROMs
2006-12-27 3:27 [Qemu-devel] [PATCH] Add -option-rom option to allow loading of PCI option ROMs Anthony Liguori
@ 2006-12-27 13:30 ` Fabrice Bellard
2006-12-27 17:12 ` Anthony Liguori
0 siblings, 1 reply; 3+ messages in thread
From: Fabrice Bellard @ 2006-12-27 13:30 UTC (permalink / raw)
To: qemu-devel
Hi,
OK for the -option-rom option. Later it would be better to handle it at
the NIC level, but it is more complicated (some BIOS patches would be
needed to remap the PCI ROM at the right address for example).
I think the -boot n option should be merged in QEMU too. Some people
need it to make tests.
Regarding VMI, I began some work in this area with kqemu but I did not
manage to find time to finish it (VMI in QEMU would enable to run Linux
VMs with performance levels close to Xen at the expense of a patched
kernel).
Regards,
Fabrice.
Anthony Liguori wrote:
> Howdy,
>
> The following patch adds an -option-rom option to allow loading of PCI
> option ROMs. This is useful for loading things like etherboot or VMI.
>
> For instance, using an etherboot ROM[1] from http://rom-o-matic.net/,
> one can use the following command line to PXE boot QEMU:
>
> qemu -hda ~/mydisk.img -option-rom ~/eb-5.4.2-winbond940.zrom
>
> This is also useful for loading a VMI option ROM for experimenting with
> paravirtualization. Not terribly useful ATM of course.
>
> BTW, I have another patch that would add the etherboot ROMs to the QEMU
> distribution for all the NICs and then plumb up -boot n to allow PXE
> booting. Is there any interest in a patch like this? This would
> increase the QEMU distribution size by 96k.
>
> [1]
> http://rom-o-matic.net/5.4.2/build.php?version=5.4.2&F=&arch=i386&nic=ns830:winbond940%20--%20[0x1050,0x0940]&ofmt=Binary%20ROM%20Image(.zrom)&A=Get%20ROM
>
>
> Regards,
>
> Anthony Liguori
>
>
> ------------------------------------------------------------------------
>
> diff -r 0a200f17f93e hw/pc.c
> --- a/hw/pc.c Sat Dec 23 16:28:52 2006 -0600
> +++ b/hw/pc.c Sat Dec 23 16:28:54 2006 -0600
> @@ -451,7 +451,7 @@ static void pc_init1(int ram_size, int v
> {
> char buf[1024];
> int ret, linux_boot, initrd_size, i;
> - unsigned long bios_offset, vga_bios_offset;
> + unsigned long bios_offset, vga_bios_offset, option_rom_offset;
> int bios_size, isa_bios_size;
> PCIBus *pci_bus;
> int piix3_devfn = -1;
> @@ -518,6 +518,23 @@ static void pc_init1(int ram_size, int v
> cpu_register_physical_memory(0x100000 - isa_bios_size,
> isa_bios_size,
> (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM);
> +
> + option_rom_offset = 0;
> + for (i = 0; i < nb_option_roms; i++) {
> + int offset = bios_offset + bios_size + option_rom_offset;
> + int size;
> +
> + size = load_image(option_rom[i], phys_ram_base + offset);
> + if ((size + option_rom_offset) > 0x10000) {
> + fprintf(stderr, "Too many option ROMS\n");
> + exit(1);
> + }
> + cpu_register_physical_memory(0xd0000 + option_rom_offset,
> + size, offset | IO_MEM_ROM);
> + option_rom_offset += size + 2047;
> + option_rom_offset -= (option_rom_offset % 2048);
> + }
> +
> /* map all the bios at the top of memory */
> cpu_register_physical_memory((uint32_t)(-bios_size),
> bios_size, bios_offset | IO_MEM_ROM);
> diff -r 0a200f17f93e qemu-doc.texi
> --- a/qemu-doc.texi Sat Dec 23 16:28:52 2006 -0600
> +++ b/qemu-doc.texi Sat Dec 23 16:28:54 2006 -0600
> @@ -325,6 +325,10 @@ Use it when installing Windows 2000 to a
> Use it when installing Windows 2000 to avoid a disk full bug. After
> Windows 2000 is installed, you no longer need this option (this option
> slows down the IDE transfers).
> +
> +@item -option-rom file
> +Load the contents of file as an option ROM. This option is useful to load
> +things like EtherBoot.
>
> @end table
>
> diff -r 0a200f17f93e vl.c
> --- a/vl.c Sat Dec 23 16:28:52 2006 -0600
> +++ b/vl.c Sat Dec 23 16:29:15 2006 -0600
> @@ -169,6 +169,8 @@ int fd_bootchk = 1;
> int fd_bootchk = 1;
> int no_reboot = 0;
> int daemonize = 0;
> +const char *option_rom[MAX_OPTION_ROMS];
> +int nb_option_roms;
>
> /***********************************************************/
> /* x86 ISA bus support */
> @@ -6213,6 +6215,7 @@ void help(void)
> #ifndef _WIN32
> "-daemonize daemonize QEMU after initializing\n"
> #endif
> + "-option-rom rom load a file, rom, into the option ROM space\n"
> "\n"
> "During emulation, the following keys are useful:\n"
> "ctrl-alt-f toggle full screen\n"
> @@ -6295,6 +6298,7 @@ enum {
> QEMU_OPTION_no_reboot,
> QEMU_OPTION_daemonize,
> QEMU_OPTION_disk,
> + QEMU_OPTION_option_rom,
> };
>
> typedef struct QEMUOption {
> @@ -6377,6 +6381,7 @@ const QEMUOption qemu_options[] = {
> { "no-acpi", 0, QEMU_OPTION_no_acpi },
> { "no-reboot", 0, QEMU_OPTION_no_reboot },
> { "daemonize", 0, QEMU_OPTION_daemonize },
> + { "option-rom", HAS_ARG, QEMU_OPTION_option_rom },
> { NULL },
> };
>
> @@ -7130,6 +7135,14 @@ int main(int argc, char **argv)
> case QEMU_OPTION_daemonize:
> daemonize = 1;
> break;
> + case QEMU_OPTION_option_rom:
> + if (nb_option_roms >= MAX_OPTION_ROMS) {
> + fprintf(stderr, "Too many option ROMs\n");
> + exit(1);
> + }
> + option_rom[nb_option_roms] = optarg;
> + nb_option_roms++;
> + break;
> }
> }
> }
> @@ -7220,6 +7233,15 @@ int main(int argc, char **argv)
>
> /* init the memory */
> phys_ram_size = ram_size + vga_ram_size + bios_size;
> +
> + for (i = 0; i < nb_option_roms; i++) {
> + int ret = get_image_size(option_rom[i]);
> + if (ret == -1) {
> + fprintf(stderr, "Could not load option rom '%s'\n", option_rom[i]);
> + exit(1);
> + }
> + phys_ram_size += ret;
> + }
>
> phys_ram_base = qemu_vmalloc(phys_ram_size);
> if (!phys_ram_base) {
> diff -r 0a200f17f93e vl.h
> --- a/vl.h Sat Dec 23 16:28:52 2006 -0600
> +++ b/vl.h Sat Dec 23 16:28:54 2006 -0600
> @@ -153,6 +153,10 @@ extern int usb_enabled;
> extern int usb_enabled;
> extern int smp_cpus;
> extern int no_quit;
> +
> +#define MAX_OPTION_ROMS 16
> +extern const char *option_rom[MAX_OPTION_ROMS];
> +extern int nb_option_roms;
>
> /* XXX: make it dynamic */
> #if defined (TARGET_PPC) || defined (TARGET_SPARC64)
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] Add -option-rom option to allow loading of PCI option ROMs
2006-12-27 13:30 ` Fabrice Bellard
@ 2006-12-27 17:12 ` Anthony Liguori
0 siblings, 0 replies; 3+ messages in thread
From: Anthony Liguori @ 2006-12-27 17:12 UTC (permalink / raw)
To: qemu-devel
Fabrice Bellard wrote:
> Hi,
>
> OK for the -option-rom option. Later it would be better to handle it
> at the NIC level, but it is more complicated (some BIOS patches would
> be needed to remap the PCI ROM at the right address for example).
Ok.
> I think the -boot n option should be merged in QEMU too. Some people
> need it to make tests.
Okay, I'll post that patch.
> Regarding VMI, I began some work in this area with kqemu but I did not
> manage to find time to finish it (VMI in QEMU would enable to run
> Linux VMs with performance levels close to Xen at the expense of a
> patched kernel).
I had a VMI ROM working with an older version of VMI. I've got some
time this week so I've been trying to do the same thing with the newer
VMI spec.
I'd like to at least get a pass through ROM working and then start
playing around with stuff like moving some of the device emulation into
the ROM. This would be most useful for something like KVM where the PIO
latency is a major bottleneck.
Eventually, it would be nice to use it to run the guest in ring 1 on
bare metal of course. I do agree that with VMI QEMU should be
competitive with Xen.
Regards,
Anthony Liguori
> Regards,
>
> Fabrice.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-12-27 17:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-27 3:27 [Qemu-devel] [PATCH] Add -option-rom option to allow loading of PCI option ROMs Anthony Liguori
2006-12-27 13:30 ` Fabrice Bellard
2006-12-27 17:12 ` Anthony Liguori
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).