Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libvmmapi/vmmapi.c
Show First 20 Lines • Show All 1,500 Lines • ▼ Show 20 Lines | |||||
vm_restart_instruction(void *arg, int vcpu) | vm_restart_instruction(void *arg, int vcpu) | ||||
{ | { | ||||
struct vmctx *ctx = arg; | struct vmctx *ctx = arg; | ||||
return (ioctl(ctx->fd, VM_RESTART_INSTRUCTION, &vcpu)); | return (ioctl(ctx->fd, VM_RESTART_INSTRUCTION, &vcpu)); | ||||
} | } | ||||
int | int | ||||
vm_set_topology(struct vmctx *ctx, | |||||
uint16_t sockets, uint16_t cores, uint16_t threads, uint16_t maxcpus) | |||||
{ | |||||
struct vm_cpu_topology topology; | |||||
bzero(&topology, sizeof (struct vm_cpu_topology)); | |||||
topology.sockets = sockets; | |||||
topology.cores = cores; | |||||
topology.threads = threads; | |||||
topology.maxcpus = maxcpus; | |||||
return (ioctl(ctx->fd, VM_SET_TOPOLOGY, &topology)); | |||||
} | |||||
int | |||||
vm_get_topology(struct vmctx *ctx, | |||||
uint16_t *sockets, uint16_t *cores, uint16_t *threads, uint16_t *maxcpus) | |||||
{ | |||||
struct vm_cpu_topology topology; | |||||
int error; | |||||
bzero(&topology, sizeof (struct vm_cpu_topology)); | |||||
error = ioctl(ctx->fd, VM_GET_TOPOLOGY, &topology); | |||||
if (error == 0) { | |||||
*sockets = topology.sockets; | |||||
*cores = topology.cores; | |||||
*threads = topology.threads; | |||||
*maxcpus = topology.maxcpus; | |||||
} | |||||
return (error); | |||||
} | |||||
int | |||||
vm_get_device_fd(struct vmctx *ctx) | vm_get_device_fd(struct vmctx *ctx) | ||||
{ | { | ||||
return (ctx->fd); | return (ctx->fd); | ||||
} | } | ||||
const cap_ioctl_t * | const cap_ioctl_t * | ||||
vm_get_ioctls(size_t *len) | vm_get_ioctls(size_t *len) | ||||
Show All 13 Lines | static const cap_ioctl_t vm_ioctl_cmds[] = { VM_RUN, VM_SUSPEND, VM_REINIT, | ||||
VM_UNBIND_PPTDEV, VM_MAP_PPTDEV_MMIO, VM_PPTDEV_MSI, | VM_UNBIND_PPTDEV, VM_MAP_PPTDEV_MMIO, VM_PPTDEV_MSI, | ||||
VM_PPTDEV_MSIX, VM_INJECT_NMI, VM_STATS, VM_STAT_DESC, | VM_PPTDEV_MSIX, 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_RESTART_INSTRUCTION, VM_SET_TOPOLOGY, VM_GET_TOPOLOGY }; | ||||
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); | ||||
} | } | ||||