From 44b1ff319c4781c7ab13f7e119b3114a1e6a52e2 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Mon, 25 Sep 2017 12:29:12 +0100 Subject: 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 Message-Id: <20170925112917.21340-2-dgilbert@redhat.com> Reviewed-by: Peter Xu Reviewed-by: Cornelia Huck Reviewed-by: Juan Quintela Signed-off-by: Dr. David Alan Gilbert --- hw/net/e1000.c | 4 +++- hw/net/e1000e.c | 4 +++- hw/net/rtl8139.c | 4 +++- hw/net/virtio-net.c | 16 ++++++++++++---- hw/net/vmxnet3.c | 4 +++- 5 files changed, 24 insertions(+), 8 deletions(-) (limited to 'hw/net') diff --git a/hw/net/e1000.c b/hw/net/e1000.c index eebe3a9..cae9518 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -1343,7 +1343,7 @@ static bool is_version_1(void *opaque, int version_id) return version_id == 1; } -static void e1000_pre_save(void *opaque) +static int e1000_pre_save(void *opaque) { E1000State *s = opaque; 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)) { s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE; } + + return 0; } static int e1000_post_load(void *opaque, int version_id) diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c index 6c42b44..744f0f3 100644 --- a/hw/net/e1000e.c +++ b/hw/net/e1000e.c @@ -523,13 +523,15 @@ static void e1000e_qdev_reset(DeviceState *dev) e1000e_core_reset(&s->core); } -static void e1000e_pre_save(void *opaque) +static int e1000e_pre_save(void *opaque) { E1000EState *s = opaque; trace_e1000e_cb_pre_save(); e1000e_core_pre_save(&s->core); + + return 0; } static int e1000e_post_load(void *opaque, int version_id) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 3be24bb..d6c8188 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -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; 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 */ s->TCTR = (current_time - s->TCTR_base) / PCI_PERIOD; s->rtl8139_mmio_io_addr_dummy = 0; + + return 0; } static const VMStateDescription vmstate_rtl8139 = { diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 148071a..150fd07 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1712,7 +1712,7 @@ struct VirtIONetMigTmp { * 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; @@ -1721,6 +1721,8 @@ static void virtio_net_tx_waiting_pre_save(void *opaque) if (tmp->parent->curr_queues == 0) { tmp->curr_queues_1 = 0; } + + return 0; } 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; } -static void virtio_net_ufo_pre_save(void *opaque) +static int virtio_net_ufo_pre_save(void *opaque) { struct VirtIONetMigTmp *tmp = opaque; tmp->has_ufo = tmp->parent->has_ufo; + + return 0; } 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; } -static void virtio_net_vnet_pre_save(void *opaque) +static int virtio_net_vnet_pre_save(void *opaque) { struct VirtIONetMigTmp *tmp = opaque; tmp->has_vnet_hdr = tmp->parent->has_vnet_hdr; + + return 0; } static const VMStateDescription vmstate_virtio_net_has_vnet = { @@ -2079,13 +2085,15 @@ static void virtio_net_instance_init(Object *obj) DEVICE(n), NULL); } -static void virtio_net_pre_save(void *opaque) +static int virtio_net_pre_save(void *opaque) { VirtIONet *n = opaque; /* At this point, backend must be stopped, otherwise * it might keep writing to memory. */ assert(!n->vhost_started); + + return 0; } static const VMStateDescription vmstate_virtio_net = { diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index a19a7a3..b43b58b 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -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; s->mcast_list_buff_size = s->mcast_list_len * sizeof(MACAddr); + + return 0; } static const VMStateDescription vmxstate_vmxnet3_mcast_list = { -- cgit v1.1