Merge pull request #12280 from RudiMT/bugfix20210302/hyperv-enhanced-sessionmode-crash-2012R2
HyperV enhanced sessionmode crash on Windows Server 2012R2
This commit is contained in:
commit
a5983aabe1
@ -1,4 +1,5 @@
|
||||
require "json"
|
||||
require "log4r"
|
||||
|
||||
require "vagrant/util/powershell"
|
||||
|
||||
@ -26,6 +27,7 @@ module VagrantPlugins
|
||||
|
||||
def initialize(id)
|
||||
@vm_id = id
|
||||
@logger = Log4r::Logger.new("vagrant::hyperv::driver")
|
||||
end
|
||||
|
||||
# @return [Boolean] Supports VMCX
|
||||
@ -294,7 +296,10 @@ module VagrantPlugins
|
||||
# @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)
|
||||
result = execute(:set_enhanced_session_transport_type, VmID: vm_id, type: transport_type)
|
||||
if !result.nil?
|
||||
@logger.debug("EnhancedSessionTransportType is not supported by this version of hyperv, ignoring")
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
@ -17,7 +17,16 @@ try {
|
||||
}
|
||||
|
||||
try {
|
||||
# HyperV 1.1 (Windows Server 2012R2) crashes on this call. Vagrantfiles before 2.2.10 do break without skipping this.
|
||||
$present = Get-Command Hyper-V\Set-VM -ParameterName EnhancedSessionTransportType -ErrorAction SilentlyContinue
|
||||
if($present) {
|
||||
Hyper-V\Set-VM -VM $VM -EnhancedSessionTransportType $Type
|
||||
}else{
|
||||
$message = @{
|
||||
"EnhancedSessionTransportTypeSupportPresent"=$false;
|
||||
} | ConvertTo-Json
|
||||
Write-OutputMessage $message
|
||||
}
|
||||
} catch {
|
||||
Write-ErrorMessage "Failed to assign EnhancedSessionTransportType to ${Type}:${PSItem}"
|
||||
exit 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user