[PATCHv5 06/13] qemu: add flag to disable MSI-X by default

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add global flag to disable MSI-X by default.  This is useful primarily
to make images loadable by older qemu (without msix).  Even when MSI-X
is disabled by flag, you can still load images that have MSI-X enabled.

Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
---
 hw/msix.c       |    5 ++++-
 qemu-options.hx |    2 ++
 vl.c            |    3 +++
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/hw/msix.c b/hw/msix.c
index a448eab..cc62a83 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -122,6 +122,9 @@ void msix_write_config(PCIDevice *dev, uint32_t addr,
                        uint32_t val, int len)
 {
     unsigned enable_pos = dev->msix_cap + MSIX_ENABLE_OFFSET;
+    if (!(dev->cap_present & QEMU_PCI_CAP_MSIX))
+        return;
+
     if (addr + len <= enable_pos || addr > enable_pos)
         return;
 
@@ -242,7 +245,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
 
     dev->msix_table_page = qemu_mallocz(MSIX_PAGE_SIZE);
 
-    dev->msix_mmio_index = cpu_register_io_memory(0, msix_mmio_read,
+    dev->msix_mmio_index = cpu_register_io_memory(msix_mmio_read,
                                                   msix_mmio_write, dev);
     if (dev->msix_mmio_index == -1) {
         ret = -EBUSY;
diff --git a/qemu-options.hx b/qemu-options.hx
index 9d5e05a..aa02615 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1584,3 +1584,5 @@ DEF("semihosting", 0, QEMU_OPTION_semihosting,
 DEF("old-param", 0, QEMU_OPTION_old_param,
     "-old-param      old param mode\n")
 #endif
+DEF("disable-msix", 0, QEMU_OPTION_disable_msix,
+    "-disable-msix disable msix support for PCI devices (enabled by default)\n")
diff --git a/vl.c b/vl.c
index 3242c23..f7c67bb 100644
--- a/vl.c
+++ b/vl.c
@@ -135,6 +135,7 @@ int main(int argc, char **argv)
 #include "hw/usb.h"
 #include "hw/pcmcia.h"
 #include "hw/pc.h"
+#include "hw/msix.h"
 #include "hw/audiodev.h"
 #include "hw/isa.h"
 #include "hw/baum.h"
@@ -5699,6 +5700,8 @@ int main(int argc, char **argv, char **envp)
                 xen_mode = XEN_ATTACH;
                 break;
 #endif
+            case QEMU_OPTION_disable_msix:
+                msix_disable = 1;
             }
         }
     }
-- 
1.6.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux