Select Git revision
vcpu.c 809 B
#include "vcpu.h"
#include "../debug/debug.h"
#include "../region/vxmon.h"
#include "linux/slab.h"
#include <linux/errno.h>
int init_vcpu(struct vcpu_t *vcpu, unsigned long id) {
if (!vcpu) {
DEBUG_FMT("vcpu isn't allocated\n");
return -EFAULT;
}
struct vmxon_t *vmxon = alloc_vmxon();
if (!vmxon) {
DEBUG_FMT("VMXON region allocation failed\n");
return -ENOMEM;
}
struct vmcs_t *vmcs = alloc_vmcs();
if (!vmcs) {
DEBUG_FMT("VMCS region allocation failed\n");
return -ENOMEM;
}
vcpu->vmxon = vmxon;
vcpu->vmcs = vmcs;
vcpu->id = id;
return 0;
}
void destroy_vcpu(struct vcpu_t *vcpu) {
kfree(vcpu->vmxon);
kfree(vcpu->vmcs);
/*BUG: prolly won't change the pointer itself */
vcpu = NULL;
}