From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yang, Sheng" Subject: [PATCH 5/6] kvm: libkvm: Add interface for PIT save/restore supporting Date: Fri, 7 Mar 2008 20:52:22 +0800 Message-ID: <200803072052.22682.sheng.yang@intel.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_GqT0H458C/BIwJP" To: kvm-devel@lists.sourceforge.net Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org --Boundary-00=_GqT0H458C/BIwJP Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =46rom 6ff60b78c3280505d84d0dc2619e95a087b88458 Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Fri, 7 Mar 2008 19:03:52 +0800 Subject: [PATCH] kvm: libkvm: Add interface for PIT save/restore supporting Signed-off-by: Sheng Yang =2D-- libkvm/libkvm-x86.c | 30 ++++++++++++++++++++++++++++++ libkvm/libkvm.h | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 0 deletions(-) diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c index d19d17f..d1809fd 100644 =2D-- 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= =20 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 =3D ioctl(kvm->vm_fd, KVM_GET_PIT, s); + if (r =3D=3D -1) { + r =3D -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 =3D ioctl(kvm->vm_fd, KVM_SET_PIT, s); + if (r =3D=3D -1) { + r =3D -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 395434c..4b40d2c 100644 =2D-- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -525,8 +525,34 @@ int kvm_get_lapic(kvm_context_t kvm, int vcpu, struct= =20 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 =2D- debian.1.5.3.7.1-dirty --Boundary-00=_GqT0H458C/BIwJP Content-Type: text/x-diff; charset="utf-8"; name="0003-kvm-libkvm-Add-interface-for-PIT-save-restore-supp.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-kvm-libkvm-Add-interface-for-PIT-save-restore-supp.patch" =46rom 6ff60b78c3280505d84d0dc2619e95a087b88458 Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Fri, 7 Mar 2008 19:03:52 +0800 Subject: [PATCH] kvm: libkvm: Add interface for PIT save/restore supporting Signed-off-by: Sheng Yang =2D-- libkvm/libkvm-x86.c | 30 ++++++++++++++++++++++++++++++ libkvm/libkvm.h | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 0 deletions(-) diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c index d19d17f..d1809fd 100644 =2D-- 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) =20 #endif =20 +#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 =3D ioctl(kvm->vm_fd, KVM_GET_PIT, s); + if (r =3D=3D -1) { + r =3D -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 =3D ioctl(kvm->vm_fd, KVM_SET_PIT, s); + if (r =3D=3D -1) { + r =3D -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 395434c..4b40d2c 100644 =2D-- 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 =20 +#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 =20 #ifdef KVM_CAP_VAPIC =2D-=20 debian.1.5.3.7.1-dirty --Boundary-00=_GqT0H458C/BIwJP Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ --Boundary-00=_GqT0H458C/BIwJP Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel --Boundary-00=_GqT0H458C/BIwJP--