diff --git a/ocaml/networkd/lib/network_utils.ml b/ocaml/networkd/lib/network_utils.ml index 4a473b29579..b6c696ea896 100644 --- a/ocaml/networkd/lib/network_utils.ml +++ b/ocaml/networkd/lib/network_utils.ml @@ -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 diff --git a/ocaml/xapi/xapi_globs.ml b/ocaml/xapi/xapi_globs.ml index efdcabfbdb6..23cc4e95c39 100644 --- a/ocaml/xapi/xapi_globs.ml +++ b/ocaml/xapi/xapi_globs.ml @@ -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" @@ -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 = diff --git a/ocaml/xapi/xapi_pif.ml b/ocaml/xapi/xapi_pif.ml index a2383ed9d9b..0284a134a68 100644 --- a/ocaml/xapi/xapi_pif.ml +++ b/ocaml/xapi/xapi_pif.ml @@ -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 =