[PATCH 13/19] qemu-kvm: Refactor in-kernel irqchip and pit control

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

 



From: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>

Simplify the logic for detecting and querying if in-kernel irqchip and
pit should be created. This also allows to drop two further fields from
kvm_context.

Signed-off-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
---
 qemu-kvm-x86.c |   16 +++++-----------
 qemu-kvm.c     |   20 +++-----------------
 qemu-kvm.h     |   24 ------------------------
 3 files changed, 8 insertions(+), 52 deletions(-)

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 6d3a243..a88f8be 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -105,17 +105,11 @@ static int kvm_create_pit(kvm_context_t kvm)
 #ifdef KVM_CAP_PIT
     int r;
 
-    kvm_state->pit_in_kernel = 0;
-    if (!kvm->no_pit_creation) {
-        r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_PIT);
-        if (r > 0) {
-            r = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT);
-            if (r >= 0) {
-                kvm_state->pit_in_kernel = 1;
-            } else {
-                fprintf(stderr, "Create kernel PIC irqchip failed\n");
-                return r;
-            }
+    if (kvm_pit_in_kernel()) {
+        r = kvm_vm_ioctl(kvm_state, KVM_CREATE_PIT);
+        if (r < 0) {
+            fprintf(stderr, "Create kernel PIC irqchip failed\n");
+            return r;
         }
     }
 #endif
diff --git a/qemu-kvm.c b/qemu-kvm.c
index e846f1c..e03b3d5 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -199,16 +199,6 @@ static void kvm_finalize(KVMState *s)
     free(s);
 }
 
-void kvm_disable_irqchip_creation(kvm_context_t kvm)
-{
-    kvm->no_irqchip_creation = 1;
-}
-
-void kvm_disable_pit_creation(kvm_context_t kvm)
-{
-    kvm->no_pit_creation = 1;
-}
-
 static int kvm_set_boot_vcpu_id(kvm_context_t kvm, uint32_t id)
 {
 #ifdef KVM_CAP_SET_BOOT_CPU_ID
@@ -260,7 +250,7 @@ void kvm_create_irqchip(kvm_context_t kvm)
     int r;
 
 #ifdef KVM_CAP_IRQCHIP
-    if (!kvm->no_irqchip_creation) {
+    if (kvm_irqchip) {
         r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_IRQCHIP);
         if (r > 0) {            /* kernel irqchip supported */
             r = kvm_vm_ioctl(kvm_state, KVM_CREATE_IRQCHIP);
@@ -1437,12 +1427,8 @@ static int kvm_create_context(void)
 
     int r;
 
-    if (!kvm_irqchip) {
-        kvm_disable_irqchip_creation(kvm_context);
-    }
-    if (!kvm_pit) {
-        kvm_disable_pit_creation(kvm_context);
-    }
+    kvm_state->pit_in_kernel = kvm_pit;
+
     if (kvm_create(kvm_context, 0, NULL) < 0) {
         kvm_finalize(kvm_state);
         return -1;
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 3db0484..409809e 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -50,12 +50,8 @@
  */
 
 struct kvm_context {
-    /// do not create in-kernel irqchip if set
-    int no_irqchip_creation;
     /// ioctl to use to inject interrupts
     int irqchip_inject_ioctl;
-    /// do not create in-kernel pit if set
-    int no_pit_creation;
 #ifdef KVM_CAP_IRQ_ROUTING
     struct kvm_irq_routing *irq_routes;
     int nr_allocated_irq_routes;
@@ -85,26 +81,6 @@ int handle_io_window(kvm_context_t kvm);
 int try_push_interrupts(kvm_context_t kvm);
 
 /*!
- * \brief Disable the in-kernel IRQCHIP creation
- *
- * In-kernel irqchip is enabled by default. If userspace irqchip is to be used,
- * this should be called prior to kvm_create().
- *
- * \param kvm Pointer to the kvm_context
- */
-void kvm_disable_irqchip_creation(kvm_context_t kvm);
-
-/*!
- * \brief Disable the in-kernel PIT creation
- *
- * In-kernel pit is enabled by default. If userspace pit is to be used,
- * this should be called prior to kvm_create().
- *
- *  \param kvm Pointer to the kvm_context
- */
-void kvm_disable_pit_creation(kvm_context_t kvm);
-
-/*!
  * \brief Create new virtual machine
  *
  * This creates a new virtual machine, maps physical RAM to it, and creates a
-- 
1.7.1

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