Changeset View
Changeset View
Standalone View
Standalone View
lib/libvmmapi/vmmapi.c
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | vm_open(const char *name) | ||||
struct vmctx *vm; | struct vmctx *vm; | ||||
int saved_errno; | int saved_errno; | ||||
vm = malloc(sizeof(struct vmctx) + strlen(name) + 1); | vm = malloc(sizeof(struct vmctx) + strlen(name) + 1); | ||||
assert(vm != NULL); | assert(vm != NULL); | ||||
vm->fd = -1; | vm->fd = -1; | ||||
vm->memflags = 0; | vm->memflags = 0; | ||||
vm->lowmem_limit = 3 * GB; | vm->lowmem_limit = 3 * GB; | ||||
grehan: This will hurt 32-bit VMs. However, it is possible to change this at runtime, though it has to… | |||||
vm->name = (char *)(vm + 1); | vm->name = (char *)(vm + 1); | ||||
strcpy(vm->name, name); | strcpy(vm->name, name); | ||||
if ((vm->fd = vm_device_open(vm->name)) < 0) | if ((vm->fd = vm_device_open(vm->name)) < 0) | ||||
goto err; | goto err; | ||||
return (vm); | return (vm); | ||||
err: | err: | ||||
▲ Show 20 Lines • Show All 871 Lines • ▼ Show 20 Lines | vm_unmap_pptdev_mmio(struct vmctx *ctx, int bus, int slot, int func, | ||||
pptmmio.func = func; | pptmmio.func = func; | ||||
pptmmio.gpa = gpa; | pptmmio.gpa = gpa; | ||||
pptmmio.len = len; | pptmmio.len = len; | ||||
return (ioctl(ctx->fd, VM_UNMAP_PPTDEV_MMIO, &pptmmio)); | return (ioctl(ctx->fd, VM_UNMAP_PPTDEV_MMIO, &pptmmio)); | ||||
} | } | ||||
int | int | ||||
vm_get_memory_region_info(struct vmctx *const ctx, vm_paddr_t *const base, | |||||
vm_paddr_t *const size, const enum vm_memory_region_type type) | |||||
{ | |||||
struct vm_memory_region_info memory_region_info; | |||||
bzero(&memory_region_info, sizeof(memory_region_info)); | |||||
memory_region_info.type = type; | |||||
const int error = ioctl(ctx->fd, VM_GET_MEMORY_REGION_INFO, &memory_region_info); | |||||
if (base) | |||||
*base = memory_region_info.base; | |||||
if (size) | |||||
*size = memory_region_info.size; | |||||
return (error); | |||||
} | |||||
int | |||||
vm_setup_pptdev_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func, | vm_setup_pptdev_msi(struct vmctx *ctx, int vcpu, int bus, int slot, int func, | ||||
uint64_t addr, uint64_t msg, int numvec) | uint64_t addr, uint64_t msg, int numvec) | ||||
{ | { | ||||
struct vm_pptdev_msi pptmsi; | struct vm_pptdev_msi pptmsi; | ||||
bzero(&pptmsi, sizeof(pptmsi)); | bzero(&pptmsi, sizeof(pptmsi)); | ||||
pptmsi.vcpu = vcpu; | pptmsi.vcpu = vcpu; | ||||
pptmsi.bus = bus; | pptmsi.bus = bus; | ||||
▲ Show 20 Lines • Show All 658 Lines • ▼ Show 20 Lines | static const cap_ioctl_t vm_ioctl_cmds[] = { VM_RUN, VM_SUSPEND, VM_REINIT, | ||||
VM_SET_KERNEMU_DEV, VM_GET_KERNEMU_DEV, | VM_SET_KERNEMU_DEV, VM_GET_KERNEMU_DEV, | ||||
VM_INJECT_EXCEPTION, VM_LAPIC_IRQ, VM_LAPIC_LOCAL_IRQ, | VM_INJECT_EXCEPTION, VM_LAPIC_IRQ, VM_LAPIC_LOCAL_IRQ, | ||||
VM_LAPIC_MSI, VM_IOAPIC_ASSERT_IRQ, VM_IOAPIC_DEASSERT_IRQ, | VM_LAPIC_MSI, VM_IOAPIC_ASSERT_IRQ, VM_IOAPIC_DEASSERT_IRQ, | ||||
VM_IOAPIC_PULSE_IRQ, VM_IOAPIC_PINCOUNT, VM_ISA_ASSERT_IRQ, | VM_IOAPIC_PULSE_IRQ, VM_IOAPIC_PINCOUNT, VM_ISA_ASSERT_IRQ, | ||||
VM_ISA_DEASSERT_IRQ, VM_ISA_PULSE_IRQ, VM_ISA_SET_IRQ_TRIGGER, | VM_ISA_DEASSERT_IRQ, VM_ISA_PULSE_IRQ, VM_ISA_SET_IRQ_TRIGGER, | ||||
VM_SET_CAPABILITY, VM_GET_CAPABILITY, VM_BIND_PPTDEV, | VM_SET_CAPABILITY, VM_GET_CAPABILITY, VM_BIND_PPTDEV, | ||||
VM_UNBIND_PPTDEV, VM_MAP_PPTDEV_MMIO, VM_PPTDEV_MSI, | VM_UNBIND_PPTDEV, VM_MAP_PPTDEV_MMIO, VM_PPTDEV_MSI, | ||||
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_GET_MEMORY_REGION_INFO, 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 }; | ||||
Show All 11 Lines |
This will hurt 32-bit VMs. However, it is possible to change this at runtime, though it has to be done prior to PCI config.