add ioctl's to save/restore mpstate
PATCH 1/1 add ioctl's to save/restore mpstate
So userspace can save/restore the mpstate during migration.
Signed-off-by Marcelo Tosatti <[email protected]>
arch/x86/kvm/x86.c +19 -0
@@ -814,6 +814,7 @@ int kvm_dev_ioctl_check_extension(long ext)case KVM_CAP_CLOCKSOURCE :case KVM_CAP_PIT :case KVM_CAP_NOP_IO_DELAY : +case KVM_CAP_MP_STATE : r =1 ;break ;case KVM_CAP_VAPIC :
@@ -3057,6 +3058,24 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,return 0 ; } +int kvm_arch_vcpu_ioctl_get_mpstate (struct kvm_vcpu *vcpu, +int *mp_state) +{ +vcpu_load (vcpu); + *mp_state = vcpu->arch.mp_state; +vcpu_put (vcpu); +return 0 ; +} + +int kvm_arch_vcpu_ioctl_set_mpstate (struct kvm_vcpu *vcpu, +int *mp_state) +{ +vcpu_load (vcpu); + vcpu->arch.mp_state = *mp_state; +vcpu_put (vcpu); +return 0 ; +} +static void set_segment (struct kvm_vcpu *vcpu,struct kvm_segment *var,int seg) {
include/linux/kvm.h +3 -0
@@ -279,6 +279,7 @@ struct kvm_s390_interrupt {#define KVM_CAP_PIT 11#define KVM_CAP_NOP_IO_DELAY 12#define KVM_CAP_PV_MMU 13 +#define KVM_CAP_MP_STATE 14/* * ioctls for VM fds
@@ -340,5 +341,7 @@ struct kvm_s390_interrupt {#define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)/* initial reset for s390 */ #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) +#define KVM_GET_MP_STATE _IO(KVMIO, 0x98) +#define KVM_SET_MP_STATE _IO(KVMIO, 0x99)#endif
include/linux/kvm_host.h +4 -0
@@ -224,6 +224,10 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);int kvm_arch_vcpu_ioctl_set_sregs (struct kvm_vcpu *vcpu,struct kvm_sregs *sregs); +int kvm_arch_vcpu_ioctl_get_mpstate (struct kvm_vcpu *vcpu, +int *mp_state); +int kvm_arch_vcpu_ioctl_set_mpstate (struct kvm_vcpu *vcpu, +int *mp_state);int kvm_arch_vcpu_ioctl_debug_guest (struct kvm_vcpu *vcpu,struct kvm_debug_guest *dbg);int kvm_arch_vcpu_ioctl_run (struct kvm_vcpu *vcpu,struct kvm_run *kvm_run);
virt/kvm/kvm_main.c +24 -0
@@ -924,6 +924,30 @@ out_free2: r =0 ;break ; } +case KVM_GET_MP_STATE : { +int mp_state; + + r =kvm_arch_vcpu_ioctl_get_mpstate (vcpu, &mp_state); +if (r) + goto out; + r = -EFAULT ; +if (copy_to_user (argp, &mp_state,sizeof (int ))) + goto out; + r =0 ; +break ; + } +case KVM_SET_MP_STATE : { +int mp_state; + + r = -EFAULT ; +if (copy_from_user (&mp_state, argp,sizeof (int ))) + goto out; + r =kvm_arch_vcpu_ioctl_set_mpstate (vcpu, &mp_state); +if (r) + goto out; + r =0 ; +break ; + }case KVM_TRANSLATE : {struct kvm_translation tr;
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Register now and save $200. Hurry, offer ends at 11:59 p.m., Monday, April 7! Use priority code J8TLD2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
include/linux/kvm.h struct kvm_s390_interrupt { · line 346
Quoted 9 lines · Marcelo Tosatti
/*
* ioctls for VM fdsinclude/linux/kvm.h +2
-0@@ -340,5 +341,7 @@ struct kvm_s390_interrupt {#define KVM_S390_SET_INITIAL_PSW _IOW(KVMIO, 0x96, struct kvm_s390_psw)/* initial reset for s390 */ #define KVM_S390_INITIAL_RESET _IO(KVMIO, 0x97) +#define KVM_GET_MP_STATE _IO(KVMIO, 0x98) +#define KVM_SET_MP_STATE _IO(KVMIO, 0x99)
This needs _IOW or _IORW to document transfer direction and structure size. Please put the data in a structure, and document the values by moving the #defines into linux/kvm.h
Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone