diff --git a/CHANGELOG.md b/CHANGELOG.md index fa98854..d2ebf95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ * [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). + ## 3.15.0.0 * Explicitly removed extra hidden files from release package. diff --git a/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 b/DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1 index 397e464..f9dc8e3 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 = $false, + [Parameter()] [Boolean] $EnableEmbeddedTeaming = $false, @@ -278,6 +286,12 @@ 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 +299,7 @@ function Set-TargetResource $parameters = @{} $parameters["Name"] = $Name $parameters["NetAdapterName"] = $NetAdapterName + $parameters["EnableIov"] = $IovEnabled if ($BandwidthReservationMode -ne "NA") { @@ -335,6 +350,7 @@ function Set-TargetResource Write-Verbose -Message $LocalizedData.CreatingSwitch $parameters = @{} $parameters["Name"] = $Name + $parameters["EnableIov"] = $IovEnabled if ($BandwidthReservationMode -ne "NA") { @@ -398,6 +414,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 +456,10 @@ function Test-TargetResource [Boolean] $AllowManagementOS = $false, + [Parameter()] + [Boolean] + $IovEnabled = $false, + [Parameter()] [Boolean] $EnableEmbeddedTeaming = $false, @@ -602,6 +625,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 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')) diff --git a/.codecov.yml b/codecov.yml similarity index 100% rename from .codecov.yml rename to codecov.yml