Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/pci_virtio_9p.c
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Lines | for (int i = 0; i < n; i++) { | ||||
iov[i].iov_len)); | iov[i].iov_len)); | ||||
} | } | ||||
l9p_connection_recv(sc->vsc_conn, iov, preq->vsr_respidx, preq); | l9p_connection_recv(sc->vsc_conn, iov, preq->vsr_respidx, preq); | ||||
} | } | ||||
} | } | ||||
static int | 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; | char *sharename, *tofree, *token, *tokens; | ||||
if (opts == NULL) | if (opts == NULL) | ||||
return (0); | return (0); | ||||
tokens = tofree = strdup(opts); | tokens = tofree = strdup(opts); | ||||
while ((token = strsep(&tokens, ",")) != NULL) { | while ((token = strsep(&tokens, ",")) != NULL) { | ||||
if (strchr(token, '=') != NULL) { | if (strchr(token, '=') != NULL) { | ||||
if (sharename != NULL) { | if (sharename != NULL) { | ||||
EPRINTLN( | EPRINTLN( | ||||
"virtio-9p: more than one share name given"); | "virtio-9p: more than one share name given"); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
sharename = strsep(&token, "="); | sharename = strsep(&token, "="); | ||||
set_config_value_node(nvl, "sharename", sharename); | set_config_value_node(node, "sharename", sharename); | ||||
set_config_value_node(nvl, "path", token); | set_config_value_node(node, "path", token); | ||||
} else | } else | ||||
set_config_bool_node(nvl, token, true); | set_config_bool_node(node, token, true); | ||||
} | } | ||||
free(tofree); | free(tofree); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | 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; | struct pci_vt9p_softc *sc; | ||||
const char *value; | const char *value; | ||||
const char *sharename; | const char *sharename; | ||||
int rootfd; | int rootfd; | ||||
bool ro; | bool ro; | ||||
cap_rights_t rootcap; | 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) { | if (value == NULL) { | ||||
EPRINTLN("virtio-9p: path required"); | EPRINTLN("virtio-9p: path required"); | ||||
return (1); | return (1); | ||||
} | } | ||||
rootfd = open(value, O_DIRECTORY); | rootfd = open(value, O_DIRECTORY); | ||||
if (rootfd < 0) { | if (rootfd < 0) { | ||||
EPRINTLN("virtio-9p: failed to open '%s': %s", value, | EPRINTLN("virtio-9p: failed to open '%s': %s", value, | ||||
strerror(errno)); | strerror(errno)); | ||||
return (-1); | return (-1); | ||||
} | } | ||||
sharename = get_config_value_node(nvl, "sharename"); | sharename = get_config_value_node(node, "sharename"); | ||||
if (sharename == NULL) { | if (sharename == NULL) { | ||||
EPRINTLN("virtio-9p: share name required"); | EPRINTLN("virtio-9p: share name required"); | ||||
return (1); | return (1); | ||||
} | } | ||||
if (strlen(sharename) > VT9P_MAXTAGSZ) { | if (strlen(sharename) > VT9P_MAXTAGSZ) { | ||||
EPRINTLN("virtio-9p: share name too long"); | EPRINTLN("virtio-9p: share name too long"); | ||||
return (1); | return (1); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |