kvm: decode the argument of KVM_CREATE_VCPU ioctl command

* kvm.c (kvm_ioctl_create_vcpu): New function.
(kvm_ioctl) <KVM_CREATE_VCPU>: Use it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
This commit is contained in:
Masatake YAMATO 2017-12-02 04:05:28 +09:00 committed by Dmitry V. Levin
parent 312073760f
commit 5f61f158c3

11
kvm.c
View File

@ -33,10 +33,21 @@
#ifdef HAVE_LINUX_KVM_H #ifdef HAVE_LINUX_KVM_H
# include <linux/kvm.h> # include <linux/kvm.h>
static int
kvm_ioctl_create_vcpu(struct tcb *const tcp, const kernel_ulong_t arg)
{
uint32_t cpuid = arg;
tprintf(", %u", cpuid);
return RVAL_IOCTL_DECODED | RVAL_FD;
}
int int
kvm_ioctl(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg) kvm_ioctl(struct tcb *const tcp, const unsigned int code, const kernel_ulong_t arg)
{ {
switch (code) { switch (code) {
case KVM_CREATE_VCPU:
return kvm_ioctl_create_vcpu(tcp, arg);
case KVM_CREATE_VM: case KVM_CREATE_VM:
return RVAL_DECODED | RVAL_FD; return RVAL_DECODED | RVAL_FD;
case KVM_RUN: case KVM_RUN: