summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mooney <pmooney@pfmooney.com>2019-07-23 22:22:38 +0000
committerPatrick Mooney <pmooney@pfmooney.com>2019-08-13 20:15:33 +0000
commit8eac8f9f2de7ea48fca516bc9a7f03d13a4adc3f (patch)
tree29fbaa8d9891de3e26dc4fbcb09ad8b1b9c53d7a
parent8e872d0bad1a3b0e405bc44327f92b7c3567a281 (diff)
downloadillumos-joyent-8eac8f9f2de7ea48fca516bc9a7f03d13a4adc3f.tar.gz
OS-XXXX Make illumos-compatible and reorg
-rw-r--r--usr/src/cmd/bhyve/Makefile4
-rw-r--r--usr/src/cmd/bhyve/bhyverun.c99
-rw-r--r--usr/src/cmd/bhyve/config.h56
-rw-r--r--usr/src/cmd/bhyve/config_sol.c393
-rw-r--r--usr/src/cmd/bhyve/inout.c2
-rw-r--r--usr/src/cmd/bhyve/pci_e82545.c3
-rw-r--r--usr/src/cmd/bhyve/smbiostbl.c6
-rw-r--r--usr/src/compat/freebsd/uuid.h4
8 files changed, 468 insertions, 99 deletions
diff --git a/usr/src/cmd/bhyve/Makefile b/usr/src/cmd/bhyve/Makefile
index cd670890b0..2d5d9f711e 100644
--- a/usr/src/cmd/bhyve/Makefile
+++ b/usr/src/cmd/bhyve/Makefile
@@ -34,7 +34,7 @@ SRCS = acpi.c \
bhyverun.c \
block_if.c \
bootrom.c \
- config.c \
+ config_sol.c \
console.c \
consport.c \
dbgport.c \
@@ -128,7 +128,7 @@ CSTD= $(CSTD_GNU99)
C99MODE= -xc99=%all
C99LMODE= -Xc99=%all
-$(PROG) := LDLIBS += -lsocket -lnsl -ldlpi -ldladm -lmd -luuid -lvmmapi -lz
+$(PROG) := LDLIBS += -lavl -lsocket -lnsl -ldlpi -ldladm -lmd -luuid -lvmmapi -lz
$(ZHYVE_PROG) := LDLIBS += -lnvpair
$(MEVENT_TEST_PROG) := LDLIBS += -lsocket
diff --git a/usr/src/cmd/bhyve/bhyverun.c b/usr/src/cmd/bhyve/bhyverun.c
index c136ee7788..6cb67214a6 100644
--- a/usr/src/cmd/bhyve/bhyverun.c
+++ b/usr/src/cmd/bhyve/bhyverun.c
@@ -562,7 +562,7 @@ int
fbsdrun_virtio_msix(void)
{
- return (get_config_bool("virtio_msix"));
+ return (get_config_bool("virtio.msix"));
}
static void *
@@ -701,7 +701,7 @@ vmexit_rdmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
if (error != 0) {
fprintf(stderr, "rdmsr to register %#x on vcpu %d\n",
vme->u.msr.code, *pvcpu);
- if (get_config_bool("strictmsr")) {
+ if (get_config_bool("x86.strict_msr")) {
vm_inject_gp(ctx, *pvcpu);
return (VMEXIT_CONTINUE);
}
@@ -727,7 +727,7 @@ vmexit_wrmsr(struct vmctx *ctx, struct vm_exit *vme, int *pvcpu)
if (error != 0) {
fprintf(stderr, "wrmsr to register %#x(%#lx) on vcpu %d\n",
vme->u.msr.code, vme->u.msr.wval, *pvcpu);
- if (get_config_bool("strictmsr")) {
+ if (get_config_bool("x86.strict_msr")) {
vm_inject_gp(ctx, *pvcpu);
return (VMEXIT_CONTINUE);
}
@@ -1032,7 +1032,7 @@ fbsdrun_set_capabilities(struct vmctx *ctx, int cpu)
{
int err, tmp;
- if (get_config_bool("vmexit_on_hlt")) {
+ if (get_config_bool("hvm.vmexit_on_hlt")) {
err = vm_get_capability(ctx, cpu, VM_CAP_HALT_EXIT, &tmp);
if (err < 0) {
fprintf(stderr, "VM exit on HLT not supported\n");
@@ -1043,7 +1043,7 @@ fbsdrun_set_capabilities(struct vmctx *ctx, int cpu)
handler[VM_EXITCODE_HLT] = vmexit_hlt;
}
- if (get_config_bool("vmexit_on_pause")) {
+ if (get_config_bool("hvm.vmexit_on_pause")) {
/*
* pause exit support required for this mode
*/
@@ -1058,7 +1058,7 @@ fbsdrun_set_capabilities(struct vmctx *ctx, int cpu)
handler[VM_EXITCODE_PAUSE] = vmexit_pause;
}
- if (get_config_bool("x2apic"))
+ if (get_config_bool("x86.x2apic"))
err = vm_set_x2apic_state(ctx, cpu, X2APIC_ENABLED);
else
err = vm_set_x2apic_state(ctx, cpu, X2APIC_DISABLED);
@@ -1219,38 +1219,33 @@ set_defaults(void)
{
/* default is xAPIC */
- set_config_bool("x2apic", false);
- set_config_bool("acpi_tables", false);
+ set_config_bool("x86.x2apic", false);
+ set_config_bool("x86.acpi_tables", false);
+ set_config_bool("x86.strict_io", false);
+ set_config_bool("x86.strict_msr", true);
+ set_config_bool("x86.mptable", true);
+
set_config_bool("bvmconsole", false);
set_config_bool("gdb.wait", false);
+
set_config_bool("memory.guest_in_core", false);
set_config_value("memory.size", "256M");
set_config_bool("memory.wired", false);
- set_config_bool("mptable", true);
+
set_config_bool("rtc.use_localtime", true);
- set_config_bool("strictio", false);
- set_config_bool("strictmsr", true);
- set_config_bool("virtio_msix", true);
- set_config_bool("vmexit_on_hlt", false);
- set_config_bool("vmexit_on_pause", false);
+
+ set_config_bool("virtio.msix", true);
+
+ set_config_bool("hvm.vmexit_on_hlt", false);
+ set_config_bool("hvm.vmexit_on_pause", false);
}
-int
-main(int argc, char *argv[])
+static void
+parse_args(int argc, char *argv[])
{
- int c, error, err;
- int max_vcpus, memflags;
-#ifndef __FreeBSD__
- bool suspend = false;
-#endif
- struct vmctx *ctx;
- uint64_t rip;
- size_t memsize;
- const char *value, *vmname;
- char *optstr;
+ const char *optstr;
+ int c;
- init_config();
- set_defaults();
progname = basename(argv[0]);
#ifdef __FreeBSD__
@@ -1261,10 +1256,10 @@ main(int argc, char *argv[])
while ((c = getopt(argc, argv, optstr)) != -1) {
switch (c) {
case 'a':
- set_config_bool("x2apic", false);
+ set_config_bool("x86.x2apic", false);
break;
case 'A':
- set_config_bool("acpi_tables", true);
+ set_config_bool("x86.acpi_tables", true);
break;
case 'b':
set_config_bool("bvmconsole", true);
@@ -1277,7 +1272,7 @@ main(int argc, char *argv[])
break;
#ifndef __FreeBSD__
case 'd':
- suspend = true;
+ set_config_bool("hvm.suspend_at_boot", true);
break;
#else
case 'p':
@@ -1337,7 +1332,7 @@ main(int argc, char *argv[])
errx(EX_USAGE, "invalid configuration option '%s'", optarg);
break;
case 'H':
- set_config_bool("vmexit_on_hlt", true);
+ set_config_bool("hvm.vmexit_on_hlt", true);
break;
case 'I':
/*
@@ -1349,10 +1344,10 @@ main(int argc, char *argv[])
*/
break;
case 'P':
- set_config_bool("vmexit_on_pause", true);
+ set_config_bool("hvm.vmexit_on_pause", true);
break;
case 'e':
- set_config_bool("strictio", true);
+ set_config_bool("x86.strict_io", true);
break;
case 'u':
set_config_bool("rtc.use_localtime", false);
@@ -1361,19 +1356,19 @@ main(int argc, char *argv[])
set_config_value("uuid", optarg);
break;
case 'w':
- set_config_bool("strictmsr", false);
+ set_config_bool("x86.strict_msr", false);
break;
case 'W':
- set_config_bool("virtio_msix", false);
+ set_config_bool("virtio.msix", false);
break;
case 'x':
- set_config_bool("x2apic", true);
+ set_config_bool("x86.x2apic", true);
break;
case 'Y':
- set_config_bool("mptable", false);
+ set_config_bool("x86.mptable", false);
break;
case 'h':
- usage(0);
+ usage(0);
default:
usage(1);
}
@@ -1386,6 +1381,23 @@ main(int argc, char *argv[])
if (argc == 1)
set_config_value("name", argv[0]);
+}
+
+int
+main(int argc, char *argv[])
+{
+ int error, err;
+ int max_vcpus, memflags;
+ struct vmctx *ctx;
+ uint64_t rip;
+ size_t memsize;
+ const char *value, *vmname;
+
+ init_config();
+ set_defaults();
+
+ parse_args(argc, argv);
+ finish_config();
vmname = get_config_value("name");
if (vmname == NULL)
@@ -1393,7 +1405,7 @@ main(int argc, char *argv[])
#if 1
if (get_config_value("config.dump")) {
- dump_config();
+ dump_config(get_config_value("config.dump_expand") != NULL);
exit(1);
}
#endif
@@ -1496,7 +1508,7 @@ main(int argc, char *argv[])
/*
* build the guest tables, MP etc.
*/
- if (get_config_bool("mptable")) {
+ if (get_config_bool("x86.mptable")) {
error = mptable_build(ctx, guest_ncpus);
if (error) {
perror("error to build the guest tables");
@@ -1507,7 +1519,7 @@ main(int argc, char *argv[])
error = smbios_build(ctx);
assert(error == 0);
- if (get_config_bool("acpi_tables")) {
+ if (get_config_bool("x86.acpi_tables")) {
error = acpi_build(ctx, guest_ncpus);
assert(error == 0);
}
@@ -1551,7 +1563,8 @@ main(int argc, char *argv[])
#ifdef __FreeBSD__
fbsdrun_addcpu(ctx, BSP, BSP, rip);
#else
- fbsdrun_addcpu(ctx, BSP, BSP, rip, suspend);
+ fbsdrun_addcpu(ctx, BSP, BSP, rip,
+ get_config_bool("hvm.suspend_at_boot"));
mark_provisioned();
#endif
diff --git a/usr/src/cmd/bhyve/config.h b/usr/src/cmd/bhyve/config.h
index ffb97372d7..5d5da5ceef 100644
--- a/usr/src/cmd/bhyve/config.h
+++ b/usr/src/cmd/bhyve/config.h
@@ -30,12 +30,6 @@
#ifndef __CONFIG_H__
#define __CONFIG_H__
-#ifdef __FreeBSD__
-#include <sys/nv.h>
-#else
-#include <sys/nvpair.h>
-#endif /* __FreeBSD__ */
-
/*-
* Manages a configuration database backed by an nv(9) list.
*
@@ -43,61 +37,25 @@
* values into other types if needed. String values can reference
* other configuration variables using a '%(name)' syntax. In this
* case, the name must be the the full path of the configuration
- * variable. The % character can be escaped with a preceding \ to
- * avoid expansion. Any \ characters must be escaped.
+ * variable. The % character can be escaped with a preceding % to avoid
+ * expansion
*
* Configuration variables are stored in a tree. The full path of a
* variable is specified as a dot-separated name similar to sysctl(8)
* OIDs.
- */
-
-/*
- * Fetches the value of a configuration variable. If the "raw" value
- * contains references to other configuration variables, this function
- * expands those references and returns a pointer to the parsed
- * string. The string's storage is only stable until the next call to
- * this function.
- *
- * If no node is found, returns NULL.
- *
- * If 'parent' is NULL, 'name' is assumed to be a top-level variable.
*/
-const char *get_config_value_node(nvlist_t *parent, const char *name);
-
-/*
- * Similar to get_config_value_node but expects a full path to the
- * leaf node.
- */
-const char *get_config_value(const char *path);
/* Initializes the tree to an empty state. */
void init_config(void);
+void finish_config(void);
-/*
- * Parses a dot-separated OID path. Will fail if the path names an
- * existing leaf configuration variable. Will create a new node if it
- * does not yet exist and 'create' is true.
- */
-nvlist_t *lookup_config_node(const char *path, bool create);
-
-/*
- * Adds or replaces the value of the specified variable.
- *
- * If 'parent' is NULL, 'name' is assumed to be a top-level variable.
- */
-void set_config_value_node(nvlist_t *parent, const char *name,
- const char *value);
-
-/*
- * Similar to set_config_value_node but expects a full path to the
- * leaf node.
- */
+const char *get_config_value(const char *path);
void set_config_value(const char *path, const char *value);
/* Convenience wrappers for boolean variables. */
-bool get_config_bool(const char *path);
-void set_config_bool(const char *path, bool value);
+boolean_t get_config_bool(const char *path);
+void set_config_bool(const char *path, boolean_t value);
-void dump_config(void);
+void dump_config(boolean_t);
#endif /* !__CONFIG_H__ */
diff --git a/usr/src/cmd/bhyve/config_sol.c b/usr/src/cmd/bhyve/config_sol.c
new file mode 100644
index 0000000000..98e9878fb7
--- /dev/null
+++ b/usr/src/cmd/bhyve/config_sol.c
@@ -0,0 +1,393 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 John H. Baldwin <jhb@FreeBSD.org>
+ * Copyright (c) 2019 Joyent, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <pthread.h>
+#include <string.h>
+#include <strings.h>
+#include <err.h>
+#include <stdlib.h>
+
+#include <sys/avl.h>
+#include <sys/debug.h>
+#include <sys/param.h>
+#include <sys/stddef.h>
+
+#include "config.h"
+
+static avl_tree_t config_tree;
+/*
+ * config_lock protects config_tree and its contents. After a call to
+ * finish_config(), it is expected that no items will be added/removed from
+ * config_tree, although value expansion may still occur.
+ */
+static pthread_mutex_t config_lock;
+static boolean_t config_finished;
+
+#define CONFIG_MAX_DEPTH 15
+
+typedef enum {
+ CF_EXPANDED = (1 << 0),
+ CF_NEEDS_EXPAND = (1 << 1),
+ CF_BOOL_CHECKED = (1 << 2),
+} config_flags_t;
+
+typedef struct config_node {
+ avl_node_t cn_node;
+ config_flags_t cn_flags;
+ boolean_t cn_bool;
+ const char *cn_path;
+ const char *cn_value_raw;
+ const char *cn_value_expanded;
+} config_node_t;
+
+static const char *expand_config_value(config_node_t *, uint_t);
+static config_node_t *find_config_path(const char *, avl_index_t *);
+
+static int
+config_node_compare(const void *a, const void *b)
+{
+ const config_node_t *left = a;
+ const config_node_t *right = b;
+ const int res = strcmp(left->cn_path, right->cn_path);
+
+ if (res > 0) {
+ return (1);
+ } else if (res < 0) {
+ return (-1);
+ }
+ return (0);
+}
+
+void
+init_config(void)
+{
+ VERIFY0(pthread_mutex_init(&config_lock, NULL));
+ avl_create(&config_tree, config_node_compare, sizeof (config_node_t),
+ offsetof(config_node_t, cn_node));
+ config_finished = B_FALSE;
+}
+
+void
+finish_config(void)
+{
+ pthread_mutex_lock(&config_lock);
+ VERIFY(!config_finished);
+ config_finished = B_TRUE;
+ pthread_mutex_unlock(&config_lock);
+}
+
+static size_t
+process_config_value(const char *orig, char *buf, size_t buflen, uint_t depth)
+{
+ const char *vp;
+ size_t len = 0;
+
+ for (vp = orig; *vp != '\0'; vp++) {
+ config_node_t *cn = NULL;
+
+ if (*vp != '%') {
+ if (buf != NULL && buflen > 0) {
+ *buf = *vp;
+ buf++;
+ buflen--;
+ }
+ continue;
+ }
+ vp++;
+ if (*vp == '%') {
+ /* Escaped '%' */
+ len--;
+ continue;
+ }
+
+ /* reference to another value */
+ if (*vp == '(') {
+ const char *end;
+ size_t namelen;
+ char *namebuf = NULL;
+
+ vp++;
+ end = strchr(vp, ')');
+ if (end == NULL) {
+ warnx("Unclosed reference in \"%s\"", orig);
+ break;
+ }
+ namelen = (uintptr_t)end - (uintptr_t)vp + 1;
+ namebuf = malloc(namelen);
+ if (namebuf == NULL) {
+ errx(4, "Failed to allocate memory");
+ }
+ strlcpy(namebuf, vp, namelen);
+ cn = find_config_path(namebuf, NULL);
+ free(namebuf);
+ /* subtract length for name and %() delimiters */
+ len -= namelen + 2;
+ } else {
+ size_t namelen;
+
+ namelen = strlen(vp);
+ /* use the rest of the value as the key */
+ cn = find_config_path(vp, NULL);
+ /* subtract length for name and % delimiter */
+ len -= namelen + 1;
+ }
+
+ if (cn != NULL) {
+ size_t reflen;
+ const char *ref;
+
+ ref = expand_config_value(cn, depth + 1);
+ reflen = strlen(ref);
+ len += reflen;
+ if (buf != NULL && buflen >= reflen) {
+ (void) strncpy(buf, ref, reflen);
+ buf += reflen;
+ buflen -= reflen;
+ }
+ }
+ }
+
+ /* account for NUL terminator */
+ len++;
+ if (buf != NULL && buflen != 0) {
+ *buf = '\0';
+ }
+ return (len);
+}
+
+static const char *
+expand_config_value(config_node_t *cn, uint_t depth)
+{
+ const char *result = NULL;
+ char *buf;
+ size_t len, done_len;
+
+ if ((cn->cn_flags & CF_NEEDS_EXPAND) == 0) {
+ return (cn->cn_value_raw);
+ } else if ((cn->cn_flags & CF_EXPANDED) != 0) {
+ if (cn->cn_value_expanded != NULL) {
+ return (cn->cn_value_expanded);
+ } else {
+ return ("");
+ }
+ }
+
+ if (depth >= CONFIG_MAX_DEPTH) {
+ warnx("Exceeded max reference depth");
+ return ("");
+ }
+
+ if (depth == 0) {
+ pthread_mutex_lock(&config_lock);
+ } else {
+ ASSERT(pthread_mutex_isowned_np(&config_lock));
+ }
+
+ /*
+ * Double check that the value was not expanded while waiting to
+ * acquire the config_lock.
+ */
+ if ((cn->cn_flags & CF_EXPANDED) != 0) {
+ result = cn->cn_value_expanded;
+ goto done;
+ }
+
+ len = process_config_value(cn->cn_value_raw, NULL, 0, depth);
+ if (len == 0) {
+ /* Special case where expansion evaluates to empty */
+ cn->cn_flags = CF_EXPANDED;
+ cn->cn_value_expanded = NULL;
+ result = "";
+ goto done;
+ }
+
+ buf = malloc(len);
+ done_len = process_config_value(cn->cn_value_raw, buf, len, depth);
+ VERIFY3U(len, ==, done_len);
+
+ cn->cn_flags = CF_EXPANDED;
+ cn->cn_value_expanded = buf;
+ result = buf;
+
+done:
+ if (depth == 0) {
+ pthread_mutex_unlock(&config_lock);
+ }
+ return (result);
+}
+
+const char *
+get_config_value(const char *path)
+{
+ config_node_t *cn;
+
+ cn = find_config_path(path, NULL);
+ if (cn != NULL) {
+ return (expand_config_value(cn, 0));
+ }
+ return (NULL);
+}
+
+static config_node_t *
+find_config_path(const char *path, avl_index_t *idx)
+{
+ config_node_t search;
+
+ search.cn_path = path;
+ return (avl_find(&config_tree, &search, idx));
+}
+
+static config_node_t *
+set_config_raw(const char *path, const char *value)
+{
+ config_node_t *cn;
+ avl_index_t idx;
+
+ ASSERT(pthread_mutex_isowned_np(&config_lock));
+ VERIFY(!config_finished);
+
+ cn = find_config_path(path, &idx);
+
+ if (cn != NULL) {
+ /* overwrite node */
+ cn->cn_flags = 0;
+ free((void *)cn->cn_value_raw);
+ free((void *)cn->cn_value_expanded);
+ cn->cn_value_raw = strdup(value);
+ cn->cn_value_expanded = NULL;
+ if (cn->cn_value_raw == NULL) {
+ goto alloc_err;
+ }
+ } else {
+ /* insert node */
+ char *dpath, *dvalue;
+
+ cn = calloc(1, sizeof (*cn));
+ dpath = strdup(path);
+ dvalue = strdup(value);
+ if (cn == NULL || dpath == NULL || dvalue == NULL) {
+ goto alloc_err;
+ }
+ cn->cn_path = dpath;
+ cn->cn_value_raw = dvalue;
+ avl_insert(&config_tree, cn, idx);
+ }
+
+ if (strstr(cn->cn_value_raw, "%") != NULL) {
+ cn->cn_flags |= CF_NEEDS_EXPAND;
+ }
+ return (cn);
+
+alloc_err:
+ err(4, "Could not allocate memory");
+ return (NULL); /* not reached */
+}
+
+void
+set_config_value(const char *path, const char *value)
+{
+ pthread_mutex_lock(&config_lock);
+ (void) set_config_raw(path, value);
+ pthread_mutex_unlock(&config_lock);
+}
+
+void
+set_config_bool(const char *path, boolean_t value)
+{
+ config_node_t *cn;
+
+ pthread_mutex_lock(&config_lock);
+ cn = set_config_raw(path, value ? "true" : "false");
+ cn->cn_bool = value;
+ cn->cn_flags |= CF_BOOL_CHECKED;
+ pthread_mutex_unlock(&config_lock);
+}
+
+boolean_t
+get_config_bool(const char *path)
+{
+ config_node_t *cn;
+
+ cn = find_config_path(path, NULL);
+ if (cn == NULL) {
+ /* XXX: strictness? */
+ return (B_FALSE);
+ }
+
+ if (cn->cn_flags & CF_BOOL_CHECKED) {
+ return (cn->cn_bool);
+ } else {
+ const char *value;
+ boolean_t valid = B_FALSE;
+ boolean_t bval = B_FALSE;
+
+ value = expand_config_value(cn, 0);
+ if (strcasecmp(value, "true") == 0 ||
+ strcasecmp(value, "on") == 0 ||
+ strcasecmp(value, "yes") == 0 ||
+ strcmp(value, "1") == 0) {
+ bval = B_TRUE;
+ valid = B_TRUE;
+ } else if (strcasecmp(value, "false") == 0 ||
+ strcasecmp(value, "off") == 0 ||
+ strcasecmp(value, "no") == 0 ||
+ strcmp(value, "0") == 0) {
+ bval = B_FALSE;
+ valid = B_TRUE;
+ }
+
+ if (valid) {
+ pthread_mutex_lock(&config_lock);
+ cn->cn_bool = bval;
+ cn->cn_flags |= CF_BOOL_CHECKED;
+ pthread_mutex_unlock(&config_lock);
+ } else {
+ warnx("Invalid value %s for boolean variable %s",
+ value, path);
+ }
+ return (bval);
+ }
+}
+
+void
+dump_config(boolean_t do_expand)
+{
+ avl_tree_t *tree = &config_tree;
+ config_node_t *cn;
+
+ for (cn = avl_first(tree); cn != NULL; cn = AVL_NEXT(tree, cn)) {
+ const char *value;
+
+ if (do_expand) {
+ value = expand_config_value(cn, 0);
+ } else {
+ value = cn->cn_value_raw;
+ }
+ printf("%s=%s\n", cn->cn_path, value);
+ }
+}
diff --git a/usr/src/cmd/bhyve/inout.c b/usr/src/cmd/bhyve/inout.c
index 6587fcb9df..a00b5d58fa 100644
--- a/usr/src/cmd/bhyve/inout.c
+++ b/usr/src/cmd/bhyve/inout.c
@@ -125,7 +125,7 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit)
handler = inout_handlers[port].handler;
- if (handler == default_inout && get_config_bool("strictio"))
+ if (handler == default_inout && get_config_bool("x86.strict_io"))
return (-1);
flags = inout_handlers[port].flags;
diff --git a/usr/src/cmd/bhyve/pci_e82545.c b/usr/src/cmd/bhyve/pci_e82545.c
index e211b5cf9c..20f2fdb5f7 100644
--- a/usr/src/cmd/bhyve/pci_e82545.c
+++ b/usr/src/cmd/bhyve/pci_e82545.c
@@ -66,6 +66,7 @@ __FBSDID("$FreeBSD$");
#include "mii.h"
#include "bhyverun.h"
+#include "config.h"
#include "pci_emul.h"
#include "mevent.h"
@@ -2388,7 +2389,7 @@ e82545_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
*/
if (!mac_provided) {
snprintf(nstr, sizeof(nstr), "%d-%d-%s", pi->pi_slot,
- pi->pi_func, vmname);
+ pi->pi_func, get_config_value("name"));
MD5Init(&mdctx);
MD5Update(&mdctx, nstr, strlen(nstr));
diff --git a/usr/src/cmd/bhyve/smbiostbl.c b/usr/src/cmd/bhyve/smbiostbl.c
index 3a951d1be3..85b69b89ab 100644
--- a/usr/src/cmd/bhyve/smbiostbl.c
+++ b/usr/src/cmd/bhyve/smbiostbl.c
@@ -844,6 +844,7 @@ smbios_build(struct vmctx *ctx)
return (0);
}
+#ifndef __FreeBSD__
int
smbios_parse(const char *opts)
{
@@ -852,6 +853,8 @@ smbios_parse(const char *opts)
char *token;
char *end;
long type;
+ const char *guest_uuid_str = get_config_value("uuid");
+
struct {
const char *key;
const char **targetp;
@@ -862,7 +865,7 @@ smbios_parse(const char *opts)
{ "serial", &smbios_type1_strings[3] },
{ "sku", &smbios_type1_strings[4] },
{ "family", &smbios_type1_strings[5] },
- { "uuid", (const char **)&guest_uuid_str },
+ { "uuid", &guest_uuid_str },
{ 0 }
};
@@ -920,3 +923,4 @@ fail:
free(buf);
return (-1);
}
+#endif /* __FreeBSD__ */
diff --git a/usr/src/compat/freebsd/uuid.h b/usr/src/compat/freebsd/uuid.h
index 72ef2c7787..ed0ddee1e3 100644
--- a/usr/src/compat/freebsd/uuid.h
+++ b/usr/src/compat/freebsd/uuid.h
@@ -25,9 +25,9 @@
#define uuid_s_invalid_string_uuid 2
static __inline void
-uuid_from_string(char *str, uuid_t *uuidp, uint32_t *status)
+uuid_from_string(const char *str, uuid_t *uuidp, uint32_t *status)
{
- if (uuid_parse(str, *uuidp) == 0) {
+ if (uuid_parse((char *)str, *uuidp) == 0) {
*status = uuid_s_ok;
} else {
*status = uuid_s_invalid_string_uuid;