Patchwork [v2,repost,7/9] loader: allow adding ROMs in done callbacks

login
register
mail settings
Submitter Michael S. Tsirkin
Date July 10, 2013, 1:51 p.m.
Message ID <1373464153-18979-8-git-send-email-mst@redhat.com>
Download mbox | patch
Permalink /patch/258054/
State New
Headers show

Comments

Michael S. Tsirkin - July 10, 2013, 1:51 p.m.
Don't abort if machine done callbacks add ROMs.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/core/loader.c    | 6 +++++-
 include/hw/loader.h | 1 +
 vl.c                | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)
Laszlo Ersek - July 17, 2013, 12:23 p.m.
On 07/10/13 15:51, Michael S. Tsirkin wrote:
> Don't abort if machine done callbacks add ROMs.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  hw/core/loader.c    | 6 +++++-
>  include/hw/loader.h | 1 +
>  vl.c                | 3 +++
>  3 files changed, 9 insertions(+), 1 deletion(-)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Patch

diff --git a/hw/core/loader.c b/hw/core/loader.c
index 1ead722..3f1d89b 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -743,10 +743,14 @@  int rom_load_all(void)
         rom->isrom = int128_nz(section.size) && memory_region_is_rom(section.mr);
     }
     qemu_register_reset(rom_reset, NULL);
-    roms_loaded = 1;
     return 0;
 }
 
+void rom_load_done(void)
+{
+    roms_loaded = 1;
+}
+
 void rom_set_fw(FWCfgState *f)
 {
     fw_cfg = f;
diff --git a/include/hw/loader.h b/include/hw/loader.h
index b39e7d1..976e5cd 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -31,6 +31,7 @@  int rom_add_blob(const char *name, const void *blob, size_t len,
 int rom_add_elf_program(const char *name, void *data, size_t datasize,
                         size_t romsize, hwaddr addr);
 int rom_load_all(void);
+void rom_load_done(void);
 void rom_set_fw(FWCfgState *f);
 int rom_copy(uint8_t *dest, hwaddr addr, size_t size);
 void *rom_ptr(hwaddr addr);
diff --git a/vl.c b/vl.c
index 6d9fd7d..8190504 100644
--- a/vl.c
+++ b/vl.c
@@ -4377,6 +4377,9 @@  int main(int argc, char **argv, char **envp)
     qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
     qemu_run_machine_init_done_notifiers();
 
+    /* Done notifiers can load ROMs */
+    rom_load_done();
+
     qemu_system_reset(VMRESET_SILENT);
     if (loadvm) {
         if (load_vmstate(loadvm) < 0) {