From 55d1c075e410ff294bf8bc37f129446a27cce7df Mon Sep 17 00:00:00 2001 From: Dan Cuomo Date: Sun, 20 Jan 2019 13:40:23 -0800 Subject: [PATCH 1/5] Adding new capability to enable Iov on the virtual switch required for advanced scenarios like Guest RDMA. It is also a virtual switch best practice to create the virtual switch with IovEnabled $true --- .../MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 | 32 +++++++++++++++++++ .../MSFT_xVMSwitch/MSFT_xVMSwitch.schema.mof | 1 + .../en-us/MSFT_xVMSwitch.strings.psd1 | 3 ++ 3 files changed, 36 insertions(+) diff --git a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 index 397e464..05125bf 100644 --- a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 +++ b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 @@ -95,6 +95,7 @@ function Get-TargetResource Type = $switch.SwitchType NetAdapterName = [string[]]$netAdapterName AllowManagementOS = $switch.AllowManagementOS + IovEnabled = $switch.IovEnabled EnableEmbeddedTeaming = $switch.EmbeddedTeamingEnabled LoadBalancingAlgorithm = $loadBalancingAlgorithm Ensure = $ensure @@ -130,6 +131,9 @@ function Get-TargetResource .PARAMETER AllowManagementOS Specify if the VM host has access to the physical NIC. +.PARAMETER IovEnabled + Specify if Iov is enabled on the VMSwitch + .PARAMETER EnableEmbeddedTeaming Should embedded NIC teaming be used (Windows Server 2016 only). @@ -168,6 +172,10 @@ function Set-TargetResource [Boolean] $AllowManagementOS = $false, + [Parameter()] + [Boolean] + $IovEnabled = $true, + [Parameter()] [Boolean] $EnableEmbeddedTeaming = $false, @@ -278,6 +286,11 @@ function Set-TargetResource $removeReaddSwitch = $true } + If ($switch.IovEnabled -ne $IovEnabled) { + Write-Verbose -Message ($LocalizedData.IovEnabledIncorrect -f $Name) + $removeReaddSwitch = $true + } + if ($removeReaddSwitch) { Write-Verbose -Message ($LocalizedData.RemoveAndReaddSwitchMessage -f $Name) @@ -285,6 +298,7 @@ function Set-TargetResource $parameters = @{} $parameters["Name"] = $Name $parameters["NetAdapterName"] = $NetAdapterName + $parameters["EnableIov"] = $IovEnabled if ($BandwidthReservationMode -ne "NA") { @@ -335,6 +349,7 @@ function Set-TargetResource Write-Verbose -Message $LocalizedData.CreatingSwitch $parameters = @{} $parameters["Name"] = $Name + $parameters['EnableIov'] = $IovEnabled if ($BandwidthReservationMode -ne "NA") { @@ -398,6 +413,9 @@ function Set-TargetResource .PARAMETER AllowManagementOS Specify if the VM host has access to the physical NIC. +.PARAMETER IovEnabled + Specify if Iov is enabled on the VMSwitch + .PARAMETER EnableEmbeddedTeaming Should embedded NIC teaming be used (Windows Server 2016 only). @@ -437,6 +455,10 @@ function Test-TargetResource [Boolean] $AllowManagementOS = $false, + [Parameter()] + [Boolean] + $IovEnabled = $true, + [Parameter()] [Boolean] $EnableEmbeddedTeaming = $false, @@ -602,6 +624,16 @@ function Test-TargetResource } } + Write-Verbose -Message ($LocalizedData.CheckIovEnabled -f $Name) + if (($switch.IovEnabled -ne $IovEnabled)) + { + return $false + } + else + { + Write-Verbose -Message ($LocalizedData.IovEnabledCorrect -f $Name) + } + if($PSBoundParameters.ContainsKey('LoadBalancingAlgorithm')) { Write-Verbose -Message ($LocalizedData.CheckingLoadBalancingAlgorithm -f $Name) diff --git a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.schema.mof b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.schema.mof index 4f6df35..b95ca27 100644 --- a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.schema.mof +++ b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.schema.mof @@ -5,6 +5,7 @@ class MSFT_xVMSwitch : OMI_BaseResource [Key, Description("Type of switch"), ValueMap{"External","Internal","Private"}, Values{"External","Internal","Private"}] String Type; [Write, Description("Network adapter name(s) for external switch type")] String NetAdapterName[]; [Write, Description("Specify if the VM host has access to the physical NIC")] Boolean AllowManagementOS; + [Write, Description("Specify if Iov is enabled on the VMSwitch")] Boolean IovEnabled; [Write, Description("Should embedded NIC teaming be used (Windows Server 2016 only)")] Boolean EnableEmbeddedTeaming; [Write, Description("Type of Bandwidth Reservation Mode to use for the switch"), ValueMap{"Default","Weight","Absolute","None","NA"}, Values{"Default","Weight","Absolute","None","NA"}] String BandwidthReservationMode; [Write, Description("Specifies the load balancing algorithm that this switch team uses"), ValueMap{"Dynamic","HyperVPort"}, Values{"Dynamic","HyperVPort"}] String LoadBalancingAlgorithm; diff --git a/DSCResources/MSFT_xVMSwitch/en-us/MSFT_xVMSwitch.strings.psd1 b/DSCResources/MSFT_xVMSwitch/en-us/MSFT_xVMSwitch.strings.psd1 index dacd8f9..bb4cc48 100644 --- a/DSCResources/MSFT_xVMSwitch/en-us/MSFT_xVMSwitch.strings.psd1 +++ b/DSCResources/MSFT_xVMSwitch/en-us/MSFT_xVMSwitch.strings.psd1 @@ -7,6 +7,9 @@ ConvertFrom-StringData @' RemoveAndReaddSwitchMessage = Removing switch '{0}' and creating with the correct properties ... SwitchCorrectNetAdapterAndBandwidthMode = Switch '{0}' set has right network adapter(s) ('{1}') and BandwidthReservationMode ('{2}') CheckAllowManagementOS = Checking switch '{0}' AllowManagementOS ... + CheckIovEnabled = Checking switch '{0}' IovEnabled ... + IovEnabledCorrect = Switch '{0}' IovEnabled is correctly set + IovEnabledIncorrect = Switch '{0}' IovEnabled property is not correct AllowManagementOSIncorrect = Switch '{0}' AllowManagementOS property is not correct AllowManagementOSUpdated = Switch '{0}' AllowManagementOS property is set to '{1}' AllowManagementOSCorrect = Switch '{0}' AllowManagementOS is correctly set From 5ece7f13cc2aca2130826c82abc8d7d78b08c2b1 Mon Sep 17 00:00:00 2001 From: Dan Cuomo Date: Mon, 21 Jan 2019 00:08:32 -0800 Subject: [PATCH 2/5] changing default for IovEnabled param --- DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 index 05125bf..1d622e0 100644 --- a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 +++ b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 @@ -174,7 +174,7 @@ function Set-TargetResource [Parameter()] [Boolean] - $IovEnabled = $true, + $IovEnabled = $false, [Parameter()] [Boolean] @@ -349,7 +349,7 @@ function Set-TargetResource Write-Verbose -Message $LocalizedData.CreatingSwitch $parameters = @{} $parameters["Name"] = $Name - $parameters['EnableIov'] = $IovEnabled + $parameters["EnableIov"] = $IovEnabled if ($BandwidthReservationMode -ne "NA") { @@ -457,7 +457,7 @@ function Test-TargetResource [Parameter()] [Boolean] - $IovEnabled = $true, + $IovEnabled = $false, [Parameter()] [Boolean] From 65f22214c4f5091db8f3bb3825db5d0245241fb7 Mon Sep 17 00:00:00 2001 From: Dan Cuomo Date: Mon, 21 Jan 2019 12:16:43 -0800 Subject: [PATCH 3/5] Updating PR to fix failing tests. --- DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 | 3 ++- .../Unit/MSFT_xVMSwitch_BandwidthReservationMode.Tests.ps1 | 1 + Tests/Unit/MSFT_xVMSwitch_EnableEmbeddedTeaming.Tests.ps1 | 1 + Tests/Unit/MSFT_xVMSwitch_Id.Tests.ps1 | 7 ++++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 index 1d622e0..f9dc8e3 100644 --- a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 +++ b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 @@ -286,7 +286,8 @@ function Set-TargetResource $removeReaddSwitch = $true } - If ($switch.IovEnabled -ne $IovEnabled) { + If ($switch.IovEnabled -ne $IovEnabled) + { Write-Verbose -Message ($LocalizedData.IovEnabledIncorrect -f $Name) $removeReaddSwitch = $true } diff --git a/Tests/Unit/MSFT_xVMSwitch_BandwidthReservationMode.Tests.ps1 b/Tests/Unit/MSFT_xVMSwitch_BandwidthReservationMode.Tests.ps1 index eb29268..750549b 100644 --- a/Tests/Unit/MSFT_xVMSwitch_BandwidthReservationMode.Tests.ps1 +++ b/Tests/Unit/MSFT_xVMSwitch_BandwidthReservationMode.Tests.ps1 @@ -88,6 +88,7 @@ try SwitchType = 'External' AllowManagementOS = $AllowManagementOS NetAdapterInterfaceDescription = 'Microsoft Network Adapter Multiplexor Driver' + IovEnabled = $false } if ($BandwidthReservationMode -ne 'NA') diff --git a/Tests/Unit/MSFT_xVMSwitch_EnableEmbeddedTeaming.Tests.ps1 b/Tests/Unit/MSFT_xVMSwitch_EnableEmbeddedTeaming.Tests.ps1 index 205f8ed..6bc264c 100644 --- a/Tests/Unit/MSFT_xVMSwitch_EnableEmbeddedTeaming.Tests.ps1 +++ b/Tests/Unit/MSFT_xVMSwitch_EnableEmbeddedTeaming.Tests.ps1 @@ -304,6 +304,7 @@ try EmbeddedTeamingEnabled = $true Id = [Guid]::NewGuid() NetAdapterInterfaceDescriptions = @("Microsoft Network Adapter Multiplexor Driver #1", "Microsoft Network Adapter Multiplexor Driver #2") + IovEnabled = $false } $testParams = @{ diff --git a/Tests/Unit/MSFT_xVMSwitch_Id.Tests.ps1 b/Tests/Unit/MSFT_xVMSwitch_Id.Tests.ps1 index 32980a4..cd041da 100644 --- a/Tests/Unit/MSFT_xVMSwitch_Id.Tests.ps1 +++ b/Tests/Unit/MSFT_xVMSwitch_Id.Tests.ps1 @@ -84,6 +84,7 @@ try LoadBalancingAlgorithm = 'HyperVPort' BandwidthReservationMode = 'Default' NetAdapterInterfaceDescriptions = @("Microsoft Network Adapter Multiplexor Driver #1", "Microsoft Network Adapter Multiplexor Driver #2") + IovEnabled = $false } if ($PSBoundParameters.ContainsKey('Id')) @@ -172,7 +173,11 @@ try [Parameter()] [Guid] - $Id + $Id, + + [Parameter()] + [Boolean] + $EnableIov ) if($PSBoundParameters.ContainsKey('Id')) From 16d4d383275efefd586e44ae5e3d748ab2df4558 Mon Sep 17 00:00:00 2001 From: Dan Cuomo Date: Mon, 28 Jan 2019 15:39:55 -0500 Subject: [PATCH 4/5] Adding details to change log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d50cb..34d9b7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ * [PR #148](https://github.com/PowerShell/xHyper-V/pull/148), Fixes [Issue #149](https://github.com/PowerShell/xHyper-V/issues/149). * [PR #67](https://github.com/PowerShell/xHyper-V/pull/67), Fixes [Issue #145](https://github.com/PowerShell/xHyper-V/issues/145). * Fixed Get throws error when NetworkAdapters are not attached or missing properties. + * Added new option to enable Iov support on the VMSwitch + * [PR #166](https://github.com/PowerShell/xHyper-V/pull/166), Fixes [Issue #166](https://github.com/PowerShell/xHyper-V/issues/166). ## 3.15.0.0 From 5c635822a5403bf4cb0509a599dd47bc7791932c Mon Sep 17 00:00:00 2001 From: dcuomo Date: Sat, 25 May 2019 12:55:02 -0700 Subject: [PATCH 5/5] asdf --- CHANGELOG.md | 2 ++ .codecov.yml => codecov.yml | 0 2 files changed, 2 insertions(+) rename .codecov.yml => codecov.yml (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34d9b7d..852f4a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ * [PR #148](https://github.com/PowerShell/xHyper-V/pull/148), Fixes [Issue #149](https://github.com/PowerShell/xHyper-V/issues/149). * [PR #67](https://github.com/PowerShell/xHyper-V/pull/67), Fixes [Issue #145](https://github.com/PowerShell/xHyper-V/issues/145). * Fixed Get throws error when NetworkAdapters are not attached or missing properties. + +* MSFT_xVMSwitch: * Added new option to enable Iov support on the VMSwitch * [PR #166](https://github.com/PowerShell/xHyper-V/pull/166), Fixes [Issue #166](https://github.com/PowerShell/xHyper-V/issues/166). diff --git a/.codecov.yml b/codecov.yml similarity index 100% rename from .codecov.yml rename to codecov.yml