mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-21 10:41:46 +01:00
Merge branch 'freebsd/current/main' into hardened/current/master
This commit is contained in:
commit
ea7c25888c
@ -187,6 +187,8 @@
|
|||||||
..
|
..
|
||||||
vkbd
|
vkbd
|
||||||
..
|
..
|
||||||
|
vmm
|
||||||
|
..
|
||||||
wg
|
wg
|
||||||
..
|
..
|
||||||
wi
|
wi
|
||||||
|
@ -310,6 +310,13 @@ INCS+= iconv.h
|
|||||||
LSUBDIRS+= dev/usb
|
LSUBDIRS+= dev/usb
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "aarch64" || \
|
||||||
|
${MACHINE_CPUARCH} == "riscv"
|
||||||
|
.if ${MK_BHYVE} != "no"
|
||||||
|
LSUBDIRS+= dev/vmm
|
||||||
|
.endif
|
||||||
|
.endif
|
||||||
|
|
||||||
.if ${MACHINE_CPUARCH} == "powerpc" && ${MACHINE_ARCH} != "powerpcspe"
|
.if ${MACHINE_CPUARCH} == "powerpc" && ${MACHINE_ARCH} != "powerpcspe"
|
||||||
_dev_powermac_nvram= dev/powermac_nvram
|
_dev_powermac_nvram= dev/powermac_nvram
|
||||||
.endif
|
.endif
|
||||||
|
@ -16,7 +16,8 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct vmctx {
|
struct vmctx {
|
||||||
int fd;
|
int fd; /* device file descriptor */
|
||||||
|
int ctlfd; /* vmm control descriptor */
|
||||||
struct {
|
struct {
|
||||||
vm_paddr_t base;
|
vm_paddr_t base;
|
||||||
vm_size_t size;
|
vm_size_t size;
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include <sys/cpuset.h>
|
#include <sys/cpuset.h>
|
||||||
|
|
||||||
#include <capsicum_helpers.h>
|
#include <capsicum_helpers.h>
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -50,11 +51,12 @@
|
|||||||
|
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <machine/vmm.h>
|
#include <machine/vmm.h>
|
||||||
#include <machine/vmm_dev.h>
|
|
||||||
#ifdef WITH_VMMAPI_SNAPSHOT
|
#ifdef WITH_VMMAPI_SNAPSHOT
|
||||||
#include <machine/vmm_snapshot.h>
|
#include <machine/vmm_snapshot.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <dev/vmm/vmm_dev.h>
|
||||||
|
|
||||||
#include "vmmapi.h"
|
#include "vmmapi.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
@ -78,58 +80,104 @@
|
|||||||
#define PROT_RW (PROT_READ | PROT_WRITE)
|
#define PROT_RW (PROT_READ | PROT_WRITE)
|
||||||
#define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
|
#define PROT_ALL (PROT_READ | PROT_WRITE | PROT_EXEC)
|
||||||
|
|
||||||
#define CREATE(x) sysctlbyname("hw.vmm.create", NULL, NULL, (x), strlen((x)))
|
|
||||||
#define DESTROY(x) sysctlbyname("hw.vmm.destroy", NULL, NULL, (x), strlen((x)))
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vm_device_open(const char *name)
|
vm_device_open(const char *name)
|
||||||
{
|
{
|
||||||
int fd, len;
|
char devpath[PATH_MAX];
|
||||||
char *vmfile;
|
|
||||||
|
|
||||||
len = strlen("/dev/vmm/") + strlen(name) + 1;
|
assert(strlen(name) <= VM_MAX_NAMELEN);
|
||||||
vmfile = malloc(len);
|
(void)snprintf(devpath, sizeof(devpath), "/dev/vmm/%s", name);
|
||||||
assert(vmfile != NULL);
|
return (open(devpath, O_RDWR));
|
||||||
snprintf(vmfile, len, "/dev/vmm/%s", name);
|
}
|
||||||
|
|
||||||
/* Open the device file */
|
static int
|
||||||
fd = open(vmfile, O_RDWR, 0);
|
vm_ctl_create(const char *name, int ctlfd)
|
||||||
|
{
|
||||||
|
struct vmmctl_vm_create vmc;
|
||||||
|
|
||||||
free(vmfile);
|
memset(&vmc, 0, sizeof(vmc));
|
||||||
return (fd);
|
if (strlcpy(vmc.name, name, sizeof(vmc.name)) >= sizeof(vmc.name)) {
|
||||||
|
errno = ENAMETOOLONG;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
return (ioctl(ctlfd, VMMCTL_VM_CREATE, &vmc));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vm_create(const char *name)
|
vm_create(const char *name)
|
||||||
{
|
{
|
||||||
|
int error, fd;
|
||||||
|
|
||||||
/* Try to load vmm(4) module before creating a guest. */
|
/* Try to load vmm(4) module before creating a guest. */
|
||||||
if (modfind("vmm") < 0)
|
if (modfind("vmm") < 0) {
|
||||||
kldload("vmm");
|
error = kldload("vmm");
|
||||||
return (CREATE(name));
|
if (error != 0)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = open("/dev/vmmctl", O_RDWR, 0);
|
||||||
|
if (fd < 0)
|
||||||
|
return (fd);
|
||||||
|
error = vm_ctl_create(name, fd);
|
||||||
|
if (error != 0) {
|
||||||
|
error = errno;
|
||||||
|
(void)close(fd);
|
||||||
|
errno = error;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
(void)close(fd);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vmctx *
|
struct vmctx *
|
||||||
vm_open(const char *name)
|
vm_open(const char *name)
|
||||||
|
{
|
||||||
|
return (vm_openf(name, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
struct vmctx *
|
||||||
|
vm_openf(const char *name, int flags)
|
||||||
{
|
{
|
||||||
struct vmctx *vm;
|
struct vmctx *vm;
|
||||||
int saved_errno;
|
int saved_errno;
|
||||||
|
bool created;
|
||||||
|
|
||||||
|
created = false;
|
||||||
|
|
||||||
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 = vm->ctlfd = -1;
|
||||||
vm->memflags = 0;
|
vm->memflags = 0;
|
||||||
vm->name = (char *)(vm + 1);
|
vm->name = (char *)(vm + 1);
|
||||||
strcpy(vm->name, name);
|
strcpy(vm->name, name);
|
||||||
memset(vm->memsegs, 0, sizeof(vm->memsegs));
|
memset(vm->memsegs, 0, sizeof(vm->memsegs));
|
||||||
|
|
||||||
if ((vm->fd = vm_device_open(vm->name)) < 0)
|
if ((vm->ctlfd = open("/dev/vmmctl", O_RDWR, 0)) < 0)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
vm->fd = vm_device_open(vm->name);
|
||||||
|
if (vm->fd < 0 && errno == ENOENT) {
|
||||||
|
if (flags & VMMAPI_OPEN_CREATE) {
|
||||||
|
if (vm_ctl_create(vm->name, vm->ctlfd) != 0)
|
||||||
|
goto err;
|
||||||
|
vm->fd = vm_device_open(vm->name);
|
||||||
|
created = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (vm->fd < 0)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (!created && (flags & VMMAPI_OPEN_REINIT) != 0 && vm_reinit(vm) != 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
return (vm);
|
return (vm);
|
||||||
err:
|
err:
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
free(vm);
|
if (created)
|
||||||
|
vm_destroy(vm);
|
||||||
|
else
|
||||||
|
vm_close(vm);
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -139,20 +187,24 @@ vm_close(struct vmctx *vm)
|
|||||||
{
|
{
|
||||||
assert(vm != NULL);
|
assert(vm != NULL);
|
||||||
|
|
||||||
close(vm->fd);
|
if (vm->fd >= 0)
|
||||||
|
(void)close(vm->fd);
|
||||||
|
if (vm->ctlfd >= 0)
|
||||||
|
(void)close(vm->ctlfd);
|
||||||
free(vm);
|
free(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vm_destroy(struct vmctx *vm)
|
vm_destroy(struct vmctx *vm)
|
||||||
{
|
{
|
||||||
assert(vm != NULL);
|
struct vmmctl_vm_destroy vmd;
|
||||||
|
|
||||||
if (vm->fd >= 0)
|
memset(&vmd, 0, sizeof(vmd));
|
||||||
close(vm->fd);
|
(void)strlcpy(vmd.name, vm->name, sizeof(vmd.name));
|
||||||
DESTROY(vm->name);
|
if (ioctl(vm->ctlfd, VMMCTL_VM_DESTROY, &vmd) != 0)
|
||||||
|
warn("ioctl(VMMCTL_VM_DESTROY)");
|
||||||
|
|
||||||
free(vm);
|
vm_close(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vcpu *
|
struct vcpu *
|
||||||
|
@ -117,6 +117,9 @@ int vm_munmap_memseg(struct vmctx *ctx, vm_paddr_t gpa, size_t len);
|
|||||||
|
|
||||||
int vm_create(const char *name);
|
int vm_create(const char *name);
|
||||||
struct vmctx *vm_open(const char *name);
|
struct vmctx *vm_open(const char *name);
|
||||||
|
#define VMMAPI_OPEN_CREATE 0x01 /* create if the VM does not exist */
|
||||||
|
#define VMMAPI_OPEN_REINIT 0x02 /* reinitialize the VM if it exists */
|
||||||
|
struct vmctx *vm_openf(const char *name, int flags);
|
||||||
void vm_close(struct vmctx *ctx);
|
void vm_close(struct vmctx *ctx);
|
||||||
void vm_destroy(struct vmctx *ctx);
|
void vm_destroy(struct vmctx *ctx);
|
||||||
int vm_limit_rights(struct vmctx *ctx);
|
int vm_limit_rights(struct vmctx *ctx);
|
||||||
|
@ -89,16 +89,81 @@ ns_get_sector_size(struct nvme_namespace_data *nsdata)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
devlist(const struct cmd *f, int argc, char *argv[])
|
scan_namespace(int fd, int ctrlr, uint32_t nsid)
|
||||||
|
{
|
||||||
|
struct nvme_namespace_data nsdata;
|
||||||
|
char name[64];
|
||||||
|
uint8_t buf[7];
|
||||||
|
uint64_t size;
|
||||||
|
|
||||||
|
if (read_namespace_data(fd, nsid, &nsdata) != 0)
|
||||||
|
return;
|
||||||
|
if (nsdata.nsze == 0)
|
||||||
|
return;
|
||||||
|
snprintf(name, sizeof(name), "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
|
||||||
|
NVME_NS_PREFIX, nsid);
|
||||||
|
size = nsdata.nsze * (uint64_t)ns_get_sector_size(&nsdata);
|
||||||
|
if (opt.human) {
|
||||||
|
humanize_number(buf, sizeof(buf), size, "B",
|
||||||
|
HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
||||||
|
printf(" %10s (%s)\n", name, buf);
|
||||||
|
} else {
|
||||||
|
printf(" %10s (%juMB)\n", name, (uintmax_t)size / 1024 / 1024);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
scan_controller(int ctrlr)
|
||||||
{
|
{
|
||||||
struct nvme_controller_data cdata;
|
struct nvme_controller_data cdata;
|
||||||
struct nvme_namespace_data nsdata;
|
struct nvme_ns_list nslist;
|
||||||
char name[64];
|
char name[64];
|
||||||
uint8_t mn[64];
|
uint8_t mn[64];
|
||||||
uint8_t buf[7];
|
uint32_t nsid;
|
||||||
uint32_t i;
|
int fd, ret;
|
||||||
uint64_t size;
|
|
||||||
int ctrlr, fd, found, ret;
|
snprintf(name, sizeof(name), "%s%d", NVME_CTRLR_PREFIX, ctrlr);
|
||||||
|
|
||||||
|
ret = open_dev(name, &fd, 0, 0);
|
||||||
|
|
||||||
|
if (ret == EACCES) {
|
||||||
|
warnx("could not open "_PATH_DEV"%s\n", name);
|
||||||
|
return (false);
|
||||||
|
} else if (ret != 0)
|
||||||
|
return (false);
|
||||||
|
|
||||||
|
if (read_controller_data(fd, &cdata) != 0) {
|
||||||
|
close(fd);
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
nvme_strvis(mn, cdata.mn, sizeof(mn), NVME_MODEL_NUMBER_LENGTH);
|
||||||
|
printf("%6s: %s\n", name, mn);
|
||||||
|
|
||||||
|
nsid = 0;
|
||||||
|
for (;;) {
|
||||||
|
if (read_active_namespaces(fd, nsid, &nslist) != 0)
|
||||||
|
break;
|
||||||
|
for (u_int i = 0; i < nitems(nslist.ns); i++) {
|
||||||
|
nsid = nslist.ns[i];
|
||||||
|
if (nsid == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
scan_namespace(fd, ctrlr, nsid);
|
||||||
|
}
|
||||||
|
if (nsid == 0 || nsid >= NVME_GLOBAL_NAMESPACE_TAG - 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
devlist(const struct cmd *f, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int ctrlr, found;
|
||||||
|
|
||||||
if (arg_parse(argc, argv, f))
|
if (arg_parse(argc, argv, f))
|
||||||
return;
|
return;
|
||||||
@ -108,41 +173,8 @@ devlist(const struct cmd *f, int argc, char *argv[])
|
|||||||
|
|
||||||
while (ctrlr < NVME_MAX_UNIT) {
|
while (ctrlr < NVME_MAX_UNIT) {
|
||||||
ctrlr++;
|
ctrlr++;
|
||||||
sprintf(name, "%s%d", NVME_CTRLR_PREFIX, ctrlr);
|
if (scan_controller(ctrlr))
|
||||||
|
found++;
|
||||||
ret = open_dev(name, &fd, 0, 0);
|
|
||||||
|
|
||||||
if (ret == EACCES) {
|
|
||||||
warnx("could not open "_PATH_DEV"%s\n", name);
|
|
||||||
continue;
|
|
||||||
} else if (ret != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
found++;
|
|
||||||
if (read_controller_data(fd, &cdata))
|
|
||||||
continue;
|
|
||||||
nvme_strvis(mn, cdata.mn, sizeof(mn), NVME_MODEL_NUMBER_LENGTH);
|
|
||||||
printf("%6s: %s\n", name, mn);
|
|
||||||
|
|
||||||
for (i = 0; i < cdata.nn; i++) {
|
|
||||||
if (read_namespace_data(fd, i + 1, &nsdata))
|
|
||||||
continue;
|
|
||||||
if (nsdata.nsze == 0)
|
|
||||||
continue;
|
|
||||||
sprintf(name, "%s%d%s%d", NVME_CTRLR_PREFIX, ctrlr,
|
|
||||||
NVME_NS_PREFIX, i + 1);
|
|
||||||
size = nsdata.nsze * (uint64_t)ns_get_sector_size(&nsdata);
|
|
||||||
if (opt.human) {
|
|
||||||
humanize_number(buf, sizeof(buf), size, "B",
|
|
||||||
HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
|
|
||||||
printf(" %10s (%s)\n", name, buf);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
printf(" %10s (%juMB)\n", name, (uintmax_t)size / 1024 / 1024);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == 0) {
|
if (found == 0) {
|
||||||
|
@ -142,6 +142,30 @@ read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata)
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
read_active_namespaces(int fd, uint32_t nsid, struct nvme_ns_list *nslist)
|
||||||
|
{
|
||||||
|
struct nvme_pt_command pt;
|
||||||
|
|
||||||
|
memset(&pt, 0, sizeof(pt));
|
||||||
|
pt.cmd.opc = NVME_OPC_IDENTIFY;
|
||||||
|
pt.cmd.nsid = htole32(nsid);
|
||||||
|
pt.cmd.cdw10 = htole32(2);
|
||||||
|
pt.buf = nslist;
|
||||||
|
pt.len = sizeof(*nslist);
|
||||||
|
pt.is_read = 1;
|
||||||
|
|
||||||
|
if (ioctl(fd, NVME_PASSTHROUGH_CMD, &pt) < 0)
|
||||||
|
return (errno);
|
||||||
|
|
||||||
|
/* Convert data to host endian */
|
||||||
|
nvme_ns_list_swapbytes(nslist);
|
||||||
|
|
||||||
|
if (nvme_completion_is_error(&pt.cpl))
|
||||||
|
return (EIO);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
open_dev(const char *str, int *fd, int write, int exit_on_error)
|
open_dev(const char *str, int *fd, int write, int exit_on_error)
|
||||||
{
|
{
|
||||||
|
@ -81,6 +81,7 @@ int open_dev(const char *str, int *fd, int write, int exit_on_error);
|
|||||||
void get_nsid(int fd, char **ctrlr_str, uint32_t *nsid);
|
void get_nsid(int fd, char **ctrlr_str, uint32_t *nsid);
|
||||||
int read_controller_data(int fd, struct nvme_controller_data *cdata);
|
int read_controller_data(int fd, struct nvme_controller_data *cdata);
|
||||||
int read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata);
|
int read_namespace_data(int fd, uint32_t nsid, struct nvme_namespace_data *nsdata);
|
||||||
|
int read_active_namespaces(int fd, uint32_t nsid, struct nvme_ns_list *nslist);
|
||||||
void print_hex(void *data, uint32_t length);
|
void print_hex(void *data, uint32_t length);
|
||||||
void print_namespace(struct nvme_namespace_data *nsdata);
|
void print_namespace(struct nvme_namespace_data *nsdata);
|
||||||
void read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp,
|
void read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp,
|
||||||
|
@ -63,14 +63,14 @@ def build_response_packet(echo, ip, icmp, oip_ihl, special):
|
|||||||
if icmp.type in icmp_id_seq_types:
|
if icmp.type in icmp_id_seq_types:
|
||||||
pkt = ip / icmp / load
|
pkt = ip / icmp / load
|
||||||
else:
|
else:
|
||||||
ip.options = ""
|
del ip.options
|
||||||
pkt = ip / icmp / oip / oicmp / load
|
pkt = ip / icmp / oip / oicmp / load
|
||||||
return pkt
|
return pkt
|
||||||
|
|
||||||
|
|
||||||
def generate_ip_options(opts):
|
def generate_ip_options(opts):
|
||||||
if not opts:
|
if not opts:
|
||||||
return ""
|
return []
|
||||||
|
|
||||||
routers = [
|
routers = [
|
||||||
"192.0.2.10",
|
"192.0.2.10",
|
||||||
@ -85,11 +85,11 @@ def generate_ip_options(opts):
|
|||||||
]
|
]
|
||||||
routers_zero = [0, 0, 0, 0, 0, 0, 0, 0, 0]
|
routers_zero = [0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||||
if opts == "EOL":
|
if opts == "EOL":
|
||||||
options = sc.IPOption(b"\x00")
|
options = sc.IPOption_EOL()
|
||||||
elif opts == "NOP":
|
elif opts == "NOP":
|
||||||
options = sc.IPOption(b"\x01")
|
options = sc.IPOption_NOP()
|
||||||
elif opts == "NOP-40":
|
elif opts == "NOP-40":
|
||||||
options = sc.IPOption(b"\x01" * 40)
|
options = sc.IPOption_NOP() * 40
|
||||||
elif opts == "RR":
|
elif opts == "RR":
|
||||||
ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
|
ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
|
||||||
options = sc.IPOption_RR(pointer=40, routers=routers)
|
options = sc.IPOption_RR(pointer=40, routers=routers)
|
||||||
@ -116,9 +116,9 @@ def generate_ip_options(opts):
|
|||||||
options = b"\x9f"
|
options = b"\x9f"
|
||||||
elif opts == "unk-40":
|
elif opts == "unk-40":
|
||||||
ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
|
ToolsHelper.set_sysctl("net.inet.ip.process_options", 0)
|
||||||
options = sc.IPOption(b"\x9f" * 40)
|
options = b"\x9f" * 40
|
||||||
else:
|
else:
|
||||||
options = ""
|
options = []
|
||||||
return options
|
return options
|
||||||
|
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ def pinger(
|
|||||||
icmp_code: sc.scapy.fields.MultiEnumField,
|
icmp_code: sc.scapy.fields.MultiEnumField,
|
||||||
# IP arguments
|
# IP arguments
|
||||||
ihl: Optional[sc.scapy.fields.BitField] = None,
|
ihl: Optional[sc.scapy.fields.BitField] = None,
|
||||||
flags: Optional[sc.scapy.fields.FlagsField] = None,
|
flags: Optional[sc.scapy.fields.FlagsField] = 0,
|
||||||
opts: Optional[str] = None,
|
opts: Optional[str] = None,
|
||||||
oip_ihl: Optional[sc.scapy.fields.BitField] = None,
|
oip_ihl: Optional[sc.scapy.fields.BitField] = None,
|
||||||
special: Optional[str] = None,
|
special: Optional[str] = None,
|
||||||
@ -169,7 +169,7 @@ def pinger(
|
|||||||
|
|
||||||
:keyword ihl: Internet Header Length, defaults to None
|
:keyword ihl: Internet Header Length, defaults to None
|
||||||
:type ihl: class:`scapy.fields.BitField`, optional
|
:type ihl: class:`scapy.fields.BitField`, optional
|
||||||
:keyword flags: IP flags - one of `DF`, `MF` or `evil`, defaults to None
|
:keyword flags: IP flags - one of `DF`, `MF` or `evil`, defaults to 0
|
||||||
:type flags: class:`scapy.fields.FlagsField`, optional
|
:type flags: class:`scapy.fields.FlagsField`, optional
|
||||||
:keyword opts: Include IP options - one of `EOL`, `NOP`, `NOP-40`, `unk`,
|
:keyword opts: Include IP options - one of `EOL`, `NOP`, `NOP-40`, `unk`,
|
||||||
`unk-40`, `RR`, `RR-same`, `RR-trunc`, `LSRR`, `LSRR-trunc`, `SSRR` or
|
`unk-40`, `RR`, `RR-same`, `RR-trunc`, `LSRR`, `LSRR-trunc`, `SSRR` or
|
||||||
@ -270,15 +270,15 @@ def pinger(
|
|||||||
def redact(output):
|
def redact(output):
|
||||||
"""Redact some elements of ping's output"""
|
"""Redact some elements of ping's output"""
|
||||||
pattern_replacements = [
|
pattern_replacements = [
|
||||||
("localhost \([0-9]{1,3}(\.[0-9]{1,3}){3}\)", "localhost"),
|
(r"localhost \([0-9]{1,3}(\.[0-9]{1,3}){3}\)", "localhost"),
|
||||||
("from [0-9]{1,3}(\.[0-9]{1,3}){3}", "from"),
|
(r"from [0-9]{1,3}(\.[0-9]{1,3}){3}", "from"),
|
||||||
("hlim=[0-9]*", "hlim="),
|
("hlim=[0-9]*", "hlim="),
|
||||||
("ttl=[0-9]*", "ttl="),
|
("ttl=[0-9]*", "ttl="),
|
||||||
("time=[0-9.-]*", "time="),
|
("time=[0-9.-]*", "time="),
|
||||||
("cp: .*", "cp: xx xx xx xx xx xx xx xx"),
|
("cp: .*", "cp: xx xx xx xx xx xx xx xx"),
|
||||||
("dp: .*", "dp: xx xx xx xx xx xx xx xx"),
|
("dp: .*", "dp: xx xx xx xx xx xx xx xx"),
|
||||||
("\(-[0-9\.]+[0-9]+ ms\)", "(- ms)"),
|
(r"\(-[0-9\.]+[0-9]+ ms\)", "(- ms)"),
|
||||||
("[0-9\.]+/[0-9.]+", "/"),
|
(r"[0-9\.]+/[0-9.]+", "/"),
|
||||||
]
|
]
|
||||||
for pattern, repl in pattern_replacements:
|
for pattern, repl in pattern_replacements:
|
||||||
output = re.sub(pattern, repl, output)
|
output = re.sub(pattern, repl, output)
|
||||||
@ -724,6 +724,7 @@ PING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
|
|||||||
|
|
||||||
@pytest.mark.parametrize("expected", testdata)
|
@pytest.mark.parametrize("expected", testdata)
|
||||||
@pytest.mark.require_user("root")
|
@pytest.mark.require_user("root")
|
||||||
|
@pytest.mark.require_user("unprivileged")
|
||||||
def test_ping(self, expected):
|
def test_ping(self, expected):
|
||||||
"""Test ping"""
|
"""Test ping"""
|
||||||
ping = subprocess.run(
|
ping = subprocess.run(
|
||||||
@ -753,6 +754,7 @@ PING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
|
|||||||
|
|
||||||
@pytest.mark.parametrize("expected", ping46_testdata)
|
@pytest.mark.parametrize("expected", ping46_testdata)
|
||||||
@pytest.mark.require_user("root")
|
@pytest.mark.require_user("root")
|
||||||
|
@pytest.mark.require_user("unprivileged")
|
||||||
def test_ping_46(self, expected):
|
def test_ping_46(self, expected):
|
||||||
"""Test ping -4/ping -6"""
|
"""Test ping -4/ping -6"""
|
||||||
for version in [4, 6]:
|
for version in [4, 6]:
|
||||||
|
@ -465,7 +465,9 @@ vmm_handler(module_t mod, int what, void *arg)
|
|||||||
switch (what) {
|
switch (what) {
|
||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
if (vmm_is_hw_supported()) {
|
if (vmm_is_hw_supported()) {
|
||||||
vmmdev_init();
|
error = vmmdev_init();
|
||||||
|
if (error != 0)
|
||||||
|
break;
|
||||||
error = vmm_init();
|
error = vmm_init();
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
vmm_initialized = 1;
|
vmm_initialized = 1;
|
||||||
|
@ -343,6 +343,11 @@ static int
|
|||||||
as3722_detach(device_t dev)
|
as3722_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct as3722_softc *sc;
|
struct as3722_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
if (sc->irq_h != NULL)
|
if (sc->irq_h != NULL)
|
||||||
@ -351,7 +356,7 @@ as3722_detach(device_t dev)
|
|||||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static phandle_t
|
static phandle_t
|
||||||
|
@ -1393,6 +1393,11 @@ static int
|
|||||||
dc_detach(device_t dev)
|
dc_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct dc_softc *sc;
|
struct dc_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
|
|
||||||
@ -1412,7 +1417,7 @@ dc_detach(device_t dev)
|
|||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t tegra_dc_methods[] = {
|
static device_method_t tegra_dc_methods[] = {
|
||||||
|
@ -1272,6 +1272,12 @@ static int
|
|||||||
hdmi_detach(device_t dev)
|
hdmi_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct hdmi_softc *sc;
|
struct hdmi_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
|
|
||||||
TEGRA_DRM_DEREGISTER_CLIENT(device_get_parent(sc->dev), sc->dev);
|
TEGRA_DRM_DEREGISTER_CLIENT(device_get_parent(sc->dev), sc->dev);
|
||||||
@ -1294,7 +1300,7 @@ hdmi_detach(device_t dev)
|
|||||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
|
||||||
if (sc->mem_res != NULL)
|
if (sc->mem_res != NULL)
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t tegra_hdmi_methods[] = {
|
static device_method_t tegra_hdmi_methods[] = {
|
||||||
|
@ -586,6 +586,11 @@ static int
|
|||||||
host1x_detach(device_t dev)
|
host1x_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct host1x_softc *sc;
|
struct host1x_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
|
|
||||||
@ -608,7 +613,7 @@ host1x_detach(device_t dev)
|
|||||||
if (sc->mem_res != NULL)
|
if (sc->mem_res != NULL)
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t host1x_methods[] = {
|
static device_method_t host1x_methods[] = {
|
||||||
|
@ -166,13 +166,18 @@ static int
|
|||||||
tegra_abpmisc_detach(device_t dev)
|
tegra_abpmisc_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct tegra_abpmisc_softc *sc;
|
struct tegra_abpmisc_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
if (sc->abp_misc_res != NULL)
|
if (sc->abp_misc_res != NULL)
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->abp_misc_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->abp_misc_res);
|
||||||
if (sc->strap_opt_res != NULL)
|
if (sc->strap_opt_res != NULL)
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 1, sc->strap_opt_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 1, sc->strap_opt_res);
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t tegra_abpmisc_methods[] = {
|
static device_method_t tegra_abpmisc_methods[] = {
|
||||||
|
@ -499,6 +499,11 @@ static int
|
|||||||
tegra_efuse_detach(device_t dev)
|
tegra_efuse_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct tegra_efuse_softc *sc;
|
struct tegra_efuse_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
dev_sc = NULL;
|
dev_sc = NULL;
|
||||||
@ -509,7 +514,7 @@ tegra_efuse_detach(device_t dev)
|
|||||||
if (sc->mem_res != NULL)
|
if (sc->mem_res != NULL)
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t tegra_efuse_methods[] = {
|
static device_method_t tegra_efuse_methods[] = {
|
||||||
|
@ -740,6 +740,11 @@ static int
|
|||||||
tegra_i2c_detach(device_t dev)
|
tegra_i2c_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct tegra_i2c_softc *sc;
|
struct tegra_i2c_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
tegra_i2c_hw_init(sc);
|
tegra_i2c_hw_init(sc);
|
||||||
@ -753,7 +758,7 @@ tegra_i2c_detach(device_t dev)
|
|||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
if (sc->iicbus)
|
if (sc->iicbus)
|
||||||
device_delete_child(dev, sc->iicbus);
|
device_delete_child(dev, sc->iicbus);
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static phandle_t
|
static phandle_t
|
||||||
|
@ -280,6 +280,11 @@ static int
|
|||||||
tegra_mc_detach(device_t dev)
|
tegra_mc_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct tegra_mc_softc *sc;
|
struct tegra_mc_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
if (sc->irq_h != NULL)
|
if (sc->irq_h != NULL)
|
||||||
@ -290,7 +295,7 @@ tegra_mc_detach(device_t dev)
|
|||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
||||||
|
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t tegra_mc_methods[] = {
|
static device_method_t tegra_mc_methods[] = {
|
||||||
|
@ -266,6 +266,11 @@ static int
|
|||||||
tegra_rtc_detach(device_t dev)
|
tegra_rtc_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct tegra_rtc_softc *sc;
|
struct tegra_rtc_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
if (sc->irq_h != NULL)
|
if (sc->irq_h != NULL)
|
||||||
@ -276,7 +281,7 @@ tegra_rtc_detach(device_t dev)
|
|||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->mem_res);
|
||||||
|
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t tegra_rtc_methods[] = {
|
static device_method_t tegra_rtc_methods[] = {
|
||||||
|
@ -915,6 +915,11 @@ static int
|
|||||||
ti_adc_detach(device_t dev)
|
ti_adc_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct ti_adc_softc *sc;
|
struct ti_adc_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
|
|
||||||
@ -938,7 +943,7 @@ ti_adc_detach(device_t dev)
|
|||||||
if (sc->sc_mem_res)
|
if (sc->sc_mem_res)
|
||||||
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
|
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->sc_mem_res);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t ti_adc_methods[] = {
|
static device_method_t ti_adc_methods[] = {
|
||||||
|
@ -450,6 +450,11 @@ static int
|
|||||||
max77620_detach(device_t dev)
|
max77620_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct max77620_softc *sc;
|
struct max77620_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
if (sc->irq_h != NULL)
|
if (sc->irq_h != NULL)
|
||||||
@ -458,7 +463,7 @@ max77620_detach(device_t dev)
|
|||||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq_res);
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static phandle_t
|
static phandle_t
|
||||||
|
@ -366,11 +366,16 @@ static int
|
|||||||
max77620_rtc_detach(device_t dev)
|
max77620_rtc_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct max77620_softc *sc;
|
struct max77620_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -362,7 +362,9 @@ vmm_handler(module_t mod, int what, void *arg)
|
|||||||
switch (what) {
|
switch (what) {
|
||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
/* TODO: if (vmm_is_hw_supported()) { */
|
/* TODO: if (vmm_is_hw_supported()) { */
|
||||||
vmmdev_init();
|
error = vmmdev_init();
|
||||||
|
if (error != 0)
|
||||||
|
break;
|
||||||
error = vmm_init();
|
error = vmm_init();
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
vmm_initialized = true;
|
vmm_initialized = true;
|
||||||
|
@ -38,7 +38,6 @@ ACPI_MODULE_NAME("CONTAINER")
|
|||||||
|
|
||||||
static int acpi_syscont_probe(device_t);
|
static int acpi_syscont_probe(device_t);
|
||||||
static int acpi_syscont_attach(device_t);
|
static int acpi_syscont_attach(device_t);
|
||||||
static int acpi_syscont_detach(device_t);
|
|
||||||
static int acpi_syscont_alloc_msi(device_t, device_t,
|
static int acpi_syscont_alloc_msi(device_t, device_t,
|
||||||
int count, int maxcount, int *irqs);
|
int count, int maxcount, int *irqs);
|
||||||
static int acpi_syscont_release_msi(device_t bus, device_t dev,
|
static int acpi_syscont_release_msi(device_t bus, device_t dev,
|
||||||
@ -54,7 +53,7 @@ static device_method_t acpi_syscont_methods[] = {
|
|||||||
/* Device interface */
|
/* Device interface */
|
||||||
DEVMETHOD(device_probe, acpi_syscont_probe),
|
DEVMETHOD(device_probe, acpi_syscont_probe),
|
||||||
DEVMETHOD(device_attach, acpi_syscont_attach),
|
DEVMETHOD(device_attach, acpi_syscont_attach),
|
||||||
DEVMETHOD(device_detach, acpi_syscont_detach),
|
DEVMETHOD(device_detach, bus_generic_detach),
|
||||||
|
|
||||||
/* Bus interface */
|
/* Bus interface */
|
||||||
DEVMETHOD(bus_add_child, bus_generic_add_child),
|
DEVMETHOD(bus_add_child, bus_generic_add_child),
|
||||||
@ -108,13 +107,6 @@ acpi_syscont_attach(device_t dev)
|
|||||||
return (bus_generic_attach(dev));
|
return (bus_generic_attach(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
acpi_syscont_detach(device_t dev)
|
|
||||||
{
|
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
acpi_syscont_alloc_msi(device_t bus, device_t dev, int count, int maxcount,
|
acpi_syscont_alloc_msi(device_t bus, device_t dev, int count, int maxcount,
|
||||||
int *irqs)
|
int *irqs)
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
|
|
||||||
static int adb_bus_probe(device_t dev);
|
static int adb_bus_probe(device_t dev);
|
||||||
static int adb_bus_attach(device_t dev);
|
static int adb_bus_attach(device_t dev);
|
||||||
static int adb_bus_detach(device_t dev);
|
|
||||||
static void adb_bus_enumerate(void *xdev);
|
static void adb_bus_enumerate(void *xdev);
|
||||||
static void adb_probe_nomatch(device_t dev, device_t child);
|
static void adb_probe_nomatch(device_t dev, device_t child);
|
||||||
static int adb_print_child(device_t dev, device_t child);
|
static int adb_print_child(device_t dev, device_t child);
|
||||||
@ -57,7 +56,7 @@ static device_method_t adb_bus_methods[] = {
|
|||||||
/* Device interface */
|
/* Device interface */
|
||||||
DEVMETHOD(device_probe, adb_bus_probe),
|
DEVMETHOD(device_probe, adb_bus_probe),
|
||||||
DEVMETHOD(device_attach, adb_bus_attach),
|
DEVMETHOD(device_attach, adb_bus_attach),
|
||||||
DEVMETHOD(device_detach, adb_bus_detach),
|
DEVMETHOD(device_detach, bus_generic_detach),
|
||||||
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
||||||
DEVMETHOD(device_suspend, bus_generic_suspend),
|
DEVMETHOD(device_suspend, bus_generic_suspend),
|
||||||
DEVMETHOD(device_resume, bus_generic_resume),
|
DEVMETHOD(device_resume, bus_generic_resume),
|
||||||
@ -188,11 +187,6 @@ adb_bus_enumerate(void *xdev)
|
|||||||
config_intrhook_disestablish(&sc->enum_hook);
|
config_intrhook_disestablish(&sc->enum_hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int adb_bus_detach(device_t dev)
|
|
||||||
{
|
|
||||||
return (bus_generic_detach(dev));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
adb_probe_nomatch(device_t dev, device_t child)
|
adb_probe_nomatch(device_t dev, device_t child)
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,9 @@ dpaa2_mc_detach(device_t dev)
|
|||||||
struct dpaa2_devinfo *dinfo = NULL;
|
struct dpaa2_devinfo *dinfo = NULL;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
bus_generic_detach(dev);
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
if (sc->rcdev)
|
if (sc->rcdev)
|
||||||
@ -292,10 +294,6 @@ dpaa2_mc_detach(device_t dev)
|
|||||||
if (dinfo)
|
if (dinfo)
|
||||||
free(dinfo, M_DPAA2_MC);
|
free(dinfo, M_DPAA2_MC);
|
||||||
|
|
||||||
error = bus_generic_detach(dev);
|
|
||||||
if (error != 0)
|
|
||||||
return (error);
|
|
||||||
|
|
||||||
return (device_delete_children(dev));
|
return (device_delete_children(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +309,7 @@ static int
|
|||||||
dwwdt_detach(device_t dev)
|
dwwdt_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct dwwdt_softc *sc = device_get_softc(dev);
|
struct dwwdt_softc *sc = device_get_softc(dev);
|
||||||
|
int error;
|
||||||
|
|
||||||
if (dwwdt_started(sc)) {
|
if (dwwdt_started(sc)) {
|
||||||
/*
|
/*
|
||||||
@ -318,6 +319,10 @@ dwwdt_detach(device_t dev)
|
|||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
EVENTHANDLER_DEREGISTER(watchdog_list, sc->sc_evtag);
|
EVENTHANDLER_DEREGISTER(watchdog_list, sc->sc_evtag);
|
||||||
sc->sc_evtag = NULL;
|
sc->sc_evtag = NULL;
|
||||||
|
|
||||||
@ -337,7 +342,7 @@ dwwdt_detach(device_t dev)
|
|||||||
sc->sc_mem_res);
|
sc->sc_mem_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -4030,6 +4030,10 @@ ena_detach(device_t pdev)
|
|||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rc = bus_generic_detach(pdev);
|
||||||
|
if (rc != 0)
|
||||||
|
return (rc);
|
||||||
|
|
||||||
ether_ifdetach(adapter->ifp);
|
ether_ifdetach(adapter->ifp);
|
||||||
|
|
||||||
ifmedia_removeall(&adapter->media);
|
ifmedia_removeall(&adapter->media);
|
||||||
@ -4096,7 +4100,7 @@ ena_detach(device_t pdev)
|
|||||||
|
|
||||||
free(ena_dev, M_DEVBUF);
|
free(ena_dev, M_DEVBUF);
|
||||||
|
|
||||||
return (bus_generic_detach(pdev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -189,12 +189,17 @@ int
|
|||||||
simplebus_detach(device_t dev)
|
simplebus_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct simplebus_softc *sc;
|
struct simplebus_softc *sc;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = bus_generic_detach(dev);
|
||||||
|
if (rv != 0)
|
||||||
|
return (rv);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
if (sc->ranges != NULL)
|
if (sc->ranges != NULL)
|
||||||
free(sc->ranges, M_DEVBUF);
|
free(sc->ranges, M_DEVBUF);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -213,7 +213,6 @@ static device_method_t gpiomdio_methods[] = {
|
|||||||
/* Device interface */
|
/* Device interface */
|
||||||
DEVMETHOD(device_probe, gpiomdio_probe),
|
DEVMETHOD(device_probe, gpiomdio_probe),
|
||||||
DEVMETHOD(device_attach, gpiomdio_attach),
|
DEVMETHOD(device_attach, gpiomdio_attach),
|
||||||
DEVMETHOD(device_detach, bus_generic_detach),
|
|
||||||
|
|
||||||
/* MDIO interface */
|
/* MDIO interface */
|
||||||
DEVMETHOD(miibus_readreg, gpiomdio_readreg),
|
DEVMETHOD(miibus_readreg, gpiomdio_readreg),
|
||||||
|
@ -820,6 +820,11 @@ gve_detach(device_t dev)
|
|||||||
{
|
{
|
||||||
struct gve_priv *priv = device_get_softc(dev);
|
struct gve_priv *priv = device_get_softc(dev);
|
||||||
if_t ifp = priv->ifp;
|
if_t ifp = priv->ifp;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
ether_ifdetach(ifp);
|
ether_ifdetach(ifp);
|
||||||
|
|
||||||
@ -836,7 +841,7 @@ gve_detach(device_t dev)
|
|||||||
taskqueue_free(priv->service_tq);
|
taskqueue_free(priv->service_tq);
|
||||||
|
|
||||||
if_free(ifp);
|
if_free(ifp);
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t gve_methods[] = {
|
static device_method_t gve_methods[] = {
|
||||||
|
@ -637,8 +637,6 @@ hifn_detach(device_t dev)
|
|||||||
|
|
||||||
crypto_unregister_all(sc->sc_cid);
|
crypto_unregister_all(sc->sc_cid);
|
||||||
|
|
||||||
bus_generic_detach(dev); /*XXX should be no children, right? */
|
|
||||||
|
|
||||||
bus_teardown_intr(dev, sc->sc_irq, sc->sc_intrhand);
|
bus_teardown_intr(dev, sc->sc_irq, sc->sc_intrhand);
|
||||||
/* XXX don't store rid */
|
/* XXX don't store rid */
|
||||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq);
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq);
|
||||||
|
@ -226,11 +226,16 @@ static int
|
|||||||
act8846_detach(device_t dev)
|
act8846_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct act8846_softc *sc;
|
struct act8846_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
LOCK_DESTROY(sc);
|
LOCK_DESTROY(sc);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static device_method_t act8846_methods[] = {
|
static device_method_t act8846_methods[] = {
|
||||||
|
@ -1879,6 +1879,11 @@ static int
|
|||||||
mana_gd_detach(device_t dev)
|
mana_gd_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct gdma_context *gc = device_get_softc(dev);
|
struct gdma_context *gc = device_get_softc(dev);
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
mana_remove(&gc->mana);
|
mana_remove(&gc->mana);
|
||||||
|
|
||||||
@ -1890,7 +1895,7 @@ mana_gd_detach(device_t dev)
|
|||||||
|
|
||||||
pci_disable_busmaster(dev);
|
pci_disable_busmaster(dev);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,14 +59,6 @@ mdio_attach(device_t dev)
|
|||||||
return (bus_generic_attach(dev));
|
return (bus_generic_attach(dev));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
mdio_detach(device_t dev)
|
|
||||||
{
|
|
||||||
|
|
||||||
bus_generic_detach(dev);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mdio_readreg(device_t dev, int phy, int reg)
|
mdio_readreg(device_t dev, int phy, int reg)
|
||||||
{
|
{
|
||||||
@ -108,7 +100,7 @@ static device_method_t mdio_methods[] = {
|
|||||||
DEVMETHOD(device_identify, mdio_identify),
|
DEVMETHOD(device_identify, mdio_identify),
|
||||||
DEVMETHOD(device_probe, mdio_probe),
|
DEVMETHOD(device_probe, mdio_probe),
|
||||||
DEVMETHOD(device_attach, mdio_attach),
|
DEVMETHOD(device_attach, mdio_attach),
|
||||||
DEVMETHOD(device_detach, mdio_detach),
|
DEVMETHOD(device_detach, bus_generic_detach),
|
||||||
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
||||||
|
|
||||||
/* bus interface */
|
/* bus interface */
|
||||||
|
@ -376,10 +376,10 @@ nvmf_scan_active_nslist(struct nvmf_softc *sc, struct nvme_ns_list *nslist,
|
|||||||
|
|
||||||
MPASS(nsid == nslist->ns[nitems(nslist->ns) - 1] && nsid != 0);
|
MPASS(nsid == nslist->ns[nitems(nslist->ns) - 1] && nsid != 0);
|
||||||
|
|
||||||
if (nsid >= 0xfffffffd)
|
if (nsid >= NVME_GLOBAL_NAMESPACE_TAG - 1)
|
||||||
*nsidp = 0;
|
*nsidp = 0;
|
||||||
else
|
else
|
||||||
*nsidp = nsid + 1;
|
*nsidp = nsid;
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,6 @@ safe_detach(device_t dev)
|
|||||||
mtx_destroy(&sc->sc_ringmtx);
|
mtx_destroy(&sc->sc_ringmtx);
|
||||||
safe_dma_free(sc, &sc->sc_ringalloc);
|
safe_dma_free(sc, &sc->sc_ringalloc);
|
||||||
|
|
||||||
bus_generic_detach(dev);
|
|
||||||
bus_teardown_intr(dev, sc->sc_irq, sc->sc_ih);
|
bus_teardown_intr(dev, sc->sc_irq, sc->sc_ih);
|
||||||
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq);
|
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->sc_irq);
|
||||||
|
|
||||||
|
@ -138,7 +138,6 @@ static device_method_t sfp_fdt_methods[] = {
|
|||||||
/* Device interface */
|
/* Device interface */
|
||||||
DEVMETHOD(device_probe, sfp_fdt_probe),
|
DEVMETHOD(device_probe, sfp_fdt_probe),
|
||||||
DEVMETHOD(device_attach, sfp_fdt_attach),
|
DEVMETHOD(device_attach, sfp_fdt_attach),
|
||||||
DEVMETHOD(device_detach, bus_generic_detach),
|
|
||||||
|
|
||||||
/* SFF */
|
/* SFF */
|
||||||
DEVMETHOD(sff_get_i2c_bus, sfp_fdt_get_i2c_bus),
|
DEVMETHOD(sff_get_i2c_bus, sfp_fdt_get_i2c_bus),
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
|
#include <sys/fcntl.h>
|
||||||
#include <sys/ioccom.h>
|
#include <sys/ioccom.h>
|
||||||
#include <sys/jail.h>
|
#include <sys/jail.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
@ -917,11 +918,88 @@ SYSCTL_PROC(_hw_vmm, OID_AUTO, create,
|
|||||||
NULL, 0, sysctl_vmm_create, "A",
|
NULL, 0, sysctl_vmm_create, "A",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
void
|
static int
|
||||||
|
vmmctl_open(struct cdev *cdev, int flags, int fmt, struct thread *td)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = vmm_priv_check(td->td_ucred);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
if ((flags & FWRITE) == 0)
|
||||||
|
return (EPERM);
|
||||||
|
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
vmmctl_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
|
||||||
|
struct thread *td)
|
||||||
|
{
|
||||||
|
int error;
|
||||||
|
|
||||||
|
switch (cmd) {
|
||||||
|
case VMMCTL_VM_CREATE: {
|
||||||
|
struct vmmctl_vm_create *vmc;
|
||||||
|
|
||||||
|
vmc = (struct vmmctl_vm_create *)data;
|
||||||
|
vmc->name[VM_MAX_NAMELEN] = '\0';
|
||||||
|
for (size_t i = 0; i < nitems(vmc->reserved); i++) {
|
||||||
|
if (vmc->reserved[i] != 0) {
|
||||||
|
error = EINVAL;
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error = vmmdev_create(vmc->name, td->td_ucred);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case VMMCTL_VM_DESTROY: {
|
||||||
|
struct vmmctl_vm_destroy *vmd;
|
||||||
|
|
||||||
|
vmd = (struct vmmctl_vm_destroy *)data;
|
||||||
|
vmd->name[VM_MAX_NAMELEN] = '\0';
|
||||||
|
for (size_t i = 0; i < nitems(vmd->reserved); i++) {
|
||||||
|
if (vmd->reserved[i] != 0) {
|
||||||
|
error = EINVAL;
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error = vmmdev_lookup_and_destroy(vmd->name, td->td_ucred);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
error = ENOTTY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct cdevsw vmmctlsw = {
|
||||||
|
.d_name = "vmmctl",
|
||||||
|
.d_version = D_VERSION,
|
||||||
|
.d_open = vmmctl_open,
|
||||||
|
.d_ioctl = vmmctl_ioctl,
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
vmmdev_init(void)
|
vmmdev_init(void)
|
||||||
{
|
{
|
||||||
|
struct cdev *cdev;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = make_dev_p(MAKEDEV_CHECKNAME, &cdev, &vmmctlsw, NULL,
|
||||||
|
UID_ROOT, GID_WHEEL, 0600, "vmmctl");
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
|
||||||
pr_allow_flag = prison_add_allow(NULL, "vmm", NULL,
|
pr_allow_flag = prison_add_allow(NULL, "vmm", NULL,
|
||||||
"Allow use of vmm in a jail.");
|
"Allow use of vmm in a jail.");
|
||||||
|
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -18,7 +18,7 @@ struct thread;
|
|||||||
struct vm;
|
struct vm;
|
||||||
struct vcpu;
|
struct vcpu;
|
||||||
|
|
||||||
void vmmdev_init(void);
|
int vmmdev_init(void);
|
||||||
int vmmdev_cleanup(void);
|
int vmmdev_cleanup(void);
|
||||||
int vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd,
|
int vmmdev_machdep_ioctl(struct vm *vm, struct vcpu *vcpu, u_long cmd,
|
||||||
caddr_t data, int fflag, struct thread *td);
|
caddr_t data, int fflag, struct thread *td);
|
||||||
@ -54,4 +54,17 @@ extern const size_t vmmdev_machdep_ioctl_count;
|
|||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
struct vmmctl_vm_create {
|
||||||
|
char name[VM_MAX_NAMELEN + 1];
|
||||||
|
int reserved[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct vmmctl_vm_destroy {
|
||||||
|
char name[VM_MAX_NAMELEN + 1];
|
||||||
|
int reserved[16];
|
||||||
|
};
|
||||||
|
|
||||||
|
#define VMMCTL_VM_CREATE _IOWR('V', 0, struct vmmctl_vm_create)
|
||||||
|
#define VMMCTL_VM_DESTROY _IOWR('V', 1, struct vmmctl_vm_destroy)
|
||||||
|
|
||||||
#endif /* _DEV_VMM_DEV_H_ */
|
#endif /* _DEV_VMM_DEV_H_ */
|
||||||
|
@ -673,12 +673,17 @@ static int
|
|||||||
fsl_pcib_detach(device_t dev)
|
fsl_pcib_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct fsl_pcib_softc *sc;
|
struct fsl_pcib_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
|
|
||||||
mtx_destroy(&sc->sc_cfg_mtx);
|
mtx_destroy(&sc->sc_cfg_mtx);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -259,6 +259,11 @@ cuda_attach(device_t dev)
|
|||||||
|
|
||||||
static int cuda_detach(device_t dev) {
|
static int cuda_detach(device_t dev) {
|
||||||
struct cuda_softc *sc;
|
struct cuda_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
|
|
||||||
@ -267,7 +272,7 @@ static int cuda_detach(device_t dev) {
|
|||||||
bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_memrid, sc->sc_memr);
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_memrid, sc->sc_memr);
|
||||||
mtx_destroy(&sc->sc_mutex);
|
mtx_destroy(&sc->sc_mutex);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t
|
static uint8_t
|
||||||
|
@ -524,6 +524,11 @@ static int
|
|||||||
pmu_detach(device_t dev)
|
pmu_detach(device_t dev)
|
||||||
{
|
{
|
||||||
struct pmu_softc *sc;
|
struct pmu_softc *sc;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
error = bus_generic_detach(dev);
|
||||||
|
if (error != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
sc = device_get_softc(dev);
|
sc = device_get_softc(dev);
|
||||||
|
|
||||||
@ -535,7 +540,7 @@ pmu_detach(device_t dev)
|
|||||||
bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_memrid, sc->sc_memr);
|
bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_memrid, sc->sc_memr);
|
||||||
mtx_destroy(&sc->sc_mutex);
|
mtx_destroy(&sc->sc_mutex);
|
||||||
|
|
||||||
return (bus_generic_detach(dev));
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t
|
static uint8_t
|
||||||
|
@ -102,12 +102,11 @@ enum vm_reg_name {
|
|||||||
#define VM_INTINFO_HWEXCEPTION (3 << 8)
|
#define VM_INTINFO_HWEXCEPTION (3 << 8)
|
||||||
#define VM_INTINFO_SWINTR (4 << 8)
|
#define VM_INTINFO_SWINTR (4 << 8)
|
||||||
|
|
||||||
|
#define VM_MAX_NAMELEN 32
|
||||||
#define VM_MAX_SUFFIXLEN 15
|
#define VM_MAX_SUFFIXLEN 15
|
||||||
|
|
||||||
#ifdef _KERNEL
|
#ifdef _KERNEL
|
||||||
|
|
||||||
#define VM_MAX_NAMELEN 32
|
|
||||||
|
|
||||||
struct vm;
|
struct vm;
|
||||||
struct vm_exception;
|
struct vm_exception;
|
||||||
struct vm_exit;
|
struct vm_exit;
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#ifndef _VMM_DEV_H_
|
#ifndef _VMM_DEV_H_
|
||||||
#define _VMM_DEV_H_
|
#define _VMM_DEV_H_
|
||||||
|
|
||||||
|
#include <machine/vmm.h>
|
||||||
|
|
||||||
struct vm_memmap {
|
struct vm_memmap {
|
||||||
vm_paddr_t gpa;
|
vm_paddr_t gpa;
|
||||||
int segid; /* memory segment */
|
int segid; /* memory segment */
|
||||||
|
@ -255,7 +255,9 @@ vmm_handler(module_t mod, int what, void *arg)
|
|||||||
switch (what) {
|
switch (what) {
|
||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
/* TODO: check if has_hyp here? */
|
/* TODO: check if has_hyp here? */
|
||||||
vmmdev_init();
|
error = vmmdev_init();
|
||||||
|
if (error != 0)
|
||||||
|
break;
|
||||||
error = vmm_init();
|
error = vmm_init();
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
vmm_initialized = true;
|
vmm_initialized = true;
|
||||||
|
@ -30,11 +30,9 @@
|
|||||||
|
|
||||||
#include <machine/atomic.h>
|
#include <machine/atomic.h>
|
||||||
|
|
||||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#else
|
#if !defined(_KERNEL) && !defined(_STANDALONE)
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#define KASSERT(exp, msg) /* */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define REFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0)
|
#define REFCOUNT_SATURATED(val) (((val) & (1U << 31)) != 0)
|
||||||
|
@ -47,7 +47,14 @@ find_device() {
|
|||||||
ctladm port -o on -p 0 >/dev/null
|
ctladm port -o on -p 0 >/dev/null
|
||||||
HEXLUN=`printf %x $LUN`
|
HEXLUN=`printf %x $LUN`
|
||||||
while true; do
|
while true; do
|
||||||
dev=`camcontrol devlist | awk -v lun=$HEXLUN '/FREEBSD CTL/ && $9==lun {split($10, fields, /[,]/); print fields[1];}' | sed 's:[()]::'`
|
dev=`camcontrol devlist | awk -v lun=$HEXLUN '
|
||||||
|
/FREEBSD CTL.*,pass/ && $9==lun {
|
||||||
|
split($10, fields, /[,]/); print fields[1];
|
||||||
|
}
|
||||||
|
/FREEBSD CTL.*\(pass/ && $9==lun {
|
||||||
|
split($10, fields, /[,]/); print fields[2];
|
||||||
|
}
|
||||||
|
' | sed 's:[()]::'`
|
||||||
if [ -z "$dev" -o ! -c /dev/$dev ]; then
|
if [ -z "$dev" -o ! -c /dev/$dev ]; then
|
||||||
retries=$(( $retries - 1 ))
|
retries=$(( $retries - 1 ))
|
||||||
if [ $retries -eq 0 ]; then
|
if [ $retries -eq 0 ]; then
|
||||||
|
@ -43,6 +43,14 @@ err()
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanup()
|
||||||
|
{
|
||||||
|
rc=$?
|
||||||
|
rm -fr "$GITARC_TMPDIR"
|
||||||
|
trap - EXIT
|
||||||
|
exit $rc
|
||||||
|
}
|
||||||
|
|
||||||
err_usage()
|
err_usage()
|
||||||
{
|
{
|
||||||
cat >&2 <<__EOF__
|
cat >&2 <<__EOF__
|
||||||
@ -101,10 +109,10 @@ Config Variables:
|
|||||||
Defaults to false.
|
Defaults to false.
|
||||||
|
|
||||||
arc.list [bool] -- Always use "list mode" (-l) with create and update.
|
arc.list [bool] -- Always use "list mode" (-l) with create and update.
|
||||||
In this mode, the list of git revisions to use
|
In this mode, the list of git revisions to use
|
||||||
is listed with a single prompt before creating or
|
is listed with a single prompt before creating or
|
||||||
updating reviews. The diffs for individual commits
|
updating reviews. The diffs for individual commits
|
||||||
are not shown.
|
are not shown.
|
||||||
|
|
||||||
arc.verbose [bool] -- Verbose output. Equivalent to the -v flag.
|
arc.verbose [bool] -- Verbose output. Equivalent to the -v flag.
|
||||||
|
|
||||||
@ -147,6 +155,12 @@ __EOF__
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Use xmktemp instead of mktemp when creating temporary files.
|
||||||
|
xmktemp()
|
||||||
|
{
|
||||||
|
mktemp "${GITARC_TMPDIR:?}/tmp.XXXXXXXXXX" || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Fetch the value of a boolean config variable ($1) and return true
|
# Fetch the value of a boolean config variable ($1) and return true
|
||||||
# (0) if the variable is true. The default value to use if the
|
# (0) if the variable is true. The default value to use if the
|
||||||
@ -200,12 +214,12 @@ diff2status()
|
|||||||
err "invalid diff ID $diff"
|
err "invalid diff ID $diff"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp=$(mktemp)
|
tmp=$(xmktemp)
|
||||||
echo '{"names":["'"$diff"'"]}' |
|
echo '{"names":["'"$diff"'"]}' |
|
||||||
arc_call_conduit -- phid.lookup > "$tmp"
|
arc_call_conduit -- phid.lookup > "$tmp"
|
||||||
status=$(jq -r "select(.response != []) | .response.${diff}.status" < "$tmp")
|
status=$(jq -r "select(.response != []) | .response.${diff}.status" < "$tmp")
|
||||||
summary=$(jq -r "select(.response != []) |
|
summary=$(jq -r "select(.response != []) |
|
||||||
.response.${diff}.fullName" < "$tmp")
|
.response.${diff}.fullName" < "$tmp")
|
||||||
printf "%-14s %s\n" "${status}" "${summary}"
|
printf "%-14s %s\n" "${status}" "${summary}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +293,7 @@ create_one_review()
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg=$(mktemp)
|
msg=$(xmktemp)
|
||||||
git show -s --format='%B' "$commit" > "$msg"
|
git show -s --format='%B' "$commit" > "$msg"
|
||||||
printf "\nTest Plan:\n" >> "$msg"
|
printf "\nTest Plan:\n" >> "$msg"
|
||||||
printf "\nReviewers:\n" >> "$msg"
|
printf "\nReviewers:\n" >> "$msg"
|
||||||
@ -305,10 +319,9 @@ create_one_review()
|
|||||||
"type": "parents.add",
|
"type": "parents.add",
|
||||||
"value": ["'"${parentphid}"'"]
|
"value": ["'"${parentphid}"'"]
|
||||||
}
|
}
|
||||||
]}' |
|
]}' |
|
||||||
arc_call_conduit -- differential.revision.edit >&3
|
arc_call_conduit -- differential.revision.edit >&3
|
||||||
fi
|
fi
|
||||||
rm -f "$msg"
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,15 +334,15 @@ diff2reviewers()
|
|||||||
reviewid=$(diff2phid "$diff")
|
reviewid=$(diff2phid "$diff")
|
||||||
userids=$( \
|
userids=$( \
|
||||||
echo '{
|
echo '{
|
||||||
"constraints": {"phids": ["'"$reviewid"'"]},
|
"constraints": {"phids": ["'"$reviewid"'"]},
|
||||||
"attachments": {"reviewers": true}
|
"attachments": {"reviewers": true}
|
||||||
}' |
|
}' |
|
||||||
arc_call_conduit -- differential.revision.search |
|
arc_call_conduit -- differential.revision.search |
|
||||||
jq '.response.data[0].attachments.reviewers.reviewers[] | select(.status == "accepted").reviewerPHID')
|
jq '.response.data[0].attachments.reviewers.reviewers[] | select(.status == "accepted").reviewerPHID')
|
||||||
if [ -n "$userids" ]; then
|
if [ -n "$userids" ]; then
|
||||||
echo '{
|
echo '{
|
||||||
"constraints": {"phids": ['"$(printf "%s" "$userids" | tr '[:space:]' ',')"']}
|
"constraints": {"phids": ['"$(echo "$userids" | tr '[:blank:]' ',')"']}
|
||||||
}' |
|
}' |
|
||||||
arc_call_conduit -- user.search |
|
arc_call_conduit -- user.search |
|
||||||
jq -r '.response.data[].fields.username'
|
jq -r '.response.data[].fields.username'
|
||||||
fi
|
fi
|
||||||
@ -427,7 +440,7 @@ gitarc__create()
|
|||||||
|
|
||||||
for commit in ${commits}; do
|
for commit in ${commits}; do
|
||||||
if create_one_review "$commit" "$reviewers" "$subscribers" "$prev" \
|
if create_one_review "$commit" "$reviewers" "$subscribers" "$prev" \
|
||||||
"$doprompt"; then
|
"$doprompt"; then
|
||||||
prev=$(commit2diff "$commit")
|
prev=$(commit2diff "$commit")
|
||||||
else
|
else
|
||||||
prev=""
|
prev=""
|
||||||
@ -448,8 +461,8 @@ gitarc__list()
|
|||||||
|
|
||||||
diff=$(log2diff "$commit")
|
diff=$(log2diff "$commit")
|
||||||
if [ -n "$diff" ]; then
|
if [ -n "$diff" ]; then
|
||||||
diff2status "$diff"
|
diff2status "$diff"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This does not use commit2diff as it needs to handle errors
|
# This does not use commit2diff as it needs to handle errors
|
||||||
@ -457,7 +470,7 @@ gitarc__list()
|
|||||||
title=$(git show -s --format=%s "$commit")
|
title=$(git show -s --format=%s "$commit")
|
||||||
diff=$(echo "$openrevs" | \
|
diff=$(echo "$openrevs" | \
|
||||||
awk -F'D[1-9][0-9]*: ' \
|
awk -F'D[1-9][0-9]*: ' \
|
||||||
'{if ($2 == "'"$(echo $title | sed 's/"/\\"/g')"'") print $0}')
|
'{if ($2 == "'"$(echo $title | sed 's/"/\\"/g')"'") print $0}')
|
||||||
if [ -z "$diff" ]; then
|
if [ -z "$diff" ]; then
|
||||||
echo "No Review : $title"
|
echo "No Review : $title"
|
||||||
elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then
|
elif [ "$(echo "$diff" | wc -l)" -ne 1 ]; then
|
||||||
@ -491,18 +504,18 @@ find_author()
|
|||||||
# freebsd.org (which isn't surprising for ports committers getting src
|
# freebsd.org (which isn't surprising for ports committers getting src
|
||||||
# commits reviewed).
|
# commits reviewed).
|
||||||
case "${addr}" in
|
case "${addr}" in
|
||||||
*.*) ;; # external user
|
*.*) ;; # external user
|
||||||
*)
|
*)
|
||||||
echo "${name} <${addr}@FreeBSD.org>"
|
echo "${name} <${addr}@FreeBSD.org>"
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Choice 2: author_addr and author_name were set in the bundle, so use
|
# Choice 2: author_addr and author_name were set in the bundle, so use
|
||||||
# that. We may need to filter some known bogus ones, should they crop up.
|
# that. We may need to filter some known bogus ones, should they crop up.
|
||||||
if [ -n "$author_name" -a -n "$author_addr" ]; then
|
if [ -n "$author_name" -a -n "$author_addr" ]; then
|
||||||
echo "${author_name} <${author_addr}>"
|
echo "${author_name} <${author_addr}>"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Choice 3: We can find this user in the FreeBSD repo. They've submited
|
# Choice 3: We can find this user in the FreeBSD repo. They've submited
|
||||||
@ -510,8 +523,8 @@ find_author()
|
|||||||
# similar to their phab username.
|
# similar to their phab username.
|
||||||
email=$(git log -1 --author "$(echo ${addr} | tr _ .)" --pretty="%aN <%aE>")
|
email=$(git log -1 --author "$(echo ${addr} | tr _ .)" --pretty="%aN <%aE>")
|
||||||
if [ -n "${email}" ]; then
|
if [ -n "${email}" ]; then
|
||||||
echo "${email}"
|
echo "${email}"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Choice 4: We know this user. They've committed before, and they happened
|
# Choice 4: We know this user. They've committed before, and they happened
|
||||||
@ -519,11 +532,11 @@ find_author()
|
|||||||
# might not be a good idea, since names can be somewhat common (there
|
# might not be a good idea, since names can be somewhat common (there
|
||||||
# are two Andrew Turners that have contributed to FreeBSD, for example).
|
# are two Andrew Turners that have contributed to FreeBSD, for example).
|
||||||
if ! (echo "${name}" | grep -w "[Uu]ser" -q); then
|
if ! (echo "${name}" | grep -w "[Uu]ser" -q); then
|
||||||
email=$(git log -1 --author "${name}" --pretty="%aN <%aE>")
|
email=$(git log -1 --author "${name}" --pretty="%aN <%aE>")
|
||||||
if [ -n "$email" ]; then
|
if [ -n "$email" ]; then
|
||||||
echo "$email"
|
echo "$email"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Choice 5: Wing it as best we can. In this scenario, we replace the last _
|
# Choice 5: Wing it as best we can. In this scenario, we replace the last _
|
||||||
@ -532,61 +545,68 @@ find_author()
|
|||||||
# don't know if the prior _ are _ or + or any number of other characters.
|
# don't know if the prior _ are _ or + or any number of other characters.
|
||||||
# Since there's issues here, prompt
|
# Since there's issues here, prompt
|
||||||
a=$(printf "%s <%s>\n" "${name}" $(echo "$addr" | sed -e 's/\(.*\)_/\1@/'))
|
a=$(printf "%s <%s>\n" "${name}" $(echo "$addr" | sed -e 's/\(.*\)_/\1@/'))
|
||||||
echo "Making best guess: Truning ${addr} to ${a}"
|
echo "Making best guess: Turning ${addr} to ${a}"
|
||||||
if ! prompt; then
|
if ! prompt; then
|
||||||
echo "ABORT"
|
echo "ABORT"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo "${a}"
|
echo "${a}"
|
||||||
}
|
}
|
||||||
|
|
||||||
patch_commit()
|
patch_commit()
|
||||||
{
|
{
|
||||||
local diff reviewid review_data authorid user_data user_addr user_name author
|
local diff reviewid review_data authorid user_data user_addr user_name
|
||||||
local tmp author_addr author_name
|
local diff_data author_addr author_name author tmp
|
||||||
|
|
||||||
diff=$1
|
diff=$1
|
||||||
reviewid=$(diff2phid "$diff")
|
reviewid=$(diff2phid "$diff")
|
||||||
# Get the author phid for this patch
|
# Get the author phid for this patch
|
||||||
review_data=$(mktemp)
|
review_data=$(xmktemp)
|
||||||
echo '{"constraints": {"phids": ["'"$reviewid"'"]}}' | \
|
echo '{"constraints": {"phids": ["'"$reviewid"'"]}}' | \
|
||||||
arc_call_conduit -- differential.revision.search > "$review_data"
|
arc_call_conduit -- differential.revision.search > "$review_data"
|
||||||
authorid=$(jq -r '.response.data[].fields.authorPHID' "$review_data")
|
authorid=$(jq -r '.response.data[].fields.authorPHID' "$review_data")
|
||||||
# Get metadata about the user that submitted this patch
|
# Get metadata about the user that submitted this patch
|
||||||
user_data=$(mktemp)
|
user_data=$(xmktemp)
|
||||||
echo '{"constraints": {"phids": ["'"$authorid"'"]}}' | \
|
echo '{"constraints": {"phids": ["'"$authorid"'"]}}' | \
|
||||||
arc_call_conduit -- user.search | \
|
arc_call_conduit -- user.search | \
|
||||||
jq -r '.response.data[].fields' > "$user_data"
|
jq -r '.response.data[].fields' > "$user_data"
|
||||||
user_addr=$(jq -r '.username' "$user_data")
|
user_addr=$(jq -r '.username' "$user_data")
|
||||||
user_name=$(jq -r '.realName' "$user_data")
|
user_name=$(jq -r '.realName' "$user_data")
|
||||||
rm "$user_data"
|
|
||||||
# Dig the data out of querydiffs api endpoint, although it's deprecated,
|
# Dig the data out of querydiffs api endpoint, although it's deprecated,
|
||||||
# since it's one of the few places we can get email addresses. It's unclear
|
# since it's one of the few places we can get email addresses. It's unclear
|
||||||
# if we can expect multiple difference ones of these. Some records don't
|
# if we can expect multiple difference ones of these. Some records don't
|
||||||
# have this data, so we remove all the 'null's. We sort the results and
|
# have this data, so we remove all the 'null's. We sort the results and
|
||||||
# remove duplicates 'just to be sure' since we've not seen multiple
|
# remove duplicates 'just to be sure' since we've not seen multiple
|
||||||
# records that match.
|
# records that match.
|
||||||
diff_data=$(mktemp)
|
diff_data=$(xmktemp)
|
||||||
echo '{"revisionIDs": [ '"${diff#D}"' ]}' | \
|
echo '{"revisionIDs": [ '"${diff#D}"' ]}' | \
|
||||||
arc_call_conduit -- differential.querydiffs |
|
arc_call_conduit -- differential.querydiffs |
|
||||||
jq -r '.response | flatten | .[]' > "$diff_data"
|
jq -r '.response | flatten | .[]' > "$diff_data"
|
||||||
author_addr=$(jq -r ".authorEmail?" "$diff_data" | sort -u)
|
author_addr=$(jq -r ".authorEmail?" "$diff_data" | sort -u)
|
||||||
author_name=$(jq -r ".authorName?" "$diff_data" | sort -u)
|
author_name=$(jq -r ".authorName?" "$diff_data" | sort -u)
|
||||||
|
|
||||||
|
# JSON will return "null" when a field is not populated.
|
||||||
|
# Turn this string into an empty one.
|
||||||
|
if [ "$author_addr" = "null" ]; then
|
||||||
|
author_addr=""
|
||||||
|
fi
|
||||||
|
if [ "$author_name" = "null" ]; then
|
||||||
|
author_name=""
|
||||||
|
fi
|
||||||
|
|
||||||
author=$(find_author "$user_addr" "$user_name" "$author_addr" "$author_name")
|
author=$(find_author "$user_addr" "$user_name" "$author_addr" "$author_name")
|
||||||
rm "$diff_data"
|
|
||||||
|
|
||||||
# If we had to guess, and the user didn't want to guess, abort
|
# If we had to guess, and the user didn't want to guess, abort
|
||||||
if [ "${author}" = "ABORT" ]; then
|
if [ "${author}" = "ABORT" ]; then
|
||||||
warn "Not committing due to uncertainty over author name"
|
warn "Not committing due to uncertainty over author name"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp=$(mktemp)
|
tmp=$(xmktemp)
|
||||||
jq -r '.response.data[].fields.title' "$review_data" > $tmp
|
jq -r '.response.data[].fields.title' "$review_data" > "$tmp"
|
||||||
echo >> $tmp
|
echo >> "$tmp"
|
||||||
jq -r '.response.data[].fields.summary' "$review_data" >> $tmp
|
jq -r '.response.data[].fields.summary' "$review_data" >> "$tmp"
|
||||||
echo >> $tmp
|
echo >> "$tmp"
|
||||||
rm "$review_data"
|
|
||||||
# XXX this leaves an extra newline in some cases.
|
# XXX this leaves an extra newline in some cases.
|
||||||
reviewers=$(diff2reviewers "$diff" | sed '/^$/d' | paste -sd ',' - | sed 's/,/, /g')
|
reviewers=$(diff2reviewers "$diff" | sed '/^$/d' | paste -sd ',' - | sed 's/,/, /g')
|
||||||
if [ -n "$reviewers" ]; then
|
if [ -n "$reviewers" ]; then
|
||||||
@ -595,7 +615,6 @@ patch_commit()
|
|||||||
# XXX TODO refactor with gitarc__stage maybe?
|
# XXX TODO refactor with gitarc__stage maybe?
|
||||||
printf "Differential Revision:\thttps://reviews.freebsd.org/%s\n" "${diff}" >> "$tmp"
|
printf "Differential Revision:\thttps://reviews.freebsd.org/%s\n" "${diff}" >> "$tmp"
|
||||||
git commit --author "${author}" --file "$tmp"
|
git commit --author "${author}" --file "$tmp"
|
||||||
rm "$tmp"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gitarc__patch()
|
gitarc__patch()
|
||||||
@ -610,7 +629,7 @@ gitarc__patch()
|
|||||||
while getopts c o; do
|
while getopts c o; do
|
||||||
case "$o" in
|
case "$o" in
|
||||||
c)
|
c)
|
||||||
require_clean_work_tree "patch -c"
|
require_clean_work_tree "patch -c"
|
||||||
commit=true
|
commit=true
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
@ -624,9 +643,9 @@ gitarc__patch()
|
|||||||
arc patch --skip-dependencies --nocommit --nobranch --force "$rev"
|
arc patch --skip-dependencies --nocommit --nobranch --force "$rev"
|
||||||
echo "Applying ${rev}..."
|
echo "Applying ${rev}..."
|
||||||
[ $? -eq 0 ] || break
|
[ $? -eq 0 ] || break
|
||||||
if ${commit}; then
|
if ${commit}; then
|
||||||
patch_commit $rev
|
patch_commit $rev
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -655,7 +674,7 @@ gitarc__stage()
|
|||||||
git checkout -q -b "${branch}" main
|
git checkout -q -b "${branch}" main
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmp=$(mktemp)
|
tmp=$(xmktemp)
|
||||||
for commit in $commits; do
|
for commit in $commits; do
|
||||||
git show -s --format=%B "$commit" > "$tmp"
|
git show -s --format=%B "$commit" > "$tmp"
|
||||||
title=$(git show -s --format=%s "$commit")
|
title=$(git show -s --format=%s "$commit")
|
||||||
@ -816,4 +835,7 @@ if get_bool_config arc.browse false; then
|
|||||||
BROWSE=--browse
|
BROWSE=--browse
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
GITARC_TMPDIR=$(mktemp -d) || exit 1
|
||||||
|
trap cleanup EXIT HUP INT QUIT TRAP USR1 TERM
|
||||||
|
|
||||||
gitarc__"${verb}" "$@"
|
gitarc__"${verb}" "$@"
|
||||||
|
@ -521,41 +521,23 @@ do_open(const char *vmname)
|
|||||||
{
|
{
|
||||||
struct vmctx *ctx;
|
struct vmctx *ctx;
|
||||||
int error;
|
int error;
|
||||||
bool reinit, romboot;
|
bool romboot;
|
||||||
|
|
||||||
reinit = false;
|
|
||||||
|
|
||||||
romboot = bootrom_boot();
|
romboot = bootrom_boot();
|
||||||
error = vm_create(vmname);
|
|
||||||
if (error) {
|
|
||||||
if (errno == EEXIST) {
|
|
||||||
if (romboot) {
|
|
||||||
reinit = true;
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* The virtual machine has been setup by the
|
|
||||||
* userspace bootloader.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
perror("vm_create");
|
|
||||||
exit(4);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!romboot) {
|
|
||||||
/*
|
|
||||||
* If the virtual machine was just created then a
|
|
||||||
* bootrom must be configured to boot it.
|
|
||||||
*/
|
|
||||||
fprintf(stderr, "virtual machine cannot be booted\n");
|
|
||||||
exit(4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx = vm_open(vmname);
|
/*
|
||||||
|
* If we don't have a boot ROM, the guest context must have been
|
||||||
|
* initialized by bhyveload(8) or equivalent.
|
||||||
|
*/
|
||||||
|
ctx = vm_openf(vmname, romboot ? VMMAPI_OPEN_REINIT : 0);
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
perror("vm_open");
|
if (errno != ENOENT)
|
||||||
exit(4);
|
err(4, "vm_openf");
|
||||||
|
if (!romboot)
|
||||||
|
errx(4, "no bootrom was configured");
|
||||||
|
ctx = vm_openf(vmname, VMMAPI_OPEN_CREATE);
|
||||||
|
if (ctx == NULL)
|
||||||
|
err(4, "vm_openf");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WITHOUT_CAPSICUM
|
#ifndef WITHOUT_CAPSICUM
|
||||||
@ -563,13 +545,6 @@ do_open(const char *vmname)
|
|||||||
err(EX_OSERR, "vm_limit_rights");
|
err(EX_OSERR, "vm_limit_rights");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (reinit) {
|
|
||||||
error = vm_reinit(ctx);
|
|
||||||
if (error) {
|
|
||||||
perror("vm_reinit");
|
|
||||||
exit(4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
error = vm_set_topology(ctx, cpu_sockets, cpu_cores, cpu_threads, 0);
|
error = vm_set_topology(ctx, cpu_sockets, cpu_cores, cpu_threads, 0);
|
||||||
if (error)
|
if (error)
|
||||||
errx(EX_OSERR, "vm_set_topology");
|
errx(EX_OSERR, "vm_set_topology");
|
||||||
|
@ -388,22 +388,17 @@ main(int argc, char *argv[])
|
|||||||
if (vmname == NULL)
|
if (vmname == NULL)
|
||||||
usage(opts);
|
usage(opts);
|
||||||
|
|
||||||
error = 0;
|
|
||||||
|
|
||||||
if (!error && create)
|
ctx = vm_openf(vmname, create ? VMMAPI_OPEN_CREATE : 0);
|
||||||
error = vm_create(vmname);
|
if (ctx == NULL) {
|
||||||
|
fprintf(stderr,
|
||||||
if (!error) {
|
"vm_open: %s could not be opened: %s\n",
|
||||||
ctx = vm_open(vmname);
|
vmname, strerror(errno));
|
||||||
if (ctx == NULL) {
|
exit(1);
|
||||||
fprintf(stderr,
|
|
||||||
"vm_open: %s could not be opened: %s\n",
|
|
||||||
vmname, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
vcpu = vm_vcpu_open(ctx, vcpuid);
|
|
||||||
}
|
}
|
||||||
|
vcpu = vm_vcpu_open(ctx, vcpuid);
|
||||||
|
|
||||||
|
error = 0;
|
||||||
if (!error && memsize)
|
if (!error && memsize)
|
||||||
error = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
|
error = vm_setup_memory(ctx, memsize, VM_MMAP_ALL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user