Index: usr.sbin/bhyve/block_if.h =================================================================== --- usr.sbin/bhyve/block_if.h +++ usr.sbin/bhyve/block_if.h @@ -38,9 +38,9 @@ #ifndef _BLOCK_IF_H_ #define _BLOCK_IF_H_ -#include #include #include +#include "config.h" struct vm_snapshot_meta; @@ -63,8 +63,8 @@ }; struct blockif_ctxt; -int blockif_legacy_config(nvlist_t *nvl, const char *opts); -struct blockif_ctxt *blockif_open(nvlist_t *nvl, const char *ident); +int blockif_legacy_config(config_node_t *node, const char *opts); +struct blockif_ctxt *blockif_open(config_node_t *node, const char *ident); off_t blockif_size(struct blockif_ctxt *bc); void blockif_chs(struct blockif_ctxt *bc, uint16_t *c, uint8_t *h, uint8_t *s); Index: usr.sbin/bhyve/block_if.c =================================================================== --- usr.sbin/bhyve/block_if.c +++ usr.sbin/bhyve/block_if.c @@ -430,7 +430,7 @@ } int -blockif_legacy_config(nvlist_t *nvl, const char *opts) +blockif_legacy_config(config_node_t *node, const char *opts) { char *cp, *path; @@ -439,17 +439,17 @@ cp = strchr(opts, ','); if (cp == NULL) { - set_config_value_node(nvl, "path", opts); + set_config_value_node(node, "path", opts); return (0); } path = strndup(opts, cp - opts); - set_config_value_node(nvl, "path", path); + set_config_value_node(node, "path", path); free(path); - return (pci_parse_legacy_config(nvl, cp + 1)); + return (pci_parse_legacy_config(node, cp + 1)); } struct blockif_ctxt * -blockif_open(nvlist_t *nvl, const char *ident) +blockif_open(config_node_t *node, const char *ident) { char tname[MAXCOMLEN + 1]; char name[MAXPATHLEN]; @@ -476,16 +476,16 @@ ro = 0; nodelete = 0; - if (get_config_bool_node_default(nvl, "nocache", false)) + if (get_config_bool_node_default(node, "nocache", false)) extra |= O_DIRECT; - if (get_config_bool_node_default(nvl, "nodelete", false)) + if (get_config_bool_node_default(node, "nodelete", false)) nodelete = 1; - if (get_config_bool_node_default(nvl, "sync", false) || - get_config_bool_node_default(nvl, "direct", false)) + if (get_config_bool_node_default(node, "sync", false) || + get_config_bool_node_default(node, "direct", false)) extra |= O_SYNC; - if (get_config_bool_node_default(nvl, "ro", false)) + if (get_config_bool_node_default(node, "ro", false)) ro = 1; - ssval = get_config_value_node(nvl, "sectorsize"); + ssval = get_config_value_node(node, "sectorsize"); if (ssval != NULL) { ssopt = strtol(ssval, &cp, 10); if (cp == ssval) { @@ -507,7 +507,7 @@ } } - path = get_config_value_node(nvl, "path"); + path = get_config_value_node(node, "path"); if (path == NULL) { EPRINTLN("Missing \"path\" for block device."); goto err; Index: usr.sbin/bhyve/config.h =================================================================== --- usr.sbin/bhyve/config.h +++ usr.sbin/bhyve/config.h @@ -45,7 +45,11 @@ * 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. - */ + */ + +typedef nvlist_t config_node_t; +#define NODE_TYPE_NODE NV_TYPE_NVLIST +#define NODE_TYPE_STRING NV_TYPE_STRING /* * Fetches the value of a configuration variable. If the "raw" value @@ -58,7 +62,8 @@ * * If 'parent' is NULL, 'name' is assumed to be a top-level variable. */ -const char *get_config_value_node(const nvlist_t *parent, const char *name); +const char *get_config_value_node(const config_node_t *parent, + const char *name); /* * Similar to get_config_value_node but expects a full path to the @@ -75,28 +80,30 @@ * variable. If the node already exists, this returns a pointer to * the existing node. */ -nvlist_t *create_config_node(const char *path); +config_node_t *create_config_node(const char *path); /* * Looks for an existing configuration node via a dot-separated OID * path. Will fail if the path names an existing leaf configuration * variable. */ -nvlist_t *find_config_node(const char *path); +config_node_t *find_config_node(const char *path); /* * Similar to the above, but treats the path relative to an existing * 'parent' node rather than as an absolute path. */ -nvlist_t *create_relative_config_node(nvlist_t *parent, const char *path); -nvlist_t *find_relative_config_node(nvlist_t *parent, const char *path); +config_node_t *create_relative_config_node(const config_node_t *parent, + const char *path); +config_node_t *find_relative_config_node(const config_node_t *parent, + const char *path); /* * 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, +void set_config_value_node(const config_node_t *parent, const char *name, const char *value); /* @@ -107,12 +114,17 @@ /* Convenience wrappers for boolean variables. */ bool get_config_bool(const char *path); -bool get_config_bool_node(const nvlist_t *parent, const char *name); +bool get_config_bool_node(const config_node_t *parent, const char *name); bool get_config_bool_default(const char *path, bool def); -bool get_config_bool_node_default(const nvlist_t *parent, const char *name, - bool def); +bool get_config_bool_node_default(const config_node_t *parent, + const char *name, bool def); void set_config_bool(const char *path, bool value); -void set_config_bool_node(nvlist_t *parent, const char *name, bool value); +void set_config_bool_node(config_node_t *parent, const char *name, + bool value); + +/* Node iterator. */ +const char *config_node_next(const config_node_t *node, int *type, + void **cookie); void dump_config(void); Index: usr.sbin/bhyve/config.c =================================================================== --- usr.sbin/bhyve/config.c +++ usr.sbin/bhyve/config.c @@ -36,19 +36,20 @@ #include "config.h" -static nvlist_t *config_root; +static config_node_t *config_root; void init_config(void) { + nvlist_t *nvl = nvlist_create(0); - config_root = nvlist_create(0); - if (config_root == NULL) + if (nvl == NULL) err(4, "Failed to create configuration root nvlist"); + config_root = (config_node_t *)nvl; } -static nvlist_t * -_lookup_config_node(nvlist_t *parent, const char *path, bool create) +static config_node_t * +_lookup_config_node(const config_node_t *parent, const char *path, bool create) { char *copy, *name, *tofree; nvlist_t *nvl, *new_nvl; @@ -57,7 +58,7 @@ if (copy == NULL) errx(4, "Failed to allocate memory"); tofree = copy; - nvl = parent; + nvl = (nvlist_t *)parent; while ((name = strsep(©, ".")) != NULL) { if (*name == '\0') { warnx("Invalid configuration node: %s", path); @@ -87,45 +88,47 @@ } } free(tofree); - return (nvl); + return ((config_node_t *)nvl); } -nvlist_t * +config_node_t * create_config_node(const char *path) { return (_lookup_config_node(config_root, path, true)); } -nvlist_t * +config_node_t * find_config_node(const char *path) { return (_lookup_config_node(config_root, path, false)); } -nvlist_t * -create_relative_config_node(nvlist_t *parent, const char *path) +config_node_t * +create_relative_config_node(const config_node_t *parent, const char *path) { return (_lookup_config_node(parent, path, true)); } -nvlist_t * -find_relative_config_node(nvlist_t *parent, const char *path) +config_node_t * +find_relative_config_node(const config_node_t *parent, const char *path) { return (_lookup_config_node(parent, path, false)); } void -set_config_value_node(nvlist_t *parent, const char *name, const char *value) +set_config_value_node(const config_node_t *node, const char *name, + const char *value) { + nvlist_t *parent = (nvlist_t *)node; if (strchr(name, '.') != NULL) errx(4, "Invalid config node name %s", name); if (parent == NULL) - parent = config_root; + parent = (nvlist_t *)config_root; if (nvlist_exists_string(parent, name)) nvlist_free_string(parent, name); else if (nvlist_exists(parent, name)) @@ -145,13 +148,13 @@ /* Look for last separator. */ name = strrchr(path, '.'); if (name == NULL) { - nvl = config_root; + nvl = (nvlist_t *)config_root; name = path; } else { node_name = strndup(path, name - path); if (node_name == NULL) errx(4, "Failed to allocate memory"); - nvl = create_config_node(node_name); + nvl = (nvlist_t *)create_config_node(node_name); if (nvl == NULL) errx(4, "Failed to create configuration node %s", node_name); @@ -164,7 +167,7 @@ if (nvlist_exists_nvlist(nvl, name)) errx(4, "Attempting to add value %s to existing node %s", value, path); - set_config_value_node(nvl, name, value); + set_config_value_node((config_node_t *)nvl, name, value); } static const char * @@ -177,13 +180,13 @@ /* Look for last separator. */ name = strrchr(path, '.'); if (name == NULL) { - nvl = config_root; + nvl = (nvlist_t *)config_root; name = path; } else { node_name = strndup(path, name - path); if (node_name == NULL) errx(4, "Failed to allocate memory"); - nvl = find_config_node(node_name); + nvl = (nvlist_t *)find_config_node(node_name); free(node_name); if (nvl == NULL) return (NULL); @@ -221,7 +224,7 @@ fputc('%', valfp); vp++; break; - } + } if (vp[1] != '(' || vp[2] == '\0') cp = NULL; else @@ -309,20 +312,21 @@ } const char * -get_config_value_node(const nvlist_t *parent, const char *name) +get_config_value_node(const config_node_t *parent, const char *name) { + nvlist_t *nvl = (nvlist_t *)parent; if (strchr(name, '.') != NULL) errx(4, "Invalid config node name %s", name); - if (parent == NULL) - parent = config_root; - if (nvlist_exists_nvlist(parent, name)) + if (nvl == NULL) + nvl = (nvlist_t *)config_root; + if (nvlist_exists_nvlist(nvl, name)) warnx("Attempt to fetch value of node %s of list %p", name, parent); - if (!nvlist_exists_string(parent, name)) + if (!nvlist_exists_string(nvl, name)) return (NULL); - return (expand_config_value(nvlist_get_string(parent, name))); + return (expand_config_value(nvlist_get_string(nvl, name))); } bool @@ -365,7 +369,7 @@ } bool -get_config_bool_node(const nvlist_t *parent, const char *name) +get_config_bool_node(const config_node_t *parent, const char *name) { const char *value; @@ -376,7 +380,7 @@ } bool -get_config_bool_node_default(const nvlist_t *parent, const char *name, +get_config_bool_node_default(const config_node_t *parent, const char *name, bool def) { const char *value; @@ -395,12 +399,20 @@ } void -set_config_bool_node(nvlist_t *parent, const char *name, bool value) +set_config_bool_node(config_node_t *parent, const char *name, bool value) { set_config_value_node(parent, name, value ? "true" : "false"); } +const char * +config_node_next(const config_node_t *node, int *type, void **cookie) +{ + nvlist_t *nvl = (nvlist_t *)node; + + return (nvlist_next(nvl, type, cookie)); +} + static void dump_tree(const char *prefix, const nvlist_t *nvl) { @@ -427,5 +439,5 @@ void dump_config(void) { - dump_tree("", config_root); + dump_tree("", (nvlist_t *)config_root); } Index: usr.sbin/bhyve/net_backends.h =================================================================== --- usr.sbin/bhyve/net_backends.h +++ usr.sbin/bhyve/net_backends.h @@ -37,9 +37,9 @@ /* Interface between network frontends and the network backends. */ typedef void (*net_be_rxeof_t)(int, enum ev_type, void *param); -int netbe_init(net_backend_t **be, nvlist_t *nvl, net_be_rxeof_t cb, +int netbe_init(net_backend_t **be, config_node_t *node, net_be_rxeof_t cb, void *param); -int netbe_legacy_config(nvlist_t *nvl, const char *opts); +int netbe_legacy_config(config_node_t *node, const char *opts); void netbe_cleanup(net_backend_t *be); uint64_t netbe_get_cap(net_backend_t *be); int netbe_set_cap(net_backend_t *be, uint64_t cap, Index: usr.sbin/bhyve/net_backends.c =================================================================== --- usr.sbin/bhyve/net_backends.c +++ usr.sbin/bhyve/net_backends.c @@ -98,7 +98,7 @@ * and should not be called by the frontend. */ int (*init)(struct net_backend *be, const char *devname, - nvlist_t *nvl, net_be_rxeof_t cb, void *param); + config_node_t *node, net_be_rxeof_t cb, void *param); void (*cleanup)(struct net_backend *be); /* @@ -206,7 +206,7 @@ static int tap_init(struct net_backend *be, const char *devname, - nvlist_t *nvl, net_be_rxeof_t cb, void *param) + config_node_t *node, net_be_rxeof_t cb, void *param) { struct tap_priv *priv = (struct tap_priv *)be->opaque; char tbuf[80]; @@ -400,7 +400,7 @@ static int ng_init(struct net_backend *be, const char *devname, - nvlist_t *nvl, net_be_rxeof_t cb, void *param) + config_node_t *node, net_be_rxeof_t cb, void *param) { struct tap_priv *p = (struct tap_priv *)be->opaque; struct ngm_connect ngc; @@ -423,26 +423,26 @@ memset(&ngc, 0, sizeof(ngc)); - value = get_config_value_node(nvl, "path"); + value = get_config_value_node(node, "path"); if (value == NULL) { WPRINTF(("path must be provided")); return (-1); } strncpy(ngc.path, value, NG_PATHSIZ - 1); - value = get_config_value_node(nvl, "hook"); + value = get_config_value_node(node, "hook"); if (value == NULL) value = "vmlink"; strncpy(ngc.ourhook, value, NG_HOOKSIZ - 1); - value = get_config_value_node(nvl, "peerhook"); + value = get_config_value_node(node, "peerhook"); if (value == NULL) { WPRINTF(("peer hook must be provided")); return (-1); } strncpy(ngc.peerhook, value, NG_HOOKSIZ - 1); - nodename = get_config_value_node(nvl, "socket"); + nodename = get_config_value_node(node, "socket"); if (NgMkSockNode(nodename, &ctrl_sock, &be->fd) < 0) { WPRINTF(("can't get Netgraph sockets")); @@ -633,7 +633,7 @@ static int netmap_init(struct net_backend *be, const char *devname, - nvlist_t *nvl, net_be_rxeof_t cb, void *param) + config_node_t *node, net_be_rxeof_t cb, void *param) { struct netmap_priv *priv = (struct netmap_priv *)be->opaque; @@ -894,7 +894,7 @@ DATA_SET(net_backend_set, vale_backend); int -netbe_legacy_config(nvlist_t *nvl, const char *opts) +netbe_legacy_config(config_node_t *node, const char *opts) { char *backend, *cp; @@ -903,13 +903,13 @@ cp = strchr(opts, ','); if (cp == NULL) { - set_config_value_node(nvl, "backend", opts); + set_config_value_node(node, "backend", opts); return (0); } backend = strndup(opts, cp - opts); - set_config_value_node(nvl, "backend", backend); + set_config_value_node(node, "backend", backend); free(backend); - return (pci_parse_legacy_config(nvl, cp + 1)); + return (pci_parse_legacy_config(node, cp + 1)); } /* @@ -925,7 +925,7 @@ * the argument for the callback. */ int -netbe_init(struct net_backend **ret, nvlist_t *nvl, net_be_rxeof_t cb, +netbe_init(struct net_backend **ret, config_node_t *node, net_be_rxeof_t cb, void *param) { struct net_backend **pbe, *nbe, *tbe = NULL; @@ -933,7 +933,7 @@ char *devname; int err; - value = get_config_value_node(nvl, "backend"); + value = get_config_value_node(node, "backend"); if (value == NULL) { return (-1); } @@ -971,7 +971,7 @@ nbe->fe_vnet_hdr_len = 0; /* Initialize the backend. */ - err = nbe->init(nbe, devname, nvl, cb, param); + err = nbe->init(nbe, devname, node, cb, param); if (err) { free(devname); free(nbe); Index: usr.sbin/bhyve/pci_ahci.c =================================================================== --- usr.sbin/bhyve/pci_ahci.c +++ usr.sbin/bhyve/pci_ahci.c @@ -2329,22 +2329,22 @@ * .path="/path/to/image" */ static int -pci_ahci_legacy_config_port(nvlist_t *nvl, int port, const char *type, +pci_ahci_legacy_config_port(config_node_t *node, int port, const char *type, const char *opts) { char node_name[sizeof("XX")]; - nvlist_t *port_nvl; + config_node_t *port_node; snprintf(node_name, sizeof(node_name), "%d", port); - port_nvl = create_relative_config_node(nvl, node_name); - set_config_value_node(port_nvl, "type", type); - return (blockif_legacy_config(port_nvl, opts)); + port_node = create_relative_config_node(node, node_name); + set_config_value_node(port_node, "type", type); + return (blockif_legacy_config(port_node, opts)); } static int -pci_ahci_legacy_config(nvlist_t *nvl, const char *opts) +pci_ahci_legacy_config(config_node_t *node, const char *opts) { - nvlist_t *ports_nvl; + config_node_t *ports_node; const char *type; char *next, *next2, *str, *tofree; int p, ret; @@ -2352,7 +2352,7 @@ if (opts == NULL) return (0); - ports_nvl = create_relative_config_node(nvl, "port"); + ports_node = create_relative_config_node(node, "port"); ret = 1; tofree = str = strdup(opts); for (p = 0; p < MAX_PORTS && str != NULL; p++, str = next) { @@ -2385,7 +2385,7 @@ goto out; } - if (pci_ahci_legacy_config_port(ports_nvl, p, type, str) != 0) + if (pci_ahci_legacy_config_port(ports_node, p, type, str) != 0) goto out; } ret = 0; @@ -2395,25 +2395,25 @@ } static int -pci_ahci_cd_legacy_config(nvlist_t *nvl, const char *opts) +pci_ahci_cd_legacy_config(config_node_t *node, const char *opts) { - nvlist_t *ports_nvl; + config_node_t *ports_node; - ports_nvl = create_relative_config_node(nvl, "port"); - return (pci_ahci_legacy_config_port(ports_nvl, 0, "cd", opts)); + ports_node = create_relative_config_node(node, "port"); + return (pci_ahci_legacy_config_port(ports_node, 0, "cd", opts)); } static int -pci_ahci_hd_legacy_config(nvlist_t *nvl, const char *opts) +pci_ahci_hd_legacy_config(config_node_t *node, const char *opts) { - nvlist_t *ports_nvl; + config_node_t *ports_node; - ports_nvl = create_relative_config_node(nvl, "port"); - return (pci_ahci_legacy_config_port(ports_nvl, 0, "hd", opts)); + ports_node = create_relative_config_node(node, "port"); + return (pci_ahci_legacy_config_port(ports_node, 0, "hd", opts)); } static int -pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_ahci_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { char bident[sizeof("XX:XX:XX")]; char node_name[sizeof("XX")]; @@ -2423,7 +2423,7 @@ MD5_CTX mdctx; u_char digest[16]; const char *path, *type, *value; - nvlist_t *ports_nvl, *port_nvl; + config_node_t *ports_node, *port_node; ret = 0; @@ -2439,17 +2439,17 @@ sc->pi = 0; slots = 32; - ports_nvl = find_relative_config_node(nvl, "port"); + ports_node = find_relative_config_node(node, "port"); for (p = 0; p < MAX_PORTS; p++) { struct ata_params *ata_ident = &sc->port[p].ata_ident; char ident[AHCI_PORT_IDENT]; snprintf(node_name, sizeof(node_name), "%d", p); - port_nvl = find_relative_config_node(ports_nvl, node_name); - if (port_nvl == NULL) + port_node = find_relative_config_node(ports_node, node_name); + if (port_node == NULL) continue; - type = get_config_value_node(port_nvl, "type"); + type = get_config_value_node(port_node, "type"); if (type == NULL) continue; @@ -2465,7 +2465,7 @@ snprintf(bident, sizeof(bident), "%d:%d:%d", pi->pi_slot, pi->pi_func, p); - bctxt = blockif_open(port_nvl, bident); + bctxt = blockif_open(port_node, bident); if (bctxt == NULL) { sc->ports = p; ret = 1; @@ -2480,7 +2480,7 @@ * Create an identifier for the backing file. * Use parts of the md5 sum of the filename */ - path = get_config_value_node(port_nvl, "path"); + path = get_config_value_node(port_node, "path"); MD5Init(&mdctx); MD5Update(&mdctx, path, strlen(path)); MD5Final(digest, &mdctx); @@ -2496,16 +2496,16 @@ ata_string((uint8_t*)&ata_ident->model, "BHYVE SATA DVD ROM", 40); else ata_string((uint8_t*)&ata_ident->model, "BHYVE SATA DISK", 40); - value = get_config_value_node(port_nvl, "nmrr"); + value = get_config_value_node(port_node, "nmrr"); if (value != NULL) ata_ident->media_rotation_rate = atoi(value); - value = get_config_value_node(port_nvl, "ser"); + value = get_config_value_node(port_node, "ser"); if (value != NULL) ata_string((uint8_t*)(&ata_ident->serial), value, 20); - value = get_config_value_node(port_nvl, "rev"); + value = get_config_value_node(port_node, "rev"); if (value != NULL) ata_string((uint8_t*)(&ata_ident->revision), value, 8); - value = get_config_value_node(port_nvl, "model"); + value = get_config_value_node(port_node, "model"); if (value != NULL) ata_string((uint8_t*)(&ata_ident->model), value, 40); ata_identify_init(&sc->port[p], atapi); Index: usr.sbin/bhyve/pci_e82545.c =================================================================== --- usr.sbin/bhyve/pci_e82545.c +++ usr.sbin/bhyve/pci_e82545.c @@ -2278,7 +2278,7 @@ } static int -e82545_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +e82545_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { char nstr[80]; struct e82545_softc *sc; @@ -2309,7 +2309,7 @@ pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_NORMAL); pci_set_cfgdata8(pi, PCIR_INTPIN, 0x1); - + /* TODO: this card also supports msi, but the freebsd driver for it * does not, so I have not implemented it. */ pci_lintr_request(pi); @@ -2321,7 +2321,7 @@ pci_emul_alloc_bar(pi, E82545_BAR_IO, PCIBAR_IO, E82545_BAR_IO_LEN); - mac = get_config_value_node(nvl, "mac"); + mac = get_config_value_node(node, "mac"); if (mac != NULL) { err = net_parsemac(mac, sc->esc_mac.octet); if (err) { @@ -2331,7 +2331,7 @@ } else net_genmac(pi, sc->esc_mac.octet); - err = netbe_init(&sc->esc_be, nvl, e82545_rx_callback, sc); + err = netbe_init(&sc->esc_be, node, e82545_rx_callback, sc); if (err) { free(sc); return (err); Index: usr.sbin/bhyve/pci_emul.h =================================================================== --- usr.sbin/bhyve/pci_emul.h +++ usr.sbin/bhyve/pci_emul.h @@ -34,13 +34,14 @@ #include #include #include -#include #include #include #include +#include "config.h" + #define PCI_BARMAX PCIR_MAX_BAR_0 /* BAR registers in a Type 0 header */ struct vmctx; @@ -53,8 +54,8 @@ /* instance creation */ int (*pe_init)(struct vmctx *, struct pci_devinst *, - nvlist_t *); - int (*pe_legacy_config)(nvlist_t *, const char *); + config_node_t *); + int (*pe_legacy_config)(config_node_t *, const char *); const char *pe_alias; /* ACPI DSDT enumeration */ @@ -243,7 +244,7 @@ int pci_msix_table_bar(struct pci_devinst *pi); int pci_msix_pba_bar(struct pci_devinst *pi); int pci_msi_maxmsgnum(struct pci_devinst *pi); -int pci_parse_legacy_config(nvlist_t *nvl, const char *opt); +int pci_parse_legacy_config(config_node_t *node, const char *opt); int pci_parse_slot(char *opt); void pci_print_supported_devices(); void pci_populate_msicap(struct msicap *cap, int msgs, int nextptr); Index: usr.sbin/bhyve/pci_emul.c =================================================================== --- usr.sbin/bhyve/pci_emul.c +++ usr.sbin/bhyve/pci_emul.c @@ -74,7 +74,7 @@ #define MAXFUNCS (PCI_FUNCMAX + 1) struct funcinfo { - nvlist_t *fi_config; + config_node_t *fi_config; struct pci_devemu *fi_pde; struct pci_devinst *fi_devi; }; @@ -178,7 +178,7 @@ * of true. */ int -pci_parse_legacy_config(nvlist_t *nvl, const char *opt) +pci_parse_legacy_config(config_node_t *node, const char *opt) { char *config, *name, *tofree, *value; @@ -191,9 +191,9 @@ if (value != NULL) { *value = '\0'; value++; - set_config_value_node(nvl, name, value); + set_config_value_node(node, name, value); } else - set_config_bool_node(nvl, name, true); + set_config_bool_node(node, name, true); } free(tofree); return (0); @@ -220,7 +220,7 @@ struct pci_devemu *pde; char *emul, *config, *str, *cp; int error, bnum, snum, fnum; - nvlist_t *nvl; + config_node_t *node; error = -1; str = strdup(opt); @@ -266,22 +266,22 @@ snprintf(node_name, sizeof(node_name), "pci.%d.%d.%d", bnum, snum, fnum); - nvl = find_config_node(node_name); - if (nvl != NULL) { + node = find_config_node(node_name); + if (node != NULL) { EPRINTLN("pci slot %d:%d:%d already occupied!", bnum, snum, fnum); goto done; } - nvl = create_config_node(node_name); + node = create_config_node(node_name); if (pde->pe_alias != NULL) - set_config_value_node(nvl, "device", pde->pe_alias); + set_config_value_node(node, "device", pde->pe_alias); else - set_config_value_node(nvl, "device", pde->pe_emu); + set_config_value_node(node, "device", pde->pe_emu); if (pde->pe_legacy_config != NULL) - error = pde->pe_legacy_config(nvl, config); + error = pde->pe_legacy_config(node, config); else - error = pci_parse_legacy_config(nvl, config); + error = pci_parse_legacy_config(node, config); done: free(str); return (error); @@ -1143,7 +1143,7 @@ struct businfo *bi; struct slotinfo *si; struct funcinfo *fi; - nvlist_t *nvl; + config_node_t *node; const char *emul; size_t lowmem; uint64_t cpu_maxphysaddr, pci_emul_memresv64; @@ -1168,8 +1168,8 @@ for (bus = 0; bus < MAXBUSES; bus++) { snprintf(node_name, sizeof(node_name), "pci.%d", bus); - nvl = find_config_node(node_name); - if (nvl == NULL) + node = find_config_node(node_name); + if (node == NULL) continue; pci_businfo[bus] = calloc(1, sizeof(struct businfo)); bi = pci_businfo[bus]; @@ -1188,12 +1188,12 @@ fi = &si->si_funcs[func]; snprintf(node_name, sizeof(node_name), "pci.%d.%d.%d", bus, slot, func); - nvl = find_config_node(node_name); - if (nvl == NULL) + node = find_config_node(node_name); + if (node == NULL) continue; - fi->fi_config = nvl; - emul = get_config_value_node(nvl, "device"); + fi->fi_config = node; + emul = get_config_value_node(node, "device"); if (emul == NULL) { EPRINTLN("pci slot %d:%d:%d: missing " "\"device\" value", bus, slot, func); @@ -2252,7 +2252,7 @@ #define PCI_EMUL_MSIX_MSGS 16 static int -pci_emul_dinit(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_emul_dinit(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { int error; struct pci_emul_dsoftc *sc; Index: usr.sbin/bhyve/pci_fbuf.c =================================================================== --- usr.sbin/bhyve/pci_fbuf.c +++ usr.sbin/bhyve/pci_fbuf.c @@ -241,17 +241,17 @@ static int -pci_fbuf_parse_config(struct pci_fbuf_softc *sc, nvlist_t *nvl) +pci_fbuf_parse_config(struct pci_fbuf_softc *sc, config_node_t *node) { const char *value; char *cp; - sc->rfb_wait = get_config_bool_node_default(nvl, "wait", false); + sc->rfb_wait = get_config_bool_node_default(node, "wait", false); /* Prefer "rfb" to "tcp". */ - value = get_config_value_node(nvl, "rfb"); + value = get_config_value_node(node, "rfb"); if (value == NULL) - value = get_config_value_node(nvl, "tcp"); + value = get_config_value_node(node, "tcp"); if (value != NULL) { /* * IPv4 -- host-ip:port @@ -299,7 +299,7 @@ } } - value = get_config_value_node(nvl, "vga"); + value = get_config_value_node(node, "vga"); if (value != NULL) { if (strcmp(value, "off") == 0) { sc->vga_enabled = 0; @@ -315,7 +315,7 @@ } } - value = get_config_value_node(nvl, "w"); + value = get_config_value_node(node, "w"); if (value != NULL) { sc->memregs.width = atoi(value); if (sc->memregs.width > COLS_MAX) { @@ -326,7 +326,7 @@ sc->memregs.width = 1920; } - value = get_config_value_node(nvl, "h"); + value = get_config_value_node(node, "h"); if (value != NULL) { sc->memregs.height = atoi(value); if (sc->memregs.height > ROWS_MAX) { @@ -338,7 +338,7 @@ sc->memregs.height = 1080; } - value = get_config_value_node(nvl, "password"); + value = get_config_value_node(node, "password"); if (value != NULL) sc->rfb_password = strdup(value); @@ -373,7 +373,7 @@ } static int -pci_fbuf_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_fbuf_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { int error, prot; struct pci_fbuf_softc *sc; @@ -413,7 +413,7 @@ sc->fsc_pi = pi; - error = pci_fbuf_parse_config(sc, nvl); + error = pci_fbuf_parse_config(sc, node); if (error != 0) goto done; Index: usr.sbin/bhyve/pci_hda.c =================================================================== --- usr.sbin/bhyve/pci_hda.c +++ usr.sbin/bhyve/pci_hda.c @@ -148,7 +148,7 @@ static inline void hda_set_field_by_offset(struct hda_softc *sc, uint32_t offset, uint32_t mask, uint32_t value); -static struct hda_softc *hda_init(nvlist_t *nvl); +static struct hda_softc *hda_init(config_node_t *node); static void hda_update_intr(struct hda_softc *sc); static void hda_response_interrupt(struct hda_softc *sc); static int hda_codec_constructor(struct hda_softc *sc, @@ -209,7 +209,7 @@ /* * PCI HDA function declarations */ -static int pci_hda_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl); +static int pci_hda_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node); static void pci_hda_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx, uint64_t offset, int size, uint64_t value); static uint64_t pci_hda_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, @@ -318,7 +318,7 @@ } static struct hda_softc * -hda_init(nvlist_t *nvl) +hda_init(config_node_t *node) { struct hda_softc *sc = NULL; struct hda_codec_class *codec = NULL; @@ -343,12 +343,12 @@ */ codec = hda_find_codec_class("hda_codec"); if (codec) { - value = get_config_value_node(nvl, "play"); + value = get_config_value_node(node, "play"); if (value == NULL) play = NULL; else play = strdup(value); - value = get_config_value_node(nvl, "rec"); + value = get_config_value_node(node, "rec"); if (value == NULL) rec = NULL; else @@ -1224,7 +1224,7 @@ * PCI HDA function definitions */ static int -pci_hda_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_hda_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct hda_softc *sc = NULL; @@ -1246,7 +1246,7 @@ /* allocate an IRQ pin for our slot */ pci_lintr_request(pi); - sc = hda_init(nvl); + sc = hda_init(node); if (!sc) return (-1); Index: usr.sbin/bhyve/pci_hostbridge.c =================================================================== --- usr.sbin/bhyve/pci_hostbridge.c +++ usr.sbin/bhyve/pci_hostbridge.c @@ -37,7 +37,8 @@ #include "pci_emul.h" static int -pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, + config_node_t *node) { const char *value; u_int vendor, device; @@ -45,10 +46,10 @@ vendor = 0x1275; /* NetApp */ device = 0x1275; /* NetApp */ - value = get_config_value_node(nvl, "vendor"); + value = get_config_value_node(node, "vendor"); if (value != NULL) vendor = strtol(value, NULL, 0); - value = get_config_value_node(nvl, "devid"); + value = get_config_value_node(node, "devid"); if (value != NULL) device = strtol(value, NULL, 0); @@ -65,11 +66,11 @@ } static int -pci_amd_hostbridge_legacy_config(nvlist_t *nvl, const char *opts) +pci_amd_hostbridge_legacy_config(config_node_t *node, const char *opts) { - set_config_value_node(nvl, "vendor", "0x1022"); /* AMD */ - set_config_value_node(nvl, "devid", "0x7432"); /* made up */ + set_config_value_node(node, "vendor", "0x1022"); /* AMD */ + set_config_value_node(node, "devid", "0x7432"); /* made up */ return (0); } Index: usr.sbin/bhyve/pci_lpc.c =================================================================== --- usr.sbin/bhyve/pci_lpc.c +++ usr.sbin/bhyve/pci_lpc.c @@ -422,7 +422,7 @@ #define LPC_VENDOR 0x8086 static int -pci_lpc_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_lpc_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { /* Index: usr.sbin/bhyve/pci_nvme.c =================================================================== --- usr.sbin/bhyve/pci_nvme.c +++ usr.sbin/bhyve/pci_nvme.c @@ -2612,7 +2612,7 @@ } static int -pci_nvme_parse_config(struct pci_nvme_softc *sc, nvlist_t *nvl) +pci_nvme_parse_config(struct pci_nvme_softc *sc, config_node_t *node) { char bident[sizeof("XX:X:X")]; const char *value; @@ -2628,10 +2628,10 @@ snprintf(sc->ctrldata.sn, sizeof(sc->ctrldata.sn), "NVME-%d-%d", sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func); - value = get_config_value_node(nvl, "maxq"); + value = get_config_value_node(node, "maxq"); if (value != NULL) sc->max_queues = atoi(value); - value = get_config_value_node(nvl, "qsz"); + value = get_config_value_node(node, "qsz"); if (value != NULL) { sc->max_qentries = atoi(value); if (sc->max_qentries <= 0) { @@ -2640,7 +2640,7 @@ return (-1); } } - value = get_config_value_node(nvl, "ioslots"); + value = get_config_value_node(node, "ioslots"); if (value != NULL) { sc->ioslots = atoi(value); if (sc->ioslots <= 0) { @@ -2648,10 +2648,10 @@ return (-1); } } - value = get_config_value_node(nvl, "sectsz"); + value = get_config_value_node(node, "sectsz"); if (value != NULL) sectsz = atoi(value); - value = get_config_value_node(nvl, "ser"); + value = get_config_value_node(node, "ser"); if (value != NULL) { /* * This field indicates the Product Serial Number in @@ -2661,10 +2661,10 @@ cpywithpad((char *)sc->ctrldata.sn, sizeof(sc->ctrldata.sn), value, ' '); } - value = get_config_value_node(nvl, "eui64"); + value = get_config_value_node(node, "eui64"); if (value != NULL) sc->nvstore.eui64 = htobe64(strtoull(value, NULL, 0)); - value = get_config_value_node(nvl, "dsm"); + value = get_config_value_node(node, "dsm"); if (value != NULL) { if (strcmp(value, "auto") == 0) sc->dataset_management = NVME_DATASET_MANAGEMENT_AUTO; @@ -2674,7 +2674,7 @@ sc->dataset_management = NVME_DATASET_MANAGEMENT_DISABLE; } - value = get_config_value_node(nvl, "ram"); + value = get_config_value_node(node, "ram"); if (value != NULL) { uint64_t sz = strtoull(value, NULL, 10); @@ -2690,7 +2690,7 @@ } else { snprintf(bident, sizeof(bident), "%d:%d", sc->nsc_pi->pi_slot, sc->nsc_pi->pi_func); - sc->nvstore.ctx = blockif_open(nvl, bident); + sc->nvstore.ctx = blockif_open(node, bident); if (sc->nvstore.ctx == NULL) { EPRINTLN("nvme: Could not open backing file: %s", strerror(errno)); @@ -2715,7 +2715,7 @@ } static int -pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_nvme_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct pci_nvme_softc *sc; uint32_t pci_membar_sz; @@ -2727,7 +2727,7 @@ pi->pi_arg = sc; sc->nsc_pi = pi; - error = pci_nvme_parse_config(sc, nvl); + error = pci_nvme_parse_config(sc, node); if (error < 0) goto done; else Index: usr.sbin/bhyve/pci_passthru.c =================================================================== --- usr.sbin/bhyve/pci_passthru.c +++ usr.sbin/bhyve/pci_passthru.c @@ -619,7 +619,7 @@ } static int -passthru_legacy_config(nvlist_t *nvl, const char *opts) +passthru_legacy_config(config_node_t *node, const char *opts) { char value[16]; int bus, slot, func; @@ -633,16 +633,16 @@ } snprintf(value, sizeof(value), "%d", bus); - set_config_value_node(nvl, "bus", value); + set_config_value_node(node, "bus", value); snprintf(value, sizeof(value), "%d", slot); - set_config_value_node(nvl, "slot", value); + set_config_value_node(node, "slot", value); snprintf(value, sizeof(value), "%d", func); - set_config_value_node(nvl, "func", value); + set_config_value_node(node, "func", value); return (0); } static int -passthru_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +passthru_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { int bus, slot, func, error, memflags; struct passthru_softc *sc; @@ -712,7 +712,7 @@ #endif #define GET_INT_CONFIG(var, name) do { \ - value = get_config_value_node(nvl, name); \ + value = get_config_value_node(node, name); \ if (value == NULL) { \ EPRINTLN("passthru: missing required %s setting", name); \ return (error); \ Index: usr.sbin/bhyve/pci_uart.c =================================================================== --- usr.sbin/bhyve/pci_uart.c +++ usr.sbin/bhyve/pci_uart.c @@ -90,16 +90,16 @@ } static int -pci_uart_legacy_config(nvlist_t *nvl, const char *opts) +pci_uart_legacy_config(config_node_t *node, const char *opts) { if (opts != NULL) - set_config_value_node(nvl, "path", opts); + set_config_value_node(node, "path", opts); return (0); } static int -pci_uart_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_uart_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct uart_softc *sc; const char *device; @@ -115,7 +115,7 @@ sc = uart_init(pci_uart_intr_assert, pci_uart_intr_deassert, pi); pi->pi_arg = sc; - device = get_config_value_node(nvl, "path"); + device = get_config_value_node(node, "path"); if (uart_set_backend(sc, device) != 0) { EPRINTLN("Unable to initialize backend '%s' for " "pci uart at %d:%d", device, pi->pi_slot, pi->pi_func); Index: usr.sbin/bhyve/pci_virtio_9p.c =================================================================== --- usr.sbin/bhyve/pci_virtio_9p.c +++ usr.sbin/bhyve/pci_virtio_9p.c @@ -222,7 +222,7 @@ } static int -pci_vt9p_legacy_config(nvlist_t *nvl, const char *opts) +pci_vt9p_legacy_config(config_node_t *node, const char *opts) { char *sharename, *tofree, *token, *tokens; @@ -239,17 +239,17 @@ } sharename = strsep(&token, "="); - set_config_value_node(nvl, "sharename", sharename); - set_config_value_node(nvl, "path", token); + set_config_value_node(node, "sharename", sharename); + set_config_value_node(node, "path", token); } else - set_config_bool_node(nvl, token, true); + set_config_bool_node(node, token, true); } free(tofree); return (0); } static int -pci_vt9p_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_vt9p_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct pci_vt9p_softc *sc; const char *value; @@ -258,9 +258,9 @@ bool ro; cap_rights_t rootcap; - ro = get_config_bool_node_default(nvl, "ro", false); + ro = get_config_bool_node_default(node, "ro", false); - value = get_config_value_node(nvl, "path"); + value = get_config_value_node(node, "path"); if (value == NULL) { EPRINTLN("virtio-9p: path required"); return (1); @@ -272,7 +272,7 @@ return (-1); } - sharename = get_config_value_node(nvl, "sharename"); + sharename = get_config_value_node(node, "sharename"); if (sharename == NULL) { EPRINTLN("virtio-9p: share name required"); return (1); Index: usr.sbin/bhyve/pci_virtio_block.c =================================================================== --- usr.sbin/bhyve/pci_virtio_block.c +++ usr.sbin/bhyve/pci_virtio_block.c @@ -437,7 +437,7 @@ } static int -pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { char bident[sizeof("XX:X:X")]; struct blockif_ctxt *bctxt; @@ -452,7 +452,7 @@ * The supplied backing file has to exist */ snprintf(bident, sizeof(bident), "%d:%d", pi->pi_slot, pi->pi_func); - bctxt = blockif_open(nvl, bident); + bctxt = blockif_open(node, bident); if (bctxt == NULL) { perror("Could not open backing file"); return (1); @@ -489,7 +489,7 @@ * Create an identifier for the backing file. Use parts of the * md5 sum of the filename */ - path = get_config_value_node(nvl, "path"); + path = get_config_value_node(node, "path"); MD5Init(&mdctx); MD5Update(&mdctx, path, strlen(path)); MD5Final(digest, &mdctx); Index: usr.sbin/bhyve/pci_virtio_console.c =================================================================== --- usr.sbin/bhyve/pci_virtio_console.c +++ usr.sbin/bhyve/pci_virtio_console.c @@ -273,7 +273,7 @@ static int pci_vtcon_sock_add(struct pci_vtcon_softc *sc, const char *port_name, - const nvlist_t *nvl) + const config_node_t *node) { struct pci_vtcon_sock *sock; struct sockaddr_un sun; @@ -292,7 +292,7 @@ goto out; } - path = get_config_value_node(nvl, "path"); + path = get_config_value_node(node, "path"); if (path == NULL) { EPRINTLN("vtcon: required path missing for port %ld", port); error = -1; @@ -351,7 +351,7 @@ errx(EX_OSERR, "Unable to apply rights for sandbox"); #endif - name = get_config_value_node(nvl, "name"); + name = get_config_value_node(node, "name"); if (name == NULL) { EPRINTLN("vtcon: required name missing for port %ld", port); error = -1; @@ -641,11 +641,11 @@ * each port. Ports are numbered starting at 0. */ static int -pci_vtcon_legacy_config_port(nvlist_t *nvl, int port, char *opt) +pci_vtcon_legacy_config_port(config_node_t *node, int port, char *opt) { char *name, *path; char node_name[sizeof("XX")]; - nvlist_t *port_nvl; + config_node_t *port_node; name = strsep(&opt, "="); path = opt; @@ -658,25 +658,25 @@ return (-1); } snprintf(node_name, sizeof(node_name), "%d", port); - port_nvl = create_relative_config_node(nvl, node_name); - set_config_value_node(port_nvl, "name", name); - set_config_value_node(port_nvl, "path", path); + port_node = create_relative_config_node(node, node_name); + set_config_value_node(port_node, "name", name); + set_config_value_node(port_node, "path", path); return (0); } static int -pci_vtcon_legacy_config(nvlist_t *nvl, const char *opts) +pci_vtcon_legacy_config(config_node_t *node, const char *opts) { char *opt, *str, *tofree; - nvlist_t *ports_nvl; + config_node_t *ports_node; int error, port; - ports_nvl = create_relative_config_node(nvl, "port"); + ports_node = create_relative_config_node(node, "port"); tofree = str = strdup(opts); error = 0; port = 0; while ((opt = strsep(&str, ",")) != NULL) { - error = pci_vtcon_legacy_config_port(ports_nvl, port, opt); + error = pci_vtcon_legacy_config_port(ports_node, port, opt); if (error) break; port++; @@ -686,10 +686,10 @@ } static int -pci_vtcon_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_vtcon_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct pci_vtcon_softc *sc; - nvlist_t *ports_nvl; + config_node_t *ports_node; int i; sc = calloc(1, sizeof(struct pci_vtcon_softc)); @@ -726,20 +726,20 @@ sc->vsc_control_port.vsp_cb = pci_vtcon_control_tx; sc->vsc_control_port.vsp_enabled = true; - ports_nvl = find_relative_config_node(nvl, "port"); - if (ports_nvl != NULL) { + ports_node = find_relative_config_node(node, "port"); + if (ports_node != NULL) { const char *name; void *cookie; int type; cookie = NULL; - while ((name = nvlist_next(ports_nvl, &type, &cookie)) != + while ((name = config_node_next(ports_node, &type, &cookie)) != NULL) { - if (type != NV_TYPE_NVLIST) + if (type != NODE_TYPE_NODE) continue; if (pci_vtcon_sock_add(sc, name, - nvlist_get_nvlist(ports_nvl, name)) < 0) { + find_relative_config_node(ports_node, name)) < 0) { EPRINTLN("cannot create port %s: %s", name, strerror(errno)); return (1); Index: usr.sbin/bhyve/pci_virtio_net.c =================================================================== --- usr.sbin/bhyve/pci_virtio_net.c +++ usr.sbin/bhyve/pci_virtio_net.c @@ -561,7 +561,7 @@ #endif static int -pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct pci_vtnet_softc *sc; const char *value; @@ -588,7 +588,7 @@ sc->vsc_queues[VTNET_CTLQ].vq_notify = pci_vtnet_ping_ctlq; #endif - value = get_config_value_node(nvl, "mac"); + value = get_config_value_node(node, "mac"); if (value != NULL) { err = net_parsemac(value, sc->vsc_config.mac); if (err) { @@ -598,7 +598,7 @@ } else net_genmac(pi, sc->vsc_config.mac); - value = get_config_value_node(nvl, "mtu"); + value = get_config_value_node(node, "mtu"); if (value != NULL) { err = net_parsemtu(value, &mtu); if (err) { @@ -617,8 +617,8 @@ sc->vsc_config.mtu = mtu; /* Permit interfaces without a configured backend. */ - if (get_config_value_node(nvl, "backend") != NULL) { - err = netbe_init(&sc->vsc_be, nvl, pci_vtnet_rx_callback, sc); + if (get_config_value_node(node, "backend") != NULL) { + err = netbe_init(&sc->vsc_be, node, pci_vtnet_rx_callback, sc); if (err) { free(sc); return (err); Index: usr.sbin/bhyve/pci_virtio_rnd.c =================================================================== --- usr.sbin/bhyve/pci_virtio_rnd.c +++ usr.sbin/bhyve/pci_virtio_rnd.c @@ -143,7 +143,7 @@ static int -pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct pci_vtrnd_softc *sc; int fd; Index: usr.sbin/bhyve/pci_virtio_scsi.c =================================================================== --- usr.sbin/bhyve/pci_virtio_scsi.c +++ usr.sbin/bhyve/pci_virtio_scsi.c @@ -245,7 +245,7 @@ static void pci_vtscsi_requestq_notify(void *, struct vqueue_info *); static int pci_vtscsi_init_queue(struct pci_vtscsi_softc *, struct pci_vtscsi_queue *, int); -static int pci_vtscsi_init(struct vmctx *, struct pci_devinst *, nvlist_t *); +static int pci_vtscsi_init(struct vmctx *, struct pci_devinst *, config_node_t *); static struct virtio_consts vtscsi_vi_consts = { "vtscsi", /* our name */ @@ -658,34 +658,34 @@ } static int -pci_vtscsi_legacy_config(nvlist_t *nvl, const char *opts) +pci_vtscsi_legacy_config(config_node_t *node, const char *opts) { char *cp, *devname; cp = strchr(opts, ','); if (cp == NULL) { - set_config_value_node(nvl, "dev", opts); + set_config_value_node(node, "dev", opts); return (0); } devname = strndup(opts, cp - opts); - set_config_value_node(nvl, "dev", devname); + set_config_value_node(node, "dev", devname); free(devname); - return (pci_parse_legacy_config(nvl, cp + 1)); + return (pci_parse_legacy_config(node, cp + 1)); } static int -pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_vtscsi_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct pci_vtscsi_softc *sc; const char *devname, *value;; int i; sc = calloc(1, sizeof(struct pci_vtscsi_softc)); - value = get_config_value_node(nvl, "iid"); + value = get_config_value_node(node, "iid"); if (value != NULL) sc->vss_iid = strtoul(value, NULL, 10); - devname = get_config_value_node(nvl, "dev"); + devname = get_config_value_node(node, "dev"); if (devname == NULL) devname = "/dev/cam/ctl"; sc->vss_ctl_fd = open(devname, O_RDWR); Index: usr.sbin/bhyve/pci_xhci.c =================================================================== --- usr.sbin/bhyve/pci_xhci.c +++ usr.sbin/bhyve/pci_xhci.c @@ -2659,17 +2659,17 @@ * .device="tablet" */ static int -pci_xhci_legacy_config(nvlist_t *nvl, const char *opts) +pci_xhci_legacy_config(config_node_t *node, const char *opts) { char node_name[16]; - nvlist_t *slots_nvl, *slot_nvl; + config_node_t *slots_node, *slot_node; char *cp, *opt, *str, *tofree; int slot; if (opts == NULL) return (0); - slots_nvl = create_relative_config_node(nvl, "slot"); + slots_node = create_relative_config_node(node, "slot"); slot = 1; tofree = str = strdup(opts); while ((opt = strsep(&str, ",")) != NULL) { @@ -2682,26 +2682,26 @@ snprintf(node_name, sizeof(node_name), "%d", slot); slot++; - slot_nvl = create_relative_config_node(slots_nvl, node_name); - set_config_value_node(slot_nvl, "device", opt); + slot_node = create_relative_config_node(slots_node, node_name); + set_config_value_node(slot_node, "device", opt); /* * NB: Given that we split on commas above, the legacy * format only supports a single option. */ if (cp != NULL && *cp != '\0') - pci_parse_legacy_config(slot_nvl, cp); + pci_parse_legacy_config(slot_node, cp); } free(tofree); return (0); } static int -pci_xhci_parse_devices(struct pci_xhci_softc *sc, nvlist_t *nvl) +pci_xhci_parse_devices(struct pci_xhci_softc *sc, config_node_t *node) { struct pci_xhci_dev_emu *dev; struct usb_devemu *ue; - const nvlist_t *slots_nvl, *slot_nvl; + const config_node_t *slots_node, *slot_node; const char *name, *device; char *cp; void *devsc, *cookie; @@ -2720,12 +2720,12 @@ ndevices = 0; - slots_nvl = find_relative_config_node(nvl, "slot"); - if (slots_nvl == NULL) + slots_node = find_relative_config_node(node, "slot"); + if (slots_node == NULL) goto portsfinal; cookie = NULL; - while ((name = nvlist_next(slots_nvl, &type, &cookie)) != NULL) { + while ((name = config_node_next(slots_node, &type, &cookie)) != NULL) { if (usb2_port == ((sc->usb2_port_start) + XHCI_MAX_DEVS/2) || usb3_port == ((sc->usb3_port_start) + XHCI_MAX_DEVS/2)) { WPRINTF(("pci_xhci max number of USB 2 or 3 " @@ -2733,7 +2733,7 @@ goto bad; } - if (type != NV_TYPE_NVLIST) { + if (type != NODE_TYPE_NODE) { EPRINTLN( "pci_xhci: config variable '%s' under slot node", name); @@ -2751,8 +2751,8 @@ goto bad; } - slot_nvl = nvlist_get_nvlist(slots_nvl, name); - device = get_config_value_node(slot_nvl, "device"); + slot_node = find_relative_config_node(slots_node, name); + device = get_config_value_node(slot_node, "device"); if (device == NULL) { EPRINTLN( "pci_xhci: missing \"device\" value for slot '%s'", @@ -2797,7 +2797,7 @@ XHCI_DEVINST_PTR(sc, dev->hci.hci_port) = dev; dev->hci.hci_address = 0; - devsc = ue->ue_init(&dev->hci, nvl); + devsc = ue->ue_init(&dev->hci, node); if (devsc == NULL) { goto bad; } @@ -2834,7 +2834,7 @@ } static int -pci_xhci_init(struct vmctx *ctx, struct pci_devinst *pi, nvlist_t *nvl) +pci_xhci_init(struct vmctx *ctx, struct pci_devinst *pi, config_node_t *node) { struct pci_xhci_softc *sc; int error; @@ -2853,7 +2853,7 @@ sc->usb3_port_start = 1; /* discover devices */ - error = pci_xhci_parse_devices(sc, nvl); + error = pci_xhci_parse_devices(sc, node); if (error < 0) goto done; else Index: usr.sbin/bhyve/usb_emul.h =================================================================== --- usr.sbin/bhyve/usb_emul.h +++ usr.sbin/bhyve/usb_emul.h @@ -31,10 +31,10 @@ #ifndef _USB_EMUL_H_ #define _USB_EMUL_H_ -#include #include #include #include +#include "config.h" #define USB_MAX_XFER_BLOCKS 8 @@ -54,7 +54,7 @@ int ue_usbspeed; /* usb device speed */ /* instance creation */ - void *(*ue_init)(struct usb_hci *hci, nvlist_t *nvl); + void *(*ue_init)(struct usb_hci *hci, config_node_t *node); /* handlers */ int (*ue_request)(void *sc, struct usb_data_xfer *xfer); Index: usr.sbin/bhyve/usb_mouse.c =================================================================== --- usr.sbin/bhyve/usb_mouse.c +++ usr.sbin/bhyve/usb_mouse.c @@ -297,7 +297,7 @@ } static void * -umouse_init(struct usb_hci *hci, nvlist_t *nvl) +umouse_init(struct usb_hci *hci, config_node_t *node) { struct umouse_softc *sc;