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 3 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.

Comment on lines 35 to 36
if List.mem_assoc !bridge config.bridge_config then
let bridge_config = List.assoc !bridge config.bridge_config in
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if List.mem_assoc !bridge config.bridge_config then
let bridge_config = List.assoc !bridge config.bridge_config in
match List.assoc_opt !bridge config.bridge_config with
| Some bridge_config ->

Error (Printf.sprintf "Could not find MAC address of %s\n" name)
in
let macs =
match config.interface_order with
Copy link
Member

Choose a reason for hiding this comment

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

I would rather have not use the if for ifaces and incorporate it to the match

Suggested change
match config.interface_order with
match (config.interface_order, ifaces) with

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.

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