Commit f3165dc0 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: selftests: Drop @test param from kvm_create_device()

Remove the two calls that pass @test=true to kvm_create_device() and drop
the @test param entirely.  The two removed calls don't check the return
value of kvm_create_device(), so other than verifying KVM doesn't explode,
which is extremely unlikely given that the non-test variant was _just_
called, they are pointless and provide no validation coverage.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent a78593fd
...@@ -65,7 +65,7 @@ static struct vm_gic vm_gic_create_with_vcpus(uint32_t gic_dev_type, uint32_t nr ...@@ -65,7 +65,7 @@ static struct vm_gic vm_gic_create_with_vcpus(uint32_t gic_dev_type, uint32_t nr
v.gic_dev_type = gic_dev_type; v.gic_dev_type = gic_dev_type;
v.vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL); v.vm = vm_create_default_with_vcpus(nr_vcpus, 0, 0, guest_code, NULL);
v.gic_fd = kvm_create_device(v.vm, gic_dev_type, false); v.gic_fd = kvm_create_device(v.vm, gic_dev_type);
return v; return v;
} }
...@@ -406,7 +406,7 @@ static void test_v3_typer_accesses(void) ...@@ -406,7 +406,7 @@ static void test_v3_typer_accesses(void)
v.vm = vm_create_default(0, 0, guest_code); v.vm = vm_create_default(0, 0, guest_code);
v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3, false); v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3);
vm_vcpu_add_default(v.vm, 3, guest_code); vm_vcpu_add_default(v.vm, 3, guest_code);
...@@ -487,7 +487,7 @@ static void test_v3_last_bit_redist_regions(void) ...@@ -487,7 +487,7 @@ static void test_v3_last_bit_redist_regions(void)
v.vm = vm_create_default_with_vcpus(6, 0, 0, guest_code, vcpuids); v.vm = vm_create_default_with_vcpus(6, 0, 0, guest_code, vcpuids);
v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3, false); v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3);
kvm_device_access(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, kvm_device_access(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true);
...@@ -536,7 +536,7 @@ static void test_v3_last_bit_single_rdist(void) ...@@ -536,7 +536,7 @@ static void test_v3_last_bit_single_rdist(void)
v.vm = vm_create_default_with_vcpus(6, 0, 0, guest_code, vcpuids); v.vm = vm_create_default_with_vcpus(6, 0, 0, guest_code, vcpuids);
v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3, false); v.gic_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_V3);
kvm_device_access(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, kvm_device_access(v.gic_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true); KVM_DEV_ARM_VGIC_CTRL_INIT, NULL, true);
...@@ -603,7 +603,7 @@ static void test_v3_its_region(void) ...@@ -603,7 +603,7 @@ static void test_v3_its_region(void)
int its_fd, ret; int its_fd, ret;
v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS); v = vm_gic_create_with_vcpus(KVM_DEV_TYPE_ARM_VGIC_V3, NR_VCPUS);
its_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_ITS, false); its_fd = kvm_create_device(v.vm, KVM_DEV_TYPE_ARM_VGIC_ITS);
addr = 0x401000; addr = 0x401000;
ret = _kvm_device_access(its_fd, KVM_DEV_ARM_VGIC_GRP_ADDR, ret = _kvm_device_access(its_fd, KVM_DEV_ARM_VGIC_GRP_ADDR,
...@@ -656,13 +656,11 @@ int test_kvm_device(uint32_t gic_dev_type) ...@@ -656,13 +656,11 @@ int test_kvm_device(uint32_t gic_dev_type)
ret = _kvm_create_device(v.vm, gic_dev_type, true, &fd); ret = _kvm_create_device(v.vm, gic_dev_type, true, &fd);
if (ret) if (ret)
return ret; return ret;
v.gic_fd = kvm_create_device(v.vm, gic_dev_type, false); v.gic_fd = kvm_create_device(v.vm, gic_dev_type);
ret = _kvm_create_device(v.vm, gic_dev_type, false, &fd); ret = _kvm_create_device(v.vm, gic_dev_type, false, &fd);
TEST_ASSERT(ret && errno == EEXIST, "create GIC device twice"); TEST_ASSERT(ret && errno == EEXIST, "create GIC device twice");
kvm_create_device(v.vm, gic_dev_type, true);
/* try to create the other gic_dev_type */ /* try to create the other gic_dev_type */
other = VGIC_DEV_IS_V2(gic_dev_type) ? KVM_DEV_TYPE_ARM_VGIC_V3 other = VGIC_DEV_IS_V2(gic_dev_type) ? KVM_DEV_TYPE_ARM_VGIC_V3
: KVM_DEV_TYPE_ARM_VGIC_V2; : KVM_DEV_TYPE_ARM_VGIC_V2;
......
...@@ -485,7 +485,7 @@ void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...); ...@@ -485,7 +485,7 @@ void vcpu_args_set(struct kvm_vm *vm, uint32_t vcpuid, unsigned int num, ...);
int _kvm_device_check_attr(int dev_fd, uint32_t group, uint64_t attr); int _kvm_device_check_attr(int dev_fd, uint32_t group, uint64_t attr);
int kvm_device_check_attr(int dev_fd, uint32_t group, uint64_t attr); int kvm_device_check_attr(int dev_fd, uint32_t group, uint64_t attr);
int _kvm_create_device(struct kvm_vm *vm, uint64_t type, bool test, int *fd); int _kvm_create_device(struct kvm_vm *vm, uint64_t type, bool test, int *fd);
int kvm_create_device(struct kvm_vm *vm, uint64_t type, bool test); int kvm_create_device(struct kvm_vm *vm, uint64_t type);
int _kvm_device_access(int dev_fd, uint32_t group, uint64_t attr, int _kvm_device_access(int dev_fd, uint32_t group, uint64_t attr,
void *val, bool write); void *val, bool write);
int kvm_device_access(int dev_fd, uint32_t group, uint64_t attr, int kvm_device_access(int dev_fd, uint32_t group, uint64_t attr,
......
...@@ -1642,18 +1642,14 @@ int _kvm_create_device(struct kvm_vm *vm, uint64_t type, bool test, int *fd) ...@@ -1642,18 +1642,14 @@ int _kvm_create_device(struct kvm_vm *vm, uint64_t type, bool test, int *fd)
return ret; return ret;
} }
int kvm_create_device(struct kvm_vm *vm, uint64_t type, bool test) int kvm_create_device(struct kvm_vm *vm, uint64_t type)
{ {
int fd, ret; int fd, ret;
ret = _kvm_create_device(vm, type, test, &fd); ret = _kvm_create_device(vm, type, false, &fd);
if (!test) { TEST_ASSERT(!ret, "KVM_CREATE_DEVICE IOCTL failed, rc: %i errno: %i", ret, errno);
TEST_ASSERT(!ret, return fd;
"KVM_CREATE_DEVICE IOCTL failed, rc: %i errno: %i", ret, errno);
return fd;
}
return ret;
} }
int _kvm_device_access(int dev_fd, uint32_t group, uint64_t attr, int _kvm_device_access(int dev_fd, uint32_t group, uint64_t attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment