summaryrefslogtreecommitdiff
path: root/libkvm
diff options
context:
space:
mode:
authorSheng Yang <sheng.yang@intel.com>2008-03-07 19:03:52 +0800
committerAvi Kivity <avi@qumranet.com>2008-03-07 18:13:43 +0200
commit7329670b5136900a05a31bcb1b0cf5d35d434519 (patch)
tree40dc411a5bbefd4f6768b4cd2052317537baac2c /libkvm
parent79b32b011c01f8c416785c66535260f75591c625 (diff)
kvm: libkvm: Add interface for PIT save/restore supporting
Signed-off-by: Sheng Yang <sheng.yang@intel.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'libkvm')
-rw-r--r--libkvm/libkvm-x86.c30
-rw-r--r--libkvm/libkvm.h26
2 files changed, 56 insertions, 0 deletions
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index d19d17f8..d1809fd1 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -361,6 +361,36 @@ int kvm_set_lapic(kvm_context_t kvm, int vcpu, struct kvm_lapic_state *s)
#endif
+#ifdef KVM_CAP_PIT
+
+int kvm_get_pit(kvm_context_t kvm, struct kvm_pit_state *s)
+{
+ int r;
+ if (!kvm->pit_in_kernel)
+ return 0;
+ r = ioctl(kvm->vm_fd, KVM_GET_PIT, s);
+ if (r == -1) {
+ r = -errno;
+ perror("kvm_get_pit");
+ }
+ return r;
+}
+
+int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s)
+{
+ int r;
+ if (!kvm->pit_in_kernel)
+ return 0;
+ r = ioctl(kvm->vm_fd, KVM_SET_PIT, s);
+ if (r == -1) {
+ r = -errno;
+ perror("kvm_set_pit");
+ }
+ return r;
+}
+
+#endif
+
void kvm_show_code(kvm_context_t kvm, int vcpu)
{
#define CR0_PE_MASK (1ULL<<0)
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
index 395434cf..4b40d2cb 100644
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -525,8 +525,34 @@ int kvm_get_lapic(kvm_context_t kvm, int vcpu, struct kvm_lapic_state *s);
* \param s Local apic state of the specific virtual CPU
*/
int kvm_set_lapic(kvm_context_t kvm, int vcpu, struct kvm_lapic_state *s);
+
+#endif
+
#endif
+#ifdef KVM_CAP_PIT
+
+/*!
+ * \brief Get in kernel PIT of the virtual domain
+ *
+ * Save the PIT state.
+ *
+ * \param kvm Pointer to the current kvm_context
+ * \param s PIT state of the virtual domain
+ */
+int kvm_get_pit(kvm_context_t kvm, struct kvm_pit_state *s);
+
+/*!
+ * \brief Set in kernel PIT of the virtual domain
+ *
+ * Restore the PIT state.
+ * Timer would be retriggerred after restored.
+ *
+ * \param kvm Pointer to the current kvm_context
+ * \param s PIT state of the virtual domain
+ */
+int kvm_set_pit(kvm_context_t kvm, struct kvm_pit_state *s);
+
#endif
#ifdef KVM_CAP_VAPIC