[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1322602539-27004-4-git-send-email-emunson@mgebm.net>
Date: Tue, 29 Nov 2011 16:35:37 -0500
From: Eric B Munson <emunson@...bm.net>
To: avi@...hat.com
Cc: Eric B Munson <emunson@...bm.net>, mingo@...hat.com, hpa@...or.com,
arnd@...db.de, ryanh@...ux.vnet.ibm.com, aliguori@...ibm.com,
mtosatti@...hat.com, jeremy.fitzhardinge@...rix.com,
kvm@...r.kernel.org, linux-arch@...r.kernel.org, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 3/5 V4] Add ioctl for KVM_GUEST_STOPPED
Now that we have a flag that will tell the guest it was suspended, create an
interface for that communication using a KVM ioctl.
Signed-off-by: Eric B Munson <emunson@...bm.net>
Cc: mingo@...hat.com
Cc: hpa@...or.com
Cc: arnd@...db.de
Cc: ryanh@...ux.vnet.ibm.com
Cc: aliguori@...ibm.com
Cc: mtosatti@...hat.com
Cc: jeremy.fitzhardinge@...rix.com
Cc: kvm@...r.kernel.org
Cc: linux-arch@...r.kernel.org
Cc: x86@...nel.org
Cc: linux-kernel@...r.kernel.org
---
arch/x86/include/asm/kvm_host.h | 2 ++
arch/x86/kvm/x86.c | 20 ++++++++++++++++++++
include/linux/kvm.h | 2 ++
3 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index b4973f4..beb94c6 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -672,6 +672,8 @@ int kvm_pv_mmu_op(struct kvm_vcpu *vcpu, unsigned long bytes,
gpa_t addr, unsigned long *ret);
u8 kvm_get_guest_memory_type(struct kvm_vcpu *vcpu, gfn_t gfn);
+int kvm_set_guest_paused(struct kvm_vcpu *vcpu);
+
extern bool tdp_enabled;
u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c38efd7..0127617 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3295,6 +3295,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
goto out;
}
+ case KVM_GUEST_PAUSED: {
+ r = kvm_set_guest_paused(vcpu);
+ break;
+ }
default:
r = -EINVAL;
}
@@ -6117,6 +6121,22 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason,
}
EXPORT_SYMBOL_GPL(kvm_task_switch);
+/*
+ * kvm_set_guest_paused() indicates to the guest kernel that it has been
+ * stopped by the hypervisor. This function will be called from the host only.
+ * EINVAL is returned when the host attempts to set the flag for a guest that
+ * does not support pv clocks.
+ */
+int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
+{
+ struct pvclock_vcpu_time_info *src = &vcpu->arch.hv_clock;
+ if (!vcpu->arch.time_page)
+ return -EINVAL;
+ src->flags |= PVCLOCK_GUEST_STOPPED;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(kvm_set_guest_paused);
+
int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
struct kvm_sregs *sregs)
{
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index c3892fc..15578a2 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -762,6 +762,8 @@ struct kvm_clock_data {
#define KVM_CREATE_SPAPR_TCE _IOW(KVMIO, 0xa8, struct kvm_create_spapr_tce)
/* Available with KVM_CAP_RMA */
#define KVM_ALLOCATE_RMA _IOR(KVMIO, 0xa9, struct kvm_allocate_rma)
+/* VM is being stopped by host */
+#define KVM_GUEST_PAUSED _IO(KVMIO, 0xaa)
#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists