Skip to contentSkip to conversation

fix segfault with -no-kvm

PATCH New Glauber Costa 1 participant 1 message Jul 20, 2009 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix segfault with -no-kvm

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.

---
 hw/i8254.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/i8254.c +2 -2
index fd0bdfe..34a716c 100644
@@ -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 {
Signature · 1 line
1.6.2.2