Skip to content

Commit

Permalink
savevm: Add DeviceState param
Browse files Browse the repository at this point in the history
When 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.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
awilliam authored and Anthony Liguori committed Jul 6, 2010
1 parent 4f43c1f commit 0be71e3
Show file tree
Hide file tree
Showing 85 changed files with 163 additions and 138 deletions.
2 changes: 1 addition & 1 deletion audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions block-migration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions hw/adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion hw/ads7846.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/arm_gic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions hw/arm_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/armv7m_nvic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/cirrus_vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down
2 changes: 1 addition & 1 deletion hw/cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions hw/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions hw/eepro100.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions hw/eeprom93xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(0, &vmstate_eeprom, eeprom);
vmstate_register(NULL, 0, &vmstate_eeprom, eeprom);
return eeprom;
}

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);
}

Expand Down
2 changes: 1 addition & 1 deletion hw/g364fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions hw/grackle_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion hw/gt64xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion hw/heathrow_pic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 11 additions & 7 deletions hw/hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion hw/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/i8254.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion hw/i8259.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion hw/ide/cmd646.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion hw/ide/isa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion hw/ide/macio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion hw/ide/microdrive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion hw/ide/mmio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

2 changes: 1 addition & 1 deletion hw/ide/piix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion hw/m48t59.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion hw/mac_dbdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions hw/mac_nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion hw/max111x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion hw/mips_fulong2e.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions hw/mipsnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
3 changes: 2 additions & 1 deletion hw/mst_fpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Loading

0 comments on commit 0be71e3

Please sign in to comment.