Changeset View
Changeset View
Standalone View
Standalone View
lib/libvmmapi/vmmapi.c
Show First 20 Lines • Show All 1,405 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
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 | |||||
vm_get_device_fd(struct vmctx *ctx) | |||||
{ | |||||
return ctx->fd; | |||||
grehan: minor style(9) nit - an extra blank line should be inserted here (also matches other one-line… | |||||
} | |||||
Not Done Inline ActionsMight be best to pass in a length param - if NULL, the length would be returned but no copy done, similar to how sysctl works. This allows the caller to determine the size of it's buffer. grehan: Might be best to pass in a length param - if NULL, the length would be returned but no copy… | |||||
Not Done Inline ActionsCan I keep the static allocation of the table and just pass a pointer to it or would you prefer dynamic allocation and forcing caller to free() it? kaktus: Can I keep the static allocation of the table and just pass a pointer to it or would you prefer… | |||||
Not Done Inline ActionsNot a lot of prior art in libc :(, but my preference would be to return a const pointer (and size param). grehan: Not a lot of prior art in libc :(, but my preference would be to return a const pointer (and… | |||||
Not Done Inline ActionsAs above, this can be cap_ioctl_t grehan: As above, this can be cap_ioctl_t | |||||
Not Done Inline ActionsMinor style nit: bcopy is used in all other routines in this file. grehan: Minor style nit: bcopy is used in all other routines in this file. | |||||
Not Done Inline ActionsNot getting this part why we just don't do a global from that? oshogbo: Not getting this part why we just don't do a global from that? | |||||
Not Done Inline ActionsAPI refinement suggested by @jhb in https://lists.freebsd.org/pipermail/svn-src-all/2017-February/139587.html I wonder if instead of doing this in the executable and exposing vm_get_ioctls, etc. if the API shouldn't really be something like 'vm_limit_rights(ctx)' and this code should be in that function in libvmmapi? It would be something like (assuming you drop vm_get_ioctls() entirely and expose vm_ioctl_cmds[] as a static global in the library): int vm_limit_rights(struct vm_ctx *ctx) { ... cap_rights_init(&rights, CAP_IOCTL, CAP_MMAP_RW); if (cap_rights_limit(ctx->fd, &rights) == -1) { if (errno == ENOSYS) return (0); else return (-1); } /* Shouldn't get ENOSYS here if cap_rights_limit worked. */ return (cap_ioctls_limit(ctx->fd, vm_ioctl_cmds, nitems(vm_ioctl_cmds)); } You wouldn't need vm_get_device_fd() either in this API. emaste: API refinement suggested by @jhb in https://lists.freebsd.org/pipermail/svn-src-all/2017… |
minor style(9) nit - an extra blank line should be inserted here (also matches other one-line functions in the file).