[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/18] kvmclock: Don't crash QEMU if KVM is disabled
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 06/18] kvmclock: Don't crash QEMU if KVM is disabled |
Date: |
Tue, 14 Mar 2017 17:18:08 +0100 |
From: Eduardo Habkost <address@hidden>
Most machines don't allow sysbus devices like "kvmclock" to be
created from the command-line, but some of them do (the ones with
has_dynamic_sysbus=true). In those cases, it's possible to
manually create a kvmclock device without KVM being enabled,
making QEMU crash:
$ qemu-system-x86_64 -machine q35,accel=tcg -device kvmclock
Segmentation fault (core dumped)
This changes kvmclock's realize method to return an error if KVM
is disabled, to ensure it won't crash QEMU.
Signed-off-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
hw/i386/kvm/clock.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/i386/kvm/clock.c b/hw/i386/kvm/clock.c
index ef9d560..13eca37 100644
--- a/hw/i386/kvm/clock.c
+++ b/hw/i386/kvm/clock.c
@@ -22,6 +22,7 @@
#include "kvm_i386.h"
#include "hw/sysbus.h"
#include "hw/kvm/clock.h"
+#include "qapi/error.h"
#include <linux/kvm.h>
#include <linux/kvm_para.h>
@@ -208,6 +209,11 @@ static void kvmclock_realize(DeviceState *dev, Error
**errp)
{
KVMClockState *s = KVM_CLOCK(dev);
+ if (!kvm_enabled()) {
+ error_setg(errp, "kvmclock device requires KVM");
+ return;
+ }
+
kvm_update_clock(s);
qemu_add_vm_change_state_handler(kvmclock_vm_state_change, s);
--
1.8.3.1
- [Qemu-devel] [PULL 00/18] Misc patches for QEMU 2.9 hard freeze, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 02/18] docs: Add a note about mixing bootindex with "-boot order", Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 04/18] exec: add cpu_synchronize_state to cpu_memory_rw_debug, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 05/18] kvm: Print MSR information if KVM_{GET, SET}_MSRS failed, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 03/18] mem-prealloc: reduce large guest start-up and migration time., Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 06/18] kvmclock: Don't crash QEMU if KVM is disabled,
Paolo Bonzini <=
- [Qemu-devel] [PULL 01/18] memory_region: Fix name comments, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 08/18] configure: add the missing help output for optional features, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 07/18] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 09/18] util: Removed unneeded header from path.c, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 12/18] qemu-timer: fix off-by-one, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 13/18] qemu-timer: do not include sysemu/cpus.h from util/qemu-timer.h, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 14/18] cpus: define QEMUTimerListNotifyCB for QEMU system emulation, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 16/18] icount: process QEMU_CLOCK_VIRTUAL timers in vCPU thread, Paolo Bonzini, 2017/03/14
- [Qemu-devel] [PULL 18/18] nbd/client: fix drop_sync [CVE-2017-2630], Paolo Bonzini, 2017/03/14