vagrant_utm 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec09354bc45c159ba048b7965ffd6802e865a3f60e99e74d2bdd5f9bb5bf3166
4
- data.tar.gz: 001d7226ab9fdd498d8340b0a095eaebe1774424418095f0a73fbb42e04fc1c9
3
+ metadata.gz: 5490d3383818806a6747017efd731d0d49117bfe2da203dc3acf83d2e528a724
4
+ data.tar.gz: 44cfea43f700fd361b7478b7829c42c03e2517089dfffa915aa800fad930fa09
5
5
  SHA512:
6
- metadata.gz: d83c1d82fdcb5dc2983edd7b16c4a72b76b934a7b66bb379b80e46e85a70a6ad0b2e1720c56f1311f3cc42f465034d08acf66c78f8a6ddac15c155ab0b001236
7
- data.tar.gz: 5247adf195d74c9992cb03451baa55f5ac5c7c5d4bc8a58f2e651b73f044bcf806fe7a8ed66a43119e549bf2c8df754e7c137f75119394c31155626e5c7662e7
6
+ metadata.gz: 960b447fed3dca3b9eb69d66230427b7701dcedbf9311aa24e10f66b1fad0c2ccd4a25d4da7e753d55c64b149bc78178a67f4fafcc3130203ce27236f56a49ac
7
+ data.tar.gz: 60c0c06b0dfee57b34b253fe784120ffbd4c0f03f38acba58f2ad59826f4ffb2921f96952c8c33959d8ae4f17bc07950ecb7b5608c4e78de72c1992dae523526
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2026-11-21
4
+
5
+ ### Fixed
6
+ - Check whether forwarded host ports can be bound when repairing collisions,
7
+ allowing multiple UTM VMs to start with distinct SSH ports (#53).
8
+ - Raise an error when the usable port range is exhausted instead of selecting
9
+ an occupied port, and honor wildcard port reservations from other VMs.
10
+ - Pin Ruby workflow runners to Ubuntu 22.04 to support Ruby 3.3.4.
11
+
3
12
  ## [0.2.0] - 2026-10-14
4
13
 
5
14
  ### Added
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "vagrant/action/builtin/handle_forwarded_port_collisions"
4
+
5
+ module VagrantPlugins
6
+ module Utm
7
+ module Action
8
+ # Keep Vagrant's lock and leases, but test whether QEMU can bind a port.
9
+ class HandleForwardedPortCollisions < Vagrant::Action::Builtin::HandleForwardedPortCollisions
10
+ protected
11
+
12
+ def handle(env) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
13
+ extra = env[:port_collision_extra_in_use] || []
14
+ extra = extra.to_h { |port| [port, Set.new(["*"])] } if extra.is_a?(Array)
15
+ remap = env[:port_collision_remap] || {}
16
+ checker = env[:port_collision_port_check] || method(:port_check)
17
+ usable = Set.new(@machine.config.vm.usable_port_range) - extra.keys
18
+ with_forwarded_ports(env) { |options| usable.delete(options[:host]) }
19
+
20
+ with_forwarded_ports(env) do |options|
21
+ next if options[:disabled] || (options[:protocol] && options[:protocol] != "tcp")
22
+
23
+ host = remap.fetch(options[:host], options[:host])
24
+ ip = options[:host_ip]
25
+ next unless port_in_use?(extra, checker, ip, host)
26
+
27
+ unless env[:port_collision_repair] && options[:auto_correct]
28
+ raise Vagrant::Errors::ForwardPortCollision,
29
+ guest_port: options[:guest].to_s, host_port: host.to_s
30
+ end
31
+
32
+ repaired = usable.to_a.sort.find do |port|
33
+ usable.delete(port)
34
+ !port_in_use?(extra, checker, ip, port)
35
+ end
36
+ unless repaired
37
+ raise Vagrant::Errors::ForwardPortAutolistEmpty,
38
+ vm_name: @machine.name, guest_port: options[:guest].to_s, host_port: host.to_s
39
+ end
40
+
41
+ options[:host] = repaired
42
+ env[:ui].info(I18n.t("vagrant.actions.vm.forward_ports.fixed_collision",
43
+ host_port: host.to_s, guest_port: options[:guest].to_s,
44
+ new_port: repaired.to_s))
45
+ end
46
+ end
47
+
48
+ def port_in_use?(extra, checker, ip, port)
49
+ # An array from read_used_ports represents reservations on any IP.
50
+ extra.fetch(port, []).include?("*") || is_forwarded_already(extra, port, ip) ||
51
+ call_port_checker(checker, ip, port) || lease_check(ip, port)
52
+ end
53
+
54
+ def port_check(host_ip, host_port)
55
+ # A successful connect can be misleading (for example with local
56
+ # traffic proxies). Binding checks the operation QEMU needs instead.
57
+ socket = TCPServer.new(host_ip.nil? || host_ip.empty? ? "0.0.0.0" : host_ip, host_port)
58
+ false
59
+ rescue Errno::EADDRINUSE, Errno::EACCES, Errno::EADDRNOTAVAIL
60
+ true
61
+ ensure
62
+ socket&.close
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
@@ -23,6 +23,7 @@ module VagrantPlugins
23
23
  autoload :Export, action_root.join("export")
24
24
  autoload :ForcedHalt, action_root.join("forced_halt")
25
25
  autoload :ForwardPorts, action_root.join("forward_ports")
26
+ autoload :HandleForwardedPortCollisions, action_root.join("handle_forwarded_port_collisions")
26
27
  autoload :Import, action_root.join("import")
27
28
  autoload :IpAddress, action_root.join("ip_address")
28
29
  autoload :IsPaused, action_root.join("is_paused")
@@ -4,6 +4,6 @@ module VagrantPlugins
4
4
  # Top level module for the Utm provider plugin.
5
5
  module Utm
6
6
  # Current version of the Utm provider plugin.
7
- VERSION = "0.2.0"
7
+ VERSION = "0.2.1"
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant_utm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naveenraj M
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-14 00:00:00.000000000 Z
11
+ date: 2026-11-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Vagrant UTM provider that allows you to manage UTM virtual machines.
14
14
  email:
@@ -66,6 +66,7 @@ files:
66
66
  - lib/vagrant_utm/action/export.rb
67
67
  - lib/vagrant_utm/action/forced_halt.rb
68
68
  - lib/vagrant_utm/action/forward_ports.rb
69
+ - lib/vagrant_utm/action/handle_forwarded_port_collisions.rb
69
70
  - lib/vagrant_utm/action/import.rb
70
71
  - lib/vagrant_utm/action/ip_address.rb
71
72
  - lib/vagrant_utm/action/is_paused.rb
@@ -141,7 +142,7 @@ metadata:
141
142
  homepage_uri: https://naveenrajm7.github.io/vagrant_utm/
142
143
  source_code_uri: https://github.com/naveenrajm7/vagrant_utm
143
144
  changelog_uri: https://github.com/naveenrajm7/vagrant_utm/blob/main/CHANGELOG.md
144
- post_install_message:
145
+ post_install_message:
145
146
  rdoc_options: []
146
147
  require_paths:
147
148
  - lib
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubygems_version: 3.5.11
160
- signing_key:
161
+ signing_key:
161
162
  specification_version: 4
162
163
  summary: Vagrant UTM provider
163
164
  test_files: []