Commit Graph

382 Commits

Author SHA1 Message Date
Fedor Korotkov bf03873c8d
Validate that a disk is not amd64 (#673)
To improve UX for cases like #672
2023-11-28 14:55:34 +00:00
Nikolay Edigaryev bad37b129c
DiskV2: write layers sparsely to avoid unnecessary disk usage (#671) 2023-11-27 23:27:07 +04:00
Nikolay Edigaryev 0f47cca746
MAC address resolver: skip expired leases (#669) 2023-11-27 10:12:36 -05:00
Fedor Korotkov aca768a838
Print put errors from Docker Helpers (#654)
* 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>
2023-11-10 22:44:51 +04:00
Tor Arne Vestbø 68b3557747
Hide dock icon in no graphics mode (#653)
* 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.
2023-11-10 09:05:20 -05:00
Fedor Korotkov b2c923f2fe
Properly enter main even loop in headless mode (#651)
Fixes #638
2023-11-09 00:05:00 +04:00
Fedor Korotkov c75009e46f
Introduce `--capture-system-keys` flag (#650)
To allow guest to capture things like Cmd+Tab.

Fixes #636
2023-11-08 20:21:55 +04:00
Nikolay Edigaryev 70040b633c
Introduce AuthenticationKeeper actor to serialize authn modification (#647) 2023-11-06 14:58:23 -05:00
Nikolay Edigaryev f4bc02d175
DiskV2.push(): map disk into memory to avoid large allocations (#645) 2023-11-03 17:13:10 +04:00
Nikolay Edigaryev d8b69de52d
Fetcher.fetchViaFile(): use an mmap(2)-ed file, similarly to DiskV1 (#641)
* Fetcher.fetchViaFile(): use an mmap(2)-ed file, similarly to DiskV1

* No need to convert Data to Data
2023-11-01 15:00:48 +04:00
Fedor Korotkov b95585b56b
Don't forget to finalize output stream (#640)
There is a suspicion that this might leak memory
2023-11-01 12:19:11 +04:00
Fedor Korotkov 8d5574ed3f
Removed usage of deprecated APIs (#628)
See https://developer.apple.com/documentation/virtualization/vzmacauxiliarystorage/3816043-init
2023-10-11 17:05:49 -04:00
Fedor Korotkov 8e9d61d5f5
Validate that a suspendable VM doesn't have shared directories (#623) 2023-10-04 20:21:45 +04:00
Fedor Korotkov 71d03226fe
Support mounting remote archives (#620)
* 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>
2023-10-03 23:01:29 +04:00
Nikolay Edigaryev 36dab9878d
tart: bump max password characters from 256 to 1024 (#618) 2023-10-02 13:58:55 +00:00
Nikolay Edigaryev f634002813
tart run: disable console device when --suspendable is requested (#615) 2023-09-30 21:13:44 +04:00
Fedor Korotkov 50ce44c3eb
Support block devices on Sonoma (#611)
* Support block devices on Sonoma

* Updated docs

* Removed unused error
2023-09-22 22:30:18 +04:00
Fedor Korotkov 6df50e55d8
`--suspendable` devices fallback on Ventura host (#605)
Fixes #604
2023-09-22 07:38:13 -04:00
Nikolay Edigaryev 3ff4fc34c6
Improved format for fast and efficient pulls from remote OCI-registry (#589)
* 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=...
2023-09-20 10:14:05 -04:00
Nikolay Edigaryev 27cadc3f3b
tart create --from-ipsw: do a HEAD instead of a GET first (#599) 2023-09-14 17:16:08 +00:00
Nikolay Edigaryev d4d3852745
Return exit code 2 on RuntimeError.VMDoesNotExist (#597)
* Return exit code 2 on RuntimeError.VMDoesNotExist

* Upgrade isFileNotFound() do detect underlying errors
2023-09-12 13:56:49 +04:00
Fedor Korotkov 4bb248e7b4
Support wildcards in `credHelpers` (#592)
* 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
2023-08-28 11:37:49 -04:00
Fedor Korotkov f45551cbf0
Support Docker's `credsStore` (#591)
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
2023-08-21 19:44:35 +00:00
Fedor Korotkov 637a2387e7
No bridged network interfaces by default (#586)
Fixes #585
2023-08-15 19:47:25 +04:00
Nikolay Edigaryev 5eddd1ce41
Introduce "tart logout" command (#583)
* Introduce "tart logout"

* tart login: introduce --no-validate
2023-08-15 15:16:33 +04:00
Fedor Korotkov 35f5b30bc4
Multiple bridged interfaces (#578)
* Support multiple Bridged Network interfaces

Fixes #572

* Allow duplicated bridged interfaces
2023-08-14 19:17:38 +04:00
Tommy feb733a7c0
GC avoidance and tmpDeterminstic (#570)
* 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>
2023-07-31 18:21:42 +00:00
Fedor Korotkov 704811e671
Introduce `TART_NO_AUTO_PRUNE` (#565)
* Introduce `TART_NO_AUTO_PRUNE`

Similar to `HOMEBREW_NO_AUTO_UPDATE`

* Self review
2023-07-25 16:01:53 +00:00
Nikolay Edigaryev 33ca96e1a0
Retrieve VM's IP for use in VNC after the VM is started #2 (#562) 2023-07-17 12:51:43 +04:00
Nikolay Edigaryev 6c377029d6
tart prune: allow pruning local VMs with --entries=vms (#557) 2023-07-13 22:05:28 +04:00
Fedor Korotkov 93a1b70ecb
Don't delete an initiator of pruning (#556)
* 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
2023-07-13 13:59:23 +04:00
Fedor Korotkov cf9a3a9221
Allow mounting a single directory without a name (#555)
* 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
2023-07-12 19:08:52 +00:00
Stanisław Chmiela ad566faa23
Add OCI annotation with upload time (#551) 2023-07-11 19:02:38 -04:00
Fedor Korotkov 1afaa7ec7a
Reclaim disk space only in the very end of `tart clone` (#553)
* Reclaim disk space only in the very end of `tart clone`

Please check comments in code for reasoning.

* Phrasing

* Removed hidden argument
2023-07-11 15:49:43 +00:00
Stanisław Chmiela 8653ca4115
Fix `prune --older-than` deleting all cache (#549)
* Fix `prune --older-than`

* Update Sources/tart/Commands/Prune.swift

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>

---------

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
2023-07-11 16:10:49 +04:00
Nikolay Edigaryev 63b74f407b
Version console device (#546) 2023-07-10 15:23:50 +00:00
Nikolay Edigaryev 3a2cba6929
Introduce TART_REGISTRY_HOSTNAME (#545)
* Introduce TART_REGISTRY_HOST

* TART_REGISTRY_HOST → TART_REGISTRY_HOSTNAME
2023-07-10 18:19:21 +04:00
Stanisław Chmiela 7592b86663
Add `host` to `Registry` taking `port` into consideration (#544) 2023-07-07 18:32:41 -04:00
Fedor Korotkov e8dbb86fc0
Support stopping of suspended VMs (#541) 2023-07-07 13:38:34 +04:00
Fedor Korotkov d2ed4ef801
Resume suspended VMs without explicit `--suspendable` flag (#540) 2023-07-07 11:38:31 +04:00
Nikolay Edigaryev 2014de7dac
Suspend/resume support (#527)
* 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>
2023-07-06 18:04:39 +00:00
Nikolay Edigaryev 1f23b24920
PIDLock: check open(2) error (#538)
* PIDLock: check open(2) error

* Bump Sentry to 8.8.0
2023-07-04 15:22:25 +00:00
Fedor Korotkov 1a2f187ac8
Fixed mouse/keyboard on Monterey guest (#535)
I guess [my comment was accurate](https://github.com/cirruslabs/tart/pull/524/files#r1239939939). Fixes #534

Tested by running `ghcr.io/cirruslabs/macos-monterey-base:latest` locally on a Sonoma host.
2023-07-01 10:35:45 +04:00
Fedor Korotkov 415ed3388d
Optimistically check if we need to do anything on a pull (#531)
* 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>
2023-06-29 10:51:41 -04:00
Nikolay Edigaryev 870b414994
tart clone: try to reclaim disk space if needed (#532) 2023-06-29 18:46:00 +04:00
Stefan Mitterrutzner be7011bf11
Adds the OCI access_token fallback field (#530) 2023-06-29 10:33:20 +00:00
Nikolay Edigaryev 1b53ce42f8
Use Mac-specific input devices when possible (#524)
* Use VZMacKeyboardConfiguration when possible

* Use VZMacTrackpadConfiguration when possible
2023-06-23 17:54:47 +00:00
Nikolay Edigaryev e89ef32a83
Enable automatic display reconfiguration for Sonoma (#521)
* Enable automatic display reconfiguration for Sonoma

* Xcode 15 Beta

---------

Co-authored-by: fedor <fedor.korotkov@gmail.com>
2023-06-23 15:25:22 +00:00
Nikolay Edigaryev 62a34bf89f
Fix "file “config.json” couldn’t be opened" error when pruning (#525)
* Fix "file “config.json” couldn’t be opened" error when pruning

* No need to use the ";"
2023-06-23 15:23:25 +00:00
Nikolay Edigaryev 9016fcfdd4
Use MainActor to ensure we're running on main queue (#515)
* Use MainActor to ensure we're running on main queue

...and to simplify the code.

* VZVirtualMachine.requestStop() is not asynchronous
2023-06-07 15:06:33 +04:00
Nikolay Edigaryev cf49fd10b6
Print errors to stderr (#504) 2023-05-18 19:11:22 +04:00
Fedor Korotkov 8e11bbe1cd
Improve error reporting for unsupported host OS version (#491)
Fixes #489
2023-05-07 21:07:26 +04:00
Nikolay Edigaryev 6de31de6bf
tart login: trim newline characters at the end of --password-stdin (#486) 2023-05-04 14:02:46 +04:00
Nikolay Edigaryev 4f70d01dd6
Set User-Agent header for OCI HTTP requests (#478)
* Set User-Agent header for OCI HTTP requests

* IORegistry value is actually a NUL-terminated C string

* Use sysctl instead of IOKit
2023-04-28 18:02:57 +04:00
Nikolay Edigaryev b03408f856
tart ip: wait for the VM to start if --wait was set (#467) 2023-04-10 10:37:00 +00:00
Nikolay Edigaryev 1d3aa5ac81
tart push: allow pushing OCI VMs from the cache too (#465)
* 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>
2023-04-06 14:20:04 +00:00
Fedor Korotkov 261c1806df
Improve `tart ip` error message (#464)
Resolves #460
2023-04-05 18:19:39 +00:00
Fedor Korotkov e1bb565c3b
UI improvements (#459) 2023-03-31 10:58:14 -04:00
Nikolay Edigaryev 9b26d30c42
tart import: fix import failing due to SIGBUS (#458) 2023-03-30 15:52:48 +04:00
Nikolay Edigaryev e72fcd9b19
tart list: show if the VM is running or not (#456)
* 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"
2023-03-29 08:51:53 -04:00
Nikolay Edigaryev 33a51b7344
tart export: make export path optional (#454) 2023-03-27 16:59:57 +00:00
Fedor Korotkov f62949b6f4
Option to pass externally created serial console (#448)
* 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>
2023-03-17 13:52:13 +00:00
Nikolay Edigaryev d7561cab0b
Graceful Softnet termination (#434) 2023-03-16 18:37:46 +04:00
fedor 066f585c53 Reformatted Serial.swift 2023-03-16 10:22:27 -04:00
Peter Nguyen d8ac36b3bd
support ZVirtioConsoleDevice for linux vm (#364)
* 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>
2023-03-16 10:21:13 -04:00
Fedor Korotkov 4a454a3115
Allow to choose IP resolution strategy (#446)
Haven't seen any reports of the `arp` vs DHCP issues so I think it's reasonable to remove the warning and allow to customize the resolution strategy.
2023-03-16 17:41:54 +04:00
Fedor Korotkov 1f35a9b35e
Fixed error message for incorrect memory (#426) 2023-02-27 18:32:40 +04:00
Nikolay Edigaryev 2be5eedeb6
Try to set a SUID bit on Softnet using Sudo before failing (#421)
* Try to set a SUID bit on Softnet using Sudo before failing

* .cirrus.yml: switch to the new Mac machine
2023-02-17 08:50:57 +04:00
Fedor Korotkov 78f7ba8f80
Remove Reporting (#411) 2023-02-09 20:47:54 +04:00
Fedor Korotkov b242f27f49
Ignore GC errors (#405)
* Ignore GC errors

Such errors are not critical

* Print GC error to stderr
2023-02-09 00:15:34 +04:00
Nikolay Edigaryev b566d07bc4
Avoid URL.formatted() method (#408) 2023-02-08 06:52:01 -05:00
Fedor Korotkov def779e20b
Report to Sentry instead of Puppy (#402)
Instead of logging locally let's report to Sentry.
2023-02-07 20:04:45 +04:00
Fedor Korotkov b8ff7474c3
Removed `--with-softnet` flag (#401)
Fixes #276
2023-02-05 21:56:23 +04:00
Fedor Korotkov f34aa5f072
JSON output for get and list commands (#394)
* 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
2023-02-04 11:40:39 +04:00
Fedor Korotkov ecc5de18be
Collect installation information (#390) 2023-02-02 06:12:28 -05:00
Nikolay Edigaryev 41af674a88
Introduce "tart import" and "tart export" commands (#386)
* 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
2023-02-01 15:27:05 -05:00
Nikolay Edigaryev ba4f00fa78
Fix ArgumentParser's exception printing (#367) 2022-12-21 18:06:01 +04:00
Nikolay Edigaryev 1380ece108
Use separate exception codes for better Sentry grouping (#363) 2022-12-19 17:40:55 +00:00
Fedor Korotkov 9cdb7087f2
Fixed --help (#361)
* Fixed --help

Apparently `--help` works via exceptions 🤷‍♂️

Fixes #360

* lint issue
2022-12-17 20:57:17 +04:00
Fedor Korotkov 828351a8fb
Report pull metrics to Sentry (#354)
* Report GC events to Sentry

* Formatting

* Use transactions for measuring pull duration on cache miss

* Fixed linting

* Explicitly enable capturing of failed requests

* Allow customizing tracesSampleRate

* bindToScope

* Measure compressed disk size

* Don't capture GC events
2022-12-15 16:53:34 -05:00
Nikolay Edigaryev f9ac994e18
Fix inverted VMStorageOCI.link() logic (#355) 2022-12-15 21:18:33 +00:00
marc-48k fdeaf979c2
Get command (#353)
* (wip) First pass at Get command.

* Adds validation in case multiple options are supplied.
2022-12-15 22:52:22 +04:00
Nikolay Edigaryev d9f1c37cdd
Sentry integration (#352)
* 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
2022-12-15 13:50:21 +00:00
Fedor Korotkov 81253417a4
Optimal buffer sizes for Softnet socket (#351)
* Optimal buffer sizes for Softnet socket

* Formatting
2022-12-14 23:18:39 +04:00
marc-48k c9caeab098
Filter tart list by source (#349)
* 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>
2022-12-14 13:08:35 -05:00
Nikolay Edigaryev 15b26f78ae
Registry: include port when looking up credentials (#346) 2022-12-05 09:56:48 -05:00
Nikolay Edigaryev 31635e59d7
Don't swallow VZVirtualMachine.start() exceptions (#343)
* Don't swallow VZVirtualMachine.start() exceptions

* Rename task to startTask for clarity

* No need to use "self"
2022-12-01 14:03:21 -05:00
Nikolay Edigaryev ad9c3c661e
Reformat code idents and introduce the SwiftFormat linter (#339)
* Package.swift: add SwiftFormat

Can be invoked with "swift package plugin swiftformat".

* $ swift package plugin swiftformat

* .cirrus.yml: run SwiftFormat

* SwiftFormat: exclude Sources/tart/OCI/Reference/Generated
2022-11-29 15:56:13 +00:00
Nikolay Edigaryev c27d4a089c
OCI: WWW-Authenticate's scheme should be treated case-insensitive (#336) 2022-11-25 16:59:38 +04:00
Nikolay Edigaryev 70f9fcc12e
tart run: do not check --disk lock for read-only attachments (#334) 2022-11-22 22:37:48 -05:00
Nikolay Edigaryev 456ebc1c7b
Rosetta support (#324) 2022-11-21 12:56:27 -05:00
Nikolay Edigaryev 14cbc727ad
tart run: check if the disks are locked (#333) 2022-11-21 17:42:53 +04:00
Nikolay Edigaryev c09cbefdd0
VZVirtualMachineDelegate implementation: show the error details (#330) 2022-11-18 18:51:26 +04:00
sheldonneuberger-sc de993fbf6d
use 64bit int for memory (#327) 2022-11-16 14:52:28 -05:00
Nikolay Edigaryev f08ddf3855
Fetch IPSWs via file (#322) 2022-11-15 10:01:52 +04:00
Nikolay Edigaryev 8524d93741
Integration tests (#313)
* Integration tests

* Set "HOMEBREW_NO_AUTO_UPDATE=1" for virtualenv installation step

* Use CIRRUS_WORKING_DIR as temporary directory if present
2022-11-14 13:24:51 -05:00
Nikolay Edigaryev 833c162187
tart stop: return a different exit code when VM is not running (#321)
See https://github.com/cirruslabs/tart/pull/316#issuecomment-1311556674.
2022-11-11 14:20:21 -05:00
Fedor Korotkov 31ba71dad7
Option to provide registry credentials via environment variables (#320)
Fixes #124
2022-11-11 18:32:23 +04:00
Nikolay Edigaryev 5e77968989
Introduce "tart stop" (#316) 2022-11-11 07:59:22 +04:00
Evan Burkey f37372da28
Implement Get command (#309) 2022-11-10 09:14:14 +04:00
Nikolay Edigaryev e600d2f036
Improve UninitializedVMDirectoryError() (#314) 2022-11-09 20:49:35 -05:00
Nikolay Edigaryev b21dbbe3a3
Fetcher: do not use cookies to avoid CSRF checks (#312)
* Fetcher: do not use cookies to avoid CSRF checks

* Explain why we disable cookies

* Rename getURLSession() → createURLSession() and move it below
2022-11-09 14:27:45 -05:00
Nikolay Edigaryev ee0fbdd83d
OCI: pull blobs via file (#306)
* OCI: pull blobs via file

* Explain why we delete the downloaded file after opening a handle to it

* Further abstract away ways to fetch a URLRequest

* No need to cast HTTPURLResponse to HTTPURLResponse

* Fetcher: no need to be a delegate anymore

* Fetcher.fetch() can be made static
2022-11-09 19:36:41 +04:00
Nikolay Edigaryev fb954b7cc1
tart list: support -q (or --quiet) for automation purposes (#293) 2022-11-02 11:49:45 -04:00
Pete Goldsmith 3d0d889c99
Remove whitespace (#285) 2022-10-22 08:17:42 -04:00
Nikolay Edigaryev 0e77f14dd7
OCI: always read channel until end (#284) 2022-10-18 11:44:14 -04:00
Nikolay Edigaryev 39e1b84423
Use URLSession.dataTask() with delegate instead of URLSession.bytes() (#282)
* Use URLSession.dataTask() with delegate instead of URLSession.bytes()

* Use URLSession.shared instead of creating a new one each time
2022-10-18 08:54:28 -04:00
Fedor Korotkov af7530ee50
Relax status code acceptance (#281)
* Relax status code acceptance

Fixes #273

* added a comment
2022-10-17 21:42:25 +04:00
Nikolay Edigaryev 36bb68a72d
tart run: deprecate --with-softnet and introduce --net-softnet (#274) 2022-10-14 18:38:39 +04:00
Nikolay Edigaryev afd707eedf
OCI reference parser: allow dashes in host name (#275) 2022-10-14 16:36:25 +04:00
Nikolay Edigaryev c67efb88f3
Fix tart prune --cache-budget logic (#272) 2022-10-14 01:43:37 +04:00
Nikolay Edigaryev 667de2a199
Monitor Softnet process and throw if it terminates prematurely (#270) 2022-10-12 20:00:13 +04:00
Nikolay Edigaryev 44650e9713
Improve RemoteName parser (#225) (#269)
* Improve RemoteName parser

* Remove Parsing import

* Permit namespace components to contain separators, but no more than one

* Add testNoPathTraversal
2022-10-11 22:59:44 +04:00
Nikolay Edigaryev 62ee42de3b
Plug URLSession.bytes() memory leak (#267) 2022-10-10 18:38:57 +04:00
Nikolay Edigaryev 89301d114e
Log cache pruning to $TART_HOME/tart.log (#265)
* Log cache pruning to $TART_HOME/tart.log

* Log zero capacities
2022-10-07 23:01:42 +04:00
Nikolay Edigaryev dbb33d0651
Don't download IPSWs into memory (#262) 2022-10-06 20:33:34 +04:00
Nikolay Edigaryev 166e3e570f
Ditch AsyncHTTPClient in favor of URLSession (#260) 2022-10-05 00:39:36 +04:00
Nikolay Edigaryev 7a2c20ba30
tart create: support fetching URLs specified in the --from-ipsw option (#256)
* tart create: support fetching URLs specified in the --from-ipsw option

* Use x-amz-meta-digest-sha256 header to cache IPSWs
2022-09-27 23:36:18 +04:00
Nikolay Edigaryev e90d53eceb
tart delete: allow removing multiple VMs at once (#257) 2022-09-27 10:30:44 -04:00
Nikolay Edigaryev afbc2e0764
tart ip: keep waiting for the /var/db/dhcpd_leases file to appear (#254) 2022-09-22 10:24:14 -04:00
Fedor Korotkov 0229138bd5
Fixed wait delay for IP command (#250)
I initially wanted a one-second wait but made a human mistake.

Fixes #249
2022-09-19 21:44:14 +04:00
Nikolay Edigaryev 4d08e6365e
Set line-buffered output for stdout and introduce --graphics for tart run (#248)
* Set line-buffered output for stdout

* tart run: introduce --graphics

* Update Sources/tart/Commands/Run.swift

Co-authored-by: Pete Goldsmith <peter.n.goldsmith@gmail.com>

* Update Sources/tart/Commands/Run.swift

Co-authored-by: Pete Goldsmith <peter.n.goldsmith@gmail.com>

Co-authored-by: Pete Goldsmith <peter.n.goldsmith@gmail.com>
2022-09-19 21:43:37 +04:00
Nikolay Edigaryev 4e20ea8f72
tart run: introduce --net-bridged (#245)
* tart run: introduce --net-bridged

* tart.entitlements: add com.apple.vm.networking
2022-09-14 17:53:04 +04:00
Nikolay Edigaryev 678ce0a55a
Introduce "tart rename" command to rename VMs (#246)
* Introduce "tart rename" command to rename VMs

* Remove unused SystemConfiguration import

* Update Sources/tart/Commands/Rename.swift

Co-authored-by: Pete Goldsmith <peter.n.goldsmith@gmail.com>

Co-authored-by: Pete Goldsmith <peter.n.goldsmith@gmail.com>
2022-09-14 17:44:26 +04:00
Fedor Korotkov 6321d547cf
Improve available capacity checking (#240)
* Improve available capacity checking

* Fixed expression
2022-09-12 21:55:25 +04:00
Nikolay Edigaryev f241e21614
Self-hosted temporary directory (#238) 2022-09-12 20:56:52 +04:00
Pete Goldsmith 87f29cc11f
Clarify requirements for `dir` argument (#231) 2022-09-07 09:02:46 -04:00
Pete Goldsmith 90d1393137
Handle tilde in path for directory share (#233)
* Expand Tilde in path

* Expand tilde in disk paths
2022-09-07 08:15:29 -04:00
Nikolay Edigaryev 625d431d10
Revert "Improve RemoteName parser (#225)" (#230)
This reverts commit ae7018c31f.
2022-09-06 22:13:30 +04:00
Nikolay Edigaryev 4648e1aea1
tart clone: clone VM and generate MAC under a file lock (#215)
* tart clone: clone VM and generate MAC under a file lock

* Lock concurrent "tart pull"'s for the same host

* Config: ensure Tart's home and cache directories always exist
2022-09-06 21:33:51 +04:00
Nikolay Edigaryev ae7018c31f
Improve RemoteName parser (#225)
* Improve RemoteName parser

* Remove Parsing import

* Permit namespace components to contain separators, but no more than one

* Add testNoPathTraversal
2022-09-06 17:28:49 +04:00
Pete Goldsmith e54c89da0c
Clarify if guest or host is unsupported (#228) 2022-09-06 09:23:41 -04:00
Nikolay Edigaryev 9a0ec3e6b0
Fix cache reclaimed bytes calculation (#223) 2022-09-01 16:12:48 -04:00
Fedor Korotkov 400f85a493
Check Tart Home for auto-pruning (#220)
Otherwise it's weird we check $TMP but prune $TART_HOME
2022-09-01 15:44:19 -04:00
Fedor Korotkov 0105280b5d
Support plaintext auths from Docker config (#219) 2022-09-01 23:10:52 +04:00
Nikolay Edigaryev 0cad2e454c
Directory sharing support (#211) 2022-08-30 10:26:16 +04:00
Nikolay Edigaryev 17dcf942c1
Terminate VM on GUI window close (#210) 2022-08-30 02:41:58 +04:00
Nikolay Edigaryev 6296df7c0c
Credential helpers: "credHelpers" map is optional in Docker's config (#209) 2022-08-29 16:38:51 -04:00
Fedor Korotkov c54b140750
Support Docker Helpers (#205)
Fixes #167
2022-08-29 20:26:53 +04:00
Fedor Korotkov 048a5506df
Support trackpad on macOS and clipboard sharing on Linux (#202)
Fixes #66
Relates to #14 since fixes on Linux
2022-08-27 20:05:45 +04:00
Nikolay Edigaryev 195a4b3a72
Make UnsupportedOSError more user-friendly (#192)
* Make UnsupportedOSError more user-friendly

* tart prune: allow only specifying a --gc flag
2022-08-24 15:03:54 -04:00
Nikolay Edigaryev 59393df2e1
Linux support (#190)
* Linux support

* Support macOS 12

* Improve readability a bit

* Remove useless variable
2022-08-23 22:38:50 +04:00
Nikolay Edigaryev 732c8244a4
Run garbage collection after each symlink and expose --gc in tart prune (#191) 2022-08-23 17:31:02 +04:00
Nikolay Edigaryev 9e69c8c161
testGetAndSetAccessTime: fix flakiness (#187) 2022-08-18 14:42:54 -04:00
Nikolay Edigaryev e4ac2275b9
tart ip: show a warning when DHCP lease and ARP cache entries mismatch (#186) 2022-08-18 22:25:02 +04:00
Nikolay Edigaryev 1a1f19e169
Implement garbage collection when deleting cached OCI VMs (#185)
* Properly calculate remotely-retrieved manifest digests

* Implement garbage collection when deleting cached OCI VMs
2022-08-18 17:13:06 +04:00
Nikolay Edigaryev fea916dacc
OCI blob compression: fix Data memory leak when using InputFilter (#183)
* OCI blob compression: fix Data memory leak when using InputFilter

* Rename mappedDiskOffset to mappedDiskReadOffset

* Update progress.completedUnitCount differently
2022-08-17 12:57:39 -04:00
Nikolay Edigaryev 14059a1d6f
tart {pull,clone}: add missing --insecure support (#181)
Co-authored-by: Nikolay Edigaryev <edi@microsun.local>
2022-08-17 01:31:19 +04:00
Nikolay Edigaryev 440681320a
Introduce "tart prune" command (#164) 2022-08-12 16:43:04 +03:00
Fedor Korotkov a80954c888
Do not include Content-Range for monolithic uploads (#179)
* Do not include Content-Range for monolithic uploads

Some registries still assumes it's a chunked upload and verifies the "chunk" size which is too big.

* Update Sources/tart/OCI/Registry.swift

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
2022-08-12 16:33:15 +03:00
Nikolay Edigaryev cc8201dee6
OCI: support insecure registries and custom ports (#174) 2022-08-12 16:24:14 +03:00
Fedor Korotkov 2cab49b3f1
Use Ventura APIs for recovery mode (#175) 2022-08-12 08:02:44 +03:00
Fedor Korotkov e2b7f12388
Support chunked uploads (#159)
* Support chunked uploads

* Rebase fixes

* Bump swift http client
2022-08-08 10:16:47 -04:00
Fedor Korotkov 617a5d02dc
Fixed potential infinity auth (#173)
Follow up to an attempt in #169
2022-08-08 16:50:13 +03:00
Nikolay Edigaryev b83bce4544
tart login: read whole stdin contents instead of just a line (#170) 2022-08-02 16:52:35 +03:00
Nikolay Edigaryev 7d16516b6a
OCI: gcr.io fixes (#169)
* Make sure we don't craft an URLComponents with an empty query items

* Prevent auth() infinite loop

* OCI: ignore invalid RFC 3339 formatted dates
2022-08-01 19:24:11 -04:00
Nikolay Edigaryev 56ddd8df75
OCI's HTTP client: prevent the usage of NIO Transport Services (#168) 2022-08-01 18:17:50 -04:00
Fedor Korotkov b1534a05d5
Configure audio devices to pass through the signal from/to the host (#163)
Fixes #161
2022-08-01 17:54:55 +03:00
Nikolay Edigaryev f54e7c2cab
tart login: only store one credential per registry (#162) 2022-08-01 09:55:37 +03:00
Nikolay Edigaryev 85dfa961c9
tart run: introduce --disk option (#156)
* tart run: introduce --disk option

* Document how to create disks using Disk Utility
2022-07-26 09:25:23 -04:00
Nikolay Edigaryev 3a74fc35e6
Introduce TART_HOME (#157) 2022-07-25 17:01:46 +03:00
Nikolay Edigaryev 7bf7f890c4
tart run: return exit status 2 when VM is already running (#155) 2022-07-21 07:53:47 -04:00
Nikolay Edigaryev 48cd4b47e4
Move full-fledged VNC support to --experimental-vnc (#154) 2022-07-21 12:37:43 +03:00
Nikolay Edigaryev c1dee4f9b2
Credentials: update Keychain entry if it already exists (#149) 2022-07-13 12:35:44 -04:00
Nikolay Edigaryev 52abb7589c
OCI: support Basic authentication scheme (#145)
* OCI: support Basic authentication scheme

* .isValid → .isValid()

* tart login: make --username optional
2022-07-08 16:36:00 +03:00
Nikolay Edigaryev 4386192161
tart login: introduce --username and --password-stdin flags (#143) 2022-07-05 16:32:20 +03:00
Nikolay Edigaryev 85429cea0a
Retrieve IP from DHCPD leases file instead of ARP cache (#141)
* Retrieve IP from DHCPD leases file instead of ARP cache

* Reference PLCache_read() from the retrieveRawLeases() parsing function
2022-06-30 17:58:52 +03:00
Nikolay Edigaryev 384abcd0bd
OCI: make sure annotations are sorted (#138) 2022-06-27 16:25:52 +03:00
Fedor Korotkov 92529afa23
Handle `tart run --no-graphics --vnc` properly (#137)
Let's start a VNC server but not force open Screen Sharing if `--no-graphics` is also passed.
2022-06-24 22:54:41 +03:00
Nikolay Edigaryev e12f95878e
Softnet: an alternative to built-in NAT with better isolation (#48)
* Softnet: an alternative to built-in NAT with better isolation

* Softnet: increase socketpair(2) socket buffer sizes to 1 MiB

* Pass VM's FD and MAC address to the Softnet

* Softnet: implement graceful shutdown

* Bring back the dispatchMain() and task cancellation

* tart pull: check for cancellation when pulling response body

* Don't dispatchMain() in withTaskCancellationHandler()

* Move VNC URL opening logic into VNCWrapper.open()
2022-06-21 19:17:02 +03:00
Fedor Korotkov 7efef28250
Allow VNC for Recovery mode (#134) 2022-06-20 20:08:31 +03:00
Nikolay Edigaryev 1e90752ded
Full-fledged VNC support (#126) 2022-06-20 18:53:17 +03:00
Fedor Korotkov 2020324ef5
Fixed --no-graphics (#132)
Followup to #129 which broke CLI integration because `--no-graphics` option didn't wait for anything.
2022-06-20 10:28:10 -04:00
Nikolay Edigaryev b581db5be4
OCI: make annotations optional (#130)
* OCI: make annotations optional

* Don't initialize annotations by default
2022-06-17 10:53:52 -04:00
Fedor Korotkov 89217c23a2
Fixes for Ventura (#129)
* Fixes for Ventura

Still a noob in SwiftUI and Swift concurrency, but it seems on Ventura a task group is not actually running on main or something. Either way I think this change simplifies things but launching a VM in a task and then just continuing with either VNC or built-in graphics.

* Check VM's state
2022-06-17 10:04:57 -04:00
Nikolay Edigaryev f59ef2722d
OCI: store uncompressed disk size in manifest (#128) 2022-06-17 11:14:28 +03:00
Fedor Korotkov 7759c72a76
Don't use dispatchMain (#123) 2022-06-14 11:31:31 -04:00
Raymond 4cc8a9925a
accept larger disk size (#122) 2022-06-10 09:05:57 -04:00
Nikolay Edigaryev b16bbf587a
Registry: log upload location when encountering blob pushing error (#121) 2022-06-08 17:23:16 +03:00
Fedor Korotkov 87733290e7
Smaller icon (#116)
Initially it wasn't fully following the [guidelines](https://developer.apple.com/design/human-interface-guidelines/macos/icons-and-images/app-icon/).

Fixes #112
2022-06-06 18:38:30 +03:00
Fedor Korotkov c14b46adc3
Make sure VM directory exists before moving (#111) 2022-06-03 23:22:11 +03:00
Nikolay Edigaryev 63329ef363
Atomic tart {create,clone,pull} operations using rename(2) (#109)
* tart clone: always re-generate MAC-address

This is not really an issue for non-enterprise users[1].

[1]: https://github.com/cirruslabs/tart/issues/20#issuecomment-1136944455

* Atomic tart {create,clone,pull} operations using rename(2)

* Print a nicer error message when attempting to double-run a VM

* tart clone: bring back the old MAC-address generation logic

* Ensure VMDirectory.temporary() will be deleted on failure
2022-06-01 11:02:31 -04:00
Nikolay Edigaryev 5446164a36
tart pull: introduce --populate-cache flag (#103)
* tart pull: introduce --populate-cache flag

* VMStorageOCI: introduce cache() method

* Review comments (#107)

* Rename SetCommand back to Set

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
2022-05-28 23:20:24 -04:00
Nikolay Edigaryev f3068b9055
tart login: verify credentials (#102)
* tart login: verify credentials

* Make DictionaryCredentialsProvider fileprivate to Login.swift
2022-05-26 09:31:46 -04:00
Fedor Korotkov afa6b7b46c
Auto-detect screen DPI (#106)
* Auto-detect screen DPI

Fixes #104

* Added a comment
2022-05-26 12:23:13 +03:00
Fedor Korotkov d277fb2941
Added helpfull messages to run command (#100) 2022-05-23 11:29:35 -04:00
Fedor Korotkov 088cdc51a3
Option to run with VNC (#97)
* Option to run with VNC

So copy/paste is working. For example, `tart run --vnc latest`.

Related to 14

* Add VNC task first

* Indicate the wait
2022-05-23 16:49:15 +03:00
Fedor Korotkov afb23a3e3a
Init HTTP client only if Registry is used (#99) 2022-05-21 00:26:43 +03:00
Fedor Korotkov 35904dc637
Async http client for pull/push (#95)
* Use async http client for pull/push

* Don't update progress too frequently

* Removed unused variable

* Rebased after added tests
2022-05-20 11:04:21 -04:00
Nikolay Edigaryev fec803277d
Registry functional/integration tests (#96)
* Registry functional/integration tests

* Remove DockerClientSwift import

* Encodable, Decodable → Codable
2022-05-20 09:52:37 -04:00
Nikolay Edigaryev 54a321df7f
Sort "tart list" by default (#94) 2022-05-19 15:05:16 -04:00
Fedor Korotkov 0a257a1547
Option to run in recovery mode (#91)
* Option to run in recovery mode

* Fixed typo

* Use Dynamic package to call private APIs

* Improved comment

* Move options closer to invocation
2022-05-19 08:17:05 -04:00
Nikolay Edigaryev 60c15e3e49
tart list: fix heading order (#90) 2022-05-18 14:20:52 -04:00
Fedor Korotkov a1bcbdbf0b
Bump default CPU cores (#86)
To prevent frustrations like #68
2022-05-18 18:12:45 +03:00
Nikolay Edigaryev c2da3fd919
Support "tart --version" (#81)
* Support "tart --version"

* Move CI.swift patcher into a separate script

Otherwise it doesn't work in GoReleaser.
2022-05-17 10:40:21 -04:00
Fedor Korotkov 63a2793c32
Support upper case in remote names (#79) 2022-05-16 18:14:42 +03:00
Fedor Korotkov 0fc3d3d1f4
Add virtual sound devices (#78) 2022-05-16 17:21:21 +03:00
Nikolay Edigaryev 60b705478b
Handle Ctrl + C properly (#73)
* Terminate when Ctrl+C is encountered when entering credentials

* Handle Ctrl+C by catching SIGINT and converting it to task cancellation

* maxCharacters instead of (buf.count - 2)

* readStdinCredential: fix maxCharacters to be 255

* "user" variable should be named "credential"
2022-05-16 09:56:30 -04:00
Nikolay Edigaryev fa9e3146c1
tart list: filter out uninitialized VM directories (#76) 2022-05-16 08:30:58 -04:00
Nikolay Edigaryev 3dfe8f870c
Provide more details when VM's network attachment disconnects (#74) 2022-05-16 08:23:34 -04:00