migration: pre_save return int

Modify the pre_save method on VMStateDescription to return an int
rather than void so that it potentially can fail.

Changed zillions of devices to make them return 0; the only
case I've made it return non-0 is hw/intc/s390_flic_kvm.c that already
had an error_report/return case.

Note: If you add an error exit in your pre_save you must emit
an error_report to say why.

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20170925112917.21340-2-dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
Dr. David Alan Gilbert 2017-09-25 12:29:12 +01:00
parent 9ac78b6171
commit 44b1ff319c
59 changed files with 199 additions and 70 deletions

View File

@ -202,7 +202,7 @@ The functions to do that are inside a vmstate definition, and are called:
This function is called after we load the state of one device. This function is called after we load the state of one device.
- void (*pre_save)(void *opaque); - int (*pre_save)(void *opaque);
This function is called before we save the state of one device. This function is called before we save the state of one device.

View File

@ -1143,13 +1143,15 @@ static void pxa2xx_rtc_init(Object *obj)
sysbus_init_mmio(dev, &s->iomem); sysbus_init_mmio(dev, &s->iomem);
} }
static void pxa2xx_rtc_pre_save(void *opaque) static int pxa2xx_rtc_pre_save(void *opaque)
{ {
PXA2xxRTCState *s = (PXA2xxRTCState *) opaque; PXA2xxRTCState *s = (PXA2xxRTCState *) opaque;
pxa2xx_rtc_hzupdate(s); pxa2xx_rtc_hzupdate(s);
pxa2xx_rtc_piupdate(s); pxa2xx_rtc_piupdate(s);
pxa2xx_rtc_swupdate(s); pxa2xx_rtc_swupdate(s);
return 0;
} }
static int pxa2xx_rtc_post_load(void *opaque, int version_id) static int pxa2xx_rtc_post_load(void *opaque, int version_id)

View File

@ -406,11 +406,13 @@ static void strongarm_rtc_init(Object *obj)
sysbus_init_mmio(dev, &s->iomem); sysbus_init_mmio(dev, &s->iomem);
} }
static void strongarm_rtc_pre_save(void *opaque) static int strongarm_rtc_pre_save(void *opaque)
{ {
StrongARMRTCState *s = opaque; StrongARMRTCState *s = opaque;
strongarm_rtc_hzupdate(s); strongarm_rtc_hzupdate(s);
return 0;
} }
static int strongarm_rtc_post_load(void *opaque, int version_id) static int strongarm_rtc_post_load(void *opaque, int version_id)

View File

@ -567,11 +567,13 @@ static int wm8750_rx(I2CSlave *i2c)
return 0x00; return 0x00;
} }
static void wm8750_pre_save(void *opaque) static int wm8750_pre_save(void *opaque)
{ {
WM8750State *s = opaque; WM8750State *s = opaque;
s->rate_vmstate = s->rate - wm_rate_table; s->rate_vmstate = s->rate - wm_rate_table;
return 0;
} }
static int wm8750_post_load(void *opaque, int version_id) static int wm8750_post_load(void *opaque, int version_id)

View File

@ -1101,11 +1101,13 @@ static int reconstruct_phase(FDCtrl *fdctrl)
} }
} }
static void fdc_pre_save(void *opaque) static int fdc_pre_save(void *opaque)
{ {
FDCtrl *s = opaque; FDCtrl *s = opaque;
s->dor_vmstate = s->dor | GET_CUR_DRV(s); s->dor_vmstate = s->dor | GET_CUR_DRV(s);
return 0;
} }
static int fdc_pre_load(void *opaque) static int fdc_pre_load(void *opaque)

View File

@ -1251,9 +1251,11 @@ static void m25p80_reset(DeviceState *d)
reset_memory(s); reset_memory(s);
} }
static void m25p80_pre_save(void *opaque) static int m25p80_pre_save(void *opaque)
{ {
flash_sync_dirty((Flash *)opaque, -1); flash_sync_dirty((Flash *)opaque, -1);
return 0;
} }
static Property m25p80_properties[] = { static Property m25p80_properties[] = {

View File

@ -325,11 +325,13 @@ static void nand_command(NANDFlashState *s)
} }
} }
static void nand_pre_save(void *opaque) static int nand_pre_save(void *opaque)
{ {
NANDFlashState *s = NAND(opaque); NANDFlashState *s = NAND(opaque);
s->ioaddr_vmstate = s->ioaddr - s->io; s->ioaddr_vmstate = s->ioaddr - s->io;
return 0;
} }
static int nand_post_load(void *opaque, int version_id) static int nand_post_load(void *opaque, int version_id)

View File

@ -137,7 +137,7 @@ static void onenand_intr_update(OneNANDState *s)
qemu_set_irq(s->intr, ((s->intstatus >> 15) ^ (~s->config[0] >> 6)) & 1); qemu_set_irq(s->intr, ((s->intstatus >> 15) ^ (~s->config[0] >> 6)) & 1);
} }
static void onenand_pre_save(void *opaque) static int onenand_pre_save(void *opaque)
{ {
OneNANDState *s = opaque; OneNANDState *s = opaque;
if (s->current == s->otp) { if (s->current == s->otp) {
@ -147,6 +147,8 @@ static void onenand_pre_save(void *opaque)
} else { } else {
s->current_direction = 0; s->current_direction = 0;
} }
return 0;
} }
static int onenand_post_load(void *opaque, int version_id) static int onenand_post_load(void *opaque, int version_id)

View File

@ -630,10 +630,12 @@ static void serial_event(void *opaque, int event)
serial_receive_break(s); serial_receive_break(s);
} }
static void serial_pre_save(void *opaque) static int serial_pre_save(void *opaque)
{ {
SerialState *s = opaque; SerialState *s = opaque;
s->fcr_vmstate = s->fcr; s->fcr_vmstate = s->fcr;
return 0;
} }
static int serial_pre_load(void *opaque) static int serial_pre_load(void *opaque)

View File

@ -2204,7 +2204,7 @@ static void qxl_realize_secondary(PCIDevice *dev, Error **errp)
qxl_realize_common(qxl, errp); qxl_realize_common(qxl, errp);
} }
static void qxl_pre_save(void *opaque) static int qxl_pre_save(void *opaque)
{ {
PCIQXLDevice* d = opaque; PCIQXLDevice* d = opaque;
uint8_t *ram_start = d->vga.vram_ptr; uint8_t *ram_start = d->vga.vram_ptr;
@ -2216,6 +2216,8 @@ static void qxl_pre_save(void *opaque)
d->last_release_offset = (uint8_t *)d->last_release - ram_start; d->last_release_offset = (uint8_t *)d->last_release - ram_start;
} }
assert(d->last_release_offset < d->vga.vram_size); assert(d->last_release_offset < d->vga.vram_size);
return 0;
} }
static int qxl_pre_load(void *opaque) static int qxl_pre_load(void *opaque)

View File

@ -41,7 +41,7 @@ static const TypeInfo i2c_bus_info = {
.instance_size = sizeof(I2CBus), .instance_size = sizeof(I2CBus),
}; };
static void i2c_bus_pre_save(void *opaque) static int i2c_bus_pre_save(void *opaque)
{ {
I2CBus *bus = opaque; I2CBus *bus = opaque;
@ -53,6 +53,8 @@ static void i2c_bus_pre_save(void *opaque)
bus->saved_address = I2C_BROADCAST; bus->saved_address = I2C_BROADCAST;
} }
} }
return 0;
} }
static const VMStateDescription vmstate_i2c_bus = { static const VMStateDescription vmstate_i2c_bus = {

View File

@ -254,11 +254,13 @@ static const VMStateDescription kvmclock_reliable_get_clock = {
* final pages of memory (which happens between vm_stop() * final pages of memory (which happens between vm_stop()
* and pre_save()) takes max_downtime. * and pre_save()) takes max_downtime.
*/ */
static void kvmclock_pre_save(void *opaque) static int kvmclock_pre_save(void *opaque)
{ {
KVMClockState *s = opaque; KVMClockState *s = opaque;
kvm_update_clock(s); kvm_update_clock(s);
return 0;
} }
static const VMStateDescription kvmclock_vmsd = { static const VMStateDescription kvmclock_vmsd = {

View File

@ -2752,7 +2752,7 @@ static int ide_drive_pio_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void ide_drive_pio_pre_save(void *opaque) static int ide_drive_pio_pre_save(void *opaque)
{ {
IDEState *s = opaque; IDEState *s = opaque;
int idx; int idx;
@ -2768,6 +2768,8 @@ static void ide_drive_pio_pre_save(void *opaque)
} else { } else {
s->end_transfer_fn_idx = idx; s->end_transfer_fn_idx = idx;
} }
return 0;
} }
static bool ide_drive_pio_state_needed(void *opaque) static bool ide_drive_pio_state_needed(void *opaque)

View File

@ -296,7 +296,7 @@ static bool ide_bmdma_status_needed(void *opaque)
return ((bm->status & abused_bits) != 0); return ((bm->status & abused_bits) != 0);
} }
static void ide_bmdma_pre_save(void *opaque) static int ide_bmdma_pre_save(void *opaque)
{ {
BMDMAState *bm = opaque; BMDMAState *bm = opaque;
uint8_t abused_bits = BM_MIGRATION_COMPAT_STATUS_BITS; uint8_t abused_bits = BM_MIGRATION_COMPAT_STATUS_BITS;
@ -310,6 +310,8 @@ static void ide_bmdma_pre_save(void *opaque)
bm->migration_retry_nsector = bm->bus->retry_nsector; bm->migration_retry_nsector = bm->bus->retry_nsector;
bm->migration_compat_status = bm->migration_compat_status =
(bm->status & ~abused_bits) | (bm->bus->error_status & abused_bits); (bm->status & ~abused_bits) | (bm->bus->error_status & abused_bits);
return 0;
} }
/* This function accesses bm->bus->error_status which is loaded only after /* This function accesses bm->bus->error_status which is loaded only after

View File

@ -1216,12 +1216,14 @@ static int ps2_kbd_post_load(void* opaque, int version_id)
return 0; return 0;
} }
static void ps2_kbd_pre_save(void *opaque) static int ps2_kbd_pre_save(void *opaque)
{ {
PS2KbdState *s = (PS2KbdState *)opaque; PS2KbdState *s = (PS2KbdState *)opaque;
PS2State *ps2 = &s->common; PS2State *ps2 = &s->common;
ps2_common_post_load(ps2); ps2_common_post_load(ps2);
return 0;
} }
static const VMStateDescription vmstate_ps2_keyboard = { static const VMStateDescription vmstate_ps2_keyboard = {
@ -1254,12 +1256,14 @@ static int ps2_mouse_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void ps2_mouse_pre_save(void *opaque) static int ps2_mouse_pre_save(void *opaque)
{ {
PS2MouseState *s = (PS2MouseState *)opaque; PS2MouseState *s = (PS2MouseState *)opaque;
PS2State *ps2 = &s->common; PS2State *ps2 = &s->common;
ps2_common_post_load(ps2); ps2_common_post_load(ps2);
return 0;
} }
static const VMStateDescription vmstate_ps2_mouse = { static const VMStateDescription vmstate_ps2_mouse = {

View File

@ -976,10 +976,12 @@ static void tsc210x_i2s_set_rate(TSC210xState *s, int in, int out)
s->i2s_rx_rate = in; s->i2s_rx_rate = in;
} }
static void tsc210x_pre_save(void *opaque) static int tsc210x_pre_save(void *opaque)
{ {
TSC210xState *s = (TSC210xState *) opaque; TSC210xState *s = (TSC210xState *) opaque;
s->now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); s->now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
return 0;
} }
static int tsc210x_post_load(void *opaque, int version_id) static int tsc210x_post_load(void *opaque, int version_id)

View File

@ -360,7 +360,7 @@ static int apic_pre_load(void *opaque)
return 0; return 0;
} }
static void apic_dispatch_pre_save(void *opaque) static int apic_dispatch_pre_save(void *opaque)
{ {
APICCommonState *s = APIC_COMMON(opaque); APICCommonState *s = APIC_COMMON(opaque);
APICCommonClass *info = APIC_COMMON_GET_CLASS(s); APICCommonClass *info = APIC_COMMON_GET_CLASS(s);
@ -368,6 +368,8 @@ static void apic_dispatch_pre_save(void *opaque)
if (info->pre_save) { if (info->pre_save) {
info->pre_save(s); info->pre_save(s);
} }
return 0;
} }
static int apic_dispatch_post_load(void *opaque, int version_id) static int apic_dispatch_post_load(void *opaque, int version_id)

View File

@ -23,7 +23,7 @@
#include "gic_internal.h" #include "gic_internal.h"
#include "hw/arm/linux-boot-if.h" #include "hw/arm/linux-boot-if.h"
static void gic_pre_save(void *opaque) static int gic_pre_save(void *opaque)
{ {
GICState *s = (GICState *)opaque; GICState *s = (GICState *)opaque;
ARMGICCommonClass *c = ARM_GIC_COMMON_GET_CLASS(s); ARMGICCommonClass *c = ARM_GIC_COMMON_GET_CLASS(s);
@ -31,6 +31,8 @@ static void gic_pre_save(void *opaque)
if (c->pre_save) { if (c->pre_save) {
c->pre_save(s); c->pre_save(s);
} }
return 0;
} }
static int gic_post_load(void *opaque, int version_id) static int gic_post_load(void *opaque, int version_id)

View File

@ -28,7 +28,7 @@
#include "gicv3_internal.h" #include "gicv3_internal.h"
#include "hw/arm/linux-boot-if.h" #include "hw/arm/linux-boot-if.h"
static void gicv3_pre_save(void *opaque) static int gicv3_pre_save(void *opaque)
{ {
GICv3State *s = (GICv3State *)opaque; GICv3State *s = (GICv3State *)opaque;
ARMGICv3CommonClass *c = ARM_GICV3_COMMON_GET_CLASS(s); ARMGICv3CommonClass *c = ARM_GICV3_COMMON_GET_CLASS(s);
@ -36,6 +36,8 @@ static void gicv3_pre_save(void *opaque)
if (c->pre_save) { if (c->pre_save) {
c->pre_save(s); c->pre_save(s);
} }
return 0;
} }
static int gicv3_post_load(void *opaque, int version_id) static int gicv3_post_load(void *opaque, int version_id)

View File

@ -23,7 +23,7 @@
#include "hw/intc/arm_gicv3_its_common.h" #include "hw/intc/arm_gicv3_its_common.h"
#include "qemu/log.h" #include "qemu/log.h"
static void gicv3_its_pre_save(void *opaque) static int gicv3_its_pre_save(void *opaque)
{ {
GICv3ITSState *s = (GICv3ITSState *)opaque; GICv3ITSState *s = (GICv3ITSState *)opaque;
GICv3ITSCommonClass *c = ARM_GICV3_ITS_COMMON_GET_CLASS(s); GICv3ITSCommonClass *c = ARM_GICV3_ITS_COMMON_GET_CLASS(s);
@ -31,6 +31,8 @@ static void gicv3_its_pre_save(void *opaque)
if (c->pre_save) { if (c->pre_save) {
c->pre_save(s); c->pre_save(s);
} }
return 0;
} }
static int gicv3_its_post_load(void *opaque, int version_id) static int gicv3_its_post_load(void *opaque, int version_id)

View File

@ -46,7 +46,7 @@ void pic_reset_common(PICCommonState *s)
/* Note: ELCR is not reset */ /* Note: ELCR is not reset */
} }
static void pic_dispatch_pre_save(void *opaque) static int pic_dispatch_pre_save(void *opaque)
{ {
PICCommonState *s = opaque; PICCommonState *s = opaque;
PICCommonClass *info = PIC_COMMON_GET_CLASS(s); PICCommonClass *info = PIC_COMMON_GET_CLASS(s);
@ -54,6 +54,8 @@ static void pic_dispatch_pre_save(void *opaque)
if (info->pre_save) { if (info->pre_save) {
info->pre_save(s); info->pre_save(s);
} }
return 0;
} }
static int pic_dispatch_post_load(void *opaque, int version_id) static int pic_dispatch_post_load(void *opaque, int version_id)

View File

@ -102,7 +102,7 @@ void ioapic_reset_common(DeviceState *dev)
} }
} }
static void ioapic_dispatch_pre_save(void *opaque) static int ioapic_dispatch_pre_save(void *opaque)
{ {
IOAPICCommonState *s = IOAPIC_COMMON(opaque); IOAPICCommonState *s = IOAPIC_COMMON(opaque);
IOAPICCommonClass *info = IOAPIC_COMMON_GET_CLASS(s); IOAPICCommonClass *info = IOAPIC_COMMON_GET_CLASS(s);
@ -110,6 +110,8 @@ static void ioapic_dispatch_pre_save(void *opaque)
if (info->pre_save) { if (info->pre_save) {
info->pre_save(s); info->pre_save(s);
} }
return 0;
} }
static int ioapic_dispatch_post_load(void *opaque, int version_id) static int ioapic_dispatch_post_load(void *opaque, int version_id)

View File

@ -420,7 +420,7 @@ typedef struct KVMS390FLICStateMigTmp {
uint8_t nimm; uint8_t nimm;
} KVMS390FLICStateMigTmp; } KVMS390FLICStateMigTmp;
static void kvm_flic_ais_pre_save(void *opaque) static int kvm_flic_ais_pre_save(void *opaque)
{ {
KVMS390FLICStateMigTmp *tmp = opaque; KVMS390FLICStateMigTmp *tmp = opaque;
KVMS390FLICState *flic = tmp->parent; KVMS390FLICState *flic = tmp->parent;
@ -433,11 +433,13 @@ static void kvm_flic_ais_pre_save(void *opaque)
if (ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr)) { if (ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr)) {
error_report("Failed to retrieve kvm flic ais states"); error_report("Failed to retrieve kvm flic ais states");
return; return -EINVAL;
} }
tmp->simm = ais.simm; tmp->simm = ais.simm;
tmp->nimm = ais.nimm; tmp->nimm = ais.nimm;
return 0;
} }
static int kvm_flic_ais_post_load(void *opaque, int version_id) static int kvm_flic_ais_post_load(void *opaque, int version_id)

View File

@ -241,7 +241,7 @@ static void icp_irq(ICSState *ics, int server, int nr, uint8_t priority)
} }
} }
static void icp_dispatch_pre_save(void *opaque) static int icp_dispatch_pre_save(void *opaque)
{ {
ICPState *icp = opaque; ICPState *icp = opaque;
ICPStateClass *info = ICP_GET_CLASS(icp); ICPStateClass *info = ICP_GET_CLASS(icp);
@ -249,6 +249,8 @@ static void icp_dispatch_pre_save(void *opaque)
if (info->pre_save) { if (info->pre_save) {
info->pre_save(icp); info->pre_save(icp);
} }
return 0;
} }
static int icp_dispatch_post_load(void *opaque, int version_id) static int icp_dispatch_post_load(void *opaque, int version_id)
@ -533,7 +535,7 @@ static void ics_simple_reset(void *dev)
} }
} }
static void ics_simple_dispatch_pre_save(void *opaque) static int ics_simple_dispatch_pre_save(void *opaque)
{ {
ICSState *ics = opaque; ICSState *ics = opaque;
ICSStateClass *info = ICS_BASE_GET_CLASS(ics); ICSStateClass *info = ICS_BASE_GET_CLASS(ics);
@ -541,6 +543,8 @@ static void ics_simple_dispatch_pre_save(void *opaque)
if (info->pre_save) { if (info->pre_save) {
info->pre_save(ics); info->pre_save(ics);
} }
return 0;
} }
static int ics_simple_dispatch_post_load(void *opaque, int version_id) static int ics_simple_dispatch_post_load(void *opaque, int version_id)

