I'm trying to control a virtual machine that has been created from two different processes, but fail to create a VZVirtualMachine object that refers to the same VM.
For example, the first process creates and starts the virtual machine:
let vmConfiguration = getFixedVMConfiguration()
let vm = VZVirtualMachine(vmConfiguration: vmConfiguration)
vm.start {
// completion handler code ...
}
and another process tries to stop the virtual machine:
let vmConfiguration = getFixedVMConfiguration()
let vm = VZVirtualMachine(vmConfiguration: vmConfiguration)
vm.stop {
// completion handler code ...
}
The vm in the second thread will refer to a separte VM even when both have been created with the same configuration. Stopping it here will not change the state of the vm in the other process. Is there a way to access created VMs and use them from other processes?
A workaround would be to handle VMs in a daemon, but I failed to pass a VZVirtualMachine object through XPC to another process, because it does not implement NSSecureCoding. How could that be achieved?