render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame qemu-kvm-irqfd-support.patch

Justin M. Forbes 272dfe
Add API to assign/deassign irqfd to kvm.
Justin M. Forbes 272dfe
Add stub so that users do not have to use
Justin M. Forbes 272dfe
ifdefs.
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Justin M. Forbes 272dfe
---
Justin M. Forbes 272dfe
 kvm-all.c |   19 +++++++++++++++++++
Justin M. Forbes 272dfe
 kvm.h     |   10 ++++++++++
Justin M. Forbes 272dfe
 2 files changed, 29 insertions(+), 0 deletions(-)
Justin M. Forbes 272dfe
Justin M. Forbes 272dfe
diff --git a/kvm-all.c b/kvm-all.c
Justin M. Forbes 272dfe
index efdf40c..b3fdf29 100644
Justin M. Forbes 272dfe
--- a/kvm-all.c
Justin M. Forbes 272dfe
+++ b/kvm-all.c
Justin M. Forbes 272dfe
@@ -1122,4 +1122,23 @@ int kvm_set_ioeventfd(uint16_t addr, uint16_t data, int fd, bool assigned)
Justin M. Forbes 272dfe
 }
Justin M. Forbes 272dfe
 #endif
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
+#if defined(KVM_IRQFD)
Justin M. Forbes 272dfe
+int kvm_set_irqfd(int gsi, int fd, bool assigned)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+    struct kvm_irqfd irqfd = {
Justin M. Forbes 272dfe
+        .fd = fd,
Justin M. Forbes 272dfe
+        .gsi = gsi,
Justin M. Forbes 272dfe
+        .flags = assigned ? 0 : KVM_IRQFD_FLAG_DEASSIGN,
Justin M. Forbes 272dfe
+    };
Justin M. Forbes 272dfe
+    int r;
Justin M. Forbes 272dfe
+    if (!kvm_irqchip_in_kernel())
Justin M. Forbes 272dfe
+        return -ENOSYS;
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
+    r = kvm_vm_ioctl(kvm_state, KVM_IRQFD, &irqfd);
Justin M. Forbes 272dfe
+    if (r < 0)
Justin M. Forbes 272dfe
+        return r;
Justin M. Forbes 272dfe
+    return 0;
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+#endif
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
 #include "qemu-kvm.c"
Justin M. Forbes 272dfe
diff --git a/kvm.h b/kvm.h
Justin M. Forbes 272dfe
index e98b5c8..ad8d122 100644
Justin M. Forbes 272dfe
--- a/kvm.h
Justin M. Forbes 272dfe
+++ b/kvm.h
Justin M. Forbes 272dfe
@@ -167,4 +167,14 @@ int kvm_set_ioeventfd(uint16_t data, uint16_t addr, int fd, bool assigned)
Justin M. Forbes 272dfe
 }
Justin M. Forbes 272dfe
 #endif
Justin M. Forbes 272dfe
 
Justin M. Forbes 272dfe
+#if defined(KVM_IRQFD) && defined(CONFIG_KVM)
Justin M. Forbes 272dfe
+int kvm_set_irqfd(int gsi, int fd, bool assigned);
Justin M. Forbes 272dfe
+#else
Justin M. Forbes 272dfe
+static inline
Justin M. Forbes 272dfe
+int kvm_set_irqfd(int gsi, int fd, bool assigned)
Justin M. Forbes 272dfe
+{
Justin M. Forbes 272dfe
+    return -ENOSYS;
Justin M. Forbes 272dfe
+}
Justin M. Forbes 272dfe
+#endif
Justin M. Forbes 272dfe
+
Justin M. Forbes 272dfe
 #endif
Justin M. Forbes 272dfe
-- 
Justin M. Forbes 272dfe
1.6.6.144.g5c3af