[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 13/26] virtio/pci/migration: Convert to VMState
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 13/26] virtio/pci/migration: Convert to VMState |
Date: |
Sun, 15 Oct 2017 06:23:23 +0300 |
From: "Dr. David Alan Gilbert" <address@hidden>
Convert the 'modern_state' part of virtio-pci to modern migration
macros.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/virtio/virtio-pci.c | 108 +++++++++++++------------------------------------
1 file changed, 27 insertions(+), 81 deletions(-)
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 8b0d6b6..f825a68 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -88,77 +88,19 @@ static void virtio_pci_save_config(DeviceState *d, QEMUFile
*f)
qemu_put_be16(f, vdev->config_vector);
}
-static void virtio_pci_load_modern_queue_state(VirtIOPCIQueue *vq,
- QEMUFile *f)
-{
- vq->num = qemu_get_be16(f);
- vq->enabled = qemu_get_be16(f);
- vq->desc[0] = qemu_get_be32(f);
- vq->desc[1] = qemu_get_be32(f);
- vq->avail[0] = qemu_get_be32(f);
- vq->avail[1] = qemu_get_be32(f);
- vq->used[0] = qemu_get_be32(f);
- vq->used[1] = qemu_get_be32(f);
-}
-
-static bool virtio_pci_has_extra_state(DeviceState *d)
-{
- VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
-
- return proxy->flags & VIRTIO_PCI_FLAG_MIGRATE_EXTRA;
-}
-
-static int get_virtio_pci_modern_state(QEMUFile *f, void *pv, size_t size,
- VMStateField *field)
-{
- VirtIOPCIProxy *proxy = pv;
- int i;
-
- proxy->dfselect = qemu_get_be32(f);
- proxy->gfselect = qemu_get_be32(f);
- proxy->guest_features[0] = qemu_get_be32(f);
- proxy->guest_features[1] = qemu_get_be32(f);
- for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
- virtio_pci_load_modern_queue_state(&proxy->vqs[i], f);
- }
-
- return 0;
-}
-
-static void virtio_pci_save_modern_queue_state(VirtIOPCIQueue *vq,
- QEMUFile *f)
-{
- qemu_put_be16(f, vq->num);
- qemu_put_be16(f, vq->enabled);
- qemu_put_be32(f, vq->desc[0]);
- qemu_put_be32(f, vq->desc[1]);
- qemu_put_be32(f, vq->avail[0]);
- qemu_put_be32(f, vq->avail[1]);
- qemu_put_be32(f, vq->used[0]);
- qemu_put_be32(f, vq->used[1]);
-}
-
-static int put_virtio_pci_modern_state(QEMUFile *f, void *pv, size_t size,
- VMStateField *field, QJSON *vmdesc)
-{
- VirtIOPCIProxy *proxy = pv;
- int i;
-
- qemu_put_be32(f, proxy->dfselect);
- qemu_put_be32(f, proxy->gfselect);
- qemu_put_be32(f, proxy->guest_features[0]);
- qemu_put_be32(f, proxy->guest_features[1]);
- for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
- virtio_pci_save_modern_queue_state(&proxy->vqs[i], f);
+static const VMStateDescription vmstate_virtio_pci_modern_queue_state = {
+ .name = "virtio_pci/modern_queue_state",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT16(num, VirtIOPCIQueue),
+ VMSTATE_UNUSED(1), /* enabled was stored as be16 */
+ VMSTATE_BOOL(enabled, VirtIOPCIQueue),
+ VMSTATE_UINT32_ARRAY(desc, VirtIOPCIQueue, 2),
+ VMSTATE_UINT32_ARRAY(avail, VirtIOPCIQueue, 2),
+ VMSTATE_UINT32_ARRAY(used, VirtIOPCIQueue, 2),
+ VMSTATE_END_OF_LIST()
}
-
- return 0;
-}
-
-static const VMStateInfo vmstate_info_virtio_pci_modern_state = {
- .name = "virtqueue_state",
- .get = get_virtio_pci_modern_state,
- .put = put_virtio_pci_modern_state,
};
static bool virtio_pci_modern_state_needed(void *opaque)
@@ -168,21 +110,18 @@ static bool virtio_pci_modern_state_needed(void *opaque)
return virtio_pci_modern(proxy);
}
-static const VMStateDescription vmstate_virtio_pci_modern_state = {
+static const VMStateDescription vmstate_virtio_pci_modern_state_sub = {
.name = "virtio_pci/modern_state",
.version_id = 1,
.minimum_version_id = 1,
.needed = &virtio_pci_modern_state_needed,
.fields = (VMStateField[]) {
- {
- .name = "modern_state",
- .version_id = 0,
- .field_exists = NULL,
- .size = 0,
- .info = &vmstate_info_virtio_pci_modern_state,
- .flags = VMS_SINGLE,
- .offset = 0,
- },
+ VMSTATE_UINT32(dfselect, VirtIOPCIProxy),
+ VMSTATE_UINT32(gfselect, VirtIOPCIProxy),
+ VMSTATE_UINT32_ARRAY(guest_features, VirtIOPCIProxy, 2),
+ VMSTATE_STRUCT_ARRAY(vqs, VirtIOPCIProxy, VIRTIO_QUEUE_MAX, 0,
+ vmstate_virtio_pci_modern_queue_state,
+ VirtIOPCIQueue),
VMSTATE_END_OF_LIST()
}
};
@@ -196,11 +135,18 @@ static const VMStateDescription vmstate_virtio_pci = {
VMSTATE_END_OF_LIST()
},
.subsections = (const VMStateDescription*[]) {
- &vmstate_virtio_pci_modern_state,
+ &vmstate_virtio_pci_modern_state_sub,
NULL
}
};
+static bool virtio_pci_has_extra_state(DeviceState *d)
+{
+ VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
+
+ return proxy->flags & VIRTIO_PCI_FLAG_MIGRATE_EXTRA;
+}
+
static void virtio_pci_save_extra_state(DeviceState *d, QEMUFile *f)
{
VirtIOPCIProxy *proxy = to_virtio_pci_proxy(d);
--
MST
- [Qemu-devel] [PULL 03/26] fw_cfg: add write callback, (continued)
- [Qemu-devel] [PULL 03/26] fw_cfg: add write callback, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 04/26] hw/misc: add vmcoreinfo device, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 05/26] dump: add guest ELF note, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 06/26] dump: update phys_base header field based on VMCOREINFO content, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 07/26] kdump: set vmcoreinfo location, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 08/26] scripts/dump-guest-memory.py: add vmcoreinfo, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 09/26] MAINTAINERS: add Dump maintainers, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 10/26] virtio/vhost: reset dev->log after syncing, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 11/26] pci: allow 32-bit PCI IO accesses to pass through the PCI bridge, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 12/26] hw/pci-bridge/pcie_pci_bridge: properly handle MSI unavailability case, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 13/26] virtio/pci/migration: Convert to VMState,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 14/26] PCI: PCIe access should always be little endian, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 15/26] pci: conventional-pci-device and pci-express-device interfaces, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 16/26] pci: Add interface names to hybrid PCI devices, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 17/26] pci: Add INTERFACE_PCIE_DEVICE to all PCIe devices, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 19/26] xen/pt: Mark TYPE_XEN_PT_DEVICE as hybrid, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 20/26] pci: Validate interfaces on base_class_init, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 21/26] hw/gen_pcie_root_port: make IO RO 0 on IO disabled, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 22/26] virtio: fix descriptor counting in virtqueue_pop, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 24/26] isapc: Remove unnecessary migration compatibility code, Michael S. Tsirkin, 2017/10/14
- [Qemu-devel] [PULL 23/26] virtio-pci: Replace modern_as with direct access to modern_bar, Michael S. Tsirkin, 2017/10/14