28 Commits
Author SHA1 Message Date
osy b1e1b12a05 scripting: model snapshots as scriptable objects
The snapshot commands could only name a snapshot and could not say anything
about it. A script could not tell when a snapshot was taken, how much it
holds, whether restoring it resumes the guest or starts it up, or whether
its data has gone missing, and there was no way to rename one or to throw
away a suspended state, both of which the window offers.

Make a snapshot an object instead. A virtual machine now has snapshots as
elements, each carrying those details, so a script can pick one out and
read it:

    tell application "UTM"
      set vm to virtual machine named "Debian"
      set candidates to (snapshots of vm whose includes running state)
      restore (item 1 of candidates)
    end tell

Renaming is setting the name, and the commands that act on a snapshot take
the snapshot itself. Creating one returns it. Two more commands cover what
the window can do and scripting could not: scanning the images for
snapshots made by other tools, and discarding a saved state so the guest
starts up instead of resuming.

This replaces the snapshot commands of the 5.0.5 beta, which addressed a
snapshot by name through its virtual machine, so scripts and utmctl calls
written against them have to be updated.

Snapshots are addressed by name, so names are now kept apart the way
virtual machine names are, by appending a number.

Deleting a snapshot is its own command rather than the standard delete,
which coerces a specifier for anything inside a virtual machine into the
virtual machine itself; deleting that would throw away far more than was
asked for. The delete command refuses such a specifier for the same reason.

UTMScripting.swift is regenerated from the sdef; only the hunks that
changed are taken.

Assisted-by: Claude:claude-opus-5
2026-09-22 10:57:36 -05:00
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
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
osy d5c224b88d utmctl: add version command
For the scripting backend, we have to use a hack. The existing property
`version` cannot be accessed through App Sandbox because the inherited
suite does not define an access-group. We create a new property that is
accessible by the com.utmapp.UTM.vm-access access group.

Resolves #7350
2025-08-17 20:22:16 -07:00
user d5402b7735 utmctl: support booting into recovery mode 2025-04-16 12:16:49 +02:00
osy 39a68379b6 utmctl: detect path if UTM.app was renamed
Fixes #7094
2025-04-07 12:42:03 -07:00
osy 6093498b44 utmctl: remove Export command because it cannot work in sandbox 2024-11-21 09:37:55 -08:00
Naveenraj M 05065625bf scripting: add export command 2024-10-04 01:33:50 -06:00
osy 8d7b51b878 utmctl: implement USB commands
Resolves #5157
2023-09-04 20:49:43 -07:00
osy 449bee449a utmctl: resolve symlink in path to self
Fixes #5526
2023-08-05 12:33:25 -07:00
osy 8731e9e81a utmctl: better error message when failed from non-interactive session
Resolves #5499
2023-07-27 23:27:29 -07:00
osy 3c2906a313 utmctl: add delete command
Resolves #5290
2023-05-29 15:29:08 -07:00
osy d2eb90befe utmctl: add clone command
Resolves #5004
2023-04-17 22:21:05 -07:00
osy 1d42ceb7fe scripting: add make virtual machine 2023-03-19 21:11:22 -07:00
osy 4042184472 utmctl: add commands file, exec, and ip-address 2023-03-14 13:37:11 -07:00
osy 9d6e59f5ef utmctl: update help text for commands 2023-01-03 19:12:11 -08:00
osy bd5de65406 scripting: use the right error description override 2023-01-03 18:29:00 -08:00
osy ad4124c273 utmctl: fix typo
Fixes #4849
2022-12-27 16:35:25 -08:00
osy fcae691742 utmctl: fix crash from utmctl help attach
Indicate to the user that the "attach" command is not yet working.

Fixes #4817
2022-12-27 16:25:36 -08:00
osy 2daa38ac35 scripting: add support for disposible mode 2022-12-16 13:58:25 -08:00
osy efae53e7bf utmctl: support name identifiers 2022-12-16 13:58:25 -08:00
osy 4a08edbd41 utmctl: support auto-hiding main window 2022-12-15 13:55:11 -08:00
osy b2b85f39a1 utmctl: verbose response on error 2022-12-15 13:26:57 -08:00
osy 8839b605ea utmctl: rewrote to use scripting bridge 2022-12-14 22:35:46 -08:00
osy f6f60fa77f utmctl: start UTM if needed 2022-12-11 15:48:47 -08:00
osy 84745e6b8c api: implement base set of commands 2022-12-11 01:00:25 -08:00
osy b0dc93a593 api: implement foundation for API client/server
Use UNIX domain sockets as the underlying communication interface between UTM
and the API clients. The application layer is JSON decoded into Swift structs.

A pure Swift socket implementation with support for Swift Concurrency powers
the client/server interface. A server is spawned as a detached Task and all
clients are handled in a TaskGroup.

The CLI interface is the first client for the API.
2022-12-11 01:00:25 -08:00
osy 089012046b project: add CLI tool 2022-12-11 01:00:25 -08:00