Sort the fw_cfg file list
PATCH 1/1 Sort the fw_cfg file list
From: Gerd Hoffmann <[email protected]>
Entries are inserted in filename order instead of being appended to the end in case sorting is enabled.
This will avoid any future issues of moving the file creation around, it doesn't matter what order they are created now, the will always be in filename order.
Added machine type handling for compatibility. This was a fairly complex change, this will preserve the order of fw_cfg for older versions no matter what order the firmware files actually come in. A list is kept of the correct legacy order and the entries will be inserted based upon their order in the list. Except that some entries are ordered (in a specific area of the list) based upon what order they appear on the command line. Special handling is added for those entries.
---
Changes from v4:
* Add a space in fw_cfg.h to improve readability.
* Move the set order override for user file out of the main function in vl.c to parse_fw_cfg(). That way it has the fw_cfg and can call the fww_cfg_set_order_override() function directly.
* Added a ROM I missed: genroms/kvmvapic.bin. I looked around some more and I couldn't find anything else.
I'm not sure who should merge this.
hw/core/loader.c | 10 ++++ hw/i386/pc.c | 4 ++ hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + hw/nvram/fw_cfg.c | 131 +++++++++++++++++++++++++++++++++++++++++++--- include/hw/boards.h | 3 +- include/hw/loader.h | 2 + include/hw/nvram/fw_cfg.h | 8 +++ vl.c | 10 +++- 9 files changed, 159 insertions(+), 11 deletions(-)
hw/core/loader.c +10 -0
@@ -1051,6 +1051,16 @@ void rom_set_fw(FWCfgState *f) fw_cfg = f; } +void rom_set_order_override (int order) +{ +fw_cfg_set_order_override (fw_cfg, order); +} + +void rom_reset_order_override (void ) +{ +fw_cfg_reset_order_override (fw_cfg); +} +static Rom *find_rom (hwaddr addr) {Rom *rom;
hw/i386/pc.c +4 -0
@@ -1406,6 +1406,7 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus) {DeviceState *dev =NULL ; +rom_set_order_override (FW_CFG_ORDER_OVERRIDE_VGA );if (pci_bus) {PCIDevice *pcidev =pci_vga_init (pci_bus); dev = pcidev ? &pcidev->qdev :NULL ;
@@ -1413,6 +1414,7 @@ DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus)ISADevice *isadev =isa_vga_init (isa_bus); dev = isadev ?DEVICE (isadev) :NULL ; } +rom_reset_order_override ();return dev; }
@@ -1541,6 +1543,7 @@ void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus) {int i; +rom_set_order_override (FW_CFG_ORDER_OVERRIDE_NIC );for (i =0 ; i < nb_nics; i++) {NICInfo *nd = &nd_table[i];
@@ -1550,6 +1553,7 @@ void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)pci_nic_init_nofail (nd, pci_bus,"e1000" ,NULL ); } } +rom_reset_order_override (); }void pc_pci_device_init (PCIBus *pci_bus)
hw/i386/pc_piix.c +1 -0
@@ -429,6 +429,7 @@ static void pc_i440fx_2_5_machine_options(MachineClass *m) m->alias =NULL ; m->is_default =0 ; pcmc->save_tsc_khz = false; + m->legacy_fw_cfg_order =1 ;SET_MACHINE_COMPAT (m,PC_COMPAT_2_5 ); }
hw/i386/pc_q35.c +1 -0
@@ -291,6 +291,7 @@ static void pc_q35_2_5_machine_options(MachineClass *m)pc_q35_2_6_machine_options (m); m->alias =NULL ; pcmc->save_tsc_khz = false; + m->legacy_fw_cfg_order =1 ;SET_MACHINE_COMPAT (m,PC_COMPAT_2_5 ); }
hw/nvram/fw_cfg.c +123 -8
174 lines not on this page · raw message
include/hw/boards.h +2 -1
@@ -84,7 +84,8 @@ struct MachineClass { no_cdrom:1, no_sdcard:1, has_dynamic_sysbus:1, - pci_allow_0_address:1; + pci_allow_0_address:1, + legacy_fw_cfg_order:1;int is_default;const char *default_machine_opts;const char *default_boot_order;
include/hw/loader.h +2 -0
@@ -128,6 +128,8 @@ int rom_add_elf_program(const char *name, void *data, size_t datasize, size_t romsize, hwaddr addr);int rom_check_and_register_reset (void );void rom_set_fw (FWCfgState *f); +void rom_set_order_override (int order); +void rom_reset_order_override (void );int rom_copy (uint8_t *dest,hwaddr addr,size_t size);void *rom_ptr (hwaddr addr);void hmp_info_roms (Monitor *mon,const QDict *qdict);
include/hw/nvram/fw_cfg.h +8 -0
@@ -57,6 +57,14 @@ typedef struct FWCfgFile {char name[FW_CFG_MAX_FILE_PATH ]; } FWCfgFile; +#define FW_CFG_ORDER_OVERRIDE_VGA 70 +#define FW_CFG_ORDER_OVERRIDE_NIC 80 +#define FW_CFG_ORDER_OVERRIDE_USER 100 +#define FW_CFG_ORDER_OVERRIDE_DEVICE 110 + +void fw_cfg_set_order_override (FWCfgState *fw_cfg,int order); +void fw_cfg_reset_order_override (FWCfgState *fw_cfg); + typedef struct FWCfgFiles { uint32_t count; FWCfgFile f[];
vl.c +8 -2
@@ -2296,8 +2296,9 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)gchar *buf;size_t size;const char *name, *file, *str; +FWCfgState *fw_cfg = (FWCfgState *) opaque; -if (opaque ==NULL ) { +if (fw_cfg ==NULL ) {error_report ("fw_cfg device not available" );return -1 ; }
@@ -2331,7 +2332,10 @@ static int parse_fw_cfg(void *opaque, QemuOpts *opts, Error **errp)return -1 ; } } -fw_cfg_add_file ((FWCfgState *)opaque, name, buf, size); +/* For legacy, keep user files in a specific global order. */ +fw_cfg_set_order_override (fw_cfg,FW_CFG_ORDER_OVERRIDE_USER ); +fw_cfg_add_file (fw_cfg, name, buf, size); +fw_cfg_reset_order_override (fw_cfg);return 0 ; }
@@ -4535,10 +4539,12 @@ int main(int argc, char **argv, char **envp)igd_gfx_passthru ();/* init generic devices */ +rom_set_order_override (FW_CFG_ORDER_OVERRIDE_DEVICE );if (qemu_opts_foreach (qemu_find_opts ("device" ), device_init_func,NULL ,NULL )) {exit (1 ); } +rom_reset_order_override ();/* Did we create any drives that we failed to create a device for? */ drive_check_orphaned ();
Signature · 1 line
2.5.0