cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
Blob Blame History Raw
From 3420a9a7d1765a77f5a03e38c0ec6b4b69419e6a Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 7 Aug 2013 09:22:44 +0200
Subject: [PATCH 13/28] pci: add VMSTATE_MSIX

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1375867368-18979-2-git-send-email-kraxel@redhat.com>
Patchwork-id: 53038
O-Subject: [RHEL-7 qemu-kvm PATCH 1/5] pci: add VMSTATE_MSIX
Bugzilla: 838170
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>

Using a trick cut+pasted from vmstate_scsi_device
to wind up msix_save and msix_load.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
(cherry picked from commit 340b50c759d6b4ef33e514c40afcc799c0d7df7a)
---
 hw/pci/msix.c         |   33 +++++++++++++++++++++++++++++++++
 include/hw/pci/msix.h |   11 +++++++++++
 2 files changed, 44 insertions(+)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 hw/pci/msix.c         |   33 +++++++++++++++++++++++++++++++++
 include/hw/pci/msix.h |   11 +++++++++++
 2 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/hw/pci/msix.c b/hw/pci/msix.c
index e231a0d..6da75ec 100644
--- a/hw/pci/msix.c
+++ b/hw/pci/msix.c
@@ -569,3 +569,36 @@ void msix_unset_vector_notifiers(PCIDevice *dev)
     dev->msix_vector_release_notifier = NULL;
     dev->msix_vector_poll_notifier = NULL;
 }
+
+static void put_msix_state(QEMUFile *f, void *pv, size_t size)
+{
+    msix_save(pv, f);
+}
+
+static int get_msix_state(QEMUFile *f, void *pv, size_t size)
+{
+    msix_load(pv, f);
+    return 0;
+}
+
+static VMStateInfo vmstate_info_msix = {
+    .name = "msix state",
+    .get  = get_msix_state,
+    .put  = put_msix_state,
+};
+
+const VMStateDescription vmstate_msix = {
+    .name = "msix",
+    .fields = (VMStateField[]) {
+        {
+            .name         = "msix",
+            .version_id   = 0,
+            .field_exists = NULL,
+            .size         = 0,   /* ouch */
+            .info         = &vmstate_info_msix,
+            .flags        = VMS_SINGLE,
+            .offset       = 0,
+        },
+        VMSTATE_END_OF_LIST()
+    }
+};
diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
index e648410..954d82b 100644
--- a/include/hw/pci/msix.h
+++ b/include/hw/pci/msix.h
@@ -43,4 +43,15 @@ int msix_set_vector_notifiers(PCIDevice *dev,
                               MSIVectorReleaseNotifier release_notifier,
                               MSIVectorPollNotifier poll_notifier);
 void msix_unset_vector_notifiers(PCIDevice *dev);
+
+extern const VMStateDescription vmstate_msix;
+
+#define VMSTATE_MSIX(_field, _state) {                               \
+    .name       = (stringify(_field)),                               \
+    .size       = sizeof(PCIDevice),                                 \
+    .vmsd       = &vmstate_msix,                                     \
+    .flags      = VMS_STRUCT,                                        \
+    .offset     = vmstate_offset_value(_state, _field, PCIDevice),   \
+}
+
 #endif
-- 
1.7.1