@@ -105,6 +105,7 @@ void *qemu_get_virtqueue_element_from_old(VirtIODevice *vdev,
size_t sz);
void qemu_put_virtqueue_element_old(const VirtQueueElement *elem,
VirtQueueElementOld *data);
+extern const VMStateDescription vmstate_virtqueue_element_old;
#define VIRTIO_QUEUE_MAX 1024
@@ -448,6 +448,17 @@ extern const VMStateInfo vmstate_info_qlist;
.offset = vmstate_offset_varray(_state, _field, _type), \
}
+#define VMSTATE_VARRAY_UINT32_UNSAFE(_field, _state, _field_num, _version, \
+ _info, _type) {\
+ .name = (stringify(_field)), \
+ .version_id = (_version), \
+ .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+ .info = &(_info), \
+ .size = sizeof(_type), \
+ .flags = VMS_VARRAY_UINT32, \
+ .offset = vmstate_offset_varray(_state, _field, _type), \
+}
+
#define VMSTATE_VSTRUCT_TEST(_field, _state, _test, _version, _vmsd, _type, _struct_version) { \
.name = (stringify(_field)), \
.version_id = (_version), \
@@ -3165,6 +3165,38 @@ static bool virtio_disabled_needed(void *opaque)
return vdev->disabled;
}
+const VMStateDescription vmstate_virtqueue_element_old = {
+ .name = "virtqueue_element",
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32(index, VirtQueueElementOld),
+ VMSTATE_UINT32(in_num, VirtQueueElementOld),
+ VMSTATE_UINT32(out_num, VirtQueueElementOld),
+ /*
+ * TODO: Needed for packed
+ * VMSTATE_UINT16(ndescs, VirtQueueElement),
+ */
+
+ VMSTATE_VALIDATE("fit", vq_element_in_range),
+ VMSTATE_VARRAY_UINT32_UNSAFE(in_addr, VirtQueueElementOld, in_num, 0,
+ vmstate_info_uint64, hwaddr),
+ VMSTATE_VARRAY_UINT32_UNSAFE(out_addr, VirtQueueElementOld, out_num, 0,
+ vmstate_info_uint64, hwaddr),
+
+ /*
+ * Assume iovec[n] == uint64_t[n*2]
+ * TODO: Probably need to send each field individually because of
+ * endianess.
+ */
+ VMSTATE_VARRAY_MULTIPLY(in_sg_64, VirtQueueElementOld, in_num,
+ sizeof(struct iovec) / sizeof(uint64_t),
+ vmstate_info_uint64, uint64_t),
+ VMSTATE_VARRAY_MULTIPLY(out_sg_64, VirtQueueElementOld, out_num,
+ sizeof(struct iovec) / sizeof(uint64_t),
+ vmstate_info_uint64, uint64_t),
+ VMSTATE_END_OF_LIST()
+ },
+};
+
static const VMStateDescription vmstate_virtqueue = {
.name = "virtqueue_state",
.version_id = 1,
VMStateDescription of an inflight descriptor represented in VirtQueueElementOld. TODO: Convert to VirtQueueElement. Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com> --- include/hw/virtio/virtio.h | 1 + include/migration/vmstate.h | 11 +++++++++++ hw/virtio/virtio.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+)