aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-pci.c
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2009-06-21 19:50:40 +0300
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-24 09:09:15 -0500
commitff24bd589c657ad82ae0f151c4906f120a91f6f3 (patch)
tree137df1a224d2de18b86bbdbb1bbc3311dcddb35a /hw/virtio-pci.c
parentaba800a3ffdffd9484d458344bfea8886e9062d2 (diff)
qemu/virtio: virtio save/load bindings
Implement bindings for virtio save/load. Use them in virtio pci. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-pci.c')
-rw-r--r--hw/virtio-pci.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index f4bc1528a9..51c7a60c34 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -105,6 +105,46 @@ static void virtio_pci_notify(void *opaque, uint16_t vector)
qemu_set_irq(proxy->pci_dev.irq[0], proxy->vdev->isr & 1);
}
+static void virtio_pci_save_config(void * opaque, QEMUFile *f)
+{
+ VirtIOPCIProxy *proxy = opaque;
+ pci_device_save(&proxy->pci_dev, f);
+ msix_save(&proxy->pci_dev, f);
+ if (msix_present(&proxy->pci_dev))
+ qemu_put_be16(f, proxy->vdev->config_vector);
+}
+
+static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f)
+{
+ VirtIOPCIProxy *proxy = opaque;
+ if (msix_present(&proxy->pci_dev))
+ qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n));
+}
+
+static int virtio_pci_load_config(void * opaque, QEMUFile *f)
+{
+ VirtIOPCIProxy *proxy = opaque;
+ int ret;
+ ret = pci_device_load(&proxy->pci_dev, f);
+ if (ret)
+ return ret;
+ msix_load(&proxy->pci_dev, f);
+ if (msix_present(&proxy->pci_dev))
+ qemu_get_be16s(f, &proxy->vdev->config_vector);
+ return 0;
+}
+
+static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f)
+{
+ VirtIOPCIProxy *proxy = opaque;
+ uint16_t vector;
+ if (!msix_present(&proxy->pci_dev))
+ return 0;
+ qemu_get_be16s(f, &vector);
+ virtio_queue_set_vector(proxy->vdev, n, vector);
+ return 0;
+}
+
static void virtio_pci_reset(void *opaque)
{
VirtIOPCIProxy *proxy = opaque;
@@ -319,7 +359,11 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
}
static const VirtIOBindings virtio_pci_bindings = {
- .notify = virtio_pci_notify
+ .notify = virtio_pci_notify,
+ .save_config = virtio_pci_save_config,
+ .load_config = virtio_pci_load_config,
+ .save_queue = virtio_pci_save_queue,
+ .load_queue = virtio_pci_load_queue,
};
static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,