vhost_nvme: fix info dump
For namespace we need to use array of objects. Remove useless check for bdev != NULL as this is already guarded by ns_active. As we are here also switch to new JSON named API. Change-Id: If8ab15c63ea015731829276e06e5cb5a801620d2 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/409025 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
This commit is contained in:
parent
cbbec6dd16
commit
ebedb9fd25
@ -1029,35 +1029,27 @@ spdk_vhost_nvme_dump_info_json(struct spdk_vhost_dev *vdev, struct spdk_json_wri
|
||||
{
|
||||
struct spdk_vhost_nvme_dev *nvme = to_nvme_dev(vdev);
|
||||
struct spdk_vhost_nvme_ns *ns_dev;
|
||||
struct spdk_bdev *bdev;
|
||||
uint32_t i;
|
||||
|
||||
if (nvme == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_json_write_name(w, "namespaces");
|
||||
spdk_json_write_object_begin(w);
|
||||
spdk_json_write_named_array_begin(w, "namespaces");
|
||||
|
||||
for (i = 0; i < nvme->num_ns; i++) {
|
||||
ns_dev = &nvme->ns[i];
|
||||
if (!ns_dev->active_ns) {
|
||||
continue;
|
||||
}
|
||||
bdev = ns_dev->bdev;
|
||||
|
||||
spdk_json_write_name(w, "nsid");
|
||||
spdk_json_write_uint32(w, ns_dev->nsid);
|
||||
|
||||
spdk_json_write_name(w, "bdev");
|
||||
if (bdev) {
|
||||
spdk_json_write_string(w, spdk_bdev_get_name(bdev));
|
||||
} else {
|
||||
spdk_json_write_null(w);
|
||||
}
|
||||
spdk_json_write_object_begin(w);
|
||||
spdk_json_write_named_uint32(w, "nsid", ns_dev->nsid);
|
||||
spdk_json_write_named_string(w, "bdev", spdk_bdev_get_name(ns_dev->bdev));
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
spdk_json_write_array_end(w);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
x
Reference in New Issue
Block a user