Changeset View
Changeset View
Standalone View
Standalone View
lib/libvmmapi/vmmapi.c
Show All 28 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <sys/linker.h> | |||||
#include <sys/mman.h> | #include <sys/mman.h> | ||||
#include <sys/module.h> | |||||
#include <sys/_iovec.h> | #include <sys/_iovec.h> | ||||
#include <sys/cpuset.h> | #include <sys/cpuset.h> | ||||
#include <x86/segments.h> | #include <x86/segments.h> | ||||
#include <machine/specialreg.h> | #include <machine/specialreg.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | vm_device_open(const char *name) | ||||
free(vmfile); | free(vmfile); | ||||
return (fd); | return (fd); | ||||
} | } | ||||
int | int | ||||
vm_create(const char *name) | vm_create(const char *name) | ||||
{ | { | ||||
/* Try to load vmm(4) module before create a guest */ | |||||
jhb: Tiny nit:
```
/* Try to load the vmm(4) module before creating a guest. */
```
You could… | |||||
if (modfind("vmm") < 0) { | |||||
if (kldload("vmm") < 0 || modfind("vmm") < 0) { | |||||
return (-1); | |||||
} | |||||
} | |||||
return (CREATE((char *)name)); | return (CREATE((char *)name)); | ||||
} | } | ||||
struct vmctx * | struct vmctx * | ||||
vm_open(const char *name) | vm_open(const char *name) | ||||
{ | { | ||||
struct vmctx *vm; | struct vmctx *vm; | ||||
▲ Show 20 Lines • Show All 1,467 Lines • Show Last 20 Lines |
Tiny nit:
You could perhaps simplify this slightly by not worrying about errors from kldload() and letting it fall through to CREATE still in that case to report the error: