vagrant_utm 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +1 -1
- data/docs/Gemfile.lock +2 -2
- data/docs/_config.yml +2 -2
- data/docs/boxes/creating_utm_box.md +7 -6
- data/docs/boxes/utm_box_gallery.md +10 -5
- data/docs/features/synced_folders.md +11 -11
- data/docs/index.md +7 -7
- data/docs/internals/actions.md +2 -1
- data/docs/known_issues.md +2 -2
- data/lib/vagrant_utm/action/prepare_nfs_settings.rb +79 -0
- data/lib/vagrant_utm/action/prepare_nfs_valid_ids.rb +24 -0
- data/lib/vagrant_utm/action.rb +22 -2
- data/lib/vagrant_utm/cap/mount_options.rb +55 -0
- data/lib/vagrant_utm/config.rb +26 -6
- data/lib/vagrant_utm/driver/base.rb +6 -0
- data/lib/vagrant_utm/driver/meta.rb +11 -3
- data/lib/vagrant_utm/driver/version_4_5.rb +10 -0
- data/lib/vagrant_utm/driver/version_4_6.rb +67 -0
- data/lib/vagrant_utm/plugin.rb +21 -0
- data/lib/vagrant_utm/scripts/add_folder_share.applescript +96 -0
- data/lib/vagrant_utm/scripts/add_qemu_additional_args.applescript +43 -0
- data/lib/vagrant_utm/scripts/read_shared_folders.js +47 -0
- data/lib/vagrant_utm/scripts/read_shared_folders_args.js +53 -0
- data/lib/vagrant_utm/scripts/remove_qemu_additional_args.applescript +46 -0
- data/lib/vagrant_utm/synced_folder.rb +127 -0
- data/lib/vagrant_utm/util/unix_mount_helpers.rb +124 -0
- data/lib/vagrant_utm/version.rb +1 -1
- data/notes/README.md +26 -6
- metadata +15 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc0499e6b39496b2bd9590d3683631bcc213f7b0f4f1a5fc259b9373e160da33
|
4
|
+
data.tar.gz: 36b2a3029c3d8ddb9d4e84865f657a989732495f59adf90e4f2eb19731780ae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adf69f5cc2fbb3d73e5453b761d374dfd29aded42d1581927a1bbfea2405a93817c11e4a79de57d1c144b6acd120e4d21dceb9140c38083436605f2f2f4a2889
|
7
|
+
data.tar.gz: c305e4949e66c6643646025c649dba12093e228dbbe298b0aada54be0974fa526bfdded85afbcf2b0c062d1982100f601bb77d290784b9d4b57e8fc4173644cf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
|
4
|
+
## [0.1.3] - 2025-04-20
|
5
|
+
|
6
|
+
### Added
|
7
|
+
|
8
|
+
- Implements VirtFS synced folder in UTM using qemu additional args and vm registry (for permission)
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- Config: Makes `virtFS` as default directory_share_mode in UTM
|
13
|
+
|
14
|
+
### Removed
|
15
|
+
|
16
|
+
- Driver: Removed support for UTM versions < 4.6.5
|
17
|
+
|
18
|
+
## [0.1.2.beta] - 2024-12-05
|
19
|
+
|
20
|
+
WARNING: This version of the plugin adds initial synced folder support. By default, Vagrant will pick the directory share method which it supports and prefers. e.g., SMB. However, SMB is not fully tested, so you need to force the plugin to pick the one that is simple and tested `rsync`
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
Vagrant.configure("2") do |config|
|
24
|
+
config.vm.synced_folder ".", "/vagrant", type: "rsync"
|
25
|
+
config.vm.box = "utm/ubuntu-24.04"
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
### Added
|
30
|
+
|
31
|
+
- Initial Synced Folder support with sync
|
32
|
+
- Warning: By default vagrant brings other sync methods eg: SMB, NFS but they are not ready to use.
|
33
|
+
|
1
34
|
## [0.1.1] - 2024-12-03
|
2
35
|
|
3
36
|
IMPORTANT: This version of the plugin only works with UTM version 4.5.1 and above, and is incompatible with 0.0.1 version of the plugin.
|
data/README.md
CHANGED
data/docs/Gemfile.lock
CHANGED
data/docs/_config.yml
CHANGED
@@ -28,8 +28,8 @@ nav_external_links:
|
|
28
28
|
url: https://mac.getutm.app
|
29
29
|
- title: Packer plugin for UTM
|
30
30
|
url: https://github.com/naveenrajm7/packer-plugin-utm
|
31
|
-
|
32
|
-
|
31
|
+
- title: UTM Gallery
|
32
|
+
url: https://naveenrajm7.github.io/utm-gallery/
|
33
33
|
|
34
34
|
|
35
35
|
# Aux links for the upper right navigation
|
@@ -60,17 +60,18 @@ Check the [UTM Guide on Guest Support](https://docs.getutm.app/guest-support/gue
|
|
60
60
|
|
61
61
|
By satisfying the [general guidance on creating vagrant boxes](https://developer.hashicorp.com/vagrant/docs/boxes/base) and the above [Virtual Machine](#virtual-machine) requirements you can use your VM with Vagrant UTM plugin.
|
62
62
|
|
63
|
-
Apart from manually building the boxes, you can also use the
|
63
|
+
Apart from manually building the boxes, you can also use the automated (almost) way of building these boxes using [packer plugin for UTM](https://github.com/naveenrajm7/packer-plugin-utm).
|
64
64
|
The packer plugin has the following components:
|
65
65
|
1. Builder
|
66
|
-
|
67
|
-
|
66
|
+
1. UTM - Use existing utm file
|
67
|
+
2. ISO - Start from scratch using ISO files
|
68
|
+
3. CLOUD - Use existing qcow2 cloud images
|
68
69
|
2. Post-processor
|
69
|
-
|
70
|
-
|
70
|
+
1. ZIP - Package UTM VM into zip file
|
71
|
+
2. Vagrant - Package UTM VM into vagrant box.
|
71
72
|
|
72
73
|
|
73
|
-
Checkout [UTM Box
|
74
|
+
Checkout [UTM Box Packer recipe](https://github.com/naveenrajm7/utm-box?tab=readme-ov-file#building-boxes) to know how to build Box using packer.
|
74
75
|
|
75
76
|
## Using your own UTM VMs
|
76
77
|
|
@@ -10,22 +10,27 @@ nav_order: 1
|
|
10
10
|
To work with Vagrant, a base VM (box) must have
|
11
11
|
[certain features](https://developer.hashicorp.com/vagrant/docs/boxes/base), like an ssh user for vagrant to connect.
|
12
12
|
|
13
|
-
To help you get started with Vagrant UTM provider,
|
13
|
+
To help you get started with Vagrant UTM provider, some pre-built VMs that work with Vagrant are published in [HCP Vagrant registry](https://portal.cloud.hashicorp.com/vagrant/discover/utm).
|
14
14
|
|
15
15
|
{: .important}
|
16
|
-
All the VMs provided are built from
|
16
|
+
All the VMs provided are built from Cloud Images or ISO files in an (semi) automated way using [packer plugin for UTM][packer plugin for UTM]. Please see the [UTM Box Guide][UTM Box Guide] on how these UTM Vagrant boxes were built using packer.
|
17
17
|
|
18
|
-
* Debian
|
18
|
+
* Debian 12 - Built from cloud image:
|
19
|
+
```ruby
|
20
|
+
config.vm.box = "utm/bookworm"
|
21
|
+
```
|
22
|
+
|
23
|
+
* Debian 11 (Xfce) - Built from UTM file of UTM gallery:
|
19
24
|
```ruby
|
20
25
|
config.vm.box = "utm/debian11"
|
21
26
|
```
|
22
27
|
|
23
|
-
* Ubuntu 24.04 :
|
28
|
+
* Ubuntu 24.04 - Built from ISO:
|
24
29
|
```ruby
|
25
30
|
config.vm.box = "utm/ubuntu-24.04"
|
26
31
|
```
|
27
32
|
|
28
|
-
*
|
33
|
+
* Build your own boxes using [packer plugin for UTM][packer plugin for UTM]
|
29
34
|
<!-- * ArchLinux ARM -->
|
30
35
|
|
31
36
|
|
@@ -7,22 +7,22 @@ nav_order: 1
|
|
7
7
|
|
8
8
|
# Synced Folders
|
9
9
|
|
10
|
-
UTM Vagrant plugin
|
11
|
-
The plugin
|
12
|
-
After which the the host directory can be selected from UTM UI, and the guest directory can be mounted in guest OS. Both of these steps are now manual until UTM exposes API to configure Host/Guest directory.
|
10
|
+
UTM Vagrant plugin has support for syncing multiple folders between host and guest machine.
|
11
|
+
The plugin implements [UTM QEMU VirtFS](https://docs.getutm.app/guest-support/linux/#virtfs) as the default synced folder implementation for UTM provider.
|
13
12
|
|
14
13
|
```ruby
|
15
14
|
Vagrant.configure("2") do |config|
|
16
|
-
config.vm.box = "utm/
|
17
|
-
config.vm.
|
18
|
-
# QEMU Directoy Share mode for the VM.
|
19
|
-
# Takes none, webDAV or virtFS
|
20
|
-
u.directory_share_mode = "webDAV"
|
21
|
-
end
|
15
|
+
config.vm.box = "utm/bookworm"
|
16
|
+
config.vm.synced_folder "../test", "/vagrant-test"
|
22
17
|
end
|
23
18
|
```
|
24
19
|
|
25
|
-
|
20
|
+
Vagrant by default syncs the current folder where that Vagrantfile is, and you can access them at `/vagrant` in the guest.
|
26
21
|
|
27
22
|
{: .important}
|
28
|
-
|
23
|
+
|
24
|
+
|
25
|
+
## Other Vagrant options
|
26
|
+
|
27
|
+
Apart from the provider specific Sync options, Vagrant has components to provide sync folders feature using NFS and RSync. These features are also supported in UTM plugin.
|
28
|
+
Check all Vagrant provided sync options at [Vagrant synced folders](https://developer.hashicorp.com/vagrant/docs/synced-folders).
|
data/docs/index.md
CHANGED
@@ -19,8 +19,8 @@ allowing Vagrant to control and provision machines via UTM's API.
|
|
19
19
|
---
|
20
20
|
|
21
21
|
{: .new}
|
22
|
-
>
|
23
|
-
>
|
22
|
+
> Plugin now supports [Vagrant boxes](https://developer.hashicorp.com/vagrant/docs/boxes)!, find UTM boxes at [HCP Vagrant registry](https://portal.cloud.hashicorp.com/vagrant/discover/utm)
|
23
|
+
> Plugin now supports multiple synced folders, check out [Synced Folder](features/synced_folders.md)
|
24
24
|
|
25
25
|
[UTM] is a free, full-featured system emulator and virtual machine host for iOS and macOS.
|
26
26
|
The UTM provider currently supports UTM versions
|
@@ -59,14 +59,14 @@ vagrant plugin install vagrant_utm
|
|
59
59
|
Option 1: Create a Vagrantfile and initiate the box (OR)
|
60
60
|
|
61
61
|
```
|
62
|
-
vagrant init utm/
|
62
|
+
vagrant init utm/bookworm
|
63
63
|
```
|
64
64
|
|
65
65
|
Option 2: Open the Vagrantfile and replace the contents with the following
|
66
66
|
|
67
67
|
```ruby
|
68
68
|
Vagrant.configure("2") do |config|
|
69
|
-
config.vm.box = "utm/
|
69
|
+
config.vm.box = "utm/bookworm"
|
70
70
|
end
|
71
71
|
```
|
72
72
|
|
@@ -81,9 +81,9 @@ Now start using your machine!
|
|
81
81
|
|
82
82
|
`vagrant ssh` to log into machine or forward ports to check your website or share folders and start developing.
|
83
83
|
|
84
|
-
Check [Commands](commands.md) for all supported Vagrant commands.
|
85
|
-
Check [Configuration](configuration.md) for more UTM provider config options.
|
86
|
-
|
84
|
+
Check [Commands](commands.md) for all supported Vagrant commands.
|
85
|
+
Check [Configuration](configuration.md) for more UTM provider config options.
|
86
|
+
Discover UTM Vagrant boxes at [HCP Vagrant UTM Registry](https://portal.cloud.hashicorp.com/vagrant/discover/utm), which as boxes of popular OS including OpenBSD!
|
87
87
|
|
88
88
|
## About the project
|
89
89
|
|
data/docs/internals/actions.md
CHANGED
@@ -17,4 +17,5 @@ The Table below maps the vagrant commands to the corresponding UTM commands that
|
|
17
17
|
| `vagrant destroy` | `utmctl delete` |
|
18
18
|
| `vagrant status` | `utmctl status` |
|
19
19
|
| `vagrant disposable` | `utmctl start --disposable` |
|
20
|
-
| `vagrant snapshot` | `qemu-img snapshot` |
|
20
|
+
| `vagrant snapshot` | `qemu-img snapshot` |
|
21
|
+
| `vagrant ip-address` | `utmctl ip-address` |
|
data/docs/known_issues.md
CHANGED
@@ -5,7 +5,7 @@ nav_order: 7
|
|
5
5
|
|
6
6
|
# Known Issues
|
7
7
|
|
8
|
-
This plugin
|
8
|
+
This plugin is built around the existing UTM API.
|
9
9
|
Hence there are things which are not ideal.
|
10
10
|
|
11
11
|
1. ~~vagrant up : Loads new VM by downloading zip file every time, and manually asks the user to confirm the download completion.~~
|
@@ -21,4 +21,4 @@ Draw back - UTM does not expose export API. (UTM already has 'Share')~~
|
|
21
21
|
|
22
22
|
5. vagrant snapshot: Even though UTM does not have snapshot feature, this plugin has a experimental support for offline VM snapshots using qemu-img.
|
23
23
|
The VM must be stopped, for any snapshot commands to work.
|
24
|
-
The snapshot only works for **single** qcow2 based VM images
|
24
|
+
The snapshot only works for **single** qcow2 based VM images
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Utm
|
5
|
+
module Action
|
6
|
+
# This action prepares the NFS settings for the machine.
|
7
|
+
class PrepareNFSSettings
|
8
|
+
include Vagrant::Action::Builtin::MixinSyncedFolders
|
9
|
+
include Vagrant::Util::Retryable
|
10
|
+
|
11
|
+
def initialize(app, _env)
|
12
|
+
@app = app
|
13
|
+
@logger = Log4r::Logger.new("vagrant::action::vm::nfs")
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
@machine = env[:machine]
|
18
|
+
|
19
|
+
@app.call(env)
|
20
|
+
|
21
|
+
opts = {
|
22
|
+
cached: !env[:synced_folders_cached].nil?,
|
23
|
+
config: env[:synced_folders_config],
|
24
|
+
disable_usable_check: !env[:test].nil?
|
25
|
+
}
|
26
|
+
folders = synced_folders(env[:machine], **opts)
|
27
|
+
|
28
|
+
return unless folders.key?(:nfs)
|
29
|
+
|
30
|
+
@logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
|
31
|
+
add_ips_to_env!(env)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Extracts the proper host and guest IPs for NFS mounts and stores them
|
35
|
+
# in the environment for the SyncedFolder action to use them in
|
36
|
+
# mounting.
|
37
|
+
#
|
38
|
+
# The ! indicates that this method modifies its argument.
|
39
|
+
def add_ips_to_env!(env)
|
40
|
+
# Hardcoded IP for the host IP
|
41
|
+
host_ip = "10.0.2.2"
|
42
|
+
machine_ip = read_dynamic_machine_ip
|
43
|
+
|
44
|
+
raise Vagrant::Errors::NFSNoHostonlyNetwork if !host_ip || !machine_ip
|
45
|
+
|
46
|
+
env[:nfs_host_ip] = host_ip
|
47
|
+
env[:nfs_machine_ip] = machine_ip
|
48
|
+
end
|
49
|
+
|
50
|
+
# Returns the IP address of the guest by looking at utm guest additions
|
51
|
+
# for the appropriate guest adapter.
|
52
|
+
#
|
53
|
+
# For DHCP interfaces, the guest property will not be present until the
|
54
|
+
# guest completes
|
55
|
+
#
|
56
|
+
# @param [Integer] adapter number to read IP for
|
57
|
+
# @return [String] ip address of adapter
|
58
|
+
def read_dynamic_machine_ip
|
59
|
+
# we need to wait for the guest's IP to show up as a guest property.
|
60
|
+
# retry thresholds are relatively high since we might need to wait
|
61
|
+
# for DHCP, but even static IPs can take a second or two to appear.
|
62
|
+
retryable(retry_options.merge(on: Vagrant::Errors::VirtualBoxGuestPropertyNotFound)) do
|
63
|
+
# Read the IP address from the list given by qemu-guest-agent
|
64
|
+
@machine.provider.driver.read_guest_ip[0]
|
65
|
+
end
|
66
|
+
rescue Vagrant::Errors::VirtualBoxGuestPropertyNotFound
|
67
|
+
# this error is more specific with a better error message directing
|
68
|
+
# the user towards the fact that it's probably a reportable bug
|
69
|
+
raise Vagrant::Errors::NFSNoGuestIP
|
70
|
+
end
|
71
|
+
|
72
|
+
# Separating these out so we can stub out the sleep in tests
|
73
|
+
def retry_options
|
74
|
+
{ tries: 15, sleep: 1 }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) HashiCorp, Inc.
|
4
|
+
# SPDX-License-Identifier: BUSL-1.1
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module Utm
|
8
|
+
module Action
|
9
|
+
# This action prepares the NFS valid IDs for the VMs.
|
10
|
+
# The ids that are valid and should not be pruned by NFS
|
11
|
+
class PrepareNFSValidIds
|
12
|
+
def initialize(app, _env)
|
13
|
+
@app = app
|
14
|
+
@logger = Log4r::Logger.new("vagrant::action::vm::nfs")
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(env)
|
18
|
+
env[:nfs_valid_ids] = env[:machine].provider.driver.read_vms.keys
|
19
|
+
@app.call(env)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/vagrant_utm/action.rb
CHANGED
@@ -40,6 +40,8 @@ module VagrantPlugins
|
|
40
40
|
autoload :PackageSetupFiles, action_root.join("package_setup_files")
|
41
41
|
autoload :PackageSetupFolders, action_root.join("package_setup_folders")
|
42
42
|
autoload :PackageVagrantfile, action_root.join("package_vagrantfile")
|
43
|
+
autoload :PrepareNFSSettings, action_root.join("prepare_nfs_settings")
|
44
|
+
autoload :PrepareNFSValidIds, action_root.join("prepare_nfs_valid_ids")
|
43
45
|
autoload :PrepareForwardedPortCollisionParams, action_root.join("prepare_forwarded_port_collision_params")
|
44
46
|
autoload :Resume, action_root.join("resume")
|
45
47
|
autoload :SetId, action_root.join("set_id")
|
@@ -66,6 +68,10 @@ module VagrantPlugins
|
|
66
68
|
b.use EnvSet, port_collision_repair: true
|
67
69
|
b.use PrepareForwardedPortCollisionParams
|
68
70
|
b.use HandleForwardedPortCollisions
|
71
|
+
b.use PrepareNFSValidIds
|
72
|
+
b.use SyncedFolderCleanup
|
73
|
+
b.use SyncedFolders
|
74
|
+
b.use PrepareNFSSettings
|
69
75
|
b.use ForwardPorts
|
70
76
|
b.use SetHostname
|
71
77
|
b.use Customize, "pre-boot"
|
@@ -90,7 +96,7 @@ module VagrantPlugins
|
|
90
96
|
# This is the action that is primarily responsible for completely
|
91
97
|
# freeing the resources of the underlying virtual machine.
|
92
98
|
# UTM equivalent of `utmctl delete <uuid>`
|
93
|
-
def self.action_destroy
|
99
|
+
def self.action_destroy # rubocop:disable Metrics/AbcSize
|
94
100
|
Vagrant::Action::Builder.new.tap do |b|
|
95
101
|
b.use CheckUtm
|
96
102
|
b.use Call, Created do |env1, b2|
|
@@ -106,6 +112,8 @@ module VagrantPlugins
|
|
106
112
|
b3.use CheckAccessible
|
107
113
|
b3.use action_halt
|
108
114
|
b3.use Destroy
|
115
|
+
b3.use PrepareNFSValidIds
|
116
|
+
b3.use SyncedFolderCleanup
|
109
117
|
else
|
110
118
|
b3.use MessageWillNotDestroy
|
111
119
|
end
|
@@ -160,7 +168,7 @@ module VagrantPlugins
|
|
160
168
|
end
|
161
169
|
|
162
170
|
# This action packages the virtual machine into a single box file.
|
163
|
-
def self.action_package
|
171
|
+
def self.action_package # rubocop:disable Metrics/AbcSize
|
164
172
|
Vagrant::Action::Builder.new.tap do |b|
|
165
173
|
b.use CheckUtm
|
166
174
|
b.use Call, Created do |env, b2|
|
@@ -174,6 +182,8 @@ module VagrantPlugins
|
|
174
182
|
b2.use CheckAccessible
|
175
183
|
b2.use action_halt
|
176
184
|
b2.use ClearForwardedPorts
|
185
|
+
b2.use PrepareNFSValidIds
|
186
|
+
b2.use SyncedFolderCleanup
|
177
187
|
b2.use Package
|
178
188
|
b2.use Export
|
179
189
|
b2.use PackageVagrantfile
|
@@ -405,6 +415,16 @@ module VagrantPlugins
|
|
405
415
|
end
|
406
416
|
end
|
407
417
|
|
418
|
+
# This is the action that is called to sync folders to a running
|
419
|
+
# machine without a reboot.
|
420
|
+
def self.action_sync_folders
|
421
|
+
Vagrant::Action::Builder.new.tap do |b|
|
422
|
+
b.use PrepareNFSValidIds
|
423
|
+
b.use SyncedFolders
|
424
|
+
b.use PrepareNFSSettings
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
408
428
|
# This action brings the machine up from nothing, including importing
|
409
429
|
# the box, configuring metadata, and booting.
|
410
430
|
def self.action_up
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) HashiCorp, Inc.
|
4
|
+
# SPDX-License-Identifier: BUSL-1.1
|
5
|
+
|
6
|
+
require_relative "../util/unix_mount_helpers"
|
7
|
+
|
8
|
+
module VagrantPlugins
|
9
|
+
module Utm
|
10
|
+
module Cap
|
11
|
+
# Capability for mount options
|
12
|
+
module MountOptions
|
13
|
+
extend VagrantPlugins::SyncedFolder::UnixMountHelpers
|
14
|
+
|
15
|
+
# Mount type for VirtFS
|
16
|
+
UTM_MOUNT_TYPE = "9p"
|
17
|
+
|
18
|
+
# Returns mount options for a utm synced folder
|
19
|
+
#
|
20
|
+
# @param [Machine] machine
|
21
|
+
# @param [String] name of mount
|
22
|
+
# @param [String] path of mount on guest
|
23
|
+
# @param [Hash] hash of mount options
|
24
|
+
def self.mount_options(machine, _name, guest_path, options)
|
25
|
+
mount_options = options.fetch(:mount_options, [])
|
26
|
+
detected_ids = detect_owner_group_ids(machine, guest_path, mount_options, options)
|
27
|
+
mount_uid = detected_ids[:uid]
|
28
|
+
mount_gid = detected_ids[:gid]
|
29
|
+
|
30
|
+
# VirtFS mount options
|
31
|
+
mount_options << "trans=virtio"
|
32
|
+
mount_options << "version=9p2000.L"
|
33
|
+
mount_options << if mount_options.include?("ro")
|
34
|
+
"ro"
|
35
|
+
else
|
36
|
+
"rw"
|
37
|
+
end
|
38
|
+
mount_options << "_netdev"
|
39
|
+
mount_options << "nofail"
|
40
|
+
|
41
|
+
mount_options = mount_options.join(",")
|
42
|
+
[mount_options, mount_uid, mount_gid]
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.mount_type(_machine)
|
46
|
+
UTM_MOUNT_TYPE
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.mount_name(_machine, name, _data)
|
50
|
+
name.gsub(%r{[\s/\\]}, "_").sub(/^_/, "")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/vagrant_utm/config.rb
CHANGED
@@ -7,11 +7,6 @@ module VagrantPlugins
|
|
7
7
|
module Utm
|
8
8
|
# This is the configuration class for the UTM provider.
|
9
9
|
class Config < Vagrant.plugin("2", :config)
|
10
|
-
# This should be set to the name of the machine in the UTM GUI.
|
11
|
-
#
|
12
|
-
# @return [String]
|
13
|
-
attr_accessor :name
|
14
|
-
|
15
10
|
# If true, will check if guest additions are installed and up to
|
16
11
|
# date. By default, this is true.
|
17
12
|
#
|
@@ -23,6 +18,19 @@ module VagrantPlugins
|
|
23
18
|
# @return [Array]
|
24
19
|
attr_reader :customizations
|
25
20
|
|
21
|
+
# Whether or not this VM has a functional VirtFS 9P filesystem module
|
22
|
+
# for VirtFS directory sharing to work.
|
23
|
+
# This defaults to true. If you set this to false, then the "utm"
|
24
|
+
# synced folder type won't be valid.
|
25
|
+
#
|
26
|
+
# @return [Boolean]
|
27
|
+
attr_accessor :functional_9pfs
|
28
|
+
|
29
|
+
# This should be set to the name of the machine in the UTM GUI.
|
30
|
+
#
|
31
|
+
# @return [String]
|
32
|
+
attr_accessor :name
|
33
|
+
|
26
34
|
# The time to wait for the VM to be 'running' after 'started'.
|
27
35
|
#
|
28
36
|
# @return [Integer]
|
@@ -33,6 +41,7 @@ module VagrantPlugins
|
|
33
41
|
super
|
34
42
|
@check_guest_additions = UNSET_VALUE
|
35
43
|
@customizations = []
|
44
|
+
@functional_9pfs = UNSET_VALUE
|
36
45
|
@name = UNSET_VALUE
|
37
46
|
@wait_time = UNSET_VALUE
|
38
47
|
end
|
@@ -76,6 +85,8 @@ module VagrantPlugins
|
|
76
85
|
customize("pre-boot", ["customize_vm.applescript", :id, "--notes", notes])
|
77
86
|
end
|
78
87
|
|
88
|
+
# TODO: All warning if user sets directory_share_mode,
|
89
|
+
# because default implementation is 'virtFS'
|
79
90
|
# Shortcut for setting the directory share mode of the virtual machine.
|
80
91
|
# Calls #customize internally.
|
81
92
|
#
|
@@ -101,8 +112,13 @@ module VagrantPlugins
|
|
101
112
|
# This is the hook that is called to finalize the object before it
|
102
113
|
# is put into use.
|
103
114
|
def finalize!
|
115
|
+
# By default, we check for guest additions (qemu-ga)
|
104
116
|
@check_guest_additions = true if @check_guest_additions == UNSET_VALUE
|
105
|
-
|
117
|
+
# Always set the directory share mode to 'virtFS'
|
118
|
+
# default share folder implementation in utm plugin
|
119
|
+
self.directory_share_mode = "virtFS"
|
120
|
+
# By default, we assume the VM supports virtio 9p filesystems
|
121
|
+
@functional_9pfs = true if @functional_9pfs == UNSET_VALUE
|
106
122
|
# The default name is just nothing, and we default it
|
107
123
|
@name = nil if @name == UNSET_VALUE
|
108
124
|
|
@@ -127,6 +143,10 @@ module VagrantPlugins
|
|
127
143
|
|
128
144
|
{ "UTM Provider" => errors }
|
129
145
|
end
|
146
|
+
|
147
|
+
def to_s
|
148
|
+
"UTM"
|
149
|
+
end
|
130
150
|
end
|
131
151
|
end
|
132
152
|
end
|
@@ -86,6 +86,12 @@ module VagrantPlugins
|
|
86
86
|
# @return [Array]
|
87
87
|
def read_used_ports(active_only: true); end
|
88
88
|
|
89
|
+
# Returns a list of all UUIDs of virtual machines currently
|
90
|
+
# known by UTM.
|
91
|
+
#
|
92
|
+
# @return [Array<String>]
|
93
|
+
def read_vms; end
|
94
|
+
|
89
95
|
# Returns the IP addresses of the guest machine.
|
90
96
|
# Only supported for VMs with qemu-guest-agent installed.
|
91
97
|
#
|
@@ -58,9 +58,14 @@ module VagrantPlugins
|
|
58
58
|
"4.6" => Version_4_6
|
59
59
|
}
|
60
60
|
|
61
|
-
# UTM 4.6.
|
62
|
-
#
|
63
|
-
|
61
|
+
# UTM version < 4.6.5 doesn't have
|
62
|
+
# import support to work with Vagrant box (< 4.6.1)
|
63
|
+
# registry support to work with synced folders (< 4.6.5)
|
64
|
+
# Restrict to UTM versions >= 4.6.5
|
65
|
+
unless Gem::Version.new(@version) >= Gem::Version.new("4.6.5")
|
66
|
+
raise Errors::UtmInvalidVersion,
|
67
|
+
supported_versions: "4.6.5 or earlier"
|
68
|
+
end
|
64
69
|
|
65
70
|
driver_klass = nil
|
66
71
|
driver_map.each do |key, klass|
|
@@ -88,6 +93,7 @@ module VagrantPlugins
|
|
88
93
|
def_delegators :@driver,
|
89
94
|
:check_qemu_guest_agent,
|
90
95
|
:clear_forwarded_ports,
|
96
|
+
:clear_shared_folders,
|
91
97
|
:create_snapshot,
|
92
98
|
:delete,
|
93
99
|
:delete_snapshot,
|
@@ -104,9 +110,11 @@ module VagrantPlugins
|
|
104
110
|
:read_network_interfaces,
|
105
111
|
:read_state,
|
106
112
|
:read_used_ports,
|
113
|
+
:read_vms,
|
107
114
|
:restore_snapshot,
|
108
115
|
:set_mac_address,
|
109
116
|
:set_name,
|
117
|
+
:share_folders,
|
110
118
|
:ssh_port,
|
111
119
|
:start,
|
112
120
|
:start_disposable,
|
@@ -239,6 +239,16 @@ module VagrantPlugins
|
|
239
239
|
ports
|
240
240
|
end
|
241
241
|
|
242
|
+
def read_vms
|
243
|
+
results = {}
|
244
|
+
list.machines.each do |machine|
|
245
|
+
# Store UUID (Unique) as key and name as value
|
246
|
+
results[machine.uuid] = machine.name
|
247
|
+
end
|
248
|
+
|
249
|
+
results
|
250
|
+
end
|
251
|
+
|
242
252
|
def set_name(name) # rubocop:disable Naming/AccessorMethodName
|
243
253
|
command = ["customize_vm.applescript", @uuid, "--name", name.to_s]
|
244
254
|
execute_osa_script(command)
|