"description": "NVMe host ID",
"type": "string"
},
+ "hostsymname": {
+ "description": "NVMe host symbolic name",
+ "type": "string"
+ },
"required": [ "hostnqn" ],
"subsystems": {
"description": "Array of NVMe subsystem properties",
struct nvme_host {
%immutable hostnqn;
%immutable hostid;
+ %immutable hostsymname;
char *hostnqn;
char *hostid;
+ char *hostsymname;
char *dhchap_key;
};
%extend nvme_host {
nvme_host(struct nvme_root *r, const char *hostnqn = NULL,
- const char *hostid = NULL) {
- if (!hostnqn)
- return nvme_default_host(r);
- return nvme_lookup_host(r, hostnqn, hostid);
+ const char *hostid = NULL, const char *hostsymname = NULL) {
+
+ nvme_host_t h = hostnqn ? nvme_lookup_host(r, hostnqn, hostid) : nvme_default_host(r);
+ if (hostsymname)
+ nvme_host_set_hostsymname(h, hostsymname);
+ return h;
}
~nvme_host() {
nvme_free_host($self);
}
+%define SET_SYMNAME_DOCSTRING
+"@brief Set or Clear Host's Symbolic Name
+
+@param hostsymname: A symbolic name, or None to clear the symbolic name.
+@type hostsymname: str|None
+
+@return: None"
+%enddef
+ %feature("autodoc", SET_SYMNAME_DOCSTRING) set_symname;
+ void set_symname(const char *hostsymname) {
+ nvme_host_set_hostsymname($self, hostsymname);
+ }
char *__str__() {
static char tmp[2048];
nvme_host_get_dhchap_key;
nvme_host_get_hostid;
nvme_host_get_hostnqn;
+ nvme_host_get_hostsymname;
nvme_host_get_root;
nvme_host_set_dhchap_key;
+ nvme_host_set_hostsymname;
nvme_identify;
nvme_identify_active_ns_list;
nvme_identify_allocated_ns;
attr_obj = json_object_object_get(host_obj, "dhchap_key");
if (attr_obj)
nvme_host_set_dhchap_key(h, json_object_get_string(attr_obj));
+ attr_obj = json_object_object_get(host_obj, "hostsymname");
+ if (attr_obj)
+ nvme_host_set_hostsymname(h, json_object_get_string(attr_obj));
subsys_array = json_object_object_get(host_obj, "subsystems");
if (!subsys_array)
return;
json_root = json_object_new_array();
nvme_for_each_host(r, h) {
nvme_subsystem_t s;
- const char *hostnqn, *hostid, *dhchap_key;
+ const char *hostnqn, *hostid, *dhchap_key, *hostsymname;
host_obj = json_object_new_object();
if (!host_obj)
if (dhchap_key)
json_object_object_add(host_obj, "dhchap_key",
json_object_new_string(dhchap_key));
+ hostsymname = nvme_host_get_hostsymname(h);
+ if (hostsymname)
+ json_object_object_add(host_obj, "hostsymname",
+ json_object_new_string(hostsymname));
subsys_array = json_object_new_array();
nvme_for_each_subsystem(h, s) {
json_update_subsys(subsys_array, s);
char *hostnqn;
char *hostid;
char *dhchap_key;
+ char *hostsymname;
};
struct nvme_root {
hostid = nvmf_hostid_from_file();
h = nvme_lookup_host(r, hostnqn, hostid);
+
+ nvme_host_set_hostsymname(h, NULL);
+
default_host = h;
free(hostnqn);
if (hostid)
return h->hostid;
}
+const char *nvme_host_get_hostsymname(nvme_host_t h)
+{
+ return h->hostsymname;
+}
+
+void nvme_host_set_hostsymname(nvme_host_t h, const char *hostsymname)
+{
+ if (h->hostsymname) {
+ free(h->hostsymname);
+ h->hostsymname = NULL;
+ }
+ if (hostsymname)
+ h->hostsymname = strdup(hostsymname);
+}
+
const char *nvme_host_get_dhchap_key(nvme_host_t h)
{
return h->dhchap_key;
free(h->hostid);
if (h->dhchap_key)
free(h->dhchap_key);
+ nvme_host_set_hostsymname(h, NULL);
h->r->modified = true;
free(h);
}
*/
nvme_ns_t nvme_scan_namespace(const char *name);
+/**
+ * nvme_host_get_hostsymname() - Get the host's symbolic name
+ * @h: Host for which the symbolic name should be returned.
+ *
+ * Return: The symbolic name or NULL if a symbolic name hasn't been
+ * configure.
+ */
+const char *nvme_host_get_hostsymname(nvme_host_t h);
+
+/**
+ * nvme_host_set_hostsymname() - Set the host's symbolic name
+ * @h: Host for which the symbolic name should be set.
+ * @hostsymname: Symbolic name
+ */
+void nvme_host_set_hostsymname(nvme_host_t h, const char *hostsymname);
+
#endif /* _LIBNVME_TREE_H */