char *subsysnqn = NVME_DISC_SUBSYS_NAME;
char *hostnqn = NULL, *hostid = NULL, *hostkey = NULL, *ctrlkey = NULL;
char *transport = NULL, *traddr = NULL, *trsvcid = NULL;
- char *hnqn = NULL, *hid = NULL;
char *config_file = PATH_NVMF_CONFIG;
enum nvme_print_flags flags;
nvme_root_t r;
set_discovery_kato(&cfg);
if (!hostnqn)
- hostnqn = hnqn = nvmf_hostnqn_from_file();
+ hostnqn = nvmf_hostnqn_from_file();
+ if (!hostnqn)
+ hostnqn = nvmf_hostnqn_generate();
if (!hostid)
- hostid = hid = nvmf_hostid_from_file();
+ hostid = nvmf_hostid_from_file();
h = nvme_lookup_host(r, hostnqn, hostid);
if (!h) {
ret = ENOMEM;
out_free_ctrl:
nvme_free_ctrl(c);
out_free:
- if (hnqn)
- free(hnqn);
- if (hid)
- free(hid);
+ free(hostnqn);
+ free(hostid);
if (dump_config)
nvme_dump_config(r);
nvme_free_tree(r);
int nvmf_connect(const char *desc, int argc, char **argv)
{
- char *hnqn = NULL, *hid = NULL;
char *subsysnqn = NULL;
char *transport = NULL, *traddr = NULL;
char *trsvcid = NULL, *hostnqn = NULL, *hostid = NULL;
nvme_read_config(r, config_file);
if (!hostnqn)
- hostnqn = hnqn = nvmf_hostnqn_from_file();
+ hostnqn = nvmf_hostnqn_from_file();
+ if (!hostnqn)
+ hostnqn = nvmf_hostnqn_generate();
if (!hostid)
- hostid = hid = nvmf_hostid_from_file();
+ hostid = nvmf_hostid_from_file();
h = nvme_lookup_host(r, hostnqn, hostid);
if (!h) {
errno = ENOMEM;
}
out_free:
- if (hnqn)
- free(hnqn);
- if (hid)
- free(hid);
+ free(hostnqn);
+ free(hostid);
if (dump_config)
nvme_dump_config(r);
nvme_free_tree(r);