Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>
Index: kvm-userspace.realtip/libkvm/kvm-common.h
===================================================================
--- kvm-userspace.realtip.orig/libkvm/kvm-common.h
+++ kvm-userspace.realtip/libkvm/kvm-common.h
@@ -49,6 +49,10 @@ struct kvm_context {
int no_pit_creation;
/// in-kernel pit status
int pit_in_kernel;
+ // do not create in-kernel acpi timer if set
+ int no_acpi_timer_creation;
+ // in-kernel acpi timer status
+ int acpi_timer_in_kernel;
};
void init_slots(void);
Index: kvm-userspace.realtip/libkvm/libkvm-x86.c
===================================================================
--- kvm-userspace.realtip.orig/libkvm/libkvm-x86.c
+++ kvm-userspace.realtip/libkvm/libkvm-x86.c
@@ -166,6 +166,29 @@ int kvm_create_pit(kvm_context_t kvm)
return 0;
}
+int kvm_create_acpi_timer(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_ACPI_TIMER
+ int r;
+
+ kvm->acpi_timer_in_kernel = 0;
+ if (!kvm->no_acpi_timer_creation) {
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_ACPI_TIMER);
+ if (r > 0) {
+ r = ioctl(kvm->vm_fd, KVM_CREATE_ACPI_TIMER);
+ if (r >= 0)
+ kvm->acpi_timer_in_kernel = 1;
+ else {
+ fprintf(stderr,
+ "Create kernel pmtimer failed\n");
+ return r;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
void **vm_mem)
{
@@ -179,6 +202,10 @@ int kvm_arch_create(kvm_context_t kvm, u
if (r < 0)
return r;
+ r = kvm_create_acpi_timer(kvm);
+ if (r < 0)
+ return r;
+
return 0;
}
Index: kvm-userspace.realtip/libkvm/libkvm.c
===================================================================
--- kvm-userspace.realtip.orig/libkvm/libkvm.c
+++ kvm-userspace.realtip/libkvm/libkvm.c
@@ -277,6 +277,11 @@ void kvm_disable_pit_creation(kvm_contex
kvm->no_pit_creation = 1;
}
+void kvm_disable_acpi_timer_creation(kvm_context_t kvm)
+{
+ kvm->no_acpi_timer_creation = 1;
+}
+
int kvm_create_vcpu(kvm_context_t kvm, int slot)
{
long mmap_size;
@@ -994,3 +999,8 @@ int kvm_pit_in_kernel(kvm_context_t kvm)
{
return kvm->pit_in_kernel;
}
+
+int kvm_acpi_timer_in_kernel(kvm_context_t kvm)
+{
+ return kvm->acpi_timer_in_kernel;
+}
Index: kvm-userspace.realtip/libkvm/libkvm.h
===================================================================
--- kvm-userspace.realtip.orig/libkvm/libkvm.h
+++ kvm-userspace.realtip/libkvm/libkvm.h
@@ -117,6 +117,16 @@ void kvm_disable_irqchip_creation(kvm_co
void kvm_disable_pit_creation(kvm_context_t kvm);
/*!
+ * \brief Disable the in-kernel ACPI timer creation
+ *
+ * In-kernel acpi timer is enabled by default. If userspace acpi timer is to
be used,
+ * this should be called prior to kvm_create().
+ *
+ * \param kvm Pointer to the kvm_context
+ */
+void kvm_disable_acpi_timer_creation(kvm_context_t kvm);
+
+/*!
* \brief Create new virtual machine
*
* This creates a new virtual machine, maps physical RAM to it, and creates a
@@ -599,6 +609,13 @@ int kvm_set_pit(kvm_context_t kvm, struc
#endif
+/*!
+ * \brief Query whether in kernel acpi timer is used
+ *
+ * \param kvm Pointer to the current kvm_context
+ */
+int kvm_acpi_timer_in_kernel(kvm_context_t kvm);
+
#ifdef KVM_CAP_OPEN_IOPORT
/*!
--
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html