diff mbox

fix segfault with -no-kvm

Message ID 1248130360-9453-1-git-send-email-glommer@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Glauber Costa July 20, 2009, 10:52 p.m. UTC
Our PIT implementation calls qemu_kvm_pit_in_kernel without
checking for kvm_enabled() as does everybody else. It will make it
dereference kvm_context pointer wich will be NULL.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 hw/i8254.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/hw/i8254.c b/hw/i8254.c
index fd0bdfe..34a716c 100644
--- a/hw/i8254.c
+++ b/hw/i8254.c
@@ -478,7 +478,7 @@  void hpet_disable_pit(void)
 {
     PITChannelState *s = &pit_state.channels[0];
 
-    if (qemu_kvm_pit_in_kernel()) {
+    if (kvm_enabled() && qemu_kvm_pit_in_kernel()) {
         if (qemu_kvm_has_pit_state2()) {
             kvm_hpet_disable_kpit();
         } else {
@@ -502,7 +502,7 @@  void hpet_enable_pit(void)
     PITState *pit = &pit_state;
     PITChannelState *s = &pit->channels[0];
 
-    if (qemu_kvm_pit_in_kernel()) {
+    if (kvm_enabled() && qemu_kvm_pit_in_kernel()) {
         if (qemu_kvm_has_pit_state2()) {
             kvm_hpet_enable_kpit();
         } else {