hyper-v: Hyper-V: add support for EnhancedSessionTransportType. Addresses #9823

This commit is contained in:
cam 2019-08-10 21:35:01 +10:00
parent 1dda6cc14c
commit 226060dfbf
6 changed files with 45 additions and 1 deletions

View File

@ -97,6 +97,11 @@ module VagrantPlugins
env[:machine].provider_config.vm_integration_services)
end
if !env[:machine].provider_config.enhanced_session_transport_type.empty?
env[:ui].detail("Setting VM Enhanced session transport type")
env[:machine].provider.driver.set_enhanced_session_transport_type(env[:machine].provider_config.enhanced_session_transport_type)
end
@app.call(env)
end
end

View File

@ -48,6 +48,8 @@ module VagrantPlugins
attr_accessor :enable_virtualization_extensions
# @return [Hash] Options for VMServiceIntegration
attr_accessor :vm_integration_services
# @return [String] Set Enhanced session transport type
attr_accessor :enhanced_session_transport_type
def initialize
@ip_address_timeout = UNSET_VALUE
@ -65,6 +67,7 @@ module VagrantPlugins
@enable_automatic_checkpoints = UNSET_VALUE
@enable_checkpoints = UNSET_VALUE
@vm_integration_services = {}
@enhanced_session_transport_type = UNSET_VALUE
end
def finalize!
@ -102,6 +105,8 @@ module VagrantPlugins
# If automatic checkpoints are enabled, checkpoints will automatically be enabled
@enable_checkpoints ||= @enable_automatic_checkpoints
@enhanced_session_transport_type = nil if @enhanced_session_transport_type == UNSET_VALUE
end
def validate(machine)

View File

@ -217,6 +217,14 @@ module VagrantPlugins
execute(:set_name, VMID: vm_id, VMName: vmname)
end
# Set enhanced session transport type of the VM
#
# @param [String] enhanced session transport type of the VM
# @return [nil]
def set_enhanced_session_transport_type(transport_type)
execute(:set_enhanced_session_transport_type, VmID: vm_id, type: transport_type)
end
protected
def execute_powershell(path, options, &block)

View File

@ -0,0 +1,24 @@
#Requires -Modules VagrantMessages
param (
[parameter (Mandatory=$true)]
[Guid] $VMID,
[parameter (Mandatory=$true)]
[string] $Type
)
$ErrorActionPreference = "Stop"
try {
$VM = Hyper-V\Get-VM -Id $VMID
} catch {
Write-ErrorMessage "Failed to locate VM: ${PSItem}"
exit 1
}
try {
Hyper-V\Set-VM -VM $VM -EnhancedSessionTransportType $Type
} catch {
Write-ErrorMessage "Failed to assign EnhancedSessionTransportType to ${Type}: ${PSItem}"
exit 1
}

View File

@ -28,7 +28,8 @@ describe VagrantPlugins::HyperV::Action::Configure do
enable_checkpoints: false,
enable_automatic_checkpoints: true,
enable_virtualization_extensions: false,
vm_integration_services: vm_integration_services
vm_integration_services: vm_integration_services,
enhanced_session_transport_type: "HvSocket"
)
}
let(:vm_integration_services){ {} }

View File

@ -19,6 +19,7 @@ you may set. A complete reference is shown below:
* `enable_virtualization_extensions` (boolean) - Enable virtualization extensions for the virtual CPUs. Default: false
* `enable_checkpoints` (boolean) Enable checkpoints of the VM. Default: false
* `enable_automatic_checkpoints` (boolean) Enable automatic checkpoints of the VM. Default: false
* `enhanced_session_transport_type` (VMBus, HvSocket) - Enhanced session transport type for the VM. Default: Hyper-V Default (currently VMBus).
* `ip_address_timeout` (integer) - Number of seconds to wait for the VM to report an IP address. Default: 120.
* `linked_clone` (boolean) - Use differencing disk instead of cloning entire VHD. Default: false
* `mac` (string) - MAC address for the guest network interface