Skip to content

CP-54444: Return MAC addresses to host installer #6466

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

Open
wants to merge 4 commits into
base: feature/host-network-device-ordering
Choose a base branch
from

Conversation

minglumlu
Copy link
Member

The host installer uses this utility to get the management interface from the management bridge. Now it changes to use MAC address(es) to find out the management interface(s). This is because the interface-rename functionality will be deprecated and the names of the network interfaces are not guaranteed to be the same between dom0 and host installer's running environment.

Note that this change must be delivered to a host before upgrading to a new version in which the interface-rename is deprecated because the host installer is built from the new version and it will not be able to find the management network interface by name if the networkd_db command returns only names generated by interface-rename.

Specifically, the "interface_order" field is only available when the networkd takes place of interface-rename to generate order. Before that, only the "bridge_mac" can be used because at that time, the host installer only uses one interface to setup its own networking during installation and no MAC addresses are recorded in networkd.db for individual interfaces. The "bridge_mac" is just the MAC address of one of the interfaces which construct the management bridge.

The host installer uses this utility to get the management interface
from the management bridge. Now it changes to use MAC address(es) to
find out the management interface(s). This is because the
interface-rename functionality will be deprecated and the names of the
network interfaces are not guaranteed to be the same between dom0 and
host installer's running environment.

Note that this change must be delivered to a host before upgrading to
a new version in which the interface-rename is deprecated because the
host installer is built from the new version and it will not be able to
find the management network interface by name if the networkd_db command
returns only names generated by interface-rename.

Specifically, the "interface_order" field is only available when the
networkd takes place of interface-rename to generate order. Before
that, only the "bridge_mac" can be used because at that time, the
host installer only uses one interface to setup its own networking
during installation and no MAC addresses are recorded in networkd.db
for individual interfaces. The "bridge_mac" is just the MAC address of
one of the interfaces which construct the management bridge.

Signed-off-by: Ming Lu <[email protected]>
@minglumlu
Copy link
Member Author

xenserver/host-installer#249 is for the host installer change.

Printf.fprintf stderr "%s\n" msg
| Ok macs -> (
Printf.printf "interfaces=%s\n" (String.concat "," ifaces) ;
Printf.printf "hwaddrs=%s\n" (String.concat "," (List.rev macs)) ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does adding this line work with the current script?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The current script doesn't care about any extra keys in the output.

@xapi-project xapi-project deleted a comment from MustardseedX May 16, 2025
@xapi-project xapi-project deleted a comment from MustardseedX May 16, 2025
@xapi-project xapi-project deleted a comment from MustardseedX May 16, 2025
@xapi-project xapi-project deleted a comment from MustardseedX May 16, 2025
in
Printf.printf "interfaces=%s\n" (String.concat "," ifaces) ;
match bridge_config.vlan with
( if !bridge <> "" then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the case of !bridge = "" not be handled as part of List.assoc_opt returning Null? I would try to reduce the deep nesting of conditions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to distinguish the cases that no -bridge option and -bridge <br> where <br> is an invalid one.

@lindig
Copy link
Contributor

lindig commented May 22, 2025

I would like @robhoes to take a look, too.

let r =
let* bridge = if !bridge = "" then Error Skip else Ok !bridge in
let* bridge_config =
match List.assoc_opt bridge config.bridge_config with
Copy link
Member

@psafont psafont May 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use |> Option.to_result ~none:error instead of the match, although that will construct the error every single time. It's a weak part of the API. It'd be nicer if it had been val to_error : none:(unit -> 'e) -> 'a option -> ('a, 'e) result

| None ->
Ok ()
| Some (parent, id) ->
Ok (Printf.printf "vlan=%d\nparent=%s\n" id parent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like using a side effect in the value position of Ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants