qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [RFC][PATCH 25/45] qemu-kvm: Update MSI cache on kvm_msi_ir


From: Jan Kiszka
Subject: [Qemu-devel] [RFC][PATCH 25/45] qemu-kvm: Update MSI cache on kvm_msi_irqfd_set
Date: Mon, 17 Oct 2011 11:27:59 +0200

Updating the MSI message registration on kvm_msi_irqfd_set will allow us
to switch to a lazy mode and remove the need to track message changes in
the device config space.

Signed-off-by: Jan Kiszka <address@hidden>
---
 hw/virtio-pci.c |   10 ++++++----
 kvm.h           |    3 ++-
 qemu-kvm.c      |   17 ++++++++++++++---
 3 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 6718945..85d6771 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -521,10 +521,10 @@ static void virtio_pci_guest_notifier_read(void *opaque)
 }
 
 static int virtio_pci_mask_vq(PCIDevice *dev, unsigned int vector,
-                              VirtQueue *vq, bool masked)
+                              MSIMessage *msg, VirtQueue *vq, bool masked)
 {
     EventNotifier *notifier = virtio_queue_get_guest_notifier(vq);
-    int r = kvm_msi_irqfd_set(&dev->msix_cache[vector],
+    int r = kvm_msi_irqfd_set(msg, &dev->msix_cache[vector],
                               event_notifier_get_fd(notifier),
                               !masked);
     if (r < 0) {
@@ -554,7 +554,8 @@ static int virtio_pci_msi_vector_config(PCIDevice *dev, 
unsigned int vector,
         if (virtio_queue_vector(vdev, n) != vector) {
             continue;
         }
-        r = virtio_pci_mask_vq(dev, vector, virtio_get_queue(vdev, n), masked);
+        r = virtio_pci_mask_vq(dev, vector, msg, virtio_get_queue(vdev, n),
+                               masked);
         if (r < 0) {
             goto undo;
         }
@@ -565,7 +566,8 @@ undo:
         if (virtio_queue_vector(vdev, n) != vector) {
             continue;
         }
-        virtio_pci_mask_vq(dev, vector, virtio_get_queue(vdev, n), !masked);
+        virtio_pci_mask_vq(dev, vector, msg, virtio_get_queue(vdev, n),
+                           !masked);
     }
     return r;
 }
diff --git a/kvm.h b/kvm.h
index fe2eec5..8647647 100644
--- a/kvm.h
+++ b/kvm.h
@@ -208,7 +208,8 @@ int kvm_msi_message_add(MSIMessage *msg, MSIRoutingCache 
*cache);
 int kvm_msi_message_del(MSIRoutingCache *cache);
 int kvm_msi_message_update(MSIMessage *msg, MSIRoutingCache *cache);
 
-int kvm_msi_irqfd_set(MSIRoutingCache *cache, int fd, bool assigned);
+int kvm_msi_irqfd_set(MSIMessage *msg, MSIRoutingCache *cache, int fd,
+                      bool assigned);
 
 int kvm_commit_irq_routes(void);
 
diff --git a/qemu-kvm.c b/qemu-kvm.c
index ab7703b..6bdd7b5 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -524,10 +524,21 @@ int kvm_msi_message_update(MSIMessage *msg, 
MSIRoutingCache *cache)
 }
 
 
-int kvm_msi_irqfd_set(MSIRoutingCache *cache, int fd, bool assigned)
+int kvm_msi_irqfd_set(MSIMessage *msg, MSIRoutingCache *cache, int fd,
+                      bool assigned)
 {
-    if (cache->type == MSI_ROUTE_NONE) {
-        return assigned ? -EINVAL : 0;
+    int ret;
+
+    if (assigned) {
+        if (cache->type == MSI_ROUTE_NONE) {
+            return -EINVAL;
+        }
+        ret = kvm_msi_message_update(msg, cache);
+        if (ret < 0) {
+            return ret;
+        }
+    } else if (cache->type == MSI_ROUTE_NONE) {
+        return 0;
     }
     cache->kvm_irqfd = assigned ? fd : -1;
     return kvm_set_irqfd(cache->kvm_gsi, fd, assigned);
-- 
1.7.3.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]