Skip to content

Commit dc565fd

Browse files
authored
CP-51895: Drop FCoE support when fcoe_driver does not exists (#6202)
FCoE support will be removed from XS9 and dom0 will no longer provide fcoe_driver. However, XS8 still actively support it. Xapi checks the existence of fcoe_driver, and thinks all PIFs no longer support FCoE if fcoe_driver not found
2 parents 757079c + 71c87a1 commit dc565fd

File tree

3 files changed

+52
-37
lines changed

3 files changed

+52
-37
lines changed

ocaml/networkd/lib/network_utils.ml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,12 +1067,19 @@ module Fcoe = struct
10671067
let call ?log args = call_script ?log ~timeout:(Some 10.0) !fcoedriver args
10681068

10691069
let get_capabilities name =
1070-
try
1071-
let output = call ~log:false ["--xapi"; name; "capable"] in
1072-
if Astring.String.is_infix ~affix:"True" output then ["fcoe"] else []
1073-
with _ ->
1074-
debug "Failed to get fcoe support status on device %s" name ;
1075-
[]
1070+
match Sys.file_exists !fcoedriver with
1071+
| false ->
1072+
info "%s: %s not found, does not support FCoE" __FUNCTION__ !fcoedriver ;
1073+
[] (* Does not support FCoE *)
1074+
| true -> (
1075+
try
1076+
let output = call ~log:false ["--xapi"; name; "capable"] in
1077+
if Astring.String.is_infix ~affix:"True" output then ["fcoe"] else []
1078+
with _ ->
1079+
debug "%s: Failed to get fcoe support status on device %s" __FUNCTION__
1080+
name ;
1081+
[]
1082+
)
10761083
end
10771084

10781085
module Sysctl = struct

ocaml/xapi/xapi_globs.ml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,11 +1689,6 @@ module Resources = struct
16891689
; ("xsh", xsh, "Path to xsh binary")
16901690
; ("static-vdis", static_vdis, "Path to static-vdis script")
16911691
; ("xen-cmdline-script", xen_cmdline_script, "Path to xen-cmdline script")
1692-
; ( "fcoe-driver"
1693-
, fcoe_driver
1694-
, "Execute during PIF unplug to get the lun devices related with the \
1695-
ether interface of the PIF"
1696-
)
16971692
; ("list_domains", list_domains, "Path to the list_domains command")
16981693
; ("systemctl", systemctl, "Control the systemd system and service manager")
16991694
; ( "alert-certificate-check"
@@ -1797,6 +1792,12 @@ module Resources = struct
17971792
, "Path to yum-config-manager command"
17981793
)
17991794
; ("c_rehash", c_rehash, "Path to regenerate CA store")
1795+
(* Dropped since XS9, list here as XS8 still requires it *)
1796+
; ( "fcoe-driver"
1797+
, fcoe_driver
1798+
, "Execute during PIF unplug to get the lun devices related with the \
1799+
ether interface of the PIF"
1800+
)
18001801
]
18011802

18021803
let essential_files =

ocaml/xapi/xapi_pif.ml

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -319,33 +319,40 @@ let assert_no_other_local_pifs ~__context ~host ~network =
319319
)
320320

321321
let assert_fcoe_not_in_use ~__context ~self =
322-
let interface = Db.PIF.get_device ~__context ~self in
323-
let output, _ =
324-
Forkhelpers.execute_command_get_output !Xapi_globs.fcoe_driver
325-
["-t"; interface]
326-
in
327-
let output = String.trim output in
328-
debug "Scsi ids on %s are: %s" interface output ;
329-
let fcoe_scsids = Str.split (Str.regexp " ") output in
330-
Helpers.get_my_pbds __context
331-
|> List.iter (fun (_, pbd_rec) ->
332-
let sr = pbd_rec.API.pBD_SR in
333-
match Db.SR.get_type ~__context ~self:sr with
334-
| "lvmofcoe" -> (
335-
try
336-
let scsid = List.assoc "SCSIid" pbd_rec.API.pBD_device_config in
337-
if List.mem scsid fcoe_scsids then
338-
raise
339-
(Api_errors.Server_error
340-
( Api_errors.pif_has_fcoe_sr_in_use
341-
, [Ref.string_of self; Ref.string_of sr]
342-
)
343-
)
344-
with Not_found -> ()
322+
match Sys.file_exists !Xapi_globs.fcoe_driver with
323+
| false ->
324+
(* Does not support FCoE from XS9, presuming not in use
325+
* Upgrade plugin will block upgrade with FCoE in use *)
326+
debug "%s not found, does not support FCoE" !Xapi_globs.fcoe_driver
327+
| true ->
328+
let interface = Db.PIF.get_device ~__context ~self in
329+
let output, _ =
330+
Forkhelpers.execute_command_get_output !Xapi_globs.fcoe_driver
331+
["-t"; interface]
332+
in
333+
let output = String.trim output in
334+
debug "%s: SCSI ids on %s are: %s" __FUNCTION__ interface output ;
335+
let fcoe_scsids = Str.split (Str.regexp " ") output in
336+
Helpers.get_my_pbds __context
337+
|> List.iter (fun (_, pbd_rec) ->
338+
let sr = pbd_rec.API.pBD_SR in
339+
match Db.SR.get_type ~__context ~self:sr with
340+
| "lvmofcoe" -> (
341+
match List.assoc_opt "SCSIid" pbd_rec.API.pBD_device_config with
342+
| Some scsid ->
343+
if List.mem scsid fcoe_scsids then
344+
raise
345+
(Api_errors.Server_error
346+
( Api_errors.pif_has_fcoe_sr_in_use
347+
, [Ref.string_of self; Ref.string_of sr]
348+
)
349+
)
350+
| None ->
351+
()
352+
)
353+
| _ ->
354+
()
345355
)
346-
| _ ->
347-
()
348-
)
349356

350357
let find_or_create_network (bridge : string) (device : string) ~managed
351358
~__context =

0 commit comments

Comments
 (0)