From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Fabiano Rosas <farosas@suse.de>,
peterx@redhat.com, "Michael S. Tsirkin" <mst@redhat.com>
Subject: [PATCH for-12.0 1/6] pcie/aer: Remove the usage of VMSTATE_VALIDATE()
Date: Fri, 20 Nov 2026 07:49:18 -0500 [thread overview]
Message-ID: <20261120124923.1656220-2-peterx@redhat.com> (raw)
In-Reply-To: <20261120124923.1656220-1-peterx@redhat.com>
Paving way removing it. We can replace it with a post_load_errp() instead.
Tested with migration with "-device ioh3420,id=rp0" against pre-patch,
which means migration compatibility is unaffected.
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
hw/pci/pcie_aer.c | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index 43b14c1f22..87248556d4 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -807,21 +807,51 @@ static const VMStateDescription vmstate_pcie_aer_err = {
}
};
-static bool pcie_aer_state_log_num_valid(void *opaque, int version_id)
-{
- PCIEAERLog *s = opaque;
+typedef struct {
+ uint16_t v;
+} tmp_u16;
+static bool pcie_aer_state_log_num_valid(PCIEAERLog *s)
+{
return s->log_num <= s->log_max;
}
+static bool pcie_aer_state_log_num_post_load(void *opaque, int version,
+ Error **errp)
+{
+ PCIEAERLog *s = container_of(opaque, PCIEAERLog, log_num);
+
+ if (!pcie_aer_state_log_num_valid(s)) {
+ error_setg(errp, "PCIe AER log num too big: log_num > log_max");
+ return false;
+ }
+
+ return true;
+}
+
+static const VMStateDescription vmstate_pcie_aer_log_num = {
+ .name = "PCIE_AER_ERROR_LOG/NUM",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .post_load_errp = pcie_aer_state_log_num_post_load,
+ .fields = (const VMStateField[]) {
+ VMSTATE_UINT16(v, tmp_u16),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
const VMStateDescription vmstate_pcie_aer_log = {
.name = "PCIE_AER_ERROR_LOG",
.version_id = 1,
.minimum_version_id = 1,
.fields = (const VMStateField[]) {
- VMSTATE_UINT16(log_num, PCIEAERLog),
+ /*
+ * Only to use STRUCT for a post_load_errp(). New code should try
+ * to use something look better, e.g. subsections in order.
+ */
+ VMSTATE_STRUCT(log_num, PCIEAERLog, 1,
+ vmstate_pcie_aer_log_num, uint16_t),
VMSTATE_UINT16_EQUAL(log_max, PCIEAERLog),
- VMSTATE_VALIDATE("log_num <= log_max", pcie_aer_state_log_num_valid),
VMSTATE_STRUCT_VARRAY_POINTER_UINT16(log, PCIEAERLog, log_num,
vmstate_pcie_aer_err, PCIEAERErr),
VMSTATE_END_OF_LIST()
--
2.56.0
next prev parent reply other threads:[~2026-11-20 12:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 12:49 [PATCH for-12.0 0/6] migration: Remove VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
2026-11-20 12:49 ` Peter Xu [this message]
2026-11-20 12:49 ` [PATCH for-12.0 2/6] hw/gpio/zaurus: Move VMSTATE_VALIDATE() check into post_load_errp() Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 3/6] hpet: Move VMSTATE_VALIDATE() check into post_load Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 4/6] arm/machine: Move all VMSTATE_VALIDATE() usages " Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 5/6] rust: Replace vmstate_validate with post_load Peter Xu
2026-11-20 14:25 ` Zhao Liu
2026-11-20 15:43 ` Peter Xu
2026-11-20 12:49 ` [PATCH for-12.0 6/6] migration: Drop VMSTATE_VALIDATE() and VMS_MUST_EXIST Peter Xu
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=20261120124923.1656220-2-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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.