@@ -97,6 +97,9 @@ static void json_parse_port(nvme_subsystem_t s, struct json_object *port_obj)
9797 c = nvme_lookup_ctrl (s , transport , traddr , host_traddr ,
9898 host_iface , trsvcid );
9999 if (c ) {
100+ attr_obj = json_object_object_get (port_obj , "dhchap_key" );
101+ if (attr_obj )
102+ nvme_ctrl_set_dhchap_key (c , json_object_get_string (attr_obj ));
100103 json_update_attributes (c , port_obj );
101104 }
102105}
@@ -139,6 +142,9 @@ static void json_parse_host(nvme_root_t r, struct json_object *host_obj)
139142 if (attr_obj )
140143 hostid = json_object_get_string (attr_obj );
141144 h = nvme_lookup_host (r , hostnqn , hostid );
145+ attr_obj = json_object_object_get (host_obj , "dhchap_key" );
146+ if (attr_obj )
147+ nvme_host_set_dhchap_key (h , json_object_get_string (attr_obj ));
142148 subsys_array = json_object_object_get (host_obj , "subsystems" );
143149 if (!subsys_array )
144150 return ;
@@ -194,6 +200,10 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c)
194200 value = nvme_ctrl_get_trsvcid (c );
195201 if (value )
196202 json_object_add_value_string (port_obj , "trsvcid" , value );
203+ value = nvme_ctrl_get_dhchap_key (c );
204+ if (value )
205+ json_object_add_value_string (port_obj , "dhchap_key" ,
206+ value );
197207 JSON_INT_OPTION (cfg , port_obj , nr_io_queues , 0 );
198208 JSON_INT_OPTION (cfg , port_obj , nr_write_queues , 0 );
199209 JSON_INT_OPTION (cfg , port_obj , nr_poll_queues , 0 );
@@ -252,7 +262,7 @@ int json_update_config(nvme_root_t r, const char *config_file)
252262 json_root = json_object_new_array ();
253263 nvme_for_each_host (r , h ) {
254264 nvme_subsystem_t s ;
255- const char * hostid ;
265+ const char * hostid , * dhchap_key ;
256266
257267 host_obj = json_object_new_object ();
258268 json_object_add_value_string (host_obj , "hostnqn" ,
@@ -261,6 +271,10 @@ int json_update_config(nvme_root_t r, const char *config_file)
261271 if (hostid )
262272 json_object_add_value_string (host_obj , "hostid" ,
263273 hostid );
274+ dhchap_key = nvme_host_get_dhchap_key (h );
275+ if (dhchap_key )
276+ json_object_add_value_string (host_obj , "dhchap_key" ,
277+ dhchap_key );
264278 subsys_array = json_object_new_array ();
265279 nvme_for_each_subsystem (h , s ) {
266280 json_update_subsys (subsys_array , s );
0 commit comments