vagrant-qemu 0.3.4 → 0.3.5
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 +8 -0
- data/README.md +26 -2
- data/lib/vagrant-qemu/action/import.rb +1 -0
- data/lib/vagrant-qemu/action/start_instance.rb +5 -6
- data/lib/vagrant-qemu/config.rb +9 -0
- data/lib/vagrant-qemu/driver.rb +31 -22
- data/lib/vagrant-qemu/provider.rb +1 -1
- data/lib/vagrant-qemu/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c30b268793fc83d9e8f8e87c6a8f4bcee6b918bc93e290fca5d7fa5bbf997fb8
|
4
|
+
data.tar.gz: 0f4601e7634001be4f8073587dd695dacac7c5ff6822c06530d8b09cae4f19e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0799387634f0395de31a58e7e94b2e5668527b4a1f02e793d7bc0efdfc8b44879146a6e5a714866e99a8447ffd4ac23985efac9ca3d4d05462a217d3ae88a6b
|
7
|
+
data.tar.gz: 9ca32661b5d7078e9e4641d2acb3c131686b9e52458405618bfe0074abc77829d36f9b858c24202f9cd01fe96793a4e5595e39dc8eecb6678c1ad38f8cfcd2e4
|
data/CHANGELOG.md
CHANGED
@@ -58,3 +58,11 @@
|
|
58
58
|
# 0.3.4 (2023-03-09)
|
59
59
|
|
60
60
|
* Add config 'drive_interface'.
|
61
|
+
|
62
|
+
# 0.3.5 (2023-07-27)
|
63
|
+
|
64
|
+
* Fix forwarded ports bug. #39
|
65
|
+
* Add config 'firmware_format', 'ssh_host', 'other_default'.
|
66
|
+
* Allow no cpu for riscv64.
|
67
|
+
* Allow more config options to be nil.
|
68
|
+
* Let id start with "vq_".
|
data/README.md
CHANGED
@@ -72,17 +72,19 @@ Same as [vagrant-libvirt version-1](https://github.com/vagrant-libvirt/vagrant-l
|
|
72
72
|
|
73
73
|
## Configuration
|
74
74
|
|
75
|
+
### Options
|
76
|
+
|
75
77
|
This provider exposes a few provider-specific configuration options:
|
76
78
|
|
77
79
|
* basic
|
78
|
-
* `ssh_port` - The SSH port number used to access VM
|
79
|
-
default: `50022`
|
80
|
+
* `ssh_port` - The SSH port number used to access VM, default: `50022`
|
80
81
|
* `arch` - The architecture of VM, default: `aarch64`
|
81
82
|
* `machine` - The machine type of VM, default: `virt,accel=hvf,highmem=off`
|
82
83
|
* `cpu` - The cpu model of VM, default: `cortex-a72`
|
83
84
|
* `smp` - The smp setting (Simulate an SMP system with n CPUs) of VM, default: `2`
|
84
85
|
* `memory` - The memory setting of VM, default: `4G`
|
85
86
|
* debug/expert
|
87
|
+
* `ssh_host` - The SSH IP used to access VM, default: `127.0.0.1`
|
86
88
|
* `net_device` - The network device, default: `virtio-net-device`
|
87
89
|
* `drive_interface` - The interface type for the main drive, default `virtio`
|
88
90
|
* `image_path` - The path to qcow2 image for box-less VM, default is nil value
|
@@ -92,6 +94,10 @@ This provider exposes a few provider-specific configuration options:
|
|
92
94
|
* `control_port` - The port number used to control vm from vagrant, default is nil value. (nil means use unix socket)
|
93
95
|
* `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)
|
94
96
|
* `no_daemonize` - Disable the "daemonize" mode of QEMU, default is false. (see "Windows host" below as example)
|
97
|
+
* `firmware_format` - The format of aarch64 firmware images (`edk2-aarch64-code.fd` and `edk2-arm-vars.fd`) loaded from `qemu_dir`, default: `raw`
|
98
|
+
* `other_default` - The other default arguments used by this plugin, default: `%W(-parallel null -monitor none -display none -vga none)`
|
99
|
+
|
100
|
+
### Usage
|
95
101
|
|
96
102
|
These can be set like typical provider-specific configuration:
|
97
103
|
|
@@ -106,6 +112,24 @@ Vagrant.configure(2) do |config|
|
|
106
112
|
end
|
107
113
|
```
|
108
114
|
|
115
|
+
### With `nil` value
|
116
|
+
|
117
|
+
To be able to custom the result qemu command deeply, you can set some config options
|
118
|
+
to `nil` value to skip related qemu arguments.
|
119
|
+
|
120
|
+
* `machine`: skip `-machine xxx`
|
121
|
+
* `cpu`: skip `-cpu xxx`
|
122
|
+
* `smp`: skip `-smp xxx`
|
123
|
+
* `memory`: skip `-m xxx`
|
124
|
+
* `net_device`: skip all network related arguments:
|
125
|
+
* `-device xxx,netdev=net0`
|
126
|
+
* `-netdev user,id=net0,xxx`
|
127
|
+
* NOTES: there will be no network, ssh won't work
|
128
|
+
* `drive_interface`: skip drive for the main image, `-drive if=xxx,xxx`
|
129
|
+
* `firmware_format`: skip firmware setup for aarch64, `-drive if=pflash,xxx`
|
130
|
+
|
131
|
+
With `other_default = []`, all default arguments will be skipped.
|
132
|
+
|
109
133
|
## Example
|
110
134
|
|
111
135
|
1. Try with a sample box
|
@@ -12,6 +12,7 @@ module VagrantPlugins
|
|
12
12
|
|
13
13
|
def call(env)
|
14
14
|
options = {
|
15
|
+
:ssh_host => env[:machine].provider_config.ssh_host,
|
15
16
|
:ssh_port => env[:machine].provider_config.ssh_port,
|
16
17
|
:arch => env[:machine].provider_config.arch,
|
17
18
|
:machine => env[:machine].provider_config.machine,
|
@@ -25,7 +26,9 @@ module VagrantPlugins
|
|
25
26
|
:ports => forwarded_ports(env),
|
26
27
|
:control_port => env[:machine].provider_config.control_port,
|
27
28
|
:debug_port => env[:machine].provider_config.debug_port,
|
28
|
-
:no_daemonize => env[:machine].provider_config.no_daemonize
|
29
|
+
:no_daemonize => env[:machine].provider_config.no_daemonize,
|
30
|
+
:firmware_format => env[:machine].provider_config.firmware_format,
|
31
|
+
:other_default => env[:machine].provider_config.other_default
|
29
32
|
}
|
30
33
|
|
31
34
|
env[:ui].output(I18n.t("vagrant_qemu.starting"))
|
@@ -45,11 +48,7 @@ module VagrantPlugins
|
|
45
48
|
# Skip port if it is disabled
|
46
49
|
next if options[:disabled]
|
47
50
|
|
48
|
-
host_ip
|
49
|
-
host_ip = "#{options[:host_ip]}:" if options[:host_ip]
|
50
|
-
guest_ip = ""
|
51
|
-
guest_ip = "#{options[:guest_ip]}:" if options[:guest_ip]
|
52
|
-
result.push("#{options[:protocol]}:#{host_ip}:#{options[:host]}-#{guest_ip}:#{options[:guest]}")
|
51
|
+
result.push("#{options[:protocol]}:#{options[:host_ip]}:#{options[:host]}-#{options[:guest_ip]}:#{options[:guest]}")
|
53
52
|
end
|
54
53
|
|
55
54
|
result
|
data/lib/vagrant-qemu/config.rb
CHANGED
@@ -3,6 +3,7 @@ require "vagrant"
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module QEMU
|
5
5
|
class Config < Vagrant.plugin("2", :config)
|
6
|
+
attr_accessor :ssh_host
|
6
7
|
attr_accessor :ssh_port
|
7
8
|
attr_accessor :arch
|
8
9
|
attr_accessor :machine
|
@@ -18,8 +19,11 @@ module VagrantPlugins
|
|
18
19
|
attr_accessor :control_port
|
19
20
|
attr_accessor :debug_port
|
20
21
|
attr_accessor :no_daemonize
|
22
|
+
attr_accessor :firmware_format
|
23
|
+
attr_accessor :other_default
|
21
24
|
|
22
25
|
def initialize
|
26
|
+
@ssh_host = UNSET_VALUE
|
23
27
|
@ssh_port = UNSET_VALUE
|
24
28
|
@arch = UNSET_VALUE
|
25
29
|
@machine = UNSET_VALUE
|
@@ -35,6 +39,8 @@ module VagrantPlugins
|
|
35
39
|
@control_port = UNSET_VALUE
|
36
40
|
@debug_port = UNSET_VALUE
|
37
41
|
@no_daemonize = UNSET_VALUE
|
42
|
+
@firmware_format = UNSET_VALUE
|
43
|
+
@other_default = UNSET_VALUE
|
38
44
|
end
|
39
45
|
|
40
46
|
#-------------------------------------------------------------------
|
@@ -47,6 +53,7 @@ module VagrantPlugins
|
|
47
53
|
end
|
48
54
|
|
49
55
|
def finalize!
|
56
|
+
@ssh_host = "127.0.0.1" if @ssh_host == UNSET_VALUE
|
50
57
|
@ssh_port = 50022 if @ssh_port == UNSET_VALUE
|
51
58
|
@arch = "aarch64" if @arch == UNSET_VALUE
|
52
59
|
@machine = "virt,accel=hvf,highmem=on" if @machine == UNSET_VALUE
|
@@ -62,6 +69,8 @@ module VagrantPlugins
|
|
62
69
|
@control_port = nil if @control_port == UNSET_VALUE
|
63
70
|
@debug_port = nil if @debug_port == UNSET_VALUE
|
64
71
|
@no_daemonize = false if @no_daemonize == UNSET_VALUE
|
72
|
+
@firmware_format = "raw" if @firmware_format == UNSET_VALUE
|
73
|
+
@other_default = %W(-parallel null -monitor none -display none -vga none) if @other_default == UNSET_VALUE
|
65
74
|
end
|
66
75
|
|
67
76
|
def validate(machine)
|
data/lib/vagrant-qemu/driver.rb
CHANGED
@@ -71,30 +71,37 @@ module VagrantPlugins
|
|
71
71
|
cmd += %W(qemu-system-#{options[:arch]})
|
72
72
|
|
73
73
|
# basic
|
74
|
-
cmd += %W(-machine #{options[:machine]})
|
75
|
-
cmd += %W(-cpu #{options[:cpu]})
|
76
|
-
cmd += %W(-smp #{options[:smp]})
|
77
|
-
cmd += %W(-m #{options[:memory]})
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
74
|
+
cmd += %W(-machine #{options[:machine]}) if !options[:machine].nil?
|
75
|
+
cmd += %W(-cpu #{options[:cpu]}) if !options[:cpu].nil?
|
76
|
+
cmd += %W(-smp #{options[:smp]}) if !options[:smp].nil?
|
77
|
+
cmd += %W(-m #{options[:memory]}) if !options[:memory].nil?
|
78
|
+
|
79
|
+
# network
|
80
|
+
if !options[:net_device].nil?
|
81
|
+
# net device
|
82
|
+
cmd += %W(-device #{options[:net_device]},netdev=net0)
|
83
|
+
|
84
|
+
# ports
|
85
|
+
hostfwd = "hostfwd=tcp::#{options[:ssh_port]}-:22"
|
86
|
+
options[:ports].each do |v|
|
87
|
+
hostfwd += ",hostfwd=#{v}"
|
88
|
+
end
|
89
|
+
extra_netdev = ""
|
90
|
+
if !options[:extra_netdev_args].nil?
|
91
|
+
extra_netdev = ",#{options[:extra_netdev_args]}"
|
92
|
+
end
|
93
|
+
cmd += %W(-netdev user,id=net0,#{hostfwd}#{extra_netdev})
|
88
94
|
end
|
89
|
-
cmd += %W(-netdev user,id=net0,#{hostfwd}#{extra_netdev})
|
90
95
|
|
91
96
|
# drive
|
92
|
-
|
93
|
-
|
97
|
+
if !options[:drive_interface].nil?
|
98
|
+
cmd += %W(-drive if=#{options[:drive_interface]},format=qcow2,file=#{image_path})
|
99
|
+
end
|
100
|
+
if options[:arch] == "aarch64" && !options[:firmware_format].nil?
|
94
101
|
fm1_path = id_dir.join("edk2-aarch64-code.fd").to_s
|
95
102
|
fm2_path = id_dir.join("edk2-arm-vars.fd").to_s
|
96
|
-
cmd += %W(-drive if=pflash,format
|
97
|
-
cmd += %W(-drive if=pflash,format
|
103
|
+
cmd += %W(-drive if=pflash,format=#{options[:firmware_format]},file=#{fm1_path},readonly=on)
|
104
|
+
cmd += %W(-drive if=pflash,format=#{options[:firmware_format]},file=#{fm2_path})
|
98
105
|
end
|
99
106
|
|
100
107
|
# control
|
@@ -103,11 +110,13 @@ module VagrantPlugins
|
|
103
110
|
cmd += %W(-chardev socket,id=ser0,#{debug_socket},server=on,wait=off)
|
104
111
|
cmd += %W(-serial chardev:ser0)
|
105
112
|
cmd += %W(-pidfile #{pid_file})
|
106
|
-
cmd += %W(-parallel null -monitor none -display none -vga none)
|
107
113
|
if !options[:no_daemonize]
|
108
114
|
cmd += %W(-daemonize)
|
109
115
|
end
|
110
116
|
|
117
|
+
# other default
|
118
|
+
cmd += options[:other_default]
|
119
|
+
|
111
120
|
# user-defined
|
112
121
|
cmd += options[:extra_qemu_args]
|
113
122
|
|
@@ -137,7 +146,7 @@ module VagrantPlugins
|
|
137
146
|
end
|
138
147
|
|
139
148
|
def import(options)
|
140
|
-
new_id = SecureRandom.urlsafe_base64(8)
|
149
|
+
new_id = "vq_" + SecureRandom.urlsafe_base64(8)
|
141
150
|
|
142
151
|
# Make dir
|
143
152
|
id_dir = @data_dir.join(new_id)
|
@@ -146,7 +155,7 @@ module VagrantPlugins
|
|
146
155
|
FileUtils.mkdir_p(id_tmp_dir)
|
147
156
|
|
148
157
|
# Prepare firmware
|
149
|
-
if options[:arch] == "aarch64"
|
158
|
+
if options[:arch] == "aarch64" && !options[:firmware_format].nil?
|
150
159
|
execute("cp", options[:qemu_dir].join("edk2-aarch64-code.fd").to_s, id_dir.join("edk2-aarch64-code.fd").to_s)
|
151
160
|
execute("cp", options[:qemu_dir].join("edk2-arm-vars.fd").to_s, id_dir.join("edk2-arm-vars.fd").to_s)
|
152
161
|
execute("chmod", "644", id_dir.join("edk2-arm-vars.fd").to_s)
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ppggff
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-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
|
@@ -47,7 +47,7 @@ homepage: https://github.com/ppggff/vagrant-qemu
|
|
47
47
|
licenses:
|
48
48
|
- MIT
|
49
49
|
metadata: {}
|
50
|
-
post_install_message:
|
50
|
+
post_install_message:
|
51
51
|
rdoc_options: []
|
52
52
|
require_paths:
|
53
53
|
- lib
|
@@ -62,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: 1.3.6
|
64
64
|
requirements: []
|
65
|
-
rubygems_version: 3.
|
66
|
-
signing_key:
|
65
|
+
rubygems_version: 3.2.33
|
66
|
+
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: Enables Vagrant to manage machines with QEMU.
|
69
69
|
test_files: []
|