View File

@ -1343,7 +1343,7 @@ static bool is_version_1(void *opaque, int version_id)
return version_id == 1; return version_id == 1;
} }
static void e1000_pre_save(void *opaque) static int e1000_pre_save(void *opaque)
{ {
E1000State *s = opaque; E1000State *s = opaque;
NetClientState *nc = qemu_get_queue(s->nic); NetClientState *nc = qemu_get_queue(s->nic);
@ -1361,6 +1361,8 @@ static void e1000_pre_save(void *opaque)
if (nc->link_down && have_autoneg(s)) { if (nc->link_down && have_autoneg(s)) {
s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE; s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
} }
return 0;
} }
static int e1000_post_load(void *opaque, int version_id) static int e1000_post_load(void *opaque, int version_id)

View File

@ -523,13 +523,15 @@ static void e1000e_qdev_reset(DeviceState *dev)
e1000e_core_reset(&s->core); e1000e_core_reset(&s->core);
} }
static void e1000e_pre_save(void *opaque) static int e1000e_pre_save(void *opaque)
{ {
E1000EState *s = opaque; E1000EState *s = opaque;
trace_e1000e_cb_pre_save(); trace_e1000e_cb_pre_save();
e1000e_core_pre_save(&s->core); e1000e_core_pre_save(&s->core);
return 0;
} }
static int e1000e_post_load(void *opaque, int version_id) static int e1000e_post_load(void *opaque, int version_id)

View File

@ -3162,7 +3162,7 @@ static const VMStateDescription vmstate_rtl8139_hotplug_ready ={
} }
}; };
static void rtl8139_pre_save(void *opaque) static int rtl8139_pre_save(void *opaque)
{ {
RTL8139State* s = opaque; RTL8139State* s = opaque;
int64_t current_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); int64_t current_time = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
@ -3170,6 +3170,8 @@ static void rtl8139_pre_save(void *opaque)
/* for migration to older versions */ /* for migration to older versions */
s->TCTR = (current_time - s->TCTR_base) / PCI_PERIOD; s->TCTR = (current_time - s->TCTR_base) / PCI_PERIOD;
s->rtl8139_mmio_io_addr_dummy = 0; s->rtl8139_mmio_io_addr_dummy = 0;
return 0;
} }
static const VMStateDescription vmstate_rtl8139 = { static const VMStateDescription vmstate_rtl8139 = {

View File

@ -1712,7 +1712,7 @@ struct VirtIONetMigTmp {
* pointer and count and also validate the count. * pointer and count and also validate the count.
*/ */
static void virtio_net_tx_waiting_pre_save(void *opaque) static int virtio_net_tx_waiting_pre_save(void *opaque)
{ {
struct VirtIONetMigTmp *tmp = opaque; struct VirtIONetMigTmp *tmp = opaque;
@ -1721,6 +1721,8 @@ static void virtio_net_tx_waiting_pre_save(void *opaque)
if (tmp->parent->curr_queues == 0) { if (tmp->parent->curr_queues == 0) {
tmp->curr_queues_1 = 0; tmp->curr_queues_1 = 0;
} }
return 0;
} }
static int virtio_net_tx_waiting_pre_load(void *opaque) static int virtio_net_tx_waiting_pre_load(void *opaque)
@ -1768,11 +1770,13 @@ static int virtio_net_ufo_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void virtio_net_ufo_pre_save(void *opaque) static int virtio_net_ufo_pre_save(void *opaque)
{ {
struct VirtIONetMigTmp *tmp = opaque; struct VirtIONetMigTmp *tmp = opaque;
tmp->has_ufo = tmp->parent->has_ufo; tmp->has_ufo = tmp->parent->has_ufo;
return 0;
} }
static const VMStateDescription vmstate_virtio_net_has_ufo = { static const VMStateDescription vmstate_virtio_net_has_ufo = {
@ -1800,11 +1804,13 @@ static int virtio_net_vnet_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void virtio_net_vnet_pre_save(void *opaque) static int virtio_net_vnet_pre_save(void *opaque)
{ {
struct VirtIONetMigTmp *tmp = opaque; struct VirtIONetMigTmp *tmp = opaque;
tmp->has_vnet_hdr = tmp->parent->has_vnet_hdr; tmp->has_vnet_hdr = tmp->parent->has_vnet_hdr;
return 0;
} }
static const VMStateDescription vmstate_virtio_net_has_vnet = { static const VMStateDescription vmstate_virtio_net_has_vnet = {
@ -2079,13 +2085,15 @@ static void virtio_net_instance_init(Object *obj)
DEVICE(n), NULL); DEVICE(n), NULL);
} }
static void virtio_net_pre_save(void *opaque) static int virtio_net_pre_save(void *opaque)
{ {
VirtIONet *n = opaque; VirtIONet *n = opaque;
/* At this point, backend must be stopped, otherwise /* At this point, backend must be stopped, otherwise
* it might keep writing to memory. */ * it might keep writing to memory. */
assert(!n->vhost_started); assert(!n->vhost_started);
return 0;
} }
static const VMStateDescription vmstate_virtio_net = { static const VMStateDescription vmstate_virtio_net = {

View File

@ -2388,11 +2388,13 @@ static int vmxnet3_mcast_list_pre_load(void *opaque)
} }
static void vmxnet3_pre_save(void *opaque) static int vmxnet3_pre_save(void *opaque)
{ {
VMXNET3State *s = opaque; VMXNET3State *s = opaque;
s->mcast_list_buff_size = s->mcast_list_len * sizeof(MACAddr); s->mcast_list_buff_size = s->mcast_list_len * sizeof(MACAddr);
return 0;
} }
static const VMStateDescription vmxstate_vmxnet3_mcast_list = { static const VMStateDescription vmxstate_vmxnet3_mcast_list = {

View File

@ -579,7 +579,7 @@ static int piix3_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void piix3_pre_save(void *opaque) static int piix3_pre_save(void *opaque)
{ {
int i; int i;
PIIX3State *piix3 = opaque; PIIX3State *piix3 = opaque;
@ -588,6 +588,8 @@ static void piix3_pre_save(void *opaque)
piix3->pci_irq_levels_vmstate[i] = piix3->pci_irq_levels_vmstate[i] =
pci_bus_get_irq_level(piix3->dev.bus, i); pci_bus_get_irq_level(piix3->dev.bus, i);
} }
return 0;
} }
static bool piix3_rcr_needed(void *opaque) static bool piix3_rcr_needed(void *opaque)

View File

@ -937,11 +937,13 @@ void cpu_ppc_clock_vm_state_change(void *opaque, int running,
* final pages of memory (which happens between vm_stop() * final pages of memory (which happens between vm_stop()
* and pre_save()) takes max_downtime. * and pre_save()) takes max_downtime.
*/ */
static void timebase_pre_save(void *opaque) static int timebase_pre_save(void *opaque)
{ {
PPCTimebase *tb = opaque; PPCTimebase *tb = opaque;
timebase_save(tb); timebase_save(tb);
return 0;
} }
const VMStateDescription vmstate_ppc_timebase = { const VMStateDescription vmstate_ppc_timebase = {

View File

@ -140,7 +140,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(IOMMUMemoryRegion *iommu,
return ret; return ret;
} }
static void spapr_tce_table_pre_save(void *opaque) static int spapr_tce_table_pre_save(void *opaque)
{ {
sPAPRTCETable *tcet = SPAPR_TCE_TABLE(opaque); sPAPRTCETable *tcet = SPAPR_TCE_TABLE(opaque);
@ -149,6 +149,8 @@ static void spapr_tce_table_pre_save(void *opaque)
trace_spapr_iommu_pre_save(tcet->liobn, tcet->mig_nb_table, trace_spapr_iommu_pre_save(tcet->liobn, tcet->mig_nb_table,
tcet->bus_offset, tcet->page_shift); tcet->bus_offset, tcet->page_shift);
return 0;
} }
static uint64_t spapr_tce_get_min_page_size(IOMMUMemoryRegion *iommu) static uint64_t spapr_tce_get_min_page_size(IOMMUMemoryRegion *iommu)

View File

@ -1844,7 +1844,7 @@ static const VMStateDescription vmstate_spapr_pci_msi = {
}, },
}; };
static void spapr_pci_pre_save(void *opaque) static int spapr_pci_pre_save(void *opaque)
{ {
sPAPRPHBState *sphb = opaque; sPAPRPHBState *sphb = opaque;
GHashTableIter iter; GHashTableIter iter;
@ -1869,7 +1869,7 @@ static void spapr_pci_pre_save(void *opaque)
sphb->msi_devs = NULL; sphb->msi_devs = NULL;
sphb->msi_devs_num = g_hash_table_size(sphb->msi); sphb->msi_devs_num = g_hash_table_size(sphb->msi);
if (!sphb->msi_devs_num) { if (!sphb->msi_devs_num) {
return; return 0;
} }
sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig)); sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig));
@ -1878,6 +1878,8 @@ static void spapr_pci_pre_save(void *opaque)
sphb->msi_devs[i].key = *(uint32_t *) key; sphb->msi_devs[i].key = *(uint32_t *) key;
sphb->msi_devs[i].value = *(spapr_pci_msi *) value; sphb->msi_devs[i].value = *(spapr_pci_msi *) value;
} }
return 0;
} }
static int spapr_pci_post_load(void *opaque, int version_id) static int spapr_pci_post_load(void *opaque, int version_id)

View File

@ -196,7 +196,7 @@ static const VMStateDescription vmstate_schdev_orb = {
}; };
static int subch_dev_post_load(void *opaque, int version_id); static int subch_dev_post_load(void *opaque, int version_id);
static void subch_dev_pre_save(void *opaque); static int subch_dev_pre_save(void *opaque);
const char err_hint_devno[] = "Devno mismatch, tried to load wrong section!" const char err_hint_devno[] = "Devno mismatch, tried to load wrong section!"
" Likely reason: some sequences of plug and unplug can break" " Likely reason: some sequences of plug and unplug can break"
@ -249,7 +249,7 @@ static int post_load_ind_addr(void *opaque, int version_id)
return 0; return 0;
} }
static void pre_save_ind_addr(void *opaque) static int pre_save_ind_addr(void *opaque)
{ {
IndAddrPtrTmp *ptmp = opaque; IndAddrPtrTmp *ptmp = opaque;
IndAddr *ind_addr = *(ptmp->parent); IndAddr *ind_addr = *(ptmp->parent);
@ -261,6 +261,8 @@ static void pre_save_ind_addr(void *opaque)
ptmp->len = 0; ptmp->len = 0;
ptmp->addr = 0L; ptmp->addr = 0L;
} }
return 0;
} }
const VMStateDescription vmstate_ind_addr_tmp = { const VMStateDescription vmstate_ind_addr_tmp = {
@ -358,12 +360,14 @@ static ChannelSubSys channel_subsys = {
QTAILQ_HEAD_INITIALIZER(channel_subsys.indicator_addresses), QTAILQ_HEAD_INITIALIZER(channel_subsys.indicator_addresses),
}; };
static void subch_dev_pre_save(void *opaque) static int subch_dev_pre_save(void *opaque)
{ {
SubchDev *s = opaque; SubchDev *s = opaque;
/* Prepare remote_schid for save */ /* Prepare remote_schid for save */
s->migrated_schid = s->schid; s->migrated_schid = s->schid;
return 0;
} }
static int subch_dev_post_load(void *opaque, int version_id) static int subch_dev_post_load(void *opaque, int version_id)

View File

@ -62,13 +62,15 @@ typedef struct VirtioCcwDeviceTmp {
uint16_t config_vector; uint16_t config_vector;
} VirtioCcwDeviceTmp; } VirtioCcwDeviceTmp;
static void virtio_ccw_dev_tmp_pre_save(void *opaque) static int virtio_ccw_dev_tmp_pre_save(void *opaque)
{ {
VirtioCcwDeviceTmp *tmp = opaque; VirtioCcwDeviceTmp *tmp = opaque;
VirtioCcwDevice *dev = tmp->parent; VirtioCcwDevice *dev = tmp->parent;
VirtIODevice *vdev = virtio_bus_get_device(&dev->bus); VirtIODevice *vdev = virtio_bus_get_device(&dev->bus);
tmp->config_vector = vdev->config_vector; tmp->config_vector = vdev->config_vector;
return 0;
} }
static int virtio_ccw_dev_tmp_post_load(void *opaque, int version_id) static int virtio_ccw_dev_tmp_post_load(void *opaque, int version_id)

