diff options
author | Sean Christopherson <seanjc@google.com> | 2022-02-15 15:14:29 -0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-06-11 11:46:25 -0400 |
commit | c472df1ac318c1120f32cd4a70d202806be30c43 (patch) | |
tree | 97809d737f6966cb8f9e792acc0698718655b632 /tools | |
parent | 114eef6e461a6a0810d6ed354b4ce7f3b74fe547 (diff) | |
download | lwn-c472df1ac318c1120f32cd4a70d202806be30c43.tar.gz lwn-c472df1ac318c1120f32cd4a70d202806be30c43.zip |
KVM: selftests: Add a VM backpointer to 'struct vcpu'
Add a backpointer to 'struct vcpu' so that tests can get at the owning
VM when passing around a vCPU object. Long term, this will be little
more than a nice-to-have feature, but in the short term it is a critical
step toward purging the VM+vcpu_id ioctl mess without introducing even
more churn.
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/kvm/include/kvm_util_base.h | 1 | ||||
-rw-r--r-- | tools/testing/selftests/kvm/lib/kvm_util.c | 1 |
2 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h index 6e63e7e57752..2e1453cb0511 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -47,6 +47,7 @@ struct vcpu { struct list_head list; uint32_t id; int fd; + struct kvm_vm *vm; struct kvm_run *state; struct kvm_dirty_gfn *dirty_gfns; uint32_t fetch_index; diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 220e079dc749..2d82b5720737 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1099,6 +1099,7 @@ void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid) vcpu = calloc(1, sizeof(*vcpu)); TEST_ASSERT(vcpu != NULL, "Insufficient Memory"); + vcpu->vm = vm; vcpu->id = vcpuid; vcpu->fd = __vm_ioctl(vm, KVM_CREATE_VCPU, (void *)(unsigned long)vcpuid); TEST_ASSERT(vcpu->fd >= 0, KVM_IOCTL_ERROR(KVM_CREATE_VCPU, vcpu->fd)); |