Commit 0750388c authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: selftests: Convert hardware_disable_test to pass around vCPU objects

Pass around 'struct kvm_vcpu' objects in hardware_disable_test instead of
the VM+vcpu_id (called "index" by the test).
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent b093da65
...@@ -27,12 +27,6 @@ ...@@ -27,12 +27,6 @@
sem_t *sem; sem_t *sem;
/* Arguments for the pthreads */
struct payload {
struct kvm_vm *vm;
uint32_t index;
};
static void guest_code(void) static void guest_code(void)
{ {
for (;;) for (;;)
...@@ -42,14 +36,14 @@ static void guest_code(void) ...@@ -42,14 +36,14 @@ static void guest_code(void)
static void *run_vcpu(void *arg) static void *run_vcpu(void *arg)
{ {
struct payload *payload = (struct payload *)arg; struct kvm_vcpu *vcpu = arg;
struct kvm_run *state = vcpu_state(payload->vm, payload->index); struct kvm_run *run = vcpu->run;
vcpu_run(payload->vm, payload->index); vcpu_run(vcpu->vm, vcpu->id);
TEST_ASSERT(false, "%s: exited with reason %d: %s\n", TEST_ASSERT(false, "%s: exited with reason %d: %s\n",
__func__, state->exit_reason, __func__, run->exit_reason,
exit_reason_str(state->exit_reason)); exit_reason_str(run->exit_reason));
pthread_exit(NULL); pthread_exit(NULL);
} }
...@@ -92,11 +86,11 @@ static inline void check_join(pthread_t thread, void **retval) ...@@ -92,11 +86,11 @@ static inline void check_join(pthread_t thread, void **retval)
static void run_test(uint32_t run) static void run_test(uint32_t run)
{ {
struct kvm_vcpu *vcpu;
struct kvm_vm *vm; struct kvm_vm *vm;
cpu_set_t cpu_set; cpu_set_t cpu_set;
pthread_t threads[VCPU_NUM]; pthread_t threads[VCPU_NUM];
pthread_t throw_away; pthread_t throw_away;
struct payload payloads[VCPU_NUM];
void *b; void *b;
uint32_t i, j; uint32_t i, j;
...@@ -108,12 +102,9 @@ static void run_test(uint32_t run) ...@@ -108,12 +102,9 @@ static void run_test(uint32_t run)
pr_debug("%s: [%d] start vcpus\n", __func__, run); pr_debug("%s: [%d] start vcpus\n", __func__, run);
for (i = 0; i < VCPU_NUM; ++i) { for (i = 0; i < VCPU_NUM; ++i) {
vm_vcpu_add(vm, i, guest_code); vcpu = vm_vcpu_add(vm, i, guest_code);
payloads[i].vm = vm;
payloads[i].index = i;
check_create_thread(&threads[i], NULL, run_vcpu, check_create_thread(&threads[i], NULL, run_vcpu, vcpu);
(void *)&payloads[i]);
check_set_affinity(threads[i], &cpu_set); check_set_affinity(threads[i], &cpu_set);
for (j = 0; j < SLEEPING_THREAD_NUM; ++j) { for (j = 0; j < SLEEPING_THREAD_NUM; ++j) {
......
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