[patch 2/4] QEMU/KVM: get/set mpstate libkvm interface

Marcelo Tosatti
2008-04-07T20:30:47Z

[-- Attachment #1: fix-mp-migration --]
[-- Type: text/plain, Size: 2190 bytes --]

Add libkvm interface to get/set the mpstate.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: marcelo/git/kvm-userspace.io/libkvm/libkvm.c
===================================================================
--- marcelo.orig/git/kvm-userspace.io/libkvm/libkvm.c
+++ marcelo/git/kvm-userspace.io/libkvm/libkvm.c
@@ -776,6 +776,32 @@ int kvm_set_sregs(kvm_context_t kvm, int
return ioctl(kvm->vcpu_fd[vcpu], KVM_SET_SREGS, sregs);
}

+int kvm_get_mpstate(kvm_context_t kvm, int vcpu, int *mpstate)
+{
+ int r;
+
+#ifdef KVM_CAP_MP_STATE
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_MP_STATE);
+ if (r > 0)
+ return ioctl(kvm->vcpu_fd[vcpu], KVM_GET_MP_STATE, mpstate);
+#endif
+ return -1;
+}
+
+int kvm_set_mpstate(kvm_context_t kvm, int vcpu, int *mpstate)
+{
+ int r;
+
+#ifdef KVM_CAP_MP_STATE
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_MP_STATE);
+ if (r > 0)
+ return ioctl(kvm->vcpu_fd[vcpu], KVM_SET_MP_STATE, mpstate);
+#endif
+ return -1;
+}
+
+
+
static int handle_mmio(kvm_context_t kvm, struct kvm_run *kvm_run)
{
unsigned long addr = kvm_run->mmio.phys_addr;
Index: marcelo/git/kvm-userspace.io/libkvm/libkvm.h
===================================================================
--- marcelo.orig/git/kvm-userspace.io/libkvm/libkvm.h
+++ marcelo/git/kvm-userspace.io/libkvm/libkvm.h
@@ -301,6 +301,18 @@ int kvm_get_sregs(kvm_context_t kvm, int
int kvm_set_sregs(kvm_context_t kvm, int vcpu, struct kvm_sregs *regs);

/*!
+ * * \brief Read VCPU MP state
+ *
+ */
+int kvm_get_mpstate(kvm_context_t kvm, int vcpu, int *mpstate);
+
+/*!
+ * * \brief Write VCPU MP state
+ *
+ */
+int kvm_set_mpstate(kvm_context_t kvm, int vcpu, int *mpstate);
+
+/*!
* \brief Simulate an external vectored interrupt
*
* This allows you to simulate an external vectored interrupt.