#include <linux/kvm.h>
#include "linux/rbtree.h"
+
#include <sys/ioctl.h>
#include "sparsebit.h"
struct hlist_node slot_node;
};
-struct vcpu {
+struct kvm_vcpu {
struct list_head list;
uint32_t id;
int fd;
continue; \
else
-struct vcpu *vcpu_get(struct kvm_vm *vm, uint32_t vcpuid);
+struct kvm_vcpu *vcpu_get(struct kvm_vm *vm, uint32_t vcpuid);
/*
* Virtual Translation Tables Dump
* Create a VM with a single vCPU with reasonable defaults and @extra_mem_pages
* additional pages of guest memory. Returns the VM and vCPU (via out param).
*/
-struct kvm_vm *__vm_create_with_one_vcpu(struct vcpu **vcpu,
+struct kvm_vm *__vm_create_with_one_vcpu(struct kvm_vcpu **vcpu,
uint64_t extra_mem_pages,
void *guest_code);
-static inline struct kvm_vm *vm_create_with_one_vcpu(struct vcpu **vcpu,
+static inline struct kvm_vm *vm_create_with_one_vcpu(struct kvm_vcpu **vcpu,
void *guest_code)
{
return __vm_create_with_one_vcpu(vcpu, 0, guest_code);
}
-struct vcpu *vm_recreate_with_one_vcpu(struct kvm_vm *vm);
+struct kvm_vcpu *vm_recreate_with_one_vcpu(struct kvm_vm *vm);
/*
* Adds a vCPU with reasonable defaults (e.g. a stack)
(uint32_t []){ vcpuid });
}
-struct kvm_vm *__vm_create_with_one_vcpu(struct vcpu **vcpu,
+struct kvm_vm *__vm_create_with_one_vcpu(struct kvm_vcpu **vcpu,
uint64_t extra_mem_pages,
void *guest_code)
{
}
}
-struct vcpu *vm_recreate_with_one_vcpu(struct kvm_vm *vm)
+struct kvm_vcpu *vm_recreate_with_one_vcpu(struct kvm_vm *vm)
{
kvm_vm_restart(vm);
return ®ion->region;
}
-static struct vcpu *vcpu_find(struct kvm_vm *vm, uint32_t vcpuid)
+static struct kvm_vcpu *vcpu_find(struct kvm_vm *vm, uint32_t vcpu_id)
{
- struct vcpu *vcpu;
+ struct kvm_vcpu *vcpu;
list_for_each_entry(vcpu, &vm->vcpus, list) {
- if (vcpu->id == vcpuid)
+ if (vcpu->id == vcpu_id)
return vcpu;
}
return NULL;
}
-struct vcpu *vcpu_get(struct kvm_vm *vm, uint32_t vcpuid)
+struct kvm_vcpu *vcpu_get(struct kvm_vm *vm, uint32_t vcpu_id)
{
- struct vcpu *vcpu = vcpu_find(vm, vcpuid);
+ struct kvm_vcpu *vcpu = vcpu_find(vm, vcpu_id);
- TEST_ASSERT(vcpu, "vCPU %d does not exist", vcpuid);
+ TEST_ASSERT(vcpu, "vCPU %d does not exist", vcpu_id);
return vcpu;
}
*
* Removes a vCPU from a VM and frees its resources.
*/
-static void vm_vcpu_rm(struct kvm_vm *vm, struct vcpu *vcpu)
+static void vm_vcpu_rm(struct kvm_vm *vm, struct kvm_vcpu *vcpu)
{
int ret;
void kvm_vm_release(struct kvm_vm *vmp)
{
- struct vcpu *vcpu, *tmp;
+ struct kvm_vcpu *vcpu, *tmp;
int ret;
list_for_each_entry_safe(vcpu, tmp, &vmp->vcpus, list)
*/
void vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpuid)
{
- struct vcpu *vcpu;
+ struct kvm_vcpu *vcpu;
/* Confirm a vcpu with the specified id doesn't already exist. */
TEST_ASSERT(!vcpu_find(vm, vcpuid), "vCPU%d already exists\n", vcpuid);
*/
struct kvm_run *vcpu_state(struct kvm_vm *vm, uint32_t vcpuid)
{
- struct vcpu *vcpu = vcpu_get(vm, vcpuid);
+ struct kvm_vcpu *vcpu = vcpu_get(vm, vcpuid);
return vcpu->run;
}
void vcpu_run_complete_io(struct kvm_vm *vm, uint32_t vcpuid)
{
- struct vcpu *vcpu = vcpu_get(vm, vcpuid);
+ struct kvm_vcpu *vcpu = vcpu_get(vm, vcpuid);
int ret;
vcpu->run->immediate_exit = 1;
int __vcpu_ioctl(struct kvm_vm *vm, uint32_t vcpuid,
unsigned long cmd, void *arg)
{
- struct vcpu *vcpu = vcpu_get(vm, vcpuid);
+ struct kvm_vcpu *vcpu = vcpu_get(vm, vcpuid);
return ioctl(vcpu->fd, cmd, arg);
}
void *vcpu_map_dirty_ring(struct kvm_vm *vm, uint32_t vcpuid)
{
- struct vcpu *vcpu = vcpu_get(vm, vcpuid);
+ struct kvm_vcpu *vcpu = vcpu_get(vm, vcpuid);
uint32_t size = vm->dirty_ring_size;
TEST_ASSERT(size > 0, "Should enable dirty ring first");
int __vcpu_has_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group,
uint64_t attr)
{
- struct vcpu *vcpu = vcpu_get(vm, vcpuid);
-
- return __kvm_has_device_attr(vcpu->fd, group, attr);
+ return __kvm_has_device_attr(vcpu_get(vm, vcpuid)->fd, group, attr);
}
/*
{
int ctr;
struct userspace_mem_region *region;
- struct vcpu *vcpu;
+ struct kvm_vcpu *vcpu;
fprintf(stream, "%*smode: 0x%x\n", indent, "", vm->mode);
fprintf(stream, "%*sfd: %i\n", indent, "", vm->fd);