vagrant-qemu 0.3.5 → 0.3.6
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 +5 -0
- data/README.md +2 -1
- data/lib/vagrant-qemu/action/import.rb +44 -9
- data/lib/vagrant-qemu/driver.rb +14 -3
- data/lib/vagrant-qemu/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 47636dd2f589218fd058d32661aa2844a842ea0c1fce7c4fbf1bceb5efc58bea
|
|
4
|
+
data.tar.gz: d4e04639beb03206cdcb5a09c2b63d608efe18b623ede070d6b2a4a1bafb452e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80ef6dbcb15d76fc97296b178416aaede61bcf4133fc38cac83fd92854cc1e92c8159b49ff961939e498a344b33a328fe87a6995675b65d91a6286d2ae0334ed
|
|
7
|
+
data.tar.gz: bad9fba78583cb6cb236e81728eba6d9fd53747b25abfe94b1227e0258364e536c093a126a3daea13a72e7bb1403df86710739032b931012ceee7f2a529dadd1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -30,6 +30,7 @@ Others:
|
|
|
30
30
|
|
|
31
31
|
* Import from a Libvirt vagrant box or qcow2 image
|
|
32
32
|
* To use box for **Paralles or VMware Fusion**, see [Wiki](https://github.com/ppggff/vagrant-qemu/wiki) for details
|
|
33
|
+
* Libvirt box v2 format support is experimental
|
|
33
34
|
* Start VM without GUI
|
|
34
35
|
* SSH into VM
|
|
35
36
|
* Provision the instances with any built-in Vagrant provisioner
|
|
@@ -87,7 +88,7 @@ This provider exposes a few provider-specific configuration options:
|
|
|
87
88
|
* `ssh_host` - The SSH IP used to access VM, default: `127.0.0.1`
|
|
88
89
|
* `net_device` - The network device, default: `virtio-net-device`
|
|
89
90
|
* `drive_interface` - The interface type for the main drive, default `virtio`
|
|
90
|
-
* `image_path` - The path to qcow2 image for box-less VM, default is nil value
|
|
91
|
+
* `image_path` - The path (or array of paths) to qcow2 image for box-less VM, default is nil value
|
|
91
92
|
* `qemu_dir` - The path to QEMU's install dir, default: `/opt/homebrew/share/qemu`
|
|
92
93
|
* `extra_qemu_args` - The raw list of additional arguments to pass to QEMU. Use with extreme caution. (see "Force Multicore" below as example)
|
|
93
94
|
* `extra_netdev_args` - extra, comma-separated arguments to pass to the -netdev parameter. Use with caution. (see "Force Local IP" below as example)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require "log4r"
|
|
2
|
+
require "open3"
|
|
2
3
|
require "pathname"
|
|
3
4
|
|
|
4
5
|
module VagrantPlugins
|
|
@@ -12,18 +13,52 @@ module VagrantPlugins
|
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def call(env)
|
|
15
|
-
image_path =
|
|
16
|
+
image_path = Array.new
|
|
16
17
|
if env[:machine].provider_config.image_path
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
paths = env[:machine].provider_config.image_path
|
|
19
|
+
paths = [paths] if !paths.kind_of?(Array)
|
|
20
|
+
paths.each do |p|
|
|
21
|
+
image_path.append(Pathname.new(p))
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
disks = env[:machine].box.metadata.fetch('disks', [])
|
|
25
|
+
if disks.empty?
|
|
26
|
+
# box v1 format
|
|
27
|
+
image_path.append(env[:machine].box.directory.join("box.img"))
|
|
28
|
+
else
|
|
29
|
+
# box v2 format
|
|
30
|
+
disks.each_with_index do |d, i|
|
|
31
|
+
if d['path'].nil?
|
|
32
|
+
@logger.error("Missing box image path for disk #{i}")
|
|
33
|
+
raise Errors::BoxInvalid, name: env[:machine].name, err: "Missing box image path for disk #{i}"
|
|
34
|
+
end
|
|
35
|
+
image_path.append(env[:machine].box.directory.join(d['path']))
|
|
36
|
+
end
|
|
37
|
+
end
|
|
20
38
|
end
|
|
21
39
|
|
|
22
|
-
if
|
|
23
|
-
@logger.error("
|
|
24
|
-
raise Errors::BoxInvalid, name: env[:machine].name, err: "
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
if image_path.empty?
|
|
41
|
+
@logger.error("Empty box image path")
|
|
42
|
+
raise Errors::BoxInvalid, name: env[:machine].name, err: "Empty box image path"
|
|
43
|
+
end
|
|
44
|
+
image_path.each do |img|
|
|
45
|
+
if !img.file?
|
|
46
|
+
@logger.error("Invalid box image path: #{img}")
|
|
47
|
+
raise Errors::BoxInvalid, name: env[:machine].name, err: "Invalid box image path: #{img}"
|
|
48
|
+
end
|
|
49
|
+
img_str = img.to_s
|
|
50
|
+
stdout, stderr, status = Open3.capture3('qemu-img', 'info', '--output=json', img_str)
|
|
51
|
+
if !status.success?
|
|
52
|
+
@logger.error("Run qemu-img info failed, #{img_str}, out: #{stdout}, err: #{stderr}")
|
|
53
|
+
raise Errors::BoxInvalid, name: env[:machine].name, err: "Run qemu-img info failed, #{img_str}, out: #{stdout}, err: #{stderr}"
|
|
54
|
+
end
|
|
55
|
+
img_info = JSON.parse(stdout)
|
|
56
|
+
format = img_info['format']
|
|
57
|
+
if format != 'qcow2'
|
|
58
|
+
@logger.error("Invalid box image format, #{img_str}, format: #{format}")
|
|
59
|
+
raise Errors::BoxInvalid, name: env[:machine].name, err: "Invalid box image format, #{img_str}, format: #{format}"
|
|
60
|
+
end
|
|
61
|
+
@logger.info("Found box image path: #{img_info}")
|
|
27
62
|
end
|
|
28
63
|
|
|
29
64
|
qemu_dir = Pathname.new(env[:machine].provider_config.qemu_dir)
|
data/lib/vagrant-qemu/driver.rb
CHANGED
|
@@ -45,9 +45,15 @@ module VagrantPlugins
|
|
|
45
45
|
def start(options)
|
|
46
46
|
if !running?
|
|
47
47
|
id_dir = @data_dir.join(@vm_id)
|
|
48
|
-
image_path = id_dir.join("linked-box.img").to_s
|
|
49
48
|
pid_file = id_dir.join("qemu.pid").to_s
|
|
50
49
|
|
|
50
|
+
image_path = Array.new
|
|
51
|
+
image_count = id_dir.glob("linked-box*.img").count
|
|
52
|
+
for i in 0..image_count-1 do
|
|
53
|
+
suffix_index = i > 0 ? "-#{i}" : ''
|
|
54
|
+
image_path.append(id_dir.join("linked-box#{suffix_index}.img").to_s)
|
|
55
|
+
end
|
|
56
|
+
|
|
51
57
|
id_tmp_dir = @tmp_dir.join(@vm_id)
|
|
52
58
|
FileUtils.mkdir_p(id_tmp_dir)
|
|
53
59
|
|
|
@@ -95,7 +101,9 @@ module VagrantPlugins
|
|
|
95
101
|
|
|
96
102
|
# drive
|
|
97
103
|
if !options[:drive_interface].nil?
|
|
98
|
-
|
|
104
|
+
image_path.each do |img|
|
|
105
|
+
cmd += %W(-drive if=#{options[:drive_interface]},format=qcow2,file=#{img})
|
|
106
|
+
end
|
|
99
107
|
end
|
|
100
108
|
if options[:arch] == "aarch64" && !options[:firmware_format].nil?
|
|
101
109
|
fm1_path = id_dir.join("edk2-aarch64-code.fd").to_s
|
|
@@ -162,7 +170,10 @@ module VagrantPlugins
|
|
|
162
170
|
end
|
|
163
171
|
|
|
164
172
|
# Create image
|
|
165
|
-
|
|
173
|
+
options[:image_path].each_with_index do |img, i|
|
|
174
|
+
suffix_index = i > 0 ? "-#{i}" : ''
|
|
175
|
+
execute("qemu-img", "create", "-f", "qcow2", "-F", "qcow2", "-b", img.to_s, id_dir.join("linked-box#{suffix_index}.img").to_s)
|
|
176
|
+
end
|
|
166
177
|
|
|
167
178
|
server = {
|
|
168
179
|
:id => new_id,
|
data/lib/vagrant-qemu/version.rb
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.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ppggff
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-02-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Enables Vagrant to manage machines with QEMU.
|
|
14
14
|
email: pgf00a@gmail.com
|