From: no-reply@sashiko.virtuozzo.com
To: svt-core@virtuozzo.com,
Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Cc: andrey.drobyshev@virtuozzo.com
Subject: Re: [PATCH QEMU HCI-8.1 v6 16/34] migration: Fix regression of passing error_fatal into vmstate_load_state()
Date: Fri, 30 Oct 2026 14:59:18 +0000 [thread overview]
Message-ID: <010701a18d5286a8-d32c5af2-ccf4-49aa-97ac-f7ce18168fac-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261030-vfio_v1-v6-16-45de246bc92e@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] migration: vmstate_load() still passes error_fatal, so load errors exit QEMU
- [Low] migration: void save callbacks only report vmstate_save_state() failure, stream not failed
--
commit 6e93ee51257c3f9653027d6d85f483dda49b4fbb
Author: Arun Menon <armenon@redhat.com>
migration: Fix regression of passing error_fatal into vmstate_load_state()
This patch replaces error_fatal in the vmstate_load_state() and
vmstate_save_state() calls in several hw/ files with a local Error
object. Failures are now reported with error_report_err() and, where the
caller can return a value, propagated.
Link: https://lore.kernel.org/r/20251028-solve_error_fatal_regression-v2-1-dab24c808a28@redhat.com
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
[ ... ]
> @@ -1344,9 +1350,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;
> }
[Severity: Low]
This isn't a bug, but the behaviour here changes. The old code ignored the
result of vmstate_load_state() and returned 0, while the new code returns
the failure to the caller.
The error is also printed here by error_report_err(). Could the outer
vmstate_load_state() caller print it a second time, so that the same
failure is reported twice?
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
[ ... ]
> 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. */
> 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);
> }
[Severity: Low]
Can a save failure here go unnoticed by the migration core?
pci_device_save() returns void, so it prints the error and returns
normally. vmstate_save_state_v() only sets the Error object on failure:
migration/vmstate.c:vmstate_save_state_v() {
...
if (ret) {
error_setg(errp, "Save of field %s/%s failed",
vmsd->name, field->name);
...
return ret;
}
}
It does not call qemu_file_set_error(), so the QEMUFile error state stays
clear. virtio_save() then keeps writing the stream, and the migration or
snapshot could be left incomplete with no failure flagged.
The same pattern appears in the other void save callbacks changed by this
patch:
hw/virtio/virtio-pci.c:virtio_pci_save_extra_state()
hw/virtio/virtio-mmio.c:virtio_mmio_save_extra_state()
hw/s390x/virtio-ccw.c:virtio_ccw_save_config()
> diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
> --- a/hw/scsi/spapr_vscsi.c
> +++ b/hw/scsi/spapr_vscsi.c
[ ... ]
> + 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);
> }
[Severity: Low]
vscsi_save_request() is a void .save_request hook, so the SCSI core cannot
see this failure either. Is it intended that the error is only printed
here and the save carries on?
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
[ ... ]
The patch fixes the hw/ callers, but the central loader still passes
error_fatal:
migration/savevm.c:vmstate_load() {
...
return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id,
&error_fatal);
}
[Severity: Medium]
Does this leave the regression described in the commit message in place for
the main load path?
vmstate_load() is called from qemu_loadvm_section_start_full() and
qemu_loadvm_section_part_end(). Any vmsd load failure there, such as a
version_id that is too new or too old, or a pre_load, get or post_load
failure, still calls exit(1) inside vmstate_load_state().
The error handling in both callers is therefore not reached for vmsd
devices:
ret = vmstate_load(f, se);
if (ret < 0) {
error_report("error while loading state for instance 0x%"PRIx32" of"
" device '%s'", instance_id, idstr);
return ret;
}
and:
ret = vmstate_load(f, se);
if (ret < 0) {
error_report("error while loading state section id %d(%s)",
section_id, se->idstr);
return ret;
}
A grep of migration/savevm.c at this commit and at the end of the series
shows the same &error_fatal in vmstate_load(). Should vmstate_load() also
use a local Error object and propagate the failure?
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261030-vfio_v1-v6-0-45de246bc92e@virtuozzo.com?part=16
next prev parent reply other threads:[~2026-10-30 14:59 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 14:45 [PATCH QEMU HCI-8.1 v6 00/34] vfio: support qemu-update with passed through GPU's and vGPU's #VSTOR-103860 Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 01/34] VZ: migration/cpr-exec: fix Error leak in preserve_ram() Andrey Drobyshev
2026-10-30 14:49 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 02/34] migration/cpr-exec: restore RAM write access if exec fails Andrey Drobyshev
2026-10-30 14:49 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 03/34] vfio/region: create BAR dma-bufs with O_CLOEXEC Andrey Drobyshev
2026-10-30 14:50 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 04/34] migration/cpr-exec: require a file or exec migration URI Andrey Drobyshev
2026-10-30 14:50 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 05/34] migration: close the CPR state if the outgoing channel fails to open Andrey Drobyshev
2026-10-30 14:51 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 06/34] migration/cpr-exec: close the persisted state if the " Andrey Drobyshev
2026-10-30 14:51 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 07/34] migration: don't refuse a blocker over a migration of another mode Andrey Drobyshev
2026-10-30 14:53 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 08/34] migration: Plug memory leaks after migrate_set_error() Andrey Drobyshev
2026-10-30 14:52 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 09/34] hw/vfio: Fix liveness check in vfio_connect_kvm_msi_virq() Andrey Drobyshev
2026-10-30 14:53 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 10/34] vfio/pci: Reject invalid MSI-X Table and PBA BIR values Andrey Drobyshev
2026-10-30 14:53 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 11/34] vfio/pci: Fix information leak in vfio_rom_read() Andrey Drobyshev
2026-10-30 14:54 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 12/34] vfio/pci: Initialize rom_read_failed in vfio_pci_load_rom() Andrey Drobyshev
2026-10-30 14:54 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 13/34] vfio/pci: Grow buffer in vfio_pci_host_match() Andrey Drobyshev
2026-10-30 14:54 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 14/34] q35: Fix migration of SMRAM state Andrey Drobyshev
2026-10-30 14:56 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 15/34] migration: ensure APIC is loaded prior to VFIO PCI devices Andrey Drobyshev
2026-10-30 14:55 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 16/34] migration: Fix regression of passing error_fatal into vmstate_load_state() Andrey Drobyshev
2026-10-30 14:59 ` no-reply [this message]
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 17/34] migration: vmstate_save_state_v: fix double error_setg Andrey Drobyshev
2026-10-30 14:59 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 18/34] migration: yank: Move register instance earlier Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 19/34] migration: Free cpr-transfer MigrationAddress along with gsource Andrey Drobyshev
2026-10-30 15:01 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 20/34] migration: Move CPR HUP watch to cpr-transfer.c Andrey Drobyshev
2026-10-30 15:02 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 21/34] migration: Fix crash on second migration when cancel early Andrey Drobyshev
2026-10-30 15:04 ` no-reply
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 22/34] kvm: tolerate ioctls after kvm_close() Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 23/34] kvm: fix coalesced MMIO flush racing with kvm_close() Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 24/34] migration/cpr: add cpr_is_in_progress() Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 25/34] vfio/migration: don't migrate device state during CPR Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 26/34] vfio/migration: don't assume the device is running on CPR incoming Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 27/34] migration/ram: don't start dirty logging in CPR modes Andrey Drobyshev
2026-10-30 14:45 ` [PATCH QEMU HCI-8.1 v6 28/34] VZ: vfio/cpr: don't close KVM on cpr-exec Andrey Drobyshev
2026-10-30 14:46 ` [PATCH QEMU HCI-8.1 v6 29/34] VZ: migration/cpr-exec: abort cpr-exec if memory can't be preserved Andrey Drobyshev
2026-10-30 14:46 ` [PATCH QEMU HCI-8.1 v6 30/34] VZ: migration/cpr-exec: take the vhost-net devices back if exec fails Andrey Drobyshev
2026-10-30 14:46 ` [PATCH QEMU HCI-8.1 v6 31/34] VZ: migration/cpr-exec: don't exec if a vhost-net device can't be released Andrey Drobyshev
2026-10-30 14:46 ` [PATCH QEMU HCI-8.1 v6 32/34] VZ: vfio/region: preserve BAR mappings across cpr-exec #VSTOR-103860 Andrey Drobyshev
2026-10-30 14:46 ` [PATCH QEMU HCI-8.1 v6 33/34] VZ: migration/cpr-exec: allow cpr-exec with VFIO devices #VSTOR-103860 Andrey Drobyshev
2026-10-30 14:46 ` [PATCH QEMU HCI-8.1 v6 34/34] VZ: vfio/migration: don't wait for stop-copy-only device state #VSTOR-141821 Andrey Drobyshev
2026-11-02 10:33 ` [PATCH QEMU HCI-8.1 v6 00/34] vfio: support qemu-update with passed through GPU's and vGPU's #VSTOR-103860 Andrey Drobyshev
2026-11-02 10:36 Andrey Drobyshev
2026-11-02 10:36 ` [PATCH QEMU HCI-8.1 v6 16/34] migration: Fix regression of passing error_fatal into vmstate_load_state() Andrey Drobyshev
2026-11-02 10:51 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=010701a18d5286a8-d32c5af2-ccf4-49aa-97ac-f7ce18168fac-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=andrey.drobyshev@virtuozzo.com \
--cc=svt-core@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.