Skip to contentSkip to conversation

kvm: qemu: Add option for enable/disable in kernel PIT

PATCH In review Yang, Sheng 2 participants 4 messages Mar 4, 2008 – Mar 6, 2008 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 3/6 kvm: qemu: Add option for enable/disable in kernel PIT

From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
From: Sheng Yang <[email protected]>
Date: Tue, 4 Mar 2008 09:29:55 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT

---
 libkvm/libkvm-x86.c |    7 +++++++
 qemu/hw/i8254.c     |   12 +++++++++---
 qemu/hw/pc.c        |    6 ++++++
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |    8 ++++++++
 6 files changed, 36 insertions(+), 3 deletions(-)
libkvm/libkvm-x86.c +0 -0
index b3a241e..22a6283 100644
@@ -630,3 +630,10 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, 

int vcpu)
}

#endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+ return kvm->pit_in_kernel;
+#endif
+}

qemu/hw/i8254.c +9 -3
index c281680..0753ca9 100644
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1
@@ -492,9 +494,13 @@ PITState *pit_init(int base, qemu_irq irq)
     PITChannelState *s;
 
     s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
+#endif
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
qemu/hw/pc.c +0 -0
index 1122b87..4587a5c 100644
@@ -984,7 +984,13 @@ static void pc_init1(ram_addr_t ram_size, int 

vga_ram_size,

         ioapic = ioapic_init();
     }
     pit = pit_init(0x40, i8259[0]);
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+#endif
     pcspk_init(pit);
+#ifdef KVM_CAP_PIT
+    }
+#endif
     if (pci_enabled) {
         pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
     }
qemu/qemu-kvm.c +4 -0
index 051946e..196e38e 100644
@@ -10,6 +10,7 @@
 
 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;
 
 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
qemu/qemu-kvm.h +2 -0
index 8e45f30..ff9c86e 100644
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;
 
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif
 
 #endif
qemu/vl.c +1 -0
index f10fbd8..4c69ff4 100644
@@ -8059,6 +8059,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs 

Extensions\n"
@@ -8177,6 +8178,7 @@ enum {
QEMU_OPTION_no_acpi,
QEMU_OPTION_no_kvm,
QEMU_OPTION_no_kvm_irqchip,
+ QEMU_OPTION_no_kvm_pit,
QEMU_OPTION_no_reboot,
QEMU_OPTION_show_cursor,
QEMU_OPTION_daemonize,

@@ -8263,6 +8265,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },

@@ -9191,6 +9194,11 @@ int main(int argc, char **argv)
kvm_irqchip = 0;
break;
}
+ case QEMU_OPTION_no_kvm_pit: {
+ extern int kvm_pit;
+ kvm_pit = 0;
+ break;
+ }

 #endif
             case QEMU_OPTION_usb:
                 usb_enabled = 1;

--
debian.1.5.3.7.1-dirty

From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
From: Sheng Yang <[email protected]>
Date: Tue, 4 Mar 2008 09:29:55 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT

---
 libkvm/libkvm-x86.c |    7 +++++++
 qemu/hw/i8254.c     |   12 +++++++++---
 qemu/hw/pc.c        |    6 ++++++
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |    8 ++++++++
 6 files changed, 36 insertions(+), 3 deletions(-)
libkvm/libkvm-x86.c +7 -0
index b3a241e..22a6283 100644
@@ -630,3 +630,10 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, int vcpu)
 }
 
 #endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+	return kvm->pit_in_kernel;
+#endif
+}
qemu/hw/i8254.c +9 -3
index c281680..0753ca9 100644
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1
@@ -492,9 +494,13 @@ PITState *pit_init(int base, qemu_irq irq)
     PITChannelState *s;
 
     s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
+#endif
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
qemu/hw/pc.c +6 -0
index 1122b87..4587a5c 100644
@@ -984,7 +984,13 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
         ioapic = ioapic_init();
     }
     pit = pit_init(0x40, i8259[0]);
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+#endif
     pcspk_init(pit);
+#ifdef KVM_CAP_PIT
+    }
+#endif
     if (pci_enabled) {
         pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
     }
qemu/qemu-kvm.c +4 -0
index 051946e..196e38e 100644
@@ -10,6 +10,7 @@
 
 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;
 
 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
