Skip to content

CA-411122: do not call set-iscsi-initiator with an empty string for IQN #6474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ocaml/xapi/xapi_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2790,6 +2790,7 @@ let set_uefi_certificates ~__context ~host:_ ~value:_ =
let set_iscsi_iqn ~__context ~host ~value =
if value = "" then
raise Api_errors.(Server_error (invalid_value, ["value"; value])) ;
D.debug "%s: iqn=%S" __FUNCTION__ value ;
(* Note, the following sequence is carefully written - see the
other-config watcher thread in xapi_host_helpers.ml *)
Db.Host.remove_from_other_config ~__context ~self:host ~key:"iscsi_iqn" ;
Expand Down
4 changes: 4 additions & 0 deletions ocaml/xapi/xapi_host_helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,13 @@ module Configuration = struct
[iqn; hostname_chopped]

let set_initiator_name iqn =
if iqn = "" then
raise Api_errors.(Server_error (invalid_value, ["iqn"; iqn])) ;
let hostname = Unix.gethostname () in
(* CA-377454 - robustness, create dir if necessary *)
Unixext.mkdir_rec "/var/lock/sm/iscsiadm" 0o700 ;
let args = make_set_initiator_args iqn hostname in
D.debug "%s: iqn=%S" __FUNCTION__ iqn ;
ignore (Helpers.call_script !Xapi_globs.set_iSCSI_initiator_script args)

let set_multipathing enabled =
Expand Down Expand Up @@ -541,6 +544,7 @@ module Configuration = struct
| Some "" ->
()
| Some iqn when iqn <> host_rec.API.host_iscsi_iqn ->
D.debug "%s: iqn=%S" __FUNCTION__ iqn ;
Client.Client.Host.set_iscsi_iqn ~rpc ~session_id ~host:host_ref
~value:iqn
| _ ->
Expand Down
Loading