bdev/nvme: Validate adrfam when printing out config file

Change-Id: Ibca68074005655f034d71f51b403e746525e922f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/408532
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2018-04-20 15:12:05 -07:00
parent a1bcc450f0
commit 106684ff45

View File

@ -1414,16 +1414,34 @@ bdev_nvme_get_spdk_running_config(FILE *fp)
"# Y is the NSID (starts at 1).\n");
TAILQ_FOREACH(nvme_ctrlr, &g_nvme_ctrlrs, tailq) {
const char *trtype;
trtype = spdk_nvme_transport_id_trtype_str(nvme_ctrlr->trid.trtype);
if (!trtype) {
continue;
}
if (nvme_ctrlr->trid.trtype == SPDK_NVME_TRANSPORT_PCIE) {
fprintf(fp, "TransportId \"trtype:%s traddr:%s\" %s\n",
spdk_nvme_transport_id_trtype_str(nvme_ctrlr->trid.trtype),
trtype,
nvme_ctrlr->trid.traddr, nvme_ctrlr->name);
} else {
fprintf(fp, "TransportId \"trtype:%s adrfam:%s traddr:%s trsvcid:%s subnqn:%s\" %s\n",
spdk_nvme_transport_id_trtype_str(nvme_ctrlr->trid.trtype),
spdk_nvme_transport_id_adrfam_str(nvme_ctrlr->trid.adrfam),
nvme_ctrlr->trid.traddr, nvme_ctrlr->trid.trsvcid,
nvme_ctrlr->trid.subnqn, nvme_ctrlr->name);
const char *adrfam;
adrfam = spdk_nvme_transport_id_adrfam_str(nvme_ctrlr->trid.adrfam);
if (adrfam) {
fprintf(fp, "TransportId \"trtype:%s adrfam:%s traddr:%s trsvcid:%s subnqn:%s\" %s\n",
trtype, adrfam,
nvme_ctrlr->trid.traddr, nvme_ctrlr->trid.trsvcid,
nvme_ctrlr->trid.subnqn, nvme_ctrlr->name);
} else {
fprintf(fp, "TransportId \"trtype:%s traddr:%s trsvcid:%s subnqn:%s\" %s\n",
trtype,
nvme_ctrlr->trid.traddr, nvme_ctrlr->trid.trsvcid,
nvme_ctrlr->trid.subnqn, nvme_ctrlr->name);
}
}
}