View File

@ -2083,7 +2083,7 @@ static void lsi_scsi_reset(DeviceState *dev)
lsi_soft_reset(s); lsi_soft_reset(s);
} }
static void lsi_pre_save(void *opaque) static int lsi_pre_save(void *opaque)
{ {
LSIState *s = opaque; LSIState *s = opaque;
@ -2092,6 +2092,8 @@ static void lsi_pre_save(void *opaque)
assert(s->current->dma_len == 0); assert(s->current->dma_len == 0);
} }
assert(QTAILQ_EMPTY(&s->queue)); assert(QTAILQ_EMPTY(&s->queue));
return 0;
} }
static const VMStateDescription vmstate_lsi_scsi = { static const VMStateDescription vmstate_lsi_scsi = {

View File

@ -1167,7 +1167,7 @@ pvscsi_reset(DeviceState *dev)
pvscsi_reset_adapter(s); pvscsi_reset_adapter(s);
} }
static void static int
pvscsi_pre_save(void *opaque) pvscsi_pre_save(void *opaque)
{ {
PVSCSIState *s = (PVSCSIState *) opaque; PVSCSIState *s = (PVSCSIState *) opaque;
@ -1176,6 +1176,8 @@ pvscsi_pre_save(void *opaque)
assert(QTAILQ_EMPTY(&s->pending_queue)); assert(QTAILQ_EMPTY(&s->pending_queue));
assert(QTAILQ_EMPTY(&s->completion_queue)); assert(QTAILQ_EMPTY(&s->completion_queue));
return 0;
} }
static int static int

View File

@ -421,9 +421,11 @@ static void cadence_ttc_init(Object *obj)
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem); sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
} }
static void cadence_timer_pre_save(void *opaque) static int cadence_timer_pre_save(void *opaque)
{ {
cadence_timer_sync((CadenceTimerState *)opaque); cadence_timer_sync((CadenceTimerState *)opaque);
return 0;
} }
static int cadence_timer_post_load(void *opaque, int version_id) static int cadence_timer_post_load(void *opaque, int version_id)

View File

@ -216,12 +216,14 @@ static void update_irq(struct HPETTimer *timer, int set)
} }
} }
static void hpet_pre_save(void *opaque) static int hpet_pre_save(void *opaque)
{ {
HPETState *s = opaque; HPETState *s = opaque;
/* save current counter value */ /* save current counter value */
s->hpet_counter = hpet_get_ticks(s); s->hpet_counter = hpet_get_ticks(s);
return 0;
} }
static int hpet_pre_load(void *opaque) static int hpet_pre_load(void *opaque)

View File

@ -237,7 +237,7 @@ static int pit_load_old(QEMUFile *f, void *opaque, int version_id)
return 0; return 0;
} }
static void pit_dispatch_pre_save(void *opaque) static int pit_dispatch_pre_save(void *opaque)
{ {
PITCommonState *s = opaque; PITCommonState *s = opaque;
PITCommonClass *c = PIT_COMMON_GET_CLASS(s); PITCommonClass *c = PIT_COMMON_GET_CLASS(s);
@ -245,6 +245,8 @@ static void pit_dispatch_pre_save(void *opaque)
if (c->pre_save) { if (c->pre_save) {
c->pre_save(s); c->pre_save(s);
} }
return 0;
} }
static int pit_dispatch_post_load(void *opaque, int version_id) static int pit_dispatch_post_load(void *opaque, int version_id)

View File

@ -795,11 +795,13 @@ static void rtc_set_date_from_host(ISADevice *dev)
rtc_set_cmos(s, &tm); rtc_set_cmos(s, &tm);
} }
static void rtc_pre_save(void *opaque) static int rtc_pre_save(void *opaque)
{ {
RTCState *s = opaque; RTCState *s = opaque;
rtc_update_time(s); rtc_update_time(s);
return 0;
} }
static int rtc_post_load(void *opaque, int version_id) static int rtc_post_load(void *opaque, int version_id)

View File

@ -211,7 +211,7 @@ static void pl031_init(Object *obj)
s->timer = timer_new_ns(rtc_clock, pl031_interrupt, s); s->timer = timer_new_ns(rtc_clock, pl031_interrupt, s);
} }
static void pl031_pre_save(void *opaque) static int pl031_pre_save(void *opaque)
{ {
PL031State *s = opaque; PL031State *s = opaque;
@ -219,6 +219,8 @@ static void pl031_pre_save(void *opaque)
* store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */ * store the base time relative to the QEMU_CLOCK_VIRTUAL for backwards-compatibility. */
int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); int64_t delta = qemu_clock_get_ns(rtc_clock) - qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND; s->tick_offset_vmstate = s->tick_offset + delta / NANOSECONDS_PER_SECOND;
return 0;
} }
static int pl031_post_load(void *opaque, int version_id) static int pl031_post_load(void *opaque, int version_id)

View File

@ -791,11 +791,13 @@ static const VMStateDescription vmstate_menelaus_tm = {
} }
}; };
static void menelaus_pre_save(void *opaque) static int menelaus_pre_save(void *opaque)
{ {
MenelausState *s = opaque; MenelausState *s = opaque;
/* Should be <= 1000 */ /* Should be <= 1000 */
s->rtc_next_vmstate = s->rtc.next - qemu_clock_get_ms(rtc_clock); s->rtc_next_vmstate = s->rtc.next - qemu_clock_get_ms(rtc_clock);
return 0;
} }
static int menelaus_post_load(void *opaque, int version_id) static int menelaus_post_load(void *opaque, int version_id)

View File

