diff mbox

[02/16] kvm: deassign irq for INTx

Message ID 1237261817-27955-3-git-send-email-sheng@linux.intel.com (mailing list archive)
State Accepted
Headers show

Commit Message

Sheng Yang March 17, 2009, 3:50 a.m. UTC
From: Marcelo Tosatti <mtosatti@redhat.com>

Also add irq_requested_type for assigned device to track current status.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
---
 qemu/hw/device-assignment.c |   12 ++++++++++++
 qemu/hw/device-assignment.h |    1 +
 2 files changed, 13 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/qemu/hw/device-assignment.c b/qemu/hw/device-assignment.c
index 7c73210..4ec655c 100644
--- a/qemu/hw/device-assignment.c
+++ b/qemu/hw/device-assignment.c
@@ -536,6 +536,17 @@  static int assign_irq(AssignedDevInfo *adev)
         calc_assigned_dev_id(dev->h_busnr, dev->h_devfn);
     assigned_irq_data.guest_irq = irq;
     assigned_irq_data.host_irq = dev->real_device.irq;
+#ifdef KVM_CAP_ASSIGN_DEV_IRQ
+    if (dev->irq_requested_type) {
+        assigned_irq_data.flags = dev->irq_requested_type;
+        r = kvm_deassign_irq(kvm_context, &assigned_irq_data);
+        /* -ENXIO means no assigned irq */
+        if (r && r != -ENXIO)
+            perror("assign_irq: deassign");
+    }
+    assigned_irq_data.flags = KVM_DEV_IRQ_HOST_INTX | KVM_DEV_IRQ_GUEST_INTX;
+#endif
+
     r = kvm_assign_irq(kvm_context, &assigned_irq_data);
     if (r < 0) {
         fprintf(stderr, "Failed to assign irq for \"%s\": %s\n",
@@ -546,6 +557,7 @@  static int assign_irq(AssignedDevInfo *adev)
     }
 
     dev->girq = irq;
+    dev->irq_requested_type = assigned_irq_data.flags;
     return r;
 }
 
diff --git a/qemu/hw/device-assignment.h b/qemu/hw/device-assignment.h
index da775d7..e648240 100644
--- a/qemu/hw/device-assignment.h
+++ b/qemu/hw/device-assignment.h
@@ -79,6 +79,7 @@  typedef struct {
     int girq;
     unsigned char h_busnr;
     unsigned int h_devfn;
+    int irq_requested_type;
     int bound;
 } AssignedDevice;