Skip to contentSkip to conversation

qemu: fix up load for msi-x

PATCH Superseded Michael S. Tsirkin 2 participants 4 messages Jul 1, 2009 1 message not in the archive KVM

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#4 lore raw

PATCH 2/2 qemu: fix up load for msi-x

In reply to a message not in the archive

Add missing load of control vector in virtio

---
 hw/virtio.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
hw/virtio.c +3 -0
index 843be86..e9dd7a0 100644
@@ -665,6 +665,9 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
     vdev->config_len = qemu_get_be32(f);
     qemu_get_buffer(f, vdev->config, vdev->config_len);
 
+    if (vdev->nvectors)
+        qemu_get_be16s(f, &vdev->config_vector);
+
     num = qemu_get_be32(f);
 
     for (i = 0; i < num; i++) {
Signature · 1 line
1.6.2.2
#1 lore raw

PATCH 1/2 fix segfault in msix_save

In reply to a message not in the archive

This fixes segfault reported by Kevin Wolf,
and simplifies the code in msix_save.

---
 hw/msix.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
hw/msix.c +7 -5
index 4ab6da6..98c62a5 100644
@@ -284,11 +284,13 @@ int msix_uninit(PCIDevice *dev)
 
 void msix_save(PCIDevice *dev, QEMUFile *f)
 {
-    unsigned nentries = (pci_get_word(dev->config + PCI_MSIX_FLAGS) &
-                         PCI_MSIX_FLAGS_QSIZE) + 1;
-    qemu_put_buffer(f, dev->msix_table_page, nentries * MSIX_ENTRY_SIZE);
-    qemu_put_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING,
-                    (nentries + 7) / 8);
+    unsigned n = dev->msix_entries_nr;
+
+    if (!dev->cap_present & QEMU_PCI_CAP_MSIX)
+        return;
+
+    qemu_put_buffer(f, dev->msix_table_page, n * MSIX_ENTRY_SIZE);
+    qemu_put_buffer(f, dev->msix_table_page + MSIX_PAGE_PENDING, (n + 7) / 8);
 }
 
 /* Should be called after restoring the config space. */
Signature · 1 line
1.6.2.2