Commit Graph
24 Commits
Author SHA1 Message Date
osy 602d8fc615 scripting: provision macOS guests on first boot
macOS 27 can create the guest's user account, turn on automatic login and
Remote Login without going through Setup Assistant, which lets CI and other
automation get a ready-to-use macOS VM. The guest only reads these options
on the first boot after macOS is installed and they include a password, so
they are passed as a parameter to a single start and are never saved to the
configuration or the registry.

This is only exposed to AppleScript (`start ... provisioning {...}`) and
utmctl (`start --provision-*`) because most users will never need it. utmctl
can read the password from standard input to keep it out of the process
list. Requests that cannot be honoured (not a macOS guest, host older than
macOS 27, install still pending, saved state, recovery mode, invalid account)
fail before the VM starts so the first boot is not used up.

UTMScripting.swift has only the regenerated `start` declaration. The rest of
the current bridge-gen.sh output is unrelated to this change.

Assisted-by: Claude:claude-fable-5-1
2026-09-19 22:05:10 -05:00
osy 5d395abfc8 scripting: return from install before the Apple Event times out
A macOS install takes several minutes, well past the default two minute
Apple Event timeout. A plain `install` therefore failed with -1712 while
the installation kept running, and a script reacting to that error by
retrying or starting the VM would race the install.

`install` now returns as soon as the installation starts, and the new
`query install` verb reports whether it is still running and how far it
has progressed, or raises the error if it failed. The installation only
counts as finished once the VM has stopped by itself, so the VM can be
started right away.

Other verbs fail with a clear error while an installation started from
a script is in progress. This includes `start`, which would otherwise
open a window that asks to install macOS again. As in the GUI, `stop`
cancels the installation.

Assisted-by: Claude:claude-opus-5
2026-09-19 09:49:15 -05:00
Marc Eisenbarth 8d04b96c23 scripting: add an install command for macOS guests
VMDisplayAppleWindowController.windowDidLoad shows a confirmation sheet
before calling requestInstallVM, so a macOS install cannot be driven from
a script without someone clicking OK.

This does not remove the sheet. It guards a genuinely destructive action
(it erases the primary drive) and a GUI user who opens a VM that happens
to carry an IPSW should keep being asked. It is also structurally
unavailable to a script: showConfirmAlert calls
beginSheetModal(for: window!), so it needs a window, and the scripted
`start` verb calls data.run(...), which loads the window controller and
raises the sheet in the first place.

So this adds a separate `install` verb that goes straight to
installVM(with:) and never opens a window. The confirmation moves rather
than disappearing: asking for `install` is the confirmation, which is why
the sdef entry says DESTRUCTIVE in as many words. This matches the
CONTRIBUTING.md guidance about putting things most users do not need into
the scripting interface rather than the UI.

It also clears the IPSW on success, as the GUI does in
didCompleteInstallation. That clearing lives in the window controller's
delegate callback, and a scripted install has no window, so without it
the IPSW outlives the install and the next `start` that does open a
display window asks "Would you like to install macOS?" over a guest that
is already installed. Measured before the fix: the registry still held
the IPSW after a completed scripted install.

Two guards, because installVM returns silently when the VM is not
stopped and calling it unguarded would report success having done
nothing: a VM with no IPSW configured, and a VM that is not stopped, each
fail with an error naming the cause.

Verified against main on Xcode 26.6 / Apple Silicon: no confirmation
sheet at any point, a macOS 26.6.2 install run to completion (21 GB,
framework returned success), the IPSW cleared from the registry
afterwards, and a subsequent `start` opening a display window with no
reinstall prompt and the guest booting to Setup Assistant.

UTMScripting.swift gains the install() method that bridge-gen.sh
generates for this sdef change.

Refs #6092

Assisted-by: Claude:claude-opus-5
2026-09-19 09:34:56 -05:00
Naveenraj M a11e968084 snapshots: expose QEMU full-VM snapshots
Expose named create, list, restore, and delete operations through AppleScript and utmctl so automation can manage QEMU full-VM snapshots. QEMU image metadata remains the source of truth, the internal suspend snapshot stays hidden and reserved, and Apple virtualization reports the feature as unsupported until it can preserve equivalent VM state reliably.

Assisted-by: Codex:gpt-5
2026-08-20 13:26:29 -07:00
Greg ORIOL c8da6919ff Add an AppleScript command to reload machine configuration from disk 2026-05-12 22:47:22 +02:00
Victor Muryn c8450702d1 Added ability to get ip for AppleVirtualization machines (#7643)
* added ability to get ip for AppleVirt machines

* fixed comments
2026-05-03 10:51:01 -07:00
user d5402b7735 utmctl: support booting into recovery mode 2025-04-16 12:16:49 +02:00
Naveenraj M f57fe2ef64 scripting: add vm resgistry suite
The registry suite is used to read and update vm registry.
All configs saved to disk is exposed by Configuration suite,
similarly those that are not saved to disk are stored in RegistryEntry
 will now be exposed by Registry suite.
  - UTMScriptingRegistryEntryImpl will control what will be exposed from RegistryEntry to scripting bridge, currently only shared directory is exposed in the form of [URL]
  - expose UTMQemuVirtualMachine.system as public to be used in Scripting
  - Add UTMRegistryEntry.appendSharedDirectory to support multiple directory shares.
2025-01-18 16:55:32 -07:00
Naveenraj M 05065625bf scripting: add export command 2024-10-04 01:33:50 -06:00
osy 37991d246f vm: rewrite UTMVirtualMachine in Swift 2023-06-28 19:45:05 -05:00
osy d498239b38 data: refactor UTMVirtualMachine to VMData for use in Views
This replaces the functionality of UTMWrappedVirtualMachine and moves some of
the presentation logic from UTMVirtualMachine.
2023-06-26 23:28:18 -05:00
osy 03d200422f manager: factor out QEMUKit as a separate project 2023-06-25 08:43:05 -05:00
osy cd96e525a3 scripting: implement delete and duplicate commands 2023-03-19 21:11:22 -07:00
osy 4b4b33d10a scripting: add configuration suite 2023-03-19 21:11:22 -07:00
osy 22e7e4284d scripting: add guest suite
Support read/write files and execute commands via QEMU guest agent.
2023-03-14 01:39:20 -07:00
osy 917ccf9c74 scripting: return error when trying to suspend or stop a non-running vm
Fixes #4884
2023-01-03 18:32:08 -08:00
osy bd5de65406 scripting: use the right error description override 2023-01-03 18:29:00 -08:00
osy 085366e70f utmctl: fix stop request not working
Fixes #4850
2022-12-27 16:36:00 -08:00
osy 2daa38ac35 scripting: add support for disposible mode 2022-12-16 13:58:25 -08:00
osy b7e4d2a627 scripting: localize error text 2022-12-15 18:17:24 -08:00
osy 1b48c64967 scripting: properly create vm window on start 2022-12-14 22:35:46 -08:00
osy 8839b605ea utmctl: rewrote to use scripting bridge 2022-12-14 22:35:46 -08:00
osy 7e71fefb1e scripting: fix various issues running scripts 2022-12-14 18:44:15 -08:00
osy d2b488b6a5 scripting: add scripting bridge support 2022-12-14 09:16:07 -08:00