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

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: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 114eef6e
...@@ -47,6 +47,7 @@ struct vcpu { ...@@ -47,6 +47,7 @@ struct vcpu {
struct list_head list; struct list_head list;
uint32_t id; uint32_t id;
int fd; int fd;
struct kvm_vm *vm;
struct kvm_run *state; struct kvm_run *state;
struct kvm_dirty_gfn *dirty_gfns; struct kvm_dirty_gfn *dirty_gfns;
uint32_t fetch_index; uint32_t fetch_index;
......
...@@ -1099,6 +1099,7 @@ void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid) ...@@ -1099,6 +1099,7 @@ void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid)
vcpu = calloc(1, sizeof(*vcpu)); vcpu = calloc(1, sizeof(*vcpu));
TEST_ASSERT(vcpu != NULL, "Insufficient Memory"); TEST_ASSERT(vcpu != NULL, "Insufficient Memory");
vcpu->vm = vm;
vcpu->id = vcpuid; vcpu->id = vcpuid;
vcpu->fd = __vm_ioctl(vm, KVM_CREATE_VCPU, (void *)(unsigned long)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)); TEST_ASSERT(vcpu->fd >= 0, KVM_IOCTL_ERROR(KVM_CREATE_VCPU, vcpu->fd));
......
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