From: Gleb Natapov <gleb@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, mst@redhat.com, armbru@redhat.com,
blauwirbel@gmail.com, alex.williamson@redhat.com,
kevin@koconnor.net
Subject: [Qemu-devel] [PATCHv4 13/15] Add bootindex for option roms.
Date: Sun, 14 Nov 2010 17:39:39 +0200 [thread overview]
Message-ID: <1289749181-12070-14-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1289749181-12070-1-git-send-email-gleb@redhat.com>
Extend -option-rom command to have additional parameter ,bootindex=.
Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
hw/loader.c | 16 +++++++++++-----
hw/loader.h | 8 ++++----
hw/multiboot.c | 3 ++-
hw/ne2000.c | 2 +-
hw/nseries.c | 2 +-
hw/pc.c | 7 ++++---
hw/pci.c | 2 +-
hw/pcnet.c | 2 +-
qemu-config.c | 17 +++++++++++++++++
sysemu.h | 6 +++++-
vl.c | 11 +++++++++--
11 files changed, 56 insertions(+), 20 deletions(-)
diff --git a/hw/loader.c b/hw/loader.c
index 1e98326..eb198f6 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -107,7 +107,7 @@ int load_image_targphys(const char *filename,
size = get_image_size(filename);
if (size > 0)
- rom_add_file_fixed(filename, addr);
+ rom_add_file_fixed(filename, addr, -1);
return size;
}
@@ -557,10 +557,11 @@ static void rom_insert(Rom *rom)
}
int rom_add_file(const char *file, const char *fw_dir,
- target_phys_addr_t addr)
+ target_phys_addr_t addr, int32_t bootindex)
{
Rom *rom;
int rc, fd = -1;
+ char devpath[100];
rom = qemu_mallocz(sizeof(*rom));
rom->name = qemu_strdup(file);
@@ -605,7 +606,12 @@ int rom_add_file(const char *file, const char *fw_dir,
snprintf(fw_file_name, sizeof(fw_file_name), "%s/%s", rom->fw_dir,
basename);
fw_cfg_add_file(fw_cfg, fw_file_name, rom->data, rom->romsize);
+ snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
+ } else {
+ snprintf(devpath, sizeof(devpath), "/rom@" TARGET_FMT_plx, addr);
}
+
+ add_boot_device_path(bootindex, NULL, devpath);
return 0;
err:
@@ -635,12 +641,12 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
int rom_add_vga(const char *file)
{
- return rom_add_file(file, "vgaroms", 0);
+ return rom_add_file(file, "vgaroms", 0, -1);
}
-int rom_add_option(const char *file)
+int rom_add_option(const char *file, int32_t bootindex)
{
- return rom_add_file(file, "genroms", 0);
+ return rom_add_file(file, "genroms", 0, bootindex);
}
static void rom_reset(void *unused)
diff --git a/hw/loader.h b/hw/loader.h
index 1f82fc5..fc6bdff 100644
--- a/hw/loader.h
+++ b/hw/loader.h
@@ -22,7 +22,7 @@ void pstrcpy_targphys(const char *name,
int rom_add_file(const char *file, const char *fw_dir,
- target_phys_addr_t addr);
+ target_phys_addr_t addr, int32_t bootindex);
int rom_add_blob(const char *name, const void *blob, size_t len,
target_phys_addr_t addr);
int rom_load_all(void);
@@ -31,8 +31,8 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
void *rom_ptr(target_phys_addr_t addr);
void do_info_roms(Monitor *mon);
-#define rom_add_file_fixed(_f, _a) \
- rom_add_file(_f, NULL, _a)
+#define rom_add_file_fixed(_f, _a, _i) \
+ rom_add_file(_f, NULL, _a, _i)
#define rom_add_blob_fixed(_f, _b, _l, _a) \
rom_add_blob(_f, _b, _l, _a)
@@ -43,6 +43,6 @@ void do_info_roms(Monitor *mon);
#define PC_ROM_SIZE (PC_ROM_MAX - PC_ROM_MIN_VGA)
int rom_add_vga(const char *file);
-int rom_add_option(const char *file);
+int rom_add_option(const char *file, int32_t bootindex);
#endif
diff --git a/hw/multiboot.c b/hw/multiboot.c
index f9097a2..b438019 100644
--- a/hw/multiboot.c
+++ b/hw/multiboot.c
@@ -325,7 +325,8 @@ int load_multiboot(void *fw_cfg,
fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, mb_bootinfo_data,
sizeof(bootinfo));
- option_rom[nb_option_roms] = "multiboot.bin";
+ option_rom[nb_option_roms].name = "multiboot.bin";
+ option_rom[nb_option_roms].bootindex = 0;
nb_option_roms++;
return 1; /* yes, we are multiboot */
diff --git a/hw/ne2000.c b/hw/ne2000.c
index f4bbac2..67e0cb0 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -742,7 +742,7 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
if (!pci_dev->qdev.hotplugged) {
static int loaded = 0;
if (!loaded) {
- rom_add_option("pxe-ne2k_pci.bin");
+ rom_add_option("pxe-ne2k_pci.bin", -1);
loaded = 1;
}
}
diff --git a/hw/nseries.c b/hw/nseries.c
index 04a028d..39780ef 100644
--- a/hw/nseries.c
+++ b/hw/nseries.c
@@ -1326,7 +1326,7 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device,
qemu_register_reset(n8x0_boot_init, s);
}
- if (option_rom[0] && (boot_device[0] == 'n' || !kernel_filename)) {
+ if (option_rom[0].name && (boot_device[0] == 'n' || !kernel_filename)) {
int rom_size;
uint8_t nolo_tags[0x10000];
/* No, wait, better start at the ROM. */
diff --git a/hw/pc.c b/hw/pc.c
index 69b13bf..5111a76 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -733,7 +733,8 @@ static void load_linux(void *fw_cfg,
fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
- option_rom[nb_option_roms] = "linuxboot.bin";
+ option_rom[nb_option_roms].name = "linuxboot.bin";
+ option_rom[nb_option_roms].bootindex = 0;
nb_option_roms++;
}
@@ -937,7 +938,7 @@ void pc_memory_init(ram_addr_t ram_size,
goto bios_error;
}
bios_offset = qemu_ram_alloc(NULL, "pc.bios", bios_size);
- ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size));
+ ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
if (ret != 0) {
bios_error:
fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
@@ -969,7 +970,7 @@ void pc_memory_init(ram_addr_t ram_size,
}
for (i = 0; i < nb_option_roms; i++) {
- rom_add_option(option_rom[i]);
+ rom_add_option(option_rom[i].name, option_rom[i].bootindex);
}
}
diff --git a/hw/pci.c b/hw/pci.c
index 114b435..49e9298 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1701,7 +1701,7 @@ static int pci_add_option_rom(PCIDevice *pdev)
if (class == 0x0300) {
rom_add_vga(pdev->romfile);
} else {
- rom_add_option(pdev->romfile);
+ rom_add_option(pdev->romfile, -1);
}
return 0;
}
diff --git a/hw/pcnet.c b/hw/pcnet.c
index a988f4f..38e6591 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -2014,7 +2014,7 @@ static int pci_pcnet_init(PCIDevice *pci_dev)
if (!pci_dev->qdev.hotplugged) {
static int loaded = 0;
if (!loaded) {
- rom_add_option("pxe-pcnet.bin");
+ rom_add_option("pxe-pcnet.bin", -1);
loaded = 1;
}
}
diff --git a/qemu-config.c b/qemu-config.c
index 52f18be..965fa46 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -429,6 +429,22 @@ QemuOptsList qemu_spice_opts = {
},
};
+QemuOptsList qemu_option_rom_opts = {
+ .name = "option-rom",
+ .implied_opt_name = "romfile",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_option_rom_opts.head),
+ .desc = {
+ {
+ .name = "bootindex",
+ .type = QEMU_OPT_NUMBER,
+ }, {
+ .name = "romfile",
+ .type = QEMU_OPT_STRING,
+ },
+ { /* end if list */ }
+ },
+};
+
static QemuOptsList *vm_config_groups[32] = {
&qemu_drive_opts,
&qemu_chardev_opts,
@@ -442,6 +458,7 @@ static QemuOptsList *vm_config_groups[32] = {
#ifdef CONFIG_SIMPLE_TRACE
&qemu_trace_opts,
#endif
+ &qemu_option_rom_opts,
NULL,
};
diff --git a/sysemu.h b/sysemu.h
index fe9a582..48f8eee 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -139,7 +139,11 @@ extern uint64_t node_mem[MAX_NODES];
extern uint64_t node_cpumask[MAX_NODES];
#define MAX_OPTION_ROMS 16
-extern const char *option_rom[MAX_OPTION_ROMS];
+typedef struct QEMUOptionRom {
+ const char *name;
+ int32_t bootindex;
+} QEMUOptionRom;
+extern QEMUOptionRom option_rom[MAX_OPTION_ROMS];
extern int nb_option_roms;
#define MAX_PROM_ENVS 128
diff --git a/vl.c b/vl.c
index 4c159f0..e8ada75 100644
--- a/vl.c
+++ b/vl.c
@@ -217,7 +217,7 @@ int cursor_hide = 1;
int graphic_rotate = 0;
uint8_t irq0override = 1;
const char *watchdog;
-const char *option_rom[MAX_OPTION_ROMS];
+QEMUOptionRom option_rom[MAX_OPTION_ROMS];
int nb_option_roms;
int semihosting_enabled = 0;
int old_param = 0;
@@ -2516,7 +2516,14 @@ int main(int argc, char **argv, char **envp)
fprintf(stderr, "Too many option ROMs\n");
exit(1);
}
- option_rom[nb_option_roms] = optarg;
+ opts = qemu_opts_parse(qemu_find_opts("option-rom"), optarg, 1);
+ option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
+ option_rom[nb_option_roms].bootindex =
+ qemu_opt_get_number(opts, "bootindex", -1);
+ if (!option_rom[nb_option_roms].name) {
+ fprintf(stderr, "Option ROM file is not specified\n");
+ exit(1);
+ }
nb_option_roms++;
break;
case QEMU_OPTION_semihosting:
--
1.7.1
next prev parent reply other threads:[~2010-11-14 15:39 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-14 15:39 [Qemu-devel] [PATCHv4 00/15] boot order specification Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 01/15] Introduce fw_name field to DeviceInfo structure Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 02/15] Introduce new BusInfo callback get_fw_dev_path Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 03/15] Keep track of ISA ports ISA device is using in qdev Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 04/15] Add get_fw_dev_path callback to ISA bus " Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 05/15] Store IDE bus id in IDEBus structure for easy access Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 06/15] Add get_fw_dev_path callback to IDE bus Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 07/15] Add get_dev_path callback for system bus Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 08/15] Add get_fw_dev_path callback for pci bus Gleb Natapov
2010-11-14 18:27 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-14 18:42 ` Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 09/15] Record which USBDevice USBPort belongs too Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 10/15] Add get_dev_path callback for usb bus Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 11/15] Add bootindex parameter to net/block/fd device Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 12/15] Change fw_cfg_add_file() to get full file path as a parameter Gleb Natapov
2010-11-14 15:39 ` Gleb Natapov [this message]
2010-11-14 21:33 ` [Qemu-devel] Re: [PATCHv4 13/15] Add bootindex for option roms Blue Swirl
2010-11-15 10:18 ` Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 14/15] Add notifier that will be called when machine is fully created Gleb Natapov
2010-11-14 15:39 ` [Qemu-devel] [PATCHv4 15/15] Pass boot device list to firmware Gleb Natapov
2010-11-14 18:41 ` [Qemu-devel] " Michael S. Tsirkin
2010-11-14 18:52 ` Gleb Natapov
2010-11-14 20:56 ` Michael S. Tsirkin
2010-11-14 20:57 ` Michael S. Tsirkin
2010-11-14 20:49 ` Blue Swirl
2010-11-14 20:54 ` Michael S. Tsirkin
2010-11-14 21:13 ` Blue Swirl
2010-11-14 21:45 ` Michael S. Tsirkin
2010-11-14 22:50 ` Blue Swirl
2010-11-15 8:42 ` Gleb Natapov
2010-11-15 20:29 ` Blue Swirl
2010-11-16 14:11 ` Gleb Natapov
2010-11-16 18:30 ` Blue Swirl
2010-11-16 19:02 ` Gleb Natapov
2010-11-17 21:54 ` Blue Swirl
2010-11-18 10:18 ` Gleb Natapov
2010-11-18 11:38 ` Michael S. Tsirkin
2010-11-18 11:45 ` Gleb Natapov
2010-11-18 11:52 ` Michael S. Tsirkin
2010-11-18 12:16 ` Gleb Natapov
2010-11-18 12:23 ` Michael S. Tsirkin
2010-11-18 12:37 ` Gleb Natapov
2010-11-18 13:12 ` Michael S. Tsirkin
2010-11-18 13:16 ` Gleb Natapov
2010-11-15 3:40 ` Kevin O'Connor
2010-11-15 7:40 ` Gleb Natapov
2010-11-15 7:53 ` Michael S. Tsirkin
2010-11-15 8:09 ` Gleb Natapov
2010-11-15 13:26 ` Kevin O'Connor
2010-11-15 13:36 ` Gleb Natapov
2010-11-15 13:46 ` Gleb Natapov
2010-11-16 2:52 ` Kevin O'Connor
2010-11-16 7:22 ` Gleb Natapov
2010-11-16 13:49 ` Kevin O'Connor
2010-11-16 18:19 ` Blue Swirl
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=1289749181-12070-14-git-send-email-gleb@redhat.com \
--to=gleb@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=blauwirbel@gmail.com \
--cc=kevin@koconnor.net \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--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).