forked from Azure/azure-vm-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unmanaged-sriov): add udev & networkd support for unmanaged devices
- Add udev rules to mark SR-IOV devices which are transparently bonded to hv_netvsc devices in 10-azure-unmanaged-sriov.rules. - Add initramfs hooks in case udev rules need to be available in initramfs. Packaging can drop them if desired. - Add networkd configuration to configured these devices as unmanaged, if marked. - Add networkd.cmake for networkd-related cmake configuration. - Move udev-related cmake configuration into new udev.cmake. Signed-off-by: Chris Patterson <[email protected]> Signed-off-by: Haiyang Zhang <[email protected]>
- Loading branch information
Showing
11 changed files
with
92 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set(NETWORKD_CONFIGS_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/network" CACHE PATH "networkd configs installation directory") | ||
|
||
install(FILES ${CMAKE_SOURCE_DIR}/networkd/10-azure-unmanaged-sriov.network DESTINATION ${NETWORKD_CONFIGS_INSTALL_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
set(UDEV_RULES_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib/udev/rules.d" CACHE PATH "udev rules.d installation directory") | ||
|
||
# Install Azure unmanaged SR-IOV rules and configuration. | ||
install(FILES ${CMAKE_SOURCE_DIR}/udev/10-azure-unmanaged-sriov.rules DESTINATION ${UDEV_RULES_INSTALL_DIR}) | ||
|
||
# Install udev rules after updating "/usr/sbin/azure-nvme-id" with installed path $AZURE_NVME_ID_INSTALL_DIR. | ||
file(READ ${CMAKE_SOURCE_DIR}/udev/80-azure-disk.rules CONTENT) | ||
string(REPLACE "/usr/sbin/azure-nvme-id" "${AZURE_NVME_ID_INSTALL_DIR}/azure-nvme-id" CONTENT "${CONTENT}") | ||
file(WRITE ${CMAKE_BINARY_DIR}/udev/80-azure-disk.rules ${CONTENT}) | ||
install(FILES ${CMAKE_BINARY_DIR}/udev/80-azure-disk.rules DESTINATION ${UDEV_RULES_INSTALL_DIR}) |
15 changes: 15 additions & 0 deletions
15
initramfs/dracut/modules.d/97azure-unmanaged-sriov/module-setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/bash | ||
# called by dracut | ||
check() { | ||
return 0 | ||
} | ||
|
||
# called by dracut | ||
depends() { | ||
return 0 | ||
} | ||
|
||
# called by dracut | ||
install() { | ||
inst_rules 10-azure-unmanaged-sriov.rules | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/sh | ||
|
||
PREREQ="udev" | ||
|
||
prereqs() | ||
{ | ||
echo "${PREREQ}" | ||
} | ||
|
||
case $1 in | ||
prereqs) | ||
prereqs | ||
exit 0 | ||
;; | ||
esac | ||
|
||
. /usr/share/initramfs-tools/hook-functions | ||
|
||
DESTINATION="${DESTDIR}/lib/udev/rules.d/" | ||
RULES_FILE="/usr/lib/udev/rules.d/10-azure-unmanaged-sriov.rules" | ||
|
||
if [ -e "${RULES_FILE}" ]; then | ||
mkdir -p "${DESTINATION}" | ||
cp -p "${RULES_FILE}" "${DESTINATION}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Azure VMs with accelerated networking may have MANA, mlx4, or mlx5 SR-IOV | ||
# devices which are transparently bonded to a synthetic hv_netvsc device. | ||
# 10-azure-unmanaged-sriov.rules will mark these devices with | ||
# AZURE_UNMANAGED_SRIOV=1 so this can configure the devices as unmanaged. | ||
|
||
[Match] | ||
Property=AZURE_UNMANAGED_SRIOV=1 | ||
|
||
[Link] | ||
Unmanaged=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Azure VMs with accelerated networking may have MANA, mlx4, or mlx5 SR-IOV devices which are transparently bonded to a synthetic | ||
# hv_netvsc device. Mark devices with the IFF_SLAVE bit set as unmanaged devices: | ||
# AZURE_UNMANAGED_SRIOV=1 for 10-azure-unmanaged-sriov.network | ||
# ID_NET_MANAGED_BY=unmanaged for systemd-networkd >= 255 | ||
# NM_UNMANAGED=1 for NetworkManager | ||
SUBSYSTEM=="net", ACTION!="remove", DRIVERS=="mana|mlx4_core|mlx5_core", ATTR{flags}=="0x?[89ABCDEF]??", ENV{AZURE_UNMANAGED_SRIOV}="1", ENV{ID_NET_MANAGED_BY}="unmanaged", ENV{NM_UNMANAGED}="1" |