Replies: 15 comments
-
@alexellis Thanks for creating this issue! As you know, This library is a Go wrapper for Virtualization.framework, so what Virtualization.framework can't do, this library can't do either. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response. I suppose I can ask it a different way. Could you see a way for us to create a disk image that could be launched as required for a CI runner using this library? Of if that were your task, how would you go about it? Unfortunately, the Tart CI stuff including their Packer integration has a license that isn't suitable for that kind of usage. Do you always have to start from a restore image? Is there a way to input things into an image at start-up time - parameters, secrets etc? |
Beta Was this translation helpful? Give feedback.
-
By the way, I had an issue building the code, what would you suggest? This is Ventura with Apple Silicon and Go 1.20.
|
Beta Was this translation helpful? Give feedback.
-
I modified go.mod for the MacOS example to stop using the local source code, and to use the latest published release. The VM boots now, but I want to send key strokes or commands to the VM. Is that something you've done? I see there's a keyboard configuration but there's no vm.SendKey or similar method available |
Beta Was this translation helpful? Give feedback.
-
On a linux command line VM, you could use a serial device for this, or ssh connection. |
Beta Was this translation helpful? Give feedback.
-
@mpoindexter this compilation failure seems related to your PR. |
Beta Was this translation helpful? Give feedback.
-
A colleague of mine pointed me at https://github.com/adrianriobo/goax/blob/main/pkg/os/darwin/applescript/applescript.m |
Beta Was this translation helpful? Give feedback.
-
What I'd like to get to - is a way to send key strokes to get from the initial "setup screen" after restoring the image, to a working machine where other operations could be performed. I don't think SSH is enabled when you get the "Bonjour Hello!" screen and setup wizard? Perhaps it may not accept serial device input at tha ttime either? It looked like the way the Tart creators get past this is by sending all the various keystrokes to tab around and click "confirm" to various pages until they land into a VM that's ready to be automated. Perhaps they also have keystrokes to open a shell and start installing packages. If you wanted to get that restored image to a point where you can open a terminal or run commands against it, what would you do, knowing what you know now? |
Beta Was this translation helpful? Give feedback.
-
I never ran a macOS VM, so my knowledge stops there :( |
Beta Was this translation helpful? Give feedback.
-
I'm not sure what are the requirements (i.e. disk format). but there is a way to create disk image to use this function.
I haven't looked into it properly, but I understand that utilizing it with CI probably requires installing some sort of command line or something. If you want to create a custom Disk image, this repository (CreateGuestImage.sh) may be helpful. (Not my work, so I haven't looked into it properly. Sorry if I'm wrong) When the CI execution environment is the host and the macOS running on the host is the guest, a way to execute commands from the host to the guest is likely to be needed. For this purpose, I would pre-install an agent to run a command line using some kind of ssh protocol similar to Lima, using the above script.
This is probably as far as I can show 🙏 If you have acquired knowledge in this area, it would be helpful to future users if you could add it to the wiki below. |
Beta Was this translation helpful? Give feedback.
-
The problem as I see it is a bit of a chicken and egg: The system is always in the restore state at the "hello, bonjour" page. Even if we mounted a second disk with extra software on it, we couldn't install it or start SSH, because we're not yet at that stage. We need a way to send key presses into the MacOS VM via the keyboard or another mechanism to advance through the wizard, then once it's fully completed, we could install an agent and communicate that way. I have had a look through the way TartCI does this with Packer, but I haven't been able to find the code or mechanism yet that they use to get the key presses for the installer - https://github.com/cirruslabs/macos-image-templates/blob/master/templates/vanilla-ventura.pkr.hcl#L21C19-L21C19 Even after they've done that installation, it's not clear how they proceed to enter CLI commands like setting up sudoless login - https://github.com/cirruslabs/macos-image-templates/blob/master/templates/vanilla-ventura.pkr.hcl#L88C3-L88C22 There's some mention of VNC in the codebase, https://github.com/cirruslabs/tart/blob/f68297097e5f043191b52302fed17f7ff87ce972/Sources/tart/Commands/Run.swift - but I didn't think VNC was running when a machine boots up - before the setup is fully completed. The alternative (which is not a great solution) is to do all of this initial installation manually, and install and agent, then save the system as a disk image, which is cloned and (if possible, wiped) upon boot-up by that custom agent, before it accepts remote procedure calls or SSH calls. |
Beta Was this translation helpful? Give feedback.
-
Yes as far as I can tell they send these boot commands over VNC https://github.com/cirruslabs/packer-plugin-tart/blob/b25da725f429c5cddcb146f37e381596929efd2f/builder/tart/step_run.go#L210-L239 |
Beta Was this translation helpful? Give feedback.
-
@alexellis Ah, maybe I understand what do you want to do. Virtualization framework supports USB keyboard. This is enabled to send key events from keyboard you are used. I believe the code in tart is here: There is support in also vz. Perhaps Packer's boot_command is prepared to set up the OS on the first boot. If this has the role of simulating the keyboard, I feel that these combinations are possible. Note that, Some special keys that are exclusive to macOS don't seem to be available yet. However, for first-time setups, I felt that the features mentioned at the beginning were sufficient. It is also used in the macOS example. |
Beta Was this translation helpful? Give feedback.
-
I think I found out how they do the bootstrap.. Seems like there is a hidden private API that enables a built-in VNC server within the installer. https://github.com/cirruslabs/tart/blob/main/Sources/tart/Commands/Run.swift#L48 Do you think that's possible over CGO?
Do you have a code example of how to send keys using it from the controlling example program? |
Beta Was this translation helpful? Give feedback.
-
@alexellis I will support private API for VNC server. I believe It's possible
No I don't have 🙏
|
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Is it possible to run pre-built MacOS images from Packer?
Describe the solution you'd like
A clear and concise description of what you want to happen.
I saw that Tart CI (licensed under a non-OSS license) shows how to build images using Packer, which can be saved and then loaded up on demand for things like CI runners.
Since I know of Lima which uses vz, I wanted to ask you whether this is possible with vz? The example only mentions being able to load a restore image, which doesn't sound like the same thing.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
It'd be interesting to be able to launch an Arm64 MacOS VM on Apple Silicon to run CI builds.
Seems like the main use-case here or the well-trodden path is Linux VMs on Apple hardware?
Beta Was this translation helpful? Give feedback.
All reactions