Changeset View
Changeset View
Standalone View
Standalone View
lib/libvmmapi/vmmapi.c
Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | vm_open(const char *name) | ||||
return (vm); | return (vm); | ||||
err: | err: | ||||
saved_errno = errno; | saved_errno = errno; | ||||
free(vm); | free(vm); | ||||
errno = saved_errno; | errno = saved_errno; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
void | int | ||||
vm_destroy(struct vmctx *vm) | vm_destroy(struct vmctx *vm) | ||||
{ | { | ||||
int dummy, error = 0; | |||||
assert(vm != NULL); | assert(vm != NULL); | ||||
if (vm->fd >= 0) | if (vm->fd >= 0) | ||||
close(vm->fd); | error = ioctl(vm->fd, VM_DESTROY, &dummy); | ||||
DESTROY(vm->name); | |||||
if (error == 0) { | |||||
close(vm->fd); | |||||
free(vm); | free(vm); | ||||
} | } | ||||
return (error); | |||||
} | |||||
int | int | ||||
vm_parse_memsize(const char *opt, size_t *ret_memsize) | vm_parse_memsize(const char *opt, size_t *ret_memsize) | ||||
{ | { | ||||
char *endptr; | char *endptr; | ||||
size_t optval; | size_t optval; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 1,527 Lines • ▼ Show 20 Lines | static const cap_ioctl_t vm_ioctl_cmds[] = { VM_RUN, VM_SUSPEND, VM_REINIT, | ||||
VM_PPTDEV_MSIX, VM_UNMAP_PPTDEV_MMIO, VM_PPTDEV_DISABLE_MSIX, | VM_PPTDEV_MSIX, VM_UNMAP_PPTDEV_MMIO, VM_PPTDEV_DISABLE_MSIX, | ||||
VM_INJECT_NMI, VM_STATS, VM_STAT_DESC, | VM_INJECT_NMI, VM_STATS, VM_STAT_DESC, | ||||
VM_SET_X2APIC_STATE, VM_GET_X2APIC_STATE, | VM_SET_X2APIC_STATE, VM_GET_X2APIC_STATE, | ||||
VM_GET_HPET_CAPABILITIES, VM_GET_GPA_PMAP, VM_GLA2GPA, | VM_GET_HPET_CAPABILITIES, VM_GET_GPA_PMAP, VM_GLA2GPA, | ||||
VM_GLA2GPA_NOFAULT, | VM_GLA2GPA_NOFAULT, | ||||
VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SUSPEND_CPU, VM_RESUME_CPU, | VM_ACTIVATE_CPU, VM_GET_CPUS, VM_SUSPEND_CPU, VM_RESUME_CPU, | ||||
VM_SET_INTINFO, VM_GET_INTINFO, | VM_SET_INTINFO, VM_GET_INTINFO, | ||||
VM_RTC_WRITE, VM_RTC_READ, VM_RTC_SETTIME, VM_RTC_GETTIME, | VM_RTC_WRITE, VM_RTC_READ, VM_RTC_SETTIME, VM_RTC_GETTIME, | ||||
VM_RESTART_INSTRUCTION, VM_SET_TOPOLOGY, VM_GET_TOPOLOGY }; | VM_RESTART_INSTRUCTION, VM_SET_TOPOLOGY, VM_GET_TOPOLOGY, | ||||
VM_DESTROY }; | |||||
if (len == NULL) { | if (len == NULL) { | ||||
cmds = malloc(sizeof(vm_ioctl_cmds)); | cmds = malloc(sizeof(vm_ioctl_cmds)); | ||||
if (cmds == NULL) | if (cmds == NULL) | ||||
return (NULL); | return (NULL); | ||||
bcopy(vm_ioctl_cmds, cmds, sizeof(vm_ioctl_cmds)); | bcopy(vm_ioctl_cmds, cmds, sizeof(vm_ioctl_cmds)); | ||||
return (cmds); | return (cmds); | ||||
} | } | ||||
*len = nitems(vm_ioctl_cmds); | *len = nitems(vm_ioctl_cmds); | ||||
return (NULL); | return (NULL); | ||||
} | } |