qemu/qemu-kvm.h +2 -0
index 8e45f30..ff9c86e 100644
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;
 
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif
 
 #endif
qemu/vl.c +8 -0
index f10fbd8..4c69ff4 100644
@@ -8059,6 +8059,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs Extensions\n"
@@ -8177,6 +8178,7 @@ enum {
     QEMU_OPTION_no_acpi,
     QEMU_OPTION_no_kvm,
     QEMU_OPTION_no_kvm_irqchip,
+    QEMU_OPTION_no_kvm_pit,
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_show_cursor,
     QEMU_OPTION_daemonize,
@@ -8263,6 +8265,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },
@@ -9191,6 +9194,11 @@ int main(int argc, char **argv)
 		kvm_irqchip = 0;
 		break;
 	    }
+	    case QEMU_OPTION_no_kvm_pit: {
+		extern int kvm_pit;
+		kvm_pit = 0;
+		break;
+	    }
 #endif
             case QEMU_OPTION_usb:
                 usb_enabled = 1;
Signature · 1 line
debian.1.5.3.7.1-dirty

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#1 lore raw
Quoted 11 lines · Sheng

From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
From: Sheng Yang <[email protected]>
Date: Tue, 4 Mar 2008 09:29:55 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT

libkvm/libkvm-x86.c +0 -0
index b3a241e..22a6283 100644

libkvm/libkvm-x86.c int kvm_disable_tpr_access_reporting(kvm_context_t kvm, · line 637

Quoted 9 lines
libkvm/libkvm-x86.c +5 -0
@@ -630,3 +630,10 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, 
 int vcpu)
 }
 
 #endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+	return kvm->pit_in_kernel;
#else
                  return 0;
Quoted 17 lines
libkvm/libkvm-x86.c +2 -0
+#endif
 
+}
qemu/hw/i8254.c +2 -0
index c281680..0753ca9 100644
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1

qemu/hw/i8254.c PITState *pit_init(int base, qemu_irq irq) · line 498

Quoted 8 lines
qemu/hw/i8254.c +1 -3
@@ -492,9 +494,13 @@ PITState *pit_init(int base, qemu_irq irq)
     PITChannelState *s;
 
     s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+#ifdef KVM_CAP_PIT
 

I think you should remove the ifdef such that the if-statement is executed even if KVM_CAP_PIT
is not defined (in which case qemu pit emulation should be used).

Quoted 14 lines
qemu/hw/i8254.c +6 -0
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
+#endif
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
qemu/hw/pc.c +0 -0
index 1122b87..4587a5c 100644

qemu/hw/pc.c static void pc_init1(ram_addr_t ram_size, int · line 989

Quoted 6 lines
qemu/hw/pc.c +1 -0
@@ -984,7 +984,13 @@ static void pc_init1(ram_addr_t ram_size, int 
 vga_ram_size,
         ioapic = ioapic_init();
     }
     pit = pit_init(0x40, i8259[0]);
+#ifdef KVM_CAP_PIT
 

and here

Quoted 10 lines
qemu/hw/pc.c +5 -0
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+#endif
     pcspk_init(pit);
+#ifdef KVM_CAP_PIT
+    }
+#endif
     if (pci_enabled) {
         pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
     }

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

#2 lore raw
Quoted 12 lines · On Tuesday 04 March 2008 21:23:46 Uri Lublin wrote:

Review PITState *pit_init(int base, qemu_irq irq) · line 497

Quoted 8 lines
(quoted diff) +1 -3
@@ -492,9 +494,13 @@ PITState *pit_init(int base, qemu_irq irq)
     PITChannelState *s;
 
     s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+#ifdef KVM_CAP_PIT

I think you should remove the ifdef such that the if-statement is executed even if KVM_CAP_PIT
is not defined (in which case qemu pit emulation should be used).

Oh, yes. Thanks for the comment!

Here is the updated patch:

---
 libkvm/libkvm-x86.c |    9 +++++++++
 qemu/hw/i8254.c     |   12 ++++++++----
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |    8 ++++++++
 5 files changed, 31 insertions(+), 4 deletions(-)
libkvm/libkvm-x86.c +0 -0
index b3a241e..d19d17f 100644
@@ -630,3 +630,12 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, 

int vcpu)
}

#endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+ return kvm->pit_in_kernel;
+#else
+ return 0;
+#endif
+}

qemu/hw/i8254.c +8 -4
index c281680..9e18ebc 100644
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1
@@ -491,10 +493,12 @@ PITState *pit_init(int base, qemu_irq irq)
     PITState *pit = &pit_state;
     PITChannelState *s;
 
-    s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    s = &pit->channels[0];
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
qemu/qemu-kvm.c +4 -0
index 051946e..196e38e 100644
@@ -10,6 +10,7 @@
 
 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;
 
 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
qemu/qemu-kvm.h +2 -0
index 8e45f30..ff9c86e 100644
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;
 
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif
 
 #endif
qemu/vl.c +1 -0
index f10fbd8..4c69ff4 100644
@@ -8059,6 +8059,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs 

Extensions\n"
@@ -8177,6 +8178,7 @@ enum {
QEMU_OPTION_no_acpi,
QEMU_OPTION_no_kvm,
QEMU_OPTION_no_kvm_irqchip,
+ QEMU_OPTION_no_kvm_pit,
QEMU_OPTION_no_reboot,
QEMU_OPTION_show_cursor,
QEMU_OPTION_daemonize,

@@ -8263,6 +8265,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },

@@ -9191,6 +9194,11 @@ int main(int argc, char **argv)
kvm_irqchip = 0;
break;
}
+ case QEMU_OPTION_no_kvm_pit: {
+ extern int kvm_pit;
+ kvm_pit = 0;
+ break;
+ }

 #endif
             case QEMU_OPTION_usb:
                 usb_enabled = 1;

--
debian.1.5.3.7.1-dirty

From 986676752cc553dc3fc10c0083e432ef62dbfcbb Mon Sep 17 00:00:00 2001
From: Sheng Yang <[email protected]>
Date: Wed, 5 Mar 2008 02:07:47 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT

---
 libkvm/libkvm-x86.c |    9 +++++++++
 qemu/hw/i8254.c     |   12 ++++++++----
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |    8 ++++++++
 5 files changed, 31 insertions(+), 4 deletions(-)
libkvm/libkvm-x86.c +9 -0
index b3a241e..d19d17f 100644
@@ -630,3 +630,12 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, int vcpu)
 }
 
 #endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+	return kvm->pit_in_kernel;
+#else
+	return 0;
+#endif
+}
qemu/hw/i8254.c +8 -4
index c281680..9e18ebc 100644
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1
@@ -491,10 +493,12 @@ PITState *pit_init(int base, qemu_irq irq)
     PITState *pit = &pit_state;
     PITChannelState *s;
 
-    s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    s = &pit->channels[0];
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
qemu/qemu-kvm.c +4 -0
index 051946e..196e38e 100644
@@ -10,6 +10,7 @@
 
 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;
 
 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
qemu/qemu-kvm.h +2 -0
index 8e45f30..ff9c86e 100644
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;
 
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif
 
 #endif
qemu/vl.c +8 -0
index f10fbd8..4c69ff4 100644
@@ -8059,6 +8059,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs Extensions\n"
@@ -8177,6 +8178,7 @@ enum {
     QEMU_OPTION_no_acpi,
     QEMU_OPTION_no_kvm,
     QEMU_OPTION_no_kvm_irqchip,
+    QEMU_OPTION_no_kvm_pit,
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_show_cursor,
     QEMU_OPTION_daemonize,
@@ -8263,6 +8265,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },
@@ -9191,6 +9194,11 @@ int main(int argc, char **argv)
 		kvm_irqchip = 0;
 		break;
 	    }
+	    case QEMU_OPTION_no_kvm_pit: {
+		extern int kvm_pit;
+		kvm_pit = 0;
+		break;
+	    }
 #endif
             case QEMU_OPTION_usb:
                 usb_enabled = 1;
Signature · 1 line
debian.1.5.3.7.1-dirty

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

#3 lore raw

Fix a bug when using "--no-kvm-irqchip".

---
 libkvm/libkvm-x86.c |    9 +++++++++
 qemu/hw/i8254.c     |   12 ++++++++----
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |   11 ++++++++++-
 5 files changed, 33 insertions(+), 5 deletions(-)
libkvm/libkvm-x86.c +0 -0
index b3a241e..d19d17f 100644
@@ -630,3 +630,12 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, 

int vcpu)
}

#endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+ return kvm->pit_in_kernel;
+#else
+ return 0;
+#endif
+}

qemu/hw/i8254.c +8 -4
index c281680..9e18ebc 100644
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1
@@ -491,10 +493,12 @@ PITState *pit_init(int base, qemu_irq irq)
     PITState *pit = &pit_state;
     PITChannelState *s;
 
-    s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    s = &pit->channels[0];
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
qemu/qemu-kvm.c +4 -0
index 051946e..196e38e 100644
@@ -10,6 +10,7 @@
 
 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;
 
 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
qemu/qemu-kvm.h +2 -0
index 8e45f30..ff9c86e 100644
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;
 
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif
 
 #endif
qemu/vl.c +1 -0
index 4762cb0..21c9b53 100644
@@ -8097,6 +8097,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs 

Extensions\n"
@@ -8219,6 +8220,7 @@ enum {
QEMU_OPTION_curses,
QEMU_OPTION_no_kvm,
QEMU_OPTION_no_kvm_irqchip,
+ QEMU_OPTION_no_kvm_pit,
QEMU_OPTION_no_reboot,
QEMU_OPTION_show_cursor,
QEMU_OPTION_daemonize,

@@ -8305,6 +8307,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },

@@ -9238,8 +9241,14 @@ int main(int argc, char **argv)
kvm_allowed = 0;
break;
case QEMU_OPTION_no_kvm_irqchip: {
- extern int kvm_irqchip;
+ extern int kvm_irqchip, kvm_pit;
kvm_irqchip = 0;
+ kvm_pit = 0;
+ break;
+ }
+ case QEMU_OPTION_no_kvm_pit: {
+ extern int kvm_pit;
+ kvm_pit = 0;
break;
}
#endif
--
debian.1.5.3.7.1-dirty

From d8c50e41b2f04b49073f958c5697a4a450d3aba1 Mon Sep 17 00:00:00 2001
From: Sheng Yang <[email protected]>
Date: Thu, 6 Mar 2008 16:43:18 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT

---
 libkvm/libkvm-x86.c |    9 +++++++++
 qemu/hw/i8254.c     |   12 ++++++++----
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |   11 ++++++++++-
 5 files changed, 33 insertions(+), 5 deletions(-)
libkvm/libkvm-x86.c +9 -0
index b3a241e..d19d17f 100644
@@ -630,3 +630,12 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, int vcpu)
 }
 
 #endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+	return kvm->pit_in_kernel;
+#else
+	return 0;
+#endif
+}
qemu/hw/i8254.c +8 -4
index c281680..9e18ebc 100644
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1
@@ -491,10 +493,12 @@ PITState *pit_init(int base, qemu_irq irq)
     PITState *pit = &pit_state;
     PITChannelState *s;
 
-    s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    s = &pit->channels[0];
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
qemu/qemu-kvm.c +4 -0
index 051946e..196e38e 100644
@@ -10,6 +10,7 @@
 
 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;
 
 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
qemu/qemu-kvm.h +2 -0
index 8e45f30..ff9c86e 100644
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;
 
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif
 
 #endif
qemu/vl.c +10 -1
index 4762cb0..21c9b53 100644
@@ -8097,6 +8097,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs Extensions\n"
@@ -8219,6 +8220,7 @@ enum {
     QEMU_OPTION_curses,
     QEMU_OPTION_no_kvm,
     QEMU_OPTION_no_kvm_irqchip,
+    QEMU_OPTION_no_kvm_pit,
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_show_cursor,
     QEMU_OPTION_daemonize,
@@ -8305,6 +8307,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },
@@ -9238,8 +9241,14 @@ int main(int argc, char **argv)
 		kvm_allowed = 0;
 		break;
 	    case QEMU_OPTION_no_kvm_irqchip: {
-		extern int kvm_irqchip;
+		extern int kvm_irqchip, kvm_pit;
 		kvm_irqchip = 0;
+		kvm_pit = 0;
+		break;
+	    }
+	    case QEMU_OPTION_no_kvm_pit: {
+		extern int kvm_pit;
+		kvm_pit = 0;
 		break;
 	    }
 #endif
Signature · 1 line
debian.1.5.3.7.1-dirty

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel