migration: Fix error propagation regression and memory leak
v2 cover migration: Fix error propagation regression and memory leak
Hi,
This series fixes the following:
commit c632ffbd74 introduced a regression of passing error_fatal to vmstate_load_state() and vmstate_save_state() functions. This will not allow us to propagate the error back to the caller.
commit 94272d9b45 introduced a memory leak in postcopy_ram_listen_thread(). We need to free the local_err object in the if clause as well.
---
Changes in v2:
- Refactoring of the return statement in virtio_gpu_load().
- Add another patch to fix the memory leak in postcopy_ram_listen_thread()
- Link to v1: https://lore.kernel.org/qemu-devel/20251024-solve_error_fatal_regression-v1-1-d26e6cbd0a7e@redhat.com
---
Arun Menon (2):
migration: Fix regression of passing error_fatal into vmstate_load_state()
migration: Fix memory leak in postcopy_ram_listen_thread()
hw/display/virtio-gpu.c | 19 ++++++++++++++----- hw/pci/pci.c | 13 +++++++++++-- hw/s390x/virtio-ccw.c | 15 +++++++++++++-- hw/scsi/spapr_vscsi.c | 9 +++++++-- hw/virtio/virtio-mmio.c | 15 +++++++++++++-- hw/virtio/virtio-pci.c | 15 +++++++++++++-- hw/virtio/virtio.c | 10 +++++++--- migration/savevm.c | 1 + 8 files changed, 79 insertions(+), 18 deletions(-)
---
base-commit: 36076d24f04ea9dc3357c0fbe7bb14917375819c
change-id: 20251024-solve_error_fatal_regression-301763debd8f
Best regards,
Signature · 1 line
Arun Menon <[email protected]>
PATCH v2 1/2 migration: Fix regression of passing error_fatal into vmstate_load_state()
error_fatal is passed to vmstate_load_state() and vmstate_save_state() functions. This was introduced in commit c632ffbd74. This would exit(1) on error, and therefore does not allow to propagate the error back to the caller.
To maintain consistency with prior error handling i.e. either propagating the error to the caller or reporting it, we must set the error within a local Error object instead of using error_fatal.
--- hw/display/virtio-gpu.c | 19 ++++++++++++++----- hw/pci/pci.c | 13 +++++++++++-- hw/s390x/virtio-ccw.c | 15 +++++++++++++-- hw/scsi/spapr_vscsi.c | 9 +++++++-- hw/virtio/virtio-mmio.c | 15 +++++++++++++-- hw/virtio/virtio-pci.c | 15 +++++++++++++-- hw/virtio/virtio.c | 10 +++++++--- 7 files changed, 78 insertions(+), 18 deletions(-)
hw/display/virtio-gpu.c +14 -5
@@ -1225,7 +1225,9 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, {VirtIOGPU *g = opaque;struct virtio_gpu_simple_resource *res; +Error *err =NULL ;int i; +int ret =0 ;/* in 2d mode we should never find unprocessed commands here */ assert (QTAILQ_EMPTY (&g->cmdq));
@@ -1248,8 +1250,12 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, }qemu_put_be32 (f,0 );/* end of list */ -return vmstate_save_state (f, &vmstate_virtio_gpu_scanouts, g,NULL , - &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio_gpu_scanouts, g,NULL , + &err); +if (ret <0 ) { +error_report_err (err); + } +return ret; } static bool virtio_gpu_load_restore_mapping(VirtIOGPU *g,
@@ -1289,6 +1295,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,struct virtio_gpu_simple_resource *res;uint32_t resource_id, pformat;int i; +int ret =0 ; g->hostmem =0 ;
@@ -1348,9 +1355,11 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size, }/* load & apply scanout state */ -vmstate_load_state (f, &vmstate_virtio_gpu_scanouts, g,1 , &error_fatal); - -return 0 ; + ret =vmstate_load_state (f, &vmstate_virtio_gpu_scanouts, g,1 , &err); +if (ret <0 ) { +error_report_err (err); + } +return ret; } static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size,
hw/pci/pci.c +11 -2
@@ -925,8 +925,13 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)* in irq_state which we are saving. * This makes us compatible with old devices * which never set or clear this bit. */ +int ret; +Error *local_err =NULL ; s->config[PCI_STATUS ] &= ~PCI_STATUS_INTERRUPT ; -vmstate_save_state (f, &vmstate_pci_device, s,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_pci_device, s,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + }/* Restore the interrupt status bit. */ pci_update_irq_status (s); }
@@ -934,8 +939,12 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)int pci_device_load (PCIDevice *s,QEMUFile *f) {int ret; +Error *local_err =NULL ; ret =vmstate_load_state (f, &vmstate_pci_device, s, s->version_id, - &error_fatal); + &local_err); +if (ret <0 ) { +error_report_err (local_err); + }/* Restore the interrupt status bit. */ pci_update_irq_status (s);return ret;
hw/s390x/virtio-ccw.c +13 -2
@@ -1130,13 +1130,24 @@ static int virtio_ccw_load_queue(DeviceState *d, int n, QEMUFile *f)static void virtio_ccw_save_config (DeviceState *d,QEMUFile *f) {VirtioCcwDevice *dev =VIRTIO_CCW_DEVICE (d); -vmstate_save_state (f, &vmstate_virtio_ccw_dev, dev,NULL , &error_fatal); +int ret; +Error *local_err =NULL ; + ret =vmstate_save_state (f, &vmstate_virtio_ccw_dev, dev,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } }static int virtio_ccw_load_config (DeviceState *d,QEMUFile *f) {VirtioCcwDevice *dev =VIRTIO_CCW_DEVICE (d); -return vmstate_load_state (f, &vmstate_virtio_ccw_dev, dev,1 , &error_fatal); +int ret; +Error *local_err =NULL ; + ret =vmstate_load_state (f, &vmstate_virtio_ccw_dev, dev,1 , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }static void virtio_ccw_pre_plugged (DeviceState *d,Error **errp)
hw/scsi/spapr_vscsi.c +7 -2
@@ -628,10 +628,15 @@ static const VMStateDescription vmstate_spapr_vscsi_req = {static void vscsi_save_request (QEMUFile *f,SCSIRequest *sreq) {vscsi_req *req = sreq->hba_private; +int rc; +Error *local_err =NULL ;assert (req->active); -vmstate_save_state (f, &vmstate_spapr_vscsi_req, req,NULL , &error_fatal); - + rc =vmstate_save_state (f, &vmstate_spapr_vscsi_req, req,NULL , &local_err); +if (rc <0 ) { +error_report_err (local_err); +return ; + }trace_spapr_vscsi_save_request (req->qtag, req->cur_desc_num, req->cur_desc_offset); }
hw/virtio/virtio-mmio.c +13 -2
@@ -612,15 +612,26 @@ static const VMStateDescription vmstate_virtio_mmio = {static void virtio_mmio_save_extra_state (DeviceState *opaque,QEMUFile *f) {VirtIOMMIOProxy *proxy =VIRTIO_MMIO (opaque); +Error *local_err =NULL ; +int ret; -vmstate_save_state (f, &vmstate_virtio_mmio, proxy,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio_mmio, proxy,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } }static int virtio_mmio_load_extra_state (DeviceState *opaque,QEMUFile *f) {VirtIOMMIOProxy *proxy =VIRTIO_MMIO (opaque); +int ret; +Error *local_err =NULL ; -return vmstate_load_state (f, &vmstate_virtio_mmio, proxy,1 , &error_fatal); + ret =vmstate_load_state (f, &vmstate_virtio_mmio, proxy,1 , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }static bool virtio_mmio_has_extra_state (DeviceState *opaque)
hw/virtio/virtio-pci.c +13 -2
@@ -187,15 +187,26 @@ static bool virtio_pci_has_extra_state(DeviceState *d)static void virtio_pci_save_extra_state (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); +int ret; +Error *local_err =NULL ; -vmstate_save_state (f, &vmstate_virtio_pci, proxy,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio_pci, proxy,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } }static int virtio_pci_load_extra_state (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); +int ret; +Error *local_err =NULL ; -return vmstate_load_state (f, &vmstate_virtio_pci, proxy,1 , &error_fatal); + ret =vmstate_load_state (f, &vmstate_virtio_pci, proxy,1 , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }static void virtio_pci_save_queue (DeviceState *d,int n,QEMUFile *f)
hw/virtio/virtio.c +7 -3
@@ -3030,7 +3030,7 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f)VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus);VirtioDeviceClass *vdc =VIRTIO_DEVICE_GET_CLASS (vdev);uint32_t guest_features_lo = (vdev->guest_features &0xffffffff ); -int i; +int i, ret;Error *local_err =NULL ;if (k->save_config) {
@@ -3075,7 +3075,7 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) }if (vdc->vmsd) { -int ret =vmstate_save_state (f, vdc->vmsd, vdev,NULL , &local_err); + ret =vmstate_save_state (f, vdc->vmsd, vdev,NULL , &local_err);if (ret) {error_report_err (local_err);return ret;
@@ -3083,7 +3083,11 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) }/* Subsections */ -return vmstate_save_state (f, &vmstate_virtio, vdev,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio, vdev,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }/* A wrapper for use as a VMState .put function */
Signature · 1 line
2.51.0
Re: [PATCH v2 1/2] migration: Fix regression of passing error_fatal into vmstate_load_state()
Quoted 26 lines · Arun Menon
error_fatalis passed tovmstate_load_state()andvmstate_save_state()functions. This was introduced in commitc632ffbd74. This would exit(1) on error, and therefore does not allow to propagate the error back to the caller.To maintain consistency with prior error handling i.e. either propagating the error to the caller or reporting it, we must set the error within a local Error object instead of using
error_fatal.Reviewed-by Cornelia Huck <[email protected]>Signed-off-by Arun Menon <[email protected]>--- hw/display/virtio-gpu.c | 19 ++++++++++++++----- hw/pci/pci.c | 13 +++++++++++-- hw/s390x/virtio-ccw.c | 15 +++++++++++++-- hw/scsi/spapr_vscsi.c | 9 +++++++-- hw/virtio/virtio-mmio.c | 15 +++++++++++++-- hw/virtio/virtio-pci.c | 15 +++++++++++++-- hw/virtio/virtio.c | 10 +++++++--- 7 files changed, 78 insertions(+), 18 deletions(-)hw/display/virtio-gpu.c +0
-0
hw/display/virtio-gpu.c static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, · line 1230
Quoted 6 lines
hw/display/virtio-gpu.c +2
-0@@ -1225,7 +1225,9 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, {VirtIOGPU *g = opaque;struct virtio_gpu_simple_resource *res; +Error *err =NULL ;int i; +int ret =0 ;
I prefer not to have a variable initialized unless necessary because it suppresses compiler warnings to tell accidental usage of variable.
Besides, the code change for other files in this patch and the existing code in this file doesn't initialize such variables, making the code style inconsistent.
That said, I feel it is too nitpicky so I give:
You may or may not resend this patch to drop the initialization.
Quoted 229 lines
hw/display/virtio-gpu.c +12
-5/* in 2d mode we should never find unprocessed commands here */ assert (QTAILQ_EMPTY (&g->cmdq));@@ -1248,8 +1250,12 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, }qemu_put_be32 (f,0 );/* end of list */ -return vmstate_save_state (f, &vmstate_virtio_gpu_scanouts, g,NULL , - &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio_gpu_scanouts, g,NULL , + &err); +if (ret <0 ) { +error_report_err (err); + } +return ret; } static bool virtio_gpu_load_restore_mapping(VirtIOGPU *g,@@ -1289,6 +1295,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,struct virtio_gpu_simple_resource *res;uint32_t resource_id, pformat;int i; +int ret =0 ; g->hostmem =0 ;@@ -1348,9 +1355,11 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size, }/* load & apply scanout state */ -vmstate_load_state (f, &vmstate_virtio_gpu_scanouts, g,1 , &error_fatal); - -return 0 ; + ret =vmstate_load_state (f, &vmstate_virtio_gpu_scanouts, g,1 , &err); +if (ret <0 ) { +error_report_err (err); + } +return ret; } static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size,hw/pci/pci.c +11
-2@@ -925,8 +925,13 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)* in irq_state which we are saving. * This makes us compatible with old devices * which never set or clear this bit. */ +int ret; +Error *local_err =NULL ; s->config[PCI_STATUS ] &= ~PCI_STATUS_INTERRUPT ; -vmstate_save_state (f, &vmstate_pci_device, s,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_pci_device, s,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + }/* Restore the interrupt status bit. */ pci_update_irq_status (s); }@@ -934,8 +939,12 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)int pci_device_load (PCIDevice *s,QEMUFile *f) {int ret; +Error *local_err =NULL ; ret =vmstate_load_state (f, &vmstate_pci_device, s, s->version_id, - &error_fatal); + &local_err); +if (ret <0 ) { +error_report_err (local_err); + }/* Restore the interrupt status bit. */ pci_update_irq_status (s);return ret;hw/s390x/virtio-ccw.c +13
-2@@ -1130,13 +1130,24 @@ static int virtio_ccw_load_queue(DeviceState *d, int n, QEMUFile *f)static void virtio_ccw_save_config (DeviceState *d,QEMUFile *f) {VirtioCcwDevice *dev =VIRTIO_CCW_DEVICE (d); -vmstate_save_state (f, &vmstate_virtio_ccw_dev, dev,NULL , &error_fatal); +int ret; +Error *local_err =NULL ; + ret =vmstate_save_state (f, &vmstate_virtio_ccw_dev, dev,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } }static int virtio_ccw_load_config (DeviceState *d,QEMUFile *f) {VirtioCcwDevice *dev =VIRTIO_CCW_DEVICE (d); -return vmstate_load_state (f, &vmstate_virtio_ccw_dev, dev,1 , &error_fatal); +int ret; +Error *local_err =NULL ; + ret =vmstate_load_state (f, &vmstate_virtio_ccw_dev, dev,1 , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }static void virtio_ccw_pre_plugged (DeviceState *d,Error **errp)hw/scsi/spapr_vscsi.c +7
-2@@ -628,10 +628,15 @@ static const VMStateDescription vmstate_spapr_vscsi_req = {static void vscsi_save_request (QEMUFile *f,SCSIRequest *sreq) {vscsi_req *req = sreq->hba_private; +int rc; +Error *local_err =NULL ;assert (req->active); -vmstate_save_state (f, &vmstate_spapr_vscsi_req, req,NULL , &error_fatal); - + rc =vmstate_save_state (f, &vmstate_spapr_vscsi_req, req,NULL , &local_err); +if (rc <0 ) { +error_report_err (local_err); +return ; + }trace_spapr_vscsi_save_request (req->qtag, req->cur_desc_num, req->cur_desc_offset); }hw/virtio/virtio-mmio.c +13
-2@@ -612,15 +612,26 @@ static const VMStateDescription vmstate_virtio_mmio = {static void virtio_mmio_save_extra_state (DeviceState *opaque,QEMUFile *f) {VirtIOMMIOProxy *proxy =VIRTIO_MMIO (opaque); +Error *local_err =NULL ; +int ret; -vmstate_save_state (f, &vmstate_virtio_mmio, proxy,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio_mmio, proxy,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } }static int virtio_mmio_load_extra_state (DeviceState *opaque,QEMUFile *f) {VirtIOMMIOProxy *proxy =VIRTIO_MMIO (opaque); +int ret; +Error *local_err =NULL ; -return vmstate_load_state (f, &vmstate_virtio_mmio, proxy,1 , &error_fatal); + ret =vmstate_load_state (f, &vmstate_virtio_mmio, proxy,1 , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }static bool virtio_mmio_has_extra_state (DeviceState *opaque)hw/virtio/virtio-pci.c +13
-2@@ -187,15 +187,26 @@ static bool virtio_pci_has_extra_state(DeviceState *d)static void virtio_pci_save_extra_state (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); +int ret; +Error *local_err =NULL ; -vmstate_save_state (f, &vmstate_virtio_pci, proxy,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio_pci, proxy,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } }static int virtio_pci_load_extra_state (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); +int ret; +Error *local_err =NULL ; -return vmstate_load_state (f, &vmstate_virtio_pci, proxy,1 , &error_fatal); + ret =vmstate_load_state (f, &vmstate_virtio_pci, proxy,1 , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }static void virtio_pci_save_queue (DeviceState *d,int n,QEMUFile *f)hw/virtio/virtio.c +7
-3@@ -3030,7 +3030,7 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f)VirtioBusClass *k =VIRTIO_BUS_GET_CLASS (qbus);VirtioDeviceClass *vdc =VIRTIO_DEVICE_GET_CLASS (vdev);uint32_t guest_features_lo = (vdev->guest_features &0xffffffff ); -int i; +int i, ret;Error *local_err =NULL ;if (k->save_config) {@@ -3075,7 +3075,7 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) }if (vdc->vmsd) { -int ret =vmstate_save_state (f, vdc->vmsd, vdev,NULL , &local_err); + ret =vmstate_save_state (f, vdc->vmsd, vdev,NULL , &local_err);if (ret) {error_report_err (local_err);return ret;@@ -3083,7 +3083,11 @@ int virtio_save(VirtIODevice *vdev, QEMUFile *f) }/* Subsections */ -return vmstate_save_state (f, &vmstate_virtio, vdev,NULL , &error_fatal); + ret =vmstate_save_state (f, &vmstate_virtio, vdev,NULL , &local_err); +if (ret <0 ) { +error_report_err (local_err); + } +return ret; }/* A wrapper for use as a VMState .put function */
Re: [PATCH v2 1/2] migration: Fix regression of passing error_fatal into vmstate_load_state()
Quoted 41 lines · Akihiko Odaki
Quoted 26 lines · Arun Menon
error_fatalis passed tovmstate_load_state()andvmstate_save_state()functions. This was introduced in commitc632ffbd74. This would exit(1) on error, and therefore does not allow to propagate the error back to the caller.To maintain consistency with prior error handling i.e. either propagating the error to the caller or reporting it, we must set the error within a local Error object instead of using
error_fatal.Reviewed-by Cornelia Huck <[email protected]>Signed-off-by Arun Menon <[email protected]>--- hw/display/virtio-gpu.c | 19 ++++++++++++++----- hw/pci/pci.c | 13 +++++++++++-- hw/s390x/virtio-ccw.c | 15 +++++++++++++-- hw/scsi/spapr_vscsi.c | 9 +++++++-- hw/virtio/virtio-mmio.c | 15 +++++++++++++-- hw/virtio/virtio-pci.c | 15 +++++++++++++-- hw/virtio/virtio.c | 10 +++++++--- 7 files changed, 78 insertions(+), 18 deletions(-)hw/display/virtio-gpu.c +0
-0hw/display/virtio-gpu.c static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, · line 1230
Quoted 6 lines
hw/display/virtio-gpu.c +2
-0@@ -1225,7 +1225,9 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size, {VirtIOGPU *g = opaque;struct virtio_gpu_simple_resource *res; +Error *err =NULL ;int i; +int ret =0 ;I prefer not to have a variable initialized unless necessary because it suppresses compiler warnings to tell accidental usage of variable.
Besides, the code change for other files in this patch and the existing code in this file doesn't initialize such variables, making the code style inconsistent.
Quoted 5 lines
That said, I feel it is too nitpicky so I give:
Reviewed-by Akihiko Odaki <[email protected]>You may or may not resend this patch to drop the initialization.
I'll fix it when queuing, thanks both.
While at it, I also touched a few other things on reordering of vars (follow rev-christmas tree), spacing, etc. The fixup is attached at the end. Please shoot if anyone disagrees.
I'll skip patch 2 because we already have a fix here:
https://lore.kernel.org/r/[email protected]
Thanks,
===8<===
From 3cd8f712b5d18b3729dc78127598ebbb2b1afae2 Mon Sep 17 00:00:00 2001
From: Peter Xu <[email protected]>
Date: Tue, 28 Oct 2025 10:23:35 -0400
Subject: [PATCH] fixup! migration: Fix regression of passing error_fatal into
vmstate_load_state()
--- hw/display/virtio-gpu.c | 6 ++---- hw/pci/pci.c | 5 +++-- hw/s390x/virtio-ccw.c | 6 ++++-- hw/scsi/spapr_vscsi.c | 3 ++- hw/virtio/virtio-mmio.c | 2 +- hw/virtio/virtio-pci.c | 4 ++-- 6 files changed, 14 insertions(+), 12 deletions(-)
hw/display/virtio-gpu.c +2 -4
@@ -1226,8 +1226,7 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque, size_t size,VirtIOGPU *g = opaque;struct virtio_gpu_simple_resource *res;Error *err =NULL ; -int i; -int ret =0 ; +int i, ret;/* in 2d mode we should never find unprocessed commands here */ assert (QTAILQ_EMPTY (&g->cmdq));
@@ -1294,8 +1293,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,Error *err =NULL ;struct virtio_gpu_simple_resource *res;uint32_t resource_id, pformat; -int i; -int ret =0 ; +int i, ret; g->hostmem =0 ;
hw/pci/pci.c +3 -2
@@ -921,12 +921,13 @@ const VMStateDescription vmstate_pci_device = {void pci_device_save (PCIDevice *s,QEMUFile *f) { +Error *local_err =NULL ; +int ret; +/* Clear interrupt status bit: it is implicit * in irq_state which we are saving. * This makes us compatible with old devices * which never set or clear this bit. */ -int ret; -Error *local_err =NULL ; s->config[PCI_STATUS ] &= ~PCI_STATUS_INTERRUPT ; ret =vmstate_save_state (f, &vmstate_pci_device, s,NULL , &local_err);if (ret <0 ) {
hw/s390x/virtio-ccw.c +4 -2
@@ -1130,8 +1130,9 @@ static int virtio_ccw_load_queue(DeviceState *d, int n, QEMUFile *f)static void virtio_ccw_save_config (DeviceState *d,QEMUFile *f) {VirtioCcwDevice *dev =VIRTIO_CCW_DEVICE (d); -int ret;Error *local_err =NULL ; +int ret; + ret =vmstate_save_state (f, &vmstate_virtio_ccw_dev, dev,NULL , &local_err);if (ret <0 ) {error_report_err (local_err);
@@ -1141,8 +1142,9 @@ static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f)static int virtio_ccw_load_config (DeviceState *d,QEMUFile *f) {VirtioCcwDevice *dev =VIRTIO_CCW_DEVICE (d); -int ret;Error *local_err =NULL ; +int ret; + ret =vmstate_load_state (f, &vmstate_virtio_ccw_dev, dev,1 , &local_err);if (ret <0 ) {error_report_err (local_err);
hw/scsi/spapr_vscsi.c +2 -1
@@ -628,8 +628,9 @@ static const VMStateDescription vmstate_spapr_vscsi_req = {static void vscsi_save_request (QEMUFile *f,SCSIRequest *sreq) {vscsi_req *req = sreq->hba_private; -int rc;Error *local_err =NULL ; +int rc; +assert (req->active); rc =vmstate_save_state (f, &vmstate_spapr_vscsi_req, req,NULL , &local_err);
hw/virtio/virtio-mmio.c +1 -1
@@ -624,8 +624,8 @@ static void virtio_mmio_save_extra_state(DeviceState *opaque, QEMUFile *f)static int virtio_mmio_load_extra_state (DeviceState *opaque,QEMUFile *f) {VirtIOMMIOProxy *proxy =VIRTIO_MMIO (opaque); -int ret;Error *local_err =NULL ; +int ret; ret =vmstate_load_state (f, &vmstate_virtio_mmio, proxy,1 , &local_err);if (ret <0 ) {
hw/virtio/virtio-pci.c +2 -2
@@ -187,8 +187,8 @@ static bool virtio_pci_has_extra_state(DeviceState *d)static void virtio_pci_save_extra_state (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); -int ret;Error *local_err =NULL ; +int ret; ret =vmstate_save_state (f, &vmstate_virtio_pci, proxy,NULL , &local_err);if (ret <0 ) {
@@ -199,8 +199,8 @@ static void virtio_pci_save_extra_state(DeviceState *d, QEMUFile *f)static int virtio_pci_load_extra_state (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); -int ret;Error *local_err =NULL ; +int ret; ret =vmstate_load_state (f, &vmstate_virtio_pci, proxy,1 , &local_err);if (ret <0 ) {
Signature · 5 lines
2.50.1 -- Peter Xu
PATCH v2 2/2 migration: Fix memory leak in postcopy_ram_listen_thread()
In reply to Arun Menoncommit 94272d9b45 introduced a memory leak in the postcopy_ram_listen_thread() call.
We need to free the local error object in the if clause as well.
--- migration/savevm.c | 1 + 1 file changed, 1 insertion(+)
migration/savevm.c +1 -0
@@ -2141,6 +2141,7 @@ static void *postcopy_ram_listen_thread(void *opaque)"bitmaps may be lost, and present migrated dirty " "bitmaps are correctly migrated and valid." , __func__, load_res); +error_free (local_err); load_res =0 ;/* prevent further exit() */ }else { error_prepend(&local_err,
Signature · 1 line
2.51.0