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

KVM: selftests: Drop vcpu_get(), rename vcpu_find() => vcpu_exists()

Drop vcpu_get() and rename vcpu_find() to vcpu_exists() to make it that
much harder for a test to give meaning to a vCPU ID.  I.e. force tests to
capture a vCPU when the vCPU is created.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 768e9a61
...@@ -93,8 +93,6 @@ struct kvm_vm { ...@@ -93,8 +93,6 @@ struct kvm_vm {
continue; \ continue; \
else else
struct kvm_vcpu *vcpu_get(struct kvm_vm *vm, uint32_t vcpu_id);
struct userspace_mem_region * struct userspace_mem_region *
memslot2region(struct kvm_vm *vm, uint32_t memslot); memslot2region(struct kvm_vm *vm, uint32_t memslot);
......
...@@ -459,26 +459,6 @@ kvm_userspace_memory_region_find(struct kvm_vm *vm, uint64_t start, ...@@ -459,26 +459,6 @@ kvm_userspace_memory_region_find(struct kvm_vm *vm, uint64_t start,
return &region->region; return &region->region;
} }
static struct kvm_vcpu *vcpu_find(struct kvm_vm *vm, uint32_t vcpu_id)
{
struct kvm_vcpu *vcpu;
list_for_each_entry(vcpu, &vm->vcpus, list) {
if (vcpu->id == vcpu_id)
return vcpu;
}
return NULL;
}
struct kvm_vcpu *vcpu_get(struct kvm_vm *vm, uint32_t vcpu_id)
{
struct kvm_vcpu *vcpu = vcpu_find(vm, vcpu_id);
TEST_ASSERT(vcpu, "vCPU %d does not exist", vcpu_id);
return vcpu;
}
/* /*
* VM VCPU Remove * VM VCPU Remove
* *
...@@ -1049,6 +1029,18 @@ static int vcpu_mmap_sz(void) ...@@ -1049,6 +1029,18 @@ static int vcpu_mmap_sz(void)
return ret; return ret;
} }
static bool vcpu_exists(struct kvm_vm *vm, uint32_t vcpu_id)
{
struct kvm_vcpu *vcpu;
list_for_each_entry(vcpu, &vm->vcpus, list) {
if (vcpu->id == vcpu_id)
return true;
}
return false;
}
/* /*
* Adds a virtual CPU to the VM specified by vm with the ID given by vcpu_id. * Adds a virtual CPU to the VM specified by vm with the ID given by vcpu_id.
* No additional vCPU setup is done. Returns the vCPU. * No additional vCPU setup is done. Returns the vCPU.
...@@ -1058,7 +1050,7 @@ struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id) ...@@ -1058,7 +1050,7 @@ struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id)
struct kvm_vcpu *vcpu; struct kvm_vcpu *vcpu;
/* Confirm a vcpu with the specified id doesn't already exist. */ /* Confirm a vcpu with the specified id doesn't already exist. */
TEST_ASSERT(!vcpu_find(vm, vcpu_id), "vCPU%d already exists\n", vcpu_id); TEST_ASSERT(!vcpu_exists(vm, vcpu_id), "vCPU%d already exists\n", vcpu_id);
/* Allocate and initialize new vcpu structure. */ /* Allocate and initialize new vcpu structure. */
vcpu = calloc(1, sizeof(*vcpu)); vcpu = calloc(1, sizeof(*vcpu));
......
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