[PATCH 2/9] msix: make kvm specific initialization a function

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

 



Signed-off-by: Avi Kivity <avi@xxxxxxxxxx>
---
 hw/msix.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/hw/msix.c b/hw/msix.c
index 312439a..2e2ce5a 100644
--- a/hw/msix.c
+++ b/hw/msix.c
@@ -48,6 +48,17 @@ int msix_supported;
 
 #ifdef CONFIG_KVM
 /* KVM specific MSIX helpers */
+
+static void kvm_msix_init(PCIDevice *dev)
+{
+#ifdef KVM_CAP_IRQCHIP
+    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
+        dev->msix_irq_entries = qemu_malloc(dev->msix_entries_nr *
+                                            sizeof *dev->msix_irq_entries);
+    }
+#endif
+}
+
 static void kvm_msix_free(PCIDevice *dev)
 {
     int vector, changed = 0;
@@ -150,6 +161,7 @@ static void kvm_msix_del(PCIDevice *dev, unsigned vector)
 }
 #else
 
+static void kvm_msix_init(PCIDevice *dev) {}
 static void kvm_msix_free(PCIDevice *dev) {}
 static void kvm_msix_update(PCIDevice *dev, int vector,
                             int was_masked, int is_masked) {}
@@ -394,12 +406,7 @@ int msix_init(struct PCIDevice *dev, unsigned short nentries,
     if (ret)
         goto err_config;
 
-#ifdef KVM_CAP_IRQCHIP
-    if (kvm_enabled() && kvm_irqchip_in_kernel()) {
-        dev->msix_irq_entries = qemu_malloc(nentries *
-                                            sizeof *dev->msix_irq_entries);
-    }
-#endif
+    kvm_msix_init(dev);
 
     dev->cap_present |= QEMU_PCI_CAP_MSIX;
     return 0;
-- 
1.7.2.3

--
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