For macOS this brings up a dialog, asking the user if they are sure
they want to shut down, which makes this less useful for automated
graceful shutdowns, but it may behave better on Linux, and there
might be ways to instruct macOS to not ask the user, so it's still
a nice feature, and aligns with the SIGUSR1 for suspend, and SIGINT
for non-graceful shutdown.
* Drop Monterey Support
People will still be able to run and SSH into Monterey VMs or use VNC but pointing devices/keyboard won't work.
Fixes#841
* Fixed x86 build
* Give Virtualization.framework a chance to stop the VM on tart stop
We were letting the CancellationError bubble up all the way until
it terminated app, which meant we didn't hit the shutdown code
in run(), stopping the VM and the network.
We now catch CancellationError and proceed to gracefully shut down.
We only stop the VM if it's still running, as a VM that has been
stopped via the menu can't be stopped again.
* Gracefully shut down VM when Tart is quit via menu
Normally the quit action will result in AppKit calling exit(),
but we want to gracefully shut down the VM, so we use the same
path as for closing of the VM window, namely signal our own
process with SIGINT or SIGUSR1.
If that doesn't work we let AppKit terminate as before.
This fixes the "Warning: NSActivity <_NSActivityAssertion:
0x600001f785a0> was ended multiple times" warning seen on
the console when quitting Tart via the menu.
* Activate Tart after application finishes launching
This ensures that the VM window has been shown by the time we
activate, so that we consistently activate and bring the VM
window to the front.
* add VM completion for run command
* add VM completion for stop command
* create ShellCompletions utilities
* add shell completions to some commands
* add shell completion for fqn command
* run command: fix tiny typo
* add shell completion for get command
* more shell completions
* remove unnecessary `try`
* refactor ShellCompletions file
The URLSession async/await functions do not report progress through
the normal URLSessionTaskDelegate callbacks, as reported in:
https://developer.apple.com/forums/thread/723015
We don't want to use URLSession.bytes, as that results in a much
slower download speed compared to URLSession.download, but we can
work around the lack of progress callbacks by observing the
progress on the URLSessionTask itself.
Fixes#767
We wrap the installation with a withTaskCancellationHandler, which
ensures that the SIGINT signal handling code in main() will trigger
a cancellation of the installer.
As the VZMacOSInstaller must be both created and interacted with
on the VM's queue, which in our case is the main queue, we need
to move the logic to a separate function tagged with @MainActor.
This makes sense either way, as it cleans up the code a bit.
* Improve macOS app integration
Tart is now a proper application bundle, with the name and icon
declared in the Info.plist, which we were missing.
This also allows us to declare the app as LSBackgroundOnly
as a default, which means that 'tart create' and similar
background commands will not show the application icon in
the dock, while 'tart run' will, thanks to it overriding
the activation policy of the app.
For now the logic of creating the Tart.app bundle is duplicated
between the CI packaging scripts and the run-signed.sh script.
Now that these scripts are growing, it makes sense to look
at whether we can share the logic somehow, e.g. by building
the application bundle directly during build, and packaging
that, instead of creating it as a post install step.
* Integration tests: fix DockerContainer import
To work around the breaking change in 4.0.0,
see 383b12e9d6.
* .cirrus.yml(Release (Dry Run)): no need to install Sentry CLI
---------
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
Right now we show only actual size of files on disk which excludes empty blocks of the recently introduced sparced format in #671. This makes impossible to get info about disk size that we just set via `tart set`.
Here is an example of `tart list` output before the change:
```
Source Name Size State
local sonoma-base 22 stopped
local sonoma-vanilla 18 stopped
local sonoma-xcode 67 stopped
local ubuntu 1 stopped
oci ghcr.io/cirruslabs/macos-sonoma-base:latest 22 stopped
oci ghcr.io/cirruslabs/macos-sonoma-base@sha256:16c1593bbaf787b20b3c0bc094c5b6baf71c937d22c2e4596da85ac55c92e6cc 22 stopped
oci ghcr.io/cirruslabs/macos-sonoma-vanilla:14.3 17 stopped
oci ghcr.io/cirruslabs/macos-sonoma-vanilla@sha256:23c4e853d48d00a4333346d66a32b2b5aad900cc0dc10e7ecb9dbe67b6f587f4 17 stopped
oci ghcr.io/cirruslabs/macos-sonoma-xcode:latest 67 stopped
oci ghcr.io/cirruslabs/macos-sonoma-xcode@sha256:d0cb8d01424a68b89e0f16f5371bf2152b2c115bd886341a6ba8da42121d1f41 67 stopped
oci ghcr.io/cirruslabs/ubuntu:22.04 1 stopped
oci ghcr.io/cirruslabs/ubuntu@sha256:037763feb7a15d6077edeb7a097738c34313637d16036764b4c196d28d8b429c 1 stopped
```
And here is the output after the change:
```
Source Name Disk Size State
local sonoma-base 50 22 stopped
local sonoma-vanilla 50 18 stopped
local sonoma-xcode 90 67 stopped
local ubuntu 20 1 stopped
oci ghcr.io/cirruslabs/macos-sonoma-base:latest 50 22 stopped
oci ghcr.io/cirruslabs/macos-sonoma-base@sha256:16c1593bbaf787b20b3c0bc094c5b6baf71c937d22c2e4596da85ac55c92e6cc 50 22 stopped
oci ghcr.io/cirruslabs/macos-sonoma-vanilla:14.3 50 17 stopped
oci ghcr.io/cirruslabs/macos-sonoma-vanilla@sha256:23c4e853d48d00a4333346d66a32b2b5aad900cc0dc10e7ecb9dbe67b6f587f4 50 17 stopped
oci ghcr.io/cirruslabs/macos-sonoma-xcode:latest 90 67 stopped
oci ghcr.io/cirruslabs/macos-sonoma-xcode@sha256:d0cb8d01424a68b89e0f16f5371bf2152b2c115bd886341a6ba8da42121d1f41 90 67 stopped
oci ghcr.io/cirruslabs/ubuntu:22.04 20 1 stopped
oci ghcr.io/cirruslabs/ubuntu@sha256:037763feb7a15d6077edeb7a097738c34313637d16036764b4c196d28d8b429c 20 1 stopped
```
Additionally, `tart get` will print actual size with a 3 decimal point precision which will help to track growth in disk images for our templates.
`tart get` before:
```
CPU Memory Disk Display State
4 8192 67 1024x768 stopped
```
`tart get` after:
```
CPU Memory Disk Size Display State
4 8192 90 67.333 1024x768 stopped
```
From a discussion in #728 it appeared that having both `--graphics` and `--no-graphics` is a bit confusing.
`--graphics` was introduced in #248 to support having both VNC and UI for debugging Packer plugin in cirruslabs/packer-plugin-tart#21. This is because `--vnc` flag has a side effect of hiding UI which I think was wrong in retrospective. One can run `tart run --vnc --no-graphics`. In most of the cases this is automated via Alfred or something like that.
Now we have so many arguments that IMO it's worth to remove `--graphics` for overall consistency in arguments: everything is enabled by default and can be disabled via `--no-*` flags.
* Build x86 binary
To support Linux VMs on Intel aka x86_64
* Fixed paths and formatting
* Unique IDs
* Fixed Goreleaser
* Skip creation integration test for now
* import
* Reenable create test
* Revert "Reenable create test"
This reverts commit 4c947c1f0e.
* Reenable create test
* tart create --linux: allow scaling VM down to 1 CPU and 256 MiB
* Revert "tart create --linux: allow scaling VM down to 1 CPU and 256 MiB"
This reverts commit 7a31443eea.
* Check minimum CPU and memory sizes in "tart set"
* Print put errors from Docker Helpers
* Update Sources/tart/Credentials/DockerConfigCredentialsProvider.swift
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
* Check output data is not empty
---------
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
* Package tart binary into app bundle when running via run-signed.sh
This is what happens when installing the tart application package
as built by CI. We should stay as close as possible to the install
situation during development, so that we get bug/behavior parity.
For example, an app bundle behaves differently than a standalone
executable when it comes to bringing up a Dock icon for the app.
* Set activation policy to prohibited when starting in no graphics mode
This ensures that the Dock icon is hidden.
* Support mounting remote archives
Allow to pass an HTTPS link instead of a local path to `tart run --dir` argument. HTTPS link should point to a gzipped Tar archive aka `*.tar.gz` file.
In this situation Tart will download an archive by the link if necessary, will cache it and will unarchive it into a temporary folder inside `$TART_HOME` to be mounted to the VM.
This use case is useful for mounting something external that updates faster than the VM itself. For example, GitHub Actions Runner installation.
* Don't use async/await APIs to prevent from deadlocks because of the MainActor thing
* Prefer cached data
* Moved comment
* Fix URLCache caching files in memory instead of on-disk (#622)
* Fix URLCache caching files in memory instead of on-disk
* Fix disk capacity typo
* Moved log
* Moved fetching logic to `DirectoryShare#createConfiguration` method
---------
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
* Improved format for fast and efficient pulls from remote OCI-registry
* Tests: introduce fileWithRandomData() helper function
* Remove useless continuation
* --concurrency should be an option, not an argument
* --v2-disk-format → --old-disk-format and use the new V2 by default
* Reduce LZ4 buffer size from 64 to 4 MiB
* --old-disk-format → --disk-format=...
* Support wildcards in `credHelpers`
With #591 `tart pull` fails when for example you have `ecr-login` set as the default `credsStore` but you try to pull our images from `ghcr.io`.
This change reverts #591 and instead supports regex in `credHelpers`. This is not supported by Docker itself but highly demanded in https://github.com/docker/cli/issues/2928
I think it's fine to support it for Tart.
Additionally this change bumps the minimum host macOS version to Ventura in order to bring `Regex`. Yes, `Regex` only supported in Swift for macOS 13+ 🤦♂️I think it's fine in the light of Sonoma release and Tart 2.0.0.
* Removed Monterey mentions from docs
This way for #581 we don't need to specify a fully quialified URL and can simply use the following `~/.docker/config.json`:
```json
{
"credsStore": "ecr-login"
}
```
Related to https://github.com/docker/cli/issues/2928
* GC avoidance and tmpDeterminstic
* change tmpDeterministic to use hashing
- temporaryDeterministic() now takes in a key and hashes it
- creates directory with the hash
* Update Sources/tart/VMStorageOCI.swift
Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
---------
Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
* Don't delete an initiator of pruning
Sometimes people have an image that is greater than half of the disk itself. In that case such image will be pulled and prunned right away.
This change makes sure that an image that is being cloned from is not pruned right away.
* Resolve symbolic links
* Allow mounting a single directory without a name
To utilize `VZSingleDirectoryShare` which seems more stable than `VZMultipleDirectoryShare`.
We've been having reports from users that mounted directories occasionally return "no such file" errors when building large projects. I took a stab at reproducing the issue by running https://github.com/devMEremenko/XcodeBenchmark in a mounted directory:
```bash
tart run --dir=workdir-test:~/workspace-temp/XcodeBenchmark ventura-xcode
```
And I was able to reproduce the "no such file" error on the first try! After looking into the issue I decided to try `VZSingleDirectoryShare` as this PR changes and to my pleasant surprise it all worked like a charm the next run. So it seems there is a bug in `VZMultipleDirectoryShare` integration with virtiofs. Since in most cases users only mount a single directory it makes sense to allow doing it wihtout providing a `name`.
So now it will be possible to run the following command:
```bash
tart run --dir=~/workspace-temp/XcodeBenchmark ventura-xcode
```
Which will make `~/workspace-temp/XcodeBenchmark` available under `/Volumes/My Shared Files/` without any intermediate directories.
* Reformat
* Updated description
* Suspend/resume support
* Use RuntimeError.SuspendFailed for consistency's sake
* Add a comment about "Running" field deprecation
* Use compute credits
* Use Mac-specific input devices and remove --no-{audio,entropy}
* Suspend the VM when closing window and running with --suspendable
* Snapshotting Improvements (#539)
* Don't use static field for arguments
It throws a runtime error
* Fixed suspendability
* Lazy generation of new MAC addresses
To support cloning on suspended VMs
* Refactored
* formatted
* Configurable signal for window closing
* reformatted
* Don't generate MAC only for suspended VMs
* Removed misleading comment
* Reverted
* Lock while a suspendable VM is starting
* Lock on TART_HOME
---------
Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
* Optimistically check if we need to do anything on a pull
Right now on a pull we always acquire a lock for a registry host. This is problematic because, for example, host can be pulling `ghcr.io/cirruslabs/macos-ventura-xcode:15-beta-2` image when a new request will come to pull `ghcr.io/cirruslabs/macos-ventura-xcode:latest` if needed.
In this situation, even though `ghcr.io/cirruslabs/macos-ventura-xcode:latest` is already cached and linked, `tart pull` will wait for a lock.
This change optimistically check if there is something to do at all before acquiring a lock.
* Fix linter errors
---------
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
* tart push: allow pushing OCI VMs from the cache too
* Check for RemoteName earlier
* Refactored pushing of OCI images under new tag (#466)
* Refactored pushing of OCI images under new tag
* Fixed compilation
---------
Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
* tart list: show if the VM is running or not
* Boolean "running" field instead of "state", similarly to "tart get"
* Re-use VMDirectory.running() in "tart get"
* Option to pass externally created serial console
See https://github.com/cirruslabs/tart/pull/364#issuecomment-1472111742 for details
* Fixed compilation
* Apply suggestions from code review
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
---------
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
* support ZVirtioConsoleDevice for linux vm, user can control the vm via serial port with screen command
* cleanup code, fix indent
* add --serial option to tart
* remove serial in vmconfig, fix Serial.swift
---------
Co-authored-by: peternguyen93 <peternguyen9321@gmail.com>
Co-authored-by: peter <peter@starlabs.sg>
* JSON output for `get` and `list` commands
In the light of the upcoming `1.0.0` release and stabilizing of the API, let's introduce some breaking changes for the good.
Removed all the `--cpu`, `--memory`, `--disk` and `--display` flags and replaced with a single `--json` flag for machine-readable output.
Added `--json` option to the `list` command to output a single JSON list. Notably removed `--quite` flag since it seemed unnecessary.
Fixes#297
* Added Size to `list` output
Fixes#379
* Added running state to `get`
Fixes#393
* Better signature
* Updated tests
* More test fixes
* Introduce "tart import" and "tart export" commands
* Use AppleArchive instead of ZIP and simply {ar,un}chive the VM dir
* Fix formatting
* Link to Apple's docs
* Print "importing..." and "exporting..." lines
* Ditch Foundation.exit()'s where feasible
* Sentry integration
* SwiftFormat
* Upload symbols and sources to Sentry
* Use Sentry Releases
* Do not use ExitCode exceptions
* Clarify why we need CustomNSError extension
* Adds Option to filter VMs by 'source'
* Tidy up columns for table on some Terminals
* Don't show headers if there's an error.
* Fixes linting errors.
* Update Sources/tart/Commands/List.swift
- removing the short name for now, as we don't know if we may need -s in the future
- removing the capitalization for the word "source" and adding an example instead
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
* source should be an Optional flag. Reverts header change.
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>