Make migration work with hotplug
cover Make migration work with hotplug
Ok, new approach. I'm going to attempt to extract myself for the canonical device path approach, because we're missing too many pieces to make that work. Instead, I'll take Anthony's advice and try to simplify. We still want a unique name for ramblocks and savevm, but the hotplug problem today is only for PCI devices. PCI conveniently has globally unique, dare I say canonical, addressing in the form of <domain>:<bus>:<device>.<func>. To get to this, let's add a new function on the BusInfo structure called get_dev_path(). For a PCI device, we can simply traverse up the qdev tree to the BusInfo structure, look for the function, and call it to return a global PCI address.
For some buses, these functions could chain up to their parent bus appending strings together to get a unique path. An example would be USB, where the USB port number may not be unique. If we traverse up to the PCI device providing USB, and then to the PCI bus, we get a globally unique PCI path, appended with a USB port number.
To make this work for ramblocks and savevm, we need a DeviceState pointer when the they are create/registered, and we need a caller provided context in case there are multiple ramblocks/savevm associated with a device. Savevm already provies the context, and I've attempted to make reasonable guesses at these for the ramblocks. Note that most of the ramblocks aren't associated with a device, so I don't think it makes sense to link savevm and ramblocks together with the same absolute id string.
Once we have savevm with unique id strings, rather than hotplug unfriendly instance numbers, we can be sure that the right driver instance is loading the correct vmstate. I've also implemented a compat field for this, so we can still accept incoming migrations from previous versions.
Once we have ramblocks with a unique id string, we can switch to using id + offset for migration, which enables a ram_addr_t space that supports gaps, which enables us to implement qemu_ram_free(). With that, I think we can finally do migrations reliable after hotplug! Note that the target VM still needs to be created to match the current devices and bus addresses of the source VM. We can also still maintain compatibility for migrations here by bumping the ram migration version and supporting both new and old (just hope the source hasn't done any hotplugs).
Sound reasonable? Is get_dev_path the right name? In the right place? The PCI return is currently "dddd:bb:dd.f", should this be "PCI:dddd:bb:dd.f"? Something else? Thanks,
Alex
---
Alex Williamson (15):
ramblocks: No more being lazy about duplicate names
pci: Free the space allocated for the option rom on removal
qemu_ram_free: Implement it
savevm: Create a new continue flag to avoid resending block name
savevm: Use RAM blocks for basis of migration
savevm: Migrate RAM based on name/offset
ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
qemu_ram_alloc: Add DeviceState and name parameters
virtio-net: Incorporate a DeviceState pointer and let savevm track instances
eepro100: Add a dev field to eeprom new/free functions
savevm: Make use of DeviceState
savevm: Add DeviceState param
pci: Implement BusInfo.get_dev_path()
qdev: Add a get_dev_path() function to BusInfo
Remove uses of ram.last_offset (aka last_ram_offset)
arch_init.c | 183 +++++++++++++++++++++++++++++++++++------ audio/audio.c | 2 block-migration.c | 4 - cpu-all.h | 5 + cpu-common.h | 2 exec.c | 96 +++++++++++++++++++--- hw/adb.c | 4 - hw/ads7846.c | 2 hw/an5206.c | 4 - hw/arm_gic.c | 2 hw/arm_timer.c | 4 - hw/armv7m.c | 9 +- hw/armv7m_nvic.c | 2 hw/axis_dev88.c | 4 - hw/cirrus_vga.c | 2 hw/cuda.c | 2 hw/dma.c | 4 - hw/dummy_m68k.c | 2 hw/eepro100.c | 8 +- hw/eeprom93xx.c | 8 +- hw/eeprom93xx.h | 4 - hw/etraxfs.c | 6 + hw/fw_cfg.c | 2 hw/g364fb.c | 4 - hw/grackle_pci.c | 4 - hw/gt64xxx.c | 3 - hw/gumstix.c | 6 + hw/heathrow_pic.c | 2 hw/hw.h | 18 ++-- hw/i2c.c | 2 hw/i8254.c | 2 hw/i8259.c | 2 hw/ide/cmd646.c | 2 hw/ide/isa.c | 2 hw/ide/macio.c | 2 hw/ide/microdrive.c | 2 hw/ide/mmio.c | 2 hw/ide/piix.c | 2 hw/integratorcp.c | 4 - hw/m48t59.c | 2 hw/mac_dbdma.c | 2 hw/mac_nvram.c | 4 - hw/mainstone.c | 6 + hw/max111x.c | 3 - hw/mcf5208.c | 4 - hw/mips_jazz.c | 4 - hw/mips_malta.c | 4 - hw/mips_mipssim.c | 4 - hw/mips_r4k.c | 6 + hw/mipsnet.c | 4 - hw/mst_fpga.c | 3 - hw/musicpal.c | 11 ++ hw/nand.c | 2 hw/omap1.c | 6 + hw/omap2.c | 6 + hw/omap_sx1.c | 12 ++- hw/onenand.c | 2 hw/openpic.c | 5 + hw/palm.c | 3 - hw/pc.c | 8 +- hw/pci.c | 34 +++++++- hw/pckbd.c | 2 hw/petalogix_s3adsp1800_mmu.c | 7 +- hw/piix4.c | 2 hw/pl011.c | 2 hw/pl022.c | 2 hw/pl061.c | 2 hw/ppc405_boards.c | 18 ++-- hw/ppc405_uc.c | 2 hw/ppc4xx_devs.c | 4 + hw/ppc4xx_pci.c | 4 - hw/ppc_newworld.c | 6 + hw/ppc_oldworld.c | 6 + hw/ppc_prep.c | 4 - hw/ppce500_mpc8544ds.c | 3 - hw/ppce500_pci.c | 4 - hw/ps2.c | 4 - hw/pxa2xx.c | 39 +++++---- hw/pxa2xx_dma.c | 2 hw/pxa2xx_gpio.c | 2 hw/pxa2xx_keypad.c | 2 hw/pxa2xx_lcd.c | 2 hw/pxa2xx_mmci.c | 2 hw/pxa2xx_pic.c | 3 - hw/pxa2xx_timer.c | 2 hw/qdev.c | 4 - hw/qdev.h | 3 + hw/r2d.c | 4 - hw/rc4030.c | 2 hw/realview.c | 6 + hw/s390-virtio.c | 2 hw/serial.c | 4 - hw/sm501.c | 2 hw/spitz.c | 11 +- hw/ssd0323.c | 3 - hw/ssi-sd.c | 2 hw/stellaris.c | 11 +- hw/stellaris_enet.c | 4 - hw/stellaris_input.c | 2 hw/sun4m.c | 8 +- hw/sun4u.c | 4 - hw/syborg.c | 2 hw/syborg_fb.c | 2 hw/syborg_interrupt.c | 3 - hw/syborg_keyboard.c | 2 hw/syborg_pointer.c | 2 hw/syborg_rtc.c | 3 - hw/syborg_serial.c | 2 hw/syborg_timer.c | 2 hw/tc6393xb.c | 2 hw/tcx.c | 2 hw/tosa.c | 2 hw/tsc2005.c | 2 hw/tsc210x.c | 4 - hw/unin_pci.c | 6 + hw/versatilepb.c | 2 hw/vga-isa-mm.c | 2 hw/vga-isa.c | 2 hw/vga.c | 2 hw/virtio-balloon.c | 3 - hw/virtio-blk.c | 2 hw/virtio-net.c | 7 +- hw/virtio-serial-bus.c | 2 hw/vmmouse.c | 2 hw/vmware_vga.c | 4 - hw/zaurus.c | 2 qemu-timer.c | 2 savevm.c | 106 +++++++++++++++++++++--- slirp/slirp.c | 5 + vl.c | 2 130 files changed, 648 insertions(+), 286 deletions(-)
PATCH 1/15 Remove uses of ram.last_offset (aka last_ram_offset)
We currently need this either to allocate the next ram_addr_t for a new block, or for total memory to be migrated. Both of which we can calculate without need of this to keep us in a contiguous address space.
---
arch_init.c | 23 ++++++++++++++++------- cpu-all.h | 1 - exec.c | 19 ++++++++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-)
arch_init.c +16 -7
@@ -108,9 +108,10 @@ static int ram_save_block(QEMUFile *f)static ram_addr_t current_addr =0 ;ram_addr_t saved_addr = current_addr;ram_addr_t addr =0 ; +uint64_t total_ram =ram_bytes_total ();int bytes_sent =0 ; -while (addr < ram_list.last_offset) { +while (addr < total_ram) {if (cpu_physical_memory_get_dirty (current_addr,MIGRATION_DIRTY_FLAG )) {uint8_t *p;
@@ -133,7 +134,7 @@ static int ram_save_block(QEMUFile *f)break ; } addr +=TARGET_PAGE_SIZE ; - current_addr = (saved_addr + addr) % ram_list.last_offset; + current_addr = (saved_addr + addr) % total_ram; }return bytes_sent;
@@ -145,8 +146,9 @@ static ram_addr_t ram_save_remaining(void) {ram_addr_t addr;ram_addr_t count =0 ; +uint64_t total_ram =ram_bytes_total (); -for (addr =0 ; addr < ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) {if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { count++; }
@@ -167,7 +169,13 @@ uint64_t ram_bytes_transferred(void)uint64_t ram_bytes_total (void ) { -return ram_list.last_offset; +RAMBlock *block; +uint64_t total =0 ; + +QLIST_FOREACH (block, &ram_list.blocks, next) + total += block->length; + +return total; }int ram_save_live (Monitor *mon,QEMUFile *f,int stage,void *opaque)
@@ -188,10 +196,11 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) }if (stage ==1 ) { +uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;/* Make sure all dirty bits are set */ -for (addr =0 ; addr < ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) {if (!cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) {cpu_physical_memory_set_dirty (addr); }
@@ -200,7 +209,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)/* Enable dirty memory tracking */ cpu_physical_memory_set_dirty_tracking (1 ); -qemu_put_be64 (f, ram_list.last_offset |RAM_SAVE_FLAG_MEM_SIZE ); +qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); } bytes_transferred_last = bytes_transferred;
@@ -259,7 +268,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) addr &=TARGET_PAGE_MASK ;if (flags &RAM_SAVE_FLAG_MEM_SIZE ) { -if (addr != ram_list.last_offset) { +if (addr !=ram_bytes_total ()) {return -EINVAL ; } }
cpu-all.h +0 -1
@@ -870,7 +870,6 @@ typedef struct RAMBlock {typedef struct RAMList {uint8_t *phys_dirty; -ram_addr_t last_offset; QLIST_HEAD(ram, RAMBlock) blocks; }RAMList ;extern RAMList ram_list;
exec.c +14 -5
@@ -2765,6 +2765,17 @@ static void *file_ram_alloc(ram_addr_t memory, const char *path) }#endif +static ram_addr_t find_ram_offset (ram_addr_t size) +{ +RAMBlock *block; +ram_addr_t last =0 ; + +QLIST_FOREACH (block, &ram_list.blocks, next) + last = MAX(last, block->offset + block->length); + +return last; +} +ram_addr_t qemu_ram_alloc (ram_addr_t size) {RAMBlock *new_block;
@@ -2798,18 +2809,16 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)madvise (new_block->host, size,MADV_MERGEABLE );#endif } - new_block->offset = ram_list.last_offset; + new_block->offset =find_ram_offset (size); new_block->length = size;QLIST_INSERT_HEAD (&ram_list.blocks, new_block, next); ram_list.phys_dirty =qemu_realloc (ram_list.phys_dirty, - (ram_list.last_offset + size) >>TARGET_PAGE_BITS ); -memset (ram_list.phys_dirty + (ram_list.last_offset >>TARGET_PAGE_BITS ), + (new_block->offset + size) >>TARGET_PAGE_BITS ); +memset (ram_list.phys_dirty + (new_block->offset >>TARGET_PAGE_BITS ),0xff , size >>TARGET_PAGE_BITS ); - ram_list.last_offset += size; -if (kvm_enabled ())kvm_setup_guest_memory (new_block->host, size);
PATCH 2/15 qdev: Add a get_dev_path() function to BusInfo
In reply to Alex WilliamsonThis function is meant to provide a stable device path for buses which are able to implement it. If a bus has a globally unique addresses scheme, one address level may be sufficient to provide a path. Other buses may need to recursively traverse up the qdev tree.
---
hw/qdev.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
hw/qdev.h +3 -0
@@ -49,10 +49,13 @@ struct DeviceState { };typedef void (*bus_dev_printfn )(Monitor *mon,DeviceState *dev,int indent); +typedef char *(*bus_get_dev_path )(DeviceState *dev); +struct BusInfo {const char *name;size_t size;bus_dev_printfn print_dev; +bus_get_dev_path get_dev_path;Property *props; };
PATCH 3/15 pci: Implement BusInfo.get_dev_path()
In reply to Alex WilliamsonThis works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely describes a global address. No need to traverse up the qdev tree. PCI segment support is a placeholder for compatibility once we support multiple segments.
---
hw/pci.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
hw/pci.c +14 -0
@@ -58,11 +58,13 @@ struct PCIBus { };static void pcibus_dev_print (Monitor *mon,DeviceState *dev,int indent); +static char *pcibus_get_dev_path (DeviceState *dev);static struct BusInfo pci_bus_info = { .name ="PCI" , .size =sizeof (PCIBus), .print_dev = pcibus_dev_print, + .get_dev_path = pcibus_get_dev_path, .props = (Property []) {DEFINE_PROP_PCI_DEVFN ("addr" , PCIDevice, devfn,-1 ),DEFINE_PROP_STRING ("romfile" , PCIDevice, romfile),
@@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) } } +static char *pcibus_get_dev_path (DeviceState *dev) +{ +PCIDevice *d = (PCIDevice *)dev; +char path[16 ]; + +snprintf (path,sizeof (path),"%04x:%02x:%02x.%x" , +0 /* FIXME for segment support */ , d->config[PCI_SECONDARY_BUS ], +PCI_SLOT (d->devfn),PCI_FUNC (d->devfn)); + +return strdup (path); +} +static PCIDeviceInfo bridge_info = { .qdev.name ="pci-bridge" , .qdev.size =sizeof (PCIBridge),
Re: [Qemu-devel] [PATCH 03/15] pci: Implement BusInfo.get_dev_path()
Quoted 30 lines · Alex Williamson
This works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely describes a global address. No need to traverse up the qdev tree. PCI segment support is a placeholder for compatibility once we support multiple segments.
Signed-off-by Alex Williamson <[email protected]>---
hw/pci.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)hw/pci.c +2
-0@@ -58,11 +58,13 @@ struct PCIBus { };static void pcibus_dev_print (Monitor *mon,DeviceState *dev,int indent); +static char *pcibus_get_dev_path (DeviceState *dev);static struct BusInfo pci_bus_info = { .name ="PCI" , .size =sizeof (PCIBus), .print_dev = pcibus_dev_print, + .get_dev_path = pcibus_get_dev_path, .props = (Property []) {DEFINE_PROP_PCI_DEVFN ("addr" , PCIDevice, devfn,-1 ),DEFINE_PROP_STRING ("romfile" , PCIDevice, romfile),
hw/pci.c static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) · line 1864
Quoted 10 lines
hw/pci.c +7
-0@@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) } } +static char *pcibus_get_dev_path (DeviceState *dev) +{ +PCIDevice *d = (PCIDevice *)dev; +char path[16 ]; + + snprintf(path, sizeof(path), "%04x:%02x:%02x.%x", + 0 /* FIXME for segment support */, d->config[PCI_SECONDARY_BUS],
pci_find_domain(d->bus)
Quoted 10 lines
hw/pci.c +5
-0+ PCI_SLOT(d->devfn), PCI_FUNC(d->devfn)); + +return strdup (path); +} +static PCIDeviceInfo bridge_info = { .qdev.name ="pci-bridge" , .qdev.size =sizeof (PCIBridge),
Signature · 1 line
yamahata
Re: [Qemu-devel] [PATCH 03/15] pci: Implement BusInfo.get_dev_path()
Quoted 34 lines · Isaku Yamahata
Quoted 33 lines · Alex Williamson
This works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely describes a global address. No need to traverse up the qdev tree. PCI segment support is a placeholder for compatibility once we support multiple segments.
Signed-off-by Alex Williamson <[email protected]>---
hw/pci.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)hw/pci.c +2
-0@@ -58,11 +58,13 @@ struct PCIBus { };static void pcibus_dev_print (Monitor *mon,DeviceState *dev,int indent); +static char *pcibus_get_dev_path (DeviceState *dev);static struct BusInfo pci_bus_info = { .name ="PCI" , .size =sizeof (PCIBus), .print_dev = pcibus_dev_print, + .get_dev_path = pcibus_get_dev_path, .props = (Property []) {DEFINE_PROP_PCI_DEVFN ("addr" , PCIDevice, devfn,-1 ),DEFINE_PROP_STRING ("romfile" , PCIDevice, romfile),@@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) } }
Quoted 9 lines
hw/pci.c static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) · line 1864
Quoted 7 lines
hw/pci.c +7
-0+static char *pcibus_get_dev_path (DeviceState *dev) +{ +PCIDevice *d = (PCIDevice *)dev; +char path[16 ]; + + snprintf(path, sizeof(path), "%04x:%02x:%02x.%x", + 0 /* FIXME for segment support */, d->config[PCI_SECONDARY_BUS],
pci_find_domain(d->bus)
Thank you Isaku, I'll make the change.
Alex
PATCH 4/15 savevm: Add DeviceState param
In reply to Alex WilliamsonWhen available, we'd like to be able to access the DeviceState when registering a savevm. For buses with a get_dev_path() function, this will allow us to create more unique savevm id strings.
---
audio/audio.c | 2 +- block-migration.c | 4 ++-- exec.c | 4 ++-- hw/adb.c | 4 ++-- hw/ads7846.c | 2 +- hw/arm_gic.c | 2 +- hw/arm_timer.c | 4 ++-- hw/armv7m_nvic.c | 2 +- hw/cirrus_vga.c | 2 +- hw/cuda.c | 2 +- hw/dma.c | 4 ++-- hw/eepro100.c | 4 ++-- hw/eeprom93xx.c | 4 ++-- hw/fw_cfg.c | 2 +- hw/g364fb.c | 2 +- hw/grackle_pci.c | 4 ++-- hw/gt64xxx.c | 3 ++- hw/heathrow_pic.c | 2 +- hw/hw.h | 18 +++++++++++------- hw/i2c.c | 2 +- hw/i8254.c | 2 +- hw/i8259.c | 2 +- hw/ide/cmd646.c | 2 +- hw/ide/isa.c | 2 +- hw/ide/macio.c | 2 +- hw/ide/microdrive.c | 2 +- hw/ide/mmio.c | 2 +- hw/ide/piix.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.c | 2 +- hw/mac_nvram.c | 4 ++-- hw/max111x.c | 3 ++- hw/mipsnet.c | 4 ++-- hw/mst_fpga.c | 3 ++- hw/nand.c | 2 +- hw/openpic.c | 5 +++-- hw/pci.c | 2 +- hw/pckbd.c | 2 +- hw/piix4.c | 2 +- hw/pl011.c | 2 +- hw/pl022.c | 2 +- hw/pl061.c | 2 +- hw/ppc4xx_pci.c | 4 ++-- hw/ppce500_pci.c | 4 ++-- hw/ps2.c | 4 ++-- hw/pxa2xx.c | 27 +++++++++++++++------------ hw/pxa2xx_dma.c | 2 +- hw/pxa2xx_gpio.c | 2 +- hw/pxa2xx_keypad.c | 2 +- hw/pxa2xx_lcd.c | 2 +- hw/pxa2xx_mmci.c | 2 +- hw/pxa2xx_pic.c | 3 ++- hw/pxa2xx_timer.c | 2 +- hw/qdev.c | 4 ++-- hw/rc4030.c | 2 +- hw/serial.c | 4 ++-- hw/spitz.c | 9 +++++---- hw/ssd0323.c | 3 ++- hw/ssi-sd.c | 2 +- hw/stellaris.c | 11 ++++++----- hw/stellaris_enet.c | 4 ++-- hw/stellaris_input.c | 2 +- hw/syborg_fb.c | 2 +- hw/syborg_interrupt.c | 3 ++- hw/syborg_keyboard.c | 2 +- hw/syborg_pointer.c | 2 +- hw/syborg_rtc.c | 3 ++- hw/syborg_serial.c | 2 +- hw/syborg_timer.c | 2 +- hw/tsc2005.c | 2 +- hw/tsc210x.c | 4 ++-- hw/unin_pci.c | 6 ++++-- hw/vga-isa-mm.c | 2 +- hw/vga-isa.c | 2 +- hw/virtio-balloon.c | 3 ++- hw/virtio-blk.c | 2 +- hw/virtio-net.c | 4 ++-- hw/virtio-serial-bus.c | 2 +- hw/vmmouse.c | 2 +- hw/vmware_vga.c | 2 +- hw/zaurus.c | 2 +- qemu-timer.c | 2 +- savevm.c | 22 +++++++++++++--------- slirp/slirp.c | 5 +++-- vl.c | 2 +- 85 files changed, 163 insertions(+), 138 deletions(-)
audio/audio.c +1 -1
@@ -1901,7 +1901,7 @@ static void audio_init (void) }QLIST_INIT (&s->card_head); -vmstate_register (0 , &vmstate_audio, s); +vmstate_register (NULL ,0 , &vmstate_audio, s); }void AUD_register_card (const char *name,QEMUSoundCard *card)
block-migration.c +2 -2
@@ -638,6 +638,6 @@ void blk_mig_init(void)QSIMPLEQ_INIT (&block_mig_state.bmds_list);QSIMPLEQ_INIT (&block_mig_state.blk_list); -register_savevm_live ("block" ,0 ,1 , block_set_params, block_save_live, -NULL , block_load, &block_mig_state); +register_savevm_live (NULL ,"block" ,0 ,1 , block_set_params, + block_save_live,NULL , block_load, &block_mig_state); }
exec.c +2 -2
@@ -641,8 +641,8 @@ void cpu_exec_init(CPUState *env)cpu_list_unlock ();#endif #if defined(CPU_SAVE_VERSION ) && !defined(CONFIG_USER_ONLY ) -vmstate_register (cpu_index, &vmstate_cpu_common, env); -register_savevm ("cpu" , cpu_index,CPU_SAVE_VERSION , +vmstate_register (NULL , cpu_index, &vmstate_cpu_common, env); +register_savevm (NULL ,"cpu" , cpu_index,CPU_SAVE_VERSION , cpu_save, cpu_load, env);#endif }
hw/adb.c +2 -2
@@ -305,7 +305,7 @@ void adb_kbd_init(ADBBusState *bus) d =adb_register_device (bus,ADB_KEYBOARD , adb_kbd_request, adb_kbd_reset, s);qemu_add_kbd_event_handler (adb_kbd_put_keycode, d); -register_savevm ("adb_kbd" ,-1 ,1 , adb_kbd_save, +register_savevm (NULL ,"adb_kbd" ,-1 ,1 , adb_kbd_save, adb_kbd_load, s); }
@@ -475,6 +475,6 @@ void adb_mouse_init(ADBBusState *bus) d =adb_register_device (bus,ADB_MOUSE , adb_mouse_request, adb_mouse_reset, s);qemu_add_mouse_event_handler (adb_mouse_event, d,0 ,"QEMU ADB Mouse" ); -register_savevm ("adb_mouse" ,-1 ,1 , adb_mouse_save, +register_savevm (NULL ,"adb_mouse" ,-1 ,1 , adb_mouse_save, adb_mouse_load, s); }
hw/ads7846.c +1 -1
@@ -151,7 +151,7 @@ static int ads7846_init(SSISlave *dev)ads7846_int_update (s); -register_savevm ("ads7846" ,-1 ,0 , ads7846_save, ads7846_load, s); +register_savevm (NULL ,"ads7846" ,-1 ,0 , ads7846_save, ads7846_load, s);return 0 ; }
hw/arm_gic.c +1 -1
@@ -744,5 +744,5 @@ static void gic_init(gic_state *s) s->iomemtype =cpu_register_io_memory (gic_dist_readfn, gic_dist_writefn, s);gic_reset (s); -register_savevm ("arm_gic" ,-1 ,1 , gic_save, gic_load, s); +register_savevm (NULL ,"arm_gic" ,-1 ,1 , gic_save, gic_load, s); }
hw/arm_timer.c +2 -2
@@ -174,7 +174,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq) bh =qemu_bh_new (arm_timer_tick, s); s->timer =ptimer_init (bh); -register_savevm ("arm_timer" ,-1 ,1 , arm_timer_save, arm_timer_load, s); +register_savevm (NULL ,"arm_timer" ,-1 ,1 , arm_timer_save, arm_timer_load, s);return s; }
@@ -271,7 +271,7 @@ static int sp804_init(SysBusDevice *dev) iomemtype =cpu_register_io_memory (sp804_readfn, sp804_writefn, s);sysbus_init_mmio (dev,0x1000 , iomemtype); -register_savevm ("sp804" ,-1 ,1 , sp804_save, sp804_load, s); +register_savevm (&dev->qdev,"sp804" ,-1 ,1 , sp804_save, sp804_load, s);return 0 ; }
hw/armv7m_nvic.c +1 -1
@@ -397,7 +397,7 @@ static int armv7m_nvic_init(SysBusDevice *dev)gic_init (&s->gic);cpu_register_physical_memory (0xe000e000 ,0x1000 , s->gic.iomemtype); s->systick.timer =qemu_new_timer (vm_clock, systick_timer_tick, s); -register_savevm ("armv7m_nvic" ,-1 ,1 , nvic_save, nvic_load, s); +register_savevm (&dev->qdev,"armv7m_nvic" ,-1 ,1 , nvic_save, nvic_load, s);return 0 ; }
hw/cirrus_vga.c +1 -1
@@ -3128,7 +3128,7 @@ void isa_cirrus_vga_init(void) s->vga.ds =graphic_console_init (s->vga.update, s->vga.invalidate, s->vga.screen_dump, s->vga.text_update, &s->vga); -vmstate_register (0 , &vmstate_cirrus_vga, s); +vmstate_register (NULL ,0 , &vmstate_cirrus_vga, s);rom_add_vga (VGABIOS_CIRRUS_FILENAME );/* XXX ISA-LFB support */ }
hw/cuda.c +1 -1
@@ -763,6 +763,6 @@ void cuda_init (int *cuda_mem_index, qemu_irq irq) s->adb_poll_timer =qemu_new_timer (vm_clock, cuda_adb_poll, s); *cuda_mem_index =cpu_register_io_memory (cuda_read, cuda_write, s); -register_savevm ("cuda" ,-1 ,1 , cuda_save, cuda_load, s); +register_savevm (NULL ,"cuda" ,-1 ,1 , cuda_save, cuda_load, s);qemu_register_reset (cuda_reset, s); }
hw/dma.c +2 -2
@@ -548,8 +548,8 @@ void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit) high_page_enable ? 0x480 : -1, cpu_request_exit);dma_init2 (&dma_controllers[1 ],0xc0 ,1 ,0x88 , high_page_enable ?0x488 :-1 , cpu_request_exit); -vmstate_register (0 , &vmstate_dma, &dma_controllers[0 ]); -vmstate_register (1 , &vmstate_dma, &dma_controllers[1 ]); +vmstate_register (NULL ,0 , &vmstate_dma, &dma_controllers[0 ]); +vmstate_register (NULL ,1 , &vmstate_dma, &dma_controllers[1 ]); dma_bh =qemu_bh_new (DMA_run_bh,NULL ); }
hw/eepro100.c +2 -2
@@ -1834,7 +1834,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev)EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);cpu_unregister_io_memory (s->mmio_index); -vmstate_unregister (s->vmstate, s); +vmstate_unregister (&pci_dev->qdev, s->vmstate, s);eeprom93xx_free (s->eeprom);qemu_del_vlan_client (&s->nic->nc);return 0 ;
@@ -1893,7 +1893,7 @@ static int e100_nic_init(PCIDevice *pci_dev) s->vmstate =qemu_malloc (sizeof (vmstate_eepro100));memcpy (s->vmstate, &vmstate_eepro100,sizeof (vmstate_eepro100)); s->vmstate->name = s->nic->nc.model; -vmstate_register (-1 , s->vmstate, s); +vmstate_register (&pci_dev->qdev,-1 , s->vmstate, s);return 0 ; }
hw/eeprom93xx.c +2 -2
@@ -316,7 +316,7 @@ eeprom_t *eeprom93xx_new(uint16_t nwords)/* Output DO is tristate, read results in 1. */ eeprom->eedo =1 ;logout ("eeprom = 0x%p, nwords = %u\n" , eeprom, nwords); -vmstate_register (0 , &vmstate_eeprom, eeprom); +vmstate_register (NULL ,0 , &vmstate_eeprom, eeprom);return eeprom; }
@@ -324,7 +324,7 @@ void eeprom93xx_free(eeprom_t *eeprom) {/* Destroy EEPROM. */ logout ("eeprom = 0x%p\n" , eeprom); -vmstate_unregister (&vmstate_eeprom, eeprom); +vmstate_unregister (NULL , &vmstate_eeprom, eeprom);qemu_free (eeprom); }
hw/fw_cfg.c +1 -1
@@ -352,7 +352,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,fw_cfg_add_i16 (s,FW_CFG_MAX_CPUS , (uint16_t )max_cpus);fw_cfg_add_i16 (s,FW_CFG_BOOT_MENU , (uint16_t )boot_menu); -vmstate_register (-1 , &vmstate_fw_cfg, s); +vmstate_register (NULL ,-1 , &vmstate_fw_cfg, s);qemu_register_reset (fw_cfg_reset, s);return s;
hw/g364fb.c +1 -1
@@ -598,7 +598,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base, s->irq = irq;qemu_register_reset (g364fb_reset, s); -register_savevm ("g364fb" ,0 ,1 , g364fb_save, g364fb_load, s); +register_savevm (NULL ,"g364fb" ,0 ,1 , g364fb_save, g364fb_load, s);g364fb_reset (s); s->ds = graphic_console_init(g364fb_update_display,
hw/grackle_pci.c +2 -2
@@ -113,8 +113,8 @@ static int pci_grackle_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("grackle" ,0 ,1 , pci_grackle_save, pci_grackle_load, - &s->host_state); +register_savevm (&dev->qdev,"grackle" ,0 ,1 , pci_grackle_save, + pci_grackle_load, &s->host_state);qemu_register_reset (pci_grackle_reset, &s->host_state);return 0 ; }
hw/gt64xxx.c +2 -1
@@ -1146,7 +1146,8 @@ PCIBus *pci_gt64120_init(qemu_irq *pic)gt64120_reset (s); -register_savevm ("GT64120 PCI Bus" ,0 ,1 , gt64120_save, gt64120_load, d); +register_savevm (&d->qdev,"GT64120 PCI Bus" ,0 ,1 , + gt64120_save, gt64120_load, d);return s->pci->bus; }
hw/heathrow_pic.c +1 -1
@@ -224,7 +224,7 @@ qemu_irq *heathrow_pic_init(int *pmem_index, s->irqs = irqs[0 ]; *pmem_index =cpu_register_io_memory (pic_read, pic_write, s); -register_savevm ("heathrow_pic" ,-1 ,1 , heathrow_pic_save, +register_savevm (NULL ,"heathrow_pic" ,-1 ,1 , heathrow_pic_save, heathrow_pic_load, s);qemu_register_reset (heathrow_pic_reset, s);return qemu_allocate_irqs (heathrow_pic_set_irq, s,64 );
hw/hw.h +11 -7
@@ -245,14 +245,16 @@ typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage, void *opaque);typedef int LoadStateHandler (QEMUFile *f,void *opaque,int version_id); -int register_savevm (const char *idstr, +int register_savevm (DeviceState *dev, +const char *idstr,int instance_id,int version_id,SaveStateHandler *save_state,LoadStateHandler *load_state,void *opaque); -int register_savevm_live(const char *idstr, +int register_savevm_live(DeviceState *dev, + const char *idstr, int instance_id, int version_id, SaveSetParamsHandler *set_params,
@@ -261,7 +263,7 @@ int register_savevm_live(const char *idstr, LoadStateHandler *load_state, void *opaque); -void unregister_savevm (const char *idstr,void *opaque); +void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque);typedef void QEMUResetHandler (void *opaque);
@@ -765,11 +767,13 @@ extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id);extern void vmstate_save_state (QEMUFile *f,const VMStateDescription *vmsd,void *opaque); -extern int vmstate_register (int instance_id,const VMStateDescription *vmsd, -void *base); -extern int vmstate_register_with_alias_id (int instance_id, +extern int vmstate_register (DeviceState *dev,int instance_id, +const VMStateDescription *vmsd,void *base); +extern int vmstate_register_with_alias_id (DeviceState *dev, +int instance_id,const VMStateDescription *vmsd,void *base,int alias_id,int required_for_version); -void vmstate_unregister (const VMStateDescription *vmsd,void *opaque); +void vmstate_unregister (DeviceState *dev,const VMStateDescription *vmsd, +void *opaque);#endif
hw/i2c.c +1 -1
@@ -62,7 +62,7 @@ i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)i2c_bus *bus; bus =FROM_QBUS (i2c_bus,qbus_create (&i2c_bus_info, parent, name)); -vmstate_register (-1 , &vmstate_i2c_bus, bus); +vmstate_register (NULL ,-1 , &vmstate_i2c_bus, bus);return bus; }
hw/i8254.c +1 -1
@@ -508,7 +508,7 @@ PITState *pit_init(int base, qemu_irq irq) s->irq_timer =qemu_new_timer (vm_clock, pit_irq_timer, s); s->irq = irq; -vmstate_register (base, &vmstate_pit, pit); +vmstate_register (NULL , base, &vmstate_pit, pit);qemu_register_reset (pit_reset, pit);register_ioport_write (base,4 ,1 , pit_ioport_write, pit);register_ioport_read (base,3 ,1 , pit_ioport_read, pit);
hw/i8259.c +1 -1
@@ -483,7 +483,7 @@ static void pic_init1(int io_addr, int elcr_addr, PicState *s)register_ioport_write (elcr_addr,1 ,1 , elcr_ioport_write, s);register_ioport_read (elcr_addr,1 ,1 , elcr_ioport_read, s); } -vmstate_register (io_addr, &vmstate_pic, s); +vmstate_register (NULL , io_addr, &vmstate_pic, s);qemu_register_reset (pic_reset, s); }
hw/ide/cmd646.c +1 -1
@@ -263,7 +263,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)ide_init2 (&d->bus[0 ], irq[0 ]);ide_init2 (&d->bus[1 ], irq[1 ]); -vmstate_register (0 , &vmstate_ide_pci, d); +vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d);qemu_register_reset (cmd646_reset, d);return 0 ; }
hw/ide/isa.c +1 -1
@@ -71,7 +71,7 @@ static int isa_ide_initfn(ISADevice *dev)ide_init_ioport (&s->bus, s->iobase, s->iobase2);isa_init_irq (dev, &s->irq, s->isairq);ide_init2 (&s->bus, s->irq); -vmstate_register (0 , &vmstate_ide_isa, s); +vmstate_register (&dev->qdev,0 , &vmstate_ide_isa, s);return 0 ; };
hw/ide/macio.c +1 -1
@@ -321,7 +321,7 @@ int pmac_ide_init (DriveInfo **hd_table, qemu_irq irq, pmac_ide_memory =cpu_register_io_memory (pmac_ide_read, pmac_ide_write, d); -vmstate_register (0 , &vmstate_pmac, d); +vmstate_register (NULL ,0 , &vmstate_pmac, d);qemu_register_reset (pmac_ide_reset, d);return pmac_ide_memory;
hw/ide/microdrive.c +1 -1
@@ -545,7 +545,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv) md->bus.ifs[0 ].mdata_size =METADATA_SIZE ; md->bus.ifs[0 ].mdata_storage = (uint8_t *)qemu_mallocz (METADATA_SIZE ); -vmstate_register (-1 , &vmstate_microdrive, md); +vmstate_register (NULL ,-1 , &vmstate_microdrive, md);return &md->card; }
hw/ide/mmio.c +1 -1
@@ -133,7 +133,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, mem2 =cpu_register_io_memory (mmio_ide_status, mmio_ide_cmd, s);cpu_register_physical_memory (membase,16 << shift, mem1);cpu_register_physical_memory (membase2,2 << shift, mem2); -vmstate_register (0 , &vmstate_ide_mmio, s); +vmstate_register (NULL ,0 , &vmstate_ide_mmio, s);qemu_register_reset (mmio_ide_reset, s); }
hw/ide/piix.c +1 -1
@@ -128,7 +128,7 @@ static int pci_piix_ide_initfn(PCIIDEState *d)pci_register_bar (&d->dev,4 ,0x10 ,PCI_BASE_ADDRESS_SPACE_IO , bmdma_map); -vmstate_register (0 , &vmstate_ide_pci, d); +vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d);ide_bus_new (&d->bus[0 ], &d->dev.qdev);ide_bus_new (&d->bus[1 ], &d->dev.qdev);
hw/m48t59.c +1 -1
@@ -694,7 +694,7 @@ static void m48t59_init_common(M48t59State *s) }qemu_get_timedate (&s->alarm,0 ); -register_savevm ("m48t59" ,-1 ,1 , m48t59_save, m48t59_load, s); +register_savevm (NULL ,"m48t59" ,-1 ,1 , m48t59_save, m48t59_load, s); }static int m48t59_init_isa1 (ISADevice *dev)
hw/mac_dbdma.c +1 -1
@@ -845,7 +845,7 @@ void* DBDMA_init (int *dbdma_mem_index) s =qemu_mallocz (sizeof (DBDMA_channel) *DBDMA_CHANNELS ); *dbdma_mem_index =cpu_register_io_memory (dbdma_read, dbdma_write, s); -register_savevm ("dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s); +register_savevm (NULL ,"dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s);qemu_register_reset (dbdma_reset, s); dbdma_bh =qemu_bh_new (DBDMA_run_bh, s);
hw/mac_nvram.c +2 -2
@@ -140,8 +140,8 @@ MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size, s->mem_index =cpu_register_io_memory (nvram_read, nvram_write, s); *mem_index = s->mem_index; -register_savevm ("macio_nvram" ,-1 ,1 , macio_nvram_save, macio_nvram_load, - s); +register_savevm (NULL ,"macio_nvram" ,-1 ,1 , macio_nvram_save, + macio_nvram_load, s);qemu_register_reset (macio_nvram_reset, s);return s;
hw/max111x.c +2 -1
@@ -143,7 +143,8 @@ static int max111x_init(SSISlave *dev, int inputs) s->input[7 ] =0x80 ; s->com =0 ; -register_savevm ("max111x" ,-1 ,0 , max111x_save, max111x_load, s); +register_savevm (&dev->qdev,"max111x" ,-1 ,0 , + max111x_save, max111x_load, s);return 0 ; }
hw/mipsnet.c +2 -2
@@ -239,7 +239,7 @@ static void mipsnet_cleanup(VLANClientState *nc) {MIPSnetState *s =DO_UPCAST (NICState, nc, nc)->opaque; -unregister_savevm ("mipsnet" , s); +unregister_savevm (NULL ,"mipsnet" , s);isa_unassign_ioport (s->io_base,36 );
@@ -284,5 +284,5 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) }mipsnet_reset (s); -register_savevm ("mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s); +register_savevm (NULL ,"mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s); }
hw/mst_fpga.c +2 -1
@@ -234,6 +234,7 @@ qemu_irq *mst_irq_init(PXA2xxState *cpu, uint32_t base, int irq) iomemtype =cpu_register_io_memory (mst_fpga_readfn, mst_fpga_writefn, s);cpu_register_physical_memory (base,0x00100000 , iomemtype); -register_savevm ("mainstone_fpga" ,0 ,0 , mst_fpga_save, mst_fpga_load, s); +register_savevm (NULL ,"mainstone_fpga" ,0 ,0 , mst_fpga_save, + mst_fpga_load, s);return qi; }
hw/nand.c +1 -1
@@ -502,7 +502,7 @@ NANDFlashState *nand_init(int manf_id, int chip_id)is used. */ s->ioaddr = s->io; -register_savevm ("nand" ,-1 ,0 , nand_save, nand_load, s); +register_savevm (NULL ,"nand" ,-1 ,0 , nand_save, nand_load, s);return s; }
hw/openpic.c +3 -2
@@ -1234,7 +1234,8 @@ qemu_irq *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, opp->irq_out = irq_out; opp->need_swap =1 ; -register_savevm ("openpic" ,0 ,2 , openpic_save, openpic_load, opp); +register_savevm (&opp->pci_dev.qdev,"openpic" ,0 ,2 , + openpic_save, openpic_load, opp);qemu_register_reset (openpic_reset, opp); opp->irq_raise = openpic_irq_raise;
@@ -1692,7 +1693,7 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus, mpp->irq_raise = mpic_irq_raise; mpp->reset = mpic_reset; -register_savevm ("mpic" ,0 ,2 , openpic_save, openpic_load, mpp); +register_savevm (NULL ,"mpic" ,0 ,2 , openpic_save, openpic_load, mpp);qemu_register_reset (mpic_reset, mpp);return qemu_allocate_irqs (openpic_set_irq, mpp, mpp->max_irq);
hw/pci.c +1 -1
@@ -232,7 +232,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,QLIST_INIT (&bus->child);pci_host_bus_register (0 , bus);/* for now only pci domain 0 is supported */ -vmstate_register (-1 , &vmstate_pcibus, bus); +vmstate_register (NULL ,-1 , &vmstate_pcibus, bus);qemu_register_reset (pci_bus_reset, bus); }
hw/pckbd.c +1 -1
@@ -418,7 +418,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, s->irq_mouse = mouse_irq; s->mask = mask; -vmstate_register (0 , &vmstate_kbd, s); +vmstate_register (NULL ,0 , &vmstate_kbd, s); s_io_memory =cpu_register_io_memory (kbd_mm_read, kbd_mm_write, s);cpu_register_physical_memory (base, size, s_io_memory);
hw/piix4.c +1 -1
@@ -87,7 +87,7 @@ static int piix4_initfn(PCIDevice *d)uint8_t *pci_conf;isa_bus_new (&d->qdev); -register_savevm ("PIIX4" ,0 ,2 , piix_save, piix_load, d); +register_savevm (&d->qdev,"PIIX4" ,0 ,2 , piix_save, piix_load, d); pci_conf = d->config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_INTEL );
hw/pl011.c +1 -1
@@ -306,7 +306,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id)qemu_chr_add_handlers (s->chr, pl011_can_receive, pl011_receive, pl011_event, s); } -register_savevm ("pl011_uart" ,-1 ,1 , pl011_save, pl011_load, s); +register_savevm (&dev->qdev,"pl011_uart" ,-1 ,1 , pl011_save, pl011_load, s);return 0 ; }
hw/pl022.c +1 -1
@@ -299,7 +299,7 @@ static int pl022_init(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq); s->ssi =ssi_create_bus (&dev->qdev,"ssi" );pl022_reset (s); -register_savevm ("pl022_ssp" ,-1 ,1 , pl022_save, pl022_load, s); +register_savevm (&dev->qdev,"pl022_ssp" ,-1 ,1 , pl022_save, pl022_load, s);return 0 ; }
hw/pl061.c +1 -1
@@ -303,7 +303,7 @@ static int pl061_init(SysBusDevice *dev)qdev_init_gpio_in (&dev->qdev, pl061_set_irq,8 );qdev_init_gpio_out (&dev->qdev, s->out,8 );pl061_reset (s); -register_savevm ("pl061_gpio" ,-1 ,1 , pl061_save, pl061_load, s); +register_savevm (&dev->qdev,"pl061_gpio" ,-1 ,1 , pl061_save, pl061_load, s);return 0 ; }
hw/ppc4xx_pci.c +2 -2
@@ -392,8 +392,8 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],qemu_register_reset (ppc4xx_pci_reset, controller);/* XXX load/save code not tested. */ -register_savevm ("ppc4xx_pci" , ppc4xx_pci_id++,1 , - ppc4xx_pci_save, ppc4xx_pci_load, controller); +register_savevm (&controller->pci_dev->qdev,"ppc4xx_pci" , ppc4xx_pci_id++, +1 , ppc4xx_pci_save, ppc4xx_pci_load, controller);return controller->pci_state.bus;
hw/ppce500_pci.c +2 -2
@@ -310,8 +310,8 @@ PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers) PCIE500_REG_SIZE, index);/* XXX load/save code not tested. */ -register_savevm ("ppce500_pci" , ppce500_pci_id++,1 , - ppce500_pci_save, ppce500_pci_load, controller); +register_savevm (&d->qdev,"ppce500_pci" , ppce500_pci_id++, +1 , ppce500_pci_save, ppce500_pci_load, controller);return controller->pci_state.bus;
hw/ps2.c +2 -2
@@ -595,7 +595,7 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg) s->common.update_irq = update_irq; s->common.update_arg = update_arg; s->scancode_set =2 ; -vmstate_register (0 , &vmstate_ps2_keyboard, s); +vmstate_register (NULL ,0 , &vmstate_ps2_keyboard, s);qemu_add_kbd_event_handler (ps2_put_keycode, s);qemu_register_reset (ps2_kbd_reset, s);return s;
@@ -607,7 +607,7 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg) s->common.update_irq = update_irq; s->common.update_arg = update_arg; -vmstate_register (0 , &vmstate_ps2_mouse, s); +vmstate_register (NULL ,0 , &vmstate_ps2_mouse, s);qemu_add_mouse_event_handler (ps2_mouse_event, s,0 ,"QEMU PS/2 Mouse" );qemu_register_reset (ps2_mouse_reset, s);return s;
hw/pxa2xx.c +15 -12
@@ -860,7 +860,7 @@ static int pxa2xx_ssp_init(SysBusDevice *dev) iomemtype =cpu_register_io_memory (pxa2xx_ssp_readfn, pxa2xx_ssp_writefn, s);sysbus_init_mmio (dev,0x1000 , iomemtype); -register_savevm ("pxa2xx_ssp" ,-1 ,0 , +register_savevm (&dev->qdev,"pxa2xx_ssp" ,-1 ,0 , pxa2xx_ssp_save, pxa2xx_ssp_load, s); s->bus =ssi_create_bus (&dev->qdev,"ssi" );
@@ -1515,7 +1515,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(target_phys_addr_t base,cpu_register_physical_memory (base & ~region_size, region_size +1 , iomemtype); -vmstate_register (base, &vmstate_pxa2xx_i2c, s); +vmstate_register (NULL , base, &vmstate_pxa2xx_i2c, s);return s; }
@@ -1751,7 +1751,7 @@ static PXA2xxI2SState *pxa2xx_i2s_init(target_phys_addr_t base, pxa2xx_i2s_writefn, s);cpu_register_physical_memory (base,0x100000 , iomemtype); -register_savevm ("pxa2xx_i2s" , base,0 , +register_savevm (NULL ,"pxa2xx_i2s" , base,0 , pxa2xx_i2s_save, pxa2xx_i2s_load, s);return s;
@@ -2014,7 +2014,8 @@ static PXA2xxFIrState *pxa2xx_fir_init(target_phys_addr_t base,qemu_chr_add_handlers (chr, pxa2xx_fir_is_empty, pxa2xx_fir_rx, pxa2xx_fir_event, s); -register_savevm ("pxa2xx_fir" ,0 ,0 , pxa2xx_fir_save, pxa2xx_fir_load, s); +register_savevm (NULL ,"pxa2xx_fir" ,0 ,0 , pxa2xx_fir_save, + pxa2xx_fir_load, s);return s; }
@@ -2099,7 +2100,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s);cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
@@ -2110,13 +2111,13 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s);cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); s->pm_base =0x40f00000 ; iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s);cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm ("pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s);for (i =0 ; pxa27x_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
@@ -2140,7 +2141,8 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) pxa2xx_rtc_writefn, s);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm ("pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, pxa2xx_rtc_load, s); +register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, + pxa2xx_rtc_load, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
@@ -2219,7 +2221,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s);cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
@@ -2230,13 +2232,13 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s);cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); s->pm_base =0x40f00000 ; iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s);cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm ("pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s);for (i =0 ; pxa255_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
@@ -2260,7 +2262,8 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) pxa2xx_rtc_writefn, s);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm ("pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, pxa2xx_rtc_load, s); +register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, + pxa2xx_rtc_load, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
hw/pxa2xx_dma.c +1 -1
@@ -507,7 +507,7 @@ static PXA2xxDMAState *pxa2xx_dma_init(target_phys_addr_t base, pxa2xx_dma_writefn, s);cpu_register_physical_memory (base,0x00010000 , iomemtype); -register_savevm ("pxa2xx_dma" ,0 ,0 , pxa2xx_dma_save, pxa2xx_dma_load, s); +register_savevm (NULL ,"pxa2xx_dma" ,0 ,0 , pxa2xx_dma_save, pxa2xx_dma_load, s);return s; }
hw/pxa2xx_gpio.c +1 -1
@@ -312,7 +312,7 @@ PXA2xxGPIOInfo *pxa2xx_gpio_init(target_phys_addr_t base, pxa2xx_gpio_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype); -register_savevm ("pxa2xx_gpio" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_gpio" ,0 ,0 , pxa2xx_gpio_save, pxa2xx_gpio_load, s);return s;
hw/pxa2xx_keypad.c +1 -1
@@ -317,7 +317,7 @@ PXA2xxKeyPadState *pxa27x_keypad_init(target_phys_addr_t base, pxa2xx_keypad_writefn, s);cpu_register_physical_memory (base,0x00100000 , iomemtype); -register_savevm ("pxa2xx_keypad" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_keypad" ,0 ,0 , pxa2xx_keypad_save, pxa2xx_keypad_load, s);return s;
hw/pxa2xx_lcd.c +1 -1
@@ -970,7 +970,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq)exit (1 ); } -register_savevm ("pxa2xx_lcdc" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_lcdc" ,0 ,0 , pxa2xx_lcdc_save, pxa2xx_lcdc_load, s);return s;
hw/pxa2xx_mmci.c +1 -1
@@ -534,7 +534,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base,/* Instantiate the actual storage */ s->card =sd_init (bd,0 ); -register_savevm ("pxa2xx_mmci" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_mmci" ,0 ,0 , pxa2xx_mmci_save, pxa2xx_mmci_load, s);return s;
hw/pxa2xx_pic.c +2 -1
@@ -306,7 +306,8 @@ qemu_irq *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)/* Enable IC coprocessor access. */ cpu_arm_set_cp_io (env,6 , pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s); -register_savevm ("pxa2xx_pic" ,0 ,0 , pxa2xx_pic_save, pxa2xx_pic_load, s); +register_savevm (NULL ,"pxa2xx_pic" ,0 ,0 , pxa2xx_pic_save, + pxa2xx_pic_load, s);return qi; }
hw/pxa2xx_timer.c +1 -1
@@ -455,7 +455,7 @@ static pxa2xx_timer_info *pxa2xx_timer_init(target_phys_addr_t base, pxa2xx_timer_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype); -register_savevm ("pxa2xx_timer" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_timer" ,0 ,0 , pxa2xx_timer_save, pxa2xx_timer_load, s);return s;
hw/qdev.c +2 -2
@@ -280,7 +280,7 @@ int qdev_init(DeviceState *dev) }qemu_register_reset (qdev_reset, dev);if (dev->info->vmsd) { -vmstate_register_with_alias_id (-1 , dev->info->vmsd, dev, +vmstate_register_with_alias_id (dev,-1 , dev->info->vmsd, dev, dev->instance_id_alias, dev->alias_required_for_version); }
@@ -342,7 +342,7 @@ void qdev_free(DeviceState *dev)qbus_free (bus); }if (dev->info->vmsd) -vmstate_unregister (dev->info->vmsd, dev); +vmstate_unregister (dev, dev->info->vmsd, dev);if (dev->info->exit) dev->info->exit (dev);if (dev->opts)
hw/rc4030.c +1 -1
@@ -813,7 +813,7 @@ void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus, s->jazz_bus_irq = jazz_bus;qemu_register_reset (rc4030_reset, s); -register_savevm ("rc4030" ,0 ,2 , rc4030_save, rc4030_load, s); +register_savevm (NULL ,"rc4030" ,0 ,2 , rc4030_save, rc4030_load, s);rc4030_reset (s); s_chipset =cpu_register_io_memory (rc4030_read, rc4030_write, s);
hw/serial.c +2 -2
@@ -813,7 +813,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, s->chr = chr;serial_init_core (s); -vmstate_register (base, &vmstate_serial, s); +vmstate_register (NULL , base, &vmstate_serial, s);register_ioport_write (base,8 ,1 , serial_ioport_write, s);register_ioport_read (base,8 ,1 , serial_ioport_read, s);
@@ -948,7 +948,7 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift, s->chr = chr;serial_init_core (s); -vmstate_register (base, &vmstate_serial, s); +vmstate_register (NULL , base, &vmstate_serial, s);if (ioregister) {if (be) {
hw/spitz.c +5 -4
@@ -178,7 +178,7 @@ static void sl_flash_register(PXA2xxState *cpu, int size) sl_writefn, s);cpu_register_physical_memory (FLASH_BASE ,0x40 , iomemtype); -register_savevm ("sl_flash" ,0 ,0 , sl_save, sl_load, s); +register_savevm (NULL ,"sl_flash" ,0 ,0 , sl_save, sl_load, s); }/* Spitz Keyboard */
@@ -508,7 +508,7 @@ static void spitz_keyboard_register(PXA2xxState *cpu)spitz_keyboard_pre_map (s);qemu_add_kbd_event_handler ((QEMUPutKBDEvent *) spitz_keyboard_handler, s); -register_savevm ("spitz_keyboard" ,0 ,0 , +register_savevm (NULL ,"spitz_keyboard" ,0 ,0 , spitz_keyboard_save, spitz_keyboard_load, s); }
@@ -613,7 +613,7 @@ static int spitz_lcdtg_init(SSISlave *dev) s->bl_power =0 ; s->bl_intensity =0x20 ; -register_savevm ("spitz-lcdtg" ,-1 ,1 , +register_savevm (&dev->qdev,"spitz-lcdtg" ,-1 ,1 , spitz_lcdtg_save, spitz_lcdtg_load, s);return 0 ; }
@@ -708,7 +708,8 @@ static int corgi_ssp_init(SSISlave *dev) s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" ); s->bus[2 ] =ssi_create_bus (&dev->qdev,"ssi2" ); -register_savevm ("spitz_ssp" ,-1 ,1 , spitz_ssp_save, spitz_ssp_load, s); +register_savevm (&dev->qdev,"spitz_ssp" ,-1 ,1 , + spitz_ssp_save, spitz_ssp_load, s);return 0 ; }
hw/ssd0323.c +2 -1
@@ -335,7 +335,8 @@ static int ssd0323_init(SSISlave *dev)qdev_init_gpio_in (&dev->qdev, ssd0323_cd,1 ); -register_savevm ("ssd0323_oled" ,-1 ,1 , ssd0323_save, ssd0323_load, s); +register_savevm (&dev->qdev,"ssd0323_oled" ,-1 ,1 , + ssd0323_save, ssd0323_load, s);return 0 ; }
hw/ssi-sd.c +1 -1
@@ -236,7 +236,7 @@ static int ssi_sd_init(SSISlave *dev) s->mode =SSI_SD_CMD ; bs =qdev_init_bdrv (&dev->qdev,IF_SD ); s->sd =sd_init (bs,1 ); -register_savevm ("ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s); +register_savevm (&dev->qdev,"ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s);return 0 ; }
hw/stellaris.c +6 -5
@@ -354,7 +354,8 @@ static int stellaris_gptm_init(SysBusDevice *dev) s->opaque[0 ] = s->opaque[1 ] = s; s->timer[0 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[0 ]); s->timer[1 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[1 ]); -register_savevm ("stellaris_gptm" ,-1 ,1 , gptm_save, gptm_load, s); +register_savevm (&dev->qdev,"stellaris_gptm" ,-1 ,1 , + gptm_save, gptm_load, s);return 0 ; }
@@ -673,7 +674,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq, ssys_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype);ssys_reset (s); -register_savevm ("stellaris_sys" ,-1 ,1 , ssys_save, ssys_load, s); +register_savevm (NULL ,"stellaris_sys" ,-1 ,1 , ssys_save, ssys_load, s);return 0 ; }
@@ -887,7 +888,7 @@ static int stellaris_i2c_init(SysBusDevice * dev)sysbus_init_mmio (dev,0x1000 , iomemtype);/* ??? For now we only implement the master interface. */ stellaris_i2c_reset (s); -register_savevm ("stellaris_i2c" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_i2c" ,-1 ,1 , stellaris_i2c_save, stellaris_i2c_load, s);return 0 ; }
@@ -1196,7 +1197,7 @@ static int stellaris_adc_init(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , iomemtype);stellaris_adc_reset (s);qdev_init_gpio_in (&dev->qdev, stellaris_adc_trigger,1 ); -register_savevm ("stellaris_adc" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_adc" ,-1 ,1 , stellaris_adc_save, stellaris_adc_load, s);return 0 ; }
@@ -1256,7 +1257,7 @@ static int stellaris_ssi_bus_init(SSISlave *dev) s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" );qdev_init_gpio_in (&dev->qdev, stellaris_ssi_bus_select,1 ); -register_savevm ("stellaris_ssi_bus" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_ssi_bus" ,-1 ,1 , stellaris_ssi_bus_save, stellaris_ssi_bus_load, s);return 0 ; }
hw/stellaris_enet.c +2 -2
@@ -389,7 +389,7 @@ static void stellaris_enet_cleanup(VLANClientState *nc) {stellaris_enet_state *s =DO_UPCAST (NICState, nc, nc)->opaque; -unregister_savevm ("stellaris_enet" , s); +unregister_savevm (&s->busdev.qdev,"stellaris_enet" , s);cpu_unregister_io_memory (s->mmio_index);
@@ -419,7 +419,7 @@ static int stellaris_enet_init(SysBusDevice *dev)qemu_format_nic_info_str (&s->nic->nc, s->conf.macaddr.a);stellaris_enet_reset (s); -register_savevm ("stellaris_enet" ,-1 ,1 , +register_savevm (&s->busdev.qdev,"stellaris_enet" ,-1 ,1 , stellaris_enet_save, stellaris_enet_load, s);return 0 ; }
hw/stellaris_input.c +1 -1
@@ -86,6 +86,6 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) } s->num_buttons = n;qemu_add_kbd_event_handler (stellaris_gamepad_put_key, s); -register_savevm ("stellaris_gamepad" ,-1 ,1 , +register_savevm (NULL ,"stellaris_gamepad" ,-1 ,1 , stellaris_gamepad_save, stellaris_gamepad_load, s); }
hw/syborg_fb.c +1 -1
@@ -526,7 +526,7 @@ static int syborg_fb_init(SysBusDevice *dev)if (!s->rows) s->rows =ds_get_height (s->ds); -register_savevm ("syborg_framebuffer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_framebuffer" ,-1 ,1 , syborg_fb_save, syborg_fb_load, s);return 0 ; }
hw/syborg_interrupt.c +2 -1
@@ -214,7 +214,8 @@ static int syborg_int_init(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , iomemtype); s->flags =qemu_mallocz (s->num_irqs *sizeof (syborg_int_flags)); -register_savevm ("syborg_int" ,-1 ,1 , syborg_int_save, syborg_int_load, s); +register_savevm (&dev->qdev,"syborg_int" ,-1 ,1 , syborg_int_save, + syborg_int_load, s);return 0 ; }
hw/syborg_keyboard.c +1 -1
@@ -220,7 +220,7 @@ static int syborg_keyboard_init(SysBusDevice *dev)qemu_add_kbd_event_handler (syborg_keyboard_event, s); -register_savevm ("syborg_keyboard" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_keyboard" ,-1 ,1 , syborg_keyboard_save, syborg_keyboard_load, s);return 0 ; }
hw/syborg_pointer.c +1 -1
@@ -218,7 +218,7 @@ static int syborg_pointer_init(SysBusDevice *dev)qemu_add_mouse_event_handler (syborg_pointer_event, s, s->absolute,"Syborg Pointer" ); -register_savevm ("syborg_pointer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_pointer" ,-1 ,1 , syborg_pointer_save, syborg_pointer_load, s);return 0 ; }
hw/syborg_rtc.c +2 -1
@@ -136,7 +136,8 @@ static int syborg_rtc_init(SysBusDevice *dev)qemu_get_timedate (&tm,0 ); s->offset = (uint64_t )mktime (&tm) *1000000000 ; -register_savevm ("syborg_rtc" ,-1 ,1 , syborg_rtc_save, syborg_rtc_load, s); +register_savevm (&dev->qdev,"syborg_rtc" ,-1 ,1 , + syborg_rtc_save, syborg_rtc_load, s);return 0 ; }
hw/syborg_serial.c +1 -1
@@ -335,7 +335,7 @@ static int syborg_serial_init(SysBusDevice *dev) } s->read_fifo =qemu_mallocz (s->fifo_size *sizeof (s->read_fifo[0 ])); -register_savevm ("syborg_serial" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_serial" ,-1 ,1 , syborg_serial_save, syborg_serial_load, s);return 0 ; }
hw/syborg_timer.c +1 -1
@@ -221,7 +221,7 @@ static int syborg_timer_init(SysBusDevice *dev) bh =qemu_bh_new (syborg_timer_tick, s); s->timer =ptimer_init (bh);ptimer_set_freq (s->timer, s->freq); -register_savevm ("syborg_timer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_timer" ,-1 ,1 , syborg_timer_save, syborg_timer_load, s);return 0 ; }
hw/tsc2005.c +1 -1
@@ -548,7 +548,7 @@ void *tsc2005_init(qemu_irq pintdav) "QEMU TSC2005-driven Touchscreen");qemu_register_reset ((void *) tsc2005_reset, s); -register_savevm ("tsc2005" ,-1 ,0 , tsc2005_save, tsc2005_load, s); +register_savevm (NULL ,"tsc2005" ,-1 ,0 , tsc2005_save, tsc2005_load, s);return s; }
hw/tsc210x.c +2 -2
@@ -1143,7 +1143,7 @@ uWireSlave *tsc2102_init(qemu_irq pint)AUD_register_card (s->name, &s->card);qemu_register_reset ((void *) tsc210x_reset, s); -register_savevm (s->name,-1 ,0 , +register_savevm (NULL , s->name,-1 ,0 , tsc210x_save, tsc210x_load, s);return &s->chip;
@@ -1194,7 +1194,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)AUD_register_card (s->name, &s->card);qemu_register_reset ((void *) tsc210x_reset, s); -register_savevm (s->name,-1 ,0 , tsc210x_save, tsc210x_load, s); +register_savevm (NULL , s->name,-1 ,0 , tsc210x_save, tsc210x_load, s);return &s->chip; }
hw/unin_pci.c +4 -2
@@ -158,7 +158,8 @@ static int pci_unin_main_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("uninorth" ,0 ,1 , pci_unin_save, pci_unin_load, &s->host_state); +register_savevm (&dev->qdev,"uninorth" ,0 ,1 , + pci_unin_save, pci_unin_load, &s->host_state);qemu_register_reset (pci_unin_reset, &s->host_state);return 0 ; }
@@ -178,7 +179,8 @@ static int pci_u3_agp_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("uninorth" ,0 ,1 , pci_unin_save, pci_unin_load, &s->host_state); +register_savevm (&dev->qdev,"uninorth" ,0 ,1 , + pci_unin_save, pci_unin_load, &s->host_state);qemu_register_reset (pci_unin_reset, &s->host_state);return 0 ;
hw/vga-isa-mm.c +1 -1
@@ -100,7 +100,7 @@ static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base, s_ioport_ctrl =cpu_register_io_memory (vga_mm_read_ctrl, vga_mm_write_ctrl, s); vga_io_memory =cpu_register_io_memory (vga_mem_read, vga_mem_write, s); -vmstate_register (0 , &vmstate_vga_common, s); +vmstate_register (NULL ,0 , &vmstate_vga_common, s);cpu_register_physical_memory (ctrl_base,0x100000 , s_ioport_ctrl); s->vga.bank_offset =0 ;
hw/vga-isa.c +1 -1
@@ -37,7 +37,7 @@ int isa_vga_init(void)vga_common_init (s,VGA_RAM_SIZE );vga_init (s); -vmstate_register (0 , &vmstate_vga_common, s); +vmstate_register (NULL ,0 , &vmstate_vga_common, s); s->ds =graphic_console_init (s->update, s->invalidate, s->screen_dump, s->text_update, s);
hw/virtio-balloon.c +2 -1
@@ -270,7 +270,8 @@ VirtIODevice *virtio_balloon_init(DeviceState *dev)reset_stats (s);qemu_add_balloon_handler (virtio_balloon_to_target, s); -register_savevm ("virtio-balloon" ,-1 ,1 , virtio_balloon_save, virtio_balloon_load, s); +register_savevm (dev,"virtio-balloon" ,-1 ,1 , + virtio_balloon_save, virtio_balloon_load, s);return &s->vdev; }
hw/virtio-blk.c +1 -1
@@ -498,7 +498,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) s->vq =virtio_add_queue (&s->vdev,128 , virtio_blk_handle_output);qemu_add_vm_change_state_handler (virtio_blk_dma_restart_cb, s); -register_savevm ("virtio-blk" , virtio_blk_id++,2 , +register_savevm (dev,"virtio-blk" , virtio_blk_id++,2 , virtio_blk_save, virtio_blk_load, s);return &s->vdev;
hw/virtio-net.c +2 -2
@@ -923,7 +923,7 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) n->vlans =qemu_mallocz (MAX_VLAN >>3 ); -register_savevm ("virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , +register_savevm (NULL ,"virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , virtio_net_save, virtio_net_load, n); n->vmstate =qemu_add_vm_change_state_handler (virtio_net_vmstate_change, n);
@@ -941,7 +941,7 @@ void virtio_net_exit(VirtIODevice *vdev)qemu_purge_queued_packets (&n->nic->nc); -unregister_savevm ("virtio-net" , n); +unregister_savevm (NULL ,"virtio-net" , n);qemu_free (n->mac_table.macs);qemu_free (n->vlans);
hw/virtio-serial-bus.c +1 -1
@@ -790,7 +790,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)* Register for the savevm section with the virtio-console name * to preserve backward compat */ -register_savevm ("virtio-console" ,-1 ,2 , virtio_serial_save, +register_savevm (dev,"virtio-console" ,-1 ,2 , virtio_serial_save, virtio_serial_load, vser);return vdev;
hw/vmmouse.c +1 -1
@@ -274,7 +274,7 @@ void *vmmouse_init(void *m)vmport_register (VMMOUSE_STATUS , vmmouse_ioport_read, s);vmport_register (VMMOUSE_COMMAND , vmmouse_ioport_read, s);vmport_register (VMMOUSE_DATA , vmmouse_ioport_read, s); -vmstate_register (0 , &vmstate_vmmouse, s); +vmstate_register (NULL ,0 , &vmstate_vmmouse, s);return s; }
hw/vmware_vga.c +1 -1
@@ -1169,7 +1169,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)vga_common_init (&s->vga, vga_ram_size);vga_init (&s->vga); -vmstate_register (0 , &vmstate_vga_common, &s->vga); +vmstate_register (NULL ,0 , &vmstate_vga_common, &s->vga);vga_init_vbe (&s->vga);
hw/zaurus.c +1 -1
@@ -230,7 +230,7 @@ ScoopInfo *scoop_init(PXA2xxState *cpu, iomemtype =cpu_register_io_memory (scoop_readfn, scoop_writefn, s);cpu_register_physical_memory (target_base,0x1000 , iomemtype); -register_savevm ("scoop" , instance,1 , scoop_save, scoop_load, s); +register_savevm (NULL ,"scoop" , instance,1 , scoop_save, scoop_load, s);return s; }
qemu-timer.c +1 -1
@@ -662,7 +662,7 @@ static const VMStateDescription vmstate_timers = {void configure_icount (const char *option) { -vmstate_register (0 , &vmstate_timers, &timers_state); +vmstate_register (NULL ,0 , &vmstate_timers, &timers_state);if (!option)return ;
savevm.c +13 -9
@@ -1026,7 +1026,8 @@ static int calculate_new_instance_id(const char *idstr)of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly distinguishing id for all instances of your device class. */ -int register_savevm_live(const char *idstr, +int register_savevm_live(DeviceState *dev, + const char *idstr, int instance_id, int version_id, SaveSetParamsHandler *set_params,
@@ -1058,18 +1059,19 @@ int register_savevm_live(const char *idstr,return 0 ; } -int register_savevm (const char *idstr, +int register_savevm (DeviceState *dev, +const char *idstr,int instance_id,int version_id,SaveStateHandler *save_state,LoadStateHandler *load_state,void *opaque) { -return register_savevm_live (idstr, instance_id, version_id, +return register_savevm_live (dev, idstr, instance_id, version_id,NULL ,NULL , save_state, load_state, opaque); } -void unregister_savevm (const char *idstr,void *opaque) +void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque) {SaveStateEntry *se, *new_se;
@@ -1081,7 +1083,7 @@ void unregister_savevm(const char *idstr, void *opaque) } } -int vmstate_register_with_alias_id (int instance_id, +int vmstate_register_with_alias_id (DeviceState *dev,int instance_id,const VMStateDescription *vmsd,void *opaque,int alias_id,int required_for_version)
@@ -1112,13 +1114,15 @@ int vmstate_register_with_alias_id(int instance_id,return 0 ; } -int vmstate_register (int instance_id,const VMStateDescription *vmsd, -void *opaque) +int vmstate_register (DeviceState *dev,int instance_id, +const VMStateDescription *vmsd,void *opaque) { -return vmstate_register_with_alias_id (instance_id, vmsd, opaque,-1 ,0 ); +return vmstate_register_with_alias_id (dev, instance_id, vmsd, + opaque,-1 ,0 ); } -void vmstate_unregister (const VMStateDescription *vmsd,void *opaque) +void vmstate_unregister (DeviceState *dev,const VMStateDescription *vmsd, +void *opaque) {SaveStateEntry *se, *new_se;
slirp/slirp.c +3 -2
@@ -232,7 +232,8 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, slirp->opaque = opaque; -register_savevm ("slirp" ,0 ,3 , slirp_state_save, slirp_state_load, slirp); +register_savevm (NULL ,"slirp" ,0 ,3 , + slirp_state_save, slirp_state_load, slirp);QTAILQ_INSERT_TAIL (&slirp_instances, slirp, entry);
@@ -243,7 +244,7 @@ void slirp_cleanup(Slirp *slirp) {QTAILQ_REMOVE (&slirp_instances, slirp, entry); -unregister_savevm ("slirp" , slirp); +unregister_savevm (NULL ,"slirp" , slirp);qemu_free (slirp->tftp_prefix);qemu_free (slirp->bootp_filename);
vl.c +1 -1
@@ -2794,7 +2794,7 @@ int main(int argc, char **argv, char **envp)if (qemu_opts_foreach (&qemu_drive_opts, drive_init_func, &machine->use_scsi,1 ) !=0 )exit (1 ); -register_savevm_live ("ram" ,0 ,3 ,NULL , ram_save_live,NULL , +register_savevm_live (NULL ,"ram" ,0 ,3 ,NULL , ram_save_live,NULL , ram_load,NULL );if (nb_numa_nodes >0 ) {
PATCH 5/15 savevm: Make use of DeviceState
In reply to Alex WilliamsonFor callers that pass a device we can traverse up the qdev tree and make use of the BusInfo.get_dev_path information for creating unique savevm id strings. This avoids needing to rely on the instance number, which can cause problems with device initialization order and hotplug.
For compatibility, we also store away the old id string and instance so we can accept migrations from VMs as we add new get_dev_path implementations.
---
savevm.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 79 insertions(+), 5 deletions(-)
savevm.c +79 -5
@@ -72,6 +72,7 @@#include "qemu-common.h" #include "hw/hw.h" +#include "hw/qdev.h" #include "net.h" #include "monitor.h" #include "sysemu.h"
@@ -988,6 +989,11 @@ const VMStateInfo vmstate_info_unused_buffer = { .put = put_unused_buffer, }; +typedef struct CompatEntry { +char idstr[256 ]; +int instance_id; +}CompatEntry ; + typedef struct SaveStateEntry { QTAILQ_ENTRY(SaveStateEntry) entry; char idstr[256];
@@ -1001,6 +1007,7 @@ typedef struct SaveStateEntry {LoadStateHandler *load_state;const VMStateDescription *vmsd;void *opaque; +CompatEntry *compat; } SaveStateEntry;
@@ -1022,6 +1029,23 @@ static int calculate_new_instance_id(const char *idstr)return instance_id; } +static int calculate_compat_instance_id (const char *idstr) +{ +SaveStateEntry *se; +int instance_id =0 ; + + QTAILQ_FOREACH(se, &savevm_handlers, entry) { +if (!se->compat) +continue ; + +if (strcmp (idstr, se->compat->idstr) ==0 + && instance_id <= se->compat->instance_id) { + instance_id = se->compat->instance_id +1 ; + } + } +return instance_id; +} +/* TODO: Individual devices generally have very little idea about the rest of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly
@@ -1039,7 +1063,6 @@ int register_savevm_live(DeviceState *dev,SaveStateEntry *se; se =qemu_mallocz (sizeof (SaveStateEntry)); -pstrcpy (se->idstr,sizeof (se->idstr), idstr); se->version_id = version_id; se->section_id = global_section_id++; se->set_params = set_params;
@@ -1049,11 +1072,28 @@ int register_savevm_live(DeviceState *dev, se->opaque = opaque; se->vmsd =NULL ; +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +pstrcpy (se->idstr,sizeof (se->idstr), id); +pstrcat (se->idstr,sizeof (se->idstr),"/" ); +qemu_free (id); + + se->compat =qemu_mallocz (sizeof (CompatEntry)); +pstrcpy (se->compat->idstr,sizeof (se->compat->idstr), idstr); + se->compat->instance_id = instance_id ==-1 ? +calculate_compat_instance_id (idstr) : instance_id; + instance_id =-1 ; + } + } +pstrcat (se->idstr,sizeof (se->idstr), idstr); +if (instance_id ==-1 ) { - se->instance_id =calculate_new_instance_id (idstr); + se->instance_id =calculate_new_instance_id (se->idstr); }else { se->instance_id = instance_id; } +assert (!se->compat || se->instance_id ==0 );/* add at the end of list */ QTAILQ_INSERT_TAIL (&savevm_handlers, se, entry);return 0 ;
@@ -1074,9 +1114,20 @@ int register_savevm(DeviceState *dev,void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque) {SaveStateEntry *se, *new_se; +char id[256 ] ="" ; + +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *path = dev->parent_bus->info->get_dev_path (dev); +if (path) { +pstrcpy (id,sizeof (id), path); +pstrcat (id,sizeof (id),"/" ); +qemu_free (path); + } + } +pstrcat (id,sizeof (id), idstr); QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { -if (strcmp (se->idstr, idstr) ==0 && se->opaque == opaque) { +if (strcmp (se->idstr, id) ==0 && se->opaque == opaque) {QTAILQ_REMOVE (&savevm_handlers, se, entry);qemu_free (se); }
@@ -1094,7 +1145,6 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,assert (alias_id ==-1 || required_for_version >= vmsd->minimum_version_id); se =qemu_mallocz (sizeof (SaveStateEntry)); -pstrcpy (se->idstr,sizeof (se->idstr), vmsd->name); se->version_id = vmsd->version_id; se->section_id = global_section_id++; se->save_live_state =NULL ;
@@ -1104,11 +1154,28 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, se->vmsd = vmsd; se->alias_id = alias_id; +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +pstrcpy (se->idstr,sizeof (se->idstr), id); +pstrcat (se->idstr,sizeof (se->idstr),"/" ); +qemu_free (id); + + se->compat =qemu_mallocz (sizeof (CompatEntry)); +pstrcpy (se->compat->idstr,sizeof (se->compat->idstr), vmsd->name); + se->compat->instance_id = instance_id ==-1 ? +calculate_compat_instance_id (vmsd->name) : instance_id; + instance_id =-1 ; + } + } +pstrcat (se->idstr,sizeof (se->idstr), vmsd->name); +if (instance_id ==-1 ) { - se->instance_id =calculate_new_instance_id (vmsd->name); + se->instance_id =calculate_new_instance_id (se->idstr); }else { se->instance_id = instance_id; } +assert (!se->compat || se->instance_id ==0 );/* add at the end of list */ QTAILQ_INSERT_TAIL (&savevm_handlers, se, entry);return 0 ;
@@ -1454,6 +1521,13 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) (instance_id == se->instance_id || instance_id == se->alias_id))return se; +/* Migrating from an older version? */ +if (strstr (se->idstr, idstr) && se->compat) { +if (!strcmp (se->compat->idstr, idstr) && + (instance_id == se->compat->instance_id || + instance_id == se->alias_id)) +return se; + } }return NULL ; }
PATCH 6/15 eepro100: Add a dev field to eeprom new/free functions
In reply to Alex WilliamsonThis allows us to create a more meaningful savevm string.
---
hw/eepro100.c | 4 ++-- hw/eeprom93xx.c | 8 ++++---- hw/eeprom93xx.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
hw/eepro100.c +2 -2
@@ -1835,7 +1835,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev)cpu_unregister_io_memory (s->mmio_index);vmstate_unregister (&pci_dev->qdev, s->vmstate, s); -eeprom93xx_free (s->eeprom); +eeprom93xx_free (&pci_dev->qdev, s->eeprom);qemu_del_vlan_client (&s->nic->nc);return 0 ; }
@@ -1862,7 +1862,7 @@ static int e100_nic_init(PCIDevice *pci_dev)/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ - s->eeprom =eeprom93xx_new (EEPROM_SIZE ); + s->eeprom =eeprom93xx_new (&pci_dev->qdev,EEPROM_SIZE );/* Handler for memory-mapped I/O */ s->mmio_index =
hw/eeprom93xx.c +4 -4
@@ -289,7 +289,7 @@ void eeprom93xx_reset(eeprom_t *eeprom) }#endif -eeprom_t *eeprom93xx_new (uint16_t nwords) +eeprom_t *eeprom93xx_new (DeviceState *dev,uint16_t nwords) {/* Add a new EEPROM (with 16, 64 or 256 words). */ eeprom_t *eeprom;
@@ -316,15 +316,15 @@ eeprom_t *eeprom93xx_new(uint16_t nwords)/* Output DO is tristate, read results in 1. */ eeprom->eedo =1 ;logout ("eeprom = 0x%p, nwords = %u\n" , eeprom, nwords); -vmstate_register (NULL ,0 , &vmstate_eeprom, eeprom); +vmstate_register (dev,0 , &vmstate_eeprom, eeprom);return eeprom; } -void eeprom93xx_free (eeprom_t *eeprom) +void eeprom93xx_free (DeviceState *dev,eeprom_t *eeprom) {/* Destroy EEPROM. */ logout ("eeprom = 0x%p\n" , eeprom); -vmstate_unregister (NULL , &vmstate_eeprom, eeprom); +vmstate_unregister (dev, &vmstate_eeprom, eeprom);qemu_free (eeprom); }
hw/eeprom93xx.h +2 -2
@@ -23,10 +23,10 @@typedef struct _eeprom_t eeprom_t ;/* Create a new EEPROM with (nwords * 2) bytes. */ -eeprom_t *eeprom93xx_new (uint16_t nwords); +eeprom_t *eeprom93xx_new (DeviceState *dev,uint16_t nwords);/* Destroy an existing EEPROM. */ -void eeprom93xx_free (eeprom_t *eeprom); +void eeprom93xx_free (DeviceState *dev,eeprom_t *eeprom);/* Read from the EEPROM. */ uint16_t eeprom93xx_read (eeprom_t *eeprom);
PATCH 7/15 virtio-net: Incorporate a DeviceState pointer and let savevm track instances
In reply to Alex WilliamsonStuff a pointer to the DeviceState into the VirtIONet structure so that we can easily remove the vmstate entry later. Also, let vmstate track the instance number (it should always be zero internally since the device path should now be unique).
---
hw/virtio-net.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
hw/virtio-net.c +4 -3
@@ -60,6 +60,7 @@ typedef struct VirtIONetuint8_t *macs; } mac_table;uint32_t *vlans; +DeviceState *qdev; } VirtIONet;/* TODO
@@ -890,7 +891,6 @@ static void virtio_net_vmstate_change(void *opaque, int running, int reason)VirtIODevice *virtio_net_init (DeviceState *dev,NICConf *conf) {VirtIONet *n; -static int virtio_net_id; n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, sizeof(struct virtio_net_config),
@@ -923,7 +923,8 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) n->vlans =qemu_mallocz (MAX_VLAN >>3 ); -register_savevm (NULL ,"virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , + n->qdev = dev; +register_savevm (dev,"virtio-net" ,-1 ,VIRTIO_NET_VM_VERSION , virtio_net_save, virtio_net_load, n); n->vmstate =qemu_add_vm_change_state_handler (virtio_net_vmstate_change, n);
@@ -941,7 +942,7 @@ void virtio_net_exit(VirtIODevice *vdev)qemu_purge_queued_packets (&n->nic->nc); -unregister_savevm (NULL ,"virtio-net" , n); +unregister_savevm (n->qdev,"virtio-net" , n);qemu_free (n->mac_table.macs);qemu_free (n->vlans);
PATCH 8/15 qemu_ram_alloc: Add DeviceState and name parameters
In reply to Alex WilliamsonThese will be used to generate unique id strings for ramblocks. The name field is required, the device pointer is optional as most callers don't have a device. When there's no device or the device isn't a child of a bus implementing BusInfo.get_dev_path, the name should be unique for the platform.
---
cpu-common.h | 2 +- exec.c | 2 +- hw/an5206.c | 4 ++-- hw/armv7m.c | 9 ++++++--- hw/axis_dev88.c | 4 ++-- hw/dummy_m68k.c | 2 +- hw/etraxfs.c | 6 +++--- hw/g364fb.c | 2 +- hw/gumstix.c | 6 ++++-- hw/integratorcp.c | 4 ++-- hw/mainstone.c | 6 ++++-- hw/mcf5208.c | 4 ++-- hw/mips_jazz.c | 4 ++-- hw/mips_malta.c | 4 ++-- hw/mips_mipssim.c | 4 ++-- hw/mips_r4k.c | 6 +++--- hw/musicpal.c | 11 +++++++---- hw/omap1.c | 6 ++++-- hw/omap2.c | 6 ++++-- hw/omap_sx1.c | 12 ++++++++---- hw/onenand.c | 2 +- hw/palm.c | 3 ++- hw/pc.c | 8 ++++---- hw/pci.c | 7 ++++++- hw/petalogix_s3adsp1800_mmu.c | 7 ++++--- hw/ppc405_boards.c | 18 +++++++++--------- hw/ppc405_uc.c | 2 +- hw/ppc4xx_devs.c | 4 +++- hw/ppc_newworld.c | 6 +++--- hw/ppc_oldworld.c | 6 +++--- hw/ppc_prep.c | 4 ++-- hw/ppce500_mpc8544ds.c | 3 ++- hw/pxa2xx.c | 12 ++++++++---- hw/r2d.c | 4 ++-- hw/realview.c | 6 +++--- hw/s390-virtio.c | 2 +- hw/sm501.c | 2 +- hw/spitz.c | 2 +- hw/sun4m.c | 8 ++++---- hw/sun4u.c | 4 ++-- hw/syborg.c | 2 +- hw/tc6393xb.c | 2 +- hw/tcx.c | 2 +- hw/tosa.c | 2 +- hw/versatilepb.c | 2 +- hw/vga.c | 2 +- hw/vmware_vga.c | 2 +- 47 files changed, 130 insertions(+), 98 deletions(-)
cpu-common.h +1 -1
@@ -40,7 +40,7 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr, }ram_addr_t cpu_get_physical_page_desc (target_phys_addr_t addr); -ram_addr_t qemu_ram_alloc (ram_addr_t ); +ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size);void qemu_ram_free (ram_addr_t addr);/* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr (ram_addr_t addr);
exec.c +1 -1
@@ -2776,7 +2776,7 @@ static ram_addr_t find_ram_offset(ram_addr_t size)return last; } -ram_addr_t qemu_ram_alloc (ram_addr_t size) +ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size) {RAMBlock *new_block;
hw/an5206.c +2 -2
@@ -54,11 +54,11 @@ static void an5206_init(ram_addr_t ram_size,/* DRAM at address zero */ cpu_register_physical_memory (0 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"an5206.ram" , ram_size) |IO_MEM_RAM );/* Internal SRAM. */ cpu_register_physical_memory (AN5206_RAMBAR_ADDR ,512 , -qemu_ram_alloc (512 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"an5206.sram" ,512 ) |IO_MEM_RAM );mcf5206_init (AN5206_MBAR_ADDR , env);
hw/armv7m.c +6 -3
@@ -200,9 +200,11 @@ qemu_irq *armv7m_init(int flash_size, int sram_size,/* Flash programming is done via the SCU, so pretend it is ROM. */ cpu_register_physical_memory (0 , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"armv7m.flash" , + flash_size) |IO_MEM_ROM );cpu_register_physical_memory (0x20000000 , sram_size, -qemu_ram_alloc (sram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"armv7m.sram" , + sram_size) |IO_MEM_RAM );armv7m_bitband_init (); nvic =qdev_create (NULL ,"armv7m_nvic" );
@@ -236,7 +238,8 @@ qemu_irq *armv7m_init(int flash_size, int sram_size,space. This stops qemu complaining about executing code outside RAM when returning from an exception. */ cpu_register_physical_memory (0xfffff000 ,0x1000 , -qemu_ram_alloc (0x1000 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"armv7m.hack" , +0x1000 ) |IO_MEM_RAM );qemu_register_reset (armv7m_reset, env);return pic;
hw/axis_dev88.c +2 -2
@@ -268,12 +268,12 @@ void axisdev88_init (ram_addr_t ram_size, env =cpu_init (cpu_model);/* allocate RAM */ - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"axisdev88.ram" , ram_size);cpu_register_physical_memory (0x40000000 , ram_size, phys_ram |IO_MEM_RAM );/* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the internal memory. */ - phys_intmem =qemu_ram_alloc (INTMEM_SIZE ); + phys_intmem =qemu_ram_alloc (NULL ,"axisdev88.chipram" ,INTMEM_SIZE );cpu_register_physical_memory (0x38000000 ,INTMEM_SIZE , phys_intmem |IO_MEM_RAM );
hw/dummy_m68k.c +1 -1
@@ -39,7 +39,7 @@ static void dummy_m68k_init(ram_addr_t ram_size,/* RAM at address zero */ cpu_register_physical_memory (0 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"dummy_m68k.ram" , ram_size) |IO_MEM_RAM );/* Load kernel. */ if (kernel_filename) {
hw/etraxfs.c +3 -3
@@ -68,17 +68,17 @@ void bareetraxfs_init (ram_addr_t ram_size, env =cpu_init (cpu_model);/* allocate RAM */ - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"etraxfs.ram" , ram_size);cpu_register_physical_memory (0x40000000 , ram_size, phys_ram |IO_MEM_RAM );/* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the internal memory. */ - phys_intmem =qemu_ram_alloc (INTMEM_SIZE ); + phys_intmem =qemu_ram_alloc (NULL ,"etraxfs.chipram" ,INTMEM_SIZE );cpu_register_physical_memory (0x38000000 ,INTMEM_SIZE , phys_intmem |IO_MEM_RAM ); - phys_flash =qemu_ram_alloc (FLASH_SIZE ); + phys_flash =qemu_ram_alloc (NULL ,"etraxfs.flash" ,FLASH_SIZE ); dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash_cfi02_register(0x0, phys_flash, dinfo ? dinfo->bdrv : NULL, (64 * 1024),
hw/g364fb.c +1 -1
@@ -593,7 +593,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base, s =qemu_mallocz (sizeof (G364State)); s->vram_size =8 *1024 *1024 ; - s->vram_offset =qemu_ram_alloc (s->vram_size); + s->vram_offset =qemu_ram_alloc (NULL ,"g364fb.vram" , s->vram_size); s->vram =qemu_get_ram_ptr (s->vram_offset); s->irq = irq;
hw/gumstix.c +4 -2
@@ -67,7 +67,8 @@ static void connex_init(ram_addr_t ram_size,#else be =0 ;#endif -if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (connex_rom), +if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (NULL ,"connext.rom" , + connex_rom), dinfo->bdrv, sector_len, connex_rom / sector_len,2 ,0 ,0 ,0 ,0 , be)) {fprintf (stderr,"qemu: Error registering flash memory.\n" );
@@ -105,7 +106,8 @@ static void verdex_init(ram_addr_t ram_size,#else be =0 ;#endif -if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (verdex_rom), +if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (NULL ,"verdex.rom" , + verdex_rom), dinfo->bdrv, sector_len, verdex_rom / sector_len,2 ,0 ,0 ,0 ,0 , be)) {fprintf (stderr,"qemu: Error registering flash memory.\n" );
hw/integratorcp.c +2 -2
@@ -253,7 +253,7 @@ static int integratorcm_init(SysBusDevice *dev) }memcpy (integrator_spd +73 ,"QEMU-MEMORY" ,11 ); s->cm_init =0x00000112 ; - s->flash_offset =qemu_ram_alloc (0x100000 ); + s->flash_offset =qemu_ram_alloc (NULL ,"integrator.flash" ,0x100000 ); iomemtype =cpu_register_io_memory (integratorcm_readfn, integratorcm_writefn, s);
@@ -467,7 +467,7 @@ static void integratorcp_init(ram_addr_t ram_size,fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"integrator.ram" , ram_size);/* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero*/
hw/mainstone.c +4 -2
@@ -87,7 +87,8 @@ static void mainstone_common_init(ram_addr_t ram_size,/* Setup CPU & memory */ cpu =pxa270_init (mainstone_binfo.ram_size, cpu_model);cpu_register_physical_memory (0 ,MAINSTONE_ROM , -qemu_ram_alloc (MAINSTONE_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"mainstone.rom" , +MAINSTONE_ROM ) |IO_MEM_ROM );#ifdef TARGET_WORDS_BIGENDIAN be =1 ;
@@ -104,7 +105,8 @@ static void mainstone_common_init(ram_addr_t ram_size, }if (!pflash_cfi01_register (mainstone_flash_base[i], -qemu_ram_alloc (MAINSTONE_FLASH ), +qemu_ram_alloc (NULL ,"mainstone.flash" , +MAINSTONE_FLASH ), dinfo->bdrv, sector_len,MAINSTONE_FLASH / sector_len,4 ,0 ,0 ,0 ,0 , be)) {
hw/mcf5208.c +2 -2
@@ -220,11 +220,11 @@ static void mcf5208evb_init(ram_addr_t ram_size,/* DRAM at 0x40000000 */ cpu_register_physical_memory (0x40000000 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"mcf5208.ram" , ram_size) |IO_MEM_RAM );/* Internal SRAM. */ cpu_register_physical_memory (0x80000000 ,16384 , -qemu_ram_alloc (16384 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"mcf5208.sram" ,16384 ) |IO_MEM_RAM );/* Internal peripherals. */ pic =mcf_intc_init (0xfc048000 , env);
hw/mips_jazz.c +2 -2
@@ -160,10 +160,10 @@ void mips_jazz_init (ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, env);/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"mips_jazz.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM ); - bios_offset =qemu_ram_alloc (MAGNUM_BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"mips_jazz.bios" ,MAGNUM_BIOS_SIZE );cpu_register_physical_memory (0x1fc00000LL ,MAGNUM_BIOS_SIZE , bios_offset |IO_MEM_ROM ); cpu_register_physical_memory(0xfff00000LL,
hw/mips_malta.c +2 -2
@@ -833,8 +833,8 @@ void mips_malta_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20)));exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + ram_offset =qemu_ram_alloc (NULL ,"mips_malta.ram" , ram_size); + bios_offset =qemu_ram_alloc (NULL ,"mips_malta.bios" ,BIOS_SIZE );cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/mips_mipssim.c +2 -2
@@ -144,8 +144,8 @@ mips_mipssim_init (ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, reset_info);/* Allocate RAM. */ - ram_offset =qemu_ram_alloc (ram_size); - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + ram_offset =qemu_ram_alloc (NULL ,"mips_mipssim.ram" , ram_size); + bios_offset =qemu_ram_alloc (NULL ,"mips_mipssim.bios" ,BIOS_SIZE );cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/mips_r4k.c +3 -3
@@ -198,7 +198,7 @@ void mips_r4k_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20)));exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"mips_r4k.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
@@ -226,14 +226,14 @@ void mips_r4k_init (ram_addr_t ram_size, be =0 ;#endif if ((bios_size >0 ) && (bios_size <=BIOS_SIZE )) { - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"mips_r4k.bios" ,BIOS_SIZE );cpu_register_physical_memory (0x1fc00000 ,BIOS_SIZE , bios_offset |IO_MEM_ROM );load_image_targphys (filename,0x1fc00000 ,BIOS_SIZE ); } else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) { uint32_t mips_rom = 0x00400000; - bios_offset = qemu_ram_alloc(mips_rom); + bios_offset = qemu_ram_alloc(NULL, "mips_r4k.bios", mips_rom); if (!pflash_cfi01_register(0x1fc00000, bios_offset, dinfo->bdrv, sector_len, mips_rom / sector_len,
hw/musicpal.c +7 -4
@@ -1508,9 +1508,10 @@ static void musicpal_init(ram_addr_t ram_size,/* For now we use a fixed - the original - RAM size */ cpu_register_physical_memory (0 ,MP_RAM_DEFAULT_SIZE , -qemu_ram_alloc (MP_RAM_DEFAULT_SIZE )); +qemu_ram_alloc (NULL ,"musicpal.ram" , +MP_RAM_DEFAULT_SIZE )); - sram_off =qemu_ram_alloc (MP_SRAM_SIZE ); + sram_off =qemu_ram_alloc (NULL ,"musicpal.sram" ,MP_SRAM_SIZE );cpu_register_physical_memory (MP_SRAM_BASE ,MP_SRAM_SIZE , sram_off); dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
@@ -1557,14 +1558,16 @@ static void musicpal_init(ram_addr_t ram_size,* image is smaller than 32 MB. */ #ifdef TARGET_WORDS_BIGENDIAN -pflash_cfi02_register (0 -MP_FLASH_SIZE_MAX ,qemu_ram_alloc (flash_size), +pflash_cfi02_register (0 -MP_FLASH_SIZE_MAX ,qemu_ram_alloc (NULL , +"musicpal.flash" , flash_size), dinfo->bdrv,0x10000 , (flash_size +0xffff ) >>16 ,MP_FLASH_SIZE_MAX / flash_size,2 ,0x00BF ,0x236D ,0x0000 ,0x0000 ,0x5555 ,0x2AAA ,1 );#else - pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size), + pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(NULL, + "musicpal.flash", flash_size), dinfo->bdrv, 0x10000, (flash_size + 0xffff) >> 16, MP_FLASH_SIZE_MAX / flash_size,
hw/omap1.c +4 -2
@@ -4655,9 +4655,11 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,/* Memory-mapped stuff */ cpu_register_physical_memory (OMAP_EMIFF_BASE , s->sdram_size, - (emiff_base =qemu_ram_alloc (s->sdram_size)) |IO_MEM_RAM ); + (emiff_base =qemu_ram_alloc (NULL ,"omap1.dram" , + s->sdram_size)) |IO_MEM_RAM );cpu_register_physical_memory (OMAP_IMIF_BASE , s->sram_size, - (imif_base =qemu_ram_alloc (s->sram_size)) |IO_MEM_RAM ); + (imif_base =qemu_ram_alloc (NULL ,"omap1.sram" , + s->sram_size)) |IO_MEM_RAM );omap_clkm_init (0xfffece00 ,0xe1008000 , s);
hw/omap2.c +4 -2
@@ -4518,9 +4518,11 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,/* Memory-mapped stuff */ cpu_register_physical_memory (OMAP2_Q2_BASE , s->sdram_size, - (q2_base =qemu_ram_alloc (s->sdram_size)) |IO_MEM_RAM ); + (q2_base =qemu_ram_alloc (NULL ,"omap2.dram" , + s->sdram_size)) |IO_MEM_RAM );cpu_register_physical_memory (OMAP2_SRAM_BASE , s->sram_size, - (sram_base =qemu_ram_alloc (s->sram_size)) |IO_MEM_RAM ); + (sram_base =qemu_ram_alloc (NULL ,"omap2.sram" , + s->sram_size)) |IO_MEM_RAM ); s->l4 =omap_l4_init (OMAP2_L4_BASE ,54 );
hw/omap_sx1.c +8 -4
@@ -139,7 +139,8 @@ static void sx1_init(ram_addr_t ram_size,/* External Flash (EMIFS) */ cpu_register_physical_memory (OMAP_CS0_BASE , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"omap_sx1.flash0-0" , + flash_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs0val); cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
@@ -157,7 +158,8 @@ static void sx1_init(ram_addr_t ram_size,#endif if ((dinfo =drive_get (IF_PFLASH ,0 , fl_idx)) !=NULL ) { -if (!pflash_cfi01_register (OMAP_CS0_BASE ,qemu_ram_alloc (flash_size), +if (!pflash_cfi01_register (OMAP_CS0_BASE ,qemu_ram_alloc (NULL , +"omap_sx1.flash0-1" , flash_size), dinfo->bdrv, sector_size, flash_size / sector_size,4 ,0 ,0 ,0 ,0 , be)) {
@@ -170,12 +172,14 @@ static void sx1_init(ram_addr_t ram_size,if ((version ==1 ) && (dinfo =drive_get (IF_PFLASH ,0 , fl_idx)) !=NULL ) {cpu_register_physical_memory (OMAP_CS1_BASE , flash1_size, -qemu_ram_alloc (flash1_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"omap_sx1.flash1-0" , + flash1_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs1val);cpu_register_physical_memory (OMAP_CS1_BASE + flash1_size,OMAP_CS1_SIZE - flash1_size, io); -if (!pflash_cfi01_register (OMAP_CS1_BASE ,qemu_ram_alloc (flash1_size), +if (!pflash_cfi01_register (OMAP_CS1_BASE ,qemu_ram_alloc (NULL , +"omap_sx1.flash1-1" , flash1_size), dinfo->bdrv, sector_size, flash1_size / sector_size,4 ,0 ,0 ,0 ,0 , be)) {
hw/onenand.c +1 -1
@@ -638,7 +638,7 @@ void *onenand_init(uint32_t id, int regshift, qemu_irq irq) s->bdrv = dinfo->bdrv; s->otp =memset (qemu_malloc ((64 +2 ) <<PAGE_SHIFT ),0xff , (64 +2 ) <<PAGE_SHIFT ); - s->ram =qemu_ram_alloc (0xc000 << s->shift); + s->ram =qemu_ram_alloc (NULL ,"onenand.ram" ,0xc000 << s->shift); ram =qemu_get_ram_ptr (s->ram); s->boot[0 ] = ram + (0x0000 << s->shift); s->boot[1 ] = ram + (0x8000 << s->shift);
hw/palm.c +2 -1
@@ -213,7 +213,8 @@ static void palmte_init(ram_addr_t ram_size,/* External Flash (EMIFS) */ cpu_register_physical_memory (OMAP_CS0_BASE , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"palmte.flash" , + flash_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs0val); cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
hw/pc.c +4 -4
@@ -896,7 +896,7 @@ void pc_memory_init(ram_addr_t ram_size, linux_boot = (kernel_filename !=NULL );/* allocate RAM */ - ram_addr =qemu_ram_alloc (below_4g_mem_size); + ram_addr =qemu_ram_alloc (NULL ,"pc.lowmem" , below_4g_mem_size);cpu_register_physical_memory (0 ,0xa0000 , ram_addr); cpu_register_physical_memory(0x100000, below_4g_mem_size - 0x100000,
@@ -907,7 +907,7 @@ void pc_memory_init(ram_addr_t ram_size,#if TARGET_PHYS_ADDR_BITS ==32 hw_error ("To much RAM for 32-bit physical address" );#else - ram_addr =qemu_ram_alloc (above_4g_mem_size); + ram_addr =qemu_ram_alloc (NULL ,"pc.highmem" , above_4g_mem_size);cpu_register_physical_memory (0x100000000ULL , above_4g_mem_size, ram_addr);
@@ -928,7 +928,7 @@ void pc_memory_init(ram_addr_t ram_size, (bios_size % 65536) != 0) { goto bios_error; } - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"pc.bios" , bios_size); ret =rom_add_file_fixed (bios_name, (uint32_t )(-bios_size));if (ret !=0 ) { bios_error:
@@ -946,7 +946,7 @@ void pc_memory_init(ram_addr_t ram_size, isa_bios_size, (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM); - option_rom_offset =qemu_ram_alloc (PC_ROM_SIZE ); + option_rom_offset =qemu_ram_alloc (NULL ,"pc.rom" ,PC_ROM_SIZE );cpu_register_physical_memory (PC_ROM_MIN_VGA ,PC_ROM_SIZE , option_rom_offset);/* map all the bios at the top of memory */
hw/pci.c +6 -1
@@ -1713,6 +1713,7 @@ static int pci_add_option_rom(PCIDevice *pdev)int size;char *path;void *ptr; +char name[32 ];if (!pdev->romfile)return 0 ;
@@ -1748,7 +1749,11 @@ static int pci_add_option_rom(PCIDevice *pdev) size =1 <<qemu_fls (size); } - pdev->rom_offset =qemu_ram_alloc (size); +if (pdev->qdev.info->vmsd) +snprintf (name,sizeof (name),"%s.rom" , pdev->qdev.info->vmsd->name); +else +snprintf (name,sizeof (name),"%s.rom" , pdev->qdev.info->name); + pdev->rom_offset =qemu_ram_alloc (&pdev->qdev, name, size); ptr =qemu_get_ram_ptr (pdev->rom_offset);load_image (path, ptr);
hw/petalogix_s3adsp1800_mmu.c +4 -3
@@ -137,14 +137,15 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, env);/* Attach emulated BRAM through the LMB. */ - phys_lmb_bram =qemu_ram_alloc (LMB_BRAM_SIZE ); + phys_lmb_bram =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.lmb_bram" , +LMB_BRAM_SIZE );cpu_register_physical_memory (0x00000000 ,LMB_BRAM_SIZE , phys_lmb_bram |IO_MEM_RAM ); - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.ram" , ram_size);cpu_register_physical_memory (ddr_base, ram_size, phys_ram |IO_MEM_RAM ); - phys_flash =qemu_ram_alloc (FLASH_SIZE ); + phys_flash =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.flash" ,FLASH_SIZE ); dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash_cfi01_register(0xa0000000, phys_flash, dinfo ? dinfo->bdrv : NULL, (64 * 1024),
hw/ppc405_boards.c +9 -9
@@ -190,7 +190,7 @@ static void ref405ep_init (ram_addr_t ram_size,DriveInfo *dinfo;/* XXX: fix this */ - ram_bases[0 ] =qemu_ram_alloc (0x08000000 ); + ram_bases[0 ] =qemu_ram_alloc (NULL ,"ef405ep.ram" ,0x08000000 ); ram_sizes[0 ] =0x08000000 ; ram_bases[1 ] =0x00000000 ; ram_sizes[1 ] =0x00000000 ;
@@ -202,7 +202,7 @@ static void ref405ep_init (ram_addr_t ram_size, kernel_filename == NULL ? 0 : 1);/* allocate SRAM */ sram_size =512 *1024 ; - sram_offset =qemu_ram_alloc (sram_size); + sram_offset =qemu_ram_alloc (NULL ,"ef405ep.sram" , sram_size);#ifdef DEBUG_BOARD_INIT printf ("%s: register SRAM at offset %08lx\n" , __func__, sram_offset);#endif
@@ -217,7 +217,7 @@ static void ref405ep_init (ram_addr_t ram_size, dinfo =drive_get (IF_PFLASH ,0 , fl_idx);if (dinfo) { bios_size =bdrv_getlength (dinfo->bdrv); - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"ef405ep.bios" , bios_size); fl_sectors = (bios_size +65535 ) >>16 ;#ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx
@@ -236,7 +236,7 @@ static void ref405ep_init (ram_addr_t ram_size,#ifdef DEBUG_BOARD_INIT printf ("Load BIOS from file\n" );#endif - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ef405ep.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -509,9 +509,9 @@ static void taihu_405ep_init(ram_addr_t ram_size,DriveInfo *dinfo;/* RAM is soldered to the board so the size cannot be changed */ - ram_bases[0 ] =qemu_ram_alloc (0x04000000 ); + ram_bases[0 ] =qemu_ram_alloc (NULL ,"taihu_405ep.ram-0" ,0x04000000 ); ram_sizes[0 ] =0x04000000 ; - ram_bases[1 ] =qemu_ram_alloc (0x04000000 ); + ram_bases[1 ] =qemu_ram_alloc (NULL ,"taihu_405ep.ram-1" ,0x04000000 ); ram_sizes[1 ] =0x04000000 ; ram_size =0x08000000 ;#ifdef DEBUG_BOARD_INIT
@@ -531,7 +531,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,/* XXX: should check that size is 2MB */ // bios_size = 2 * 1024 * 1024; fl_sectors = (bios_size +65535 ) >>16 ; - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.bios" , bios_size);#ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx " at offset %08lx addr " TARGET_FMT_lx " '%s' %d\n",
@@ -551,7 +551,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,#endif if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.bios" ,BIOS_SIZE ); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);if (filename) { bios_size =load_image (filename,qemu_get_ram_ptr (bios_offset));
@@ -580,7 +580,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, fl_idx, bios_size, bios_offset, (target_ulong )0xfc000000 , bdrv_get_device_name(dinfo->bdrv));#endif - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.flash" , bios_size); pflash_cfi02_register(0xfc000000, bios_offset, dinfo->bdrv, 65536, fl_sectors, 1, 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
hw/ppc405_uc.c +1 -1
@@ -995,7 +995,7 @@ static void ppc405_ocm_init(CPUState *env)ppc405_ocm_t *ocm; ocm =qemu_mallocz (sizeof (ppc405_ocm_t)); - ocm->offset =qemu_ram_alloc (4096 ); + ocm->offset =qemu_ram_alloc (NULL ,"ppc405.ocm" ,4096 );qemu_register_reset (&ocm_reset, ocm);ppc_dcr_register (env,OCM0_ISARC , ocm, &dcr_read_ocm, &dcr_write_ocm);
hw/ppc4xx_devs.c +3 -1
@@ -668,7 +668,9 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,unsigned int bank_size = sdram_bank_sizes[j];if (bank_size <= size_left) { - ram_bases[i] =qemu_ram_alloc (bank_size); +char name[32 ]; +snprintf (name,sizeof (name),"ppc4xx.sdram%d" , i); + ram_bases[i] =qemu_ram_alloc (NULL , name, bank_size); ram_sizes[i] = bank_size; size_left -= bank_size;break ;
hw/ppc_newworld.c +3 -3
@@ -173,11 +173,11 @@ static void ppc_core99_init (ram_addr_t ram_size, }/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_core99.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_core99.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =PROM_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -198,7 +198,7 @@ static void ppc_core99_init (ram_addr_t ram_size, }/* allocate and load VGA BIOS */ - vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); + vga_bios_offset =qemu_ram_alloc (NULL ,"ppc_core99.vbios" ,VGA_BIOS_SIZE ); vga_bios_ptr =qemu_get_ram_ptr (vga_bios_offset); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,VGABIOS_FILENAME );if (filename) {
hw/ppc_oldworld.c +3 -3
@@ -179,11 +179,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size,exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =PROM_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -203,7 +203,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, }/* allocate and load VGA BIOS */ - vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); + vga_bios_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.vbios" ,VGA_BIOS_SIZE ); vga_bios_ptr =qemu_get_ram_ptr (vga_bios_offset); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,VGABIOS_FILENAME );if (filename) {
hw/ppc_prep.c +2 -2
@@ -604,11 +604,11 @@ static void ppc_prep_init (ram_addr_t ram_size, }/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_prep.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_prep.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
hw/ppce500_mpc8544ds.c +2 -1
@@ -189,7 +189,8 @@ static void mpc8544ds_init(ram_addr_t ram_size, ram_size &= ~(RAM_SIZES_ALIGN -1 );/* Register Memory */ -cpu_register_physical_memory (0 , ram_size,qemu_ram_alloc (ram_size)); +cpu_register_physical_memory (0 , ram_size,qemu_ram_alloc (NULL , +"mpc8544ds.ram" , ram_size));/* MPIC */ irqs =qemu_mallocz (sizeof (qemu_irq) *OPENPIC_OUTPUT_NB );
hw/pxa2xx.c +8 -4
@@ -2054,9 +2054,11 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)/* SDRAM & Internal Memory Storage */ cpu_register_physical_memory (PXA2XX_SDRAM_BASE , - sdram_size,qemu_ram_alloc (sdram_size) |IO_MEM_RAM ); + sdram_size,qemu_ram_alloc (NULL ,"pxa270.sdram" , + sdram_size) |IO_MEM_RAM );cpu_register_physical_memory (PXA2XX_INTERNAL_BASE , -0x40000 ,qemu_ram_alloc (0x40000 ) |IO_MEM_RAM ); +0x40000 ,qemu_ram_alloc (NULL ,"pxa270.internal" , +0x40000 ) |IO_MEM_RAM ); s->pic =pxa2xx_pic_init (0x40d00000 , s->env);
@@ -2175,9 +2177,11 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)/* SDRAM & Internal Memory Storage */ cpu_register_physical_memory (PXA2XX_SDRAM_BASE , sdram_size, -qemu_ram_alloc (sdram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"pxa255.sdram" , + sdram_size) |IO_MEM_RAM );cpu_register_physical_memory (PXA2XX_INTERNAL_BASE ,PXA2XX_INTERNAL_SIZE , -qemu_ram_alloc (PXA2XX_INTERNAL_SIZE ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"pxa255.internal" , +PXA2XX_INTERNAL_SIZE ) |IO_MEM_RAM ); s->pic =pxa2xx_pic_init (0x40d00000 , s->env);
hw/r2d.c +2 -2
@@ -242,7 +242,7 @@ static void r2d_init(ram_addr_t ram_size, }/* Allocate memory space */ - sdram_addr =qemu_ram_alloc (SDRAM_SIZE ); + sdram_addr =qemu_ram_alloc (NULL ,"r2d.sdram" ,SDRAM_SIZE );cpu_register_physical_memory (SDRAM_BASE ,SDRAM_SIZE , sdram_addr);/* Register peripherals */ s =sh7750_init (env);
@@ -257,7 +257,7 @@ static void r2d_init(ram_addr_t ram_size, dinfo, NULL);/* onboard flash memory */ - pflash_cfi02_register(0x0, qemu_ram_alloc(FLASH_SIZE), + pflash_cfi02_register(0x0, qemu_ram_alloc(NULL, "r2d.flash", FLASH_SIZE), dinfo ? dinfo->bdrv : NULL, (16 * 1024), FLASH_SIZE >> 16, 1, 4, 0x0000, 0x0000, 0x0000, 0x0000,
hw/realview.c +3 -3
@@ -196,12 +196,12 @@ static void realview_init(ram_addr_t ram_size,/* Core tile RAM. */ low_ram_size = ram_size -0x20000000 ; ram_size =0x20000000 ; - ram_offset =qemu_ram_alloc (low_ram_size); + ram_offset =qemu_ram_alloc (NULL ,"realview.lowmem" , low_ram_size);cpu_register_physical_memory (0x20000000 , low_ram_size, ram_offset |IO_MEM_RAM ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"realview.highmem" , ram_size); low_ram_size = ram_size;if (low_ram_size >0x10000000 ) low_ram_size =0x10000000 ;
@@ -354,7 +354,7 @@ static void realview_init(ram_addr_t ram_size,startup code. I guess this works on real hardware because the BootROM happens to be in ROM/flash or in memory that isn't clobbered until after Linux boots the secondary CPUs. */ - ram_offset =qemu_ram_alloc (0x1000 ); + ram_offset =qemu_ram_alloc (NULL ,"realview.hack" ,0x1000 );cpu_register_physical_memory (SMP_BOOT_ADDR ,0x1000 , ram_offset |IO_MEM_RAM );
hw/s390-virtio.c +1 -1
@@ -157,7 +157,7 @@ static void s390_init(ram_addr_t ram_size, s390_bus =s390_virtio_bus_init (&ram_size);/* allocate RAM */ - ram_addr =qemu_ram_alloc (ram_size); + ram_addr =qemu_ram_alloc (NULL ,"s390.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_addr);/* init CPUs */
hw/sm501.c +1 -1
@@ -1371,7 +1371,7 @@ void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq, s->dc_crt_control =0x00010000 ;/* allocate local memory */ - s->local_mem_offset =qemu_ram_alloc (local_mem_bytes); + s->local_mem_offset =qemu_ram_alloc (NULL ,"sm501.local" , local_mem_bytes); s->local_mem =qemu_get_ram_ptr (s->local_mem_offset);cpu_register_physical_memory (base, local_mem_bytes, s->local_mem_offset);
hw/spitz.c +1 -1
@@ -966,7 +966,7 @@ static void spitz_common_init(ram_addr_t ram_size,sl_flash_register (cpu, (model == spitz) ?FLASH_128M :FLASH_1024M );cpu_register_physical_memory (0 ,SPITZ_ROM , -qemu_ram_alloc (SPITZ_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"spitz.rom" ,SPITZ_ROM ) |IO_MEM_ROM );/* Setup peripherals */ spitz_keyboard_register (cpu);
hw/sun4m.c +4 -4
@@ -592,7 +592,7 @@ static int idreg_init1(SysBusDevice *dev) {ram_addr_t idreg_offset; - idreg_offset =qemu_ram_alloc (sizeof (idreg_data)); + idreg_offset =qemu_ram_alloc (NULL ,"sun4m.idreg" ,sizeof (idreg_data));sysbus_init_mmio (dev,sizeof (idreg_data), idreg_offset |IO_MEM_ROM );return 0 ; }
@@ -627,7 +627,7 @@ static int afx_init1(SysBusDevice *dev) {ram_addr_t afx_offset; - afx_offset =qemu_ram_alloc (4 ); + afx_offset =qemu_ram_alloc (NULL ,"sun4m.afx" ,4 );sysbus_init_mmio (dev,4 , afx_offset |IO_MEM_RAM );return 0 ; }
@@ -690,7 +690,7 @@ static int prom_init1(SysBusDevice *dev) {ram_addr_t prom_offset; - prom_offset =qemu_ram_alloc (PROM_SIZE_MAX ); + prom_offset =qemu_ram_alloc (NULL ,"sun4m.prom" ,PROM_SIZE_MAX );sysbus_init_mmio (dev,PROM_SIZE_MAX , prom_offset |IO_MEM_ROM );return 0 ; }
@@ -725,7 +725,7 @@ static int ram_init1(SysBusDevice *dev) RAM_size = d->size; - ram_offset =qemu_ram_alloc (RAM_size); + ram_offset =qemu_ram_alloc (NULL ,"sun4m.ram" , RAM_size);sysbus_init_mmio (dev, RAM_size, ram_offset);return 0 ; }
hw/sun4u.c +2 -2
@@ -629,7 +629,7 @@ static int prom_init1(SysBusDevice *dev) {ram_addr_t prom_offset; - prom_offset =qemu_ram_alloc (PROM_SIZE_MAX ); + prom_offset =qemu_ram_alloc (NULL ,"sun4u.prom" ,PROM_SIZE_MAX );sysbus_init_mmio (dev,PROM_SIZE_MAX , prom_offset |IO_MEM_ROM );return 0 ; }
@@ -665,7 +665,7 @@ static int ram_init1(SysBusDevice *dev) RAM_size = d->size; - ram_offset =qemu_ram_alloc (RAM_size); + ram_offset =qemu_ram_alloc (NULL ,"sun4u.ram" , RAM_size);sysbus_init_mmio (dev, RAM_size, ram_offset);return 0 ; }
hw/syborg.c +1 -1
@@ -51,7 +51,7 @@ static void syborg_init(ram_addr_t ram_size, }/* RAM at address zero. */ - ram_addr =qemu_ram_alloc (ram_size); + ram_addr =qemu_ram_alloc (NULL ,"syborg.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_addr |IO_MEM_RAM ); cpu_pic =arm_pic_init_cpu (env);
hw/tc6393xb.c +1 -1
@@ -593,7 +593,7 @@ TC6393xbState *tc6393xb_init(uint32_t base, qemu_irq irq) tc6393xb_writefn, s);cpu_register_physical_memory (base,0x10000 , iomemtype); - s->vram_addr =qemu_ram_alloc (0x100000 ); + s->vram_addr =qemu_ram_alloc (NULL ,"tc6393xb.vram" ,0x100000 ); s->vram_ptr =qemu_get_ram_ptr (s->vram_addr);cpu_register_physical_memory (base +0x100000 ,0x100000 , s->vram_addr); s->scr_width =480 ;
hw/tcx.c +1 -1
@@ -510,7 +510,7 @@ static int tcx_init1(SysBusDevice *dev)int size;uint8_t *vram_base; - vram_offset =qemu_ram_alloc (s->vram_size * (1 +4 +4 )); + vram_offset =qemu_ram_alloc (NULL ,"tcx.vram" , s->vram_size * (1 +4 +4 )); vram_base =qemu_get_ram_ptr (vram_offset); s->vram_offset = vram_offset;
hw/tosa.c +1 -1
@@ -215,7 +215,7 @@ static void tosa_init(ram_addr_t ram_size, cpu =pxa255_init (tosa_binfo.ram_size);cpu_register_physical_memory (0 ,TOSA_ROM , -qemu_ram_alloc (TOSA_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"tosa.rom" ,TOSA_ROM ) |IO_MEM_ROM ); tmio =tc6393xb_init (0x10000000 ,pxa2xx_gpio_in_get (cpu->gpio)[TOSA_GPIO_TC6393XB_INT ]);
hw/versatilepb.c +1 -1
@@ -180,7 +180,7 @@ static void versatile_init(ram_addr_t ram_size,fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"versatile.ram" , ram_size);/* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/vga.c +1 -1
@@ -2261,7 +2261,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)#else s->is_vbe_vmstate =0 ;#endif - s->vram_offset =qemu_ram_alloc (vga_ram_size); + s->vram_offset =qemu_ram_alloc (NULL ,"vga.vram" , vga_ram_size); s->vram_ptr =qemu_get_ram_ptr (s->vram_offset); s->vram_size = vga_ram_size; s->get_bpp = vga_get_bpp;
hw/vmware_vga.c +1 -1
@@ -1164,7 +1164,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) s->fifo_size =SVGA_FIFO_SIZE ; - s->fifo_offset =qemu_ram_alloc (s->fifo_size); + s->fifo_offset =qemu_ram_alloc (NULL ,"vmsvga.fifo" , s->fifo_size); s->fifo_ptr =qemu_get_ram_ptr (s->fifo_offset);vga_common_init (&s->vga, vga_ram_size);
PATCH 9/15 ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
In reply to Alex WilliamsonWith these two pieces in place, we can start naming ramblocks. When the device is present and it lives on a bus that provides a device path, we concatenate the path and the provided name. Otherwise we just use name. The resulting id string must be unique. For now we assume an allocation for the same name and size is a device that has been removed and reinserted and return the same block. This will go away once qemu_ram_free() is implemented.
---
cpu-all.h | 1 + exec.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
cpu-all.h +1 -0
@@ -865,6 +865,7 @@ typedef struct RAMBlock {uint8_t *host;ram_addr_t offset;ram_addr_t length; +char idstr[256 ];QLIST_ENTRY (RAMBlock) next; } RAMBlock;
exec.c +27 -2
@@ -36,6 +36,7 @@#include "qemu-common.h" #include "tcg.h" #include "hw/hw.h" +#include "hw/qdev.h" #include "osdep.h" #include "kvm.h" #include "qemu-timer.h"
@@ -2778,10 +2779,34 @@ static ram_addr_t find_ram_offset(ram_addr_t size)ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size) { -RAMBlock *new_block; +RAMBlock *new_block, *block; size =TARGET_PAGE_ALIGN (size); - new_block =qemu_malloc (sizeof (*new_block)); + new_block =qemu_mallocz (sizeof (*new_block)); + +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +snprintf (new_block->idstr,sizeof (new_block->idstr),"%s/" , id); +qemu_free (id); + } + } +pstrcat (new_block->idstr,sizeof (new_block->idstr), name); + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strcmp (block->idstr, new_block->idstr)) { +if (block->length == new_block->length) { +fprintf (stderr,"RAMBlock \"%s\" exists, assuming lack of" +"free.\n" , new_block->idstr); +qemu_free (new_block); +return block->offset; + }else { +fprintf (stderr,"RAMBlock \"%s\" already registered with" +"different size, abort\n" , new_block->idstr); +abort (); + } + } + }if (mem_path) {#if defined (__linux__) && !defined(TARGET_S390X )
PATCH 10/15 savevm: Migrate RAM based on name/offset
In reply to Alex WilliamsonSynchronize RAM blocks with the target and migrate using name/offset pairs. This ensures both source and target have the same view of RAM and that we get the right bits into the right slot.
---
arch_init.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- vl.c | 2 + 2 files changed, 108 insertions(+), 12 deletions(-)
arch_init.c +107 -11
@@ -113,20 +113,33 @@ static int ram_save_block(QEMUFile *f)while (addr < total_ram) {if (cpu_physical_memory_get_dirty (current_addr,MIGRATION_DIRTY_FLAG )) { +RAMBlock *block; +ram_addr_t offset;uint8_t *p;cpu_physical_memory_reset_dirty (current_addr, current_addr +TARGET_PAGE_SIZE ,MIGRATION_DIRTY_FLAG ); - p =qemu_get_ram_ptr (current_addr); + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (current_addr - block->offset < block->length) +break ; + } + offset = current_addr - block->offset; + p = block->host + offset;if (is_dup_page (p, *p)) { -qemu_put_be64 (f, current_addr |RAM_SAVE_FLAG_COMPRESS ); +qemu_put_be64 (f, offset |RAM_SAVE_FLAG_COMPRESS ); +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr));qemu_put_byte (f, *p); bytes_sent =1 ; }else { -qemu_put_be64 (f, current_addr |RAM_SAVE_FLAG_PAGE ); +qemu_put_be64 (f, offset |RAM_SAVE_FLAG_PAGE ); +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr));qemu_put_buffer (f, p,TARGET_PAGE_SIZE ); bytes_sent =TARGET_PAGE_SIZE ; }
@@ -196,6 +209,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) }if (stage ==1 ) { +RAMBlock *block;uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;
@@ -210,6 +224,12 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)cpu_physical_memory_set_dirty_tracking (1 );qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); + + QLIST_FOREACH(block, &ram_list.blocks, next) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr,strlen (block->idstr)); +qemu_put_be64 (f, block->length); + } } bytes_transferred_last = bytes_transferred;
@@ -257,7 +277,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)ram_addr_t addr;int flags; -if (version_id !=3 ) { +if (version_id <3 || version_id >4 ) {return -EINVAL ; }
@@ -268,23 +288,99 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) addr &=TARGET_PAGE_MASK ;if (flags &RAM_SAVE_FLAG_MEM_SIZE ) { -if (addr !=ram_bytes_total ()) { -return -EINVAL ; +if (version_id ==3 ) { +if (addr !=ram_bytes_total ()) { +return -EINVAL ; + } + }else { +/* Synchronize RAM block list */ +char id[256 ]; +ram_addr_t length; +ram_addr_t total_ram_bytes = addr; + +while (total_ram_bytes) { +RAMBlock *block; +uint8_t len; + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + length =qemu_get_be64 (f); + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) { +if (block->length != length) +return -EINVAL ; +break ; + } + } + +if (!block) { +if (!qemu_ram_alloc (NULL , id, length)) +return -ENOMEM ; + } + + total_ram_bytes -= length; + } } }if (flags &RAM_SAVE_FLAG_COMPRESS ) { -uint8_t ch =qemu_get_byte (f); -memset (qemu_get_ram_ptr (addr), ch,TARGET_PAGE_SIZE ); +void *host; +uint8_t ch; + +if (version_id ==3 ) { + host =qemu_get_ram_ptr (addr); + }else { +RAMBlock *block; +char id[256 ]; +uint8_t len; + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) +break ; + } +if (!block) +return -EINVAL ; + + host = block->host + addr; + } + ch =qemu_get_byte (f); +memset (host, ch,TARGET_PAGE_SIZE );#ifndef _WIN32if (ch ==0 && (!kvm_enabled () ||kvm_has_sync_mmu ())) { -madvise (qemu_get_ram_ptr (addr),TARGET_PAGE_SIZE , -MADV_DONTNEED ); +madvise (host,TARGET_PAGE_SIZE ,MADV_DONTNEED ); }#endif }else if (flags &RAM_SAVE_FLAG_PAGE ) { -qemu_get_buffer (f,qemu_get_ram_ptr (addr),TARGET_PAGE_SIZE ); +void *host; + +if (version_id ==3 ) { + host =qemu_get_ram_ptr (addr); + }else { +RAMBlock *block; +char id[256 ]; +uint8_t len; + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) +break ; + } +if (!block) +return -EINVAL ; + + host = block->host + addr; + } +qemu_get_buffer (f, host,TARGET_PAGE_SIZE ); }if (qemu_file_has_error (f)) {return -EIO ;
vl.c +1 -1
@@ -2794,7 +2794,7 @@ int main(int argc, char **argv, char **envp)if (qemu_opts_foreach (&qemu_drive_opts, drive_init_func, &machine->use_scsi,1 ) !=0 )exit (1 ); -register_savevm_live (NULL ,"ram" ,0 ,3 ,NULL , ram_save_live,NULL , +register_savevm_live (NULL ,"ram" ,0 ,4 ,NULL , ram_save_live,NULL , ram_load,NULL );if (nb_numa_nodes >0 ) {
[Qemu-devel] Re: [PATCH 10/15] savevm: Migrate RAM based on name/offset
Quoted 6 lines · Alex Williamson
if (flags& RAM_SAVE_FLAG_COMPRESS) {arch_init.c +3
-2-uint8_t ch =qemu_get_byte (f); -memset (qemu_get_ram_ptr (addr), ch,TARGET_PAGE_SIZE ); +void *host; +uint8_t ch; +
arch_init.c int ram_load(QEMUFile *f, void *opaque, int version_id) · line 341
Quoted 10 lines
arch_init.c +10
-0+if (version_id ==3 ) { + host =qemu_get_ram_ptr (addr); + }else { +RAMBlock *block; +char id[256 ]; +uint8_t len; + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ;
Can you measure the amount of bytes transferred before and now? It seems pretty expensive. Maybe you could add another flag so that the memory name is passed on the wire only if it differs from the previous one. Alternatively (perhaps better) define a new kind of RAM save data just for the RAM block, and assume all pages after it are for that block. You can even encode the RAM length in the flags, so that you only have to pass "len | RAM_SAVE_FLAG_BLOCK_NAME" followed by the length+characters of the name.
Also, code like this:
+ len = qemu_get_byte(f); + qemu_get_buffer(f, (uint8_t *)id, len); + id[len] = 0;
+
+ QLIST_FOREACH(block, &ram_list.blocks, next) {
+ if (!strncmp(id, block->idstr, sizeof(id)))
+ break;
+ }
+ if (!block)
+ return -EINVAL;
is present three times. It should be split in two functions and these functions be called (the first function can also be used elsewhere, I think, though this of course can be done in a followup).
Paolo
PATCH 11/15 savevm: Use RAM blocks for basis of migration
In reply to Alex WilliamsonWe don't want to assume a contiguous address space, so migrate based on RAM blocks instead of a fixed linear address map. This will allow us to have holes in the ram_addr_t namespace, so we can implement qemu_ram_free().
---
arch_init.c | 67 +++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 42 insertions(+), 25 deletions(-)
arch_init.c +42 -25
@@ -105,27 +105,26 @@ static int is_dup_page(uint8_t *page, uint8_t ch)static int ram_save_block (QEMUFile *f) { -static ram_addr_t current_addr =0 ; -ram_addr_t saved_addr = current_addr; -ram_addr_t addr =0 ; -uint64_t total_ram =ram_bytes_total (); +static RAMBlock *last_block =NULL ; +static ram_addr_t last_offset =0 ; +RAMBlock *block = last_block; +ram_addr_t offset = last_offset; +ram_addr_t current_addr;int bytes_sent =0 ; -while (addr < total_ram) { +if (!block) + block =QLIST_FIRST (&ram_list.blocks); + + current_addr = block->offset + offset; + + do { if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) { -RAMBlock *block; -ram_addr_t offset; uint8_t *p; cpu_physical_memory_reset_dirty(current_addr, current_addr + TARGET_PAGE_SIZE, MIGRATION_DIRTY_FLAG); - QLIST_FOREACH(block, &ram_list.blocks, next) { -if (current_addr - block->offset < block->length) -break ; - } - offset = current_addr - block->offset; p = block->host + offset; if (is_dup_page(p, *p)) {
@@ -146,9 +145,21 @@ static int ram_save_block(QEMUFile *f)break ; } - addr +=TARGET_PAGE_SIZE ; - current_addr = (saved_addr + addr) % total_ram; - } + + offset +=TARGET_PAGE_SIZE ; +if (offset >= block->length) { + offset =0 ; + block =QLIST_NEXT (block, next); +if (!block) + block =QLIST_FIRST (&ram_list.blocks); + } + + current_addr = block->offset + offset; + + }while (current_addr != last_block->offset + last_offset); + + last_block = block; + last_offset = offset;return bytes_sent; }
@@ -157,13 +168,16 @@ static uint64_t bytes_transferred;static ram_addr_t ram_save_remaining (void ) { -ram_addr_t addr; +RAMBlock *block;ram_addr_t count =0 ; -uint64_t total_ram =ram_bytes_total (); -for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) { -if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { - count++; + QLIST_FOREACH(block, &ram_list.blocks, next) { +ram_addr_t addr; +for (addr = block->offset; addr < block->offset + block->length; + addr +=TARGET_PAGE_SIZE ) { +if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { + count++; + } } }
@@ -210,20 +224,23 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)if (stage ==1 ) {RAMBlock *block; -uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;/* Make sure all dirty bits are set */ -for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) { -if (!cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { -cpu_physical_memory_set_dirty (addr); + QLIST_FOREACH(block, &ram_list.blocks, next) { +for (addr = block->offset; addr < block->offset + block->length; + addr +=TARGET_PAGE_SIZE ) { +if (!cpu_physical_memory_get_dirty (addr, +MIGRATION_DIRTY_FLAG )) { +cpu_physical_memory_set_dirty (addr); + } } }/* Enable dirty memory tracking */ cpu_physical_memory_set_dirty_tracking (1 ); -qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); +qemu_put_be64 (f,ram_bytes_total () |RAM_SAVE_FLAG_MEM_SIZE ); QLIST_FOREACH(block, &ram_list.blocks, next) {qemu_put_byte (f,strlen (block->idstr));
PATCH 12/15 savevm: Create a new continue flag to avoid resending block name
In reply to Alex WilliamsonAllows us to compress the protocol a bit by setting a flag on the offset which indicates we're still working within the same block as last time. That way we can avoid sending the block name for every page. Suggested by Anthony Liguori.
---
arch_init.c | 94 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 50 insertions(+), 44 deletions(-)
arch_init.c +50 -44
@@ -87,6 +87,7 @@ const uint32_t arch_type = QEMU_ARCH;#define RAM_SAVE_FLAG_MEM_SIZE 0x04#define RAM_SAVE_FLAG_PAGE 0x08#define RAM_SAVE_FLAG_EOS 0x10 +#define RAM_SAVE_FLAG_CONTINUE 0x20static int is_dup_page (uint8_t *page,uint8_t ch) {
@@ -120,6 +121,7 @@ static int ram_save_block(QEMUFile *f) do { if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) { uint8_t *p; + int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0; cpu_physical_memory_reset_dirty(current_addr, current_addr + TARGET_PAGE_SIZE,
@@ -128,17 +130,21 @@ static int ram_save_block(QEMUFile *f) p = block->host + offset;if (is_dup_page (p, *p)) { -qemu_put_be64 (f, offset |RAM_SAVE_FLAG_COMPRESS ); -qemu_put_byte (f,strlen (block->idstr)); -qemu_put_buffer (f, (uint8_t *)block->idstr, -strlen (block->idstr)); +qemu_put_be64 (f, offset | cont |RAM_SAVE_FLAG_COMPRESS ); +if (!cont) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr)); + }qemu_put_byte (f, *p); bytes_sent =1 ; }else { -qemu_put_be64 (f, offset |RAM_SAVE_FLAG_PAGE ); -qemu_put_byte (f,strlen (block->idstr)); -qemu_put_buffer (f, (uint8_t *)block->idstr, -strlen (block->idstr)); +qemu_put_be64 (f, offset | cont |RAM_SAVE_FLAG_PAGE ); +if (!cont) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr)); + }qemu_put_buffer (f, p,TARGET_PAGE_SIZE ); bytes_sent =TARGET_PAGE_SIZE ; }
@@ -289,6 +295,36 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)return (stage ==2 ) && (expected_time <=migrate_max_downtime ()); } +static inline void *host_from_stream_offset (QEMUFile *f, +ram_addr_t offset, +int flags) +{ +static RAMBlock *block =NULL ; +char id[256 ]; +uint8_t len; + +if (flags &RAM_SAVE_FLAG_CONTINUE ) { +if (!block) { +fprintf (stderr,"Ack, bad migration stream!\n" ); +return NULL ; + } + +return block->host + offset; + } + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) +return block->host + offset; + } + +fprintf (stderr,"Can't find block %s!\n" , id); +return NULL ; +} +int ram_load (QEMUFile *f,void *opaque,int version_id) {ram_addr_t addr;
@@ -346,26 +382,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)void *host;uint8_t ch; -if (version_id ==3 ) { +if (version_id ==3 ) host =qemu_get_ram_ptr (addr); - }else { -RAMBlock *block; -char id[256 ]; -uint8_t len; - - len =qemu_get_byte (f); -qemu_get_buffer (f, (uint8_t *)id, len); - id[len] =0 ; +else + host =host_from_stream_offset (f, addr, flags); - QLIST_FOREACH(block, &ram_list.blocks, next) { -if (!strncmp (id, block->idstr,sizeof (id))) -break ; - } -if (!block) -return -EINVAL ; - - host = block->host + addr; - } ch =qemu_get_byte (f);memset (host, ch,TARGET_PAGE_SIZE );#ifndef _WIN32
@@ -377,26 +398,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) }else if (flags &RAM_SAVE_FLAG_PAGE ) {void *host; -if (version_id ==3 ) { +if (version_id ==3 ) host =qemu_get_ram_ptr (addr); - }else { -RAMBlock *block; -char id[256 ]; -uint8_t len; +else + host =host_from_stream_offset (f, addr, flags); - len =qemu_get_byte (f); -qemu_get_buffer (f, (uint8_t *)id, len); - id[len] =0 ; - - QLIST_FOREACH(block, &ram_list.blocks, next) { -if (!strncmp (id, block->idstr,sizeof (id))) -break ; - } -if (!block) -return -EINVAL ; - - host = block->host + addr; - }qemu_get_buffer (f, host,TARGET_PAGE_SIZE ); }if (qemu_file_has_error (f)) {
[Qemu-devel] Re: [PATCH 12/15] savevm: Create a new continue flag to avoid resending block name
Quoted 148 lines · Alex Williamson
Allows us to compress the protocol a bit by setting a flag on the offset which indicates we're still working within the same block as last time. That way we can avoid sending the block name for every page. Suggested by Anthony Liguori.
Signed-off-by Alex Williamson<[email protected]>---
arch_init.c | 94 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 50 insertions(+), 44 deletions(-)arch_init.c +50
-37@@ -87,6 +87,7 @@ const uint32_t arch_type = QEMU_ARCH;#define RAM_SAVE_FLAG_MEM_SIZE 0x04#define RAM_SAVE_FLAG_PAGE 0x08#define RAM_SAVE_FLAG_EOS 0x10 +#define RAM_SAVE_FLAG_CONTINUE 0x20static int is_dup_page (uint8_t *page,uint8_t ch) {@@ -120,6 +121,7 @@ static int ram_save_block(QEMUFile *f) do { if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) { uint8_t *p; + int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0; cpu_physical_memory_reset_dirty(current_addr, current_addr + TARGET_PAGE_SIZE,@@ -128,17 +130,21 @@ static int ram_save_block(QEMUFile *f) p = block->host + offset;if (is_dup_page (p, *p)) { -qemu_put_be64 (f, offset |RAM_SAVE_FLAG_COMPRESS ); -qemu_put_byte (f,strlen (block->idstr)); -qemu_put_buffer (f, (uint8_t *)block->idstr, -strlen (block->idstr)); +qemu_put_be64 (f, offset | cont |RAM_SAVE_FLAG_COMPRESS ); +if (!cont) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr)); + }qemu_put_byte (f, *p); bytes_sent =1 ; }else { -qemu_put_be64 (f, offset |RAM_SAVE_FLAG_PAGE ); -qemu_put_byte (f,strlen (block->idstr)); -qemu_put_buffer (f, (uint8_t *)block->idstr, -strlen (block->idstr)); +qemu_put_be64 (f, offset | cont |RAM_SAVE_FLAG_PAGE ); +if (!cont) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr)); + }qemu_put_buffer (f, p,TARGET_PAGE_SIZE ); bytes_sent =TARGET_PAGE_SIZE ; }@@ -289,6 +295,36 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)return (stage ==2 )&& (expected_time<=migrate_max_downtime ()); } +static inline void *host_from_stream_offset (QEMUFile *f, +ram_addr_t offset, +int flags) +{ +static RAMBlock *block =NULL ; +char id[256 ]; +uint8_t len; + +if (flags&RAM_SAVE_FLAG_CONTINUE ) { +if (!block) { +fprintf (stderr,"Ack, bad migration stream!\n" ); +return NULL ; + } + +return block->host + offset; + } + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + + QLIST_FOREACH(block,&ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) +return block->host + offset; + } + +fprintf (stderr,"Can't find block %s!\n" , id); +return NULL ; +} +int ram_load (QEMUFile *f,void *opaque,int version_id) {ram_addr_t addr;@@ -346,26 +382,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)void *host;uint8_t ch; -if (version_id ==3 ) { +if (version_id ==3 ) host =qemu_get_ram_ptr (addr); - }else { -RAMBlock *block; -char id[256 ]; -uint8_t len; - - len =qemu_get_byte (f); -qemu_get_buffer (f, (uint8_t *)id, len); - id[len] =0 ; +else + host =host_from_stream_offset (f, addr, flags); - QLIST_FOREACH(block,&ram_list.blocks, next) { -if (!strncmp (id, block->idstr,sizeof (id))) -break ; - } -if (!block) -return -EINVAL ; - - host = block->host + addr; - } ch =qemu_get_byte (f);memset (host, ch,TARGET_PAGE_SIZE );#ifndef _WIN32@@ -377,26 +398,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) }else if (flags&RAM_SAVE_FLAG_PAGE ) {void *host; -if (version_id ==3 ) { +if (version_id ==3 ) host =qemu_get_ram_ptr (addr); - }else { -RAMBlock *block; -char id[256 ]; -uint8_t len; +else + host =host_from_stream_offset (f, addr, flags); - len =qemu_get_byte (f); -qemu_get_buffer (f, (uint8_t *)id, len); - id[len] =0 ; - - QLIST_FOREACH(block,&ram_list.blocks, next) { -if (!strncmp (id, block->idstr,sizeof (id)))
arch_init.c int ram_load(QEMUFile *f, void *opaque, int version_id) · line 408
Quoted 10 lines
arch_init.c +0
-7-break ; - } -if (!block) -return -EINVAL ; - - host = block->host + addr; - }qemu_get_buffer (f, host,TARGET_PAGE_SIZE ); }if (qemu_file_has_error (f)) {
Gah, sorry. :)
This also takes care of the code duplication, great.
Paolo
[Qemu-devel] Re: [PATCH 12/15] savevm: Create a new continue flag to avoid resending block name
Quoted 33 lines · Paolo Bonzini
Quoted 20 lines
arch_init.c +3
-11@@ -377,26 +398,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) }else if (flags&RAM_SAVE_FLAG_PAGE ) {void *host; -if (version_id ==3 ) { +if (version_id ==3 ) host =qemu_get_ram_ptr (addr); - }else { -RAMBlock *block; -char id[256 ]; -uint8_t len; +else + host =host_from_stream_offset (f, addr, flags); - len =qemu_get_byte (f); -qemu_get_buffer (f, (uint8_t *)id, len); - id[len] =0 ; - - QLIST_FOREACH(block,&ram_list.blocks, next) { -if (!strncmp (id, block->idstr,sizeof (id)))arch_init.c int ram_load(QEMUFile *f, void *opaque, int version_id) · line 408
Quoted 10 lines
arch_init.c +0
-7-break ; - } -if (!block) -return -EINVAL ; - - host = block->host + addr; - }qemu_get_buffer (f, host,TARGET_PAGE_SIZE ); }if (qemu_file_has_error (f)) {Gah, sorry. :)
Quoted 1 line
This also takes care of the code duplication, great.
It was certainly a good thought ;) See my reply to Yoshi for the overhead saved. Thanks,
Alex
PATCH 13/15 qemu_ram_free: Implement it
In reply to Alex WilliamsonNow that we can support a ram_addr_t space with holes, we can implement qemu_ram_free().
---
cpu-all.h | 3 +++ exec.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 8 deletions(-)
cpu-all.h +3 -0
@@ -867,6 +867,9 @@ typedef struct RAMBlock {ram_addr_t length;char idstr[256 ];QLIST_ENTRY (RAMBlock) next; +#if defined(__linux__) && !defined(TARGET_S390X ) +int fd; +#endif } RAMBlock; typedef struct RAMList {
exec.c +51 -8
91 lines not on this page · raw message
PATCH 14/15 pci: Free the space allocated for the option rom on removal
In reply to Alex Williamson---
hw/pci.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
hw/pci.c +11 -0
@@ -76,6 +76,7 @@ static struct BusInfo pci_bus_info = {static void pci_update_mappings (PCIDevice *d);static void pci_set_irq (void *opaque,int irq_num,int level);static int pci_add_option_rom (PCIDevice *pdev); +static void pci_del_option_rom (PCIDevice *pdev);static uint16_t pci_default_sub_vendor_id =PCI_SUBVENDOR_ID_REDHAT_QUMRANET ;static uint16_t pci_default_sub_device_id =PCI_SUBDEVICE_ID_QEMU ;
@@ -709,6 +710,7 @@ static int pci_unregister_device(DeviceState *dev)return ret;pci_unregister_io_regions (pci_dev); +pci_del_option_rom (pci_dev);do_pci_unregister_device (pci_dev);return 0 ; }
@@ -1765,6 +1767,15 @@ static int pci_add_option_rom(PCIDevice *pdev)return 0 ; } +static void pci_del_option_rom (PCIDevice *pdev) +{ +if (!pdev->rom_offset) +return ; + +qemu_ram_free (pdev->rom_offset); + pdev->rom_offset =0 ; +} +/* Reserve space and add capability to the linked list in pci config space */ int pci_add_capability_at_offset (PCIDevice *pdev,uint8_t cap_id,uint8_t offset,uint8_t size)
PATCH 15/15 ramblocks: No more being lazy about duplicate names
In reply to Alex WilliamsonNow that we have a working qemu_ram_free() and the primary runtime user of it has been updated, don't be lenient about duplicate id strings. We also shouldn't need to create them ondemand at the target.
---
arch_init.c | 5 +++-- exec.c | 13 +++---------- 2 files changed, 6 insertions(+), 12 deletions(-)
arch_init.c +3 -2
@@ -369,8 +369,9 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) }if (!block) { -if (!qemu_ram_alloc (NULL , id, length)) -return -ENOMEM ; +fprintf (stderr,"Unknown ramblock \"%s\", cannot " +"accept migration\n" , id); +return -EINVAL ; } total_ram_bytes -= length;
exec.c +3 -10
@@ -2813,16 +2813,9 @@ ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size) QLIST_FOREACH(block, &ram_list.blocks, next) {if (!strcmp (block->idstr, new_block->idstr)) { -if (block->length == new_block->length) { -fprintf (stderr,"RAMBlock \"%s\" exists, assuming lack of" -"free.\n" , new_block->idstr); -qemu_free (new_block); -return block->offset; - }else { -fprintf (stderr,"RAMBlock \"%s\" already registered with" -"different size, abort\n" , new_block->idstr); -abort (); - } +fprintf (stderr,"RAMBlock \"%s\" already registered, abort!\n" , + new_block->idstr); +abort (); } }
2010/6/24 Alex Williamson <[email protected]>:
Quoted 43 lines
Ok, new approach. I'm going to attempt to extract myself for the canonical device path approach, because we're missing too many pieces to make that work. Instead, I'll take Anthony's advice and try to simplify. We still want a unique name for ramblocks and savevm, but the hotplug problem today is only for PCI devices. PCI conveniently has globally unique, dare I say canonical, addressing in the form of <domain>:<bus>:<device>.<func>. To get to this, let's add a new function on the BusInfo structure called
get_dev_path(). For a PCI device, we can simply traverse up the qdev tree to the BusInfo structure, look for the function, and call it to return a global PCI address.For some buses, these functions could chain up to their parent bus appending strings together to get a unique path. An example would be USB, where the USB port number may not be unique. If we traverse up to the PCI device providing USB, and then to the PCI bus, we get a globally unique PCI path, appended with a USB port number.
To make this work for ramblocks and savevm, we need a DeviceState pointer when the they are create/registered, and we need a caller provided context in case there are multiple ramblocks/savevm associated with a device. Savevm already provies the context, and I've attempted to make reasonable guesses at these for the ramblocks. Note that most of the ramblocks aren't associated with a device, so I don't think it makes sense to link savevm and ramblocks together with the same absolute id string.
Once we have savevm with unique id strings, rather than hotplug unfriendly instance numbers, we can be sure that the right driver instance is loading the correct vmstate. I've also implemented a compat field for this, so we can still accept incoming migrations from previous versions.
Once we have ramblocks with a unique id string, we can switch to using id + offset for migration, which enables a
ram_addr_tspace that supports gaps, which enables us to implementqemu_ram_free(). With that, I think we can finally do migrations reliable after hotplug! Note that the target VM still needs to be created to match the current devices and bus addresses of the source VM. We can also still maintain compatibility for migrations here by bumping the ram migration version and supporting both new and old (just hope the source hasn't done any hotplugs).
Quoted 3 lines
Sound reasonable? Is
get_dev_paththe right name? In the right place? The PCI return is currently "dddd:bb:dd.f", should this be "PCI:dddd:bb:dd.f"? Something else? Thanks,
Hi Alex,
Is there additional overhead to save rams introduce by this series? If so, how much?
Thanks,
Yoshi
Quoted 157 lines
Alex
---
Alex Williamson (15):
ramblocks: No more being lazy about duplicate names
pci: Free the space allocated for the option rom on removal
qemu_ram_free: Implement it
savevm: Create a new continue flag to avoid resending block name
savevm: Use RAM blocks for basis of migration
savevm: Migrate RAM based on name/offset
ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
qemu_ram_alloc: Add DeviceState and name parameters
virtio-net: Incorporate a DeviceState pointer and let savevm track instances
eepro100: Add a dev field to eeprom new/free functions
savevm: Make use of DeviceState
savevm: Add DeviceState param
pci: ImplementBusInfo.get_dev_path()
qdev: Add aget_dev_path()function to BusInfo
Remove uses of ram.last_offset (akalast_ram_offset)arch_init.c | 183 +++++++++++++++++++++++++++++++++++------
audio/audio.c| 2
block-migration.c | 4 -
cpu-all.h | 5 +
cpu-common.h | 2
exec.c | 96 +++++++++++++++++++---hw/adb.c| 4 -hw/ads7846.c | 2 hw/an5206.c | 4 - hw/arm_gic.c | 2 hw/arm_timer.c | 4 - hw/armv7m.c | 9 +- hw/armv7m_nvic.c | 2 hw/axis_dev88.c | 4 - hw/cirrus_vga.c | 2hw/cuda.c | 2
hw/dma.c | 4 -
hw/dummy_m68k.c | 2
hw/eepro100.c | 8 +-
hw/eeprom93xx.c | 8 +-
hw/eeprom93xx.h | 4 -hw/etraxfs.c | 6 + hw/fw_cfg.c | 2 hw/g364fb.c | 4 -hw/grackle_pci.c | 4 -
hw/gt64xxx.c | 3 -
hw/gumstix.c | 6 +
hw/heathrow_pic.c | 2
hw/hw.h | 18 ++--
hw/i2c.c | 2
hw/i8254.c | 2
hw/i8259.c | 2
hw/ide/cmd646.c | 2
hw/ide/isa.c | 2
hw/ide/macio.c | 2
hw/ide/microdrive.c | 2
hw/ide/mmio.c | 2
hw/ide/piix.c | 2
hw/integratorcp.c | 4 -
hw/m48t59.c | 2hw/mac_dbdma.c | 2 hw/mac_nvram.c | 4 - hw/mainstone.c | 6 +hw/max111x.c | 3 -
hw/mcf5208.c | 4 -
hw/mips_jazz.c | 4 -
hw/mips_malta.c | 4 -
hw/mips_mipssim.c | 4 -
hw/mips_r4k.c | 6 +
hw/mipsnet.c | 4 -
hw/mst_fpga.c | 3 -
hw/musicpal.c | 11 ++hw/nand.c | 2 hw/omap1.c | 6 + hw/omap2.c | 6 +hw/omap_sx1.c | 12 ++-
hw/onenand.c | 2
hw/openpic.c | 5 +
hw/palm.c | 3 -
hw/pc.c | 8 +-
hw/pci.c | 34 +++++++-
hw/pckbd.c | 2
hw/petalogix_s3adsp1800_mmu.c | 7 +-hw/piix4.c | 2 hw/pl011.c | 2 hw/pl022.c | 2 hw/pl061.c | 2hw/ppc405_boards.c | 18 ++--
hw/ppc405_uc.c | 2
hw/ppc4xx_devs.c | 4 +
hw/ppc4xx_pci.c | 4 -
hw/ppc_newworld.c | 6 +
hw/ppc_oldworld.c | 6 +
hw/ppc_prep.c | 4 -
hw/ppce500_mpc8544ds.c | 3 -
hw/ppce500_pci.c | 4 -
hw/ps2.c | 4 -
hw/pxa2xx.c | 39 +++++----
hw/pxa2xx_dma.c | 2
hw/pxa2xx_gpio.c | 2
hw/pxa2xx_keypad.c | 2hw/pxa2xx_lcd.c | 2 hw/pxa2xx_mmci.c | 2 hw/pxa2xx_pic.c | 3 -hw/pxa2xx_timer.c | 2
hw/qdev.c | 4 -
hw/qdev.h | 3 +
hw/r2d.c | 4 -
hw/rc4030.c | 2
hw/realview.c | 6 +hw/s390-virtio.c| 2
hw/serial.c | 4 -
hw/sm501.c | 2
hw/spitz.c | 11 +-hw/ssd0323.c| 3 -
hw/ssi-sd.c | 2
hw/stellaris.c | 11 +-hw/stellaris_enet.c| 4 -hw/stellaris_input.c| 2
hw/sun4m.c | 8 +-
hw/sun4u.c | 4 -
hw/syborg.c | 2
hw/syborg_fb.c | 2hw/syborg_interrupt.c| 3 -hw/syborg_keyboard.c| 2hw/syborg_pointer.c| 2hw/syborg_rtc.c| 3 -hw/syborg_serial.c| 2hw/syborg_timer.c| 2
hw/tc6393xb.c | 2
hw/tcx.c | 2
hw/tosa.c | 2
hw/tsc2005.c | 2
hw/tsc210x.c | 4 -hw/unin_pci.c| 6 +hw/versatilepb.c| 2hw/vga-isa-mm.c| 2
hw/vga-isa.c | 2
hw/vga.c | 2hw/virtio-balloon.c| 3 -hw/virtio-blk.c| 2hw/virtio-net.c| 7 +-hw/virtio-serial-bus.c| 2
hw/vmmouse.c | 2hw/vmware_vga.c| 4 -
hw/zaurus.c | 2
qemu-timer.c | 2
savevm.c | 106 +++++++++++++++++++++---slirp/slirp.c| 5 +
vl.c | 2130 files changed, 648 insertions(+), 286 deletions(-)
Quoted 5 lines · Yoshiaki Tamura
Hi Alex,
Is there additional overhead to save rams introduce by this series? If so, how much?
Yes, there is overhead, but it's typically quite small. If I migrate a 1G VM immediately after I boot to a login prompt (lots of zero pages), I get an overhead of 0.000076%. That's only 226 extra bytes over the 297164995 bytes otherwise transferred. If I build a kernel on the guest and migrate during the compilation, the overhead is 0.000019%. The overhead is tiny largely due to patch 12/15, which avoids sending the block name if we're working within the same block as sent previously. If I disable this optimization, the overhead goes up to 0.93% after boot and 0.26% during a kernel compile.
Note that an x86 VM does a separate qemu_ram_alloc for memory above 4G, which means in bigger VMs we may end up needing to resend the ramblock name once in a while as we bounce between above and below 4G. Worst case for this could match the 0.26% above, but in my testing during a kernel compile, this seems to increase the overhead to 0.000026% on a 6G VM. I don't see any reason why we couldn't allocate all the ram in a single qemu_ram_alloc call, so I'll add another patch to make that change (which will also shorten the name to "pc.ram" for even less overhead ;). Thanks,
Alex
Quoted 17 lines · Alex Williamson
Quoted 5 lines · Yoshiaki Tamura
Hi Alex,
Is there additional overhead to save rams introduce by this series? If so, how much?
Yes, there is overhead, but it's typically quite small. If I migrate a 1G VM immediately after I boot to a login prompt (lots of zero pages), I get an overhead of 0.000076%. That's only 226 extra bytes over the 297164995 bytes otherwise transferred. If I build a kernel on the guest and migrate during the compilation, the overhead is 0.000019%. The overhead is tiny largely due to patch 12/15, which avoids sending the block name if we're working within the same block as sent previously. If I disable this optimization, the overhead goes up to 0.93% after boot and 0.26% during a kernel compile.
Quoted 9 lines
Note that an x86 VM does a separate
qemu_ram_allocfor memory above 4G, which means in bigger VMs we may end up needing to resend the ramblock name once in a while as we bounce between above and below 4G. Worst case for this could match the 0.26% above, but in my testing during a kernel compile, this seems to increase the overhead to 0.000026% on a 6G VM. I don't see any reason why we couldn't allocate all the ram in a singleqemu_ram_alloccall, so I'll add another patch to make that change (which will also shorten the name to "pc.ram" for even less overhead ;). Thanks,
FWIW, with this change, my migration during kernel compile on the 6G VM seems to be running just at 0.000019%-0.000020%, so that eliminates the penalty for bigger memory VMs. Thanks,
Alex
Quoted 8 lines · Alex Williamson
Quoted 7 lines · Alex Williamson
Quoted 5 lines · Yoshiaki Tamura
Hi Alex,
Is there additional overhead to save rams introduce by this series? If so, how much?
Quoted 9 lines
Quoted 9 lines
Yes, there is overhead, but it's typically quite small. If I migrate a 1G VM immediately after I boot to a login prompt (lots of zero pages), I get an overhead of 0.000076%. That's only 226 extra bytes over the 297164995 bytes otherwise transferred. If I build a kernel on the guest and migrate during the compilation, the overhead is 0.000019%. The overhead is tiny largely due to patch 12/15, which avoids sending the block name if we're working within the same block as sent previously. If I disable this optimization, the overhead goes up to 0.93% after boot and 0.26% during a kernel compile.
Thank your for the detailed numbers and analysis!
If the overhead is at this level, I think it's worth introducing to support migration with hot plug devices.
Quoted 6 lines
Quoted 6 lines
Note that an x86 VM does a separate
qemu_ram_allocfor memory above 4G, which means in bigger VMs we may end up needing to resend the ramblock name once in a while as we bounce between above and below 4G. Worst case for this could match the 0.26% above, but in my testing during a kernel compile, this seems to increase the overhead to 0.000026% on a 6G VM.
If we run a program which bounce between the region intentionally, we should get a number close to 0.26%, but the overhead is still low enough, and it shouldn't be a big problem.
Quoted 4 lines
Quoted 4 lines
I don't see any reason why we couldn't allocate all the ram in a single
qemu_ram_alloccall, so I'll add another patch to make that change (which will also shorten the name to "pc.ram" for even less overhead ;). Thanks,
Hmm. I didn't know about the qemu_ram_alloc over 4G issue.
If there isn't any reason, how about submitting a patch to fix it besides this series?
Quoted 3 lines
FWIW, with this change, my migration during kernel compile on the 6G VM seems to be running just at 0.000019%-0.000020%, so that eliminates the penalty for bigger memory VMs. Thanks,
It make sense:-)
Thanks,
Yoshi
Quoted 7 lines
Alex
v2 cover Make migration work with hotplug
In reply to Alex Williamsonv2:
Not too many comments, hope that's because everyone agrees ;) A couple minor changes. The 2nd patch is new and provides a bit of an optimization for large memory pc guets. The first two patches stand on their own even if we're undecided about the rest. Thanks,
Alex
changes:
- Use pci_find_domain() for PCI domain, thanks Isaku
- Convert pc to allocate all ram in one chunk, which avoids penalizing large memory VMs bouncing between ramblocks during migration.
v1:
Ok, new approach. I'm going to attempt to extract myself for the canonical device path approach, because we're missing too many pieces to make that work. Instead, I'll take Anthony's advice and try to simplify. We still want a unique name for ramblocks and savevm, but the hotplug problem today is only for PCI devices. PCI conveniently has globally unique, dare I say canonical, addressing in the form of <domain>:<bus>:<device>.<func>. To get to this, let's add a new function on the BusInfo structure called get_dev_path(). For a PCI device, we can simply traverse up the qdev tree to the BusInfo structure, look for the function, and call it to return a global PCI address.
For some buses, these functions could chain up to their parent bus appending strings together to get a unique path. An example would be USB, where the USB port number may not be unique. If we traverse up to the PCI device providing USB, and then to the PCI bus, we get a globally unique PCI path, appended with a USB port number.
To make this work for ramblocks and savevm, we need a DeviceState pointer when the they are create/registered, and we need a caller provided context in case there are multiple ramblocks/savevm associated with a device. Savevm already provies the context, and I've attempted to make reasonable guesses at these for the ramblocks. Note that most of the ramblocks aren't associated with a device, so I don't think it makes sense to link savevm and ramblocks together with the same absolute id string.
Once we have savevm with unique id strings, rather than hotplug unfriendly instance numbers, we can be sure that the right driver instance is loading the correct vmstate. I've also implemented a compat field for this, so we can still accept incoming migrations from previous versions.
Once we have ramblocks with a unique id string, we can switch to using id + offset for migration, which enables a ram_addr_t space that supports gaps, which enables us to implement qemu_ram_free(). With that, I think we can finally do migrations reliable after hotplug! Note that the target VM still needs to be created to match the current devices and bus addresses of the source VM. We can also still maintain compatibility for migrations here by bumping the ram migration version and supporting both new and old (just hope the source hasn't done any hotplugs).
Sound reasonable? Is get_dev_path the right name? In the right place? The PCI return is currently "dddd:bb:dd.f", should this be "PCI:dddd:bb:dd.f"? Something else? Thanks,
Alex
---
Alex Williamson (16):
ramblocks: No more being lazy about duplicate names
pci: Free the space allocated for the option rom on removal
qemu_ram_free: Implement it
savevm: Create a new continue flag to avoid resending block name
savevm: Use RAM blocks for basis of migration
savevm: Migrate RAM based on name/offset
ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
qemu_ram_alloc: Add DeviceState and name parameters
virtio-net: Incorporate a DeviceState pointer and let savevm track instances
eepro100: Add a dev field to eeprom new/free functions
savevm: Make use of DeviceState
savevm: Add DeviceState param
pci: Implement BusInfo.get_dev_path()
qdev: Add a get_dev_path() function to BusInfo
pc: Allocate all ram in a single qemu_ram_alloc()
Remove uses of ram.last_offset (aka last_ram_offset)
arch_init.c | 183 +++++++++++++++++++++++++++++++++++------ audio/audio.c | 2 block-migration.c | 4 - cpu-all.h | 5 + cpu-common.h | 2 exec.c | 96 +++++++++++++++++++--- hw/adb.c | 4 - hw/ads7846.c | 2 hw/an5206.c | 4 - hw/arm_gic.c | 2 hw/arm_timer.c | 4 - hw/armv7m.c | 9 +- hw/armv7m_nvic.c | 2 hw/axis_dev88.c | 4 - hw/cirrus_vga.c | 2 hw/cuda.c | 2 hw/dma.c | 4 - hw/dummy_m68k.c | 2 hw/eepro100.c | 8 +- hw/eeprom93xx.c | 8 +- hw/eeprom93xx.h | 4 - hw/etraxfs.c | 6 + hw/fw_cfg.c | 2 hw/g364fb.c | 4 - hw/grackle_pci.c | 4 - hw/gt64xxx.c | 3 - hw/gumstix.c | 6 + hw/heathrow_pic.c | 2 hw/hw.h | 18 ++-- hw/i2c.c | 2 hw/i8254.c | 2 hw/i8259.c | 2 hw/ide/cmd646.c | 2 hw/ide/isa.c | 2 hw/ide/macio.c | 2 hw/ide/microdrive.c | 2 hw/ide/mmio.c | 2 hw/ide/piix.c | 2 hw/integratorcp.c | 4 - hw/m48t59.c | 2 hw/mac_dbdma.c | 2 hw/mac_nvram.c | 4 - hw/mainstone.c | 6 + hw/max111x.c | 3 - hw/mcf5208.c | 4 - hw/mips_jazz.c | 4 - hw/mips_malta.c | 4 - hw/mips_mipssim.c | 4 - hw/mips_r4k.c | 6 + hw/mipsnet.c | 4 - hw/mst_fpga.c | 3 - hw/musicpal.c | 11 ++ hw/nand.c | 2 hw/omap1.c | 6 + hw/omap2.c | 6 + hw/omap_sx1.c | 12 ++- hw/onenand.c | 2 hw/openpic.c | 5 + hw/palm.c | 3 - hw/pc.c | 27 +++--- hw/pci.c | 34 +++++++- hw/pckbd.c | 2 hw/petalogix_s3adsp1800_mmu.c | 7 +- hw/piix4.c | 2 hw/pl011.c | 2 hw/pl022.c | 2 hw/pl061.c | 2 hw/ppc405_boards.c | 18 ++-- hw/ppc405_uc.c | 2 hw/ppc4xx_devs.c | 4 + hw/ppc4xx_pci.c | 4 - hw/ppc_newworld.c | 6 + hw/ppc_oldworld.c | 6 + hw/ppc_prep.c | 4 - hw/ppce500_mpc8544ds.c | 3 - hw/ppce500_pci.c | 4 - hw/ps2.c | 4 - hw/pxa2xx.c | 39 +++++---- hw/pxa2xx_dma.c | 2 hw/pxa2xx_gpio.c | 2 hw/pxa2xx_keypad.c | 2 hw/pxa2xx_lcd.c | 2 hw/pxa2xx_mmci.c | 2 hw/pxa2xx_pic.c | 3 - hw/pxa2xx_timer.c | 2 hw/qdev.c | 4 - hw/qdev.h | 3 + hw/r2d.c | 4 - hw/rc4030.c | 2 hw/realview.c | 6 + hw/s390-virtio.c | 2 hw/serial.c | 4 - hw/sm501.c | 2 hw/spitz.c | 11 +- hw/ssd0323.c | 3 - hw/ssi-sd.c | 2 hw/stellaris.c | 11 +- hw/stellaris_enet.c | 4 - hw/stellaris_input.c | 2 hw/sun4m.c | 8 +- hw/sun4u.c | 4 - hw/syborg.c | 2 hw/syborg_fb.c | 2 hw/syborg_interrupt.c | 3 - hw/syborg_keyboard.c | 2 hw/syborg_pointer.c | 2 hw/syborg_rtc.c | 3 - hw/syborg_serial.c | 2 hw/syborg_timer.c | 2 hw/tc6393xb.c | 2 hw/tcx.c | 2 hw/tosa.c | 2 hw/tsc2005.c | 2 hw/tsc210x.c | 4 - hw/unin_pci.c | 6 + hw/versatilepb.c | 2 hw/vga-isa-mm.c | 2 hw/vga-isa.c | 2 hw/vga.c | 2 hw/virtio-balloon.c | 3 - hw/virtio-blk.c | 2 hw/virtio-net.c | 7 +- hw/virtio-serial-bus.c | 2 hw/vmmouse.c | 2 hw/vmware_vga.c | 4 - hw/zaurus.c | 2 qemu-timer.c | 2 savevm.c | 106 +++++++++++++++++++++--- slirp/slirp.c | 5 + vl.c | 2 130 files changed, 656 insertions(+), 297 deletions(-)
PATCH v2 1/16 Remove uses of ram.last_offset (aka last_ram_offset)
We currently need this either to allocate the next ram_addr_t for a new block, or for total memory to be migrated. Both of which we can calculate without need of this to keep us in a contiguous address space.
---
arch_init.c | 23 ++++++++++++++++------- cpu-all.h | 1 - exec.c | 19 ++++++++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-)
arch_init.c +16 -7
@@ -108,9 +108,10 @@ static int ram_save_block(QEMUFile *f)static ram_addr_t current_addr =0 ;ram_addr_t saved_addr = current_addr;ram_addr_t addr =0 ; +uint64_t total_ram =ram_bytes_total ();int bytes_sent =0 ; -while (addr < ram_list.last_offset) { +while (addr < total_ram) {if (cpu_physical_memory_get_dirty (current_addr,MIGRATION_DIRTY_FLAG )) {uint8_t *p;
@@ -133,7 +134,7 @@ static int ram_save_block(QEMUFile *f)break ; } addr +=TARGET_PAGE_SIZE ; - current_addr = (saved_addr + addr) % ram_list.last_offset; + current_addr = (saved_addr + addr) % total_ram; }return bytes_sent;
@@ -145,8 +146,9 @@ static ram_addr_t ram_save_remaining(void) {ram_addr_t addr;ram_addr_t count =0 ; +uint64_t total_ram =ram_bytes_total (); -for (addr =0 ; addr < ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) {if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { count++; }
@@ -167,7 +169,13 @@ uint64_t ram_bytes_transferred(void)uint64_t ram_bytes_total (void ) { -return ram_list.last_offset; +RAMBlock *block; +uint64_t total =0 ; + +QLIST_FOREACH (block, &ram_list.blocks, next) + total += block->length; + +return total; }int ram_save_live (Monitor *mon,QEMUFile *f,int stage,void *opaque)
@@ -188,10 +196,11 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) }if (stage ==1 ) { +uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;/* Make sure all dirty bits are set */ -for (addr =0 ; addr < ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) {if (!cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) {cpu_physical_memory_set_dirty (addr); }
@@ -200,7 +209,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)/* Enable dirty memory tracking */ cpu_physical_memory_set_dirty_tracking (1 ); -qemu_put_be64 (f, ram_list.last_offset |RAM_SAVE_FLAG_MEM_SIZE ); +qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); } bytes_transferred_last = bytes_transferred;
@@ -259,7 +268,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) addr &=TARGET_PAGE_MASK ;if (flags &RAM_SAVE_FLAG_MEM_SIZE ) { -if (addr != ram_list.last_offset) { +if (addr !=ram_bytes_total ()) {return -EINVAL ; } }
cpu-all.h +0 -1
@@ -870,7 +870,6 @@ typedef struct RAMBlock {typedef struct RAMList {uint8_t *phys_dirty; -ram_addr_t last_offset; QLIST_HEAD(ram, RAMBlock) blocks; }RAMList ;extern RAMList ram_list;
exec.c +14 -5
@@ -2765,6 +2765,17 @@ static void *file_ram_alloc(ram_addr_t memory, const char *path) }#endif +static ram_addr_t find_ram_offset (ram_addr_t size) +{ +RAMBlock *block; +ram_addr_t last =0 ; + +QLIST_FOREACH (block, &ram_list.blocks, next) + last = MAX(last, block->offset + block->length); + +return last; +} +ram_addr_t qemu_ram_alloc (ram_addr_t size) {RAMBlock *new_block;
@@ -2798,18 +2809,16 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)madvise (new_block->host, size,MADV_MERGEABLE );#endif } - new_block->offset = ram_list.last_offset; + new_block->offset =find_ram_offset (size); new_block->length = size;QLIST_INSERT_HEAD (&ram_list.blocks, new_block, next); ram_list.phys_dirty =qemu_realloc (ram_list.phys_dirty, - (ram_list.last_offset + size) >>TARGET_PAGE_BITS ); -memset (ram_list.phys_dirty + (ram_list.last_offset >>TARGET_PAGE_BITS ), + (new_block->offset + size) >>TARGET_PAGE_BITS ); +memset (ram_list.phys_dirty + (new_block->offset >>TARGET_PAGE_BITS ),0xff , size >>TARGET_PAGE_BITS ); - ram_list.last_offset += size; -if (kvm_enabled ())kvm_setup_guest_memory (new_block->host, size);
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH v2 01/16] Remove uses of ram.last_offset (aka last_ram_offset)
Quoted 6 lines · Alex Williamson
We currently need this either to allocate the next
ram_addr_tfor a new block, or for total memory to be migrated. Both of which we can calculate without need of this to keep us in a contiguous address space.Signed-off-by Alex Williamson<[email protected]>
Applied all. Thanks.
Regards,
Anthony Liguori
Quoted 149 lines
---
arch_init.c | 23 ++++++++++++++++------- cpu-all.h | 1 - exec.c | 19 ++++++++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-)arch_init.c +16
-7@@ -108,9 +108,10 @@ static int ram_save_block(QEMUFile *f)static ram_addr_t current_addr =0 ;ram_addr_t saved_addr = current_addr;ram_addr_t addr =0 ; +uint64_t total_ram =ram_bytes_total ();int bytes_sent =0 ; -while (addr< ram_list.last_offset) { +while (addr< total_ram) {if (cpu_physical_memory_get_dirty (current_addr,MIGRATION_DIRTY_FLAG )) {uint8_t *p;@@ -133,7 +134,7 @@ static int ram_save_block(QEMUFile *f)break ; } addr +=TARGET_PAGE_SIZE ; - current_addr = (saved_addr + addr) % ram_list.last_offset; + current_addr = (saved_addr + addr) % total_ram; }return bytes_sent;@@ -145,8 +146,9 @@ static ram_addr_t ram_save_remaining(void) {ram_addr_t addr;ram_addr_t count =0 ; +uint64_t total_ram =ram_bytes_total (); -for (addr =0 ; addr< ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr< total_ram; addr +=TARGET_PAGE_SIZE ) {if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { count++; }@@ -167,7 +169,13 @@ uint64_t ram_bytes_transferred(void)uint64_t ram_bytes_total (void ) { -return ram_list.last_offset; +RAMBlock *block; +uint64_t total =0 ; + +QLIST_FOREACH (block,&ram_list.blocks, next) + total += block->length; + +return total; }int ram_save_live (Monitor *mon,QEMUFile *f,int stage,void *opaque)@@ -188,10 +196,11 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) }if (stage ==1 ) { +uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;/* Make sure all dirty bits are set */ -for (addr =0 ; addr< ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr< total_ram; addr +=TARGET_PAGE_SIZE ) {if (!cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) {cpu_physical_memory_set_dirty (addr); }@@ -200,7 +209,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)/* Enable dirty memory tracking */ cpu_physical_memory_set_dirty_tracking (1 ); -qemu_put_be64 (f, ram_list.last_offset |RAM_SAVE_FLAG_MEM_SIZE ); +qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); } bytes_transferred_last = bytes_transferred;@@ -259,7 +268,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) addr&=TARGET_PAGE_MASK ;if (flags&RAM_SAVE_FLAG_MEM_SIZE ) { -if (addr != ram_list.last_offset) { +if (addr !=ram_bytes_total ()) {return -EINVAL ; } }cpu-all.h +0
-1@@ -870,7 +870,6 @@ typedef struct RAMBlock {typedef struct RAMList {uint8_t *phys_dirty; -ram_addr_t last_offset; QLIST_HEAD(ram, RAMBlock) blocks; }RAMList ;extern RAMList ram_list;exec.c +14
-5@@ -2765,6 +2765,17 @@ static void *file_ram_alloc(ram_addr_t memory, const char *path) }#endif +static ram_addr_t find_ram_offset (ram_addr_t size) +{ +RAMBlock *block; +ram_addr_t last =0 ; + +QLIST_FOREACH (block,&ram_list.blocks, next) + last = MAX(last, block->offset + block->length); + +return last; +} +ram_addr_t qemu_ram_alloc (ram_addr_t size) {RAMBlock *new_block;@@ -2798,18 +2809,16 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)madvise (new_block->host, size,MADV_MERGEABLE );#endif } - new_block->offset = ram_list.last_offset; + new_block->offset =find_ram_offset (size); new_block->length = size;QLIST_INSERT_HEAD (&ram_list.blocks, new_block, next); ram_list.phys_dirty =qemu_realloc (ram_list.phys_dirty, - (ram_list.last_offset + size)>>TARGET_PAGE_BITS ); -memset (ram_list.phys_dirty + (ram_list.last_offset>>TARGET_PAGE_BITS ), + (new_block->offset + size)>>TARGET_PAGE_BITS ); +memset (ram_list.phys_dirty + (new_block->offset>>TARGET_PAGE_BITS ),0xff , size>>TARGET_PAGE_BITS ); - ram_list.last_offset += size; -if (kvm_enabled ())kvm_setup_guest_memory (new_block->host, size);
PATCH v2 2/16 pc: Allocate all ram in a single qemu_ram_alloc()
In reply to Alex WilliamsonThis will benefit us when we migrate based on ramblock name since we won't be bouncing between separate blocks.
---
hw/pc.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-)
hw/pc.c +9 -13
@@ -893,27 +893,23 @@ void pc_memory_init(ram_addr_t ram_size, *above_4g_mem_size_p = above_4g_mem_size; *below_4g_mem_size_p = below_4g_mem_size; +#if TARGET_PHYS_ADDR_BITS ==32 +if (above_4g_mem_size >0 ) { +hw_error ("To much RAM for 32-bit physical address" ); + } +#endif linux_boot = (kernel_filename !=NULL );/* allocate RAM */ - ram_addr =qemu_ram_alloc (below_4g_mem_size); + ram_addr =qemu_ram_alloc (below_4g_mem_size + above_4g_mem_size);cpu_register_physical_memory (0 ,0xa0000 , ram_addr);cpu_register_physical_memory (0x100000 , below_4g_mem_size -0x100000 , ram_addr +0x100000 ); - -/* above 4giga memory allocation */ -if (above_4g_mem_size >0 ) { -#if TARGET_PHYS_ADDR_BITS ==32 -hw_error ("To much RAM for 32-bit physical address" ); -#else - ram_addr =qemu_ram_alloc (above_4g_mem_size); -cpu_register_physical_memory (0x100000000ULL , - above_4g_mem_size, - ram_addr); +#if TARGET_PHYS_ADDR_BITS >32 +cpu_register_physical_memory (0x100000000ULL , above_4g_mem_size, + ram_addr + below_4g_mem_size);#endif - } -/* BIOS load */ if (bios_name ==NULL )
PATCH v2 3/16 qdev: Add a get_dev_path() function to BusInfo
In reply to Alex WilliamsonThis function is meant to provide a stable device path for buses which are able to implement it. If a bus has a globally unique addresses scheme, one address level may be sufficient to provide a path. Other buses may need to recursively traverse up the qdev tree.
---
hw/qdev.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
hw/qdev.h +3 -0
@@ -49,10 +49,13 @@ struct DeviceState { };typedef void (*bus_dev_printfn )(Monitor *mon,DeviceState *dev,int indent); +typedef char *(*bus_get_dev_path )(DeviceState *dev); +struct BusInfo {const char *name;size_t size;bus_dev_printfn print_dev; +bus_get_dev_path get_dev_path;Property *props; };
PATCH v2 4/16 pci: Implement BusInfo.get_dev_path()
In reply to Alex WilliamsonThis works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely describes a global address. No need to traverse up the qdev tree. PCI segment support is a placeholder for compatibility once we support multiple segments.
---
hw/pci.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
hw/pci.c +14 -0
@@ -58,11 +58,13 @@ struct PCIBus { };static void pcibus_dev_print (Monitor *mon,DeviceState *dev,int indent); +static char *pcibus_get_dev_path (DeviceState *dev);static struct BusInfo pci_bus_info = { .name ="PCI" , .size =sizeof (PCIBus), .print_dev = pcibus_dev_print, + .get_dev_path = pcibus_get_dev_path, .props = (Property []) {DEFINE_PROP_PCI_DEVFN ("addr" , PCIDevice, devfn,-1 ),DEFINE_PROP_STRING ("romfile" , PCIDevice, romfile),
@@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) } } +static char *pcibus_get_dev_path (DeviceState *dev) +{ +PCIDevice *d = (PCIDevice *)dev; +char path[16 ]; + +snprintf (path,sizeof (path),"%04x:%02x:%02x.%x" , +pci_find_domain (d->bus), d->config[PCI_SECONDARY_BUS ], +PCI_SLOT (d->devfn),PCI_FUNC (d->devfn)); + +return strdup (path); +} +static PCIDeviceInfo bridge_info = { .qdev.name ="pci-bridge" , .qdev.size =sizeof (PCIBridge),
PATCH v2 5/16 savevm: Add DeviceState param
In reply to Alex WilliamsonWhen available, we'd like to be able to access the DeviceState when registering a savevm. For buses with a get_dev_path() function, this will allow us to create more unique savevm id strings.
---
audio/audio.c | 2 +- block-migration.c | 4 ++-- exec.c | 4 ++-- hw/adb.c | 4 ++-- hw/ads7846.c | 2 +- hw/arm_gic.c | 2 +- hw/arm_timer.c | 4 ++-- hw/armv7m_nvic.c | 2 +- hw/cirrus_vga.c | 2 +- hw/cuda.c | 2 +- hw/dma.c | 4 ++-- hw/eepro100.c | 4 ++-- hw/eeprom93xx.c | 4 ++-- hw/fw_cfg.c | 2 +- hw/g364fb.c | 2 +- hw/grackle_pci.c | 4 ++-- hw/gt64xxx.c | 3 ++- hw/heathrow_pic.c | 2 +- hw/hw.h | 18 +++++++++++------- hw/i2c.c | 2 +- hw/i8254.c | 2 +- hw/i8259.c | 2 +- hw/ide/cmd646.c | 2 +- hw/ide/isa.c | 2 +- hw/ide/macio.c | 2 +- hw/ide/microdrive.c | 2 +- hw/ide/mmio.c | 2 +- hw/ide/piix.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.c | 2 +- hw/mac_nvram.c | 4 ++-- hw/max111x.c | 3 ++- hw/mipsnet.c | 4 ++-- hw/mst_fpga.c | 3 ++- hw/nand.c | 2 +- hw/openpic.c | 5 +++-- hw/pci.c | 2 +- hw/pckbd.c | 2 +- hw/piix4.c | 2 +- hw/pl011.c | 2 +- hw/pl022.c | 2 +- hw/pl061.c | 2 +- hw/ppc4xx_pci.c | 4 ++-- hw/ppce500_pci.c | 4 ++-- hw/ps2.c | 4 ++-- hw/pxa2xx.c | 27 +++++++++++++++------------ hw/pxa2xx_dma.c | 2 +- hw/pxa2xx_gpio.c | 2 +- hw/pxa2xx_keypad.c | 2 +- hw/pxa2xx_lcd.c | 2 +- hw/pxa2xx_mmci.c | 2 +- hw/pxa2xx_pic.c | 3 ++- hw/pxa2xx_timer.c | 2 +- hw/qdev.c | 4 ++-- hw/rc4030.c | 2 +- hw/serial.c | 4 ++-- hw/spitz.c | 9 +++++---- hw/ssd0323.c | 3 ++- hw/ssi-sd.c | 2 +- hw/stellaris.c | 11 ++++++----- hw/stellaris_enet.c | 4 ++-- hw/stellaris_input.c | 2 +- hw/syborg_fb.c | 2 +- hw/syborg_interrupt.c | 3 ++- hw/syborg_keyboard.c | 2 +- hw/syborg_pointer.c | 2 +- hw/syborg_rtc.c | 3 ++- hw/syborg_serial.c | 2 +- hw/syborg_timer.c | 2 +- hw/tsc2005.c | 2 +- hw/tsc210x.c | 4 ++-- hw/unin_pci.c | 6 ++++-- hw/vga-isa-mm.c | 2 +- hw/vga-isa.c | 2 +- hw/virtio-balloon.c | 3 ++- hw/virtio-blk.c | 2 +- hw/virtio-net.c | 4 ++-- hw/virtio-serial-bus.c | 2 +- hw/vmmouse.c | 2 +- hw/vmware_vga.c | 2 +- hw/zaurus.c | 2 +- qemu-timer.c | 2 +- savevm.c | 22 +++++++++++++--------- slirp/slirp.c | 5 +++-- vl.c | 2 +- 85 files changed, 163 insertions(+), 138 deletions(-)
audio/audio.c +1 -1
@@ -1901,7 +1901,7 @@ static void audio_init (void) }QLIST_INIT (&s->card_head); -vmstate_register (0 , &vmstate_audio, s); +vmstate_register (NULL ,0 , &vmstate_audio, s); }void AUD_register_card (const char *name,QEMUSoundCard *card)
block-migration.c +2 -2
@@ -638,6 +638,6 @@ void blk_mig_init(void)QSIMPLEQ_INIT (&block_mig_state.bmds_list);QSIMPLEQ_INIT (&block_mig_state.blk_list); -register_savevm_live ("block" ,0 ,1 , block_set_params, block_save_live, -NULL , block_load, &block_mig_state); +register_savevm_live (NULL ,"block" ,0 ,1 , block_set_params, + block_save_live,NULL , block_load, &block_mig_state); }
exec.c +2 -2
@@ -641,8 +641,8 @@ void cpu_exec_init(CPUState *env)cpu_list_unlock ();#endif #if defined(CPU_SAVE_VERSION ) && !defined(CONFIG_USER_ONLY ) -vmstate_register (cpu_index, &vmstate_cpu_common, env); -register_savevm ("cpu" , cpu_index,CPU_SAVE_VERSION , +vmstate_register (NULL , cpu_index, &vmstate_cpu_common, env); +register_savevm (NULL ,"cpu" , cpu_index,CPU_SAVE_VERSION , cpu_save, cpu_load, env);#endif }
hw/adb.c +2 -2
@@ -305,7 +305,7 @@ void adb_kbd_init(ADBBusState *bus) d =adb_register_device (bus,ADB_KEYBOARD , adb_kbd_request, adb_kbd_reset, s);qemu_add_kbd_event_handler (adb_kbd_put_keycode, d); -register_savevm ("adb_kbd" ,-1 ,1 , adb_kbd_save, +register_savevm (NULL ,"adb_kbd" ,-1 ,1 , adb_kbd_save, adb_kbd_load, s); }
@@ -475,6 +475,6 @@ void adb_mouse_init(ADBBusState *bus) d =adb_register_device (bus,ADB_MOUSE , adb_mouse_request, adb_mouse_reset, s);qemu_add_mouse_event_handler (adb_mouse_event, d,0 ,"QEMU ADB Mouse" ); -register_savevm ("adb_mouse" ,-1 ,1 , adb_mouse_save, +register_savevm (NULL ,"adb_mouse" ,-1 ,1 , adb_mouse_save, adb_mouse_load, s); }
hw/ads7846.c +1 -1
@@ -151,7 +151,7 @@ static int ads7846_init(SSISlave *dev)ads7846_int_update (s); -register_savevm ("ads7846" ,-1 ,0 , ads7846_save, ads7846_load, s); +register_savevm (NULL ,"ads7846" ,-1 ,0 , ads7846_save, ads7846_load, s);return 0 ; }
hw/arm_gic.c +1 -1
@@ -744,5 +744,5 @@ static void gic_init(gic_state *s) s->iomemtype =cpu_register_io_memory (gic_dist_readfn, gic_dist_writefn, s);gic_reset (s); -register_savevm ("arm_gic" ,-1 ,1 , gic_save, gic_load, s); +register_savevm (NULL ,"arm_gic" ,-1 ,1 , gic_save, gic_load, s); }
hw/arm_timer.c +2 -2
@@ -174,7 +174,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq) bh =qemu_bh_new (arm_timer_tick, s); s->timer =ptimer_init (bh); -register_savevm ("arm_timer" ,-1 ,1 , arm_timer_save, arm_timer_load, s); +register_savevm (NULL ,"arm_timer" ,-1 ,1 , arm_timer_save, arm_timer_load, s);return s; }
@@ -271,7 +271,7 @@ static int sp804_init(SysBusDevice *dev) iomemtype =cpu_register_io_memory (sp804_readfn, sp804_writefn, s);sysbus_init_mmio (dev,0x1000 , iomemtype); -register_savevm ("sp804" ,-1 ,1 , sp804_save, sp804_load, s); +register_savevm (&dev->qdev,"sp804" ,-1 ,1 , sp804_save, sp804_load, s);return 0 ; }
hw/armv7m_nvic.c +1 -1
@@ -397,7 +397,7 @@ static int armv7m_nvic_init(SysBusDevice *dev)gic_init (&s->gic);cpu_register_physical_memory (0xe000e000 ,0x1000 , s->gic.iomemtype); s->systick.timer =qemu_new_timer (vm_clock, systick_timer_tick, s); -register_savevm ("armv7m_nvic" ,-1 ,1 , nvic_save, nvic_load, s); +register_savevm (&dev->qdev,"armv7m_nvic" ,-1 ,1 , nvic_save, nvic_load, s);return 0 ; }
hw/cirrus_vga.c +1 -1
@@ -3128,7 +3128,7 @@ void isa_cirrus_vga_init(void) s->vga.ds =graphic_console_init (s->vga.update, s->vga.invalidate, s->vga.screen_dump, s->vga.text_update, &s->vga); -vmstate_register (0 , &vmstate_cirrus_vga, s); +vmstate_register (NULL ,0 , &vmstate_cirrus_vga, s);rom_add_vga (VGABIOS_CIRRUS_FILENAME );/* XXX ISA-LFB support */ }
hw/cuda.c +1 -1
@@ -763,6 +763,6 @@ void cuda_init (int *cuda_mem_index, qemu_irq irq) s->adb_poll_timer =qemu_new_timer (vm_clock, cuda_adb_poll, s); *cuda_mem_index =cpu_register_io_memory (cuda_read, cuda_write, s); -register_savevm ("cuda" ,-1 ,1 , cuda_save, cuda_load, s); +register_savevm (NULL ,"cuda" ,-1 ,1 , cuda_save, cuda_load, s);qemu_register_reset (cuda_reset, s); }
hw/dma.c +2 -2
@@ -548,8 +548,8 @@ void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit) high_page_enable ? 0x480 : -1, cpu_request_exit);dma_init2 (&dma_controllers[1 ],0xc0 ,1 ,0x88 , high_page_enable ?0x488 :-1 , cpu_request_exit); -vmstate_register (0 , &vmstate_dma, &dma_controllers[0 ]); -vmstate_register (1 , &vmstate_dma, &dma_controllers[1 ]); +vmstate_register (NULL ,0 , &vmstate_dma, &dma_controllers[0 ]); +vmstate_register (NULL ,1 , &vmstate_dma, &dma_controllers[1 ]); dma_bh =qemu_bh_new (DMA_run_bh,NULL ); }
hw/eepro100.c +2 -2
@@ -1834,7 +1834,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev)EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);cpu_unregister_io_memory (s->mmio_index); -vmstate_unregister (s->vmstate, s); +vmstate_unregister (&pci_dev->qdev, s->vmstate, s);eeprom93xx_free (s->eeprom);qemu_del_vlan_client (&s->nic->nc);return 0 ;
@@ -1893,7 +1893,7 @@ static int e100_nic_init(PCIDevice *pci_dev) s->vmstate =qemu_malloc (sizeof (vmstate_eepro100));memcpy (s->vmstate, &vmstate_eepro100,sizeof (vmstate_eepro100)); s->vmstate->name = s->nic->nc.model; -vmstate_register (-1 , s->vmstate, s); +vmstate_register (&pci_dev->qdev,-1 , s->vmstate, s);return 0 ; }
hw/eeprom93xx.c +2 -2
@@ -316,7 +316,7 @@ eeprom_t *eeprom93xx_new(uint16_t nwords)/* Output DO is tristate, read results in 1. */ eeprom->eedo =1 ;logout ("eeprom = 0x%p, nwords = %u\n" , eeprom, nwords); -vmstate_register (0 , &vmstate_eeprom, eeprom); +vmstate_register (NULL ,0 , &vmstate_eeprom, eeprom);return eeprom; }
@@ -324,7 +324,7 @@ void eeprom93xx_free(eeprom_t *eeprom) {/* Destroy EEPROM. */ logout ("eeprom = 0x%p\n" , eeprom); -vmstate_unregister (&vmstate_eeprom, eeprom); +vmstate_unregister (NULL , &vmstate_eeprom, eeprom);qemu_free (eeprom); }
hw/fw_cfg.c +1 -1
@@ -352,7 +352,7 @@ FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,fw_cfg_add_i16 (s,FW_CFG_MAX_CPUS , (uint16_t )max_cpus);fw_cfg_add_i16 (s,FW_CFG_BOOT_MENU , (uint16_t )boot_menu); -vmstate_register (-1 , &vmstate_fw_cfg, s); +vmstate_register (NULL ,-1 , &vmstate_fw_cfg, s);qemu_register_reset (fw_cfg_reset, s);return s;
hw/g364fb.c +1 -1
@@ -598,7 +598,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base, s->irq = irq;qemu_register_reset (g364fb_reset, s); -register_savevm ("g364fb" ,0 ,1 , g364fb_save, g364fb_load, s); +register_savevm (NULL ,"g364fb" ,0 ,1 , g364fb_save, g364fb_load, s);g364fb_reset (s); s->ds = graphic_console_init(g364fb_update_display,
hw/grackle_pci.c +2 -2
@@ -113,8 +113,8 @@ static int pci_grackle_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("grackle" ,0 ,1 , pci_grackle_save, pci_grackle_load, - &s->host_state); +register_savevm (&dev->qdev,"grackle" ,0 ,1 , pci_grackle_save, + pci_grackle_load, &s->host_state);qemu_register_reset (pci_grackle_reset, &s->host_state);return 0 ; }
hw/gt64xxx.c +2 -1
@@ -1146,7 +1146,8 @@ PCIBus *pci_gt64120_init(qemu_irq *pic)gt64120_reset (s); -register_savevm ("GT64120 PCI Bus" ,0 ,1 , gt64120_save, gt64120_load, d); +register_savevm (&d->qdev,"GT64120 PCI Bus" ,0 ,1 , + gt64120_save, gt64120_load, d);return s->pci->bus; }
hw/heathrow_pic.c +1 -1
@@ -224,7 +224,7 @@ qemu_irq *heathrow_pic_init(int *pmem_index, s->irqs = irqs[0 ]; *pmem_index =cpu_register_io_memory (pic_read, pic_write, s); -register_savevm ("heathrow_pic" ,-1 ,1 , heathrow_pic_save, +register_savevm (NULL ,"heathrow_pic" ,-1 ,1 , heathrow_pic_save, heathrow_pic_load, s);qemu_register_reset (heathrow_pic_reset, s);return qemu_allocate_irqs (heathrow_pic_set_irq, s,64 );
hw/hw.h +11 -7
@@ -245,14 +245,16 @@ typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage, void *opaque);typedef int LoadStateHandler (QEMUFile *f,void *opaque,int version_id); -int register_savevm (const char *idstr, +int register_savevm (DeviceState *dev, +const char *idstr,int instance_id,int version_id,SaveStateHandler *save_state,LoadStateHandler *load_state,void *opaque); -int register_savevm_live(const char *idstr, +int register_savevm_live(DeviceState *dev, + const char *idstr, int instance_id, int version_id, SaveSetParamsHandler *set_params,
@@ -261,7 +263,7 @@ int register_savevm_live(const char *idstr, LoadStateHandler *load_state, void *opaque); -void unregister_savevm (const char *idstr,void *opaque); +void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque);typedef void QEMUResetHandler (void *opaque);
@@ -765,11 +767,13 @@ extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id);extern void vmstate_save_state (QEMUFile *f,const VMStateDescription *vmsd,void *opaque); -extern int vmstate_register (int instance_id,const VMStateDescription *vmsd, -void *base); -extern int vmstate_register_with_alias_id (int instance_id, +extern int vmstate_register (DeviceState *dev,int instance_id, +const VMStateDescription *vmsd,void *base); +extern int vmstate_register_with_alias_id (DeviceState *dev, +int instance_id,const VMStateDescription *vmsd,void *base,int alias_id,int required_for_version); -void vmstate_unregister (const VMStateDescription *vmsd,void *opaque); +void vmstate_unregister (DeviceState *dev,const VMStateDescription *vmsd, +void *opaque);#endif
hw/i2c.c +1 -1
@@ -62,7 +62,7 @@ i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)i2c_bus *bus; bus =FROM_QBUS (i2c_bus,qbus_create (&i2c_bus_info, parent, name)); -vmstate_register (-1 , &vmstate_i2c_bus, bus); +vmstate_register (NULL ,-1 , &vmstate_i2c_bus, bus);return bus; }
hw/i8254.c +1 -1
@@ -508,7 +508,7 @@ PITState *pit_init(int base, qemu_irq irq) s->irq_timer =qemu_new_timer (vm_clock, pit_irq_timer, s); s->irq = irq; -vmstate_register (base, &vmstate_pit, pit); +vmstate_register (NULL , base, &vmstate_pit, pit);qemu_register_reset (pit_reset, pit);register_ioport_write (base,4 ,1 , pit_ioport_write, pit);register_ioport_read (base,3 ,1 , pit_ioport_read, pit);
hw/i8259.c +1 -1
@@ -483,7 +483,7 @@ static void pic_init1(int io_addr, int elcr_addr, PicState *s)register_ioport_write (elcr_addr,1 ,1 , elcr_ioport_write, s);register_ioport_read (elcr_addr,1 ,1 , elcr_ioport_read, s); } -vmstate_register (io_addr, &vmstate_pic, s); +vmstate_register (NULL , io_addr, &vmstate_pic, s);qemu_register_reset (pic_reset, s); }
hw/ide/cmd646.c +1 -1
@@ -263,7 +263,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)ide_init2 (&d->bus[0 ], irq[0 ]);ide_init2 (&d->bus[1 ], irq[1 ]); -vmstate_register (0 , &vmstate_ide_pci, d); +vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d);qemu_register_reset (cmd646_reset, d);return 0 ; }
hw/ide/isa.c +1 -1
@@ -71,7 +71,7 @@ static int isa_ide_initfn(ISADevice *dev)ide_init_ioport (&s->bus, s->iobase, s->iobase2);isa_init_irq (dev, &s->irq, s->isairq);ide_init2 (&s->bus, s->irq); -vmstate_register (0 , &vmstate_ide_isa, s); +vmstate_register (&dev->qdev,0 , &vmstate_ide_isa, s);return 0 ; };
hw/ide/macio.c +1 -1
@@ -321,7 +321,7 @@ int pmac_ide_init (DriveInfo **hd_table, qemu_irq irq, pmac_ide_memory =cpu_register_io_memory (pmac_ide_read, pmac_ide_write, d); -vmstate_register (0 , &vmstate_pmac, d); +vmstate_register (NULL ,0 , &vmstate_pmac, d);qemu_register_reset (pmac_ide_reset, d);return pmac_ide_memory;
hw/ide/microdrive.c +1 -1
@@ -545,7 +545,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv) md->bus.ifs[0 ].mdata_size =METADATA_SIZE ; md->bus.ifs[0 ].mdata_storage = (uint8_t *)qemu_mallocz (METADATA_SIZE ); -vmstate_register (-1 , &vmstate_microdrive, md); +vmstate_register (NULL ,-1 , &vmstate_microdrive, md);return &md->card; }
hw/ide/mmio.c +1 -1
@@ -133,7 +133,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, mem2 =cpu_register_io_memory (mmio_ide_status, mmio_ide_cmd, s);cpu_register_physical_memory (membase,16 << shift, mem1);cpu_register_physical_memory (membase2,2 << shift, mem2); -vmstate_register (0 , &vmstate_ide_mmio, s); +vmstate_register (NULL ,0 , &vmstate_ide_mmio, s);qemu_register_reset (mmio_ide_reset, s); }
hw/ide/piix.c +1 -1
@@ -128,7 +128,7 @@ static int pci_piix_ide_initfn(PCIIDEState *d)pci_register_bar (&d->dev,4 ,0x10 ,PCI_BASE_ADDRESS_SPACE_IO , bmdma_map); -vmstate_register (0 , &vmstate_ide_pci, d); +vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d);ide_bus_new (&d->bus[0 ], &d->dev.qdev);ide_bus_new (&d->bus[1 ], &d->dev.qdev);
hw/m48t59.c +1 -1
@@ -694,7 +694,7 @@ static void m48t59_init_common(M48t59State *s) }qemu_get_timedate (&s->alarm,0 ); -register_savevm ("m48t59" ,-1 ,1 , m48t59_save, m48t59_load, s); +register_savevm (NULL ,"m48t59" ,-1 ,1 , m48t59_save, m48t59_load, s); }static int m48t59_init_isa1 (ISADevice *dev)
hw/mac_dbdma.c +1 -1
@@ -845,7 +845,7 @@ void* DBDMA_init (int *dbdma_mem_index) s =qemu_mallocz (sizeof (DBDMA_channel) *DBDMA_CHANNELS ); *dbdma_mem_index =cpu_register_io_memory (dbdma_read, dbdma_write, s); -register_savevm ("dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s); +register_savevm (NULL ,"dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s);qemu_register_reset (dbdma_reset, s); dbdma_bh =qemu_bh_new (DBDMA_run_bh, s);
hw/mac_nvram.c +2 -2
@@ -140,8 +140,8 @@ MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size, s->mem_index =cpu_register_io_memory (nvram_read, nvram_write, s); *mem_index = s->mem_index; -register_savevm ("macio_nvram" ,-1 ,1 , macio_nvram_save, macio_nvram_load, - s); +register_savevm (NULL ,"macio_nvram" ,-1 ,1 , macio_nvram_save, + macio_nvram_load, s);qemu_register_reset (macio_nvram_reset, s);return s;
hw/max111x.c +2 -1
@@ -143,7 +143,8 @@ static int max111x_init(SSISlave *dev, int inputs) s->input[7 ] =0x80 ; s->com =0 ; -register_savevm ("max111x" ,-1 ,0 , max111x_save, max111x_load, s); +register_savevm (&dev->qdev,"max111x" ,-1 ,0 , + max111x_save, max111x_load, s);return 0 ; }
hw/mipsnet.c +2 -2
@@ -239,7 +239,7 @@ static void mipsnet_cleanup(VLANClientState *nc) {MIPSnetState *s =DO_UPCAST (NICState, nc, nc)->opaque; -unregister_savevm ("mipsnet" , s); +unregister_savevm (NULL ,"mipsnet" , s);isa_unassign_ioport (s->io_base,36 );
@@ -284,5 +284,5 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) }mipsnet_reset (s); -register_savevm ("mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s); +register_savevm (NULL ,"mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s); }
hw/mst_fpga.c +2 -1
@@ -234,6 +234,7 @@ qemu_irq *mst_irq_init(PXA2xxState *cpu, uint32_t base, int irq) iomemtype =cpu_register_io_memory (mst_fpga_readfn, mst_fpga_writefn, s);cpu_register_physical_memory (base,0x00100000 , iomemtype); -register_savevm ("mainstone_fpga" ,0 ,0 , mst_fpga_save, mst_fpga_load, s); +register_savevm (NULL ,"mainstone_fpga" ,0 ,0 , mst_fpga_save, + mst_fpga_load, s);return qi; }
hw/nand.c +1 -1
@@ -502,7 +502,7 @@ NANDFlashState *nand_init(int manf_id, int chip_id)is used. */ s->ioaddr = s->io; -register_savevm ("nand" ,-1 ,0 , nand_save, nand_load, s); +register_savevm (NULL ,"nand" ,-1 ,0 , nand_save, nand_load, s);return s; }
hw/openpic.c +3 -2
@@ -1234,7 +1234,8 @@ qemu_irq *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, opp->irq_out = irq_out; opp->need_swap =1 ; -register_savevm ("openpic" ,0 ,2 , openpic_save, openpic_load, opp); +register_savevm (&opp->pci_dev.qdev,"openpic" ,0 ,2 , + openpic_save, openpic_load, opp);qemu_register_reset (openpic_reset, opp); opp->irq_raise = openpic_irq_raise;
@@ -1692,7 +1693,7 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus, mpp->irq_raise = mpic_irq_raise; mpp->reset = mpic_reset; -register_savevm ("mpic" ,0 ,2 , openpic_save, openpic_load, mpp); +register_savevm (NULL ,"mpic" ,0 ,2 , openpic_save, openpic_load, mpp);qemu_register_reset (mpic_reset, mpp);return qemu_allocate_irqs (openpic_set_irq, mpp, mpp->max_irq);
hw/pci.c +1 -1
@@ -232,7 +232,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,QLIST_INIT (&bus->child);pci_host_bus_register (0 , bus);/* for now only pci domain 0 is supported */ -vmstate_register (-1 , &vmstate_pcibus, bus); +vmstate_register (NULL ,-1 , &vmstate_pcibus, bus);qemu_register_reset (pci_bus_reset, bus); }
hw/pckbd.c +1 -1
@@ -418,7 +418,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, s->irq_mouse = mouse_irq; s->mask = mask; -vmstate_register (0 , &vmstate_kbd, s); +vmstate_register (NULL ,0 , &vmstate_kbd, s); s_io_memory =cpu_register_io_memory (kbd_mm_read, kbd_mm_write, s);cpu_register_physical_memory (base, size, s_io_memory);
hw/piix4.c +1 -1
@@ -87,7 +87,7 @@ static int piix4_initfn(PCIDevice *d)uint8_t *pci_conf;isa_bus_new (&d->qdev); -register_savevm ("PIIX4" ,0 ,2 , piix_save, piix_load, d); +register_savevm (&d->qdev,"PIIX4" ,0 ,2 , piix_save, piix_load, d); pci_conf = d->config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_INTEL );
hw/pl011.c +1 -1
@@ -306,7 +306,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id)qemu_chr_add_handlers (s->chr, pl011_can_receive, pl011_receive, pl011_event, s); } -register_savevm ("pl011_uart" ,-1 ,1 , pl011_save, pl011_load, s); +register_savevm (&dev->qdev,"pl011_uart" ,-1 ,1 , pl011_save, pl011_load, s);return 0 ; }
hw/pl022.c +1 -1
@@ -299,7 +299,7 @@ static int pl022_init(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq); s->ssi =ssi_create_bus (&dev->qdev,"ssi" );pl022_reset (s); -register_savevm ("pl022_ssp" ,-1 ,1 , pl022_save, pl022_load, s); +register_savevm (&dev->qdev,"pl022_ssp" ,-1 ,1 , pl022_save, pl022_load, s);return 0 ; }
hw/pl061.c +1 -1
@@ -303,7 +303,7 @@ static int pl061_init(SysBusDevice *dev)qdev_init_gpio_in (&dev->qdev, pl061_set_irq,8 );qdev_init_gpio_out (&dev->qdev, s->out,8 );pl061_reset (s); -register_savevm ("pl061_gpio" ,-1 ,1 , pl061_save, pl061_load, s); +register_savevm (&dev->qdev,"pl061_gpio" ,-1 ,1 , pl061_save, pl061_load, s);return 0 ; }
hw/ppc4xx_pci.c +2 -2
@@ -392,8 +392,8 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],qemu_register_reset (ppc4xx_pci_reset, controller);/* XXX load/save code not tested. */ -register_savevm ("ppc4xx_pci" , ppc4xx_pci_id++,1 , - ppc4xx_pci_save, ppc4xx_pci_load, controller); +register_savevm (&controller->pci_dev->qdev,"ppc4xx_pci" , ppc4xx_pci_id++, +1 , ppc4xx_pci_save, ppc4xx_pci_load, controller);return controller->pci_state.bus;
hw/ppce500_pci.c +2 -2
@@ -310,8 +310,8 @@ PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers) PCIE500_REG_SIZE, index);/* XXX load/save code not tested. */ -register_savevm ("ppce500_pci" , ppce500_pci_id++,1 , - ppce500_pci_save, ppce500_pci_load, controller); +register_savevm (&d->qdev,"ppce500_pci" , ppce500_pci_id++, +1 , ppce500_pci_save, ppce500_pci_load, controller);return controller->pci_state.bus;
hw/ps2.c +2 -2
@@ -595,7 +595,7 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg) s->common.update_irq = update_irq; s->common.update_arg = update_arg; s->scancode_set =2 ; -vmstate_register (0 , &vmstate_ps2_keyboard, s); +vmstate_register (NULL ,0 , &vmstate_ps2_keyboard, s);qemu_add_kbd_event_handler (ps2_put_keycode, s);qemu_register_reset (ps2_kbd_reset, s);return s;
@@ -607,7 +607,7 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg) s->common.update_irq = update_irq; s->common.update_arg = update_arg; -vmstate_register (0 , &vmstate_ps2_mouse, s); +vmstate_register (NULL ,0 , &vmstate_ps2_mouse, s);qemu_add_mouse_event_handler (ps2_mouse_event, s,0 ,"QEMU PS/2 Mouse" );qemu_register_reset (ps2_mouse_reset, s);return s;
hw/pxa2xx.c +15 -12
@@ -860,7 +860,7 @@ static int pxa2xx_ssp_init(SysBusDevice *dev) iomemtype =cpu_register_io_memory (pxa2xx_ssp_readfn, pxa2xx_ssp_writefn, s);sysbus_init_mmio (dev,0x1000 , iomemtype); -register_savevm ("pxa2xx_ssp" ,-1 ,0 , +register_savevm (&dev->qdev,"pxa2xx_ssp" ,-1 ,0 , pxa2xx_ssp_save, pxa2xx_ssp_load, s); s->bus =ssi_create_bus (&dev->qdev,"ssi" );
@@ -1515,7 +1515,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(target_phys_addr_t base,cpu_register_physical_memory (base & ~region_size, region_size +1 , iomemtype); -vmstate_register (base, &vmstate_pxa2xx_i2c, s); +vmstate_register (NULL , base, &vmstate_pxa2xx_i2c, s);return s; }
@@ -1751,7 +1751,7 @@ static PXA2xxI2SState *pxa2xx_i2s_init(target_phys_addr_t base, pxa2xx_i2s_writefn, s);cpu_register_physical_memory (base,0x100000 , iomemtype); -register_savevm ("pxa2xx_i2s" , base,0 , +register_savevm (NULL ,"pxa2xx_i2s" , base,0 , pxa2xx_i2s_save, pxa2xx_i2s_load, s);return s;
@@ -2014,7 +2014,8 @@ static PXA2xxFIrState *pxa2xx_fir_init(target_phys_addr_t base,qemu_chr_add_handlers (chr, pxa2xx_fir_is_empty, pxa2xx_fir_rx, pxa2xx_fir_event, s); -register_savevm ("pxa2xx_fir" ,0 ,0 , pxa2xx_fir_save, pxa2xx_fir_load, s); +register_savevm (NULL ,"pxa2xx_fir" ,0 ,0 , pxa2xx_fir_save, + pxa2xx_fir_load, s);return s; }
@@ -2099,7 +2100,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s);cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
@@ -2110,13 +2111,13 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s);cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); s->pm_base =0x40f00000 ; iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s);cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm ("pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s);for (i =0 ; pxa27x_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
@@ -2140,7 +2141,8 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) pxa2xx_rtc_writefn, s);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm ("pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, pxa2xx_rtc_load, s); +register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, + pxa2xx_rtc_load, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
@@ -2219,7 +2221,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s);cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
@@ -2230,13 +2232,13 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s);cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); s->pm_base =0x40f00000 ; iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s);cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm ("pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s);for (i =0 ; pxa255_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
@@ -2260,7 +2262,8 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) pxa2xx_rtc_writefn, s);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm ("pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, pxa2xx_rtc_load, s); +register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, + pxa2xx_rtc_load, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
hw/pxa2xx_dma.c +1 -1
@@ -507,7 +507,7 @@ static PXA2xxDMAState *pxa2xx_dma_init(target_phys_addr_t base, pxa2xx_dma_writefn, s);cpu_register_physical_memory (base,0x00010000 , iomemtype); -register_savevm ("pxa2xx_dma" ,0 ,0 , pxa2xx_dma_save, pxa2xx_dma_load, s); +register_savevm (NULL ,"pxa2xx_dma" ,0 ,0 , pxa2xx_dma_save, pxa2xx_dma_load, s);return s; }
hw/pxa2xx_gpio.c +1 -1
@@ -312,7 +312,7 @@ PXA2xxGPIOInfo *pxa2xx_gpio_init(target_phys_addr_t base, pxa2xx_gpio_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype); -register_savevm ("pxa2xx_gpio" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_gpio" ,0 ,0 , pxa2xx_gpio_save, pxa2xx_gpio_load, s);return s;
hw/pxa2xx_keypad.c +1 -1
@@ -317,7 +317,7 @@ PXA2xxKeyPadState *pxa27x_keypad_init(target_phys_addr_t base, pxa2xx_keypad_writefn, s);cpu_register_physical_memory (base,0x00100000 , iomemtype); -register_savevm ("pxa2xx_keypad" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_keypad" ,0 ,0 , pxa2xx_keypad_save, pxa2xx_keypad_load, s);return s;
hw/pxa2xx_lcd.c +1 -1
@@ -970,7 +970,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq)exit (1 ); } -register_savevm ("pxa2xx_lcdc" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_lcdc" ,0 ,0 , pxa2xx_lcdc_save, pxa2xx_lcdc_load, s);return s;
hw/pxa2xx_mmci.c +1 -1
@@ -534,7 +534,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base,/* Instantiate the actual storage */ s->card =sd_init (bd,0 ); -register_savevm ("pxa2xx_mmci" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_mmci" ,0 ,0 , pxa2xx_mmci_save, pxa2xx_mmci_load, s);return s;
hw/pxa2xx_pic.c +2 -1
@@ -306,7 +306,8 @@ qemu_irq *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)/* Enable IC coprocessor access. */ cpu_arm_set_cp_io (env,6 , pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s); -register_savevm ("pxa2xx_pic" ,0 ,0 , pxa2xx_pic_save, pxa2xx_pic_load, s); +register_savevm (NULL ,"pxa2xx_pic" ,0 ,0 , pxa2xx_pic_save, + pxa2xx_pic_load, s);return qi; }
hw/pxa2xx_timer.c +1 -1
@@ -455,7 +455,7 @@ static pxa2xx_timer_info *pxa2xx_timer_init(target_phys_addr_t base, pxa2xx_timer_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype); -register_savevm ("pxa2xx_timer" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_timer" ,0 ,0 , pxa2xx_timer_save, pxa2xx_timer_load, s);return s;
hw/qdev.c +2 -2
@@ -280,7 +280,7 @@ int qdev_init(DeviceState *dev) }qemu_register_reset (qdev_reset, dev);if (dev->info->vmsd) { -vmstate_register_with_alias_id (-1 , dev->info->vmsd, dev, +vmstate_register_with_alias_id (dev,-1 , dev->info->vmsd, dev, dev->instance_id_alias, dev->alias_required_for_version); }
@@ -342,7 +342,7 @@ void qdev_free(DeviceState *dev)qbus_free (bus); }if (dev->info->vmsd) -vmstate_unregister (dev->info->vmsd, dev); +vmstate_unregister (dev, dev->info->vmsd, dev);if (dev->info->exit) dev->info->exit (dev);if (dev->opts)
hw/rc4030.c +1 -1
@@ -813,7 +813,7 @@ void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus, s->jazz_bus_irq = jazz_bus;qemu_register_reset (rc4030_reset, s); -register_savevm ("rc4030" ,0 ,2 , rc4030_save, rc4030_load, s); +register_savevm (NULL ,"rc4030" ,0 ,2 , rc4030_save, rc4030_load, s);rc4030_reset (s); s_chipset =cpu_register_io_memory (rc4030_read, rc4030_write, s);
hw/serial.c +2 -2
@@ -813,7 +813,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, s->chr = chr;serial_init_core (s); -vmstate_register (base, &vmstate_serial, s); +vmstate_register (NULL , base, &vmstate_serial, s);register_ioport_write (base,8 ,1 , serial_ioport_write, s);register_ioport_read (base,8 ,1 , serial_ioport_read, s);
@@ -948,7 +948,7 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift, s->chr = chr;serial_init_core (s); -vmstate_register (base, &vmstate_serial, s); +vmstate_register (NULL , base, &vmstate_serial, s);if (ioregister) {if (be) {
hw/spitz.c +5 -4
@@ -178,7 +178,7 @@ static void sl_flash_register(PXA2xxState *cpu, int size) sl_writefn, s);cpu_register_physical_memory (FLASH_BASE ,0x40 , iomemtype); -register_savevm ("sl_flash" ,0 ,0 , sl_save, sl_load, s); +register_savevm (NULL ,"sl_flash" ,0 ,0 , sl_save, sl_load, s); }/* Spitz Keyboard */
@@ -508,7 +508,7 @@ static void spitz_keyboard_register(PXA2xxState *cpu)spitz_keyboard_pre_map (s);qemu_add_kbd_event_handler ((QEMUPutKBDEvent *) spitz_keyboard_handler, s); -register_savevm ("spitz_keyboard" ,0 ,0 , +register_savevm (NULL ,"spitz_keyboard" ,0 ,0 , spitz_keyboard_save, spitz_keyboard_load, s); }
@@ -613,7 +613,7 @@ static int spitz_lcdtg_init(SSISlave *dev) s->bl_power =0 ; s->bl_intensity =0x20 ; -register_savevm ("spitz-lcdtg" ,-1 ,1 , +register_savevm (&dev->qdev,"spitz-lcdtg" ,-1 ,1 , spitz_lcdtg_save, spitz_lcdtg_load, s);return 0 ; }
@@ -708,7 +708,8 @@ static int corgi_ssp_init(SSISlave *dev) s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" ); s->bus[2 ] =ssi_create_bus (&dev->qdev,"ssi2" ); -register_savevm ("spitz_ssp" ,-1 ,1 , spitz_ssp_save, spitz_ssp_load, s); +register_savevm (&dev->qdev,"spitz_ssp" ,-1 ,1 , + spitz_ssp_save, spitz_ssp_load, s);return 0 ; }
hw/ssd0323.c +2 -1
@@ -335,7 +335,8 @@ static int ssd0323_init(SSISlave *dev)qdev_init_gpio_in (&dev->qdev, ssd0323_cd,1 ); -register_savevm ("ssd0323_oled" ,-1 ,1 , ssd0323_save, ssd0323_load, s); +register_savevm (&dev->qdev,"ssd0323_oled" ,-1 ,1 , + ssd0323_save, ssd0323_load, s);return 0 ; }
hw/ssi-sd.c +1 -1
@@ -236,7 +236,7 @@ static int ssi_sd_init(SSISlave *dev) s->mode =SSI_SD_CMD ; bs =qdev_init_bdrv (&dev->qdev,IF_SD ); s->sd =sd_init (bs,1 ); -register_savevm ("ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s); +register_savevm (&dev->qdev,"ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s);return 0 ; }
hw/stellaris.c +6 -5
@@ -354,7 +354,8 @@ static int stellaris_gptm_init(SysBusDevice *dev) s->opaque[0 ] = s->opaque[1 ] = s; s->timer[0 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[0 ]); s->timer[1 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[1 ]); -register_savevm ("stellaris_gptm" ,-1 ,1 , gptm_save, gptm_load, s); +register_savevm (&dev->qdev,"stellaris_gptm" ,-1 ,1 , + gptm_save, gptm_load, s);return 0 ; }
@@ -673,7 +674,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq, ssys_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype);ssys_reset (s); -register_savevm ("stellaris_sys" ,-1 ,1 , ssys_save, ssys_load, s); +register_savevm (NULL ,"stellaris_sys" ,-1 ,1 , ssys_save, ssys_load, s);return 0 ; }
@@ -887,7 +888,7 @@ static int stellaris_i2c_init(SysBusDevice * dev)sysbus_init_mmio (dev,0x1000 , iomemtype);/* ??? For now we only implement the master interface. */ stellaris_i2c_reset (s); -register_savevm ("stellaris_i2c" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_i2c" ,-1 ,1 , stellaris_i2c_save, stellaris_i2c_load, s);return 0 ; }
@@ -1196,7 +1197,7 @@ static int stellaris_adc_init(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , iomemtype);stellaris_adc_reset (s);qdev_init_gpio_in (&dev->qdev, stellaris_adc_trigger,1 ); -register_savevm ("stellaris_adc" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_adc" ,-1 ,1 , stellaris_adc_save, stellaris_adc_load, s);return 0 ; }
@@ -1256,7 +1257,7 @@ static int stellaris_ssi_bus_init(SSISlave *dev) s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" );qdev_init_gpio_in (&dev->qdev, stellaris_ssi_bus_select,1 ); -register_savevm ("stellaris_ssi_bus" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_ssi_bus" ,-1 ,1 , stellaris_ssi_bus_save, stellaris_ssi_bus_load, s);return 0 ; }
hw/stellaris_enet.c +2 -2
@@ -389,7 +389,7 @@ static void stellaris_enet_cleanup(VLANClientState *nc) {stellaris_enet_state *s =DO_UPCAST (NICState, nc, nc)->opaque; -unregister_savevm ("stellaris_enet" , s); +unregister_savevm (&s->busdev.qdev,"stellaris_enet" , s);cpu_unregister_io_memory (s->mmio_index);
@@ -419,7 +419,7 @@ static int stellaris_enet_init(SysBusDevice *dev)qemu_format_nic_info_str (&s->nic->nc, s->conf.macaddr.a);stellaris_enet_reset (s); -register_savevm ("stellaris_enet" ,-1 ,1 , +register_savevm (&s->busdev.qdev,"stellaris_enet" ,-1 ,1 , stellaris_enet_save, stellaris_enet_load, s);return 0 ; }
hw/stellaris_input.c +1 -1
@@ -86,6 +86,6 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) } s->num_buttons = n;qemu_add_kbd_event_handler (stellaris_gamepad_put_key, s); -register_savevm ("stellaris_gamepad" ,-1 ,1 , +register_savevm (NULL ,"stellaris_gamepad" ,-1 ,1 , stellaris_gamepad_save, stellaris_gamepad_load, s); }
hw/syborg_fb.c +1 -1
@@ -526,7 +526,7 @@ static int syborg_fb_init(SysBusDevice *dev)if (!s->rows) s->rows =ds_get_height (s->ds); -register_savevm ("syborg_framebuffer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_framebuffer" ,-1 ,1 , syborg_fb_save, syborg_fb_load, s);return 0 ; }
hw/syborg_interrupt.c +2 -1
@@ -214,7 +214,8 @@ static int syborg_int_init(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , iomemtype); s->flags =qemu_mallocz (s->num_irqs *sizeof (syborg_int_flags)); -register_savevm ("syborg_int" ,-1 ,1 , syborg_int_save, syborg_int_load, s); +register_savevm (&dev->qdev,"syborg_int" ,-1 ,1 , syborg_int_save, + syborg_int_load, s);return 0 ; }
hw/syborg_keyboard.c +1 -1
@@ -220,7 +220,7 @@ static int syborg_keyboard_init(SysBusDevice *dev)qemu_add_kbd_event_handler (syborg_keyboard_event, s); -register_savevm ("syborg_keyboard" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_keyboard" ,-1 ,1 , syborg_keyboard_save, syborg_keyboard_load, s);return 0 ; }
hw/syborg_pointer.c +1 -1
@@ -218,7 +218,7 @@ static int syborg_pointer_init(SysBusDevice *dev)qemu_add_mouse_event_handler (syborg_pointer_event, s, s->absolute,"Syborg Pointer" ); -register_savevm ("syborg_pointer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_pointer" ,-1 ,1 , syborg_pointer_save, syborg_pointer_load, s);return 0 ; }
hw/syborg_rtc.c +2 -1
@@ -136,7 +136,8 @@ static int syborg_rtc_init(SysBusDevice *dev)qemu_get_timedate (&tm,0 ); s->offset = (uint64_t )mktime (&tm) *1000000000 ; -register_savevm ("syborg_rtc" ,-1 ,1 , syborg_rtc_save, syborg_rtc_load, s); +register_savevm (&dev->qdev,"syborg_rtc" ,-1 ,1 , + syborg_rtc_save, syborg_rtc_load, s);return 0 ; }
hw/syborg_serial.c +1 -1
@@ -335,7 +335,7 @@ static int syborg_serial_init(SysBusDevice *dev) } s->read_fifo =qemu_mallocz (s->fifo_size *sizeof (s->read_fifo[0 ])); -register_savevm ("syborg_serial" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_serial" ,-1 ,1 , syborg_serial_save, syborg_serial_load, s);return 0 ; }
hw/syborg_timer.c +1 -1
@@ -221,7 +221,7 @@ static int syborg_timer_init(SysBusDevice *dev) bh =qemu_bh_new (syborg_timer_tick, s); s->timer =ptimer_init (bh);ptimer_set_freq (s->timer, s->freq); -register_savevm ("syborg_timer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_timer" ,-1 ,1 , syborg_timer_save, syborg_timer_load, s);return 0 ; }
hw/tsc2005.c +1 -1
@@ -548,7 +548,7 @@ void *tsc2005_init(qemu_irq pintdav) "QEMU TSC2005-driven Touchscreen");qemu_register_reset ((void *) tsc2005_reset, s); -register_savevm ("tsc2005" ,-1 ,0 , tsc2005_save, tsc2005_load, s); +register_savevm (NULL ,"tsc2005" ,-1 ,0 , tsc2005_save, tsc2005_load, s);return s; }
hw/tsc210x.c +2 -2
@@ -1143,7 +1143,7 @@ uWireSlave *tsc2102_init(qemu_irq pint)AUD_register_card (s->name, &s->card);qemu_register_reset ((void *) tsc210x_reset, s); -register_savevm (s->name,-1 ,0 , +register_savevm (NULL , s->name,-1 ,0 , tsc210x_save, tsc210x_load, s);return &s->chip;
@@ -1194,7 +1194,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)AUD_register_card (s->name, &s->card);qemu_register_reset ((void *) tsc210x_reset, s); -register_savevm (s->name,-1 ,0 , tsc210x_save, tsc210x_load, s); +register_savevm (NULL , s->name,-1 ,0 , tsc210x_save, tsc210x_load, s);return &s->chip; }
hw/unin_pci.c +4 -2
@@ -158,7 +158,8 @@ static int pci_unin_main_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("uninorth" ,0 ,1 , pci_unin_save, pci_unin_load, &s->host_state); +register_savevm (&dev->qdev,"uninorth" ,0 ,1 , + pci_unin_save, pci_unin_load, &s->host_state);qemu_register_reset (pci_unin_reset, &s->host_state);return 0 ; }
@@ -178,7 +179,8 @@ static int pci_u3_agp_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("uninorth" ,0 ,1 , pci_unin_save, pci_unin_load, &s->host_state); +register_savevm (&dev->qdev,"uninorth" ,0 ,1 , + pci_unin_save, pci_unin_load, &s->host_state);qemu_register_reset (pci_unin_reset, &s->host_state);return 0 ;
hw/vga-isa-mm.c +1 -1
@@ -100,7 +100,7 @@ static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base, s_ioport_ctrl =cpu_register_io_memory (vga_mm_read_ctrl, vga_mm_write_ctrl, s); vga_io_memory =cpu_register_io_memory (vga_mem_read, vga_mem_write, s); -vmstate_register (0 , &vmstate_vga_common, s); +vmstate_register (NULL ,0 , &vmstate_vga_common, s);cpu_register_physical_memory (ctrl_base,0x100000 , s_ioport_ctrl); s->vga.bank_offset =0 ;
hw/vga-isa.c +1 -1
@@ -37,7 +37,7 @@ int isa_vga_init(void)vga_common_init (s,VGA_RAM_SIZE );vga_init (s); -vmstate_register (0 , &vmstate_vga_common, s); +vmstate_register (NULL ,0 , &vmstate_vga_common, s); s->ds =graphic_console_init (s->update, s->invalidate, s->screen_dump, s->text_update, s);
hw/virtio-balloon.c +2 -1
@@ -270,7 +270,8 @@ VirtIODevice *virtio_balloon_init(DeviceState *dev)reset_stats (s);qemu_add_balloon_handler (virtio_balloon_to_target, s); -register_savevm ("virtio-balloon" ,-1 ,1 , virtio_balloon_save, virtio_balloon_load, s); +register_savevm (dev,"virtio-balloon" ,-1 ,1 , + virtio_balloon_save, virtio_balloon_load, s);return &s->vdev; }
hw/virtio-blk.c +1 -1
@@ -498,7 +498,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) s->vq =virtio_add_queue (&s->vdev,128 , virtio_blk_handle_output);qemu_add_vm_change_state_handler (virtio_blk_dma_restart_cb, s); -register_savevm ("virtio-blk" , virtio_blk_id++,2 , +register_savevm (dev,"virtio-blk" , virtio_blk_id++,2 , virtio_blk_save, virtio_blk_load, s);return &s->vdev;
hw/virtio-net.c +2 -2
@@ -923,7 +923,7 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) n->vlans =qemu_mallocz (MAX_VLAN >>3 ); -register_savevm ("virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , +register_savevm (NULL ,"virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , virtio_net_save, virtio_net_load, n); n->vmstate =qemu_add_vm_change_state_handler (virtio_net_vmstate_change, n);
@@ -941,7 +941,7 @@ void virtio_net_exit(VirtIODevice *vdev)qemu_purge_queued_packets (&n->nic->nc); -unregister_savevm ("virtio-net" , n); +unregister_savevm (NULL ,"virtio-net" , n);qemu_free (n->mac_table.macs);qemu_free (n->vlans);
hw/virtio-serial-bus.c +1 -1
@@ -790,7 +790,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)* Register for the savevm section with the virtio-console name * to preserve backward compat */ -register_savevm ("virtio-console" ,-1 ,2 , virtio_serial_save, +register_savevm (dev,"virtio-console" ,-1 ,2 , virtio_serial_save, virtio_serial_load, vser);return vdev;
hw/vmmouse.c +1 -1
@@ -274,7 +274,7 @@ void *vmmouse_init(void *m)vmport_register (VMMOUSE_STATUS , vmmouse_ioport_read, s);vmport_register (VMMOUSE_COMMAND , vmmouse_ioport_read, s);vmport_register (VMMOUSE_DATA , vmmouse_ioport_read, s); -vmstate_register (0 , &vmstate_vmmouse, s); +vmstate_register (NULL ,0 , &vmstate_vmmouse, s);return s; }
hw/vmware_vga.c +1 -1
@@ -1169,7 +1169,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)vga_common_init (&s->vga, vga_ram_size);vga_init (&s->vga); -vmstate_register (0 , &vmstate_vga_common, &s->vga); +vmstate_register (NULL ,0 , &vmstate_vga_common, &s->vga);vga_init_vbe (&s->vga);
hw/zaurus.c +1 -1
@@ -230,7 +230,7 @@ ScoopInfo *scoop_init(PXA2xxState *cpu, iomemtype =cpu_register_io_memory (scoop_readfn, scoop_writefn, s);cpu_register_physical_memory (target_base,0x1000 , iomemtype); -register_savevm ("scoop" , instance,1 , scoop_save, scoop_load, s); +register_savevm (NULL ,"scoop" , instance,1 , scoop_save, scoop_load, s);return s; }
qemu-timer.c +1 -1
@@ -662,7 +662,7 @@ static const VMStateDescription vmstate_timers = {void configure_icount (const char *option) { -vmstate_register (0 , &vmstate_timers, &timers_state); +vmstate_register (NULL ,0 , &vmstate_timers, &timers_state);if (!option)return ;
savevm.c +13 -9
@@ -1026,7 +1026,8 @@ static int calculate_new_instance_id(const char *idstr)of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly distinguishing id for all instances of your device class. */ -int register_savevm_live(const char *idstr, +int register_savevm_live(DeviceState *dev, + const char *idstr, int instance_id, int version_id, SaveSetParamsHandler *set_params,
@@ -1058,18 +1059,19 @@ int register_savevm_live(const char *idstr,return 0 ; } -int register_savevm (const char *idstr, +int register_savevm (DeviceState *dev, +const char *idstr,int instance_id,int version_id,SaveStateHandler *save_state,LoadStateHandler *load_state,void *opaque) { -return register_savevm_live (idstr, instance_id, version_id, +return register_savevm_live (dev, idstr, instance_id, version_id,NULL ,NULL , save_state, load_state, opaque); } -void unregister_savevm (const char *idstr,void *opaque) +void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque) {SaveStateEntry *se, *new_se;
@@ -1081,7 +1083,7 @@ void unregister_savevm(const char *idstr, void *opaque) } } -int vmstate_register_with_alias_id (int instance_id, +int vmstate_register_with_alias_id (DeviceState *dev,int instance_id,const VMStateDescription *vmsd,void *opaque,int alias_id,int required_for_version)
@@ -1112,13 +1114,15 @@ int vmstate_register_with_alias_id(int instance_id,return 0 ; } -int vmstate_register (int instance_id,const VMStateDescription *vmsd, -void *opaque) +int vmstate_register (DeviceState *dev,int instance_id, +const VMStateDescription *vmsd,void *opaque) { -return vmstate_register_with_alias_id (instance_id, vmsd, opaque,-1 ,0 ); +return vmstate_register_with_alias_id (dev, instance_id, vmsd, + opaque,-1 ,0 ); } -void vmstate_unregister (const VMStateDescription *vmsd,void *opaque) +void vmstate_unregister (DeviceState *dev,const VMStateDescription *vmsd, +void *opaque) {SaveStateEntry *se, *new_se;
slirp/slirp.c +3 -2
@@ -232,7 +232,8 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, slirp->opaque = opaque; -register_savevm ("slirp" ,0 ,3 , slirp_state_save, slirp_state_load, slirp); +register_savevm (NULL ,"slirp" ,0 ,3 , + slirp_state_save, slirp_state_load, slirp);QTAILQ_INSERT_TAIL (&slirp_instances, slirp, entry);
@@ -243,7 +244,7 @@ void slirp_cleanup(Slirp *slirp) {QTAILQ_REMOVE (&slirp_instances, slirp, entry); -unregister_savevm ("slirp" , slirp); +unregister_savevm (NULL ,"slirp" , slirp);qemu_free (slirp->tftp_prefix);qemu_free (slirp->bootp_filename);
vl.c +1 -1
@@ -2794,7 +2794,7 @@ int main(int argc, char **argv, char **envp)if (qemu_opts_foreach (&qemu_drive_opts, drive_init_func, &machine->use_scsi,1 ) !=0 )exit (1 ); -register_savevm_live ("ram" ,0 ,3 ,NULL , ram_save_live,NULL , +register_savevm_live (NULL ,"ram" ,0 ,3 ,NULL , ram_save_live,NULL , ram_load,NULL );if (nb_numa_nodes >0 ) {
PATCH v2 6/16 savevm: Make use of DeviceState
In reply to Alex WilliamsonFor callers that pass a device we can traverse up the qdev tree and make use of the BusInfo.get_dev_path information for creating unique savevm id strings. This avoids needing to rely on the instance number, which can cause problems with device initialization order and hotplug.
For compatibility, we also store away the old id string and instance so we can accept migrations from VMs as we add new get_dev_path implementations.
---
savevm.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 79 insertions(+), 5 deletions(-)
savevm.c +79 -5
@@ -72,6 +72,7 @@#include "qemu-common.h" #include "hw/hw.h" +#include "hw/qdev.h" #include "net.h" #include "monitor.h" #include "sysemu.h"
@@ -988,6 +989,11 @@ const VMStateInfo vmstate_info_unused_buffer = { .put = put_unused_buffer, }; +typedef struct CompatEntry { +char idstr[256 ]; +int instance_id; +}CompatEntry ; + typedef struct SaveStateEntry { QTAILQ_ENTRY(SaveStateEntry) entry; char idstr[256];
@@ -1001,6 +1007,7 @@ typedef struct SaveStateEntry {LoadStateHandler *load_state;const VMStateDescription *vmsd;void *opaque; +CompatEntry *compat; } SaveStateEntry;
@@ -1022,6 +1029,23 @@ static int calculate_new_instance_id(const char *idstr)return instance_id; } +static int calculate_compat_instance_id (const char *idstr) +{ +SaveStateEntry *se; +int instance_id =0 ; + + QTAILQ_FOREACH(se, &savevm_handlers, entry) { +if (!se->compat) +continue ; + +if (strcmp (idstr, se->compat->idstr) ==0 + && instance_id <= se->compat->instance_id) { + instance_id = se->compat->instance_id +1 ; + } + } +return instance_id; +} +/* TODO: Individual devices generally have very little idea about the rest of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly
@@ -1039,7 +1063,6 @@ int register_savevm_live(DeviceState *dev,SaveStateEntry *se; se =qemu_mallocz (sizeof (SaveStateEntry)); -pstrcpy (se->idstr,sizeof (se->idstr), idstr); se->version_id = version_id; se->section_id = global_section_id++; se->set_params = set_params;
@@ -1049,11 +1072,28 @@ int register_savevm_live(DeviceState *dev, se->opaque = opaque; se->vmsd =NULL ; +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +pstrcpy (se->idstr,sizeof (se->idstr), id); +pstrcat (se->idstr,sizeof (se->idstr),"/" ); +qemu_free (id); + + se->compat =qemu_mallocz (sizeof (CompatEntry)); +pstrcpy (se->compat->idstr,sizeof (se->compat->idstr), idstr); + se->compat->instance_id = instance_id ==-1 ? +calculate_compat_instance_id (idstr) : instance_id; + instance_id =-1 ; + } + } +pstrcat (se->idstr,sizeof (se->idstr), idstr); +if (instance_id ==-1 ) { - se->instance_id =calculate_new_instance_id (idstr); + se->instance_id =calculate_new_instance_id (se->idstr); }else { se->instance_id = instance_id; } +assert (!se->compat || se->instance_id ==0 );/* add at the end of list */ QTAILQ_INSERT_TAIL (&savevm_handlers, se, entry);return 0 ;
@@ -1074,9 +1114,20 @@ int register_savevm(DeviceState *dev,void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque) {SaveStateEntry *se, *new_se; +char id[256 ] ="" ; + +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *path = dev->parent_bus->info->get_dev_path (dev); +if (path) { +pstrcpy (id,sizeof (id), path); +pstrcat (id,sizeof (id),"/" ); +qemu_free (path); + } + } +pstrcat (id,sizeof (id), idstr); QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { -if (strcmp (se->idstr, idstr) ==0 && se->opaque == opaque) { +if (strcmp (se->idstr, id) ==0 && se->opaque == opaque) {QTAILQ_REMOVE (&savevm_handlers, se, entry);qemu_free (se); }
@@ -1094,7 +1145,6 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,assert (alias_id ==-1 || required_for_version >= vmsd->minimum_version_id); se =qemu_mallocz (sizeof (SaveStateEntry)); -pstrcpy (se->idstr,sizeof (se->idstr), vmsd->name); se->version_id = vmsd->version_id; se->section_id = global_section_id++; se->save_live_state =NULL ;
@@ -1104,11 +1154,28 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, se->vmsd = vmsd; se->alias_id = alias_id; +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +pstrcpy (se->idstr,sizeof (se->idstr), id); +pstrcat (se->idstr,sizeof (se->idstr),"/" ); +qemu_free (id); + + se->compat =qemu_mallocz (sizeof (CompatEntry)); +pstrcpy (se->compat->idstr,sizeof (se->compat->idstr), vmsd->name); + se->compat->instance_id = instance_id ==-1 ? +calculate_compat_instance_id (vmsd->name) : instance_id; + instance_id =-1 ; + } + } +pstrcat (se->idstr,sizeof (se->idstr), vmsd->name); +if (instance_id ==-1 ) { - se->instance_id =calculate_new_instance_id (vmsd->name); + se->instance_id =calculate_new_instance_id (se->idstr); }else { se->instance_id = instance_id; } +assert (!se->compat || se->instance_id ==0 );/* add at the end of list */ QTAILQ_INSERT_TAIL (&savevm_handlers, se, entry);return 0 ;
@@ -1454,6 +1521,13 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) (instance_id == se->instance_id || instance_id == se->alias_id))return se; +/* Migrating from an older version? */ +if (strstr (se->idstr, idstr) && se->compat) { +if (!strcmp (se->compat->idstr, idstr) && + (instance_id == se->compat->instance_id || + instance_id == se->alias_id)) +return se; + } }return NULL ; }
PATCH v2 7/16 eepro100: Add a dev field to eeprom new/free functions
In reply to Alex WilliamsonThis allows us to create a more meaningful savevm string.
---
hw/eepro100.c | 4 ++-- hw/eeprom93xx.c | 8 ++++---- hw/eeprom93xx.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
hw/eepro100.c +2 -2
@@ -1835,7 +1835,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev)cpu_unregister_io_memory (s->mmio_index);vmstate_unregister (&pci_dev->qdev, s->vmstate, s); -eeprom93xx_free (s->eeprom); +eeprom93xx_free (&pci_dev->qdev, s->eeprom);qemu_del_vlan_client (&s->nic->nc);return 0 ; }
@@ -1862,7 +1862,7 @@ static int e100_nic_init(PCIDevice *pci_dev)/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ - s->eeprom =eeprom93xx_new (EEPROM_SIZE ); + s->eeprom =eeprom93xx_new (&pci_dev->qdev,EEPROM_SIZE );/* Handler for memory-mapped I/O */ s->mmio_index =
hw/eeprom93xx.c +4 -4
@@ -289,7 +289,7 @@ void eeprom93xx_reset(eeprom_t *eeprom) }#endif -eeprom_t *eeprom93xx_new (uint16_t nwords) +eeprom_t *eeprom93xx_new (DeviceState *dev,uint16_t nwords) {/* Add a new EEPROM (with 16, 64 or 256 words). */ eeprom_t *eeprom;
@@ -316,15 +316,15 @@ eeprom_t *eeprom93xx_new(uint16_t nwords)/* Output DO is tristate, read results in 1. */ eeprom->eedo =1 ;logout ("eeprom = 0x%p, nwords = %u\n" , eeprom, nwords); -vmstate_register (NULL ,0 , &vmstate_eeprom, eeprom); +vmstate_register (dev,0 , &vmstate_eeprom, eeprom);return eeprom; } -void eeprom93xx_free (eeprom_t *eeprom) +void eeprom93xx_free (DeviceState *dev,eeprom_t *eeprom) {/* Destroy EEPROM. */ logout ("eeprom = 0x%p\n" , eeprom); -vmstate_unregister (NULL , &vmstate_eeprom, eeprom); +vmstate_unregister (dev, &vmstate_eeprom, eeprom);qemu_free (eeprom); }
hw/eeprom93xx.h +2 -2
@@ -23,10 +23,10 @@typedef struct _eeprom_t eeprom_t ;/* Create a new EEPROM with (nwords * 2) bytes. */ -eeprom_t *eeprom93xx_new (uint16_t nwords); +eeprom_t *eeprom93xx_new (DeviceState *dev,uint16_t nwords);/* Destroy an existing EEPROM. */ -void eeprom93xx_free (eeprom_t *eeprom); +void eeprom93xx_free (DeviceState *dev,eeprom_t *eeprom);/* Read from the EEPROM. */ uint16_t eeprom93xx_read (eeprom_t *eeprom);
PATCH v2 8/16 virtio-net: Incorporate a DeviceState pointer and let savevm track instances
In reply to Alex WilliamsonStuff a pointer to the DeviceState into the VirtIONet structure so that we can easily remove the vmstate entry later. Also, let vmstate track the instance number (it should always be zero internally since the device path should now be unique).
---
hw/virtio-net.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
hw/virtio-net.c +4 -3
@@ -60,6 +60,7 @@ typedef struct VirtIONetuint8_t *macs; } mac_table;uint32_t *vlans; +DeviceState *qdev; } VirtIONet;/* TODO
@@ -890,7 +891,6 @@ static void virtio_net_vmstate_change(void *opaque, int running, int reason)VirtIODevice *virtio_net_init (DeviceState *dev,NICConf *conf) {VirtIONet *n; -static int virtio_net_id; n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, sizeof(struct virtio_net_config),
@@ -923,7 +923,8 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) n->vlans =qemu_mallocz (MAX_VLAN >>3 ); -register_savevm (NULL ,"virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , + n->qdev = dev; +register_savevm (dev,"virtio-net" ,-1 ,VIRTIO_NET_VM_VERSION , virtio_net_save, virtio_net_load, n); n->vmstate =qemu_add_vm_change_state_handler (virtio_net_vmstate_change, n);
@@ -941,7 +942,7 @@ void virtio_net_exit(VirtIODevice *vdev)qemu_purge_queued_packets (&n->nic->nc); -unregister_savevm (NULL ,"virtio-net" , n); +unregister_savevm (n->qdev,"virtio-net" , n);qemu_free (n->mac_table.macs);qemu_free (n->vlans);
PATCH v2 9/16 qemu_ram_alloc: Add DeviceState and name parameters
In reply to Alex WilliamsonThese will be used to generate unique id strings for ramblocks. The name field is required, the device pointer is optional as most callers don't have a device. When there's no device or the device isn't a child of a bus implementing BusInfo.get_dev_path, the name should be unique for the platform.
---
cpu-common.h | 2 +- exec.c | 2 +- hw/an5206.c | 4 ++-- hw/armv7m.c | 9 ++++++--- hw/axis_dev88.c | 4 ++-- hw/dummy_m68k.c | 2 +- hw/etraxfs.c | 6 +++--- hw/g364fb.c | 2 +- hw/gumstix.c | 6 ++++-- hw/integratorcp.c | 4 ++-- hw/mainstone.c | 6 ++++-- hw/mcf5208.c | 4 ++-- hw/mips_jazz.c | 4 ++-- hw/mips_malta.c | 4 ++-- hw/mips_mipssim.c | 4 ++-- hw/mips_r4k.c | 6 +++--- hw/musicpal.c | 11 +++++++---- hw/omap1.c | 6 ++++-- hw/omap2.c | 6 ++++-- hw/omap_sx1.c | 12 ++++++++---- hw/onenand.c | 2 +- hw/palm.c | 3 ++- hw/pc.c | 7 ++++--- hw/pci.c | 7 ++++++- hw/petalogix_s3adsp1800_mmu.c | 7 ++++--- hw/ppc405_boards.c | 18 +++++++++--------- hw/ppc405_uc.c | 2 +- hw/ppc4xx_devs.c | 4 +++- hw/ppc_newworld.c | 6 +++--- hw/ppc_oldworld.c | 6 +++--- hw/ppc_prep.c | 4 ++-- hw/ppce500_mpc8544ds.c | 3 ++- hw/pxa2xx.c | 12 ++++++++---- hw/r2d.c | 4 ++-- hw/realview.c | 6 +++--- hw/s390-virtio.c | 2 +- hw/sm501.c | 2 +- hw/spitz.c | 2 +- hw/sun4m.c | 8 ++++---- hw/sun4u.c | 4 ++-- hw/syborg.c | 2 +- hw/tc6393xb.c | 2 +- hw/tcx.c | 2 +- hw/tosa.c | 2 +- hw/versatilepb.c | 2 +- hw/vga.c | 2 +- hw/vmware_vga.c | 2 +- 47 files changed, 130 insertions(+), 97 deletions(-)
cpu-common.h +1 -1
@@ -40,7 +40,7 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr, }ram_addr_t cpu_get_physical_page_desc (target_phys_addr_t addr); -ram_addr_t qemu_ram_alloc (ram_addr_t ); +ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size);void qemu_ram_free (ram_addr_t addr);/* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr (ram_addr_t addr);
exec.c +1 -1
@@ -2776,7 +2776,7 @@ static ram_addr_t find_ram_offset(ram_addr_t size)return last; } -ram_addr_t qemu_ram_alloc (ram_addr_t size) +ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size) {RAMBlock *new_block;
hw/an5206.c +2 -2
@@ -54,11 +54,11 @@ static void an5206_init(ram_addr_t ram_size,/* DRAM at address zero */ cpu_register_physical_memory (0 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"an5206.ram" , ram_size) |IO_MEM_RAM );/* Internal SRAM. */ cpu_register_physical_memory (AN5206_RAMBAR_ADDR ,512 , -qemu_ram_alloc (512 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"an5206.sram" ,512 ) |IO_MEM_RAM );mcf5206_init (AN5206_MBAR_ADDR , env);
hw/armv7m.c +6 -3
@@ -200,9 +200,11 @@ qemu_irq *armv7m_init(int flash_size, int sram_size,/* Flash programming is done via the SCU, so pretend it is ROM. */ cpu_register_physical_memory (0 , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"armv7m.flash" , + flash_size) |IO_MEM_ROM );cpu_register_physical_memory (0x20000000 , sram_size, -qemu_ram_alloc (sram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"armv7m.sram" , + sram_size) |IO_MEM_RAM );armv7m_bitband_init (); nvic =qdev_create (NULL ,"armv7m_nvic" );
@@ -236,7 +238,8 @@ qemu_irq *armv7m_init(int flash_size, int sram_size,space. This stops qemu complaining about executing code outside RAM when returning from an exception. */ cpu_register_physical_memory (0xfffff000 ,0x1000 , -qemu_ram_alloc (0x1000 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"armv7m.hack" , +0x1000 ) |IO_MEM_RAM );qemu_register_reset (armv7m_reset, env);return pic;
hw/axis_dev88.c +2 -2
@@ -268,12 +268,12 @@ void axisdev88_init (ram_addr_t ram_size, env =cpu_init (cpu_model);/* allocate RAM */ - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"axisdev88.ram" , ram_size);cpu_register_physical_memory (0x40000000 , ram_size, phys_ram |IO_MEM_RAM );/* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the internal memory. */ - phys_intmem =qemu_ram_alloc (INTMEM_SIZE ); + phys_intmem =qemu_ram_alloc (NULL ,"axisdev88.chipram" ,INTMEM_SIZE );cpu_register_physical_memory (0x38000000 ,INTMEM_SIZE , phys_intmem |IO_MEM_RAM );
hw/dummy_m68k.c +1 -1
@@ -39,7 +39,7 @@ static void dummy_m68k_init(ram_addr_t ram_size,/* RAM at address zero */ cpu_register_physical_memory (0 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"dummy_m68k.ram" , ram_size) |IO_MEM_RAM );/* Load kernel. */ if (kernel_filename) {
hw/etraxfs.c +3 -3
@@ -68,17 +68,17 @@ void bareetraxfs_init (ram_addr_t ram_size, env =cpu_init (cpu_model);/* allocate RAM */ - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"etraxfs.ram" , ram_size);cpu_register_physical_memory (0x40000000 , ram_size, phys_ram |IO_MEM_RAM );/* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the internal memory. */ - phys_intmem =qemu_ram_alloc (INTMEM_SIZE ); + phys_intmem =qemu_ram_alloc (NULL ,"etraxfs.chipram" ,INTMEM_SIZE );cpu_register_physical_memory (0x38000000 ,INTMEM_SIZE , phys_intmem |IO_MEM_RAM ); - phys_flash =qemu_ram_alloc (FLASH_SIZE ); + phys_flash =qemu_ram_alloc (NULL ,"etraxfs.flash" ,FLASH_SIZE ); dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash_cfi02_register(0x0, phys_flash, dinfo ? dinfo->bdrv : NULL, (64 * 1024),
hw/g364fb.c +1 -1
@@ -593,7 +593,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base, s =qemu_mallocz (sizeof (G364State)); s->vram_size =8 *1024 *1024 ; - s->vram_offset =qemu_ram_alloc (s->vram_size); + s->vram_offset =qemu_ram_alloc (NULL ,"g364fb.vram" , s->vram_size); s->vram =qemu_get_ram_ptr (s->vram_offset); s->irq = irq;
hw/gumstix.c +4 -2
@@ -67,7 +67,8 @@ static void connex_init(ram_addr_t ram_size,#else be =0 ;#endif -if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (connex_rom), +if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (NULL ,"connext.rom" , + connex_rom), dinfo->bdrv, sector_len, connex_rom / sector_len,2 ,0 ,0 ,0 ,0 , be)) {fprintf (stderr,"qemu: Error registering flash memory.\n" );
@@ -105,7 +106,8 @@ static void verdex_init(ram_addr_t ram_size,#else be =0 ;#endif -if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (verdex_rom), +if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (NULL ,"verdex.rom" , + verdex_rom), dinfo->bdrv, sector_len, verdex_rom / sector_len,2 ,0 ,0 ,0 ,0 , be)) {fprintf (stderr,"qemu: Error registering flash memory.\n" );
hw/integratorcp.c +2 -2
@@ -253,7 +253,7 @@ static int integratorcm_init(SysBusDevice *dev) }memcpy (integrator_spd +73 ,"QEMU-MEMORY" ,11 ); s->cm_init =0x00000112 ; - s->flash_offset =qemu_ram_alloc (0x100000 ); + s->flash_offset =qemu_ram_alloc (NULL ,"integrator.flash" ,0x100000 ); iomemtype =cpu_register_io_memory (integratorcm_readfn, integratorcm_writefn, s);
@@ -467,7 +467,7 @@ static void integratorcp_init(ram_addr_t ram_size,fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"integrator.ram" , ram_size);/* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero*/
hw/mainstone.c +4 -2
@@ -87,7 +87,8 @@ static void mainstone_common_init(ram_addr_t ram_size,/* Setup CPU & memory */ cpu =pxa270_init (mainstone_binfo.ram_size, cpu_model);cpu_register_physical_memory (0 ,MAINSTONE_ROM , -qemu_ram_alloc (MAINSTONE_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"mainstone.rom" , +MAINSTONE_ROM ) |IO_MEM_ROM );#ifdef TARGET_WORDS_BIGENDIAN be =1 ;
@@ -104,7 +105,8 @@ static void mainstone_common_init(ram_addr_t ram_size, }if (!pflash_cfi01_register (mainstone_flash_base[i], -qemu_ram_alloc (MAINSTONE_FLASH ), +qemu_ram_alloc (NULL ,"mainstone.flash" , +MAINSTONE_FLASH ), dinfo->bdrv, sector_len,MAINSTONE_FLASH / sector_len,4 ,0 ,0 ,0 ,0 , be)) {
hw/mcf5208.c +2 -2
@@ -220,11 +220,11 @@ static void mcf5208evb_init(ram_addr_t ram_size,/* DRAM at 0x40000000 */ cpu_register_physical_memory (0x40000000 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"mcf5208.ram" , ram_size) |IO_MEM_RAM );/* Internal SRAM. */ cpu_register_physical_memory (0x80000000 ,16384 , -qemu_ram_alloc (16384 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"mcf5208.sram" ,16384 ) |IO_MEM_RAM );/* Internal peripherals. */ pic =mcf_intc_init (0xfc048000 , env);
hw/mips_jazz.c +2 -2
@@ -160,10 +160,10 @@ void mips_jazz_init (ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, env);/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"mips_jazz.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM ); - bios_offset =qemu_ram_alloc (MAGNUM_BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"mips_jazz.bios" ,MAGNUM_BIOS_SIZE );cpu_register_physical_memory (0x1fc00000LL ,MAGNUM_BIOS_SIZE , bios_offset |IO_MEM_ROM ); cpu_register_physical_memory(0xfff00000LL,
hw/mips_malta.c +2 -2
@@ -833,8 +833,8 @@ void mips_malta_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20)));exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + ram_offset =qemu_ram_alloc (NULL ,"mips_malta.ram" , ram_size); + bios_offset =qemu_ram_alloc (NULL ,"mips_malta.bios" ,BIOS_SIZE );cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/mips_mipssim.c +2 -2
@@ -144,8 +144,8 @@ mips_mipssim_init (ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, reset_info);/* Allocate RAM. */ - ram_offset =qemu_ram_alloc (ram_size); - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + ram_offset =qemu_ram_alloc (NULL ,"mips_mipssim.ram" , ram_size); + bios_offset =qemu_ram_alloc (NULL ,"mips_mipssim.bios" ,BIOS_SIZE );cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/mips_r4k.c +3 -3
@@ -198,7 +198,7 @@ void mips_r4k_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20)));exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"mips_r4k.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
@@ -226,14 +226,14 @@ void mips_r4k_init (ram_addr_t ram_size, be =0 ;#endif if ((bios_size >0 ) && (bios_size <=BIOS_SIZE )) { - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"mips_r4k.bios" ,BIOS_SIZE );cpu_register_physical_memory (0x1fc00000 ,BIOS_SIZE , bios_offset |IO_MEM_ROM );load_image_targphys (filename,0x1fc00000 ,BIOS_SIZE ); } else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) { uint32_t mips_rom = 0x00400000; - bios_offset = qemu_ram_alloc(mips_rom); + bios_offset = qemu_ram_alloc(NULL, "mips_r4k.bios", mips_rom); if (!pflash_cfi01_register(0x1fc00000, bios_offset, dinfo->bdrv, sector_len, mips_rom / sector_len,
hw/musicpal.c +7 -4
@@ -1508,9 +1508,10 @@ static void musicpal_init(ram_addr_t ram_size,/* For now we use a fixed - the original - RAM size */ cpu_register_physical_memory (0 ,MP_RAM_DEFAULT_SIZE , -qemu_ram_alloc (MP_RAM_DEFAULT_SIZE )); +qemu_ram_alloc (NULL ,"musicpal.ram" , +MP_RAM_DEFAULT_SIZE )); - sram_off =qemu_ram_alloc (MP_SRAM_SIZE ); + sram_off =qemu_ram_alloc (NULL ,"musicpal.sram" ,MP_SRAM_SIZE );cpu_register_physical_memory (MP_SRAM_BASE ,MP_SRAM_SIZE , sram_off); dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
@@ -1557,14 +1558,16 @@ static void musicpal_init(ram_addr_t ram_size,* image is smaller than 32 MB. */ #ifdef TARGET_WORDS_BIGENDIAN -pflash_cfi02_register (0 -MP_FLASH_SIZE_MAX ,qemu_ram_alloc (flash_size), +pflash_cfi02_register (0 -MP_FLASH_SIZE_MAX ,qemu_ram_alloc (NULL , +"musicpal.flash" , flash_size), dinfo->bdrv,0x10000 , (flash_size +0xffff ) >>16 ,MP_FLASH_SIZE_MAX / flash_size,2 ,0x00BF ,0x236D ,0x0000 ,0x0000 ,0x5555 ,0x2AAA ,1 );#else - pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size), + pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(NULL, + "musicpal.flash", flash_size), dinfo->bdrv, 0x10000, (flash_size + 0xffff) >> 16, MP_FLASH_SIZE_MAX / flash_size,
hw/omap1.c +4 -2
@@ -4655,9 +4655,11 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,/* Memory-mapped stuff */ cpu_register_physical_memory (OMAP_EMIFF_BASE , s->sdram_size, - (emiff_base =qemu_ram_alloc (s->sdram_size)) |IO_MEM_RAM ); + (emiff_base =qemu_ram_alloc (NULL ,"omap1.dram" , + s->sdram_size)) |IO_MEM_RAM );cpu_register_physical_memory (OMAP_IMIF_BASE , s->sram_size, - (imif_base =qemu_ram_alloc (s->sram_size)) |IO_MEM_RAM ); + (imif_base =qemu_ram_alloc (NULL ,"omap1.sram" , + s->sram_size)) |IO_MEM_RAM );omap_clkm_init (0xfffece00 ,0xe1008000 , s);
hw/omap2.c +4 -2
@@ -4518,9 +4518,11 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,/* Memory-mapped stuff */ cpu_register_physical_memory (OMAP2_Q2_BASE , s->sdram_size, - (q2_base =qemu_ram_alloc (s->sdram_size)) |IO_MEM_RAM ); + (q2_base =qemu_ram_alloc (NULL ,"omap2.dram" , + s->sdram_size)) |IO_MEM_RAM );cpu_register_physical_memory (OMAP2_SRAM_BASE , s->sram_size, - (sram_base =qemu_ram_alloc (s->sram_size)) |IO_MEM_RAM ); + (sram_base =qemu_ram_alloc (NULL ,"omap2.sram" , + s->sram_size)) |IO_MEM_RAM ); s->l4 =omap_l4_init (OMAP2_L4_BASE ,54 );
hw/omap_sx1.c +8 -4
@@ -139,7 +139,8 @@ static void sx1_init(ram_addr_t ram_size,/* External Flash (EMIFS) */ cpu_register_physical_memory (OMAP_CS0_BASE , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"omap_sx1.flash0-0" , + flash_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs0val); cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
@@ -157,7 +158,8 @@ static void sx1_init(ram_addr_t ram_size,#endif if ((dinfo =drive_get (IF_PFLASH ,0 , fl_idx)) !=NULL ) { -if (!pflash_cfi01_register (OMAP_CS0_BASE ,qemu_ram_alloc (flash_size), +if (!pflash_cfi01_register (OMAP_CS0_BASE ,qemu_ram_alloc (NULL , +"omap_sx1.flash0-1" , flash_size), dinfo->bdrv, sector_size, flash_size / sector_size,4 ,0 ,0 ,0 ,0 , be)) {
@@ -170,12 +172,14 @@ static void sx1_init(ram_addr_t ram_size,if ((version ==1 ) && (dinfo =drive_get (IF_PFLASH ,0 , fl_idx)) !=NULL ) {cpu_register_physical_memory (OMAP_CS1_BASE , flash1_size, -qemu_ram_alloc (flash1_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"omap_sx1.flash1-0" , + flash1_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs1val);cpu_register_physical_memory (OMAP_CS1_BASE + flash1_size,OMAP_CS1_SIZE - flash1_size, io); -if (!pflash_cfi01_register (OMAP_CS1_BASE ,qemu_ram_alloc (flash1_size), +if (!pflash_cfi01_register (OMAP_CS1_BASE ,qemu_ram_alloc (NULL , +"omap_sx1.flash1-1" , flash1_size), dinfo->bdrv, sector_size, flash1_size / sector_size,4 ,0 ,0 ,0 ,0 , be)) {
hw/onenand.c +1 -1
@@ -638,7 +638,7 @@ void *onenand_init(uint32_t id, int regshift, qemu_irq irq) s->bdrv = dinfo->bdrv; s->otp =memset (qemu_malloc ((64 +2 ) <<PAGE_SHIFT ),0xff , (64 +2 ) <<PAGE_SHIFT ); - s->ram =qemu_ram_alloc (0xc000 << s->shift); + s->ram =qemu_ram_alloc (NULL ,"onenand.ram" ,0xc000 << s->shift); ram =qemu_get_ram_ptr (s->ram); s->boot[0 ] = ram + (0x0000 << s->shift); s->boot[1 ] = ram + (0x8000 << s->shift);
hw/palm.c +2 -1
@@ -213,7 +213,8 @@ static void palmte_init(ram_addr_t ram_size,/* External Flash (EMIFS) */ cpu_register_physical_memory (OMAP_CS0_BASE , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"palmte.flash" , + flash_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs0val); cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
hw/pc.c +4 -3
@@ -901,7 +901,8 @@ void pc_memory_init(ram_addr_t ram_size, linux_boot = (kernel_filename !=NULL );/* allocate RAM */ - ram_addr =qemu_ram_alloc (below_4g_mem_size + above_4g_mem_size); + ram_addr =qemu_ram_alloc (NULL ,"pc.ram" , + below_4g_mem_size + above_4g_mem_size);cpu_register_physical_memory (0 ,0xa0000 , ram_addr); cpu_register_physical_memory(0x100000, below_4g_mem_size - 0x100000,
@@ -924,7 +925,7 @@ void pc_memory_init(ram_addr_t ram_size, (bios_size % 65536) != 0) { goto bios_error; } - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"pc.bios" , bios_size); ret =rom_add_file_fixed (bios_name, (uint32_t )(-bios_size));if (ret !=0 ) { bios_error:
@@ -942,7 +943,7 @@ void pc_memory_init(ram_addr_t ram_size, isa_bios_size, (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM); - option_rom_offset =qemu_ram_alloc (PC_ROM_SIZE ); + option_rom_offset =qemu_ram_alloc (NULL ,"pc.rom" ,PC_ROM_SIZE );cpu_register_physical_memory (PC_ROM_MIN_VGA ,PC_ROM_SIZE , option_rom_offset);/* map all the bios at the top of memory */
hw/pci.c +6 -1
@@ -1713,6 +1713,7 @@ static int pci_add_option_rom(PCIDevice *pdev)int size;char *path;void *ptr; +char name[32 ];if (!pdev->romfile)return 0 ;
@@ -1748,7 +1749,11 @@ static int pci_add_option_rom(PCIDevice *pdev) size =1 <<qemu_fls (size); } - pdev->rom_offset =qemu_ram_alloc (size); +if (pdev->qdev.info->vmsd) +snprintf (name,sizeof (name),"%s.rom" , pdev->qdev.info->vmsd->name); +else +snprintf (name,sizeof (name),"%s.rom" , pdev->qdev.info->name); + pdev->rom_offset =qemu_ram_alloc (&pdev->qdev, name, size); ptr =qemu_get_ram_ptr (pdev->rom_offset);load_image (path, ptr);
hw/petalogix_s3adsp1800_mmu.c +4 -3
@@ -137,14 +137,15 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, env);/* Attach emulated BRAM through the LMB. */ - phys_lmb_bram =qemu_ram_alloc (LMB_BRAM_SIZE ); + phys_lmb_bram =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.lmb_bram" , +LMB_BRAM_SIZE );cpu_register_physical_memory (0x00000000 ,LMB_BRAM_SIZE , phys_lmb_bram |IO_MEM_RAM ); - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.ram" , ram_size);cpu_register_physical_memory (ddr_base, ram_size, phys_ram |IO_MEM_RAM ); - phys_flash =qemu_ram_alloc (FLASH_SIZE ); + phys_flash =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.flash" ,FLASH_SIZE ); dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash_cfi01_register(0xa0000000, phys_flash, dinfo ? dinfo->bdrv : NULL, (64 * 1024),
hw/ppc405_boards.c +9 -9
@@ -190,7 +190,7 @@ static void ref405ep_init (ram_addr_t ram_size,DriveInfo *dinfo;/* XXX: fix this */ - ram_bases[0 ] =qemu_ram_alloc (0x08000000 ); + ram_bases[0 ] =qemu_ram_alloc (NULL ,"ef405ep.ram" ,0x08000000 ); ram_sizes[0 ] =0x08000000 ; ram_bases[1 ] =0x00000000 ; ram_sizes[1 ] =0x00000000 ;
@@ -202,7 +202,7 @@ static void ref405ep_init (ram_addr_t ram_size, kernel_filename == NULL ? 0 : 1);/* allocate SRAM */ sram_size =512 *1024 ; - sram_offset =qemu_ram_alloc (sram_size); + sram_offset =qemu_ram_alloc (NULL ,"ef405ep.sram" , sram_size);#ifdef DEBUG_BOARD_INIT printf ("%s: register SRAM at offset %08lx\n" , __func__, sram_offset);#endif
@@ -217,7 +217,7 @@ static void ref405ep_init (ram_addr_t ram_size, dinfo =drive_get (IF_PFLASH ,0 , fl_idx);if (dinfo) { bios_size =bdrv_getlength (dinfo->bdrv); - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"ef405ep.bios" , bios_size); fl_sectors = (bios_size +65535 ) >>16 ;#ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx
@@ -236,7 +236,7 @@ static void ref405ep_init (ram_addr_t ram_size,#ifdef DEBUG_BOARD_INIT printf ("Load BIOS from file\n" );#endif - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ef405ep.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -509,9 +509,9 @@ static void taihu_405ep_init(ram_addr_t ram_size,DriveInfo *dinfo;/* RAM is soldered to the board so the size cannot be changed */ - ram_bases[0 ] =qemu_ram_alloc (0x04000000 ); + ram_bases[0 ] =qemu_ram_alloc (NULL ,"taihu_405ep.ram-0" ,0x04000000 ); ram_sizes[0 ] =0x04000000 ; - ram_bases[1 ] =qemu_ram_alloc (0x04000000 ); + ram_bases[1 ] =qemu_ram_alloc (NULL ,"taihu_405ep.ram-1" ,0x04000000 ); ram_sizes[1 ] =0x04000000 ; ram_size =0x08000000 ;#ifdef DEBUG_BOARD_INIT
@@ -531,7 +531,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,/* XXX: should check that size is 2MB */ // bios_size = 2 * 1024 * 1024; fl_sectors = (bios_size +65535 ) >>16 ; - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.bios" , bios_size);#ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx " at offset %08lx addr " TARGET_FMT_lx " '%s' %d\n",
@@ -551,7 +551,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,#endif if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.bios" ,BIOS_SIZE ); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);if (filename) { bios_size =load_image (filename,qemu_get_ram_ptr (bios_offset));
@@ -580,7 +580,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, fl_idx, bios_size, bios_offset, (target_ulong )0xfc000000 , bdrv_get_device_name(dinfo->bdrv));#endif - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.flash" , bios_size); pflash_cfi02_register(0xfc000000, bios_offset, dinfo->bdrv, 65536, fl_sectors, 1, 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
hw/ppc405_uc.c +1 -1
@@ -995,7 +995,7 @@ static void ppc405_ocm_init(CPUState *env)ppc405_ocm_t *ocm; ocm =qemu_mallocz (sizeof (ppc405_ocm_t)); - ocm->offset =qemu_ram_alloc (4096 ); + ocm->offset =qemu_ram_alloc (NULL ,"ppc405.ocm" ,4096 );qemu_register_reset (&ocm_reset, ocm);ppc_dcr_register (env,OCM0_ISARC , ocm, &dcr_read_ocm, &dcr_write_ocm);
hw/ppc4xx_devs.c +3 -1
@@ -668,7 +668,9 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,unsigned int bank_size = sdram_bank_sizes[j];if (bank_size <= size_left) { - ram_bases[i] =qemu_ram_alloc (bank_size); +char name[32 ]; +snprintf (name,sizeof (name),"ppc4xx.sdram%d" , i); + ram_bases[i] =qemu_ram_alloc (NULL , name, bank_size); ram_sizes[i] = bank_size; size_left -= bank_size;break ;
hw/ppc_newworld.c +3 -3
@@ -173,11 +173,11 @@ static void ppc_core99_init (ram_addr_t ram_size, }/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_core99.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_core99.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =PROM_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -198,7 +198,7 @@ static void ppc_core99_init (ram_addr_t ram_size, }/* allocate and load VGA BIOS */ - vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); + vga_bios_offset =qemu_ram_alloc (NULL ,"ppc_core99.vbios" ,VGA_BIOS_SIZE ); vga_bios_ptr =qemu_get_ram_ptr (vga_bios_offset); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,VGABIOS_FILENAME );if (filename) {
hw/ppc_oldworld.c +3 -3
@@ -179,11 +179,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size,exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =PROM_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -203,7 +203,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, }/* allocate and load VGA BIOS */ - vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); + vga_bios_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.vbios" ,VGA_BIOS_SIZE ); vga_bios_ptr =qemu_get_ram_ptr (vga_bios_offset); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,VGABIOS_FILENAME );if (filename) {
hw/ppc_prep.c +2 -2
@@ -604,11 +604,11 @@ static void ppc_prep_init (ram_addr_t ram_size, }/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_prep.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_prep.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
hw/ppce500_mpc8544ds.c +2 -1
@@ -189,7 +189,8 @@ static void mpc8544ds_init(ram_addr_t ram_size, ram_size &= ~(RAM_SIZES_ALIGN -1 );/* Register Memory */ -cpu_register_physical_memory (0 , ram_size,qemu_ram_alloc (ram_size)); +cpu_register_physical_memory (0 , ram_size,qemu_ram_alloc (NULL , +"mpc8544ds.ram" , ram_size));/* MPIC */ irqs =qemu_mallocz (sizeof (qemu_irq) *OPENPIC_OUTPUT_NB );
hw/pxa2xx.c +8 -4
@@ -2054,9 +2054,11 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)/* SDRAM & Internal Memory Storage */ cpu_register_physical_memory (PXA2XX_SDRAM_BASE , - sdram_size,qemu_ram_alloc (sdram_size) |IO_MEM_RAM ); + sdram_size,qemu_ram_alloc (NULL ,"pxa270.sdram" , + sdram_size) |IO_MEM_RAM );cpu_register_physical_memory (PXA2XX_INTERNAL_BASE , -0x40000 ,qemu_ram_alloc (0x40000 ) |IO_MEM_RAM ); +0x40000 ,qemu_ram_alloc (NULL ,"pxa270.internal" , +0x40000 ) |IO_MEM_RAM ); s->pic =pxa2xx_pic_init (0x40d00000 , s->env);
@@ -2175,9 +2177,11 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)/* SDRAM & Internal Memory Storage */ cpu_register_physical_memory (PXA2XX_SDRAM_BASE , sdram_size, -qemu_ram_alloc (sdram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"pxa255.sdram" , + sdram_size) |IO_MEM_RAM );cpu_register_physical_memory (PXA2XX_INTERNAL_BASE ,PXA2XX_INTERNAL_SIZE , -qemu_ram_alloc (PXA2XX_INTERNAL_SIZE ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"pxa255.internal" , +PXA2XX_INTERNAL_SIZE ) |IO_MEM_RAM ); s->pic =pxa2xx_pic_init (0x40d00000 , s->env);
hw/r2d.c +2 -2
@@ -242,7 +242,7 @@ static void r2d_init(ram_addr_t ram_size, }/* Allocate memory space */ - sdram_addr =qemu_ram_alloc (SDRAM_SIZE ); + sdram_addr =qemu_ram_alloc (NULL ,"r2d.sdram" ,SDRAM_SIZE );cpu_register_physical_memory (SDRAM_BASE ,SDRAM_SIZE , sdram_addr);/* Register peripherals */ s =sh7750_init (env);
@@ -257,7 +257,7 @@ static void r2d_init(ram_addr_t ram_size, dinfo, NULL);/* onboard flash memory */ - pflash_cfi02_register(0x0, qemu_ram_alloc(FLASH_SIZE), + pflash_cfi02_register(0x0, qemu_ram_alloc(NULL, "r2d.flash", FLASH_SIZE), dinfo ? dinfo->bdrv : NULL, (16 * 1024), FLASH_SIZE >> 16, 1, 4, 0x0000, 0x0000, 0x0000, 0x0000,
hw/realview.c +3 -3
@@ -196,12 +196,12 @@ static void realview_init(ram_addr_t ram_size,/* Core tile RAM. */ low_ram_size = ram_size -0x20000000 ; ram_size =0x20000000 ; - ram_offset =qemu_ram_alloc (low_ram_size); + ram_offset =qemu_ram_alloc (NULL ,"realview.lowmem" , low_ram_size);cpu_register_physical_memory (0x20000000 , low_ram_size, ram_offset |IO_MEM_RAM ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"realview.highmem" , ram_size); low_ram_size = ram_size;if (low_ram_size >0x10000000 ) low_ram_size =0x10000000 ;
@@ -354,7 +354,7 @@ static void realview_init(ram_addr_t ram_size,startup code. I guess this works on real hardware because the BootROM happens to be in ROM/flash or in memory that isn't clobbered until after Linux boots the secondary CPUs. */ - ram_offset =qemu_ram_alloc (0x1000 ); + ram_offset =qemu_ram_alloc (NULL ,"realview.hack" ,0x1000 );cpu_register_physical_memory (SMP_BOOT_ADDR ,0x1000 , ram_offset |IO_MEM_RAM );
hw/s390-virtio.c +1 -1
@@ -157,7 +157,7 @@ static void s390_init(ram_addr_t ram_size, s390_bus =s390_virtio_bus_init (&ram_size);/* allocate RAM */ - ram_addr =qemu_ram_alloc (ram_size); + ram_addr =qemu_ram_alloc (NULL ,"s390.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_addr);/* init CPUs */
hw/sm501.c +1 -1
@@ -1371,7 +1371,7 @@ void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq, s->dc_crt_control =0x00010000 ;/* allocate local memory */ - s->local_mem_offset =qemu_ram_alloc (local_mem_bytes); + s->local_mem_offset =qemu_ram_alloc (NULL ,"sm501.local" , local_mem_bytes); s->local_mem =qemu_get_ram_ptr (s->local_mem_offset);cpu_register_physical_memory (base, local_mem_bytes, s->local_mem_offset);
hw/spitz.c +1 -1
@@ -966,7 +966,7 @@ static void spitz_common_init(ram_addr_t ram_size,sl_flash_register (cpu, (model == spitz) ?FLASH_128M :FLASH_1024M );cpu_register_physical_memory (0 ,SPITZ_ROM , -qemu_ram_alloc (SPITZ_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"spitz.rom" ,SPITZ_ROM ) |IO_MEM_ROM );/* Setup peripherals */ spitz_keyboard_register (cpu);
hw/sun4m.c +4 -4
@@ -592,7 +592,7 @@ static int idreg_init1(SysBusDevice *dev) {ram_addr_t idreg_offset; - idreg_offset =qemu_ram_alloc (sizeof (idreg_data)); + idreg_offset =qemu_ram_alloc (NULL ,"sun4m.idreg" ,sizeof (idreg_data));sysbus_init_mmio (dev,sizeof (idreg_data), idreg_offset |IO_MEM_ROM );return 0 ; }
@@ -627,7 +627,7 @@ static int afx_init1(SysBusDevice *dev) {ram_addr_t afx_offset; - afx_offset =qemu_ram_alloc (4 ); + afx_offset =qemu_ram_alloc (NULL ,"sun4m.afx" ,4 );sysbus_init_mmio (dev,4 , afx_offset |IO_MEM_RAM );return 0 ; }
@@ -690,7 +690,7 @@ static int prom_init1(SysBusDevice *dev) {ram_addr_t prom_offset; - prom_offset =qemu_ram_alloc (PROM_SIZE_MAX ); + prom_offset =qemu_ram_alloc (NULL ,"sun4m.prom" ,PROM_SIZE_MAX );sysbus_init_mmio (dev,PROM_SIZE_MAX , prom_offset |IO_MEM_ROM );return 0 ; }
@@ -725,7 +725,7 @@ static int ram_init1(SysBusDevice *dev) RAM_size = d->size; - ram_offset =qemu_ram_alloc (RAM_size); + ram_offset =qemu_ram_alloc (NULL ,"sun4m.ram" , RAM_size);sysbus_init_mmio (dev, RAM_size, ram_offset);return 0 ; }
hw/sun4u.c +2 -2
@@ -629,7 +629,7 @@ static int prom_init1(SysBusDevice *dev) {ram_addr_t prom_offset; - prom_offset =qemu_ram_alloc (PROM_SIZE_MAX ); + prom_offset =qemu_ram_alloc (NULL ,"sun4u.prom" ,PROM_SIZE_MAX );sysbus_init_mmio (dev,PROM_SIZE_MAX , prom_offset |IO_MEM_ROM );return 0 ; }
@@ -665,7 +665,7 @@ static int ram_init1(SysBusDevice *dev) RAM_size = d->size; - ram_offset =qemu_ram_alloc (RAM_size); + ram_offset =qemu_ram_alloc (NULL ,"sun4u.ram" , RAM_size);sysbus_init_mmio (dev, RAM_size, ram_offset);return 0 ; }
hw/syborg.c +1 -1
@@ -51,7 +51,7 @@ static void syborg_init(ram_addr_t ram_size, }/* RAM at address zero. */ - ram_addr =qemu_ram_alloc (ram_size); + ram_addr =qemu_ram_alloc (NULL ,"syborg.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_addr |IO_MEM_RAM ); cpu_pic =arm_pic_init_cpu (env);
hw/tc6393xb.c +1 -1
@@ -593,7 +593,7 @@ TC6393xbState *tc6393xb_init(uint32_t base, qemu_irq irq) tc6393xb_writefn, s);cpu_register_physical_memory (base,0x10000 , iomemtype); - s->vram_addr =qemu_ram_alloc (0x100000 ); + s->vram_addr =qemu_ram_alloc (NULL ,"tc6393xb.vram" ,0x100000 ); s->vram_ptr =qemu_get_ram_ptr (s->vram_addr);cpu_register_physical_memory (base +0x100000 ,0x100000 , s->vram_addr); s->scr_width =480 ;
hw/tcx.c +1 -1
@@ -510,7 +510,7 @@ static int tcx_init1(SysBusDevice *dev)int size;uint8_t *vram_base; - vram_offset =qemu_ram_alloc (s->vram_size * (1 +4 +4 )); + vram_offset =qemu_ram_alloc (NULL ,"tcx.vram" , s->vram_size * (1 +4 +4 )); vram_base =qemu_get_ram_ptr (vram_offset); s->vram_offset = vram_offset;
hw/tosa.c +1 -1
@@ -215,7 +215,7 @@ static void tosa_init(ram_addr_t ram_size, cpu =pxa255_init (tosa_binfo.ram_size);cpu_register_physical_memory (0 ,TOSA_ROM , -qemu_ram_alloc (TOSA_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"tosa.rom" ,TOSA_ROM ) |IO_MEM_ROM ); tmio =tc6393xb_init (0x10000000 ,pxa2xx_gpio_in_get (cpu->gpio)[TOSA_GPIO_TC6393XB_INT ]);
hw/versatilepb.c +1 -1
@@ -180,7 +180,7 @@ static void versatile_init(ram_addr_t ram_size,fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"versatile.ram" , ram_size);/* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/vga.c +1 -1
@@ -2261,7 +2261,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)#else s->is_vbe_vmstate =0 ;#endif - s->vram_offset =qemu_ram_alloc (vga_ram_size); + s->vram_offset =qemu_ram_alloc (NULL ,"vga.vram" , vga_ram_size); s->vram_ptr =qemu_get_ram_ptr (s->vram_offset); s->vram_size = vga_ram_size; s->get_bpp = vga_get_bpp;
hw/vmware_vga.c +1 -1
@@ -1164,7 +1164,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) s->fifo_size =SVGA_FIFO_SIZE ; - s->fifo_offset =qemu_ram_alloc (s->fifo_size); + s->fifo_offset =qemu_ram_alloc (NULL ,"vmsvga.fifo" , s->fifo_size); s->fifo_ptr =qemu_get_ram_ptr (s->fifo_offset);vga_common_init (&s->vga, vga_ram_size);
PATCH v2 10/16 ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
In reply to Alex WilliamsonWith these two pieces in place, we can start naming ramblocks. When the device is present and it lives on a bus that provides a device path, we concatenate the path and the provided name. Otherwise we just use name. The resulting id string must be unique. For now we assume an allocation for the same name and size is a device that has been removed and reinserted and return the same block. This will go away once qemu_ram_free() is implemented.
---
cpu-all.h | 1 + exec.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
cpu-all.h +1 -0
@@ -865,6 +865,7 @@ typedef struct RAMBlock {uint8_t *host;ram_addr_t offset;ram_addr_t length; +char idstr[256 ];QLIST_ENTRY (RAMBlock) next; } RAMBlock;
exec.c +27 -2
@@ -36,6 +36,7 @@#include "qemu-common.h" #include "tcg.h" #include "hw/hw.h" +#include "hw/qdev.h" #include "osdep.h" #include "kvm.h" #include "qemu-timer.h"
@@ -2778,10 +2779,34 @@ static ram_addr_t find_ram_offset(ram_addr_t size)ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size) { -RAMBlock *new_block; +RAMBlock *new_block, *block; size =TARGET_PAGE_ALIGN (size); - new_block =qemu_malloc (sizeof (*new_block)); + new_block =qemu_mallocz (sizeof (*new_block)); + +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +snprintf (new_block->idstr,sizeof (new_block->idstr),"%s/" , id); +qemu_free (id); + } + } +pstrcat (new_block->idstr,sizeof (new_block->idstr), name); + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strcmp (block->idstr, new_block->idstr)) { +if (block->length == new_block->length) { +fprintf (stderr,"RAMBlock \"%s\" exists, assuming lack of" +"free.\n" , new_block->idstr); +qemu_free (new_block); +return block->offset; + }else { +fprintf (stderr,"RAMBlock \"%s\" already registered with" +"different size, abort\n" , new_block->idstr); +abort (); + } + } + }if (mem_path) {#if defined (__linux__) && !defined(TARGET_S390X )
PATCH v2 11/16 savevm: Migrate RAM based on name/offset
In reply to Alex WilliamsonSynchronize RAM blocks with the target and migrate using name/offset pairs. This ensures both source and target have the same view of RAM and that we get the right bits into the right slot.
---
arch_init.c | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- vl.c | 2 + 2 files changed, 108 insertions(+), 12 deletions(-)
arch_init.c +107 -11
@@ -113,20 +113,33 @@ static int ram_save_block(QEMUFile *f)while (addr < total_ram) {if (cpu_physical_memory_get_dirty (current_addr,MIGRATION_DIRTY_FLAG )) { +RAMBlock *block; +ram_addr_t offset;uint8_t *p;cpu_physical_memory_reset_dirty (current_addr, current_addr +TARGET_PAGE_SIZE ,MIGRATION_DIRTY_FLAG ); - p =qemu_get_ram_ptr (current_addr); + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (current_addr - block->offset < block->length) +break ; + } + offset = current_addr - block->offset; + p = block->host + offset;if (is_dup_page (p, *p)) { -qemu_put_be64 (f, current_addr |RAM_SAVE_FLAG_COMPRESS ); +qemu_put_be64 (f, offset |RAM_SAVE_FLAG_COMPRESS ); +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr));qemu_put_byte (f, *p); bytes_sent =1 ; }else { -qemu_put_be64 (f, current_addr |RAM_SAVE_FLAG_PAGE ); +qemu_put_be64 (f, offset |RAM_SAVE_FLAG_PAGE ); +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr));qemu_put_buffer (f, p,TARGET_PAGE_SIZE ); bytes_sent =TARGET_PAGE_SIZE ; }
@@ -196,6 +209,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) }if (stage ==1 ) { +RAMBlock *block;uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;
@@ -210,6 +224,12 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)cpu_physical_memory_set_dirty_tracking (1 );qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); + + QLIST_FOREACH(block, &ram_list.blocks, next) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr,strlen (block->idstr)); +qemu_put_be64 (f, block->length); + } } bytes_transferred_last = bytes_transferred;
@@ -257,7 +277,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)ram_addr_t addr;int flags; -if (version_id !=3 ) { +if (version_id <3 || version_id >4 ) {return -EINVAL ; }
@@ -268,23 +288,99 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) addr &=TARGET_PAGE_MASK ;if (flags &RAM_SAVE_FLAG_MEM_SIZE ) { -if (addr !=ram_bytes_total ()) { -return -EINVAL ; +if (version_id ==3 ) { +if (addr !=ram_bytes_total ()) { +return -EINVAL ; + } + }else { +/* Synchronize RAM block list */ +char id[256 ]; +ram_addr_t length; +ram_addr_t total_ram_bytes = addr; + +while (total_ram_bytes) { +RAMBlock *block; +uint8_t len; + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + length =qemu_get_be64 (f); + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) { +if (block->length != length) +return -EINVAL ; +break ; + } + } + +if (!block) { +if (!qemu_ram_alloc (NULL , id, length)) +return -ENOMEM ; + } + + total_ram_bytes -= length; + } } }if (flags &RAM_SAVE_FLAG_COMPRESS ) { -uint8_t ch =qemu_get_byte (f); -memset (qemu_get_ram_ptr (addr), ch,TARGET_PAGE_SIZE ); +void *host; +uint8_t ch; + +if (version_id ==3 ) { + host =qemu_get_ram_ptr (addr); + }else { +RAMBlock *block; +char id[256 ]; +uint8_t len; + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) +break ; + } +if (!block) +return -EINVAL ; + + host = block->host + addr; + } + ch =qemu_get_byte (f); +memset (host, ch,TARGET_PAGE_SIZE );#ifndef _WIN32if (ch ==0 && (!kvm_enabled () ||kvm_has_sync_mmu ())) { -madvise (qemu_get_ram_ptr (addr),TARGET_PAGE_SIZE , -MADV_DONTNEED ); +madvise (host,TARGET_PAGE_SIZE ,MADV_DONTNEED ); }#endif }else if (flags &RAM_SAVE_FLAG_PAGE ) { -qemu_get_buffer (f,qemu_get_ram_ptr (addr),TARGET_PAGE_SIZE ); +void *host; + +if (version_id ==3 ) { + host =qemu_get_ram_ptr (addr); + }else { +RAMBlock *block; +char id[256 ]; +uint8_t len; + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) +break ; + } +if (!block) +return -EINVAL ; + + host = block->host + addr; + } +qemu_get_buffer (f, host,TARGET_PAGE_SIZE ); }if (qemu_file_has_error (f)) {return -EIO ;
vl.c +1 -1
@@ -2794,7 +2794,7 @@ int main(int argc, char **argv, char **envp)if (qemu_opts_foreach (&qemu_drive_opts, drive_init_func, &machine->use_scsi,1 ) !=0 )exit (1 ); -register_savevm_live (NULL ,"ram" ,0 ,3 ,NULL , ram_save_live,NULL , +register_savevm_live (NULL ,"ram" ,0 ,4 ,NULL , ram_save_live,NULL , ram_load,NULL );if (nb_numa_nodes >0 ) {
PATCH v2 12/16 savevm: Use RAM blocks for basis of migration
In reply to Alex WilliamsonWe don't want to assume a contiguous address space, so migrate based on RAM blocks instead of a fixed linear address map. This will allow us to have holes in the ram_addr_t namespace, so we can implement qemu_ram_free().
---
arch_init.c | 67 +++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 42 insertions(+), 25 deletions(-)
arch_init.c +42 -25
@@ -105,27 +105,26 @@ static int is_dup_page(uint8_t *page, uint8_t ch)static int ram_save_block (QEMUFile *f) { -static ram_addr_t current_addr =0 ; -ram_addr_t saved_addr = current_addr; -ram_addr_t addr =0 ; -uint64_t total_ram =ram_bytes_total (); +static RAMBlock *last_block =NULL ; +static ram_addr_t last_offset =0 ; +RAMBlock *block = last_block; +ram_addr_t offset = last_offset; +ram_addr_t current_addr;int bytes_sent =0 ; -while (addr < total_ram) { +if (!block) + block =QLIST_FIRST (&ram_list.blocks); + + current_addr = block->offset + offset; + + do { if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) { -RAMBlock *block; -ram_addr_t offset; uint8_t *p; cpu_physical_memory_reset_dirty(current_addr, current_addr + TARGET_PAGE_SIZE, MIGRATION_DIRTY_FLAG); - QLIST_FOREACH(block, &ram_list.blocks, next) { -if (current_addr - block->offset < block->length) -break ; - } - offset = current_addr - block->offset; p = block->host + offset; if (is_dup_page(p, *p)) {
@@ -146,9 +145,21 @@ static int ram_save_block(QEMUFile *f)break ; } - addr +=TARGET_PAGE_SIZE ; - current_addr = (saved_addr + addr) % total_ram; - } + + offset +=TARGET_PAGE_SIZE ; +if (offset >= block->length) { + offset =0 ; + block =QLIST_NEXT (block, next); +if (!block) + block =QLIST_FIRST (&ram_list.blocks); + } + + current_addr = block->offset + offset; + + }while (current_addr != last_block->offset + last_offset); + + last_block = block; + last_offset = offset;return bytes_sent; }
@@ -157,13 +168,16 @@ static uint64_t bytes_transferred;static ram_addr_t ram_save_remaining (void ) { -ram_addr_t addr; +RAMBlock *block;ram_addr_t count =0 ; -uint64_t total_ram =ram_bytes_total (); -for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) { -if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { - count++; + QLIST_FOREACH(block, &ram_list.blocks, next) { +ram_addr_t addr; +for (addr = block->offset; addr < block->offset + block->length; + addr +=TARGET_PAGE_SIZE ) { +if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { + count++; + } } }
@@ -210,20 +224,23 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)if (stage ==1 ) {RAMBlock *block; -uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;/* Make sure all dirty bits are set */ -for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) { -if (!cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { -cpu_physical_memory_set_dirty (addr); + QLIST_FOREACH(block, &ram_list.blocks, next) { +for (addr = block->offset; addr < block->offset + block->length; + addr +=TARGET_PAGE_SIZE ) { +if (!cpu_physical_memory_get_dirty (addr, +MIGRATION_DIRTY_FLAG )) { +cpu_physical_memory_set_dirty (addr); + } } }/* Enable dirty memory tracking */ cpu_physical_memory_set_dirty_tracking (1 ); -qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); +qemu_put_be64 (f,ram_bytes_total () |RAM_SAVE_FLAG_MEM_SIZE ); QLIST_FOREACH(block, &ram_list.blocks, next) {qemu_put_byte (f,strlen (block->idstr));
PATCH v2 13/16 savevm: Create a new continue flag to avoid resending block name
In reply to Alex WilliamsonAllows us to compress the protocol a bit by setting a flag on the offset which indicates we're still working within the same block as last time. That way we can avoid sending the block name for every page. Suggested by Anthony Liguori.
---
arch_init.c | 94 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 50 insertions(+), 44 deletions(-)
arch_init.c +50 -44
@@ -87,6 +87,7 @@ const uint32_t arch_type = QEMU_ARCH;#define RAM_SAVE_FLAG_MEM_SIZE 0x04#define RAM_SAVE_FLAG_PAGE 0x08#define RAM_SAVE_FLAG_EOS 0x10 +#define RAM_SAVE_FLAG_CONTINUE 0x20static int is_dup_page (uint8_t *page,uint8_t ch) {
@@ -120,6 +121,7 @@ static int ram_save_block(QEMUFile *f) do { if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) { uint8_t *p; + int cont = (block == last_block) ? RAM_SAVE_FLAG_CONTINUE : 0; cpu_physical_memory_reset_dirty(current_addr, current_addr + TARGET_PAGE_SIZE,
@@ -128,17 +130,21 @@ static int ram_save_block(QEMUFile *f) p = block->host + offset;if (is_dup_page (p, *p)) { -qemu_put_be64 (f, offset |RAM_SAVE_FLAG_COMPRESS ); -qemu_put_byte (f,strlen (block->idstr)); -qemu_put_buffer (f, (uint8_t *)block->idstr, -strlen (block->idstr)); +qemu_put_be64 (f, offset | cont |RAM_SAVE_FLAG_COMPRESS ); +if (!cont) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr)); + }qemu_put_byte (f, *p); bytes_sent =1 ; }else { -qemu_put_be64 (f, offset |RAM_SAVE_FLAG_PAGE ); -qemu_put_byte (f,strlen (block->idstr)); -qemu_put_buffer (f, (uint8_t *)block->idstr, -strlen (block->idstr)); +qemu_put_be64 (f, offset | cont |RAM_SAVE_FLAG_PAGE ); +if (!cont) { +qemu_put_byte (f,strlen (block->idstr)); +qemu_put_buffer (f, (uint8_t *)block->idstr, +strlen (block->idstr)); + }qemu_put_buffer (f, p,TARGET_PAGE_SIZE ); bytes_sent =TARGET_PAGE_SIZE ; }
@@ -289,6 +295,36 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)return (stage ==2 ) && (expected_time <=migrate_max_downtime ()); } +static inline void *host_from_stream_offset (QEMUFile *f, +ram_addr_t offset, +int flags) +{ +static RAMBlock *block =NULL ; +char id[256 ]; +uint8_t len; + +if (flags &RAM_SAVE_FLAG_CONTINUE ) { +if (!block) { +fprintf (stderr,"Ack, bad migration stream!\n" ); +return NULL ; + } + +return block->host + offset; + } + + len =qemu_get_byte (f); +qemu_get_buffer (f, (uint8_t *)id, len); + id[len] =0 ; + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strncmp (id, block->idstr,sizeof (id))) +return block->host + offset; + } + +fprintf (stderr,"Can't find block %s!\n" , id); +return NULL ; +} +int ram_load (QEMUFile *f,void *opaque,int version_id) {ram_addr_t addr;
@@ -346,26 +382,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id)void *host;uint8_t ch; -if (version_id ==3 ) { +if (version_id ==3 ) host =qemu_get_ram_ptr (addr); - }else { -RAMBlock *block; -char id[256 ]; -uint8_t len; - - len =qemu_get_byte (f); -qemu_get_buffer (f, (uint8_t *)id, len); - id[len] =0 ; +else + host =host_from_stream_offset (f, addr, flags); - QLIST_FOREACH(block, &ram_list.blocks, next) { -if (!strncmp (id, block->idstr,sizeof (id))) -break ; - } -if (!block) -return -EINVAL ; - - host = block->host + addr; - } ch =qemu_get_byte (f);memset (host, ch,TARGET_PAGE_SIZE );#ifndef _WIN32
@@ -377,26 +398,11 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) }else if (flags &RAM_SAVE_FLAG_PAGE ) {void *host; -if (version_id ==3 ) { +if (version_id ==3 ) host =qemu_get_ram_ptr (addr); - }else { -RAMBlock *block; -char id[256 ]; -uint8_t len; +else + host =host_from_stream_offset (f, addr, flags); - len =qemu_get_byte (f); -qemu_get_buffer (f, (uint8_t *)id, len); - id[len] =0 ; - - QLIST_FOREACH(block, &ram_list.blocks, next) { -if (!strncmp (id, block->idstr,sizeof (id))) -break ; - } -if (!block) -return -EINVAL ; - - host = block->host + addr; - }qemu_get_buffer (f, host,TARGET_PAGE_SIZE ); }if (qemu_file_has_error (f)) {
PATCH v2 14/16 qemu_ram_free: Implement it
In reply to Alex WilliamsonNow that we can support a ram_addr_t space with holes, we can implement qemu_ram_free().
---
cpu-all.h | 3 +++ exec.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 8 deletions(-)
cpu-all.h +3 -0
@@ -867,6 +867,9 @@ typedef struct RAMBlock {ram_addr_t length;char idstr[256 ];QLIST_ENTRY (RAMBlock) next; +#if defined(__linux__) && !defined(TARGET_S390X ) +int fd; +#endif } RAMBlock; typedef struct RAMList {
exec.c +51 -8
91 lines not on this page · raw message
PATCH v2 15/16 pci: Free the space allocated for the option rom on removal
In reply to Alex Williamson---
hw/pci.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
hw/pci.c +11 -0
@@ -76,6 +76,7 @@ static struct BusInfo pci_bus_info = {static void pci_update_mappings (PCIDevice *d);static void pci_set_irq (void *opaque,int irq_num,int level);static int pci_add_option_rom (PCIDevice *pdev); +static void pci_del_option_rom (PCIDevice *pdev);static uint16_t pci_default_sub_vendor_id =PCI_SUBVENDOR_ID_REDHAT_QUMRANET ;static uint16_t pci_default_sub_device_id =PCI_SUBDEVICE_ID_QEMU ;
@@ -709,6 +710,7 @@ static int pci_unregister_device(DeviceState *dev)return ret;pci_unregister_io_regions (pci_dev); +pci_del_option_rom (pci_dev);do_pci_unregister_device (pci_dev);return 0 ; }
@@ -1765,6 +1767,15 @@ static int pci_add_option_rom(PCIDevice *pdev)return 0 ; } +static void pci_del_option_rom (PCIDevice *pdev) +{ +if (!pdev->rom_offset) +return ; + +qemu_ram_free (pdev->rom_offset); + pdev->rom_offset =0 ; +} +/* Reserve space and add capability to the linked list in pci config space */ int pci_add_capability_at_offset (PCIDevice *pdev,uint8_t cap_id,uint8_t offset,uint8_t size)
PATCH v2 16/16 ramblocks: No more being lazy about duplicate names
In reply to Alex WilliamsonNow that we have a working qemu_ram_free() and the primary runtime user of it has been updated, don't be lenient about duplicate id strings. We also shouldn't need to create them ondemand at the target.
---
arch_init.c | 5 +++-- exec.c | 13 +++---------- 2 files changed, 6 insertions(+), 12 deletions(-)
arch_init.c +3 -2
@@ -369,8 +369,9 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) }if (!block) { -if (!qemu_ram_alloc (NULL , id, length)) -return -ENOMEM ; +fprintf (stderr,"Unknown ramblock \"%s\", cannot " +"accept migration\n" , id); +return -EINVAL ; } total_ram_bytes -= length;
exec.c +3 -10
@@ -2813,16 +2813,9 @@ ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size) QLIST_FOREACH(block, &ram_list.blocks, next) {if (!strcmp (block->idstr, new_block->idstr)) { -if (block->length == new_block->length) { -fprintf (stderr,"RAMBlock \"%s\" exists, assuming lack of" -"free.\n" , new_block->idstr); -qemu_free (new_block); -return block->offset; - }else { -fprintf (stderr,"RAMBlock \"%s\" already registered with" -"different size, abort\n" , new_block->idstr); -abort (); - } +fprintf (stderr,"RAMBlock \"%s\" already registered, abort!\n" , + new_block->idstr); +abort (); } }
v3 cover Make migration work with hotplug
In reply to Alex Williamsonv3:
Still looking for comments...
changes:
- Rebase to latest upstream to pickup a few more callers
- Fix a bug in patch introducing qemu_ram_free(). Since we now try to place blocks into existing holes in the address space, the end of the current block isn't necessarily the top ram_addr_t for realloc'ing the dirty bitmap.
v2:
Not too many comments, hope that's because everyone agrees ;) A couple minor changes. The 2nd patch is new and provides a bit of an optimization for large memory pc guets. The first two patches stand on their own even if we're undecided about the rest. Thanks,
Alex
changes:
- Use pci_find_domain() for PCI domain, thanks Isaku
- Convert pc to allocate all ram in one chunk, which avoids penalizing large memory VMs bouncing between ramblocks during migration.
v1:
Ok, new approach. I'm going to attempt to extract myself for the canonical device path approach, because we're missing too many pieces to make that work. Instead, I'll take Anthony's advice and try to simplify. We still want a unique name for ramblocks and savevm, but the hotplug problem today is only for PCI devices. PCI conveniently has globally unique, dare I say canonical, addressing in the form of <domain>:<bus>:<device>.<func>. To get to this, let's add a new function on the BusInfo structure called get_dev_path(). For a PCI device, we can simply traverse up the qdev tree to the BusInfo structure, look for the function, and call it to return a global PCI address.
For some buses, these functions could chain up to their parent bus appending strings together to get a unique path. An example would be USB, where the USB port number may not be unique. If we traverse up to the PCI device providing USB, and then to the PCI bus, we get a globally unique PCI path, appended with a USB port number.
To make this work for ramblocks and savevm, we need a DeviceState pointer when the they are create/registered, and we need a caller provided context in case there are multiple ramblocks/savevm associated with a device. Savevm already provies the context, and I've attempted to make reasonable guesses at these for the ramblocks. Note that most of the ramblocks aren't associated with a device, so I don't think it makes sense to link savevm and ramblocks together with the same absolute id string.
Once we have savevm with unique id strings, rather than hotplug unfriendly instance numbers, we can be sure that the right driver instance is loading the correct vmstate. I've also implemented a compat field for this, so we can still accept incoming migrations from previous versions.
Once we have ramblocks with a unique id string, we can switch to using id + offset for migration, which enables a ram_addr_t space that supports gaps, which enables us to implement qemu_ram_free(). With that, I think we can finally do migrations reliable after hotplug! Note that the target VM still needs to be created to match the current devices and bus addresses of the source VM. We can also still maintain compatibility for migrations here by bumping the ram migration version and supporting both new and old (just hope the source hasn't done any hotplugs).
Sound reasonable? Is get_dev_path the right name? In the right place? The PCI return is currently "dddd:bb:dd.f", should this be "PCI:dddd:bb:dd.f"? Something else? Thanks,
Alex
---
Alex Williamson (16):
ramblocks: No more being lazy about duplicate names
pci: Free the space allocated for the option rom on removal
qemu_ram_free: Implement it
savevm: Create a new continue flag to avoid resending block name
savevm: Use RAM blocks for basis of migration
savevm: Migrate RAM based on name/offset
ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
qemu_ram_alloc: Add DeviceState and name parameters
virtio-net: Incorporate a DeviceState pointer and let savevm track instances
eepro100: Add a dev field to eeprom new/free functions
savevm: Make use of DeviceState
savevm: Add DeviceState param
pci: Implement BusInfo.get_dev_path()
qdev: Add a get_dev_path() function to BusInfo
pc: Allocate all ram in a single qemu_ram_alloc()
Remove uses of ram.last_offset (aka last_ram_offset)
arch_init.c | 183 +++++++++++++++++++++++++++++++++++------ audio/audio.c | 2 block-migration.c | 4 - cpu-all.h | 5 + cpu-common.h | 2 exec.c | 107 +++++++++++++++++++++--- hw/adb.c | 4 - hw/ads7846.c | 2 hw/an5206.c | 4 - hw/arm_gic.c | 2 hw/arm_timer.c | 4 - hw/armv7m.c | 9 +- hw/armv7m_nvic.c | 2 hw/axis_dev88.c | 4 - hw/cirrus_vga.c | 2 hw/cuda.c | 2 hw/dma.c | 4 - hw/dummy_m68k.c | 2 hw/eepro100.c | 8 +- hw/eeprom93xx.c | 8 +- hw/eeprom93xx.h | 4 - hw/etraxfs.c | 6 + hw/g364fb.c | 4 - hw/grackle_pci.c | 4 - hw/gt64xxx.c | 3 - hw/gumstix.c | 6 + hw/heathrow_pic.c | 2 hw/hw.h | 18 ++-- hw/i2c.c | 2 hw/i8254.c | 2 hw/i8259.c | 2 hw/ide/cmd646.c | 2 hw/ide/isa.c | 2 hw/ide/macio.c | 2 hw/ide/microdrive.c | 2 hw/ide/mmio.c | 2 hw/ide/piix.c | 2 hw/ide/via.c | 2 hw/integratorcp.c | 4 - hw/m48t59.c | 2 hw/mac_dbdma.c | 2 hw/mac_nvram.c | 4 - hw/mainstone.c | 6 + hw/max111x.c | 3 - hw/mcf5208.c | 4 - hw/mips_fulong2e.c | 6 + hw/mips_jazz.c | 4 - hw/mips_malta.c | 4 - hw/mips_mipssim.c | 4 - hw/mips_r4k.c | 6 + hw/mipsnet.c | 4 - hw/mst_fpga.c | 3 - hw/musicpal.c | 11 ++ hw/nand.c | 2 hw/omap1.c | 6 + hw/omap2.c | 6 + hw/omap_sx1.c | 12 ++- hw/onenand.c | 2 hw/openpic.c | 5 + hw/palm.c | 3 - hw/pc.c | 27 +++--- hw/pci.c | 34 +++++++- hw/pckbd.c | 2 hw/petalogix_s3adsp1800_mmu.c | 7 +- hw/piix4.c | 2 hw/pl011.c | 2 hw/pl022.c | 2 hw/pl061.c | 2 hw/ppc405_boards.c | 18 ++-- hw/ppc405_uc.c | 2 hw/ppc4xx_devs.c | 4 + hw/ppc4xx_pci.c | 4 - hw/ppc_newworld.c | 6 + hw/ppc_oldworld.c | 6 + hw/ppc_prep.c | 4 - hw/ppce500_mpc8544ds.c | 3 - hw/ppce500_pci.c | 4 - hw/ps2.c | 4 - hw/pxa2xx.c | 39 +++++---- hw/pxa2xx_dma.c | 2 hw/pxa2xx_gpio.c | 2 hw/pxa2xx_keypad.c | 2 hw/pxa2xx_lcd.c | 2 hw/pxa2xx_mmci.c | 2 hw/pxa2xx_pic.c | 3 - hw/pxa2xx_timer.c | 2 hw/qdev.c | 4 - hw/qdev.h | 3 + hw/r2d.c | 4 - hw/rc4030.c | 2 hw/realview.c | 6 + hw/s390-virtio.c | 2 hw/serial.c | 4 - hw/sm501.c | 2 hw/spitz.c | 11 +- hw/ssd0323.c | 3 - hw/ssi-sd.c | 2 hw/stellaris.c | 11 +- hw/stellaris_enet.c | 4 - hw/stellaris_input.c | 2 hw/sun4m.c | 8 +- hw/sun4u.c | 4 - hw/syborg.c | 2 hw/syborg_fb.c | 2 hw/syborg_interrupt.c | 3 - hw/syborg_keyboard.c | 2 hw/syborg_pointer.c | 2 hw/syborg_rtc.c | 3 - hw/syborg_serial.c | 2 hw/syborg_timer.c | 2 hw/tc6393xb.c | 2 hw/tcx.c | 2 hw/tosa.c | 2 hw/tsc2005.c | 2 hw/tsc210x.c | 4 - hw/unin_pci.c | 6 + hw/versatilepb.c | 2 hw/vga-isa-mm.c | 2 hw/vga-isa.c | 2 hw/vga.c | 2 hw/virtio-balloon.c | 3 - hw/virtio-blk.c | 2 hw/virtio-net.c | 7 +- hw/virtio-serial-bus.c | 2 hw/vmmouse.c | 2 hw/vmware_vga.c | 4 - hw/zaurus.c | 2 qemu-timer.c | 2 savevm.c | 106 +++++++++++++++++++++--- slirp/slirp.c | 5 + vl.c | 2 131 files changed, 670 insertions(+), 300 deletions(-)
PATCH v3 1/16 Remove uses of ram.last_offset (aka last_ram_offset)
We currently need this either to allocate the next ram_addr_t for a new block, or for total memory to be migrated. Both of which we can calculate without need of this to keep us in a contiguous address space.
---
arch_init.c | 23 ++++++++++++++++------- cpu-all.h | 1 - exec.c | 19 ++++++++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-)
arch_init.c +16 -7
@@ -108,9 +108,10 @@ static int ram_save_block(QEMUFile *f)static ram_addr_t current_addr =0 ;ram_addr_t saved_addr = current_addr;ram_addr_t addr =0 ; +uint64_t total_ram =ram_bytes_total ();int bytes_sent =0 ; -while (addr < ram_list.last_offset) { +while (addr < total_ram) {if (cpu_physical_memory_get_dirty (current_addr,MIGRATION_DIRTY_FLAG )) {uint8_t *p;
@@ -133,7 +134,7 @@ static int ram_save_block(QEMUFile *f)break ; } addr +=TARGET_PAGE_SIZE ; - current_addr = (saved_addr + addr) % ram_list.last_offset; + current_addr = (saved_addr + addr) % total_ram; }return bytes_sent;
@@ -145,8 +146,9 @@ static ram_addr_t ram_save_remaining(void) {ram_addr_t addr;ram_addr_t count =0 ; +uint64_t total_ram =ram_bytes_total (); -for (addr =0 ; addr < ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) {if (cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) { count++; }
@@ -167,7 +169,13 @@ uint64_t ram_bytes_transferred(void)uint64_t ram_bytes_total (void ) { -return ram_list.last_offset; +RAMBlock *block; +uint64_t total =0 ; + +QLIST_FOREACH (block, &ram_list.blocks, next) + total += block->length; + +return total; }int ram_save_live (Monitor *mon,QEMUFile *f,int stage,void *opaque)
@@ -188,10 +196,11 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) }if (stage ==1 ) { +uint64_t total_ram =ram_bytes_total (); bytes_transferred =0 ;/* Make sure all dirty bits are set */ -for (addr =0 ; addr < ram_list.last_offset; addr +=TARGET_PAGE_SIZE ) { +for (addr =0 ; addr < total_ram; addr +=TARGET_PAGE_SIZE ) {if (!cpu_physical_memory_get_dirty (addr,MIGRATION_DIRTY_FLAG )) {cpu_physical_memory_set_dirty (addr); }
@@ -200,7 +209,7 @@ int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque)/* Enable dirty memory tracking */ cpu_physical_memory_set_dirty_tracking (1 ); -qemu_put_be64 (f, ram_list.last_offset |RAM_SAVE_FLAG_MEM_SIZE ); +qemu_put_be64 (f, total_ram |RAM_SAVE_FLAG_MEM_SIZE ); } bytes_transferred_last = bytes_transferred;
@@ -259,7 +268,7 @@ int ram_load(QEMUFile *f, void *opaque, int version_id) addr &=TARGET_PAGE_MASK ;if (flags &RAM_SAVE_FLAG_MEM_SIZE ) { -if (addr != ram_list.last_offset) { +if (addr !=ram_bytes_total ()) {return -EINVAL ; } }
cpu-all.h +0 -1
@@ -870,7 +870,6 @@ typedef struct RAMBlock {typedef struct RAMList {uint8_t *phys_dirty; -ram_addr_t last_offset; QLIST_HEAD(ram, RAMBlock) blocks; }RAMList ;extern RAMList ram_list;
exec.c +14 -5
@@ -2767,6 +2767,17 @@ static void *file_ram_alloc(ram_addr_t memory, const char *path) }#endif +static ram_addr_t find_ram_offset (ram_addr_t size) +{ +RAMBlock *block; +ram_addr_t last =0 ; + +QLIST_FOREACH (block, &ram_list.blocks, next) + last = MAX(last, block->offset + block->length); + +return last; +} +ram_addr_t qemu_ram_alloc (ram_addr_t size) {RAMBlock *new_block;
@@ -2800,18 +2811,16 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)madvise (new_block->host, size,MADV_MERGEABLE );#endif } - new_block->offset = ram_list.last_offset; + new_block->offset =find_ram_offset (size); new_block->length = size;QLIST_INSERT_HEAD (&ram_list.blocks, new_block, next); ram_list.phys_dirty =qemu_realloc (ram_list.phys_dirty, - (ram_list.last_offset + size) >>TARGET_PAGE_BITS ); -memset (ram_list.phys_dirty + (ram_list.last_offset >>TARGET_PAGE_BITS ), + (new_block->offset + size) >>TARGET_PAGE_BITS ); +memset (ram_list.phys_dirty + (new_block->offset >>TARGET_PAGE_BITS ),0xff , size >>TARGET_PAGE_BITS ); - ram_list.last_offset += size; -if (kvm_enabled ())kvm_setup_guest_memory (new_block->host, size);
PATCH v3 2/16 pc: Allocate all ram in a single qemu_ram_alloc()
In reply to Alex WilliamsonThis will benefit us when we migrate based on ramblock name since we won't be bouncing between separate blocks.
---
hw/pc.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-)
hw/pc.c +9 -13
@@ -877,27 +877,23 @@ void pc_memory_init(ram_addr_t ram_size, *above_4g_mem_size_p = above_4g_mem_size; *below_4g_mem_size_p = below_4g_mem_size; +#if TARGET_PHYS_ADDR_BITS ==32 +if (above_4g_mem_size >0 ) { +hw_error ("To much RAM for 32-bit physical address" ); + } +#endif linux_boot = (kernel_filename !=NULL );/* allocate RAM */ - ram_addr =qemu_ram_alloc (below_4g_mem_size); + ram_addr =qemu_ram_alloc (below_4g_mem_size + above_4g_mem_size);cpu_register_physical_memory (0 ,0xa0000 , ram_addr);cpu_register_physical_memory (0x100000 , below_4g_mem_size -0x100000 , ram_addr +0x100000 ); - -/* above 4giga memory allocation */ -if (above_4g_mem_size >0 ) { -#if TARGET_PHYS_ADDR_BITS ==32 -hw_error ("To much RAM for 32-bit physical address" ); -#else - ram_addr =qemu_ram_alloc (above_4g_mem_size); -cpu_register_physical_memory (0x100000000ULL , - above_4g_mem_size, - ram_addr); +#if TARGET_PHYS_ADDR_BITS >32 +cpu_register_physical_memory (0x100000000ULL , above_4g_mem_size, + ram_addr + below_4g_mem_size);#endif - } -/* BIOS load */ if (bios_name ==NULL )
PATCH v3 3/16 qdev: Add a get_dev_path() function to BusInfo
In reply to Alex WilliamsonThis function is meant to provide a stable device path for buses which are able to implement it. If a bus has a globally unique addresses scheme, one address level may be sufficient to provide a path. Other buses may need to recursively traverse up the qdev tree.
---
hw/qdev.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
hw/qdev.h +3 -0
@@ -49,10 +49,13 @@ struct DeviceState { };typedef void (*bus_dev_printfn )(Monitor *mon,DeviceState *dev,int indent); +typedef char *(*bus_get_dev_path )(DeviceState *dev); +struct BusInfo {const char *name;size_t size;bus_dev_printfn print_dev; +bus_get_dev_path get_dev_path;Property *props; };
PATCH v3 4/16 pci: Implement BusInfo.get_dev_path()
In reply to Alex WilliamsonThis works great for PCI since a <segment>:<bus>:<dev>.<fn> uniquely describes a global address. No need to traverse up the qdev tree. PCI segment support is a placeholder for compatibility once we support multiple segments.
---
hw/pci.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-)
hw/pci.c +14 -0
@@ -58,11 +58,13 @@ struct PCIBus { };static void pcibus_dev_print (Monitor *mon,DeviceState *dev,int indent); +static char *pcibus_get_dev_path (DeviceState *dev);static struct BusInfo pci_bus_info = { .name ="PCI" , .size =sizeof (PCIBus), .print_dev = pcibus_dev_print, + .get_dev_path = pcibus_get_dev_path, .props = (Property []) {DEFINE_PROP_PCI_DEVFN ("addr" , PCIDevice, devfn,-1 ),DEFINE_PROP_STRING ("romfile" , PCIDevice, romfile),
@@ -1853,6 +1855,18 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent) } } +static char *pcibus_get_dev_path (DeviceState *dev) +{ +PCIDevice *d = (PCIDevice *)dev; +char path[16 ]; + +snprintf (path,sizeof (path),"%04x:%02x:%02x.%x" , +pci_find_domain (d->bus), d->config[PCI_SECONDARY_BUS ], +PCI_SLOT (d->devfn),PCI_FUNC (d->devfn)); + +return strdup (path); +} +static PCIDeviceInfo bridge_info = { .qdev.name ="pci-bridge" , .qdev.size =sizeof (PCIBridge),
PATCH v3 5/16 savevm: Add DeviceState param
In reply to Alex WilliamsonWhen available, we'd like to be able to access the DeviceState when registering a savevm. For buses with a get_dev_path() function, this will allow us to create more unique savevm id strings.
---
audio/audio.c | 2 +- block-migration.c | 4 ++-- exec.c | 4 ++-- hw/adb.c | 4 ++-- hw/ads7846.c | 2 +- hw/arm_gic.c | 2 +- hw/arm_timer.c | 4 ++-- hw/armv7m_nvic.c | 2 +- hw/cirrus_vga.c | 2 +- hw/cuda.c | 2 +- hw/dma.c | 4 ++-- hw/eepro100.c | 4 ++-- hw/eeprom93xx.c | 4 ++-- hw/g364fb.c | 2 +- hw/grackle_pci.c | 4 ++-- hw/gt64xxx.c | 3 ++- hw/heathrow_pic.c | 2 +- hw/hw.h | 18 +++++++++++------- hw/i2c.c | 2 +- hw/i8254.c | 2 +- hw/i8259.c | 2 +- hw/ide/cmd646.c | 2 +- hw/ide/isa.c | 2 +- hw/ide/macio.c | 2 +- hw/ide/microdrive.c | 2 +- hw/ide/mmio.c | 2 +- hw/ide/piix.c | 2 +- hw/ide/via.c | 2 +- hw/m48t59.c | 2 +- hw/mac_dbdma.c | 2 +- hw/mac_nvram.c | 4 ++-- hw/max111x.c | 3 ++- hw/mips_fulong2e.c | 2 +- hw/mipsnet.c | 4 ++-- hw/mst_fpga.c | 3 ++- hw/nand.c | 2 +- hw/openpic.c | 5 +++-- hw/pci.c | 2 +- hw/pckbd.c | 2 +- hw/piix4.c | 2 +- hw/pl011.c | 2 +- hw/pl022.c | 2 +- hw/pl061.c | 2 +- hw/ppc4xx_pci.c | 4 ++-- hw/ppce500_pci.c | 4 ++-- hw/ps2.c | 4 ++-- hw/pxa2xx.c | 27 +++++++++++++++------------ hw/pxa2xx_dma.c | 2 +- hw/pxa2xx_gpio.c | 2 +- hw/pxa2xx_keypad.c | 2 +- hw/pxa2xx_lcd.c | 2 +- hw/pxa2xx_mmci.c | 2 +- hw/pxa2xx_pic.c | 3 ++- hw/pxa2xx_timer.c | 2 +- hw/qdev.c | 4 ++-- hw/rc4030.c | 2 +- hw/serial.c | 4 ++-- hw/spitz.c | 9 +++++---- hw/ssd0323.c | 3 ++- hw/ssi-sd.c | 2 +- hw/stellaris.c | 11 ++++++----- hw/stellaris_enet.c | 4 ++-- hw/stellaris_input.c | 2 +- hw/syborg_fb.c | 2 +- hw/syborg_interrupt.c | 3 ++- hw/syborg_keyboard.c | 2 +- hw/syborg_pointer.c | 2 +- hw/syborg_rtc.c | 3 ++- hw/syborg_serial.c | 2 +- hw/syborg_timer.c | 2 +- hw/tsc2005.c | 2 +- hw/tsc210x.c | 4 ++-- hw/unin_pci.c | 6 ++++-- hw/vga-isa-mm.c | 2 +- hw/vga-isa.c | 2 +- hw/virtio-balloon.c | 3 ++- hw/virtio-blk.c | 2 +- hw/virtio-net.c | 4 ++-- hw/virtio-serial-bus.c | 2 +- hw/vmmouse.c | 2 +- hw/vmware_vga.c | 2 +- hw/zaurus.c | 2 +- qemu-timer.c | 2 +- savevm.c | 22 +++++++++++++--------- slirp/slirp.c | 5 +++-- vl.c | 2 +- 86 files changed, 164 insertions(+), 139 deletions(-)
audio/audio.c +1 -1
@@ -1901,7 +1901,7 @@ static void audio_init (void) }QLIST_INIT (&s->card_head); -vmstate_register (0 , &vmstate_audio, s); +vmstate_register (NULL ,0 , &vmstate_audio, s); }void AUD_register_card (const char *name,QEMUSoundCard *card)
block-migration.c +2 -2
@@ -638,6 +638,6 @@ void blk_mig_init(void)QSIMPLEQ_INIT (&block_mig_state.bmds_list);QSIMPLEQ_INIT (&block_mig_state.blk_list); -register_savevm_live ("block" ,0 ,1 , block_set_params, block_save_live, -NULL , block_load, &block_mig_state); +register_savevm_live (NULL ,"block" ,0 ,1 , block_set_params, + block_save_live,NULL , block_load, &block_mig_state); }
exec.c +2 -2
@@ -641,8 +641,8 @@ void cpu_exec_init(CPUState *env)cpu_list_unlock ();#endif #if defined(CPU_SAVE_VERSION ) && !defined(CONFIG_USER_ONLY ) -vmstate_register (cpu_index, &vmstate_cpu_common, env); -register_savevm ("cpu" , cpu_index,CPU_SAVE_VERSION , +vmstate_register (NULL , cpu_index, &vmstate_cpu_common, env); +register_savevm (NULL ,"cpu" , cpu_index,CPU_SAVE_VERSION , cpu_save, cpu_load, env);#endif }
hw/adb.c +2 -2
@@ -305,7 +305,7 @@ void adb_kbd_init(ADBBusState *bus) d =adb_register_device (bus,ADB_KEYBOARD , adb_kbd_request, adb_kbd_reset, s);qemu_add_kbd_event_handler (adb_kbd_put_keycode, d); -register_savevm ("adb_kbd" ,-1 ,1 , adb_kbd_save, +register_savevm (NULL ,"adb_kbd" ,-1 ,1 , adb_kbd_save, adb_kbd_load, s); }
@@ -475,6 +475,6 @@ void adb_mouse_init(ADBBusState *bus) d =adb_register_device (bus,ADB_MOUSE , adb_mouse_request, adb_mouse_reset, s);qemu_add_mouse_event_handler (adb_mouse_event, d,0 ,"QEMU ADB Mouse" ); -register_savevm ("adb_mouse" ,-1 ,1 , adb_mouse_save, +register_savevm (NULL ,"adb_mouse" ,-1 ,1 , adb_mouse_save, adb_mouse_load, s); }
hw/ads7846.c +1 -1
@@ -151,7 +151,7 @@ static int ads7846_init(SSISlave *dev)ads7846_int_update (s); -register_savevm ("ads7846" ,-1 ,0 , ads7846_save, ads7846_load, s); +register_savevm (NULL ,"ads7846" ,-1 ,0 , ads7846_save, ads7846_load, s);return 0 ; }
hw/arm_gic.c +1 -1
@@ -744,5 +744,5 @@ static void gic_init(gic_state *s) s->iomemtype =cpu_register_io_memory (gic_dist_readfn, gic_dist_writefn, s);gic_reset (s); -register_savevm ("arm_gic" ,-1 ,1 , gic_save, gic_load, s); +register_savevm (NULL ,"arm_gic" ,-1 ,1 , gic_save, gic_load, s); }
hw/arm_timer.c +2 -2
@@ -174,7 +174,7 @@ static arm_timer_state *arm_timer_init(uint32_t freq) bh =qemu_bh_new (arm_timer_tick, s); s->timer =ptimer_init (bh); -register_savevm ("arm_timer" ,-1 ,1 , arm_timer_save, arm_timer_load, s); +register_savevm (NULL ,"arm_timer" ,-1 ,1 , arm_timer_save, arm_timer_load, s);return s; }
@@ -271,7 +271,7 @@ static int sp804_init(SysBusDevice *dev) iomemtype =cpu_register_io_memory (sp804_readfn, sp804_writefn, s);sysbus_init_mmio (dev,0x1000 , iomemtype); -register_savevm ("sp804" ,-1 ,1 , sp804_save, sp804_load, s); +register_savevm (&dev->qdev,"sp804" ,-1 ,1 , sp804_save, sp804_load, s);return 0 ; }
hw/armv7m_nvic.c +1 -1
@@ -397,7 +397,7 @@ static int armv7m_nvic_init(SysBusDevice *dev)gic_init (&s->gic);cpu_register_physical_memory (0xe000e000 ,0x1000 , s->gic.iomemtype); s->systick.timer =qemu_new_timer (vm_clock, systick_timer_tick, s); -register_savevm ("armv7m_nvic" ,-1 ,1 , nvic_save, nvic_load, s); +register_savevm (&dev->qdev,"armv7m_nvic" ,-1 ,1 , nvic_save, nvic_load, s);return 0 ; }
hw/cirrus_vga.c +1 -1
@@ -3128,7 +3128,7 @@ void isa_cirrus_vga_init(void) s->vga.ds =graphic_console_init (s->vga.update, s->vga.invalidate, s->vga.screen_dump, s->vga.text_update, &s->vga); -vmstate_register (0 , &vmstate_cirrus_vga, s); +vmstate_register (NULL ,0 , &vmstate_cirrus_vga, s);rom_add_vga (VGABIOS_CIRRUS_FILENAME );/* XXX ISA-LFB support */ }
hw/cuda.c +1 -1
@@ -763,6 +763,6 @@ void cuda_init (int *cuda_mem_index, qemu_irq irq) s->adb_poll_timer =qemu_new_timer (vm_clock, cuda_adb_poll, s); *cuda_mem_index =cpu_register_io_memory (cuda_read, cuda_write, s); -register_savevm ("cuda" ,-1 ,1 , cuda_save, cuda_load, s); +register_savevm (NULL ,"cuda" ,-1 ,1 , cuda_save, cuda_load, s);qemu_register_reset (cuda_reset, s); }
hw/dma.c +2 -2
@@ -548,8 +548,8 @@ void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit) high_page_enable ? 0x480 : -1, cpu_request_exit);dma_init2 (&dma_controllers[1 ],0xc0 ,1 ,0x88 , high_page_enable ?0x488 :-1 , cpu_request_exit); -vmstate_register (0 , &vmstate_dma, &dma_controllers[0 ]); -vmstate_register (1 , &vmstate_dma, &dma_controllers[1 ]); +vmstate_register (NULL ,0 , &vmstate_dma, &dma_controllers[0 ]); +vmstate_register (NULL ,1 , &vmstate_dma, &dma_controllers[1 ]); dma_bh =qemu_bh_new (DMA_run_bh,NULL ); }
hw/eepro100.c +2 -2
@@ -1834,7 +1834,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev)EEPRO100State *s =DO_UPCAST (EEPRO100State, dev, pci_dev);cpu_unregister_io_memory (s->mmio_index); -vmstate_unregister (s->vmstate, s); +vmstate_unregister (&pci_dev->qdev, s->vmstate, s);eeprom93xx_free (s->eeprom);qemu_del_vlan_client (&s->nic->nc);return 0 ;
@@ -1893,7 +1893,7 @@ static int e100_nic_init(PCIDevice *pci_dev) s->vmstate =qemu_malloc (sizeof (vmstate_eepro100));memcpy (s->vmstate, &vmstate_eepro100,sizeof (vmstate_eepro100)); s->vmstate->name = s->nic->nc.model; -vmstate_register (-1 , s->vmstate, s); +vmstate_register (&pci_dev->qdev,-1 , s->vmstate, s);return 0 ; }
hw/eeprom93xx.c +2 -2
@@ -316,7 +316,7 @@ eeprom_t *eeprom93xx_new(uint16_t nwords)/* Output DO is tristate, read results in 1. */ eeprom->eedo =1 ;logout ("eeprom = 0x%p, nwords = %u\n" , eeprom, nwords); -vmstate_register (0 , &vmstate_eeprom, eeprom); +vmstate_register (NULL ,0 , &vmstate_eeprom, eeprom);return eeprom; }
@@ -324,7 +324,7 @@ void eeprom93xx_free(eeprom_t *eeprom) {/* Destroy EEPROM. */ logout ("eeprom = 0x%p\n" , eeprom); -vmstate_unregister (&vmstate_eeprom, eeprom); +vmstate_unregister (NULL , &vmstate_eeprom, eeprom);qemu_free (eeprom); }
hw/g364fb.c +1 -1
@@ -598,7 +598,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base, s->irq = irq;qemu_register_reset (g364fb_reset, s); -register_savevm ("g364fb" ,0 ,1 , g364fb_save, g364fb_load, s); +register_savevm (NULL ,"g364fb" ,0 ,1 , g364fb_save, g364fb_load, s);g364fb_reset (s); s->ds = graphic_console_init(g364fb_update_display,
hw/grackle_pci.c +2 -2
@@ -113,8 +113,8 @@ static int pci_grackle_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("grackle" ,0 ,1 , pci_grackle_save, pci_grackle_load, - &s->host_state); +register_savevm (&dev->qdev,"grackle" ,0 ,1 , pci_grackle_save, + pci_grackle_load, &s->host_state);qemu_register_reset (pci_grackle_reset, &s->host_state);return 0 ; }
hw/gt64xxx.c +2 -1
@@ -1146,7 +1146,8 @@ PCIBus *pci_gt64120_init(qemu_irq *pic)gt64120_reset (s); -register_savevm ("GT64120 PCI Bus" ,0 ,1 , gt64120_save, gt64120_load, d); +register_savevm (&d->qdev,"GT64120 PCI Bus" ,0 ,1 , + gt64120_save, gt64120_load, d);return s->pci->bus; }
hw/heathrow_pic.c +1 -1
@@ -224,7 +224,7 @@ qemu_irq *heathrow_pic_init(int *pmem_index, s->irqs = irqs[0 ]; *pmem_index =cpu_register_io_memory (pic_read, pic_write, s); -register_savevm ("heathrow_pic" ,-1 ,1 , heathrow_pic_save, +register_savevm (NULL ,"heathrow_pic" ,-1 ,1 , heathrow_pic_save, heathrow_pic_load, s);qemu_register_reset (heathrow_pic_reset, s);return qemu_allocate_irqs (heathrow_pic_set_irq, s,64 );
hw/hw.h +11 -7
@@ -245,14 +245,16 @@ typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage, void *opaque);typedef int LoadStateHandler (QEMUFile *f,void *opaque,int version_id); -int register_savevm (const char *idstr, +int register_savevm (DeviceState *dev, +const char *idstr,int instance_id,int version_id,SaveStateHandler *save_state,LoadStateHandler *load_state,void *opaque); -int register_savevm_live(const char *idstr, +int register_savevm_live(DeviceState *dev, + const char *idstr, int instance_id, int version_id, SaveSetParamsHandler *set_params,
@@ -261,7 +263,7 @@ int register_savevm_live(const char *idstr, LoadStateHandler *load_state, void *opaque); -void unregister_savevm (const char *idstr,void *opaque); +void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque);typedef void QEMUResetHandler (void *opaque);
@@ -765,11 +767,13 @@ extern int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, int version_id);extern void vmstate_save_state (QEMUFile *f,const VMStateDescription *vmsd,void *opaque); -extern int vmstate_register (int instance_id,const VMStateDescription *vmsd, -void *base); -extern int vmstate_register_with_alias_id (int instance_id, +extern int vmstate_register (DeviceState *dev,int instance_id, +const VMStateDescription *vmsd,void *base); +extern int vmstate_register_with_alias_id (DeviceState *dev, +int instance_id,const VMStateDescription *vmsd,void *base,int alias_id,int required_for_version); -void vmstate_unregister (const VMStateDescription *vmsd,void *opaque); +void vmstate_unregister (DeviceState *dev,const VMStateDescription *vmsd, +void *opaque);#endif
hw/i2c.c +1 -1
@@ -62,7 +62,7 @@ i2c_bus *i2c_init_bus(DeviceState *parent, const char *name)i2c_bus *bus; bus =FROM_QBUS (i2c_bus,qbus_create (&i2c_bus_info, parent, name)); -vmstate_register (-1 , &vmstate_i2c_bus, bus); +vmstate_register (NULL ,-1 , &vmstate_i2c_bus, bus);return bus; }
hw/i8254.c +1 -1
@@ -508,7 +508,7 @@ PITState *pit_init(int base, qemu_irq irq) s->irq_timer =qemu_new_timer (vm_clock, pit_irq_timer, s); s->irq = irq; -vmstate_register (base, &vmstate_pit, pit); +vmstate_register (NULL , base, &vmstate_pit, pit);qemu_register_reset (pit_reset, pit);register_ioport_write (base,4 ,1 , pit_ioport_write, pit);register_ioport_read (base,3 ,1 , pit_ioport_read, pit);
hw/i8259.c +1 -1
@@ -483,7 +483,7 @@ static void pic_init1(int io_addr, int elcr_addr, PicState *s)register_ioport_write (elcr_addr,1 ,1 , elcr_ioport_write, s);register_ioport_read (elcr_addr,1 ,1 , elcr_ioport_read, s); } -vmstate_register (io_addr, &vmstate_pic, s); +vmstate_register (NULL , io_addr, &vmstate_pic, s);qemu_register_reset (pic_reset, s); }
hw/ide/cmd646.c +1 -1
@@ -263,7 +263,7 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)ide_init2 (&d->bus[0 ], irq[0 ]);ide_init2 (&d->bus[1 ], irq[1 ]); -vmstate_register (0 , &vmstate_ide_pci, d); +vmstate_register (&dev->qdev,0 , &vmstate_ide_pci, d);qemu_register_reset (cmd646_reset, d);return 0 ; }
hw/ide/isa.c +1 -1
@@ -71,7 +71,7 @@ static int isa_ide_initfn(ISADevice *dev)ide_init_ioport (&s->bus, s->iobase, s->iobase2);isa_init_irq (dev, &s->irq, s->isairq);ide_init2 (&s->bus, s->irq); -vmstate_register (0 , &vmstate_ide_isa, s); +vmstate_register (&dev->qdev,0 , &vmstate_ide_isa, s);return 0 ; };
hw/ide/macio.c +1 -1
@@ -321,7 +321,7 @@ int pmac_ide_init (DriveInfo **hd_table, qemu_irq irq, pmac_ide_memory =cpu_register_io_memory (pmac_ide_read, pmac_ide_write, d); -vmstate_register (0 , &vmstate_pmac, d); +vmstate_register (NULL ,0 , &vmstate_pmac, d);qemu_register_reset (pmac_ide_reset, d);return pmac_ide_memory;
hw/ide/microdrive.c +1 -1
@@ -545,7 +545,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv) md->bus.ifs[0 ].mdata_size =METADATA_SIZE ; md->bus.ifs[0 ].mdata_storage = (uint8_t *)qemu_mallocz (METADATA_SIZE ); -vmstate_register (-1 , &vmstate_microdrive, md); +vmstate_register (NULL ,-1 , &vmstate_microdrive, md);return &md->card; }
hw/ide/mmio.c +1 -1
@@ -133,7 +133,7 @@ void mmio_ide_init (target_phys_addr_t membase, target_phys_addr_t membase2, mem2 =cpu_register_io_memory (mmio_ide_status, mmio_ide_cmd, s);cpu_register_physical_memory (membase,16 << shift, mem1);cpu_register_physical_memory (membase2,2 << shift, mem2); -vmstate_register (0 , &vmstate_ide_mmio, s); +vmstate_register (NULL ,0 , &vmstate_ide_mmio, s);qemu_register_reset (mmio_ide_reset, s); }
hw/ide/piix.c +1 -1
@@ -128,7 +128,7 @@ static int pci_piix_ide_initfn(PCIIDEState *d)pci_register_bar (&d->dev,4 ,0x10 ,PCI_BASE_ADDRESS_SPACE_IO , bmdma_map); -vmstate_register (0 , &vmstate_ide_pci, d); +vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d);ide_bus_new (&d->bus[0 ], &d->dev.qdev);ide_bus_new (&d->bus[1 ], &d->dev.qdev);
hw/ide/via.c +1 -1
@@ -157,7 +157,7 @@ static int vt82c686b_ide_initfn(PCIDevice *dev)pci_register_bar ((PCIDevice *)d,4 ,0x10 ,PCI_BASE_ADDRESS_SPACE_IO , bmdma_map); -vmstate_register (0 , &vmstate_ide_pci, d); +vmstate_register (&d->dev.qdev,0 , &vmstate_ide_pci, d);ide_bus_new (&d->bus[0 ], &d->dev.qdev);ide_bus_new (&d->bus[1 ], &d->dev.qdev);
hw/m48t59.c +1 -1
@@ -694,7 +694,7 @@ static void m48t59_init_common(M48t59State *s) }qemu_get_timedate (&s->alarm,0 ); -register_savevm ("m48t59" ,-1 ,1 , m48t59_save, m48t59_load, s); +register_savevm (NULL ,"m48t59" ,-1 ,1 , m48t59_save, m48t59_load, s); }static int m48t59_init_isa1 (ISADevice *dev)
hw/mac_dbdma.c +1 -1
@@ -845,7 +845,7 @@ void* DBDMA_init (int *dbdma_mem_index) s =qemu_mallocz (sizeof (DBDMA_channel) *DBDMA_CHANNELS ); *dbdma_mem_index =cpu_register_io_memory (dbdma_read, dbdma_write, s); -register_savevm ("dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s); +register_savevm (NULL ,"dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s);qemu_register_reset (dbdma_reset, s); dbdma_bh =qemu_bh_new (DBDMA_run_bh, s);
hw/mac_nvram.c +2 -2
@@ -140,8 +140,8 @@ MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size, s->mem_index =cpu_register_io_memory (nvram_read, nvram_write, s); *mem_index = s->mem_index; -register_savevm ("macio_nvram" ,-1 ,1 , macio_nvram_save, macio_nvram_load, - s); +register_savevm (NULL ,"macio_nvram" ,-1 ,1 , macio_nvram_save, + macio_nvram_load, s);qemu_register_reset (macio_nvram_reset, s);return s;
hw/max111x.c +2 -1
@@ -143,7 +143,8 @@ static int max111x_init(SSISlave *dev, int inputs) s->input[7 ] =0x80 ; s->com =0 ; -register_savevm ("max111x" ,-1 ,0 , max111x_save, max111x_load, s); +register_savevm (&dev->qdev,"max111x" ,-1 ,0 , + max111x_save, max111x_load, s);return 0 ; }
hw/mips_fulong2e.c +1 -1
@@ -282,7 +282,7 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,exit (1 ); } -register_savevm ("cpu" ,0 ,3 , cpu_save, cpu_load, env); +register_savevm (NULL ,"cpu" ,0 ,3 , cpu_save, cpu_load, env);qemu_register_reset (main_cpu_reset, env);/* fulong 2e has 256M ram. */
hw/mipsnet.c +2 -2
@@ -239,7 +239,7 @@ static void mipsnet_cleanup(VLANClientState *nc) {MIPSnetState *s =DO_UPCAST (NICState, nc, nc)->opaque; -unregister_savevm ("mipsnet" , s); +unregister_savevm (NULL ,"mipsnet" , s);isa_unassign_ioport (s->io_base,36 );
@@ -284,5 +284,5 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd) }mipsnet_reset (s); -register_savevm ("mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s); +register_savevm (NULL ,"mipsnet" ,0 ,0 , mipsnet_save, mipsnet_load, s); }
hw/mst_fpga.c +2 -1
@@ -234,6 +234,7 @@ qemu_irq *mst_irq_init(PXA2xxState *cpu, uint32_t base, int irq) iomemtype =cpu_register_io_memory (mst_fpga_readfn, mst_fpga_writefn, s);cpu_register_physical_memory (base,0x00100000 , iomemtype); -register_savevm ("mainstone_fpga" ,0 ,0 , mst_fpga_save, mst_fpga_load, s); +register_savevm (NULL ,"mainstone_fpga" ,0 ,0 , mst_fpga_save, + mst_fpga_load, s);return qi; }
hw/nand.c +1 -1
@@ -502,7 +502,7 @@ NANDFlashState *nand_init(int manf_id, int chip_id)is used. */ s->ioaddr = s->io; -register_savevm ("nand" ,-1 ,0 , nand_save, nand_load, s); +register_savevm (NULL ,"nand" ,-1 ,0 , nand_save, nand_load, s);return s; }
hw/openpic.c +3 -2
@@ -1234,7 +1234,8 @@ qemu_irq *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, opp->irq_out = irq_out; opp->need_swap =1 ; -register_savevm ("openpic" ,0 ,2 , openpic_save, openpic_load, opp); +register_savevm (&opp->pci_dev.qdev,"openpic" ,0 ,2 , + openpic_save, openpic_load, opp);qemu_register_reset (openpic_reset, opp); opp->irq_raise = openpic_irq_raise;
@@ -1692,7 +1693,7 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus, mpp->irq_raise = mpic_irq_raise; mpp->reset = mpic_reset; -register_savevm ("mpic" ,0 ,2 , openpic_save, openpic_load, mpp); +register_savevm (NULL ,"mpic" ,0 ,2 , openpic_save, openpic_load, mpp);qemu_register_reset (mpic_reset, mpp);return qemu_allocate_irqs (openpic_set_irq, mpp, mpp->max_irq);
hw/pci.c +1 -1
@@ -232,7 +232,7 @@ void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,QLIST_INIT (&bus->child);pci_host_bus_register (0 , bus);/* for now only pci domain 0 is supported */ -vmstate_register (-1 , &vmstate_pcibus, bus); +vmstate_register (NULL ,-1 , &vmstate_pcibus, bus);qemu_register_reset (pci_bus_reset, bus); }
hw/pckbd.c +1 -1
@@ -418,7 +418,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, s->irq_mouse = mouse_irq; s->mask = mask; -vmstate_register (0 , &vmstate_kbd, s); +vmstate_register (NULL ,0 , &vmstate_kbd, s); s_io_memory =cpu_register_io_memory (kbd_mm_read, kbd_mm_write, s);cpu_register_physical_memory (base, size, s_io_memory);
hw/piix4.c +1 -1
@@ -87,7 +87,7 @@ static int piix4_initfn(PCIDevice *d)uint8_t *pci_conf;isa_bus_new (&d->qdev); -register_savevm ("PIIX4" ,0 ,2 , piix_save, piix_load, d); +register_savevm (&d->qdev,"PIIX4" ,0 ,2 , piix_save, piix_load, d); pci_conf = d->config;pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_INTEL );
hw/pl011.c +1 -1
@@ -306,7 +306,7 @@ static int pl011_init(SysBusDevice *dev, const unsigned char *id)qemu_chr_add_handlers (s->chr, pl011_can_receive, pl011_receive, pl011_event, s); } -register_savevm ("pl011_uart" ,-1 ,1 , pl011_save, pl011_load, s); +register_savevm (&dev->qdev,"pl011_uart" ,-1 ,1 , pl011_save, pl011_load, s);return 0 ; }
hw/pl022.c +1 -1
@@ -299,7 +299,7 @@ static int pl022_init(SysBusDevice *dev)sysbus_init_irq (dev, &s->irq); s->ssi =ssi_create_bus (&dev->qdev,"ssi" );pl022_reset (s); -register_savevm ("pl022_ssp" ,-1 ,1 , pl022_save, pl022_load, s); +register_savevm (&dev->qdev,"pl022_ssp" ,-1 ,1 , pl022_save, pl022_load, s);return 0 ; }
hw/pl061.c +1 -1
@@ -303,7 +303,7 @@ static int pl061_init(SysBusDevice *dev)qdev_init_gpio_in (&dev->qdev, pl061_set_irq,8 );qdev_init_gpio_out (&dev->qdev, s->out,8 );pl061_reset (s); -register_savevm ("pl061_gpio" ,-1 ,1 , pl061_save, pl061_load, s); +register_savevm (&dev->qdev,"pl061_gpio" ,-1 ,1 , pl061_save, pl061_load, s);return 0 ; }
hw/ppc4xx_pci.c +2 -2
@@ -392,8 +392,8 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],qemu_register_reset (ppc4xx_pci_reset, controller);/* XXX load/save code not tested. */ -register_savevm ("ppc4xx_pci" , ppc4xx_pci_id++,1 , - ppc4xx_pci_save, ppc4xx_pci_load, controller); +register_savevm (&controller->pci_dev->qdev,"ppc4xx_pci" , ppc4xx_pci_id++, +1 , ppc4xx_pci_save, ppc4xx_pci_load, controller);return controller->pci_state.bus;
hw/ppce500_pci.c +2 -2
@@ -310,8 +310,8 @@ PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers) PCIE500_REG_SIZE, index);/* XXX load/save code not tested. */ -register_savevm ("ppce500_pci" , ppce500_pci_id++,1 , - ppce500_pci_save, ppce500_pci_load, controller); +register_savevm (&d->qdev,"ppce500_pci" , ppce500_pci_id++, +1 , ppce500_pci_save, ppce500_pci_load, controller);return controller->pci_state.bus;
hw/ps2.c +2 -2
@@ -595,7 +595,7 @@ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg) s->common.update_irq = update_irq; s->common.update_arg = update_arg; s->scancode_set =2 ; -vmstate_register (0 , &vmstate_ps2_keyboard, s); +vmstate_register (NULL ,0 , &vmstate_ps2_keyboard, s);qemu_add_kbd_event_handler (ps2_put_keycode, s);qemu_register_reset (ps2_kbd_reset, s);return s;
@@ -607,7 +607,7 @@ void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg) s->common.update_irq = update_irq; s->common.update_arg = update_arg; -vmstate_register (0 , &vmstate_ps2_mouse, s); +vmstate_register (NULL ,0 , &vmstate_ps2_mouse, s);qemu_add_mouse_event_handler (ps2_mouse_event, s,0 ,"QEMU PS/2 Mouse" );qemu_register_reset (ps2_mouse_reset, s);return s;
hw/pxa2xx.c +15 -12
@@ -860,7 +860,7 @@ static int pxa2xx_ssp_init(SysBusDevice *dev) iomemtype =cpu_register_io_memory (pxa2xx_ssp_readfn, pxa2xx_ssp_writefn, s);sysbus_init_mmio (dev,0x1000 , iomemtype); -register_savevm ("pxa2xx_ssp" ,-1 ,0 , +register_savevm (&dev->qdev,"pxa2xx_ssp" ,-1 ,0 , pxa2xx_ssp_save, pxa2xx_ssp_load, s); s->bus =ssi_create_bus (&dev->qdev,"ssi" );
@@ -1515,7 +1515,7 @@ PXA2xxI2CState *pxa2xx_i2c_init(target_phys_addr_t base,cpu_register_physical_memory (base & ~region_size, region_size +1 , iomemtype); -vmstate_register (base, &vmstate_pxa2xx_i2c, s); +vmstate_register (NULL , base, &vmstate_pxa2xx_i2c, s);return s; }
@@ -1751,7 +1751,7 @@ static PXA2xxI2SState *pxa2xx_i2s_init(target_phys_addr_t base, pxa2xx_i2s_writefn, s);cpu_register_physical_memory (base,0x100000 , iomemtype); -register_savevm ("pxa2xx_i2s" , base,0 , +register_savevm (NULL ,"pxa2xx_i2s" , base,0 , pxa2xx_i2s_save, pxa2xx_i2s_load, s);return s;
@@ -2014,7 +2014,8 @@ static PXA2xxFIrState *pxa2xx_fir_init(target_phys_addr_t base,qemu_chr_add_handlers (chr, pxa2xx_fir_is_empty, pxa2xx_fir_rx, pxa2xx_fir_event, s); -register_savevm ("pxa2xx_fir" ,0 ,0 , pxa2xx_fir_save, pxa2xx_fir_load, s); +register_savevm (NULL ,"pxa2xx_fir" ,0 ,0 , pxa2xx_fir_save, + pxa2xx_fir_load, s);return s; }
@@ -2099,7 +2100,7 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s);cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
@@ -2110,13 +2111,13 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s);cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); s->pm_base =0x40f00000 ; iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s);cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm ("pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s);for (i =0 ; pxa27x_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
@@ -2140,7 +2141,8 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision) pxa2xx_rtc_writefn, s);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm ("pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, pxa2xx_rtc_load, s); +register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, + pxa2xx_rtc_load, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
@@ -2219,7 +2221,7 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_cm_readfn, pxa2xx_cm_writefn, s);cpu_register_physical_memory (s->cm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s); +register_savevm (NULL ,"pxa2xx_cm" ,0 ,0 , pxa2xx_cm_save, pxa2xx_cm_load, s);cpu_arm_set_cp_io (s->env,14 , pxa2xx_cp14_read, pxa2xx_cp14_write, s);
@@ -2230,13 +2232,13 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) iomemtype =cpu_register_io_memory (pxa2xx_mm_readfn, pxa2xx_mm_writefn, s);cpu_register_physical_memory (s->mm_base,0x1000 , iomemtype); -register_savevm ("pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); +register_savevm (NULL ,"pxa2xx_mm" ,0 ,0 , pxa2xx_mm_save, pxa2xx_mm_load, s); s->pm_base =0x40f00000 ; iomemtype =cpu_register_io_memory (pxa2xx_pm_readfn, pxa2xx_pm_writefn, s);cpu_register_physical_memory (s->pm_base,0x100 , iomemtype); -register_savevm ("pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s); +register_savevm (NULL ,"pxa2xx_pm" ,0 ,0 , pxa2xx_pm_save, pxa2xx_pm_load, s);for (i =0 ; pxa255_ssp[i].io_base; i ++); s->ssp = (SSIBus **)qemu_mallocz (sizeof (SSIBus *) * i);
@@ -2260,7 +2262,8 @@ PXA2xxState *pxa255_init(unsigned int sdram_size) pxa2xx_rtc_writefn, s);cpu_register_physical_memory (s->rtc_base,0x1000 , iomemtype);pxa2xx_rtc_init (s); -register_savevm ("pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, pxa2xx_rtc_load, s); +register_savevm (NULL ,"pxa2xx_rtc" ,0 ,0 , pxa2xx_rtc_save, + pxa2xx_rtc_load, s); s->i2c[0 ] =pxa2xx_i2c_init (0x40301600 , s->pic[PXA2XX_PIC_I2C ],0xffff ); s->i2c[1 ] =pxa2xx_i2c_init (0x40f00100 , s->pic[PXA2XX_PIC_PWRI2C ],0xff );
hw/pxa2xx_dma.c +1 -1
@@ -507,7 +507,7 @@ static PXA2xxDMAState *pxa2xx_dma_init(target_phys_addr_t base, pxa2xx_dma_writefn, s);cpu_register_physical_memory (base,0x00010000 , iomemtype); -register_savevm ("pxa2xx_dma" ,0 ,0 , pxa2xx_dma_save, pxa2xx_dma_load, s); +register_savevm (NULL ,"pxa2xx_dma" ,0 ,0 , pxa2xx_dma_save, pxa2xx_dma_load, s);return s; }
hw/pxa2xx_gpio.c +1 -1
@@ -312,7 +312,7 @@ PXA2xxGPIOInfo *pxa2xx_gpio_init(target_phys_addr_t base, pxa2xx_gpio_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype); -register_savevm ("pxa2xx_gpio" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_gpio" ,0 ,0 , pxa2xx_gpio_save, pxa2xx_gpio_load, s);return s;
hw/pxa2xx_keypad.c +1 -1
@@ -317,7 +317,7 @@ PXA2xxKeyPadState *pxa27x_keypad_init(target_phys_addr_t base, pxa2xx_keypad_writefn, s);cpu_register_physical_memory (base,0x00100000 , iomemtype); -register_savevm ("pxa2xx_keypad" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_keypad" ,0 ,0 , pxa2xx_keypad_save, pxa2xx_keypad_load, s);return s;
hw/pxa2xx_lcd.c +1 -1
@@ -970,7 +970,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(target_phys_addr_t base, qemu_irq irq)exit (1 ); } -register_savevm ("pxa2xx_lcdc" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_lcdc" ,0 ,0 , pxa2xx_lcdc_save, pxa2xx_lcdc_load, s);return s;
hw/pxa2xx_mmci.c +1 -1
@@ -534,7 +534,7 @@ PXA2xxMMCIState *pxa2xx_mmci_init(target_phys_addr_t base,/* Instantiate the actual storage */ s->card =sd_init (bd,0 ); -register_savevm ("pxa2xx_mmci" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_mmci" ,0 ,0 , pxa2xx_mmci_save, pxa2xx_mmci_load, s);return s;
hw/pxa2xx_pic.c +2 -1
@@ -306,7 +306,8 @@ qemu_irq *pxa2xx_pic_init(target_phys_addr_t base, CPUState *env)/* Enable IC coprocessor access. */ cpu_arm_set_cp_io (env,6 , pxa2xx_pic_cp_read, pxa2xx_pic_cp_write, s); -register_savevm ("pxa2xx_pic" ,0 ,0 , pxa2xx_pic_save, pxa2xx_pic_load, s); +register_savevm (NULL ,"pxa2xx_pic" ,0 ,0 , pxa2xx_pic_save, + pxa2xx_pic_load, s);return qi; }
hw/pxa2xx_timer.c +1 -1
@@ -455,7 +455,7 @@ static pxa2xx_timer_info *pxa2xx_timer_init(target_phys_addr_t base, pxa2xx_timer_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype); -register_savevm ("pxa2xx_timer" ,0 ,0 , +register_savevm (NULL ,"pxa2xx_timer" ,0 ,0 , pxa2xx_timer_save, pxa2xx_timer_load, s);return s;
hw/qdev.c +2 -2
@@ -280,7 +280,7 @@ int qdev_init(DeviceState *dev) }qemu_register_reset (qdev_reset, dev);if (dev->info->vmsd) { -vmstate_register_with_alias_id (-1 , dev->info->vmsd, dev, +vmstate_register_with_alias_id (dev,-1 , dev->info->vmsd, dev, dev->instance_id_alias, dev->alias_required_for_version); }
@@ -342,7 +342,7 @@ void qdev_free(DeviceState *dev)qbus_free (bus); }if (dev->info->vmsd) -vmstate_unregister (dev->info->vmsd, dev); +vmstate_unregister (dev, dev->info->vmsd, dev);if (dev->info->exit) dev->info->exit (dev);if (dev->opts)
hw/rc4030.c +1 -1
@@ -813,7 +813,7 @@ void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus, s->jazz_bus_irq = jazz_bus;qemu_register_reset (rc4030_reset, s); -register_savevm ("rc4030" ,0 ,2 , rc4030_save, rc4030_load, s); +register_savevm (NULL ,"rc4030" ,0 ,2 , rc4030_save, rc4030_load, s);rc4030_reset (s); s_chipset =cpu_register_io_memory (rc4030_read, rc4030_write, s);
hw/serial.c +2 -2
@@ -813,7 +813,7 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, s->chr = chr;serial_init_core (s); -vmstate_register (base, &vmstate_serial, s); +vmstate_register (NULL , base, &vmstate_serial, s);register_ioport_write (base,8 ,1 , serial_ioport_write, s);register_ioport_read (base,8 ,1 , serial_ioport_read, s);
@@ -948,7 +948,7 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift, s->chr = chr;serial_init_core (s); -vmstate_register (base, &vmstate_serial, s); +vmstate_register (NULL , base, &vmstate_serial, s);if (ioregister) {if (be) {
hw/spitz.c +5 -4
@@ -178,7 +178,7 @@ static void sl_flash_register(PXA2xxState *cpu, int size) sl_writefn, s);cpu_register_physical_memory (FLASH_BASE ,0x40 , iomemtype); -register_savevm ("sl_flash" ,0 ,0 , sl_save, sl_load, s); +register_savevm (NULL ,"sl_flash" ,0 ,0 , sl_save, sl_load, s); }/* Spitz Keyboard */
@@ -508,7 +508,7 @@ static void spitz_keyboard_register(PXA2xxState *cpu)spitz_keyboard_pre_map (s);qemu_add_kbd_event_handler ((QEMUPutKBDEvent *) spitz_keyboard_handler, s); -register_savevm ("spitz_keyboard" ,0 ,0 , +register_savevm (NULL ,"spitz_keyboard" ,0 ,0 , spitz_keyboard_save, spitz_keyboard_load, s); }
@@ -613,7 +613,7 @@ static int spitz_lcdtg_init(SSISlave *dev) s->bl_power =0 ; s->bl_intensity =0x20 ; -register_savevm ("spitz-lcdtg" ,-1 ,1 , +register_savevm (&dev->qdev,"spitz-lcdtg" ,-1 ,1 , spitz_lcdtg_save, spitz_lcdtg_load, s);return 0 ; }
@@ -708,7 +708,8 @@ static int corgi_ssp_init(SSISlave *dev) s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" ); s->bus[2 ] =ssi_create_bus (&dev->qdev,"ssi2" ); -register_savevm ("spitz_ssp" ,-1 ,1 , spitz_ssp_save, spitz_ssp_load, s); +register_savevm (&dev->qdev,"spitz_ssp" ,-1 ,1 , + spitz_ssp_save, spitz_ssp_load, s);return 0 ; }
hw/ssd0323.c +2 -1
@@ -335,7 +335,8 @@ static int ssd0323_init(SSISlave *dev)qdev_init_gpio_in (&dev->qdev, ssd0323_cd,1 ); -register_savevm ("ssd0323_oled" ,-1 ,1 , ssd0323_save, ssd0323_load, s); +register_savevm (&dev->qdev,"ssd0323_oled" ,-1 ,1 , + ssd0323_save, ssd0323_load, s);return 0 ; }
hw/ssi-sd.c +1 -1
@@ -236,7 +236,7 @@ static int ssi_sd_init(SSISlave *dev) s->mode =SSI_SD_CMD ; bs =qdev_init_bdrv (&dev->qdev,IF_SD ); s->sd =sd_init (bs,1 ); -register_savevm ("ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s); +register_savevm (&dev->qdev,"ssi_sd" ,-1 ,1 , ssi_sd_save, ssi_sd_load, s);return 0 ; }
hw/stellaris.c +6 -5
@@ -354,7 +354,8 @@ static int stellaris_gptm_init(SysBusDevice *dev) s->opaque[0 ] = s->opaque[1 ] = s; s->timer[0 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[0 ]); s->timer[1 ] =qemu_new_timer (vm_clock, gptm_tick, &s->opaque[1 ]); -register_savevm ("stellaris_gptm" ,-1 ,1 , gptm_save, gptm_load, s); +register_savevm (&dev->qdev,"stellaris_gptm" ,-1 ,1 , + gptm_save, gptm_load, s);return 0 ; }
@@ -673,7 +674,7 @@ static int stellaris_sys_init(uint32_t base, qemu_irq irq, ssys_writefn, s);cpu_register_physical_memory (base,0x00001000 , iomemtype);ssys_reset (s); -register_savevm ("stellaris_sys" ,-1 ,1 , ssys_save, ssys_load, s); +register_savevm (NULL ,"stellaris_sys" ,-1 ,1 , ssys_save, ssys_load, s);return 0 ; }
@@ -887,7 +888,7 @@ static int stellaris_i2c_init(SysBusDevice * dev)sysbus_init_mmio (dev,0x1000 , iomemtype);/* ??? For now we only implement the master interface. */ stellaris_i2c_reset (s); -register_savevm ("stellaris_i2c" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_i2c" ,-1 ,1 , stellaris_i2c_save, stellaris_i2c_load, s);return 0 ; }
@@ -1196,7 +1197,7 @@ static int stellaris_adc_init(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , iomemtype);stellaris_adc_reset (s);qdev_init_gpio_in (&dev->qdev, stellaris_adc_trigger,1 ); -register_savevm ("stellaris_adc" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_adc" ,-1 ,1 , stellaris_adc_save, stellaris_adc_load, s);return 0 ; }
@@ -1256,7 +1257,7 @@ static int stellaris_ssi_bus_init(SSISlave *dev) s->bus[1 ] =ssi_create_bus (&dev->qdev,"ssi1" );qdev_init_gpio_in (&dev->qdev, stellaris_ssi_bus_select,1 ); -register_savevm ("stellaris_ssi_bus" ,-1 ,1 , +register_savevm (&dev->qdev,"stellaris_ssi_bus" ,-1 ,1 , stellaris_ssi_bus_save, stellaris_ssi_bus_load, s);return 0 ; }
hw/stellaris_enet.c +2 -2
@@ -389,7 +389,7 @@ static void stellaris_enet_cleanup(VLANClientState *nc) {stellaris_enet_state *s =DO_UPCAST (NICState, nc, nc)->opaque; -unregister_savevm ("stellaris_enet" , s); +unregister_savevm (&s->busdev.qdev,"stellaris_enet" , s);cpu_unregister_io_memory (s->mmio_index);
@@ -419,7 +419,7 @@ static int stellaris_enet_init(SysBusDevice *dev)qemu_format_nic_info_str (&s->nic->nc, s->conf.macaddr.a);stellaris_enet_reset (s); -register_savevm ("stellaris_enet" ,-1 ,1 , +register_savevm (&s->busdev.qdev,"stellaris_enet" ,-1 ,1 , stellaris_enet_save, stellaris_enet_load, s);return 0 ; }
hw/stellaris_input.c +1 -1
@@ -86,6 +86,6 @@ void stellaris_gamepad_init(int n, qemu_irq *irq, const int *keycode) } s->num_buttons = n;qemu_add_kbd_event_handler (stellaris_gamepad_put_key, s); -register_savevm ("stellaris_gamepad" ,-1 ,1 , +register_savevm (NULL ,"stellaris_gamepad" ,-1 ,1 , stellaris_gamepad_save, stellaris_gamepad_load, s); }
hw/syborg_fb.c +1 -1
@@ -526,7 +526,7 @@ static int syborg_fb_init(SysBusDevice *dev)if (!s->rows) s->rows =ds_get_height (s->ds); -register_savevm ("syborg_framebuffer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_framebuffer" ,-1 ,1 , syborg_fb_save, syborg_fb_load, s);return 0 ; }
hw/syborg_interrupt.c +2 -1
@@ -214,7 +214,8 @@ static int syborg_int_init(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , iomemtype); s->flags =qemu_mallocz (s->num_irqs *sizeof (syborg_int_flags)); -register_savevm ("syborg_int" ,-1 ,1 , syborg_int_save, syborg_int_load, s); +register_savevm (&dev->qdev,"syborg_int" ,-1 ,1 , syborg_int_save, + syborg_int_load, s);return 0 ; }
hw/syborg_keyboard.c +1 -1
@@ -220,7 +220,7 @@ static int syborg_keyboard_init(SysBusDevice *dev)qemu_add_kbd_event_handler (syborg_keyboard_event, s); -register_savevm ("syborg_keyboard" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_keyboard" ,-1 ,1 , syborg_keyboard_save, syborg_keyboard_load, s);return 0 ; }
hw/syborg_pointer.c +1 -1
@@ -218,7 +218,7 @@ static int syborg_pointer_init(SysBusDevice *dev)qemu_add_mouse_event_handler (syborg_pointer_event, s, s->absolute,"Syborg Pointer" ); -register_savevm ("syborg_pointer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_pointer" ,-1 ,1 , syborg_pointer_save, syborg_pointer_load, s);return 0 ; }
hw/syborg_rtc.c +2 -1
@@ -136,7 +136,8 @@ static int syborg_rtc_init(SysBusDevice *dev)qemu_get_timedate (&tm,0 ); s->offset = (uint64_t )mktime (&tm) *1000000000 ; -register_savevm ("syborg_rtc" ,-1 ,1 , syborg_rtc_save, syborg_rtc_load, s); +register_savevm (&dev->qdev,"syborg_rtc" ,-1 ,1 , + syborg_rtc_save, syborg_rtc_load, s);return 0 ; }
hw/syborg_serial.c +1 -1
@@ -335,7 +335,7 @@ static int syborg_serial_init(SysBusDevice *dev) } s->read_fifo =qemu_mallocz (s->fifo_size *sizeof (s->read_fifo[0 ])); -register_savevm ("syborg_serial" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_serial" ,-1 ,1 , syborg_serial_save, syborg_serial_load, s);return 0 ; }
hw/syborg_timer.c +1 -1
@@ -221,7 +221,7 @@ static int syborg_timer_init(SysBusDevice *dev) bh =qemu_bh_new (syborg_timer_tick, s); s->timer =ptimer_init (bh);ptimer_set_freq (s->timer, s->freq); -register_savevm ("syborg_timer" ,-1 ,1 , +register_savevm (&dev->qdev,"syborg_timer" ,-1 ,1 , syborg_timer_save, syborg_timer_load, s);return 0 ; }
hw/tsc2005.c +1 -1
@@ -548,7 +548,7 @@ void *tsc2005_init(qemu_irq pintdav) "QEMU TSC2005-driven Touchscreen");qemu_register_reset ((void *) tsc2005_reset, s); -register_savevm ("tsc2005" ,-1 ,0 , tsc2005_save, tsc2005_load, s); +register_savevm (NULL ,"tsc2005" ,-1 ,0 , tsc2005_save, tsc2005_load, s);return s; }
hw/tsc210x.c +2 -2
@@ -1143,7 +1143,7 @@ uWireSlave *tsc2102_init(qemu_irq pint)AUD_register_card (s->name, &s->card);qemu_register_reset ((void *) tsc210x_reset, s); -register_savevm (s->name,-1 ,0 , +register_savevm (NULL , s->name,-1 ,0 , tsc210x_save, tsc210x_load, s);return &s->chip;
@@ -1194,7 +1194,7 @@ uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav)AUD_register_card (s->name, &s->card);qemu_register_reset ((void *) tsc210x_reset, s); -register_savevm (s->name,-1 ,0 , tsc210x_save, tsc210x_load, s); +register_savevm (NULL , s->name,-1 ,0 , tsc210x_save, tsc210x_load, s);return &s->chip; }
hw/unin_pci.c +4 -2
@@ -158,7 +158,8 @@ static int pci_unin_main_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("uninorth" ,0 ,1 , pci_unin_save, pci_unin_load, &s->host_state); +register_savevm (&dev->qdev,"uninorth" ,0 ,1 , + pci_unin_save, pci_unin_load, &s->host_state);qemu_register_reset (pci_unin_reset, &s->host_state);return 0 ; }
@@ -178,7 +179,8 @@ static int pci_u3_agp_init_device(SysBusDevice *dev)sysbus_init_mmio (dev,0x1000 , pci_mem_config);sysbus_init_mmio (dev,0x1000 , pci_mem_data); -register_savevm ("uninorth" ,0 ,1 , pci_unin_save, pci_unin_load, &s->host_state); +register_savevm (&dev->qdev,"uninorth" ,0 ,1 , + pci_unin_save, pci_unin_load, &s->host_state);qemu_register_reset (pci_unin_reset, &s->host_state);return 0 ;
hw/vga-isa-mm.c +1 -1
@@ -100,7 +100,7 @@ static void vga_mm_init(ISAVGAMMState *s, target_phys_addr_t vram_base, s_ioport_ctrl =cpu_register_io_memory (vga_mm_read_ctrl, vga_mm_write_ctrl, s); vga_io_memory =cpu_register_io_memory (vga_mem_read, vga_mem_write, s); -vmstate_register (0 , &vmstate_vga_common, s); +vmstate_register (NULL ,0 , &vmstate_vga_common, s);cpu_register_physical_memory (ctrl_base,0x100000 , s_ioport_ctrl); s->vga.bank_offset =0 ;
hw/vga-isa.c +1 -1
@@ -37,7 +37,7 @@ int isa_vga_init(void)vga_common_init (s,VGA_RAM_SIZE );vga_init (s); -vmstate_register (0 , &vmstate_vga_common, s); +vmstate_register (NULL ,0 , &vmstate_vga_common, s); s->ds =graphic_console_init (s->update, s->invalidate, s->screen_dump, s->text_update, s);
hw/virtio-balloon.c +2 -1
@@ -270,7 +270,8 @@ VirtIODevice *virtio_balloon_init(DeviceState *dev)reset_stats (s);qemu_add_balloon_handler (virtio_balloon_to_target, s); -register_savevm ("virtio-balloon" ,-1 ,1 , virtio_balloon_save, virtio_balloon_load, s); +register_savevm (dev,"virtio-balloon" ,-1 ,1 , + virtio_balloon_save, virtio_balloon_load, s);return &s->vdev; }
hw/virtio-blk.c +1 -1
@@ -498,7 +498,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) s->vq =virtio_add_queue (&s->vdev,128 , virtio_blk_handle_output);qemu_add_vm_change_state_handler (virtio_blk_dma_restart_cb, s); -register_savevm ("virtio-blk" , virtio_blk_id++,2 , +register_savevm (dev,"virtio-blk" , virtio_blk_id++,2 , virtio_blk_save, virtio_blk_load, s);return &s->vdev;
hw/virtio-net.c +2 -2
@@ -923,7 +923,7 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) n->vlans =qemu_mallocz (MAX_VLAN >>3 ); -register_savevm ("virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , +register_savevm (NULL ,"virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , virtio_net_save, virtio_net_load, n); n->vmstate =qemu_add_vm_change_state_handler (virtio_net_vmstate_change, n);
@@ -941,7 +941,7 @@ void virtio_net_exit(VirtIODevice *vdev)qemu_purge_queued_packets (&n->nic->nc); -unregister_savevm ("virtio-net" , n); +unregister_savevm (NULL ,"virtio-net" , n);qemu_free (n->mac_table.macs);qemu_free (n->vlans);
hw/virtio-serial-bus.c +1 -1
@@ -784,7 +784,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)* Register for the savevm section with the virtio-console name * to preserve backward compat */ -register_savevm ("virtio-console" ,-1 ,2 , virtio_serial_save, +register_savevm (dev,"virtio-console" ,-1 ,2 , virtio_serial_save, virtio_serial_load, vser);return vdev;
hw/vmmouse.c +1 -1
@@ -274,7 +274,7 @@ void *vmmouse_init(void *m)vmport_register (VMMOUSE_STATUS , vmmouse_ioport_read, s);vmport_register (VMMOUSE_COMMAND , vmmouse_ioport_read, s);vmport_register (VMMOUSE_DATA , vmmouse_ioport_read, s); -vmstate_register (0 , &vmstate_vmmouse, s); +vmstate_register (NULL ,0 , &vmstate_vmmouse, s);return s; }
hw/vmware_vga.c +1 -1
@@ -1169,7 +1169,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size)vga_common_init (&s->vga, vga_ram_size);vga_init (&s->vga); -vmstate_register (0 , &vmstate_vga_common, &s->vga); +vmstate_register (NULL ,0 , &vmstate_vga_common, &s->vga);vga_init_vbe (&s->vga);
hw/zaurus.c +1 -1
@@ -230,7 +230,7 @@ ScoopInfo *scoop_init(PXA2xxState *cpu, iomemtype =cpu_register_io_memory (scoop_readfn, scoop_writefn, s);cpu_register_physical_memory (target_base,0x1000 , iomemtype); -register_savevm ("scoop" , instance,1 , scoop_save, scoop_load, s); +register_savevm (NULL ,"scoop" , instance,1 , scoop_save, scoop_load, s);return s; }
qemu-timer.c +1 -1
@@ -662,7 +662,7 @@ static const VMStateDescription vmstate_timers = {void configure_icount (const char *option) { -vmstate_register (0 , &vmstate_timers, &timers_state); +vmstate_register (NULL ,0 , &vmstate_timers, &timers_state);if (!option)return ;
savevm.c +13 -9
@@ -1026,7 +1026,8 @@ static int calculate_new_instance_id(const char *idstr)of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly distinguishing id for all instances of your device class. */ -int register_savevm_live(const char *idstr, +int register_savevm_live(DeviceState *dev, + const char *idstr, int instance_id, int version_id, SaveSetParamsHandler *set_params,
@@ -1058,18 +1059,19 @@ int register_savevm_live(const char *idstr,return 0 ; } -int register_savevm (const char *idstr, +int register_savevm (DeviceState *dev, +const char *idstr,int instance_id,int version_id,SaveStateHandler *save_state,LoadStateHandler *load_state,void *opaque) { -return register_savevm_live (idstr, instance_id, version_id, +return register_savevm_live (dev, idstr, instance_id, version_id,NULL ,NULL , save_state, load_state, opaque); } -void unregister_savevm (const char *idstr,void *opaque) +void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque) {SaveStateEntry *se, *new_se;
@@ -1081,7 +1083,7 @@ void unregister_savevm(const char *idstr, void *opaque) } } -int vmstate_register_with_alias_id (int instance_id, +int vmstate_register_with_alias_id (DeviceState *dev,int instance_id,const VMStateDescription *vmsd,void *opaque,int alias_id,int required_for_version)
@@ -1112,13 +1114,15 @@ int vmstate_register_with_alias_id(int instance_id,return 0 ; } -int vmstate_register (int instance_id,const VMStateDescription *vmsd, -void *opaque) +int vmstate_register (DeviceState *dev,int instance_id, +const VMStateDescription *vmsd,void *opaque) { -return vmstate_register_with_alias_id (instance_id, vmsd, opaque,-1 ,0 ); +return vmstate_register_with_alias_id (dev, instance_id, vmsd, + opaque,-1 ,0 ); } -void vmstate_unregister (const VMStateDescription *vmsd,void *opaque) +void vmstate_unregister (DeviceState *dev,const VMStateDescription *vmsd, +void *opaque) {SaveStateEntry *se, *new_se;
slirp/slirp.c +3 -2
@@ -232,7 +232,8 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, slirp->opaque = opaque; -register_savevm ("slirp" ,0 ,3 , slirp_state_save, slirp_state_load, slirp); +register_savevm (NULL ,"slirp" ,0 ,3 , + slirp_state_save, slirp_state_load, slirp);QTAILQ_INSERT_TAIL (&slirp_instances, slirp, entry);
@@ -243,7 +244,7 @@ void slirp_cleanup(Slirp *slirp) {QTAILQ_REMOVE (&slirp_instances, slirp, entry); -unregister_savevm ("slirp" , slirp); +unregister_savevm (NULL ,"slirp" , slirp);qemu_free (slirp->tftp_prefix);qemu_free (slirp->bootp_filename);
vl.c +1 -1
@@ -2794,7 +2794,7 @@ int main(int argc, char **argv, char **envp)if (qemu_opts_foreach (&qemu_drive_opts, drive_init_func, &machine->use_scsi,1 ) !=0 )exit (1 ); -register_savevm_live ("ram" ,0 ,3 ,NULL , ram_save_live,NULL , +register_savevm_live (NULL ,"ram" ,0 ,3 ,NULL , ram_save_live,NULL , ram_load,NULL );if (nb_numa_nodes >0 ) {
PATCH v3 6/16 savevm: Make use of DeviceState
In reply to Alex WilliamsonFor callers that pass a device we can traverse up the qdev tree and make use of the BusInfo.get_dev_path information for creating unique savevm id strings. This avoids needing to rely on the instance number, which can cause problems with device initialization order and hotplug.
For compatibility, we also store away the old id string and instance so we can accept migrations from VMs as we add new get_dev_path implementations.
---
savevm.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 79 insertions(+), 5 deletions(-)
savevm.c +79 -5
@@ -72,6 +72,7 @@#include "qemu-common.h" #include "hw/hw.h" +#include "hw/qdev.h" #include "net.h" #include "monitor.h" #include "sysemu.h"
@@ -988,6 +989,11 @@ const VMStateInfo vmstate_info_unused_buffer = { .put = put_unused_buffer, }; +typedef struct CompatEntry { +char idstr[256 ]; +int instance_id; +}CompatEntry ; + typedef struct SaveStateEntry { QTAILQ_ENTRY(SaveStateEntry) entry; char idstr[256];
@@ -1001,6 +1007,7 @@ typedef struct SaveStateEntry {LoadStateHandler *load_state;const VMStateDescription *vmsd;void *opaque; +CompatEntry *compat; } SaveStateEntry;
@@ -1022,6 +1029,23 @@ static int calculate_new_instance_id(const char *idstr)return instance_id; } +static int calculate_compat_instance_id (const char *idstr) +{ +SaveStateEntry *se; +int instance_id =0 ; + + QTAILQ_FOREACH(se, &savevm_handlers, entry) { +if (!se->compat) +continue ; + +if (strcmp (idstr, se->compat->idstr) ==0 + && instance_id <= se->compat->instance_id) { + instance_id = se->compat->instance_id +1 ; + } + } +return instance_id; +} +/* TODO: Individual devices generally have very little idea about the rest of the system, so instance_id should be removed/replaced. Meanwhile pass -1 as instance_id if you do not already have a clearly
@@ -1039,7 +1063,6 @@ int register_savevm_live(DeviceState *dev,SaveStateEntry *se; se =qemu_mallocz (sizeof (SaveStateEntry)); -pstrcpy (se->idstr,sizeof (se->idstr), idstr); se->version_id = version_id; se->section_id = global_section_id++; se->set_params = set_params;
@@ -1049,11 +1072,28 @@ int register_savevm_live(DeviceState *dev, se->opaque = opaque; se->vmsd =NULL ; +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +pstrcpy (se->idstr,sizeof (se->idstr), id); +pstrcat (se->idstr,sizeof (se->idstr),"/" ); +qemu_free (id); + + se->compat =qemu_mallocz (sizeof (CompatEntry)); +pstrcpy (se->compat->idstr,sizeof (se->compat->idstr), idstr); + se->compat->instance_id = instance_id ==-1 ? +calculate_compat_instance_id (idstr) : instance_id; + instance_id =-1 ; + } + } +pstrcat (se->idstr,sizeof (se->idstr), idstr); +if (instance_id ==-1 ) { - se->instance_id =calculate_new_instance_id (idstr); + se->instance_id =calculate_new_instance_id (se->idstr); }else { se->instance_id = instance_id; } +assert (!se->compat || se->instance_id ==0 );/* add at the end of list */ QTAILQ_INSERT_TAIL (&savevm_handlers, se, entry);return 0 ;
@@ -1074,9 +1114,20 @@ int register_savevm(DeviceState *dev,void unregister_savevm (DeviceState *dev,const char *idstr,void *opaque) {SaveStateEntry *se, *new_se; +char id[256 ] ="" ; + +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *path = dev->parent_bus->info->get_dev_path (dev); +if (path) { +pstrcpy (id,sizeof (id), path); +pstrcat (id,sizeof (id),"/" ); +qemu_free (path); + } + } +pstrcat (id,sizeof (id), idstr); QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { -if (strcmp (se->idstr, idstr) ==0 && se->opaque == opaque) { +if (strcmp (se->idstr, id) ==0 && se->opaque == opaque) {QTAILQ_REMOVE (&savevm_handlers, se, entry);qemu_free (se); }
@@ -1094,7 +1145,6 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,assert (alias_id ==-1 || required_for_version >= vmsd->minimum_version_id); se =qemu_mallocz (sizeof (SaveStateEntry)); -pstrcpy (se->idstr,sizeof (se->idstr), vmsd->name); se->version_id = vmsd->version_id; se->section_id = global_section_id++; se->save_live_state =NULL ;
@@ -1104,11 +1154,28 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, se->vmsd = vmsd; se->alias_id = alias_id; +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +pstrcpy (se->idstr,sizeof (se->idstr), id); +pstrcat (se->idstr,sizeof (se->idstr),"/" ); +qemu_free (id); + + se->compat =qemu_mallocz (sizeof (CompatEntry)); +pstrcpy (se->compat->idstr,sizeof (se->compat->idstr), vmsd->name); + se->compat->instance_id = instance_id ==-1 ? +calculate_compat_instance_id (vmsd->name) : instance_id; + instance_id =-1 ; + } + } +pstrcat (se->idstr,sizeof (se->idstr), vmsd->name); +if (instance_id ==-1 ) { - se->instance_id =calculate_new_instance_id (vmsd->name); + se->instance_id =calculate_new_instance_id (se->idstr); }else { se->instance_id = instance_id; } +assert (!se->compat || se->instance_id ==0 );/* add at the end of list */ QTAILQ_INSERT_TAIL (&savevm_handlers, se, entry);return 0 ;
@@ -1454,6 +1521,13 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) (instance_id == se->instance_id || instance_id == se->alias_id))return se; +/* Migrating from an older version? */ +if (strstr (se->idstr, idstr) && se->compat) { +if (!strcmp (se->compat->idstr, idstr) && + (instance_id == se->compat->instance_id || + instance_id == se->alias_id)) +return se; + } }return NULL ; }
PATCH v3 7/16 eepro100: Add a dev field to eeprom new/free functions
In reply to Alex WilliamsonThis allows us to create a more meaningful savevm string.
---
hw/eepro100.c | 4 ++-- hw/eeprom93xx.c | 8 ++++---- hw/eeprom93xx.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
hw/eepro100.c +2 -2
@@ -1835,7 +1835,7 @@ static int pci_nic_uninit(PCIDevice *pci_dev)cpu_unregister_io_memory (s->mmio_index);vmstate_unregister (&pci_dev->qdev, s->vmstate, s); -eeprom93xx_free (s->eeprom); +eeprom93xx_free (&pci_dev->qdev, s->eeprom);qemu_del_vlan_client (&s->nic->nc);return 0 ; }
@@ -1862,7 +1862,7 @@ static int e100_nic_init(PCIDevice *pci_dev)/* Add 64 * 2 EEPROM. i82557 and i82558 support a 64 word EEPROM, * i82559 and later support 64 or 256 word EEPROM. */ - s->eeprom =eeprom93xx_new (EEPROM_SIZE ); + s->eeprom =eeprom93xx_new (&pci_dev->qdev,EEPROM_SIZE );/* Handler for memory-mapped I/O */ s->mmio_index =
hw/eeprom93xx.c +4 -4
@@ -289,7 +289,7 @@ void eeprom93xx_reset(eeprom_t *eeprom) }#endif -eeprom_t *eeprom93xx_new (uint16_t nwords) +eeprom_t *eeprom93xx_new (DeviceState *dev,uint16_t nwords) {/* Add a new EEPROM (with 16, 64 or 256 words). */ eeprom_t *eeprom;
@@ -316,15 +316,15 @@ eeprom_t *eeprom93xx_new(uint16_t nwords)/* Output DO is tristate, read results in 1. */ eeprom->eedo =1 ;logout ("eeprom = 0x%p, nwords = %u\n" , eeprom, nwords); -vmstate_register (NULL ,0 , &vmstate_eeprom, eeprom); +vmstate_register (dev,0 , &vmstate_eeprom, eeprom);return eeprom; } -void eeprom93xx_free (eeprom_t *eeprom) +void eeprom93xx_free (DeviceState *dev,eeprom_t *eeprom) {/* Destroy EEPROM. */ logout ("eeprom = 0x%p\n" , eeprom); -vmstate_unregister (NULL , &vmstate_eeprom, eeprom); +vmstate_unregister (dev, &vmstate_eeprom, eeprom);qemu_free (eeprom); }
hw/eeprom93xx.h +2 -2
@@ -23,10 +23,10 @@typedef struct _eeprom_t eeprom_t ;/* Create a new EEPROM with (nwords * 2) bytes. */ -eeprom_t *eeprom93xx_new (uint16_t nwords); +eeprom_t *eeprom93xx_new (DeviceState *dev,uint16_t nwords);/* Destroy an existing EEPROM. */ -void eeprom93xx_free (eeprom_t *eeprom); +void eeprom93xx_free (DeviceState *dev,eeprom_t *eeprom);/* Read from the EEPROM. */ uint16_t eeprom93xx_read (eeprom_t *eeprom);
PATCH v3 8/16 virtio-net: Incorporate a DeviceState pointer and let savevm track instances
In reply to Alex WilliamsonStuff a pointer to the DeviceState into the VirtIONet structure so that we can easily remove the vmstate entry later. Also, let vmstate track the instance number (it should always be zero internally since the device path should now be unique).
---
hw/virtio-net.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
hw/virtio-net.c +4 -3
@@ -60,6 +60,7 @@ typedef struct VirtIONetuint8_t *macs; } mac_table;uint32_t *vlans; +DeviceState *qdev; } VirtIONet;/* TODO
@@ -890,7 +891,6 @@ static void virtio_net_vmstate_change(void *opaque, int running, int reason)VirtIODevice *virtio_net_init (DeviceState *dev,NICConf *conf) {VirtIONet *n; -static int virtio_net_id; n = (VirtIONet *)virtio_common_init("virtio-net", VIRTIO_ID_NET, sizeof(struct virtio_net_config),
@@ -923,7 +923,8 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf) n->vlans =qemu_mallocz (MAX_VLAN >>3 ); -register_savevm (NULL ,"virtio-net" , virtio_net_id++,VIRTIO_NET_VM_VERSION , + n->qdev = dev; +register_savevm (dev,"virtio-net" ,-1 ,VIRTIO_NET_VM_VERSION , virtio_net_save, virtio_net_load, n); n->vmstate =qemu_add_vm_change_state_handler (virtio_net_vmstate_change, n);
@@ -941,7 +942,7 @@ void virtio_net_exit(VirtIODevice *vdev)qemu_purge_queued_packets (&n->nic->nc); -unregister_savevm (NULL ,"virtio-net" , n); +unregister_savevm (n->qdev,"virtio-net" , n);qemu_free (n->mac_table.macs);qemu_free (n->vlans);
PATCH v3 9/16 qemu_ram_alloc: Add DeviceState and name parameters
In reply to Alex WilliamsonThese will be used to generate unique id strings for ramblocks. The name field is required, the device pointer is optional as most callers don't have a device. When there's no device or the device isn't a child of a bus implementing BusInfo.get_dev_path, the name should be unique for the platform.
---
cpu-common.h | 2 +- exec.c | 2 +- hw/an5206.c | 4 ++-- hw/armv7m.c | 9 ++++++--- hw/axis_dev88.c | 4 ++-- hw/dummy_m68k.c | 2 +- hw/etraxfs.c | 6 +++--- hw/g364fb.c | 2 +- hw/gumstix.c | 6 ++++-- hw/integratorcp.c | 4 ++-- hw/mainstone.c | 6 ++++-- hw/mcf5208.c | 4 ++-- hw/mips_fulong2e.c | 4 ++-- hw/mips_jazz.c | 4 ++-- hw/mips_malta.c | 4 ++-- hw/mips_mipssim.c | 4 ++-- hw/mips_r4k.c | 6 +++--- hw/musicpal.c | 11 +++++++---- hw/omap1.c | 6 ++++-- hw/omap2.c | 6 ++++-- hw/omap_sx1.c | 12 ++++++++---- hw/onenand.c | 2 +- hw/palm.c | 3 ++- hw/pc.c | 7 ++++--- hw/pci.c | 7 ++++++- hw/petalogix_s3adsp1800_mmu.c | 7 ++++--- hw/ppc405_boards.c | 18 +++++++++--------- hw/ppc405_uc.c | 2 +- hw/ppc4xx_devs.c | 4 +++- hw/ppc_newworld.c | 6 +++--- hw/ppc_oldworld.c | 6 +++--- hw/ppc_prep.c | 4 ++-- hw/ppce500_mpc8544ds.c | 3 ++- hw/pxa2xx.c | 12 ++++++++---- hw/r2d.c | 4 ++-- hw/realview.c | 6 +++--- hw/s390-virtio.c | 2 +- hw/sm501.c | 2 +- hw/spitz.c | 2 +- hw/sun4m.c | 8 ++++---- hw/sun4u.c | 4 ++-- hw/syborg.c | 2 +- hw/tc6393xb.c | 2 +- hw/tcx.c | 2 +- hw/tosa.c | 2 +- hw/versatilepb.c | 2 +- hw/vga.c | 2 +- hw/vmware_vga.c | 2 +- 48 files changed, 132 insertions(+), 99 deletions(-)
cpu-common.h +1 -1
@@ -40,7 +40,7 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr, }ram_addr_t cpu_get_physical_page_desc (target_phys_addr_t addr); -ram_addr_t qemu_ram_alloc (ram_addr_t ); +ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size);void qemu_ram_free (ram_addr_t addr);/* This should only be used for ram local to a device. */ void *qemu_get_ram_ptr (ram_addr_t addr);
exec.c +1 -1
@@ -2778,7 +2778,7 @@ static ram_addr_t find_ram_offset(ram_addr_t size)return last; } -ram_addr_t qemu_ram_alloc (ram_addr_t size) +ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size) {RAMBlock *new_block;
hw/an5206.c +2 -2
@@ -54,11 +54,11 @@ static void an5206_init(ram_addr_t ram_size,/* DRAM at address zero */ cpu_register_physical_memory (0 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"an5206.ram" , ram_size) |IO_MEM_RAM );/* Internal SRAM. */ cpu_register_physical_memory (AN5206_RAMBAR_ADDR ,512 , -qemu_ram_alloc (512 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"an5206.sram" ,512 ) |IO_MEM_RAM );mcf5206_init (AN5206_MBAR_ADDR , env);
hw/armv7m.c +6 -3
@@ -200,9 +200,11 @@ qemu_irq *armv7m_init(int flash_size, int sram_size,/* Flash programming is done via the SCU, so pretend it is ROM. */ cpu_register_physical_memory (0 , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"armv7m.flash" , + flash_size) |IO_MEM_ROM );cpu_register_physical_memory (0x20000000 , sram_size, -qemu_ram_alloc (sram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"armv7m.sram" , + sram_size) |IO_MEM_RAM );armv7m_bitband_init (); nvic =qdev_create (NULL ,"armv7m_nvic" );
@@ -236,7 +238,8 @@ qemu_irq *armv7m_init(int flash_size, int sram_size,space. This stops qemu complaining about executing code outside RAM when returning from an exception. */ cpu_register_physical_memory (0xfffff000 ,0x1000 , -qemu_ram_alloc (0x1000 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"armv7m.hack" , +0x1000 ) |IO_MEM_RAM );qemu_register_reset (armv7m_reset, env);return pic;
hw/axis_dev88.c +2 -2
@@ -268,12 +268,12 @@ void axisdev88_init (ram_addr_t ram_size, env =cpu_init (cpu_model);/* allocate RAM */ - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"axisdev88.ram" , ram_size);cpu_register_physical_memory (0x40000000 , ram_size, phys_ram |IO_MEM_RAM );/* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the internal memory. */ - phys_intmem =qemu_ram_alloc (INTMEM_SIZE ); + phys_intmem =qemu_ram_alloc (NULL ,"axisdev88.chipram" ,INTMEM_SIZE );cpu_register_physical_memory (0x38000000 ,INTMEM_SIZE , phys_intmem |IO_MEM_RAM );
hw/dummy_m68k.c +1 -1
@@ -39,7 +39,7 @@ static void dummy_m68k_init(ram_addr_t ram_size,/* RAM at address zero */ cpu_register_physical_memory (0 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"dummy_m68k.ram" , ram_size) |IO_MEM_RAM );/* Load kernel. */ if (kernel_filename) {
hw/etraxfs.c +3 -3
@@ -68,17 +68,17 @@ void bareetraxfs_init (ram_addr_t ram_size, env =cpu_init (cpu_model);/* allocate RAM */ - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"etraxfs.ram" , ram_size);cpu_register_physical_memory (0x40000000 , ram_size, phys_ram |IO_MEM_RAM );/* The ETRAX-FS has 128Kb on chip ram, the docs refer to it as the internal memory. */ - phys_intmem =qemu_ram_alloc (INTMEM_SIZE ); + phys_intmem =qemu_ram_alloc (NULL ,"etraxfs.chipram" ,INTMEM_SIZE );cpu_register_physical_memory (0x38000000 ,INTMEM_SIZE , phys_intmem |IO_MEM_RAM ); - phys_flash =qemu_ram_alloc (FLASH_SIZE ); + phys_flash =qemu_ram_alloc (NULL ,"etraxfs.flash" ,FLASH_SIZE ); dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash_cfi02_register(0x0, phys_flash, dinfo ? dinfo->bdrv : NULL, (64 * 1024),
hw/g364fb.c +1 -1
@@ -593,7 +593,7 @@ int g364fb_mm_init(target_phys_addr_t vram_base, s =qemu_mallocz (sizeof (G364State)); s->vram_size =8 *1024 *1024 ; - s->vram_offset =qemu_ram_alloc (s->vram_size); + s->vram_offset =qemu_ram_alloc (NULL ,"g364fb.vram" , s->vram_size); s->vram =qemu_get_ram_ptr (s->vram_offset); s->irq = irq;
hw/gumstix.c +4 -2
@@ -67,7 +67,8 @@ static void connex_init(ram_addr_t ram_size,#else be =0 ;#endif -if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (connex_rom), +if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (NULL ,"connext.rom" , + connex_rom), dinfo->bdrv, sector_len, connex_rom / sector_len,2 ,0 ,0 ,0 ,0 , be)) {fprintf (stderr,"qemu: Error registering flash memory.\n" );
@@ -105,7 +106,8 @@ static void verdex_init(ram_addr_t ram_size,#else be =0 ;#endif -if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (verdex_rom), +if (!pflash_cfi01_register (0x00000000 ,qemu_ram_alloc (NULL ,"verdex.rom" , + verdex_rom), dinfo->bdrv, sector_len, verdex_rom / sector_len,2 ,0 ,0 ,0 ,0 , be)) {fprintf (stderr,"qemu: Error registering flash memory.\n" );
hw/integratorcp.c +2 -2
@@ -253,7 +253,7 @@ static int integratorcm_init(SysBusDevice *dev) }memcpy (integrator_spd +73 ,"QEMU-MEMORY" ,11 ); s->cm_init =0x00000112 ; - s->flash_offset =qemu_ram_alloc (0x100000 ); + s->flash_offset =qemu_ram_alloc (NULL ,"integrator.flash" ,0x100000 ); iomemtype =cpu_register_io_memory (integratorcm_readfn, integratorcm_writefn, s);
@@ -467,7 +467,7 @@ static void integratorcp_init(ram_addr_t ram_size,fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"integrator.ram" , ram_size);/* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero*/
hw/mainstone.c +4 -2
@@ -87,7 +87,8 @@ static void mainstone_common_init(ram_addr_t ram_size,/* Setup CPU & memory */ cpu =pxa270_init (mainstone_binfo.ram_size, cpu_model);cpu_register_physical_memory (0 ,MAINSTONE_ROM , -qemu_ram_alloc (MAINSTONE_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"mainstone.rom" , +MAINSTONE_ROM ) |IO_MEM_ROM );#ifdef TARGET_WORDS_BIGENDIAN be =1 ;
@@ -104,7 +105,8 @@ static void mainstone_common_init(ram_addr_t ram_size, }if (!pflash_cfi01_register (mainstone_flash_base[i], -qemu_ram_alloc (MAINSTONE_FLASH ), +qemu_ram_alloc (NULL ,"mainstone.flash" , +MAINSTONE_FLASH ), dinfo->bdrv, sector_len,MAINSTONE_FLASH / sector_len,4 ,0 ,0 ,0 ,0 , be)) {
hw/mcf5208.c +2 -2
@@ -220,11 +220,11 @@ static void mcf5208evb_init(ram_addr_t ram_size,/* DRAM at 0x40000000 */ cpu_register_physical_memory (0x40000000 , ram_size, -qemu_ram_alloc (ram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"mcf5208.ram" , ram_size) |IO_MEM_RAM );/* Internal SRAM. */ cpu_register_physical_memory (0x80000000 ,16384 , -qemu_ram_alloc (16384 ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"mcf5208.sram" ,16384 ) |IO_MEM_RAM );/* Internal peripherals. */ pic =mcf_intc_init (0xfc048000 , env);
hw/mips_fulong2e.c +2 -2
@@ -292,8 +292,8 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device, bios_size =1024 *1024 ;/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); - bios_offset =qemu_ram_alloc (bios_size); + ram_offset =qemu_ram_alloc (NULL ,"mips_fulong2e.ram" , ram_size); + bios_offset =qemu_ram_alloc (NULL ,"mips_fulong2e.bios" , bios_size);cpu_register_physical_memory (0 , ram_size,IO_MEM_RAM ); cpu_register_physical_memory(0x1fc00000LL,
hw/mips_jazz.c +2 -2
@@ -158,10 +158,10 @@ void mips_jazz_init (ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, env);/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"mips_jazz.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM ); - bios_offset =qemu_ram_alloc (MAGNUM_BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"mips_jazz.bios" ,MAGNUM_BIOS_SIZE );cpu_register_physical_memory (0x1fc00000LL ,MAGNUM_BIOS_SIZE , bios_offset |IO_MEM_ROM ); cpu_register_physical_memory(0xfff00000LL,
hw/mips_malta.c +2 -2
@@ -831,8 +831,8 @@ void mips_malta_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20)));exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + ram_offset =qemu_ram_alloc (NULL ,"mips_malta.ram" , ram_size); + bios_offset =qemu_ram_alloc (NULL ,"mips_malta.bios" ,BIOS_SIZE );cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/mips_mipssim.c +2 -2
@@ -144,8 +144,8 @@ mips_mipssim_init (ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, reset_info);/* Allocate RAM. */ - ram_offset =qemu_ram_alloc (ram_size); - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + ram_offset =qemu_ram_alloc (NULL ,"mips_mipssim.ram" , ram_size); + bios_offset =qemu_ram_alloc (NULL ,"mips_mipssim.bios" ,BIOS_SIZE );cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/mips_r4k.c +3 -3
@@ -198,7 +198,7 @@ void mips_r4k_init (ram_addr_t ram_size, ((unsigned int)ram_size / (1 << 20)));exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"mips_r4k.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
@@ -226,14 +226,14 @@ void mips_r4k_init (ram_addr_t ram_size, be =0 ;#endif if ((bios_size >0 ) && (bios_size <=BIOS_SIZE )) { - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"mips_r4k.bios" ,BIOS_SIZE );cpu_register_physical_memory (0x1fc00000 ,BIOS_SIZE , bios_offset |IO_MEM_ROM );load_image_targphys (filename,0x1fc00000 ,BIOS_SIZE ); } else if ((dinfo = drive_get(IF_PFLASH, 0, 0)) != NULL) { uint32_t mips_rom = 0x00400000; - bios_offset = qemu_ram_alloc(mips_rom); + bios_offset = qemu_ram_alloc(NULL, "mips_r4k.bios", mips_rom); if (!pflash_cfi01_register(0x1fc00000, bios_offset, dinfo->bdrv, sector_len, mips_rom / sector_len,
hw/musicpal.c +7 -4
@@ -1506,9 +1506,10 @@ static void musicpal_init(ram_addr_t ram_size,/* For now we use a fixed - the original - RAM size */ cpu_register_physical_memory (0 ,MP_RAM_DEFAULT_SIZE , -qemu_ram_alloc (MP_RAM_DEFAULT_SIZE )); +qemu_ram_alloc (NULL ,"musicpal.ram" , +MP_RAM_DEFAULT_SIZE )); - sram_off =qemu_ram_alloc (MP_SRAM_SIZE ); + sram_off =qemu_ram_alloc (NULL ,"musicpal.sram" ,MP_SRAM_SIZE );cpu_register_physical_memory (MP_SRAM_BASE ,MP_SRAM_SIZE , sram_off); dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
@@ -1555,14 +1556,16 @@ static void musicpal_init(ram_addr_t ram_size,* image is smaller than 32 MB. */ #ifdef TARGET_WORDS_BIGENDIAN -pflash_cfi02_register (0 -MP_FLASH_SIZE_MAX ,qemu_ram_alloc (flash_size), +pflash_cfi02_register (0 -MP_FLASH_SIZE_MAX ,qemu_ram_alloc (NULL , +"musicpal.flash" , flash_size), dinfo->bdrv,0x10000 , (flash_size +0xffff ) >>16 ,MP_FLASH_SIZE_MAX / flash_size,2 ,0x00BF ,0x236D ,0x0000 ,0x0000 ,0x5555 ,0x2AAA ,1 );#else - pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size), + pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(NULL, + "musicpal.flash", flash_size), dinfo->bdrv, 0x10000, (flash_size + 0xffff) >> 16, MP_FLASH_SIZE_MAX / flash_size,
hw/omap1.c +4 -2
@@ -3732,9 +3732,11 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size,/* Memory-mapped stuff */ cpu_register_physical_memory (OMAP_EMIFF_BASE , s->sdram_size, - (emiff_base =qemu_ram_alloc (s->sdram_size)) |IO_MEM_RAM ); + (emiff_base =qemu_ram_alloc (NULL ,"omap1.dram" , + s->sdram_size)) |IO_MEM_RAM );cpu_register_physical_memory (OMAP_IMIF_BASE , s->sram_size, - (imif_base =qemu_ram_alloc (s->sram_size)) |IO_MEM_RAM ); + (imif_base =qemu_ram_alloc (NULL ,"omap1.sram" , + s->sram_size)) |IO_MEM_RAM );omap_clkm_init (0xfffece00 ,0xe1008000 , s);
hw/omap2.c +4 -2
@@ -2253,9 +2253,11 @@ struct omap_mpu_state_s *omap2420_mpu_init(unsigned long sdram_size,/* Memory-mapped stuff */ cpu_register_physical_memory (OMAP2_Q2_BASE , s->sdram_size, - (q2_base =qemu_ram_alloc (s->sdram_size)) |IO_MEM_RAM ); + (q2_base =qemu_ram_alloc (NULL ,"omap2.dram" , + s->sdram_size)) |IO_MEM_RAM );cpu_register_physical_memory (OMAP2_SRAM_BASE , s->sram_size, - (sram_base =qemu_ram_alloc (s->sram_size)) |IO_MEM_RAM ); + (sram_base =qemu_ram_alloc (NULL ,"omap2.sram" , + s->sram_size)) |IO_MEM_RAM ); s->l4 =omap_l4_init (OMAP2_L4_BASE ,54 );
hw/omap_sx1.c +8 -4
@@ -139,7 +139,8 @@ static void sx1_init(ram_addr_t ram_size,/* External Flash (EMIFS) */ cpu_register_physical_memory (OMAP_CS0_BASE , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"omap_sx1.flash0-0" , + flash_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs0val); cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
@@ -157,7 +158,8 @@ static void sx1_init(ram_addr_t ram_size,#endif if ((dinfo =drive_get (IF_PFLASH ,0 , fl_idx)) !=NULL ) { -if (!pflash_cfi01_register (OMAP_CS0_BASE ,qemu_ram_alloc (flash_size), +if (!pflash_cfi01_register (OMAP_CS0_BASE ,qemu_ram_alloc (NULL , +"omap_sx1.flash0-1" , flash_size), dinfo->bdrv, sector_size, flash_size / sector_size,4 ,0 ,0 ,0 ,0 , be)) {
@@ -170,12 +172,14 @@ static void sx1_init(ram_addr_t ram_size,if ((version ==1 ) && (dinfo =drive_get (IF_PFLASH ,0 , fl_idx)) !=NULL ) {cpu_register_physical_memory (OMAP_CS1_BASE , flash1_size, -qemu_ram_alloc (flash1_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"omap_sx1.flash1-0" , + flash1_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs1val);cpu_register_physical_memory (OMAP_CS1_BASE + flash1_size,OMAP_CS1_SIZE - flash1_size, io); -if (!pflash_cfi01_register (OMAP_CS1_BASE ,qemu_ram_alloc (flash1_size), +if (!pflash_cfi01_register (OMAP_CS1_BASE ,qemu_ram_alloc (NULL , +"omap_sx1.flash1-1" , flash1_size), dinfo->bdrv, sector_size, flash1_size / sector_size,4 ,0 ,0 ,0 ,0 , be)) {
hw/onenand.c +1 -1
@@ -638,7 +638,7 @@ void *onenand_init(uint32_t id, int regshift, qemu_irq irq) s->bdrv = dinfo->bdrv; s->otp =memset (qemu_malloc ((64 +2 ) <<PAGE_SHIFT ),0xff , (64 +2 ) <<PAGE_SHIFT ); - s->ram =qemu_ram_alloc (0xc000 << s->shift); + s->ram =qemu_ram_alloc (NULL ,"onenand.ram" ,0xc000 << s->shift); ram =qemu_get_ram_ptr (s->ram); s->boot[0 ] = ram + (0x0000 << s->shift); s->boot[1 ] = ram + (0x8000 << s->shift);
hw/palm.c +2 -1
@@ -213,7 +213,8 @@ static void palmte_init(ram_addr_t ram_size,/* External Flash (EMIFS) */ cpu_register_physical_memory (OMAP_CS0_BASE , flash_size, -qemu_ram_alloc (flash_size) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"palmte.flash" , + flash_size) |IO_MEM_ROM ); io =cpu_register_io_memory (static_readfn, static_writefn, &cs0val); cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
hw/pc.c +4 -3
@@ -885,7 +885,8 @@ void pc_memory_init(ram_addr_t ram_size, linux_boot = (kernel_filename !=NULL );/* allocate RAM */ - ram_addr =qemu_ram_alloc (below_4g_mem_size + above_4g_mem_size); + ram_addr =qemu_ram_alloc (NULL ,"pc.ram" , + below_4g_mem_size + above_4g_mem_size);cpu_register_physical_memory (0 ,0xa0000 , ram_addr); cpu_register_physical_memory(0x100000, below_4g_mem_size - 0x100000,
@@ -908,7 +909,7 @@ void pc_memory_init(ram_addr_t ram_size, (bios_size % 65536) != 0) { goto bios_error; } - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"pc.bios" , bios_size); ret =rom_add_file_fixed (bios_name, (uint32_t )(-bios_size));if (ret !=0 ) { bios_error:
@@ -926,7 +927,7 @@ void pc_memory_init(ram_addr_t ram_size, isa_bios_size, (bios_offset + bios_size - isa_bios_size) | IO_MEM_ROM); - option_rom_offset =qemu_ram_alloc (PC_ROM_SIZE ); + option_rom_offset =qemu_ram_alloc (NULL ,"pc.rom" ,PC_ROM_SIZE );cpu_register_physical_memory (PC_ROM_MIN_VGA ,PC_ROM_SIZE , option_rom_offset);/* map all the bios at the top of memory */
hw/pci.c +6 -1
@@ -1713,6 +1713,7 @@ static int pci_add_option_rom(PCIDevice *pdev)int size;char *path;void *ptr; +char name[32 ];if (!pdev->romfile)return 0 ;
@@ -1748,7 +1749,11 @@ static int pci_add_option_rom(PCIDevice *pdev) size =1 <<qemu_fls (size); } - pdev->rom_offset =qemu_ram_alloc (size); +if (pdev->qdev.info->vmsd) +snprintf (name,sizeof (name),"%s.rom" , pdev->qdev.info->vmsd->name); +else +snprintf (name,sizeof (name),"%s.rom" , pdev->qdev.info->name); + pdev->rom_offset =qemu_ram_alloc (&pdev->qdev, name, size); ptr =qemu_get_ram_ptr (pdev->rom_offset);load_image (path, ptr);
hw/petalogix_s3adsp1800_mmu.c +4 -3
@@ -137,14 +137,15 @@ petalogix_s3adsp1800_init(ram_addr_t ram_size,qemu_register_reset (main_cpu_reset, env);/* Attach emulated BRAM through the LMB. */ - phys_lmb_bram =qemu_ram_alloc (LMB_BRAM_SIZE ); + phys_lmb_bram =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.lmb_bram" , +LMB_BRAM_SIZE );cpu_register_physical_memory (0x00000000 ,LMB_BRAM_SIZE , phys_lmb_bram |IO_MEM_RAM ); - phys_ram =qemu_ram_alloc (ram_size); + phys_ram =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.ram" , ram_size);cpu_register_physical_memory (ddr_base, ram_size, phys_ram |IO_MEM_RAM ); - phys_flash =qemu_ram_alloc (FLASH_SIZE ); + phys_flash =qemu_ram_alloc (NULL ,"petalogix_s3adsp1800.flash" ,FLASH_SIZE ); dinfo =drive_get (IF_PFLASH ,0 ,0 ); pflash_cfi01_register(0xa0000000, phys_flash, dinfo ? dinfo->bdrv : NULL, (64 * 1024),
hw/ppc405_boards.c +9 -9
@@ -190,7 +190,7 @@ static void ref405ep_init (ram_addr_t ram_size,DriveInfo *dinfo;/* XXX: fix this */ - ram_bases[0 ] =qemu_ram_alloc (0x08000000 ); + ram_bases[0 ] =qemu_ram_alloc (NULL ,"ef405ep.ram" ,0x08000000 ); ram_sizes[0 ] =0x08000000 ; ram_bases[1 ] =0x00000000 ; ram_sizes[1 ] =0x00000000 ;
@@ -202,7 +202,7 @@ static void ref405ep_init (ram_addr_t ram_size, kernel_filename == NULL ? 0 : 1);/* allocate SRAM */ sram_size =512 *1024 ; - sram_offset =qemu_ram_alloc (sram_size); + sram_offset =qemu_ram_alloc (NULL ,"ef405ep.sram" , sram_size);#ifdef DEBUG_BOARD_INIT printf ("%s: register SRAM at offset %08lx\n" , __func__, sram_offset);#endif
@@ -217,7 +217,7 @@ static void ref405ep_init (ram_addr_t ram_size, dinfo =drive_get (IF_PFLASH ,0 , fl_idx);if (dinfo) { bios_size =bdrv_getlength (dinfo->bdrv); - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"ef405ep.bios" , bios_size); fl_sectors = (bios_size +65535 ) >>16 ;#ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx
@@ -236,7 +236,7 @@ static void ref405ep_init (ram_addr_t ram_size,#ifdef DEBUG_BOARD_INIT printf ("Load BIOS from file\n" );#endif - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ef405ep.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -509,9 +509,9 @@ static void taihu_405ep_init(ram_addr_t ram_size,DriveInfo *dinfo;/* RAM is soldered to the board so the size cannot be changed */ - ram_bases[0 ] =qemu_ram_alloc (0x04000000 ); + ram_bases[0 ] =qemu_ram_alloc (NULL ,"taihu_405ep.ram-0" ,0x04000000 ); ram_sizes[0 ] =0x04000000 ; - ram_bases[1 ] =qemu_ram_alloc (0x04000000 ); + ram_bases[1 ] =qemu_ram_alloc (NULL ,"taihu_405ep.ram-1" ,0x04000000 ); ram_sizes[1 ] =0x04000000 ; ram_size =0x08000000 ;#ifdef DEBUG_BOARD_INIT
@@ -531,7 +531,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,/* XXX: should check that size is 2MB */ // bios_size = 2 * 1024 * 1024; fl_sectors = (bios_size +65535 ) >>16 ; - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.bios" , bios_size);#ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size " TARGET_FMT_lx " at offset %08lx addr " TARGET_FMT_lx " '%s' %d\n",
@@ -551,7 +551,7 @@ static void taihu_405ep_init(ram_addr_t ram_size,#endif if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.bios" ,BIOS_SIZE ); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);if (filename) { bios_size =load_image (filename,qemu_get_ram_ptr (bios_offset));
@@ -580,7 +580,7 @@ static void taihu_405ep_init(ram_addr_t ram_size, fl_idx, bios_size, bios_offset, (target_ulong )0xfc000000 , bdrv_get_device_name(dinfo->bdrv));#endif - bios_offset =qemu_ram_alloc (bios_size); + bios_offset =qemu_ram_alloc (NULL ,"taihu_405ep.flash" , bios_size); pflash_cfi02_register(0xfc000000, bios_offset, dinfo->bdrv, 65536, fl_sectors, 1, 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA,
hw/ppc405_uc.c +1 -1
@@ -995,7 +995,7 @@ static void ppc405_ocm_init(CPUState *env)ppc405_ocm_t *ocm; ocm =qemu_mallocz (sizeof (ppc405_ocm_t)); - ocm->offset =qemu_ram_alloc (4096 ); + ocm->offset =qemu_ram_alloc (NULL ,"ppc405.ocm" ,4096 );qemu_register_reset (&ocm_reset, ocm);ppc_dcr_register (env,OCM0_ISARC , ocm, &dcr_read_ocm, &dcr_write_ocm);
hw/ppc4xx_devs.c +3 -1
@@ -668,7 +668,9 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,unsigned int bank_size = sdram_bank_sizes[j];if (bank_size <= size_left) { - ram_bases[i] =qemu_ram_alloc (bank_size); +char name[32 ]; +snprintf (name,sizeof (name),"ppc4xx.sdram%d" , i); + ram_bases[i] =qemu_ram_alloc (NULL , name, bank_size); ram_sizes[i] = bank_size; size_left -= bank_size;break ;
hw/ppc_newworld.c +3 -3
@@ -173,11 +173,11 @@ static void ppc_core99_init (ram_addr_t ram_size, }/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_core99.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_core99.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =PROM_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -198,7 +198,7 @@ static void ppc_core99_init (ram_addr_t ram_size, }/* allocate and load VGA BIOS */ - vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); + vga_bios_offset =qemu_ram_alloc (NULL ,"ppc_core99.vbios" ,VGA_BIOS_SIZE ); vga_bios_ptr =qemu_get_ram_ptr (vga_bios_offset); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,VGABIOS_FILENAME );if (filename) {
hw/ppc_oldworld.c +3 -3
@@ -179,11 +179,11 @@ static void ppc_heathrow_init (ram_addr_t ram_size,exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =PROM_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
@@ -203,7 +203,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size, }/* allocate and load VGA BIOS */ - vga_bios_offset =qemu_ram_alloc (VGA_BIOS_SIZE ); + vga_bios_offset =qemu_ram_alloc (NULL ,"ppc_heathrow.vbios" ,VGA_BIOS_SIZE ); vga_bios_ptr =qemu_get_ram_ptr (vga_bios_offset); filename =qemu_find_file (QEMU_FILE_TYPE_BIOS ,VGABIOS_FILENAME );if (filename) {
hw/ppc_prep.c +2 -2
@@ -604,11 +604,11 @@ static void ppc_prep_init (ram_addr_t ram_size, }/* allocate RAM */ - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"ppc_prep.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_offset);/* allocate and load BIOS */ - bios_offset =qemu_ram_alloc (BIOS_SIZE ); + bios_offset =qemu_ram_alloc (NULL ,"ppc_prep.bios" ,BIOS_SIZE );if (bios_name ==NULL ) bios_name =BIOS_FILENAME ; filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name);
hw/ppce500_mpc8544ds.c +2 -1
@@ -189,7 +189,8 @@ static void mpc8544ds_init(ram_addr_t ram_size, ram_size &= ~(RAM_SIZES_ALIGN -1 );/* Register Memory */ -cpu_register_physical_memory (0 , ram_size,qemu_ram_alloc (ram_size)); +cpu_register_physical_memory (0 , ram_size,qemu_ram_alloc (NULL , +"mpc8544ds.ram" , ram_size));/* MPIC */ irqs =qemu_mallocz (sizeof (qemu_irq) *OPENPIC_OUTPUT_NB );
hw/pxa2xx.c +8 -4
@@ -2054,9 +2054,11 @@ PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision)/* SDRAM & Internal Memory Storage */ cpu_register_physical_memory (PXA2XX_SDRAM_BASE , - sdram_size,qemu_ram_alloc (sdram_size) |IO_MEM_RAM ); + sdram_size,qemu_ram_alloc (NULL ,"pxa270.sdram" , + sdram_size) |IO_MEM_RAM );cpu_register_physical_memory (PXA2XX_INTERNAL_BASE , -0x40000 ,qemu_ram_alloc (0x40000 ) |IO_MEM_RAM ); +0x40000 ,qemu_ram_alloc (NULL ,"pxa270.internal" , +0x40000 ) |IO_MEM_RAM ); s->pic =pxa2xx_pic_init (0x40d00000 , s->env);
@@ -2175,9 +2177,11 @@ PXA2xxState *pxa255_init(unsigned int sdram_size)/* SDRAM & Internal Memory Storage */ cpu_register_physical_memory (PXA2XX_SDRAM_BASE , sdram_size, -qemu_ram_alloc (sdram_size) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"pxa255.sdram" , + sdram_size) |IO_MEM_RAM );cpu_register_physical_memory (PXA2XX_INTERNAL_BASE ,PXA2XX_INTERNAL_SIZE , -qemu_ram_alloc (PXA2XX_INTERNAL_SIZE ) |IO_MEM_RAM ); +qemu_ram_alloc (NULL ,"pxa255.internal" , +PXA2XX_INTERNAL_SIZE ) |IO_MEM_RAM ); s->pic =pxa2xx_pic_init (0x40d00000 , s->env);
hw/r2d.c +2 -2
@@ -242,7 +242,7 @@ static void r2d_init(ram_addr_t ram_size, }/* Allocate memory space */ - sdram_addr =qemu_ram_alloc (SDRAM_SIZE ); + sdram_addr =qemu_ram_alloc (NULL ,"r2d.sdram" ,SDRAM_SIZE );cpu_register_physical_memory (SDRAM_BASE ,SDRAM_SIZE , sdram_addr);/* Register peripherals */ s =sh7750_init (env);
@@ -258,7 +258,7 @@ static void r2d_init(ram_addr_t ram_size,/* onboard flash memory */ dinfo =drive_get (IF_PFLASH ,0 ,0 ); - pflash_cfi02_register(0x0, qemu_ram_alloc(FLASH_SIZE), + pflash_cfi02_register(0x0, qemu_ram_alloc(NULL, "r2d.flash", FLASH_SIZE), dinfo ? dinfo->bdrv : NULL, (16 * 1024), FLASH_SIZE >> 16, 1, 4, 0x0000, 0x0000, 0x0000, 0x0000,
hw/realview.c +3 -3
@@ -196,12 +196,12 @@ static void realview_init(ram_addr_t ram_size,/* Core tile RAM. */ low_ram_size = ram_size -0x20000000 ; ram_size =0x20000000 ; - ram_offset =qemu_ram_alloc (low_ram_size); + ram_offset =qemu_ram_alloc (NULL ,"realview.lowmem" , low_ram_size);cpu_register_physical_memory (0x20000000 , low_ram_size, ram_offset |IO_MEM_RAM ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"realview.highmem" , ram_size); low_ram_size = ram_size;if (low_ram_size >0x10000000 ) low_ram_size =0x10000000 ;
@@ -354,7 +354,7 @@ static void realview_init(ram_addr_t ram_size,startup code. I guess this works on real hardware because the BootROM happens to be in ROM/flash or in memory that isn't clobbered until after Linux boots the secondary CPUs. */ - ram_offset =qemu_ram_alloc (0x1000 ); + ram_offset =qemu_ram_alloc (NULL ,"realview.hack" ,0x1000 );cpu_register_physical_memory (SMP_BOOT_ADDR ,0x1000 , ram_offset |IO_MEM_RAM );
hw/s390-virtio.c +1 -1
@@ -157,7 +157,7 @@ static void s390_init(ram_addr_t ram_size, s390_bus =s390_virtio_bus_init (&ram_size);/* allocate RAM */ - ram_addr =qemu_ram_alloc (ram_size); + ram_addr =qemu_ram_alloc (NULL ,"s390.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_addr);/* init CPUs */
hw/sm501.c +1 -1
@@ -1371,7 +1371,7 @@ void sm501_init(uint32_t base, uint32_t local_mem_bytes, qemu_irq irq, s->dc_crt_control =0x00010000 ;/* allocate local memory */ - s->local_mem_offset =qemu_ram_alloc (local_mem_bytes); + s->local_mem_offset =qemu_ram_alloc (NULL ,"sm501.local" , local_mem_bytes); s->local_mem =qemu_get_ram_ptr (s->local_mem_offset);cpu_register_physical_memory (base, local_mem_bytes, s->local_mem_offset);
hw/spitz.c +1 -1
@@ -962,7 +962,7 @@ static void spitz_common_init(ram_addr_t ram_size,sl_flash_register (cpu, (model == spitz) ?FLASH_128M :FLASH_1024M );cpu_register_physical_memory (0 ,SPITZ_ROM , -qemu_ram_alloc (SPITZ_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"spitz.rom" ,SPITZ_ROM ) |IO_MEM_ROM );/* Setup peripherals */ spitz_keyboard_register (cpu);
hw/sun4m.c +4 -4
@@ -592,7 +592,7 @@ static int idreg_init1(SysBusDevice *dev) {ram_addr_t idreg_offset; - idreg_offset =qemu_ram_alloc (sizeof (idreg_data)); + idreg_offset =qemu_ram_alloc (NULL ,"sun4m.idreg" ,sizeof (idreg_data));sysbus_init_mmio (dev,sizeof (idreg_data), idreg_offset |IO_MEM_ROM );return 0 ; }
@@ -627,7 +627,7 @@ static int afx_init1(SysBusDevice *dev) {ram_addr_t afx_offset; - afx_offset =qemu_ram_alloc (4 ); + afx_offset =qemu_ram_alloc (NULL ,"sun4m.afx" ,4 );sysbus_init_mmio (dev,4 , afx_offset |IO_MEM_RAM );return 0 ; }
@@ -690,7 +690,7 @@ static int prom_init1(SysBusDevice *dev) {ram_addr_t prom_offset; - prom_offset =qemu_ram_alloc (PROM_SIZE_MAX ); + prom_offset =qemu_ram_alloc (NULL ,"sun4m.prom" ,PROM_SIZE_MAX );sysbus_init_mmio (dev,PROM_SIZE_MAX , prom_offset |IO_MEM_ROM );return 0 ; }
@@ -725,7 +725,7 @@ static int ram_init1(SysBusDevice *dev) RAM_size = d->size; - ram_offset =qemu_ram_alloc (RAM_size); + ram_offset =qemu_ram_alloc (NULL ,"sun4m.ram" , RAM_size);sysbus_init_mmio (dev, RAM_size, ram_offset);return 0 ; }
hw/sun4u.c +2 -2
@@ -629,7 +629,7 @@ static int prom_init1(SysBusDevice *dev) {ram_addr_t prom_offset; - prom_offset =qemu_ram_alloc (PROM_SIZE_MAX ); + prom_offset =qemu_ram_alloc (NULL ,"sun4u.prom" ,PROM_SIZE_MAX );sysbus_init_mmio (dev,PROM_SIZE_MAX , prom_offset |IO_MEM_ROM );return 0 ; }
@@ -665,7 +665,7 @@ static int ram_init1(SysBusDevice *dev) RAM_size = d->size; - ram_offset =qemu_ram_alloc (RAM_size); + ram_offset =qemu_ram_alloc (NULL ,"sun4u.ram" , RAM_size);sysbus_init_mmio (dev, RAM_size, ram_offset);return 0 ; }
hw/syborg.c +1 -1
@@ -51,7 +51,7 @@ static void syborg_init(ram_addr_t ram_size, }/* RAM at address zero. */ - ram_addr =qemu_ram_alloc (ram_size); + ram_addr =qemu_ram_alloc (NULL ,"syborg.ram" , ram_size);cpu_register_physical_memory (0 , ram_size, ram_addr |IO_MEM_RAM ); cpu_pic =arm_pic_init_cpu (env);
hw/tc6393xb.c +1 -1
@@ -593,7 +593,7 @@ TC6393xbState *tc6393xb_init(uint32_t base, qemu_irq irq) tc6393xb_writefn, s);cpu_register_physical_memory (base,0x10000 , iomemtype); - s->vram_addr =qemu_ram_alloc (0x100000 ); + s->vram_addr =qemu_ram_alloc (NULL ,"tc6393xb.vram" ,0x100000 ); s->vram_ptr =qemu_get_ram_ptr (s->vram_addr);cpu_register_physical_memory (base +0x100000 ,0x100000 , s->vram_addr); s->scr_width =480 ;
hw/tcx.c +1 -1
@@ -510,7 +510,7 @@ static int tcx_init1(SysBusDevice *dev)int size;uint8_t *vram_base; - vram_offset =qemu_ram_alloc (s->vram_size * (1 +4 +4 )); + vram_offset =qemu_ram_alloc (NULL ,"tcx.vram" , s->vram_size * (1 +4 +4 )); vram_base =qemu_get_ram_ptr (vram_offset); s->vram_offset = vram_offset;
hw/tosa.c +1 -1
@@ -215,7 +215,7 @@ static void tosa_init(ram_addr_t ram_size, cpu =pxa255_init (tosa_binfo.ram_size);cpu_register_physical_memory (0 ,TOSA_ROM , -qemu_ram_alloc (TOSA_ROM ) |IO_MEM_ROM ); +qemu_ram_alloc (NULL ,"tosa.rom" ,TOSA_ROM ) |IO_MEM_ROM ); tmio =tc6393xb_init (0x10000000 ,pxa2xx_gpio_in_get (cpu->gpio)[TOSA_GPIO_TC6393XB_INT ]);
hw/versatilepb.c +1 -1
@@ -180,7 +180,7 @@ static void versatile_init(ram_addr_t ram_size,fprintf (stderr,"Unable to find CPU definition\n" );exit (1 ); } - ram_offset =qemu_ram_alloc (ram_size); + ram_offset =qemu_ram_alloc (NULL ,"versatile.ram" , ram_size);/* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ cpu_register_physical_memory (0 , ram_size, ram_offset |IO_MEM_RAM );
hw/vga.c +1 -1
@@ -2261,7 +2261,7 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)#else s->is_vbe_vmstate =0 ;#endif - s->vram_offset =qemu_ram_alloc (vga_ram_size); + s->vram_offset =qemu_ram_alloc (NULL ,"vga.vram" , vga_ram_size); s->vram_ptr =qemu_get_ram_ptr (s->vram_offset); s->vram_size = vga_ram_size; s->get_bpp = vga_get_bpp;
hw/vmware_vga.c +1 -1
@@ -1164,7 +1164,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) s->fifo_size =SVGA_FIFO_SIZE ; - s->fifo_offset =qemu_ram_alloc (s->fifo_size); + s->fifo_offset =qemu_ram_alloc (NULL ,"vmsvga.fifo" , s->fifo_size); s->fifo_ptr =qemu_get_ram_ptr (s->fifo_offset);vga_common_init (&s->vga, vga_ram_size);
PATCH v3 10/16 ramblocks: Make use of DeviceState pointer and BusInfo.get_dev_path
In reply to Alex WilliamsonWith these two pieces in place, we can start naming ramblocks. When the device is present and it lives on a bus that provides a device path, we concatenate the path and the provided name. Otherwise we just use name. The resulting id string must be unique. For now we assume an allocation for the same name and size is a device that has been removed and reinserted and return the same block. This will go away once qemu_ram_free() is implemented.
---
cpu-all.h | 1 + exec.c | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-)
cpu-all.h +1 -0
@@ -865,6 +865,7 @@ typedef struct RAMBlock {uint8_t *host;ram_addr_t offset;ram_addr_t length; +char idstr[256 ];QLIST_ENTRY (RAMBlock) next; } RAMBlock;
exec.c +27 -2
@@ -36,6 +36,7 @@#include "qemu-common.h" #include "tcg.h" #include "hw/hw.h" +#include "hw/qdev.h" #include "osdep.h" #include "kvm.h" #include "qemu-timer.h"
@@ -2780,10 +2781,34 @@ static ram_addr_t find_ram_offset(ram_addr_t size)ram_addr_t qemu_ram_alloc (DeviceState *dev,const char *name,ram_addr_t size) { -RAMBlock *new_block; +RAMBlock *new_block, *block; size =TARGET_PAGE_ALIGN (size); - new_block =qemu_malloc (sizeof (*new_block)); + new_block =qemu_mallocz (sizeof (*new_block)); + +if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { +char *id = dev->parent_bus->info->get_dev_path (dev); +if (id) { +snprintf (new_block->idstr,sizeof (new_block->idstr),"%s/" , id); +qemu_free (id); + } + } +pstrcat (new_block->idstr,sizeof (new_block->idstr), name); + + QLIST_FOREACH(block, &ram_list.blocks, next) { +if (!strcmp (block->idstr, new_block->idstr)) { +if (block->length == new_block->length) { +fprintf (stderr,"RAMBlock \"%s\" exists, assuming lack of" +"free.\n" , new_block->idstr); +qemu_free (new_block); +return block->offset; + }else { +fprintf (stderr,"RAMBlock \"%s\" already registered with" +"different size, abort\n" , new_block->idstr); +abort (); + } + } + }if (mem_path) {#if defined (__linux__) && !defined(TARGET_S390X )