@ -1374,7 +1374,7 @@ static int ccid_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void ccid_pre_save(void *opaque) static int ccid_pre_save(void *opaque)
{ {
USBCCIDState *s = opaque; USBCCIDState *s = opaque;
@ -1386,6 +1386,8 @@ static void ccid_pre_save(void *opaque)
*/ */
s->migration_state = MIGRATION_MIGRATED; s->migration_state = MIGRATION_MIGRATED;
} }
return 0;
} }
static VMStateDescription bulk_in_vmstate = { static VMStateDescription bulk_in_vmstate = {

View File

@ -2381,7 +2381,7 @@ static USBBusOps ehci_bus_ops_standalone = {
.wakeup_endpoint = ehci_wakeup_endpoint, .wakeup_endpoint = ehci_wakeup_endpoint,
}; };
static void usb_ehci_pre_save(void *opaque) static int usb_ehci_pre_save(void *opaque)
{ {
EHCIState *ehci = opaque; EHCIState *ehci = opaque;
uint32_t new_frindex; uint32_t new_frindex;
@ -2390,6 +2390,8 @@ static void usb_ehci_pre_save(void *opaque)
new_frindex = ehci->frindex & ~7; new_frindex = ehci->frindex & ~7;
ehci->last_run_ns -= (ehci->frindex - new_frindex) * UFRAME_TIMER_NS; ehci->last_run_ns -= (ehci->frindex - new_frindex) * UFRAME_TIMER_NS;
ehci->frindex = new_frindex; ehci->frindex = new_frindex;
return 0;
} }
static int usb_ehci_post_load(void *opaque, int version_id) static int usb_ehci_post_load(void *opaque, int version_id)

View File

@ -2111,11 +2111,13 @@ static void usbredir_buffered_bulk_packet(void *priv, uint64_t id,
* Migration code * Migration code
*/ */
static void usbredir_pre_save(void *priv) static int usbredir_pre_save(void *priv)
{ {
USBRedirDevice *dev = priv; USBRedirDevice *dev = priv;
usbredir_fill_already_in_flight(dev); usbredir_fill_already_in_flight(dev);
return 0;
} }
static int usbredir_post_load(void *priv, int version_id) static int usbredir_post_load(void *priv, int version_id)

View File

@ -254,13 +254,15 @@ static void vhost_vsock_post_load_timer_cb(void *opaque)
vhost_vsock_send_transport_reset(vsock); vhost_vsock_send_transport_reset(vsock);
} }
static void vhost_vsock_pre_save(void *opaque) static int vhost_vsock_pre_save(void *opaque)
{ {
VHostVSock *vsock = opaque; VHostVSock *vsock = opaque;
/* At this point, backend must be stopped, otherwise /* At this point, backend must be stopped, otherwise
* it might keep writing to memory. */ * it might keep writing to memory. */
assert(!vsock->vhost_dev.started); assert(!vsock->vhost_dev.started);
return 0;
} }
static int vhost_vsock_post_load(void *opaque, int version_id) static int vhost_vsock_post_load(void *opaque, int version_id)

View File

@ -179,7 +179,7 @@ struct VMStateDescription {
LoadStateHandler *load_state_old; LoadStateHandler *load_state_old;
int (*pre_load)(void *opaque); int (*pre_load)(void *opaque);
int (*post_load)(void *opaque, int version_id); int (*post_load)(void *opaque, int version_id);
void (*pre_save)(void *opaque); int (*pre_save)(void *opaque);
bool (*needed)(void *opaque); bool (*needed)(void *opaque);
VMStateField *fields; VMStateField *fields;
const VMStateDescription **subsections; const VMStateDescription **subsections;

View File

@ -34,11 +34,13 @@ COLOMode get_colo_mode(void)
} }
} }
static void colo_info_pre_save(void *opaque) static int colo_info_pre_save(void *opaque)
{ {
COLOInfo *s = opaque; COLOInfo *s = opaque;
s->colo_requested = migrate_colo_enabled(); s->colo_requested = migrate_colo_enabled();
return 0;
} }
static bool colo_info_need(void *opaque) static bool colo_info_need(void *opaque)

View File

@ -101,12 +101,14 @@ static int global_state_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void global_state_pre_save(void *opaque) static int global_state_pre_save(void *opaque)
{ {
GlobalState *s = opaque; GlobalState *s = opaque;
trace_migrate_global_state_pre_save((char *)s->runstate); trace_migrate_global_state_pre_save((char *)s->runstate);
s->size = strlen((char *)s->runstate) + 1; s->size = strlen((char *)s->runstate) + 1;
return 0;
} }
static const VMStateDescription vmstate_globalstate = { static const VMStateDescription vmstate_globalstate = {

View File

@ -312,7 +312,7 @@ static SaveState savevm_state = {
.global_section_id = 0, .global_section_id = 0,
}; };
static void configuration_pre_save(void *opaque) static int configuration_pre_save(void *opaque)
{ {
SaveState *state = opaque; SaveState *state = opaque;
const char *current_name = MACHINE_GET_CLASS(current_machine)->name; const char *current_name = MACHINE_GET_CLASS(current_machine)->name;
@ -320,6 +320,8 @@ static void configuration_pre_save(void *opaque)
state->len = strlen(current_name); state->len = strlen(current_name);
state->name = current_name; state->name = current_name;
state->target_page_bits = qemu_target_page_bits(); state->target_page_bits = qemu_target_page_bits();
return 0;
} }
static int configuration_pre_load(void *opaque) static int configuration_pre_load(void *opaque)

View File

@ -21,10 +21,12 @@
#include "migration/vmstate.h" #include "migration/vmstate.h"
#include "migration/snapshot.h" #include "migration/snapshot.h"
static void replay_pre_save(void *opaque) static int replay_pre_save(void *opaque)
{ {
ReplayState *state = opaque; ReplayState *state = opaque;
state->file_offset = ftell(replay_file); state->file_offset = ftell(replay_file);
return 0;
} }
static int replay_post_load(void *opaque, int version_id) static int replay_post_load(void *opaque, int version_id)

View File

@ -1203,11 +1203,13 @@ struct sbuf_tmp {
uint32_t roff, woff; uint32_t roff, woff;
}; };
static void sbuf_tmp_pre_save(void *opaque) static int sbuf_tmp_pre_save(void *opaque)
{ {
struct sbuf_tmp *tmp = opaque; struct sbuf_tmp *tmp = opaque;
tmp->woff = tmp->parent->sb_wptr - tmp->parent->sb_data; tmp->woff = tmp->parent->sb_wptr - tmp->parent->sb_data;
tmp->roff = tmp->parent->sb_rptr - tmp->parent->sb_data; tmp->roff = tmp->parent->sb_rptr - tmp->parent->sb_data;
return 0;
} }
static int sbuf_tmp_post_load(void *opaque, int version) static int sbuf_tmp_post_load(void *opaque, int version)
@ -1303,7 +1305,7 @@ typedef struct SS_FamilyTmpStruct {
#define SS_FAMILY_MIG_IPV6 10 /* Linux */ #define SS_FAMILY_MIG_IPV6 10 /* Linux */
#define SS_FAMILY_MIG_OTHER 0xffff #define SS_FAMILY_MIG_OTHER 0xffff
static void ss_family_pre_save(void *opaque) static int ss_family_pre_save(void *opaque)
{ {
SS_FamilyTmpStruct *tss = opaque; SS_FamilyTmpStruct *tss = opaque;
@ -1314,6 +1316,8 @@ static void ss_family_pre_save(void *opaque)
} else if (tss->parent->ss.ss_family == AF_INET6) { } else if (tss->parent->ss.ss_family == AF_INET6) {
tss->portable_family = SS_FAMILY_MIG_IPV6; tss->portable_family = SS_FAMILY_MIG_IPV6;
} }
return 0;
} }
static int ss_family_post_load(void *opaque, int version_id) static int ss_family_post_load(void *opaque, int version_id)

