From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [patch 11/12] libkvm: interface for pmtimer save/restore Date: Thu, 29 May 2008 19:23:00 -0300 Message-ID: <20080529222829.214104186@localhost.localdomain> References: <20080529222249.563011248@localhost.localdomain> Cc: Chris Wright , Glauber Costa , Anthony Liguori , kvm@vger.kernel.org, Marcelo Tosatti To: Avi Kivity Return-path: Received: from mx1.redhat.com ([66.187.233.31]:41183 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754674AbYE2WgE (ORCPT ); Thu, 29 May 2008 18:36:04 -0400 Content-Disposition: inline; filename=inkernel-acpi-migration Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Marcelo Tosatti Index: kvm-userspace.realtip/libkvm/libkvm-x86.c =================================================================== --- kvm-userspace.realtip.orig/libkvm/libkvm-x86.c +++ kvm-userspace.realtip/libkvm/libkvm-x86.c @@ -418,6 +418,37 @@ int kvm_set_pit(kvm_context_t kvm, struc #endif +#ifdef KVM_CAP_ACPI_TIMER + +int kvm_get_acpi_timer(kvm_context_t kvm, struct kvm_acpi_timer_state *s) +{ + int r; + if (!kvm->acpi_timer_in_kernel) + return 0; + r = ioctl(kvm->vm_fd, KVM_GET_ACPI_TIMER, s); + if (r != 0) { + r = -errno; + perror("kvm_get_acpi_timer"); + } + return r; +} + +int kvm_set_acpi_timer(kvm_context_t kvm, struct kvm_acpi_timer_state *s) +{ + int r; + if (!kvm->acpi_timer_in_kernel) + return 0; + r = ioctl(kvm->vm_fd, KVM_SET_ACPI_TIMER, s); + if (r != 0) { + r = -errno; + perror("kvm_set_acpi_timer"); + } + + return r; +} + +#endif + void kvm_show_code(kvm_context_t kvm, int vcpu) { #define SHOW_CODE_LEN 50 Index: kvm-userspace.realtip/libkvm/libkvm.h =================================================================== --- kvm-userspace.realtip.orig/libkvm/libkvm.h +++ kvm-userspace.realtip/libkvm/libkvm.h @@ -616,6 +616,28 @@ int kvm_set_pit(kvm_context_t kvm, struc */ int kvm_acpi_timer_in_kernel(kvm_context_t kvm); +#ifdef KVM_CAP_ACPI_TIMER + +#if defined(__i386__) || defined(__x86_64__) +/*! + * \brief Get in kernel ACPI timer of the virtual domain + * + * \param kvm Pointer to the current kvm_context + * \param s ACPI timer state of the virtual domain + */ +int kvm_get_acpi_timer(kvm_context_t kvm, struct kvm_acpi_timer_state *s); + +/*! + * \brief Set in kernel ACPI timer of the virtual domain + * + * \param kvm Pointer to the current kvm_context + * \param s ACPI timer state of the virtual domain + */ +int kvm_set_acpi_timer(kvm_context_t kvm, struct kvm_acpi_timer_state *s); +#endif + +#endif + #ifdef KVM_CAP_OPEN_IOPORT /*! --