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
9 changed files
with
84 additions
and
14 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 | ||
|
||
[Network] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# 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 these as unmanaged devices (NM_UNMANAGED=1 for NetworkManager, AZURE_UNMANAGED_SRIOV=1 for networkd, etc.). | ||
SUBSYSTEM=="net", ACTION!="remove", DRIVERS=="mana", ATTR{flags}=="0x?[89ABCDEF]??", ENV{NM_UNMANAGED}="1", ENV{AZURE_UNMANAGED_SRIOV}="1" | ||
SUBSYSTEM=="net", ACTION!="remove", DRIVERS=="hv_pci", DRIVERS=="mlx4_core|mlx5_core", ENV{NM_UNMANAGED}="1", ENV{AZURE_UNMANAGED_SRIOV}="1" |