View File

@ -394,7 +394,7 @@ static const VMStateInfo vmstate_powered_off = {
.put = put_power, .put = put_power,
}; };
static void cpu_pre_save(void *opaque) static int cpu_pre_save(void *opaque)
{ {
ARMCPU *cpu = opaque; ARMCPU *cpu = opaque;
@ -415,6 +415,8 @@ static void cpu_pre_save(void *opaque)
cpu->cpreg_array_len * sizeof(uint64_t)); cpu->cpreg_array_len * sizeof(uint64_t));
memcpy(cpu->cpreg_vmstate_values, cpu->cpreg_values, memcpy(cpu->cpreg_vmstate_values, cpu->cpreg_values,
cpu->cpreg_array_len * sizeof(uint64_t)); cpu->cpreg_array_len * sizeof(uint64_t));
return 0;
} }
static int cpu_post_load(void *opaque, int version_id) static int cpu_post_load(void *opaque, int version_id)

View File

@ -160,13 +160,15 @@ static floatx80 cpu_set_fp80(uint64_t mant, uint16_t upper)
return temp.d; return temp.d;
} }
static void fpreg_pre_save(void *opaque) static int fpreg_pre_save(void *opaque)
{ {
x86_FPReg_tmp *tmp = opaque; x86_FPReg_tmp *tmp = opaque;
/* we save the real CPU data (in case of MMX usage only 'mant' /* we save the real CPU data (in case of MMX usage only 'mant'
contains the MMX register */ contains the MMX register */
cpu_get_fp80(&tmp->tmp_mant, &tmp->tmp_exp, tmp->parent->d); cpu_get_fp80(&tmp->tmp_mant, &tmp->tmp_exp, tmp->parent->d);
return 0;
} }
static int fpreg_post_load(void *opaque, int version) static int fpreg_post_load(void *opaque, int version)
@ -196,7 +198,7 @@ static const VMStateDescription vmstate_fpreg = {
} }
}; };
static void cpu_pre_save(void *opaque) static int cpu_pre_save(void *opaque)
{ {
X86CPU *cpu = opaque; X86CPU *cpu = opaque;
CPUX86State *env = &cpu->env; CPUX86State *env = &cpu->env;
@ -228,6 +230,7 @@ static void cpu_pre_save(void *opaque)
env->segs[R_SS].flags &= ~(env->segs[R_SS].flags & DESC_DPL_MASK); env->segs[R_SS].flags &= ~(env->segs[R_SS].flags & DESC_DPL_MASK);
} }
return 0;
} }
static int cpu_post_load(void *opaque, int version_id) static int cpu_post_load(void *opaque, int version_id)

View File

@ -146,7 +146,7 @@ static bool cpu_pre_2_8_migration(void *opaque, int version_id)
return cpu->pre_2_8_migration; return cpu->pre_2_8_migration;
} }
static void cpu_pre_save(void *opaque) static int cpu_pre_save(void *opaque)
{ {
PowerPCCPU *cpu = opaque; PowerPCCPU *cpu = opaque;
CPUPPCState *env = &cpu->env; CPUPPCState *env = &cpu->env;
@ -195,6 +195,8 @@ static void cpu_pre_save(void *opaque)
cpu->mig_insns_flags2 = env->insns_flags2 & insns_compat_mask2; cpu->mig_insns_flags2 = env->insns_flags2 & insns_compat_mask2;
cpu->mig_nb_BATs = env->nb_BATs; cpu->mig_nb_BATs = env->nb_BATs;
} }
return 0;
} }
/* /*

View File

@ -37,13 +37,15 @@ static int cpu_post_load(void *opaque, int version_id)
return 0; return 0;
} }
static void cpu_pre_save(void *opaque) static int cpu_pre_save(void *opaque)
{ {
S390CPU *cpu = opaque; S390CPU *cpu = opaque;
if (kvm_enabled()) { if (kvm_enabled()) {
kvm_s390_vcpu_interrupt_pre_save(cpu); kvm_s390_vcpu_interrupt_pre_save(cpu);
} }
return 0;
} }
static inline bool fpu_needed(void *opaque) static inline bool fpu_needed(void *opaque)

View File

@ -88,7 +88,7 @@ static const VMStateInfo vmstate_psr = {
.put = put_psr, .put = put_psr,
}; };
static void cpu_pre_save(void *opaque) static int cpu_pre_save(void *opaque)
{ {
SPARCCPU *cpu = opaque; SPARCCPU *cpu = opaque;
CPUSPARCState *env = &cpu->env; CPUSPARCState *env = &cpu->env;
@ -97,6 +97,8 @@ static void cpu_pre_save(void *opaque)
* window as the outs of the first window * window as the outs of the first window
*/ */
cpu_set_cwp(env, env->cwp); cpu_set_cwp(env, env->cwp);
return 0;
} }
/* 32-bit SPARC retains migration compatibility with older versions /* 32-bit SPARC retains migration compatibility with older versions

View File

@ -765,11 +765,13 @@ typedef struct TmpTestStruct {
int64_t diff; int64_t diff;
} TmpTestStruct; } TmpTestStruct;
static void tmp_child_pre_save(void *opaque) static int tmp_child_pre_save(void *opaque)
{ {
struct TmpTestStruct *tts = opaque; struct TmpTestStruct *tts = opaque;
tts->diff = tts->parent->b - tts->parent->a; tts->diff = tts->parent->b - tts->parent->a;
return 0;
} }
static int tmp_child_post_load(void *opaque, int version_id) static int tmp_child_post_load(void *opaque, int version_id)