From: "Yang, Sheng" <sheng.yang@intel.com>
To: kvm-devel@lists.sourceforge.net
Subject: Re: [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
Date: Thu, 6 Mar 2008 16:46:13 +0800 [thread overview]
Message-ID: <200803061646.13237.sheng.yang@intel.com> (raw)
In-Reply-To: <200803051020.46027.sheng.yang@intel.com>
[-- 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
next prev parent reply other threads:[~2008-03-06 8:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-03-07 12:52 Yang, Sheng
2008-03-11 18:25 ` Hollis Blanchard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200803061646.13237.sheng.yang@intel.com \
--to=sheng.yang@intel.com \
--cc=kvm-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.