diff mbox

[1/3] set the readonly property of rom memory region in pc

Message ID 1347006389-543-2-git-send-email-liusheng@linux.vnet.ibm.com
State New
Headers show

Commit Message

Liu Sheng Sept. 7, 2012, 8:26 a.m. UTC
make sure the memory regions of rom in pc have readonly property,
prepare for plug these memory to kvm as readonly memory slots.

Signed-off-by: Liu Sheng <liusheng@linux.vnet.ibm.com>
---
 hw/pc.c  |    1 +
 hw/pci.c |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/hw/pc.c b/hw/pc.c
index c32ee8e..b7fb058 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -992,6 +992,7 @@  void *pc_memory_init(MemoryRegion *system_memory,
     option_rom_mr = g_malloc(sizeof(*option_rom_mr));
     memory_region_init_ram(option_rom_mr, "pc.rom", PC_ROM_SIZE);
     vmstate_register_ram_global(option_rom_mr);
+    memory_region_set_readonly(option_rom_mr, true);
     memory_region_add_subregion_overlap(rom_memory,
                                         PC_ROM_MIN_VGA,
                                         option_rom_mr,
diff --git a/hw/pci.c b/hw/pci.c
index 4d95984..195971c 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1786,6 +1786,7 @@  static int pci_add_option_rom(PCIDevice *pdev, bool is_default_rom)
     pdev->has_rom = true;
     memory_region_init_ram(&pdev->rom, name, size);
     vmstate_register_ram(&pdev->rom, &pdev->qdev);
+    memory_region_set_readonly(&pdev->rom, true);
     ptr = memory_region_get_ram_ptr(&pdev->rom);
     load_image(path, ptr);
     g_free(path);