Skip to content
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

xVMSwitch: Adding new capability to enable Iov on the virtual switch #166

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 33 additions & 0 deletions DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -168,6 +172,10 @@ function Set-TargetResource
[Boolean]
$AllowManagementOS = $false,

[Parameter()]
[Boolean]
$IovEnabled = $false,

[Parameter()]
[Boolean]
$EnableEmbeddedTeaming = $false,
Expand Down Expand Up @@ -278,13 +286,20 @@ 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)
$switch | Remove-VMSwitch -Force
$parameters = @{}
$parameters["Name"] = $Name
$parameters["NetAdapterName"] = $NetAdapterName
$parameters["EnableIov"] = $IovEnabled

if ($BandwidthReservationMode -ne "NA")
{
Expand Down Expand Up @@ -335,6 +350,7 @@ function Set-TargetResource
Write-Verbose -Message $LocalizedData.CreatingSwitch
$parameters = @{}
$parameters["Name"] = $Name
$parameters["EnableIov"] = $IovEnabled

if ($BandwidthReservationMode -ne "NA")
{
Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -437,6 +456,10 @@ function Test-TargetResource
[Boolean]
$AllowManagementOS = $false,

[Parameter()]
[Boolean]
$IovEnabled = $false,

[Parameter()]
[Boolean]
$EnableEmbeddedTeaming = $false,
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions DSCResources/MSFT_xVMSwitch/MSFT_xVMSwitch.schema.mof
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions DSCResources/MSFT_xVMSwitch/en-us/MSFT_xVMSwitch.strings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ try
SwitchType = 'External'
AllowManagementOS = $AllowManagementOS
NetAdapterInterfaceDescription = 'Microsoft Network Adapter Multiplexor Driver'
IovEnabled = $false
}

if ($BandwidthReservationMode -ne 'NA')
Expand Down
1 change: 1 addition & 0 deletions Tests/Unit/MSFT_xVMSwitch_EnableEmbeddedTeaming.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @{
Expand Down
7 changes: 6 additions & 1 deletion Tests/Unit/MSFT_xVMSwitch_Id.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -172,7 +173,11 @@ try

[Parameter()]
[Guid]
$Id
$Id,

[Parameter()]
[Boolean]
$EnableIov
)

if($PSBoundParameters.ContainsKey('Id'))
Expand Down
File renamed without changes.