Skip to content

CP-51895: Drop FCoE support when fcoe_driver does not exists #6202

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 2 commits into from
Jan 7, 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
19 changes: 13 additions & 6 deletions ocaml/networkd/lib/network_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1067,12 +1067,19 @@ module Fcoe = struct
let call ?log args = call_script ?log ~timeout:(Some 10.0) !fcoedriver args

let get_capabilities name =
try
let output = call ~log:false ["--xapi"; name; "capable"] in
if Astring.String.is_infix ~affix:"True" output then ["fcoe"] else []
with _ ->
debug "Failed to get fcoe support status on device %s" name ;
[]
match Sys.file_exists !fcoedriver with
| false ->
info "%s: %s not found, does not support FCoE" __FUNCTION__ !fcoedriver ;
[] (* Does not support FCoE *)
| true -> (
try
let output = call ~log:false ["--xapi"; name; "capable"] in
if Astring.String.is_infix ~affix:"True" output then ["fcoe"] else []
with _ ->
debug "%s: Failed to get fcoe support status on device %s" __FUNCTION__
name ;
[]
)
end

module Sysctl = struct
Expand Down
11 changes: 6 additions & 5 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1689,11 +1689,6 @@ module Resources = struct
; ("xsh", xsh, "Path to xsh binary")
; ("static-vdis", static_vdis, "Path to static-vdis script")
; ("xen-cmdline-script", xen_cmdline_script, "Path to xen-cmdline script")
; ( "fcoe-driver"
, fcoe_driver
, "Execute during PIF unplug to get the lun devices related with the \
ether interface of the PIF"
)
; ("list_domains", list_domains, "Path to the list_domains command")
; ("systemctl", systemctl, "Control the systemd system and service manager")
; ( "alert-certificate-check"
Expand Down Expand Up @@ -1797,6 +1792,12 @@ module Resources = struct
, "Path to yum-config-manager command"
)
; ("c_rehash", c_rehash, "Path to regenerate CA store")
(* Dropped since XS9, list here as XS8 still requires it *)
; ( "fcoe-driver"
, fcoe_driver
, "Execute during PIF unplug to get the lun devices related with the \
ether interface of the PIF"
)
]

let essential_files =
Expand Down
59 changes: 33 additions & 26 deletions ocaml/xapi/xapi_pif.ml
Original file line number Diff line number Diff line change
Expand Up @@ -319,33 +319,40 @@ let assert_no_other_local_pifs ~__context ~host ~network =
)

let assert_fcoe_not_in_use ~__context ~self =
let interface = Db.PIF.get_device ~__context ~self in
let output, _ =
Forkhelpers.execute_command_get_output !Xapi_globs.fcoe_driver
["-t"; interface]
in
let output = String.trim output in
debug "Scsi ids on %s are: %s" interface output ;
let fcoe_scsids = Str.split (Str.regexp " ") output in
Helpers.get_my_pbds __context
|> List.iter (fun (_, pbd_rec) ->
let sr = pbd_rec.API.pBD_SR in
match Db.SR.get_type ~__context ~self:sr with
| "lvmofcoe" -> (
try
let scsid = List.assoc "SCSIid" pbd_rec.API.pBD_device_config in
if List.mem scsid fcoe_scsids then
raise
(Api_errors.Server_error
( Api_errors.pif_has_fcoe_sr_in_use
, [Ref.string_of self; Ref.string_of sr]
)
)
with Not_found -> ()
match Sys.file_exists !Xapi_globs.fcoe_driver with
| false ->
(* Does not support FCoE from XS9, presuming not in use
* Upgrade plugin will block upgrade with FCoE in use *)
debug "%s not found, does not support FCoE" !Xapi_globs.fcoe_driver
| true ->
let interface = Db.PIF.get_device ~__context ~self in
let output, _ =
Forkhelpers.execute_command_get_output !Xapi_globs.fcoe_driver
["-t"; interface]
in
let output = String.trim output in
debug "%s: SCSI ids on %s are: %s" __FUNCTION__ interface output ;
let fcoe_scsids = Str.split (Str.regexp " ") output in
Helpers.get_my_pbds __context
|> List.iter (fun (_, pbd_rec) ->
let sr = pbd_rec.API.pBD_SR in
match Db.SR.get_type ~__context ~self:sr with
| "lvmofcoe" -> (
match List.assoc_opt "SCSIid" pbd_rec.API.pBD_device_config with
| Some scsid ->
if List.mem scsid fcoe_scsids then
raise
(Api_errors.Server_error
( Api_errors.pif_has_fcoe_sr_in_use
, [Ref.string_of self; Ref.string_of sr]
)
)
| None ->
()
)
| _ ->
()
)
| _ ->
()
)

let find_or_create_network (bridge : string) (device : string) ~managed
~__context =
Expand Down
Loading