vagrant-qemu 0.3.9 → 0.3.12
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 +15 -0
- data/README.md +38 -0
- data/lib/vagrant-qemu/action/import.rb +3 -1
- data/lib/vagrant-qemu/action/start_instance.rb +4 -1
- data/lib/vagrant-qemu/action.rb +3 -0
- data/lib/vagrant-qemu/cap/disk.rb +104 -0
- data/lib/vagrant-qemu/cap.rb +8 -0
- data/lib/vagrant-qemu/config.rb +12 -0
- data/lib/vagrant-qemu/driver.rb +65 -3
- data/lib/vagrant-qemu/plugin.rb +25 -0
- data/lib/vagrant-qemu/version.rb +1 -1
- data/lib/vagrant-qemu.rb +1 -0
- data/locales/en.yml +2 -0
- metadata +4 -3
- data/x +0 -76
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22e76d0b973e4e459a0780c79265d30b6cd0b48d4e94d28fdc82ef9cccfca37f
|
4
|
+
data.tar.gz: '049fb94522b7197b4d77975da222b033755761d0db699d90c6a98cb1fe49cd33'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '06901f39eac546967a57ca981739ca160caae09ec28ae9ade2c809bae6862bdeaf61ec8ac8f8cea6fbaba37146323ca08f1bb60bab53433381ac5619bf9f3517'
|
7
|
+
data.tar.gz: c815fe0029b54a7e092543fddbb5769add49393ef5fdd4e84584b8c893a164f88e1d56aebe5251b891dac7bee4a13037366988e22abdbb3189f96b979f338680
|
data/CHANGELOG.md
CHANGED
@@ -85,3 +85,18 @@
|
|
85
85
|
# 0.3.9 (2025-02-22)
|
86
86
|
|
87
87
|
* Support ssh_port in string (need better error message)
|
88
|
+
|
89
|
+
# 0.3.10 (2025-05-06)
|
90
|
+
|
91
|
+
* Add support for `qemu_bin` to customize QEMU binary
|
92
|
+
|
93
|
+
# 0.3.11 (2025-05-06)
|
94
|
+
|
95
|
+
* Re-publish with repacked gem
|
96
|
+
|
97
|
+
# 0.3.22 (2025-05-19)
|
98
|
+
|
99
|
+
* Add support for extra `-drive` arguments
|
100
|
+
* Add `extra_image_opts` to customize image creation
|
101
|
+
* Add support for cloud-init and disks
|
102
|
+
* Add support for resizing disk on vm setup
|
data/README.md
CHANGED
@@ -37,6 +37,8 @@ Others:
|
|
37
37
|
* Synced folder support via SMB
|
38
38
|
* Basic operation: up, ssh, halt, destroy
|
39
39
|
* Basic suport to forwarded ports, see [vagrant doc](https://www.vagrantup.com/docs/networking/forwarded_ports) for details
|
40
|
+
* Support Cloud-init, see [vagrant doc](https://developer.hashicorp.com/vagrant/docs/cloud-init/usage) for details
|
41
|
+
* Support Disks, see [vagrant doc](https://developer.hashicorp.com/vagrant/docs/disks/usage) for details
|
40
42
|
|
41
43
|
## Usage
|
42
44
|
|
@@ -84,20 +86,24 @@ This provider exposes a few provider-specific configuration options:
|
|
84
86
|
* `cpu` - The cpu model of VM, default: `cortex-a72`
|
85
87
|
* `smp` - The smp setting (Simulate an SMP system with n CPUs) of VM, default: `2`
|
86
88
|
* `memory` - The memory setting of VM, default: `4G`
|
89
|
+
* `disk_resize` - The target disk size of the primary disk, requires resizing of filesystem inside of VM, default: `nil`.
|
87
90
|
* debug/expert
|
88
91
|
* `ssh_host` - The SSH IP used to access VM, default: `127.0.0.1`
|
89
92
|
* `ssh_auto_correct` - Auto correct port collisions for ssh port, default: `false`
|
90
93
|
* `net_device` - The network device, default: `virtio-net-device`
|
91
94
|
* `drive_interface` - The interface type for the main drive, default `virtio`
|
92
95
|
* `image_path` - The path (or array of paths) to qcow2 image for box-less VM, default is nil value
|
96
|
+
* `qemu_bin` - Path to an alternative QEMU binary, default: autodetected
|
93
97
|
* `qemu_dir` - The path to QEMU's install dir, default: `/opt/homebrew/share/qemu`
|
94
98
|
* `extra_qemu_args` - The raw list of additional arguments to pass to QEMU. Use with extreme caution. (see "Force Multicore" below as example)
|
95
99
|
* `extra_netdev_args` - extra, comma-separated arguments to pass to the -netdev parameter. Use with caution. (see "Force Local IP" below as example)
|
100
|
+
* `extra_drive_args` - Add optional extra arguments to each drive attached, default: `[]`
|
96
101
|
* `control_port` - The port number used to control vm from vagrant, default is nil value. (nil means use unix socket)
|
97
102
|
* `debug_port` - The port number used to export serial port of the vm for debug, default is nil value. (nil means use unix socket, see "Debug" below for details)
|
98
103
|
* `no_daemonize` - Disable the "daemonize" mode of QEMU, default is false. (see "Windows host" below as example)
|
99
104
|
* `firmware_format` - The format of aarch64 firmware images (`edk2-aarch64-code.fd` and `edk2-arm-vars.fd`) loaded from `qemu_dir`, default: `raw`
|
100
105
|
* `other_default` - The other default arguments used by this plugin, default: `%W(-parallel null -monitor none -display none -vga none)`
|
106
|
+
* `extra_image_opts` - Options passed via `-o` to `qemu-img` when the base qcow2 images are created, default: `[]`
|
101
107
|
|
102
108
|
### Usage
|
103
109
|
|
@@ -266,6 +272,38 @@ Vagrant.configure("2") do |config|
|
|
266
272
|
end
|
267
273
|
```
|
268
274
|
|
275
|
+
10. Use socket_vmnet to communicate between machines
|
276
|
+
|
277
|
+
Thanks example from @Leandros.
|
278
|
+
|
279
|
+
See [pr#73](https://github.com/ppggff/vagrant-qemu/pull/73) for details.
|
280
|
+
|
281
|
+
11. Improved VM I/O performance
|
282
|
+
|
283
|
+
When creating the disks that are attached, each disk is an id assign in order
|
284
|
+
they appear in the `Vagrantfile`. The primary disk has the `id` of `disk0`.
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
Vagrant.configure("2") do |config|
|
288
|
+
# ... other stuff
|
289
|
+
|
290
|
+
config.vm.provider "qemu" do |qe|
|
291
|
+
# Use a `none` drive interface.
|
292
|
+
qe.drive_interface = "none"
|
293
|
+
qe.extra_drive_args = "cache=none,aio=threads"
|
294
|
+
|
295
|
+
# To improve I/O performance, create a separate I/O thread.
|
296
|
+
# We refer to the primary disk as `disk0`.
|
297
|
+
qe.extra_qemu_args = %w(
|
298
|
+
-object iothread,id=io1
|
299
|
+
-device virtio-blk-pci,drive=disk0,iothread=io1
|
300
|
+
)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
```
|
304
|
+
|
305
|
+
See the [QEMU Documentation](https://www.qemu.org/docs/master/devel/multiple-iothreads.html) and [heiko-sieger.info/tuning-vm-disk-performance/](https://www.heiko-sieger.info/tuning-vm-disk-performance/) for more details.
|
306
|
+
|
269
307
|
## Debug
|
270
308
|
|
271
309
|
Serial port is exported to unix socket: `<user_home>/.vagrant.d/tmp/vagrant-qemu/<id>/qemu_socket_serial`, or `debug_port`.
|
@@ -75,7 +75,9 @@ module VagrantPlugins
|
|
75
75
|
:image_path => image_path,
|
76
76
|
:qemu_dir => qemu_dir,
|
77
77
|
:arch => env[:machine].provider_config.arch,
|
78
|
-
:firmware_format => env[:machine].provider_config.firmware_format
|
78
|
+
:firmware_format => env[:machine].provider_config.firmware_format,
|
79
|
+
:extra_image_opts => env[:machine].provider_config.extra_image_opts,
|
80
|
+
:disk_resize => env[:machine].provider_config.disk_resize,
|
79
81
|
}
|
80
82
|
|
81
83
|
env[:ui].detail("Creating and registering the VM...")
|
@@ -22,14 +22,17 @@ module VagrantPlugins
|
|
22
22
|
:memory => env[:machine].provider_config.memory,
|
23
23
|
:net_device => env[:machine].provider_config.net_device,
|
24
24
|
:drive_interface => env[:machine].provider_config.drive_interface,
|
25
|
+
:qemu_bin => env[:machine].provider_config.qemu_bin,
|
25
26
|
:extra_qemu_args => env[:machine].provider_config.extra_qemu_args,
|
26
27
|
:extra_netdev_args => env[:machine].provider_config.extra_netdev_args,
|
28
|
+
:extra_drive_args => env[:machine].provider_config.extra_drive_args,
|
27
29
|
:ports => fwPorts,
|
28
30
|
:control_port => env[:machine].provider_config.control_port,
|
29
31
|
:debug_port => env[:machine].provider_config.debug_port,
|
30
32
|
:no_daemonize => env[:machine].provider_config.no_daemonize,
|
31
33
|
:firmware_format => env[:machine].provider_config.firmware_format,
|
32
|
-
:other_default => env[:machine].provider_config.other_default
|
34
|
+
:other_default => env[:machine].provider_config.other_default,
|
35
|
+
:extra_image_opts => env[:machine].provider_config.extra_image_opts,
|
33
36
|
}
|
34
37
|
|
35
38
|
env[:ui].output(I18n.t("vagrant_qemu.starting"))
|
data/lib/vagrant-qemu/action.rb
CHANGED
@@ -0,0 +1,104 @@
|
|
1
|
+
require "log4r"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module QEMU
|
5
|
+
module Cap
|
6
|
+
module Disk
|
7
|
+
@@logger = Log4r::Logger.new("vagrant_qemu::cap::disk")
|
8
|
+
|
9
|
+
DEFAULT_DISK_EXT_LIST = ["qcow2", "iso"].map(&:freeze).freeze
|
10
|
+
DEFAULT_DISK_EXT = "qcow2".freeze
|
11
|
+
|
12
|
+
# @param [Vagrant::Machine] machine
|
13
|
+
# @return [String]
|
14
|
+
def self.set_default_disk_ext(machine)
|
15
|
+
DEFAULT_DISK_EXT
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param [Vagrant::Machine] machine
|
19
|
+
# @return [Array]
|
20
|
+
def self.default_disk_exts(machine)
|
21
|
+
DEFAULT_DISK_EXT_LIST
|
22
|
+
end
|
23
|
+
|
24
|
+
# @param [Vagrant::Machine] machine
|
25
|
+
# @param [String] disk_ext
|
26
|
+
# @return [Bool]
|
27
|
+
def self.validate_disk_ext(machine, disk_ext)
|
28
|
+
DEFAULT_DISK_EXT_LIST.include?(disk_ext)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @param [Vagrant::Machine] machine
|
32
|
+
# @param [VagrantPlugins::Kernel_V2::VagrantConfigDisk] defined_disks
|
33
|
+
# @return [Hash] configured_disks - A hash of all the current configured disks
|
34
|
+
def self.configure_disks(machine, defined_disks)
|
35
|
+
return {} if defined_disks.empty?
|
36
|
+
|
37
|
+
configured_disks = {disk: [], floppy: [], dvd: []}
|
38
|
+
defined_disks.each do |disk|
|
39
|
+
@@logger.info("Disk: #{disk.to_yaml}")
|
40
|
+
case disk.type
|
41
|
+
when :disk
|
42
|
+
disk_data = setup_disk(machine, disk)
|
43
|
+
if !disk_data.empty?
|
44
|
+
configured_disks[:disk] << disk_data
|
45
|
+
machine.provider.driver.attach_disk(disk_data)
|
46
|
+
end
|
47
|
+
when :floppy
|
48
|
+
machine.ui.info(I18n.t("vagrant_qemu.errors.floppy_unsupported"))
|
49
|
+
when :dvd
|
50
|
+
disk_data = setup_dvd(machine, disk)
|
51
|
+
if !disk_data.empty?
|
52
|
+
configured_disks[:dvd] << disk_data
|
53
|
+
machine.provider.driver.attach_dvd(disk_data)
|
54
|
+
end
|
55
|
+
else
|
56
|
+
@@logger.info("unsupported disk type: #{disk.type}")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
configured_disks
|
61
|
+
end
|
62
|
+
|
63
|
+
# @param [Vagrant::Machine] machine
|
64
|
+
# @param [VagrantPlugins::Kernel_V2::VagrantConfigDisk] defined_disks
|
65
|
+
# @param [Hash] disk_meta - A hash of all the previously defined disks
|
66
|
+
# from the last configure_disk action
|
67
|
+
# @return [nil]
|
68
|
+
def self.cleanup_disks(machine, defined_disks, disk_meta)
|
69
|
+
return if disk_meta.values.flatten.empty?
|
70
|
+
end
|
71
|
+
|
72
|
+
protected
|
73
|
+
|
74
|
+
# Sets up all disk configs of type `:disk`
|
75
|
+
#
|
76
|
+
# @param [Vagrant::Machine] machine - the current machine
|
77
|
+
# @param [Config::Disk] disk - the current disk to configure
|
78
|
+
# @return [Hash] - disk_metadata
|
79
|
+
def self.setup_disk(machine, disk)
|
80
|
+
disk_dir = machine.provider.driver.disk_dir
|
81
|
+
disk_path = disk_dir.join("#{disk.name}.#{disk.disk_ext}")
|
82
|
+
args = ["create", "-f", "qcow2"]
|
83
|
+
|
84
|
+
disk_provider_config = disk.provider_config[:qemu] if disk.provider_config
|
85
|
+
args.push(disk_path.to_s)
|
86
|
+
args.push("#{disk.size}")
|
87
|
+
machine.provider.driver.execute("qemu-img", *args)
|
88
|
+
|
89
|
+
{UUID: disk.id, Name: disk.name, Path: disk_path.to_s, primary: !!disk.primary}
|
90
|
+
end
|
91
|
+
|
92
|
+
# Sets up all disk configs of type `:dvd`
|
93
|
+
#
|
94
|
+
# @param [Vagrant::Machine] machine - the current machine
|
95
|
+
# @param [Config::Disk] disk - the current disk to configure
|
96
|
+
# @return [Hash] - disk_metadata
|
97
|
+
def self.setup_dvd(machine, disk)
|
98
|
+
{UUID: disk.id, Name: disk.name, Path: disk.file, primary: !!disk.primary}
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
data/lib/vagrant-qemu/config.rb
CHANGED
@@ -14,14 +14,18 @@ module VagrantPlugins
|
|
14
14
|
attr_accessor :net_device
|
15
15
|
attr_accessor :drive_interface
|
16
16
|
attr_accessor :image_path
|
17
|
+
attr_accessor :qemu_bin
|
17
18
|
attr_accessor :qemu_dir
|
19
|
+
attr_accessor :disk_resize
|
18
20
|
attr_accessor :extra_qemu_args
|
19
21
|
attr_accessor :extra_netdev_args
|
22
|
+
attr_accessor :extra_drive_args
|
20
23
|
attr_accessor :control_port
|
21
24
|
attr_accessor :debug_port
|
22
25
|
attr_accessor :no_daemonize
|
23
26
|
attr_accessor :firmware_format
|
24
27
|
attr_accessor :other_default
|
28
|
+
attr_accessor :extra_image_opts
|
25
29
|
|
26
30
|
def initialize
|
27
31
|
@ssh_host = UNSET_VALUE
|
@@ -35,14 +39,18 @@ module VagrantPlugins
|
|
35
39
|
@net_device = UNSET_VALUE
|
36
40
|
@drive_interface = UNSET_VALUE
|
37
41
|
@image_path = UNSET_VALUE
|
42
|
+
@qemu_bin = UNSET_VALUE
|
38
43
|
@qemu_dir = UNSET_VALUE
|
44
|
+
@disk_resize = UNSET_VALUE
|
39
45
|
@extra_qemu_args = UNSET_VALUE
|
40
46
|
@extra_netdev_args = UNSET_VALUE
|
47
|
+
@extra_drive_args = UNSET_VALUE
|
41
48
|
@control_port = UNSET_VALUE
|
42
49
|
@debug_port = UNSET_VALUE
|
43
50
|
@no_daemonize = UNSET_VALUE
|
44
51
|
@firmware_format = UNSET_VALUE
|
45
52
|
@other_default = UNSET_VALUE
|
53
|
+
@extra_image_opts = UNSET_VALUE
|
46
54
|
end
|
47
55
|
|
48
56
|
#-------------------------------------------------------------------
|
@@ -66,14 +74,18 @@ module VagrantPlugins
|
|
66
74
|
@net_device = "virtio-net-device" if @net_device == UNSET_VALUE
|
67
75
|
@drive_interface = "virtio" if @drive_interface == UNSET_VALUE
|
68
76
|
@image_path = nil if @image_path == UNSET_VALUE
|
77
|
+
@qemu_bin = nil if @qemu_bin == UNSET_VALUE
|
69
78
|
@qemu_dir = "/opt/homebrew/share/qemu" if @qemu_dir == UNSET_VALUE
|
79
|
+
@disk_resize = nil if @disk_resize == UNSET_VALUE
|
70
80
|
@extra_qemu_args = [] if @extra_qemu_args == UNSET_VALUE
|
71
81
|
@extra_netdev_args = nil if @extra_netdev_args == UNSET_VALUE
|
82
|
+
@extra_drive_args = nil if @extra_drive_args == UNSET_VALUE
|
72
83
|
@control_port = nil if @control_port == UNSET_VALUE
|
73
84
|
@debug_port = nil if @debug_port == UNSET_VALUE
|
74
85
|
@no_daemonize = false if @no_daemonize == UNSET_VALUE
|
75
86
|
@firmware_format = "raw" if @firmware_format == UNSET_VALUE
|
76
87
|
@other_default = %W(-parallel null -monitor none -display none -vga none) if @other_default == UNSET_VALUE
|
88
|
+
@extra_image_opts = nil if @extra_image_opts == UNSET_VALUE
|
77
89
|
|
78
90
|
# TODO better error msg
|
79
91
|
@ssh_port = Integer(@ssh_port)
|
data/lib/vagrant-qemu/driver.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'log4r'
|
1
2
|
require 'childprocess'
|
2
3
|
require 'securerandom'
|
3
4
|
require 'yaml'
|
@@ -16,11 +17,14 @@ module VagrantPlugins
|
|
16
17
|
attr_reader :vm_id
|
17
18
|
attr_reader :data_dir
|
18
19
|
attr_reader :tmp_dir
|
20
|
+
attr_reader :attached_drives
|
19
21
|
|
20
22
|
def initialize(id, dir, tmp)
|
21
23
|
@vm_id = id
|
22
24
|
@data_dir = dir
|
23
25
|
@tmp_dir = tmp.join("vagrant-qemu")
|
26
|
+
@attached_drives = {disk: [], floppy: [], dvd: []}
|
27
|
+
@logger = Log4r::Logger.new("vagrant_qemu::driver")
|
24
28
|
end
|
25
29
|
|
26
30
|
def get_current_state
|
@@ -78,7 +82,15 @@ module VagrantPlugins
|
|
78
82
|
end
|
79
83
|
|
80
84
|
cmd = []
|
81
|
-
|
85
|
+
if options[:qemu_bin].nil?
|
86
|
+
cmd += %W(qemu-system-#{options[:arch]})
|
87
|
+
else
|
88
|
+
if options[:qemu_bin].kind_of?(Array)
|
89
|
+
cmd += options[:qemu_bin]
|
90
|
+
else
|
91
|
+
cmd += %W(#{options[:qemu_bin]})
|
92
|
+
end
|
93
|
+
end
|
82
94
|
|
83
95
|
# basic
|
84
96
|
cmd += %W(-machine #{options[:machine]}) if !options[:machine].nil?
|
@@ -104,9 +116,16 @@ module VagrantPlugins
|
|
104
116
|
end
|
105
117
|
|
106
118
|
# drive
|
119
|
+
diskid = 0
|
120
|
+
extra_drive_args = ""
|
121
|
+
if !options[:extra_drive_args].nil?
|
122
|
+
extra_drive_args = ",#{options[:extra_drive_args]}"
|
123
|
+
end
|
124
|
+
|
107
125
|
if !options[:drive_interface].nil?
|
108
126
|
image_path.each do |img|
|
109
|
-
cmd += %W(-drive if=#{options[:drive_interface]},format=qcow2,file=#{img})
|
127
|
+
cmd += %W(-drive if=#{options[:drive_interface]},id=disk#{diskid},format=qcow2,file=#{img}#{extra_drive_args})
|
128
|
+
diskid += 1
|
110
129
|
end
|
111
130
|
end
|
112
131
|
if options[:arch] == "aarch64" && !options[:firmware_format].nil?
|
@@ -116,6 +135,18 @@ module VagrantPlugins
|
|
116
135
|
cmd += %W(-drive if=pflash,format=#{options[:firmware_format]},file=#{fm2_path})
|
117
136
|
end
|
118
137
|
|
138
|
+
dvd_index = 1
|
139
|
+
@attached_drives[:dvd].each do |disk|
|
140
|
+
cmd += %W(-drive file=#{disk[:Path]},index=#{dvd_index},media=cdrom)
|
141
|
+
dvd_index += 1
|
142
|
+
end
|
143
|
+
if !options[:drive_interface].nil?
|
144
|
+
@attached_drives[:disk].each do |disk|
|
145
|
+
cmd += %W(-drive if=#{options[:drive_interface]},id=disk#{diskid},format=qcow2,file=#{disk[:Path]}#{extra_drive_args})
|
146
|
+
diskid += 1
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
119
150
|
# control
|
120
151
|
pid_file = id_tmp_dir.join("qemu.pid").to_s
|
121
152
|
cmd += %W(-chardev socket,id=mon0,#{control_socket},server=on,wait=off)
|
@@ -189,7 +220,26 @@ module VagrantPlugins
|
|
189
220
|
# Create image
|
190
221
|
options[:image_path].each_with_index do |img, i|
|
191
222
|
suffix_index = i > 0 ? "-#{i}" : ''
|
192
|
-
|
223
|
+
|
224
|
+
linked_image = id_dir.join("linked-box#{suffix_index}.img").to_s
|
225
|
+
args = ["create", "-f", "qcow2", "-F", "qcow2", "-b", img.to_s]
|
226
|
+
|
227
|
+
if !options[:extra_image_opts].nil?
|
228
|
+
options[:extra_image_opts].each do |opt|
|
229
|
+
args.push("-o")
|
230
|
+
args.push(opt)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
args.push(linked_image)
|
235
|
+
|
236
|
+
if i == 0
|
237
|
+
if !options[:disk_resize].nil?
|
238
|
+
args.push(options[:disk_resize])
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
execute("qemu-img", *args)
|
193
243
|
end
|
194
244
|
|
195
245
|
server = {
|
@@ -301,6 +351,18 @@ module VagrantPlugins
|
|
301
351
|
end
|
302
352
|
end
|
303
353
|
end
|
354
|
+
|
355
|
+
def attach_dvd(disk)
|
356
|
+
@attached_drives[:dvd] << disk
|
357
|
+
end
|
358
|
+
|
359
|
+
def attach_disk(disk)
|
360
|
+
@attached_drives[:disk] << disk
|
361
|
+
end
|
362
|
+
|
363
|
+
def disk_dir
|
364
|
+
@data_dir.join(@vm_id)
|
365
|
+
end
|
304
366
|
end
|
305
367
|
end
|
306
368
|
end
|
data/lib/vagrant-qemu/plugin.rb
CHANGED
@@ -24,6 +24,31 @@ module VagrantPlugins
|
|
24
24
|
Config
|
25
25
|
end
|
26
26
|
|
27
|
+
provider_capability(:qemu, :set_default_disk_ext) do
|
28
|
+
require File.expand_path("../cap/disk", __FILE__)
|
29
|
+
Cap::Disk
|
30
|
+
end
|
31
|
+
|
32
|
+
provider_capability(:qemu, :default_disk_exts) do
|
33
|
+
require File.expand_path("../cap/disk", __FILE__)
|
34
|
+
Cap::Disk
|
35
|
+
end
|
36
|
+
|
37
|
+
provider_capability(:qemu, :configure_disks) do
|
38
|
+
require File.expand_path("../cap/disk", __FILE__)
|
39
|
+
Cap::Disk
|
40
|
+
end
|
41
|
+
|
42
|
+
provider_capability(:qemu, :cleanup_disks) do
|
43
|
+
require File.expand_path("../cap/disk", __FILE__)
|
44
|
+
Cap::Disk
|
45
|
+
end
|
46
|
+
|
47
|
+
provider_capability(:qemu, :validate_disk_ext) do
|
48
|
+
require File.expand_path("../cap/disk", __FILE__)
|
49
|
+
Cap::Disk
|
50
|
+
end
|
51
|
+
|
27
52
|
provider(:qemu, box_format: "libvirt", box_optional: true, parallel: true) do
|
28
53
|
# Setup logging and i18n
|
29
54
|
setup_logging
|
data/lib/vagrant-qemu/version.rb
CHANGED
data/lib/vagrant-qemu.rb
CHANGED
@@ -6,6 +6,7 @@ module VagrantPlugins
|
|
6
6
|
module QEMU
|
7
7
|
lib_path = Pathname.new(File.expand_path("../vagrant-qemu", __FILE__))
|
8
8
|
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Cap, lib_path.join("cap")
|
9
10
|
autoload :Errors, lib_path.join("errors")
|
10
11
|
|
11
12
|
# This returns the path to the source of this plugin.
|
data/locales/en.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-qemu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ppggff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Enables Vagrant to manage machines with QEMU.
|
14
14
|
email: pgf00a@gmail.com
|
@@ -34,6 +34,8 @@ files:
|
|
34
34
|
- lib/vagrant-qemu/action/start_instance.rb
|
35
35
|
- lib/vagrant-qemu/action/stop_instance.rb
|
36
36
|
- lib/vagrant-qemu/action/warn_networks.rb
|
37
|
+
- lib/vagrant-qemu/cap.rb
|
38
|
+
- lib/vagrant-qemu/cap/disk.rb
|
37
39
|
- lib/vagrant-qemu/config.rb
|
38
40
|
- lib/vagrant-qemu/driver.rb
|
39
41
|
- lib/vagrant-qemu/errors.rb
|
@@ -43,7 +45,6 @@ files:
|
|
43
45
|
- lib/vagrant-qemu/version.rb
|
44
46
|
- locales/en.yml
|
45
47
|
- vagrant-qemu.gemspec
|
46
|
-
- x
|
47
48
|
homepage: https://github.com/ppggff/vagrant-qemu
|
48
49
|
licenses:
|
49
50
|
- MIT
|
data/x
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
diff --git a/lib/vagrant-qemu/action.rb b/lib/vagrant-qemu/action.rb
|
2
|
-
index bb87e38..8818aa9 100644
|
3
|
-
--- a/lib/vagrant-qemu/action.rb
|
4
|
-
+++ b/lib/vagrant-qemu/action.rb
|
5
|
-
@@ -116,7 +116,7 @@ module VagrantPlugins
|
6
|
-
end
|
7
|
-
|
8
|
-
b1.use Provision
|
9
|
-
- b1.use EnvSet, port_collision_repair: false
|
10
|
-
+ b1.use EnvSet, port_collision_repair: true
|
11
|
-
b1.use PrepareForwardedPortCollisionParams
|
12
|
-
b1.use HandleForwardedPortCollisions
|
13
|
-
b1.use SyncedFolderCleanup
|
14
|
-
diff --git a/lib/vagrant-qemu/action/prepare_forwarded_port_collision_params.rb b/lib/vagrant-qemu/action/prepare_forwarded_port_collision_params.rb
|
15
|
-
index 159a785..b7c93a3 100644
|
16
|
-
--- a/lib/vagrant-qemu/action/prepare_forwarded_port_collision_params.rb
|
17
|
-
+++ b/lib/vagrant-qemu/action/prepare_forwarded_port_collision_params.rb
|
18
|
-
@@ -16,16 +16,23 @@ module VagrantPlugins
|
19
|
-
# Build the remap for any existing collision detections
|
20
|
-
remap = {}
|
21
|
-
env[:port_collision_remap] = remap
|
22
|
-
+
|
23
|
-
+ has_ssh_forward = false
|
24
|
-
machine.config.vm.networks.each do |type, options|
|
25
|
-
next if type != :forwarded_port
|
26
|
-
|
27
|
-
# remap ssh.host to ssh_port
|
28
|
-
if options[:id] == "ssh"
|
29
|
-
remap[options[:host]] = machine.provider_config.ssh_port
|
30
|
-
+ has_ssh_forward = true
|
31
|
-
break
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
+ if !has_ssh_forward
|
36
|
-
+ machine.config.vm.networks.forward_port(22, machine.provider_config.ssh_port, [id: "ssh", auto_correct: true])
|
37
|
-
+ end
|
38
|
-
+
|
39
|
-
@app.call(env)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
diff --git a/lib/vagrant-qemu/action/start_instance.rb b/lib/vagrant-qemu/action/start_instance.rb
|
43
|
-
index 13c1d9d..b434bb3 100644
|
44
|
-
--- a/lib/vagrant-qemu/action/start_instance.rb
|
45
|
-
+++ b/lib/vagrant-qemu/action/start_instance.rb
|
46
|
-
@@ -11,6 +11,7 @@ module VagrantPlugins
|
47
|
-
end
|
48
|
-
|
49
|
-
def call(env)
|
50
|
-
+ fwPorts = forwarded_ports(env)
|
51
|
-
options = {
|
52
|
-
:ssh_host => env[:machine].provider_config.ssh_host,
|
53
|
-
:ssh_port => env[:machine].provider_config.ssh_port,
|
54
|
-
@@ -23,7 +24,7 @@ module VagrantPlugins
|
55
|
-
:drive_interface => env[:machine].provider_config.drive_interface,
|
56
|
-
:extra_qemu_args => env[:machine].provider_config.extra_qemu_args,
|
57
|
-
:extra_netdev_args => env[:machine].provider_config.extra_netdev_args,
|
58
|
-
- :ports => forwarded_ports(env),
|
59
|
-
+ :ports => fwPorts,
|
60
|
-
:control_port => env[:machine].provider_config.control_port,
|
61
|
-
:debug_port => env[:machine].provider_config.debug_port,
|
62
|
-
:no_daemonize => env[:machine].provider_config.no_daemonize,
|
63
|
-
@@ -43,7 +44,12 @@ module VagrantPlugins
|
64
|
-
next if type != :forwarded_port
|
65
|
-
|
66
|
-
# Don't include SSH
|
67
|
-
- next if options[:id] == "ssh"
|
68
|
-
+ if options[:id] == "ssh"
|
69
|
-
+ if options[:host] != env[:machine].provider_config.ssh_port
|
70
|
-
+ env[:machine].provider_config.ssh_port = options[:host]
|
71
|
-
+ end
|
72
|
-
+ next
|
73
|
-
+ end
|
74
|
-
|
75
|
-
# Skip port if it is disabled
|
76
|
-
next if options[:disabled]
|