diff options
| author | Fabiano Rosas <farosas@suse.de> | 2026-08-18 15:24:38 -0300 |
|---|---|---|
| committer | Fabiano Rosas <farosas@suse.de> | 2026-08-28 09:09:31 -0300 |
| commit | 797b88eddd7066febfb103b7d48ed8b6a693c06b (patch) | |
| tree | d35f14c261d5b1784d06df6df699d35980014b5a /migration | |
| parent | 028d4ec43de6e9b165e98cd35853b6a623faeb9f (diff) | |
| download | qemu-797b88eddd7066febfb103b7d48ed8b6a693c06b.tar.gz qemu-797b88eddd7066febfb103b7d48ed8b6a693c06b.zip | |
migration: Add VMS_NO_STATE flag
There are a few special cases of vmstate usage:
The vmstate_msix and vmstate_scsi_device have fields that contain no
data, only a vmstate_info structure.
The VMSTATE_VALIDATE macro serves only to invoke the .field_exists
routine for validation.
Regardless whether these scenarios are valid, add a separate flag to
identify them so we can enforce common constraints for the normal
vmstates such as having a size greater than zero.
Note that n_elems is hardcoded to 1 for all vmstates, except
VMS_[V]ARRAY, so VMSTATE_VALIDATE needed to set VMS_ARRAY to be able
to force n_elems to 0. This patch now checks the flag at
vmstate_n_elems().
Acked-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
Diffstat (limited to 'migration')
| -rw-r--r-- | migration/vmstate.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/migration/vmstate.c b/migration/vmstate.c index 9556030f89..1f9cb45923 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -110,12 +110,16 @@ static uint64_t vmstate_read_from_offset(const VMStateStructMember *member, static uint64_t vmstate_n_elems(void *opaque, const VMStateField *field) { - uint64_t n_elems = 1; + uint64_t n_elems; if (field->flags & VMS_ARRAY) { n_elems = field->num; } else if (field->flags & VMS_VARRAY) { n_elems = vmstate_read_from_offset(&field->num_indirect, opaque); + } else if (field->flags & VMS_MUST_EXIST && field->flags & VMS_NO_STATE) { + n_elems = 0; + } else { + n_elems = 1; } trace_vmstate_n_elems(field->name, n_elems); |
