From: Avi K. <av...@qu...> - 2008-04-11 00:22:13
|
Marcelo Tosatti wrote: > Add libkvm interface to get/set the mpstate. > > Signed-off-by: Marcelo Tosatti <mto...@re...> > > 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; > +} > We usually follow the convention of returning -errno in case of error instead of -1 in libkvm. -- Any sufficiently difficult bug is indistinguishable from a feature. |