diff mbox

[RFC,4/4] KVM in-kernel PM Timer implementation (experimental code part 4)

Message ID 1193640890.681341292329073856.JavaMail.root@zmail07.collab.prod.int.phx2.redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ulrich Obergfell Dec. 14, 2010, 12:17 p.m. UTC
None
diff mbox

Patch

diff -up ./qemu-kvm.c.orig4 ./qemu-kvm.c
--- ./qemu-kvm.c.orig4	2010-12-10 10:50:42.857811776 +0100
+++ ./qemu-kvm.c	2010-12-10 11:45:23.783748044 +0100
@@ -54,6 +54,9 @@  int kvm_irqchip = 1;
 int kvm_pit = 1;
 int kvm_pit_reinject = 1;
 int kvm_nested = 0;
+#ifdef KVM_CAP_PMTMR
+int kvm_pmtmr = 0;
+#endif
 
 
 KVMState *kvm_state;
@@ -186,7 +189,7 @@  int kvm_init(int smp_cpus)
     kvm_context->no_irqchip_creation = 0;
     kvm_context->no_pit_creation = 0;
 #ifdef KVM_CAP_PMTMR
-    kvm_context->no_pmtmr_creation = 0;
+    kvm_context->no_pmtmr_creation = 1;
 #endif
 
 #ifdef KVM_CAP_SET_GUEST_DEBUG
@@ -241,6 +244,11 @@  void kvm_disable_pit_creation(kvm_contex
 }
 
 #ifdef	KVM_CAP_PMTMR
+void kvm_enable_pmtmr_creation(kvm_context_t kvm)
+{
+    kvm->no_pmtmr_creation = 0;
+}
+
 void (*kvm_arch_pmtmr_handler)(kvm_context_t kvm);
 /*
  * This handler is called by
@@ -1654,6 +1662,11 @@  static int kvm_create_context(void)
     if (!kvm_pit) {
         kvm_disable_pit_creation(kvm_context);
     }
+#ifdef KVM_CAP_PMTMR
+    if (kvm_pmtmr) {
+        kvm_enable_pmtmr_creation(kvm_context);
+    }
+#endif
     if (kvm_create(kvm_context, 0, NULL) < 0) {
         kvm_finalize(kvm_state);
         return -1;
diff -up ./qemu-kvm.h.orig4 ./qemu-kvm.h
--- ./qemu-kvm.h.orig4	2010-12-10 11:26:43.726790319 +0100
+++ ./qemu-kvm.h	2010-12-10 11:47:50.074805792 +0100
@@ -124,6 +124,18 @@  void kvm_disable_irqchip_creation(kvm_co
  */
 void kvm_disable_pit_creation(kvm_context_t kvm);
 
+#ifdef KVM_CAP_PMTMR
+/*!
+ * \brief Enable the in-kernel ACPI PM Timer register creation
+ *
+ * In-kernel ACPI PM Timer register is disabled by default.
+ * If in-kernel is to be used, this should be called prior to kvm_create().
+ *
+ *  \param kvm Pointer to the kvm_context
+ */
+void kvm_enable_pmtmr_creation(kvm_context_t kvm);
+#endif
+
 /*!
  * \brief Create new virtual machine
  *
@@ -706,6 +718,9 @@  extern int kvm_irqchip;
 extern int kvm_pit;
 extern int kvm_pit_reinject;
 extern int kvm_nested;
+#ifdef KVM_CAP_PMTMR
+extern int kvm_pmtmr;
+#endif
 extern kvm_context_t kvm_context;
 
 struct ioperm_data {
diff -up ./qemu-options.hx.orig4 ./qemu-options.hx
--- ./qemu-options.hx.orig4	2010-12-02 15:15:20.000000000 +0100
+++ ./qemu-options.hx	2010-12-06 11:27:57.273648509 +0100
@@ -2330,6 +2330,9 @@  DEF("no-kvm-pit-reinjection", 0, QEMU_OP
     QEMU_ARCH_I386)
 DEF("enable-nesting", 0, QEMU_OPTION_enable_nesting,
     "-enable-nesting enable support for running a VM inside the VM (AMD only)\n", QEMU_ARCH_I386)
+DEF("kvm-pmtmr", 0, QEMU_OPTION_kvm_pmtmr,
+    "-kvm-pmtmr      enable KVM kernel mode ACPI PM Timer register emulation\n",
+    QEMU_ARCH_I386)
 DEF("nvram", HAS_ARG, QEMU_OPTION_nvram,
     "-nvram FILE     provide ia64 nvram contents\n", QEMU_ARCH_ALL)
 DEF("tdf", 0, QEMU_OPTION_tdf,
diff -up ./vl.c.orig4 ./vl.c
--- ./vl.c.orig4	2010-12-10 10:34:55.388997058 +0100
+++ ./vl.c	2010-12-10 11:50:20.566810444 +0100
@@ -2474,6 +2474,12 @@  int main(int argc, char **argv, char **e
 		kvm_nested = 1;
 		break;
 	    }
+#ifdef KVM_CAP_PMTMR
+	    case QEMU_OPTION_kvm_pmtmr: {
+		kvm_pmtmr = 1;
+		break;
+	    }
+#endif
 #endif
             case QEMU_OPTION_usb:
                 usb_enabled = 1;