diff options
author | Dan McDonald <danmcd@mnx.io> | 2022-05-02 20:11:38 -0400 |
---|---|---|
committer | Dan McDonald <danmcd@mnx.io> | 2022-05-02 20:11:38 -0400 |
commit | 6b1923e3b8d5b0582fb17f95b315aa664d0c45a5 (patch) | |
tree | 4af9662138b87e0ad85452cc4184d1412c041089 | |
parent | 0bac467c5c1d37ae879894be3f86644aa211be1f (diff) | |
parent | 3466010b6f73e5cbeb612e538494c9d42c6d4a68 (diff) | |
download | illumos-joyent-6b1923e3b8d5b0582fb17f95b315aa664d0c45a5.tar.gz |
[illumos-gate merge]
commit 3466010b6f73e5cbeb612e538494c9d42c6d4a68
14660 expose bhyve kernel interface version
commit 2a22bccab8733d6de38ab1e1fbe8c810122a4427
14657 zoneadmd: remove warning gags and add ctf support
Conflicts:
usr/src/cmd/zoneadmd/Makefile
usr/src/cmd/zoneadmd/vplat.c
usr/src/cmd/zoneadmd/zoneadmd.c
-rw-r--r-- | usr/src/cmd/zoneadmd/Makefile | 6 | ||||
-rw-r--r-- | usr/src/cmd/zoneadmd/vplat.c | 15 | ||||
-rw-r--r-- | usr/src/cmd/zoneadmd/zoneadmd.c | 8 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-bhyve-tests.p5m | 1 | ||||
-rw-r--r-- | usr/src/test/bhyve-tests/runfiles/default.run | 1 | ||||
-rw-r--r-- | usr/src/test/bhyve-tests/tests/vmm/Makefile | 3 | ||||
-rw-r--r-- | usr/src/test/bhyve-tests/tests/vmm/interface_version.c | 48 | ||||
-rw-r--r-- | usr/src/uts/intel/io/vmm/vmm_sol_dev.c | 3 | ||||
-rw-r--r-- | usr/src/uts/intel/sys/vmm_dev.h | 19 |
9 files changed, 89 insertions, 15 deletions
diff --git a/usr/src/cmd/zoneadmd/Makefile b/usr/src/cmd/zoneadmd/Makefile index aa41acfc8b..cfff59f12a 100644 --- a/usr/src/cmd/zoneadmd/Makefile +++ b/usr/src/cmd/zoneadmd/Makefile @@ -39,9 +39,6 @@ clobber := TARGET = clobber lint := TARGET = lint CFLAGS += $(CCVERBOSE) -CERRWARN += -_gcc=-Wno-switch -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += $(CNOWARN_UNINIT) XGETFLAGS += -a -x zoneadmd.xcl @@ -63,7 +60,8 @@ install: $(SUBDIRS) $(POFILE): -clean clobebr lint: $(SUBDIRS) +clean: + $(RM) $(OBJS) check: $(CSTYLE) -p -P *.c diff --git a/usr/src/cmd/zoneadmd/vplat.c b/usr/src/cmd/zoneadmd/vplat.c index d38d78c0cf..0ace033738 100644 --- a/usr/src/cmd/zoneadmd/vplat.c +++ b/usr/src/cmd/zoneadmd/vplat.c @@ -1187,6 +1187,9 @@ mount_one_dev(zlog_t *zlogp, char *devpath, zone_mnt_t mount_cmd) case ZS_EXCLUSIVE: curr_iptype = "exclusive"; break; + default: + zerror(zlogp, B_FALSE, "bad ip-type"); + goto cleanup; } if (curr_iptype == NULL) abort(); @@ -3263,6 +3266,9 @@ get_privset(zlog_t *zlogp, priv_set_t *privs, zone_mnt_t mount_cmd) case ZS_EXCLUSIVE: curr_iptype = "exclusive"; break; + default: + zerror(zlogp, B_FALSE, "bad ip-type"); + return (-1); } if (zonecfg_default_privset(privs, curr_iptype) == Z_OK) @@ -4778,13 +4784,10 @@ vplat_create(zlog_t *zlogp, zone_mnt_t mount_cmd, zoneid_t zone_did) zerror(zlogp, B_TRUE, "unable to determine ip-type"); return (-1); } - switch (iptype) { - case ZS_SHARED: - flags = 0; - break; - case ZS_EXCLUSIVE: + if (iptype == ZS_EXCLUSIVE) { flags = ZCF_NET_EXCL; - break; + } else { + flags = 0; } if (flags == -1) abort(); diff --git a/usr/src/cmd/zoneadmd/zoneadmd.c b/usr/src/cmd/zoneadmd/zoneadmd.c index 1c38d5b282..342b1bf958 100644 --- a/usr/src/cmd/zoneadmd/zoneadmd.c +++ b/usr/src/cmd/zoneadmd/zoneadmd.c @@ -2025,8 +2025,8 @@ server(void *cookie, char *args, size_t alen, door_desc_t *dp, zerror(zlogp, B_FALSE, "zone is already ready"); rval = 0; break; - case Z_BOOT: case Z_FORCEBOOT: + case Z_BOOT: (void) strlcpy(boot_args, zargp->bootbuf, sizeof (boot_args)); eventstream_write(Z_EVT_ZONE_BOOTING); @@ -2054,8 +2054,8 @@ server(void *cookie, char *args, size_t alen, door_desc_t *dp, case Z_SHUTDOWN: case Z_REBOOT: case Z_NOTE_UNINSTALLING: - case Z_MOUNT: case Z_FORCEMOUNT: + case Z_MOUNT: case Z_UNMOUNT: if (kernelcall) /* Invalid; can't happen */ abort(); @@ -2104,8 +2104,8 @@ server(void *cookie, char *args, size_t alen, door_desc_t *dp, else eventstream_write(Z_EVT_ZONE_HALTED); break; - case Z_BOOT: case Z_FORCEBOOT: + case Z_BOOT: /* * We could have two clients racing to boot this * zone; the second client loses, but its request @@ -2160,8 +2160,8 @@ server(void *cookie, char *args, size_t alen, door_desc_t *dp, } break; case Z_NOTE_UNINSTALLING: - case Z_MOUNT: case Z_FORCEMOUNT: + case Z_MOUNT: case Z_UNMOUNT: zerror(zlogp, B_FALSE, "%s operation is invalid " "for zones in state '%s'", z_cmd_name(cmd), diff --git a/usr/src/pkg/manifests/system-bhyve-tests.p5m b/usr/src/pkg/manifests/system-bhyve-tests.p5m index 1a0ba140ce..d4c8be469f 100644 --- a/usr/src/pkg/manifests/system-bhyve-tests.p5m +++ b/usr/src/pkg/manifests/system-bhyve-tests.p5m @@ -50,6 +50,7 @@ file path=opt/bhyve-tests/tests/mevent/vnode_file mode=0555 file path=opt/bhyve-tests/tests/mevent/vnode_zvol mode=0555 dir path=opt/bhyve-tests/tests/vmm file path=opt/bhyve-tests/tests/vmm/fpu_getset mode=0555 +file path=opt/bhyve-tests/tests/vmm/interface_version mode=0555 file path=opt/bhyve-tests/tests/vmm/mem_devmem mode=0555 file path=opt/bhyve-tests/tests/vmm/mem_partial mode=0555 file path=opt/bhyve-tests/tests/vmm/mem_seg_map mode=0555 diff --git a/usr/src/test/bhyve-tests/runfiles/default.run b/usr/src/test/bhyve-tests/runfiles/default.run index 476fa5f839..9296a30852 100644 --- a/usr/src/test/bhyve-tests/runfiles/default.run +++ b/usr/src/test/bhyve-tests/runfiles/default.run @@ -23,6 +23,7 @@ outputdir = /var/tmp/test_results user = root tests = [ 'fpu_getset', + 'interface_version', 'mem_devmem', 'mem_partial', 'mem_seg_map' diff --git a/usr/src/test/bhyve-tests/tests/vmm/Makefile b/usr/src/test/bhyve-tests/tests/vmm/Makefile index 1620706cb6..eeca882915 100644 --- a/usr/src/test/bhyve-tests/tests/vmm/Makefile +++ b/usr/src/test/bhyve-tests/tests/vmm/Makefile @@ -18,7 +18,8 @@ include $(SRC)/test/Makefile.com PROG = mem_partial \ mem_seg_map \ mem_devmem \ - fpu_getset + fpu_getset \ + interface_version COMMON_OBJS = common.o CLEAN_OBJS = $(PROG:%=%.o) diff --git a/usr/src/test/bhyve-tests/tests/vmm/interface_version.c b/usr/src/test/bhyve-tests/tests/vmm/interface_version.c new file mode 100644 index 0000000000..b3de2f4f4f --- /dev/null +++ b/usr/src/test/bhyve-tests/tests/vmm/interface_version.c @@ -0,0 +1,48 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2022 Oxide Computer Company + */ + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <fcntl.h> +#include <libgen.h> + +#include <sys/vmm.h> +#include <sys/vmm_dev.h> + +int +main(int argc, char *argv[]) +{ + const char *suite_name = basename(argv[0]); + + int ctl_fd = open(VMM_CTL_DEV, O_EXCL | O_RDWR); + if (ctl_fd < 0) { + perror("could not open vmmctl device"); + } + + int version = ioctl(ctl_fd, VMM_INTERFACE_VERSION, 0); + if (version < 0) { + perror("VMM_INTERFACE_VERSION ioctl failed"); + } + if (version != VMM_CURRENT_INTERFACE_VERSION) { + (void) fprintf(stderr, "kernel version %d != expected %d\n", + version, VMM_CURRENT_INTERFACE_VERSION); + return (EXIT_FAILURE); + } + + (void) close(ctl_fd); + (void) printf("%s\tPASS\n", suite_name); + return (0); +} diff --git a/usr/src/uts/intel/io/vmm/vmm_sol_dev.c b/usr/src/uts/intel/io/vmm/vmm_sol_dev.c index 3474ba905b..60a888e600 100644 --- a/usr/src/uts/intel/io/vmm/vmm_sol_dev.c +++ b/usr/src/uts/intel/io/vmm/vmm_sol_dev.c @@ -2489,6 +2489,9 @@ vmm_ctl_ioctl(int cmd, intptr_t arg, int md, cred_t *cr, int *rvalp) } case VMM_VM_SUPPORTED: return (vmm_is_supported(arg)); + case VMM_INTERFACE_VERSION: + *rvalp = VMM_CURRENT_INTERFACE_VERSION; + return (0); case VMM_RESV_QUERY: case VMM_RESV_ADD: case VMM_RESV_REMOVE: diff --git a/usr/src/uts/intel/sys/vmm_dev.h b/usr/src/uts/intel/sys/vmm_dev.h index 027a7da214..0e883f21bb 100644 --- a/usr/src/uts/intel/sys/vmm_dev.h +++ b/usr/src/uts/intel/sys/vmm_dev.h @@ -350,6 +350,24 @@ struct vmm_dirty_tracker { void *vdt_pfns; /* bit vector of dirty bits */ }; +/* + * VMM Interface Version + * + * Despite the fact that the kernel interface to bhyve is explicitly considered + * Private, there are out-of-gate consumers which utilize it. While they assume + * the risk of any breakage incurred by changes to bhyve, we can at least try to + * make it easier to detect changes by exposing a "version" of the interface. + * It can also be used by the in-gate userland to detect if packaging updates + * somehow result in the userland and kernel falling out of sync. + * + * There are no established criteria for the magnitude of change which requires + * this version to be incremented, and maintenance of it is considered a + * best-effort activity. Nothing is to be inferred about the magnitude of a + * change when the version is modified. It follows no rules like semver. + */ +#define VMM_CURRENT_INTERFACE_VERSION 1 + + #define VMMCTL_IOC_BASE (('V' << 16) | ('M' << 8)) #define VMM_IOC_BASE (('v' << 16) | ('m' << 8)) #define VMM_LOCK_IOC_BASE (('v' << 16) | ('l' << 8)) @@ -359,6 +377,7 @@ struct vmm_dirty_tracker { #define VMM_CREATE_VM (VMMCTL_IOC_BASE | 0x01) #define VMM_DESTROY_VM (VMMCTL_IOC_BASE | 0x02) #define VMM_VM_SUPPORTED (VMMCTL_IOC_BASE | 0x03) +#define VMM_INTERFACE_VERSION (VMMCTL_IOC_BASE | 0x04) #define VMM_RESV_QUERY (VMMCTL_IOC_BASE | 0x10) #define VMM_RESV_ADD (VMMCTL_IOC_BASE | 0x11) |