Add a 'host_iface' controller option.
Ported from nvme-cli.
Signed-off-by: Hannes Reinecke <hare@suse.de>
fprintf(stderr, "Failed to allocated memory\n");
return ENOMEM;
}
- c = nvme_create_ctrl(NVME_DISC_SUBSYS_NAME, "loop", NULL, NULL, NULL);
+ c = nvme_create_ctrl(NVME_DISC_SUBSYS_NAME, "loop",
+ NULL, NULL, NULL, NULL);
if (!c) {
fprintf(stderr, "Failed to allocate memory\n");
return ENOMEM;
nvme_ctrl_get_traddr(c)) ||
add_argument(argstr, "host_traddr",
nvme_ctrl_get_host_traddr(c)) ||
+ add_argument(argstr, "host_iface",
+ nvme_ctrl_get_host_iface(c)) ||
add_argument(argstr, "trsvcid",
nvme_ctrl_get_trsvcid(c)) ||
(hostnqn && add_argument(argstr, "hostnqn", hostnqn)) ||
nvme_msg(LOG_DEBUG, "lookup ctrl "
"(transport: %s, traddr: %s, trsvcid %s)\n",
transport, traddr, trsvcid);
- c = nvme_create_ctrl(e->subnqn, transport, traddr, NULL, trsvcid);
+ c = nvme_create_ctrl(e->subnqn, transport, traddr, NULL, NULL, trsvcid);
if (!c) {
nvme_msg(LOG_DEBUG, "skipping discovery entry, "
"failed to allocate %s controller with traddr %s\n",
nvme_ctrl_t c;
struct json_object *attr_obj;
const char *transport, *traddr = NULL;
- const char *host_traddr = NULL, *trsvcid = NULL;
+ const char *host_traddr = NULL, *host_iface = NULL, *trsvcid = NULL;
attr_obj = json_object_object_get(port_obj, "transport");
if (!attr_obj)
attr_obj = json_object_object_get(port_obj, "host_traddr");
if (attr_obj)
host_traddr = json_object_get_string(attr_obj);
+ attr_obj = json_object_object_get(port_obj, "host_iface");
+ if (attr_obj)
+ host_iface = json_object_get_string(attr_obj);
attr_obj = json_object_object_get(port_obj, "trsvcid");
if (attr_obj)
trsvcid = json_object_get_string(attr_obj);
- c = nvme_lookup_ctrl(s, transport, traddr,
- host_traddr, trsvcid);
+ c = nvme_lookup_ctrl(s, transport, traddr, host_traddr,
+ host_iface, trsvcid);
if (c) {
json_update_attributes(c, port_obj);
}
value = nvme_ctrl_get_host_traddr(c);
if (value)
json_object_add_value_string(port_obj, "host_traddr", value);
+ value = nvme_ctrl_get_host_iface(c);
+ if (value)
+ json_object_add_value_string(port_obj, "host_iface", value);
value = nvme_ctrl_get_trsvcid(c);
if (value)
json_object_add_value_string(port_obj, "trsvcid", value);
char *traddr;
char *trsvcid;
char *host_traddr;
+ char *host_iface;
bool discovered;
bool persistent;
struct nvme_fabrics_config cfg;
return c->host_traddr;
}
+const char *nvme_ctrl_get_host_iface(nvme_ctrl_t c)
+{
+ return c->host_iface;
+}
+
const char *nvme_ctrl_get_hostnqn(nvme_ctrl_t c)
{
if (!c->s)
free(c->trsvcid);
if (c->host_traddr)
free(c->host_traddr);
+ if (c->host_iface)
+ free(c->host_iface);
free(c->firmware);
free(c->model);
free(c->state);
freeaddrinfo(host_info);
}
-struct nvme_ctrl *nvme_create_ctrl(const char *subsysnqn,
- const char *transport, const char *traddr,
- const char *host_traddr, const char *trsvcid)
+struct nvme_ctrl *nvme_create_ctrl(const char *subsysnqn, const char *transport,
+ const char *traddr, const char *host_traddr,
+ const char *host_iface, const char *trsvcid)
{
struct nvme_ctrl *c;
bool discovery = false;
else
c->host_traddr = strdup(host_traddr);
}
+ if (host_iface)
+ c->host_iface = strdup(host_iface);
if (trsvcid)
c->trsvcid = strdup(trsvcid);
else if (discovery)
return c;
}
-struct nvme_ctrl *nvme_lookup_ctrl(struct nvme_subsystem *s,
- const char *transport, const char *traddr,
- const char *host_traddr, const char *trsvcid)
+struct nvme_ctrl *nvme_lookup_ctrl(struct nvme_subsystem *s, const char *transport,
+ const char *traddr, const char *host_traddr,
+ const char *host_iface, const char *trsvcid)
{
struct nvme_ctrl *c;
if (host_traddr && c->host_traddr &&
strcmp(c->host_traddr, host_traddr))
continue;
+ if (host_iface && c->host_iface &&
+ strcmp(c->host_iface, host_iface))
+ continue;
if (trsvcid && c->trsvcid &&
strcmp(c->trsvcid, trsvcid))
continue;
return c;
}
- c = nvme_create_ctrl(s->subsysnqn, transport,
- traddr, host_traddr, trsvcid);
+ c = nvme_create_ctrl(s->subsysnqn, transport, traddr,
+ host_traddr, host_iface, trsvcid);
if (c) {
c->s = s;
list_add(&s->ctrls, &c->entry);
{
nvme_ctrl_t c;
char *addr, *address, *a, *e;
- char *transport, *traddr = NULL, *trsvcid = NULL, *host_traddr = NULL;
+ char *transport, *traddr = NULL, *trsvcid = NULL;
+ char *host_traddr = NULL, *host_iface = NULL;
int ret;
transport = nvme_get_attr(path, "transport");
trsvcid = a + 8;
else if (!strncmp(a, "host_traddr=", 12))
host_traddr = a + 12;
+ else if (!strncmp(a, "host_iface=", 11))
+ host_iface = a + 12;
a = strtok_r(NULL, ",", &e);
}
- c = nvme_lookup_ctrl(s, transport, traddr, host_traddr, trsvcid);
+ c = nvme_lookup_ctrl(s, transport, traddr,
+ host_traddr, host_iface, trsvcid);
free(addr);
if (!c) {
errno = ENOMEM;
* @transport:
* @traddr:
* @host_traddr:
+ * @host_iface:
* @trsvcid:
*
* Return:
*/
nvme_ctrl_t nvme_lookup_ctrl(nvme_subsystem_t s, const char *transport,
const char *traddr, const char *host_traddr,
- const char *trsvcid);
+ const char *host_iface, const char *trsvcid);
/**
* @transport:
* @traddr:
* @host_traddr:
+ * @host_iface:
* @trsvcid:
*
* Return:
*/
nvme_ctrl_t nvme_create_ctrl(const char *subsysnqn, const char *transport,
const char *traddr, const char *host_traddr,
- const char *trsvcid);
+ const char *host_iface, const char *trsvcid);
/**
*/
const char *nvme_ctrl_get_host_traddr(nvme_ctrl_t c);
+/**
+ * nvme_ctrl_get_host_iface() -
+ * @c:
+ *
+ * Return:
+ */
+const char *nvme_ctrl_get_host_iface(nvme_ctrl_t c);
+
/**
* nvme_ctrl_get_config() -
* @c: