* [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
@ 2008-03-04 10:22 Yang, Sheng
2008-03-04 13:23 ` Uri Lublin
0 siblings, 1 reply; 6+ messages in thread
From: Yang, Sheng @ 2008-03-04 10:22 UTC (permalink / raw)
To: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 4675 bytes --]
From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Tue, 4 Mar 2008 09:29:55 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..22a6283 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..0753ca9 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 1122b87..4587a5c 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -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);
}
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index f10fbd8..4c69ff4 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #2: 0002-kvm-qemu-Add-option-for-enable-disable-in-kernel-P.patch --]
[-- Type: text/x-diff, Size: 4680 bytes --]
From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Tue, 4 Mar 2008 09:29:55 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..22a6283 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..0753ca9 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 1122b87..4587a5c 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -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);
}
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index f10fbd8..4c69ff4 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 158 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
2008-03-04 10:22 [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT Yang, Sheng
@ 2008-03-04 13:23 ` Uri Lublin
2008-03-05 2:20 ` Yang, Sheng
0 siblings, 1 reply; 6+ messages in thread
From: Uri Lublin @ 2008-03-04 13:23 UTC (permalink / raw)
To: Yang, Sheng; +Cc: kvm-devel
Yang, Sheng wrote:
> From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
> From: Sheng Yang <sheng.yang@intel.com>
> Date: Tue, 4 Mar 2008 09:29:55 +0800
> Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
>
> diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
> index b3a241e..22a6283 100644
> --- a/libkvm/libkvm-x86.c
> +++ b/libkvm/libkvm-x86.c
> @@ -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;
> +#endif
>
> +}
> diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
> index c281680..0753ca9 100644
> --- a/qemu/hw/i8254.c
> +++ b/qemu/hw/i8254.c
> @@ -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
>
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).
> + 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);
>
> diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
> index 1122b87..4587a5c 100644
> --- a/qemu/hw/pc.c
> +++ b/qemu/hw/pc.c
> @@ -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
> + 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/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
2008-03-04 13:23 ` Uri Lublin
@ 2008-03-05 2:20 ` Yang, Sheng
2008-03-06 8:46 ` Yang, Sheng
0 siblings, 1 reply; 6+ messages in thread
From: Yang, Sheng @ 2008-03-05 2:20 UTC (permalink / raw)
To: Uri Lublin; +Cc: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 4345 bytes --]
On Tuesday 04 March 2008 21:23:46 Uri Lublin wrote:
> > @@ -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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..d19d17f 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..9e18ebc 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index f10fbd8..4c69ff4 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #2: 0002-kvm-qemu-Add-option-for-enable-disable-in-kernel-P.patch --]
[-- Type: text/x-diff, Size: 4181 bytes --]
From 986676752cc553dc3fc10c0083e432ef62dbfcbb Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Wed, 5 Mar 2008 02:07:47 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..d19d17f 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..9e18ebc 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index f10fbd8..4c69ff4 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 158 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
2008-03-05 2:20 ` Yang, Sheng
@ 2008-03-06 8:46 ` Yang, Sheng
0 siblings, 0 replies; 6+ messages in thread
From: Yang, Sheng @ 2008-03-06 8:46 UTC (permalink / raw)
To: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 3883 bytes --]
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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..d19d17f 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..9e18ebc 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index 4762cb0..21c9b53 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #2: 0002-kvm-qemu-Add-option-for-enable-disable-in-kernel-P.patch --]
[-- Type: text/x-diff, Size: 4268 bytes --]
From d8c50e41b2f04b49073f958c5697a4a450d3aba1 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Thu, 6 Mar 2008 16:43:18 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..d19d17f 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..9e18ebc 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index 4762cb0..21c9b53 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 158 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
@ 2008-03-07 12:52 Yang, Sheng
2008-03-11 18:25 ` Hollis Blanchard
0 siblings, 1 reply; 6+ messages in thread
From: Yang, Sheng @ 2008-03-07 12:52 UTC (permalink / raw)
To: kvm-devel
[-- Attachment #1: Type: text/plain, Size: 4261 bytes --]
From 98543bb3c3821e5bc9003bb91d7d0c755394ffac Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Fri, 7 Mar 2008 14:24:32 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..d19d17f 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..9e18ebc 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 45fddd3..4d59b39 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -10,6 +10,7 @@
int kvm_allowed = 1;
int kvm_irqchip = 1;
+int kvm_pit = 1;
#include <string.h>
#include "hw/hw.h"
@@ -544,6 +545,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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index 4762cb0..21c9b53 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #2: 0002-kvm-qemu-Add-option-for-enable-disable-in-kernel-P.patch --]
[-- Type: text/x-diff, Size: 4268 bytes --]
From 98543bb3c3821e5bc9003bb91d7d0c755394ffac Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Fri, 7 Mar 2008 14:24:32 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
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(-)
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..d19d17f 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -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
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..9e18ebc 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -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);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 45fddd3..4d59b39 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -10,6 +10,7 @@
int kvm_allowed = 1;
int kvm_irqchip = 1;
+int kvm_pit = 1;
#include <string.h>
#include "hw/hw.h"
@@ -544,6 +545,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;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -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
diff --git a/qemu/vl.c b/qemu/vl.c
index 4762cb0..21c9b53 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -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
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 158 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
2008-03-07 12:52 Yang, Sheng
@ 2008-03-11 18:25 ` Hollis Blanchard
0 siblings, 0 replies; 6+ messages in thread
From: Hollis Blanchard @ 2008-03-11 18:25 UTC (permalink / raw)
To: Yang, Sheng; +Cc: kvm-devel, kvm-ppc-devel, kvm-ia64-devel, Avi Kivity
On Fri, 2008-03-07 at 20:52 +0800, Yang, Sheng wrote:
> From 98543bb3c3821e5bc9003bb91d7d0c755394ffac Mon Sep 17 00:00:00 2001
> From: Sheng Yang <sheng.yang@intel.com>
> Date: Fri, 7 Mar 2008 14:24:32 +0800
> Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT
This patch breaks all non-x86 architectures, since common code now calls
functions defined only in libkvm-x86.c .
--
Hollis Blanchard
IBM Linux Technology Center
-------------------------------------------------------------------------
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/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-03-11 18:25 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-04 10:22 [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT Yang, Sheng
2008-03-04 13:23 ` Uri Lublin
2008-03-05 2:20 ` Yang, Sheng
2008-03-06 8:46 ` Yang, Sheng
-- strict thread matches above, loose matches on Subject: below --
2008-03-07 12:52 Yang, Sheng
2008-03-11 18:25 ` Hollis Blanchard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox