mirror of https://github.com/cirruslabs/tart.git
Add support pasting clipboard from host for Linux VMs (#806)
* Added partial support pasting clipboard from host (only for Linux VMs) * Added option "--no-clipboard" to run command
This commit is contained in:
parent
c6e8d0bfd7
commit
3ff3850da2
|
|
@ -40,6 +40,11 @@ struct Run: AsyncParsableCommand {
|
|||
@Flag(help: "Disable audio pass-through to host.")
|
||||
var noAudio: Bool = false
|
||||
|
||||
@Flag(help: ArgumentHelp(
|
||||
"Disable clipboard sharing between host and guest.",
|
||||
discussion: "Only works with Linux-based guest operating systems."))
|
||||
var noClipboard: Bool = false
|
||||
|
||||
#if arch(arm64)
|
||||
@Flag(help: "Boot into recovery mode")
|
||||
#endif
|
||||
|
|
@ -231,7 +236,8 @@ struct Run: AsyncParsableCommand {
|
|||
directorySharingDevices: directoryShares() + rosettaDirectoryShare(),
|
||||
serialPorts: serialPorts,
|
||||
suspendable: suspendable,
|
||||
audio: !noAudio
|
||||
audio: !noAudio,
|
||||
clipboard: !noClipboard
|
||||
)
|
||||
|
||||
let vncImpl: VNC? = try {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
|||
directorySharingDevices: [VZDirectorySharingDeviceConfiguration] = [],
|
||||
serialPorts: [VZSerialPortConfiguration] = [],
|
||||
suspendable: Bool = false,
|
||||
audio: Bool = true
|
||||
audio: Bool = true,
|
||||
clipboard: Bool = true
|
||||
) throws {
|
||||
name = vmDir.name
|
||||
config = try VMConfig.init(fromURL: vmDir.configURL)
|
||||
|
|
@ -64,7 +65,8 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
|||
directorySharingDevices: directorySharingDevices,
|
||||
serialPorts: serialPorts,
|
||||
suspendable: suspendable,
|
||||
audio: audio
|
||||
audio: audio,
|
||||
clipboard: clipboard
|
||||
)
|
||||
virtualMachine = VZVirtualMachine(configuration: configuration)
|
||||
|
||||
|
|
@ -291,7 +293,8 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
|||
directorySharingDevices: [VZDirectorySharingDeviceConfiguration],
|
||||
serialPorts: [VZSerialPortConfiguration],
|
||||
suspendable: Bool = false,
|
||||
audio: Bool = true
|
||||
audio: Bool = true,
|
||||
clipboard: Bool = true
|
||||
) throws -> VZVirtualMachineConfiguration {
|
||||
let configuration = VZVirtualMachineConfiguration()
|
||||
|
||||
|
|
@ -336,6 +339,16 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject {
|
|||
return vio
|
||||
}
|
||||
|
||||
// Clipboard sharing via Spice agent
|
||||
if clipboard && vmConfig.os == .linux {
|
||||
let spiceAgentConsoleDevice = VZVirtioConsoleDeviceConfiguration()
|
||||
let spiceAgentPort = VZVirtioConsolePortConfiguration()
|
||||
spiceAgentPort.name = VZSpiceAgentPortAttachment.spiceAgentPortName
|
||||
spiceAgentPort.attachment = VZSpiceAgentPortAttachment()
|
||||
spiceAgentConsoleDevice.ports[0] = spiceAgentPort
|
||||
configuration.consoleDevices.append(spiceAgentConsoleDevice)
|
||||
}
|
||||
|
||||
// Storage
|
||||
let attachment: VZDiskImageStorageDeviceAttachment = vmConfig.os == .linux ?
|
||||
// Use "cached" caching mode for virtio drive to prevent fs corruption on linux
|
||||
|
|
|
|||
Loading…
Reference in New Issue