migration: Support QLIST migration

Support QLIST migration using the same principle as QTAILQ:
94869d5c52 ("migration: migrate QTAILQ").

The VMSTATE_QLIST_V macro has the same proto as VMSTATE_QTAILQ_V.
The change mainly resides in QLIST RAW macros: QLIST_RAW_INSERT_HEAD
and QLIST_RAW_REVERSE.

Tests also are provided.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
Eric Auger 2020-01-13 14:48:23 +01:00 committed by Juan Quintela
parent 0ab994867c
commit 4746dbf8a9
5 changed files with 305 additions and 0 deletions

View file

@ -229,6 +229,7 @@ extern const VMStateInfo vmstate_info_tmp;
extern const VMStateInfo vmstate_info_bitmap;
extern const VMStateInfo vmstate_info_qtailq;
extern const VMStateInfo vmstate_info_gtree;
extern const VMStateInfo vmstate_info_qlist;
#define type_check_2darray(t1,t2,n,m) ((t1(*)[n][m])0 - (t2*)0)
/*
@ -798,6 +799,26 @@ extern const VMStateInfo vmstate_info_gtree;
.offset = offsetof(_state, _field), \
}
/*
* For migrating a QLIST
* Target QLIST needs be properly initialized.
* _type: type of QLIST element
* _next: name of QLIST_ENTRY entry field in QLIST element
* _vmsd: VMSD for QLIST element
* size: size of QLIST element
* start: offset of QLIST_ENTRY in QTAILQ element
*/
#define VMSTATE_QLIST_V(_field, _state, _version, _vmsd, _type, _next) \
{ \
.name = (stringify(_field)), \
.version_id = (_version), \
.vmsd = &(_vmsd), \
.size = sizeof(_type), \
.info = &vmstate_info_qlist, \
.offset = offsetof(_state, _field), \
.start = offsetof(_type, _next), \
}
/* _f : field name
_f_n : num of elements field_name
_n : num of elements