Example #1
0
// ConnectSerialPort connects a serial port to a server or client uri.
func (l VirtualDeviceList) ConnectSerialPort(device *types.VirtualSerialPort, uri string, client bool, proxyuri string) *types.VirtualSerialPort {
	if strings.HasPrefix(uri, "[") {
		device.Backing = &types.VirtualSerialPortFileBackingInfo{
			VirtualDeviceFileBackingInfo: types.VirtualDeviceFileBackingInfo{
				FileName: uri,
			},
		}

		return device
	}

	direction := types.VirtualDeviceURIBackingOptionDirectionServer
	if client {
		direction = types.VirtualDeviceURIBackingOptionDirectionClient
	}

	device.Backing = &types.VirtualSerialPortURIBackingInfo{
		VirtualDeviceURIBackingInfo: types.VirtualDeviceURIBackingInfo{
			Direction:  string(direction),
			ServiceURI: uri,
			ProxyURI:   proxyuri,
		},
	}

	return device
}
Example #2
0
func (s *VirtualMachineConfigSpec) addVirtualSerialPort(device *types.VirtualSerialPort, suffix string, connected bool) *VirtualMachineConfigSpec {
	device.GetVirtualDevice().Key = s.generateNextKey()

	// Set serial device's backing to a datastore file when debug is true
	// We then instruct Linux kernel to use that as a serial console
	if suffix == "" {
		device.GetVirtualDevice().Backing = &types.VirtualSerialPortURIBackingInfo{
			VirtualDeviceURIBackingInfo: types.VirtualDeviceURIBackingInfo{
				Direction:  string(types.VirtualDeviceURIBackingOptionDirectionClient),
				ServiceURI: s.ConnectorURI(),
			},
		}

		device.GetVirtualDevice().Connectable = &types.VirtualDeviceConnectInfo{
			Connected:         connected,
			StartConnected:    connected,
			AllowGuestControl: false,
		}
	} else {
		device.GetVirtualDevice().Backing = &types.VirtualSerialPortFileBackingInfo{
			VirtualDeviceFileBackingInfo: types.VirtualDeviceFileBackingInfo{
				FileName: fmt.Sprintf("%s/%s/%s.%s", s.VMPathName(), s.config.VMFullName, s.ID(), suffix),
			},
		}
	}

	return s.AddVirtualDevice(device)
}
func (l VirtualDeviceList) setDefaultSerialPortBacking(device *types.VirtualSerialPort) {
	device.Backing = &types.VirtualSerialPortURIBackingInfo{
		VirtualDeviceURIBackingInfo: types.VirtualDeviceURIBackingInfo{
			Direction:  "client",
			ServiceURI: "localhost:0",
		},
	}
}
// ConnectSerialPort connects a serial port to a server or client uri.
func (l VirtualDeviceList) ConnectSerialPort(device *types.VirtualSerialPort, uri string, client bool) *types.VirtualSerialPort {
	direction := types.VirtualDeviceURIBackingOptionDirectionServer
	if client {
		direction = types.VirtualDeviceURIBackingOptionDirectionClient
	}

	device.Backing = &types.VirtualSerialPortURIBackingInfo{
		VirtualDeviceURIBackingInfo: types.VirtualDeviceURIBackingInfo{
			Direction:  string(direction),
			ServiceURI: uri,
		},
	}

	return device
}