VMware Cloud Community
selwins93
Enthusiast
Enthusiast

Configuring serial ports

I have a VM deployed in VMWare esxi 6.5 also added virtual serial port(named pipe) to that VM through ps script. Pipename 'clustervm1-01' and Nearend 'client' was configured with the below lines of code.

$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.operation = "add"
$dev.device = New-Object VMware.Vim.VirtualSerialPort
$dev.device.key = -1
$dev.device.backing = New-Object VMware.Vim.VirtualSerialPortPipeBackingInfo
$dev.Device.Backing.Pipename = 'cluster1-01-1'
$dev.Device.Backing.Endpoint = "client"
$dev.device.backing.deviceName = 'cluster1-01-1'
$dev.device.connectable = New-Object VMware.Vim.VirtualDeviceConnectOption
$dev.device.connectable.startConnected = $true
$dev.device.connectable.allowGuestControl = $true
$dev.device.connectable.connected = $true
$dev.device.yieldOnPoll = $true


I'm trying to map A virtual machine with the Far End under connections options. How to map 'Far End' through script? @LucD 

0 Kudos
11 Replies
LucD
Leadership
Leadership

The choice is done through the NoRxLoss property on the VirtualSerialPort.PipeBackingInfo object.
A value of $true means 'A process', a value of $false means ''A virtual machine

 




Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

selwins93
Enthusiast
Enthusiast

Hi @LucD Even after using NoRxLoss property with the value $false, Far End still remains with A process 

 

 

$dev = New-Object VMWare.Vim.VirtualDeviceConfigSpec
            $dev.Operation = "add"
            $dev.device = New-Object VMWare.Vim.VirtualSerialPort
            $dev.Device.Backing = New-Object VMware.Vim.VirtualSerialPortPipeBackingInfo
            $dev.Device.Backing.PipeName = 'cluster1-01-1'
            $dev.Device.Backing.Endpoint = "client"
            $dev.Device.Backing.NoRxLoss = $false

            $dev.device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo

            $dev.device.connectable.startConnected = $true

            $dev.device.connectable.allowGuestControl = $true

            $dev.device.connectable.connected = $true

            $dev.device.yieldOnPoll = $true

 

 

0 Kudos
LucD
Leadership
Leadership

Strange, the following works for me.

With $true I get "A process", with $false I get "A virtual machine"

$vm = Get-VM -Name MyVM

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec

$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.operation = "add"

$serial = New-Object VMware.Vim.VirtualSerialPort
$serial.key = -1
$serial.yieldOnPoll = $true

$serial.backing = New-Object VMware.Vim.VirtualSerialPortPipeBackingInfo
$serial.Backing.Pipename = 'cluster1-01-1'
$serial.Backing.Endpoint = "client"
$serial.Backing.NoRxLoss = $true

$serial.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
$serial.connectable.startConnected = $true
$serial.connectable.allowGuestControl = $true
$serial.connectable.connected = $true

$dev.Device += $serial

$spec.DeviceChange += $dev

$vm.ExtensionData.ReconfigVM($spec)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
selwins93
Enthusiast
Enthusiast

Thanks @LucD, even when I set the value of NoRxLoss as $true. The result seems to be empty neither a process nor a virtual machine got mapped.

0 Kudos
LucD
Leadership
Leadership

Which vSphere version are you using?
I did my tests in 7U1.

Any error messages in the vpxd log?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

selwins93
Enthusiast
Enthusiast

@LucD Its VMWare ESXi 6.5
Also i've gone through the below link where the noRxLoss comes under VirtualDevicePipeBackingOption

https://vdc-repo.vmware.com/vmwb-repository/dcr-public/6b586ed2-655c-49d9-9029-bc416323cb22/fa0b429a...

0 Kudos
LucD
Leadership
Leadership

I suspect you are interpreting that incorrectly.

The VirtualDevicePipeBackingOption object is Extended By the VirtualSerialPortPipeBackingOption, and that is where the NoRXLoss property is added.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
selwins93
Enthusiast
Enthusiast

Hi @LucD luckily I got it resolved. my pending requirement is, if want more than 1 serial ports for a VM. Which object/property defines the serial port's count?

0 Kudos
LucD
Leadership
Leadership

The snippet I provided earlier does that.
I have no clue why that should not be working for you.

Any errors?
Did you check the vpxd log?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
selwins93
Enthusiast
Enthusiast

Hi @LucD luckily I got it resolved. my pending requirement is, if want more than 1 serial ports for a VM. Which object/property defines the serial port's count?

0 Kudos
LucD
Leadership
Leadership

You will have to create a 2nd entry under DeviceChange.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos