vagrant-libvirt 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -8
- data/lib/vagrant-libvirt/action/create_domain.rb +24 -0
- data/lib/vagrant-libvirt/action/create_networks.rb +11 -0
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +1 -1
- data/lib/vagrant-libvirt/action/start_domain.rb +36 -0
- data/lib/vagrant-libvirt/config.rb +45 -2
- data/lib/vagrant-libvirt/driver.rb +8 -8
- data/lib/vagrant-libvirt/errors.rb +4 -0
- data/lib/vagrant-libvirt/templates/domain.xml.erb +18 -5
- data/lib/vagrant-libvirt/util/network_util.rb +2 -1
- data/lib/vagrant-libvirt/util/nfs.rb +2 -0
- data/lib/vagrant-libvirt/version +1 -1
- data/locales/en.yml +4 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/libvirt_context.rb +7 -4
- data/spec/support/sharedcontext.rb +1 -1
- data/spec/unit/action/prepare_nfs_settings_spec.rb +55 -0
- data/spec/unit/action/shutdown_domain_spec.rb +1 -1
- data/spec/unit/action/wait_till_up_spec.rb +2 -1
- data/spec/unit/config_spec.rb +48 -0
- data/spec/unit/driver_spec.rb +138 -3
- data/spec/unit/templates/domain_all_settings.xml +10 -4
- data/spec/unit/templates/domain_spec.rb +3 -0
- metadata +39 -38
- data/spec/unit/provider_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696535927498f1996c3fd02f6e5503bd8ac47e92eb226d03cd28c46329232b93
|
4
|
+
data.tar.gz: 73cfeb05a09dad74122a6f09f562b5d56ac7c43a7ec029f2e8f5c8dcfa2a9413
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4237cc046b138f9fbd5efad00bcc80d97b964d6a374e68b94c20cc19fd668e6eda2ea2939d8782ca05b9ea80478907a9728c3b34692b1b2adbb6305f1798cf4
|
7
|
+
data.tar.gz: 5a3e8094b553fd2557be01514f782139bfa52edca8c7dc811138932a84c7f3bffe44e7c0a5a5b322868e648016146efc9b67f5e3a7356e98b2d58b0e6ca2db74
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Vagrant Libvirt Provider
|
2
2
|
|
3
3
|
[![Join the chat at https://gitter.im/vagrant-libvirt/vagrant-libvirt](https://badges.gitter.im/vagrant-libvirt/vagrant-libvirt.svg)](https://gitter.im/vagrant-libvirt/vagrant-libvirt?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
4
|
-
[![Build Status](https://
|
4
|
+
[![Build Status](https://github.com/vagrant-libvirt/vagrant-libvirt/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/vagrant-libvirt/vagrant-libvirt/actions/workflows/unit-tests.yml)
|
5
5
|
[![Coverage Status](https://coveralls.io/repos/github/vagrant-libvirt/vagrant-libvirt/badge.svg?branch=master)](https://coveralls.io/github/vagrant-libvirt/vagrant-libvirt?branch=master)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/vagrant-libvirt.svg)](https://badge.fury.io/rb/vagrant-libvirt)
|
6
7
|
|
7
8
|
This is a [Vagrant](http://www.vagrantup.com) plugin that adds a
|
8
9
|
[Libvirt](http://libvirt.org) provider to Vagrant, allowing Vagrant to
|
@@ -49,6 +50,7 @@ can help a lot :-)
|
|
49
50
|
* [USB Redirector Devices](#usb-redirector-devices)
|
50
51
|
* [Filter for USB Redirector Devices](#filter-for-usb-redirector-devices)
|
51
52
|
* [Random number generator passthrough](#random-number-generator-passthrough)
|
53
|
+
* [Serial Console Devices](#serial-console-devices)
|
52
54
|
* [Watchdog device](#watchdog-device)
|
53
55
|
* [Smartcard device](#smartcard-device)
|
54
56
|
* [Hypervisor Features](#hypervisor-features)
|
@@ -137,12 +139,6 @@ docker pull vagrantlibvirt/vagrant-libvirt:edge
|
|
137
139
|
```
|
138
140
|
---
|
139
141
|
|
140
|
-
Preparing the docker run, only once:
|
141
|
-
|
142
|
-
```bash
|
143
|
-
mkdir -p ~/.vagrant.d/{boxes,data,tmp}
|
144
|
-
```
|
145
|
-
|
146
142
|
Running the image:
|
147
143
|
```bash
|
148
144
|
docker run -it --rm \
|
@@ -173,6 +169,14 @@ vagrant(){
|
|
173
169
|
```
|
174
170
|
|
175
171
|
### Using Podman
|
172
|
+
|
173
|
+
Preparing the podman run, only once:
|
174
|
+
|
175
|
+
```bash
|
176
|
+
mkdir -p ~/.vagrant.d/{boxes,data,tmp}
|
177
|
+
```
|
178
|
+
_N.B. This is needed until the entrypoint works for podman to only mount the `~/.vagrant.d` directory_
|
179
|
+
|
176
180
|
To run with Podman you need to include
|
177
181
|
|
178
182
|
```bash
|
@@ -180,6 +184,7 @@ To run with Podman you need to include
|
|
180
184
|
--security-opt label=disable \
|
181
185
|
-v ~/.vagrant.d/boxes:/vagrant/boxes \
|
182
186
|
-v ~/.vagrant.d/data:/vagrant/data \
|
187
|
+
-v ~/.vagrant.d/data:/vagrant/tmp \
|
183
188
|
```
|
184
189
|
|
185
190
|
for example:
|
@@ -191,6 +196,7 @@ vagrant(){
|
|
191
196
|
-v /var/run/libvirt/:/var/run/libvirt/ \
|
192
197
|
-v ~/.vagrant.d/boxes:/vagrant/boxes \
|
193
198
|
-v ~/.vagrant.d/data:/vagrant/data \
|
199
|
+
-v ~/.vagrant.d/data:/vagrant/tmp \
|
194
200
|
-v $(realpath "${PWD}"):${PWD} \
|
195
201
|
-w $(realpath "${PWD}") \
|
196
202
|
--network host \
|
@@ -232,7 +238,7 @@ installed](http://docs.vagrantup.com/v2/installation/index.html).
|
|
232
238
|
Vagrant-libvirt supports Vagrant 2.0, 2.1 & 2.2. It should also work with earlier
|
233
239
|
releases from 1.5 onwards but they are not actively tested.
|
234
240
|
|
235
|
-
Check the [
|
241
|
+
Check the [unit tests](https://github.com/vagrant-libvirt/vagrant-libvirt/blob/master/.github/workflows/unit-tests.yml)
|
236
242
|
for the current list of tested versions.
|
237
243
|
|
238
244
|
*We only test with the upstream version!* If you decide to install your distro's
|
@@ -593,6 +599,8 @@ end
|
|
593
599
|
* `graphics_autoport` - Sets autoport for graphics, Libvirt in this case
|
594
600
|
ignores graphics_port value, Defaults to 'yes'. Possible value are "yes" and
|
595
601
|
"no"
|
602
|
+
* `graphics_gl` - Set to `true` to enable OpenGL. Defaults to `true` if
|
603
|
+
`video_accel3d` is `true`.
|
596
604
|
* `keymap` - Set keymap for vm. default: en-us
|
597
605
|
* `kvm_hidden` - [Hide the hypervisor from the
|
598
606
|
guest](https://libvirt.org/formatdomain.html#elementsFeatures). Useful for
|
@@ -603,6 +611,8 @@ end
|
|
603
611
|
"cirrus", "vmvga", "xen", "vbox", or "qxl".
|
604
612
|
* `video_vram` - Used by some graphics card types to vary the amount of RAM
|
605
613
|
dedicated to video. Defaults to 9216.
|
614
|
+
* `video_accel3d` - Set to `true` to enable 3D acceleration. Defaults to
|
615
|
+
`false`.
|
606
616
|
* `sound_type` - [Set the virtual sound card](https://libvirt.org/formatdomain.html#elementsSound)
|
607
617
|
Defaults to "ich6".
|
608
618
|
* `machine_type` - Sets machine type. Equivalent to qemu `-machine`. Use
|
@@ -657,6 +667,9 @@ end
|
|
657
667
|
it is not possible to communicate with VM through `vagrant ssh` or run
|
658
668
|
provisioning. Setting to 'false' is only possible when VM doesn't use box.
|
659
669
|
Defaults set to 'true'.
|
670
|
+
* `serial` - [libvirt serial devices](https://libvirt.org/formatdomain.html#elementsConsole).
|
671
|
+
Configure a serial/console port to communicate with the guest. Can be used
|
672
|
+
to log to file boot time messages sent to ttyS0 console by the guest.
|
660
673
|
|
661
674
|
Specific domain settings can be set for each domain separately in multi-VM
|
662
675
|
environment. Example below shows a part of Vagrantfile, where specific options
|
@@ -906,6 +919,9 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
906
919
|
If not specified the default is 'false'.
|
907
920
|
* `:bus` - The bus of the PCI device. Both :bus and :slot have to be defined.
|
908
921
|
* `:slot` - The slot of the PCI device. Both :bus and :slot have to be defined.
|
922
|
+
* `:libvirt__always_destroy` - Allow domains that use but did not create a
|
923
|
+
network to destroy it when the domain is destroyed (default: `true`). Set to
|
924
|
+
`false` to only allow the domain that created the network to destroy it.
|
909
925
|
|
910
926
|
When the option `:libvirt__dhcp_enabled` is to to 'false' it shouldn't matter
|
911
927
|
whether the virtual network contains a DHCP server or not and vagrant-libvirt
|
@@ -1249,6 +1265,26 @@ Vagrant.configure("2") do |config|
|
|
1249
1265
|
end
|
1250
1266
|
```
|
1251
1267
|
|
1268
|
+
## Serial Console Devices
|
1269
|
+
You can define settings to redirect output from the serial console of any VM brought up with libvirt to a file or other devices that are listening. [See libvirt documentation](https://libvirt.org/formatdomain.html#elementCharSerial).
|
1270
|
+
|
1271
|
+
Currently only redirecting to a file is supported.
|
1272
|
+
|
1273
|
+
* `type` - only value that has an effect is file, in the future support may be added for virtual console, pty, dev, pipe, tcp, udp, unix socket, spiceport & nmdm.
|
1274
|
+
* `source` - options pertaining to how the connection attaches to the host, contains sub-settings dependent on `type`.
|
1275
|
+
`source` options for type `file`
|
1276
|
+
* `path` - file on host to connect to the serial port to record all output. May be created by qemu system user causing some permissions issues.
|
1277
|
+
|
1278
|
+
```ruby
|
1279
|
+
Vagrant.configure("2") do |config|
|
1280
|
+
config.vm.define :test do |test|
|
1281
|
+
test.vm.provider :libvirt do |domain|
|
1282
|
+
domain.serial :type => "file", :source => {:path => "/var/log/vm_consoles/test.log}
|
1283
|
+
end
|
1284
|
+
end
|
1285
|
+
end
|
1286
|
+
```
|
1287
|
+
|
1252
1288
|
## Random number generator passthrough
|
1253
1289
|
|
1254
1290
|
You can pass through `/dev/random` to your VM by configuring the domain like this:
|
@@ -78,9 +78,11 @@ module VagrantPlugins
|
|
78
78
|
else
|
79
79
|
"passwd='#{config.graphics_passwd}'"
|
80
80
|
end
|
81
|
+
@graphics_gl = config.graphics_gl
|
81
82
|
@video_type = config.video_type
|
82
83
|
@sound_type = config.sound_type
|
83
84
|
@video_vram = config.video_vram
|
85
|
+
@video_accel3d = config.video_accel3d
|
84
86
|
@keymap = config.keymap
|
85
87
|
@kvm_hidden = config.kvm_hidden
|
86
88
|
|
@@ -171,6 +173,20 @@ module VagrantPlugins
|
|
171
173
|
storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
|
172
174
|
end
|
173
175
|
|
176
|
+
@serials = config.serials
|
177
|
+
|
178
|
+
@serials.each do |serial|
|
179
|
+
next unless serial[:source] && serial[:source][:path]
|
180
|
+
|
181
|
+
dir = File.dirname(serial[:source][:path])
|
182
|
+
begin
|
183
|
+
FileUtils.mkdir_p(dir)
|
184
|
+
rescue ::Errno::EACCES
|
185
|
+
raise Errors::SerialCannotCreatePathError,
|
186
|
+
path: dir
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
174
190
|
@disks.each do |disk|
|
175
191
|
disk[:path] ||= _disk_name(@name, disk)
|
176
192
|
|
@@ -285,6 +301,7 @@ module VagrantPlugins
|
|
285
301
|
env[:ui].info(" -- Graphics Password: #{@graphics_passwd.empty? ? 'Not defined' : 'Defined'}")
|
286
302
|
env[:ui].info(" -- Video Type: #{@video_type}")
|
287
303
|
env[:ui].info(" -- Video VRAM: #{@video_vram}")
|
304
|
+
env[:ui].info(" -- Video 3D accel: #{@video_accel3d}")
|
288
305
|
env[:ui].info(" -- Sound Type: #{@sound_type}")
|
289
306
|
env[:ui].info(" -- Keymap: #{@keymap}")
|
290
307
|
env[:ui].info(" -- TPM Backend: #{@tpm_type}")
|
@@ -379,6 +396,13 @@ module VagrantPlugins
|
|
379
396
|
env[:ui].info(" -- smartcard device: mode=#{@smartcard_dev[:mode]}, type=#{@smartcard_dev[:type]}")
|
380
397
|
end
|
381
398
|
|
399
|
+
@serials.each_with_index do |serial, port|
|
400
|
+
if serial[:source]
|
401
|
+
env[:ui].info(" -- SERIAL(COM#{port}: redirect to #{serial[:source][:path]}")
|
402
|
+
env[:ui].warn(I18n.t('vagrant_libvirt.warnings.creating_domain_console_access_disabled'))
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
382
406
|
unless @qemu_args.empty?
|
383
407
|
env[:ui].info(' -- Command line args: ')
|
384
408
|
@qemu_args.each do |arg|
|
@@ -208,6 +208,9 @@ module VagrantPlugins
|
|
208
208
|
|
209
209
|
# Create a private network.
|
210
210
|
create_private_network(env)
|
211
|
+
write_created_network(env)
|
212
|
+
else
|
213
|
+
write_created_network(env) unless @options[:always_destroy] == false
|
211
214
|
end
|
212
215
|
end
|
213
216
|
|
@@ -247,6 +250,9 @@ module VagrantPlugins
|
|
247
250
|
|
248
251
|
# Create a private network.
|
249
252
|
create_private_network(env)
|
253
|
+
write_created_network(env)
|
254
|
+
else
|
255
|
+
write_created_network(env) unless @options[:always_destroy] == false
|
250
256
|
end
|
251
257
|
end
|
252
258
|
|
@@ -273,6 +279,9 @@ module VagrantPlugins
|
|
273
279
|
|
274
280
|
# Create a private network.
|
275
281
|
create_private_network(env)
|
282
|
+
write_created_network(env)
|
283
|
+
else
|
284
|
+
write_created_network(env) unless @options[:always_destroy] == false
|
276
285
|
end
|
277
286
|
end
|
278
287
|
|
@@ -347,7 +356,9 @@ module VagrantPlugins
|
|
347
356
|
rescue => e
|
348
357
|
raise Errors::CreateNetworkError, error_message: e.message
|
349
358
|
end
|
359
|
+
end
|
350
360
|
|
361
|
+
def write_created_network(env)
|
351
362
|
created_networks_file = env[:machine].data_dir + 'created_networks'
|
352
363
|
|
353
364
|
message = 'Saving information about created network ' \
|
@@ -59,7 +59,7 @@ module VagrantPlugins
|
|
59
59
|
command = "ip=$(which ip); ${ip:-/sbin/ip} addr show | grep -i 'inet ' | grep -v '127.0.0.1' | tr -s ' ' | cut -d' ' -f3 | cut -d'/' -f 1"
|
60
60
|
result = ''
|
61
61
|
machine.communicate.execute(command) do |type, data|
|
62
|
-
result
|
62
|
+
result += data if type == :stdout
|
63
63
|
end
|
64
64
|
|
65
65
|
ips = result.chomp.split("\n").uniq
|
@@ -222,6 +222,24 @@ module VagrantPlugins
|
|
222
222
|
graphics.attributes['passwd'] = config.graphics_passwd
|
223
223
|
end
|
224
224
|
end
|
225
|
+
graphics_gl = REXML::XPath.first(xml_descr, '/domain/devices/graphics/gl')
|
226
|
+
if graphics_gl.nil?
|
227
|
+
if config.graphics_gl
|
228
|
+
graphics_gl = REXML::Element.new('gl', REXML::XPath.first(xml_descr, '/domain/devices/graphics'))
|
229
|
+
graphics_gl.attributes['enable'] = 'yes'
|
230
|
+
descr_changed = true
|
231
|
+
end
|
232
|
+
else
|
233
|
+
if config.graphics_gl
|
234
|
+
if graphics_gl.attributes['enable'] != 'yes'
|
235
|
+
graphics_gl.attributes['enable'] = 'yes'
|
236
|
+
descr_changed = true
|
237
|
+
end
|
238
|
+
else
|
239
|
+
graphics_gl.parent.delete_element(graphics_gl)
|
240
|
+
descr_changed = true
|
241
|
+
end
|
242
|
+
end
|
225
243
|
else
|
226
244
|
# graphics_type = none, remove entire element
|
227
245
|
graphics.parent.delete_element(graphics) unless graphics.nil?
|
@@ -280,6 +298,24 @@ module VagrantPlugins
|
|
280
298
|
video_model.attributes['vram'] = config.video_vram
|
281
299
|
end
|
282
300
|
end
|
301
|
+
video_accel = REXML::XPath.first(xml_descr, '/domain/devices/video/model/acceleration')
|
302
|
+
if video_accel.nil?
|
303
|
+
if config.video_accel3d
|
304
|
+
video_accel = REXML::Element.new('acceleration', REXML::XPath.first(xml_descr, '/domain/devices/video/model'))
|
305
|
+
video_accel.attributes['accel3d'] = 'yes'
|
306
|
+
descr_changed = true
|
307
|
+
end
|
308
|
+
else
|
309
|
+
if config.video_accel3d
|
310
|
+
if video_accel.attributes['accel3d'] != 'yes'
|
311
|
+
video_accel.attributes['accel3d'] = 'yes'
|
312
|
+
descr_changed = true
|
313
|
+
end
|
314
|
+
else
|
315
|
+
video_accel.parent.delete_element(video_accel)
|
316
|
+
descr_changed = true
|
317
|
+
end
|
318
|
+
end
|
283
319
|
end
|
284
320
|
|
285
321
|
# Sound device
|
@@ -119,8 +119,10 @@ module VagrantPlugins
|
|
119
119
|
attr_accessor :graphics_port
|
120
120
|
attr_accessor :graphics_passwd
|
121
121
|
attr_accessor :graphics_ip
|
122
|
+
attr_accessor :graphics_gl
|
122
123
|
attr_accessor :video_type
|
123
124
|
attr_accessor :video_vram
|
125
|
+
attr_accessor :video_accel3d
|
124
126
|
attr_accessor :keymap
|
125
127
|
attr_accessor :kvm_hidden
|
126
128
|
attr_accessor :sound_type
|
@@ -196,6 +198,9 @@ module VagrantPlugins
|
|
196
198
|
# Use QEMU Agent to get ip address
|
197
199
|
attr_accessor :qemu_use_agent
|
198
200
|
|
201
|
+
# serial consoles
|
202
|
+
attr_accessor :serials
|
203
|
+
|
199
204
|
def initialize
|
200
205
|
@uri = UNSET_VALUE
|
201
206
|
@driver = UNSET_VALUE
|
@@ -267,8 +272,10 @@ module VagrantPlugins
|
|
267
272
|
@graphics_port = UNSET_VALUE
|
268
273
|
@graphics_ip = UNSET_VALUE
|
269
274
|
@graphics_passwd = UNSET_VALUE
|
275
|
+
@graphics_gl = UNSET_VALUE
|
270
276
|
@video_type = UNSET_VALUE
|
271
277
|
@video_vram = UNSET_VALUE
|
278
|
+
@video_accel3d = UNSET_VALUE
|
272
279
|
@sound_type = UNSET_VALUE
|
273
280
|
@keymap = UNSET_VALUE
|
274
281
|
@kvm_hidden = UNSET_VALUE
|
@@ -338,6 +345,8 @@ module VagrantPlugins
|
|
338
345
|
|
339
346
|
# Use Qemu agent to get ip address
|
340
347
|
@qemu_use_agent = UNSET_VALUE
|
348
|
+
|
349
|
+
@serials = []
|
341
350
|
end
|
342
351
|
|
343
352
|
def boot(device)
|
@@ -705,6 +714,20 @@ module VagrantPlugins
|
|
705
714
|
@qemu_env.merge!(options)
|
706
715
|
end
|
707
716
|
|
717
|
+
def serial(options={})
|
718
|
+
options = {
|
719
|
+
:type => "pty",
|
720
|
+
:source => nil,
|
721
|
+
}.merge(options)
|
722
|
+
|
723
|
+
serial = {
|
724
|
+
:type => options[:type],
|
725
|
+
:source => options[:source],
|
726
|
+
}
|
727
|
+
|
728
|
+
@serials << serial
|
729
|
+
end
|
730
|
+
|
708
731
|
def _default_uri
|
709
732
|
# Determine if any settings except driver provided explicitly, if not
|
710
733
|
# and the LIBVIRT_DEFAULT_URI var is set, use that.
|
@@ -817,7 +840,6 @@ module VagrantPlugins
|
|
817
840
|
@management_network_pci_slot = nil if @management_network_pci_slot == UNSET_VALUE
|
818
841
|
@management_network_domain = nil if @management_network_domain == UNSET_VALUE
|
819
842
|
@management_network_mtu = nil if @management_network_mtu == UNSET_VALUE
|
820
|
-
@system_uri = 'qemu:///system' if @system_uri == UNSET_VALUE
|
821
843
|
|
822
844
|
# Domain specific settings.
|
823
845
|
@title = '' if @title == UNSET_VALUE
|
@@ -871,6 +893,8 @@ module VagrantPlugins
|
|
871
893
|
@graphics_ip = '127.0.0.1' if @graphics_ip == UNSET_VALUE
|
872
894
|
@video_type = 'cirrus' if @video_type == UNSET_VALUE
|
873
895
|
@video_vram = 9216 if @video_vram == UNSET_VALUE
|
896
|
+
@video_accel3d = false if @video_accel3d == UNSET_VALUE
|
897
|
+
@graphics_gl = @video_accel3d if @graphics_gl == UNSET_VALUE
|
874
898
|
@sound_type = nil if @sound_type == UNSET_VALUE
|
875
899
|
@keymap = 'en-us' if @keymap == UNSET_VALUE
|
876
900
|
@kvm_hidden = false if @kvm_hidden == UNSET_VALUE
|
@@ -945,7 +969,9 @@ module VagrantPlugins
|
|
945
969
|
# Additional QEMU commandline environment variables
|
946
970
|
@qemu_env = {} if @qemu_env == UNSET_VALUE
|
947
971
|
|
948
|
-
@qemu_use_agent =
|
972
|
+
@qemu_use_agent = false if @qemu_use_agent == UNSET_VALUE
|
973
|
+
|
974
|
+
@serials = [{:type => 'pty', :source => nil}] if @serials == []
|
949
975
|
end
|
950
976
|
|
951
977
|
def validate(machine)
|
@@ -959,6 +985,9 @@ module VagrantPlugins
|
|
959
985
|
end
|
960
986
|
end
|
961
987
|
|
988
|
+
unless @qemu_use_agent == true || @qemu_use_agent == false
|
989
|
+
errors << "libvirt.qemu_use_agent must be a boolean."
|
990
|
+
end
|
962
991
|
|
963
992
|
if @qemu_use_agent == true
|
964
993
|
# if qemu agent is used to optain domain ip configuration, at least
|
@@ -976,6 +1005,12 @@ module VagrantPlugins
|
|
976
1005
|
end
|
977
1006
|
end
|
978
1007
|
|
1008
|
+
machine.provider_config.serials.each do |serial|
|
1009
|
+
if serial[:source] and serial[:source][:path].nil?
|
1010
|
+
errors << "serial :source requires :path to be defined"
|
1011
|
+
end
|
1012
|
+
end
|
1013
|
+
|
979
1014
|
machine.config.vm.networks.each do |_type, opts|
|
980
1015
|
if opts[:mac]
|
981
1016
|
if opts[:mac] =~ /\A([0-9a-fA-F]{12})\z/
|
@@ -1017,6 +1052,10 @@ module VagrantPlugins
|
|
1017
1052
|
c = qemu_env != UNSET_VALUE ? qemu_env.dup : {}
|
1018
1053
|
c.merge!(other.qemu_env) if other.qemu_env != UNSET_VALUE
|
1019
1054
|
result.qemu_env = c
|
1055
|
+
|
1056
|
+
s = serials.dup
|
1057
|
+
s += other.serials
|
1058
|
+
result.serials = s
|
1020
1059
|
end
|
1021
1060
|
end
|
1022
1061
|
|
@@ -1026,6 +1065,10 @@ module VagrantPlugins
|
|
1026
1065
|
# Parse uri to extract individual components
|
1027
1066
|
uri = _parse_uri(@uri)
|
1028
1067
|
|
1068
|
+
system_uri = uri.dup
|
1069
|
+
system_uri.path = '/system'
|
1070
|
+
@system_uri = system_uri.to_s if @system_uri == UNSET_VALUE
|
1071
|
+
|
1029
1072
|
# only set @connect_via_ssh if not explicitly to avoid overriding
|
1030
1073
|
# and allow an error to occur if the @uri and @connect_via_ssh disagree
|
1031
1074
|
@connect_via_ssh = uri.scheme.include? "ssh" if @connect_via_ssh == UNSET_VALUE
|
@@ -61,7 +61,7 @@ module VagrantPlugins
|
|
61
61
|
|
62
62
|
config = @machine.provider_config
|
63
63
|
|
64
|
-
@system_connection = Libvirt::
|
64
|
+
@system_connection = Libvirt::open_read_only(config.system_uri)
|
65
65
|
@system_connection
|
66
66
|
end
|
67
67
|
|
@@ -98,16 +98,16 @@ module VagrantPlugins
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def get_domain_ipaddress(machine, domain)
|
101
|
-
if @machine.provider_config.qemu_use_session
|
102
|
-
return get_ipaddress_from_system domain.mac
|
103
|
-
end
|
104
|
-
|
105
101
|
# attempt to get ip address from qemu agent
|
106
102
|
if @machine.provider_config.qemu_use_agent == true
|
107
103
|
@logger.info('Get IP via qemu agent')
|
108
104
|
return get_ipaddress_from_qemu_agent(domain, machine.id)
|
109
105
|
end
|
110
106
|
|
107
|
+
if @machine.provider_config.qemu_use_session
|
108
|
+
return get_ipaddress_from_system domain.mac
|
109
|
+
end
|
110
|
+
|
111
111
|
# Get IP address from dhcp leases table
|
112
112
|
begin
|
113
113
|
ip_address = get_ipaddress_from_domain(domain)
|
@@ -168,9 +168,9 @@ module VagrantPlugins
|
|
168
168
|
def get_ipaddress_from_qemu_agent(domain, machine_id)
|
169
169
|
ip_address = nil
|
170
170
|
addresses = nil
|
171
|
-
|
171
|
+
libvirt_domain = connection.client.lookup_domain_by_uuid(machine_id)
|
172
172
|
begin
|
173
|
-
response =
|
173
|
+
response = libvirt_domain.qemu_agent_command('{"execute":"guest-network-get-interfaces"}', timeout=10)
|
174
174
|
@logger.debug("Got Response from qemu agent")
|
175
175
|
@logger.debug(response)
|
176
176
|
addresses = JSON.parse(response)
|
@@ -180,7 +180,7 @@ module VagrantPlugins
|
|
180
180
|
|
181
181
|
unless addresses.nil?
|
182
182
|
addresses["return"].each{ |interface|
|
183
|
-
if domain.mac == interface["hardware-address"]
|
183
|
+
if domain.mac.downcase == interface["hardware-address"].downcase
|
184
184
|
@logger.debug("Found mathing interface: [%s]" % interface["name"])
|
185
185
|
if interface.has_key?("ip-addresses")
|
186
186
|
interface["ip-addresses"].each{ |ip|
|
@@ -181,6 +181,10 @@ module VagrantPlugins
|
|
181
181
|
class DeleteSnapshotError < VagrantLibvirtError
|
182
182
|
error_key(:delete_snapshot_error)
|
183
183
|
end
|
184
|
+
|
185
|
+
class SerialCannotCreatePathError < VagrantLibvirtError
|
186
|
+
error_key(:serial_cannot_create_path_error)
|
187
|
+
end
|
184
188
|
end
|
185
189
|
end
|
186
190
|
end
|
@@ -162,10 +162,19 @@
|
|
162
162
|
</disk>
|
163
163
|
<% end %>
|
164
164
|
|
165
|
-
|
166
|
-
|
165
|
+
<% @serials.each_with_index do |serial, port| %>
|
166
|
+
<serial type='<%= serial[:type] %>'>
|
167
|
+
<% unless serial[:source].nil? %>
|
168
|
+
<source path='<%= serial[:source][:path] %>'/>
|
169
|
+
<% end %>
|
170
|
+
<target port='<%= port %>'/>
|
167
171
|
</serial>
|
168
|
-
|
172
|
+
<% end %>
|
173
|
+
<% console_log = @serials.first %>
|
174
|
+
<console type='<%= console_log[:type] %>'>
|
175
|
+
<% unless console_log[:source].nil? %>
|
176
|
+
<source path='<%= console_log[:source][:path] %>'/>
|
177
|
+
<% end %>
|
169
178
|
<target port='0'/>
|
170
179
|
</console>
|
171
180
|
|
@@ -207,9 +216,13 @@
|
|
207
216
|
<% end %>
|
208
217
|
<% if @graphics_type != 'none' %>
|
209
218
|
<%# Video device -%>
|
210
|
-
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd%>
|
219
|
+
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd %> <% if not @graphics_gl %>/><% else %>>
|
220
|
+
<gl enable='yes' />
|
221
|
+
</graphics><% end %>
|
211
222
|
<video>
|
212
|
-
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'
|
223
|
+
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'<% if not @video_accel3d %>/><% else %>>
|
224
|
+
<acceleration accel3d='yes'/>
|
225
|
+
</model><% end %>
|
213
226
|
</video>
|
214
227
|
<%#End Video -%>
|
215
228
|
<% end %>
|
@@ -119,7 +119,8 @@ module VagrantPlugins
|
|
119
119
|
IPAddr.new(options[:network_address]).get_mask :
|
120
120
|
'255.255.255.0',
|
121
121
|
dhcp_enabled: true,
|
122
|
-
forward_mode: 'nat'
|
122
|
+
forward_mode: 'nat',
|
123
|
+
always_destroy: true
|
123
124
|
}.merge(options)
|
124
125
|
|
125
126
|
if options[:type].to_s == 'dhcp' && options[:ip].nil?
|
data/lib/vagrant-libvirt/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.0
|
data/locales/en.yml
CHANGED
@@ -64,6 +64,8 @@ en:
|
|
64
64
|
the minimum box image size of '%{minimum}'.
|
65
65
|
forwarding_udp: |-
|
66
66
|
Forwarding UDP ports is not supported. Ignoring.
|
67
|
+
creating_domain_console_access_disabled: |-
|
68
|
+
Serial console is being redirected, access via virsh will be disabled.
|
67
69
|
|
68
70
|
errors:
|
69
71
|
call_chain_error: Invalid action chain, must ensure that '%{require_action}' is called prior to calling '%{current_action}'
|
@@ -166,6 +168,8 @@ en:
|
|
166
168
|
management_network_required: |-
|
167
169
|
Management network can't be disabled when VM use box.
|
168
170
|
Please fix your configuration and run vagrant again.
|
171
|
+
serial_cannot_create_path_error: |-
|
172
|
+
Error creating path for serial port output log: %{path}
|
169
173
|
|
170
174
|
states:
|
171
175
|
paused: |-
|
data/spec/spec_helper.rb
CHANGED
@@ -42,4 +42,12 @@ RSpec.configure do |config|
|
|
42
42
|
config.before(:suite) do
|
43
43
|
ENV.delete('LIBVIRT_DEFAULT_URI')
|
44
44
|
end
|
45
|
+
|
46
|
+
config.mock_with :rspec do |mocks|
|
47
|
+
# This option should be set when all dependencies are being loaded
|
48
|
+
# before a spec run, as is the case in a typical spec helper. It will
|
49
|
+
# cause any verifying double instantiation for a class that does not
|
50
|
+
# exist to raise, protecting against incorrectly spelt names.
|
51
|
+
mocks.verify_doubled_constant_names = true
|
52
|
+
end
|
45
53
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'fog/libvirt'
|
4
|
+
require 'fog/libvirt/models/compute/server'
|
5
|
+
require 'libvirt'
|
4
6
|
|
5
7
|
shared_context 'libvirt' do
|
6
8
|
include_context 'unit'
|
@@ -8,7 +10,9 @@ shared_context 'libvirt' do
|
|
8
10
|
let(:libvirt_context) { true }
|
9
11
|
let(:id) { 'dummy-vagrant_dummy' }
|
10
12
|
let(:connection) { double('connection') }
|
11
|
-
let(:domain) {
|
13
|
+
let(:domain) { instance_double('::Fog::Libvirt::Compute::Server') }
|
14
|
+
let(:libvirt_client) { instance_double('::Libvirt::Connect') }
|
15
|
+
let(:libvirt_domain) { instance_double('::Libvirt::Domain') }
|
12
16
|
let(:logger) { double('logger') }
|
13
17
|
|
14
18
|
def connection_result(options = {})
|
@@ -22,11 +26,10 @@ shared_context 'libvirt' do
|
|
22
26
|
stub_const('::Fog::Compute', connection)
|
23
27
|
|
24
28
|
# drivers also call vm_exists? during init;
|
25
|
-
allow(connection).to receive(:servers)
|
29
|
+
allow(connection).to receive(:servers)
|
26
30
|
.and_return(connection_result(result: nil))
|
27
31
|
|
28
|
-
|
29
|
-
allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
|
32
|
+
allow(connection).to receive(:client).and_return(libvirt_client)
|
30
33
|
|
31
34
|
allow(machine).to receive(:id).and_return(id)
|
32
35
|
allow(Log4r::Logger).to receive(:new).and_return(logger)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'support/sharedcontext'
|
5
|
+
|
6
|
+
require 'vagrant-libvirt/action/prepare_nfs_settings'
|
7
|
+
|
8
|
+
|
9
|
+
describe VagrantPlugins::ProviderLibvirt::Action::PrepareNFSSettings do
|
10
|
+
subject { described_class.new(app, env) }
|
11
|
+
|
12
|
+
include_context 'unit'
|
13
|
+
|
14
|
+
describe '#call' do
|
15
|
+
before do
|
16
|
+
# avoid requiring nfsd installed to run tests
|
17
|
+
allow(machine.env.host).to receive(:capability?).with(:nfs_installed).and_return(true)
|
18
|
+
allow(machine.env.host).to receive(:capability).with(:nfs_installed).and_return(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when enabled' do
|
22
|
+
let(:vagrantfile) do
|
23
|
+
<<-EOF
|
24
|
+
Vagrant.configure('2') do |config|
|
25
|
+
config.vm.box = "vagrant-libvirt/test"
|
26
|
+
config.vm.define :test
|
27
|
+
config.vm.synced_folder ".", "/vagrant", type: "nfs"
|
28
|
+
config.vm.provider :libvirt do |libvirt|
|
29
|
+
#{vagrantfile_providerconfig}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
EOF
|
33
|
+
end
|
34
|
+
let(:socket) { double('socket') }
|
35
|
+
|
36
|
+
before do
|
37
|
+
allow(::TCPSocket).to receive(:new).and_return(socket)
|
38
|
+
allow(socket).to receive(:close)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should retrieve the guest IP address' do
|
42
|
+
times_called = 0
|
43
|
+
expect(::TCPSocket).to receive(:new) do
|
44
|
+
# force reaching later code
|
45
|
+
times_called += 1
|
46
|
+
times_called < 2 ? raise("StandardError") : socket
|
47
|
+
end
|
48
|
+
expect(machine).to receive(:ssh_info).and_return({:host => '192.168.1.2'})
|
49
|
+
expect(communicator).to receive(:execute).and_yield(:stdout, "192.168.1.2\n192.168.2.2")
|
50
|
+
|
51
|
+
expect(subject.call(env)).to be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -22,6 +22,8 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
|
22
22
|
.and_return(driver)
|
23
23
|
allow(driver).to receive(:get_domain).and_return(domain)
|
24
24
|
allow(driver).to receive(:state).and_return(:running)
|
25
|
+
# return some information for domain when needed
|
26
|
+
allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
|
25
27
|
end
|
26
28
|
|
27
29
|
context 'when machine does not exist' do
|
@@ -62,7 +64,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::WaitTillUp do
|
|
62
64
|
expect(app).to_not receive(:call)
|
63
65
|
expect(ui).to receive(:info).with('Waiting for domain to get an IP address...')
|
64
66
|
expect(ui).to_not receive(:info).with('Waiting for SSH to become available...')
|
65
|
-
expect(env[:machine].communicate).to_not receive(:ready?)
|
66
67
|
expect {subject.call(env) }.to raise_error(::Fog::Errors::TimeoutError)
|
67
68
|
end
|
68
69
|
end
|
data/spec/unit/config_spec.rb
CHANGED
@@ -338,6 +338,54 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
|
338
338
|
end
|
339
339
|
end
|
340
340
|
|
341
|
+
context '@system_uri' do
|
342
|
+
[
|
343
|
+
# system uri
|
344
|
+
[ # transport and hostname
|
345
|
+
{:uri => "qemu+ssh://localhost/session"},
|
346
|
+
{:uri => "qemu+ssh://localhost/session", :system_uri => "qemu+ssh://localhost/system"},
|
347
|
+
],
|
348
|
+
[ # explicitly set
|
349
|
+
{:qemu_use_session => true, :system_uri => "custom://remote/system"},
|
350
|
+
{:uri => "qemu:///session", :system_uri => "custom://remote/system"},
|
351
|
+
],
|
352
|
+
].each do |inputs, outputs, options|
|
353
|
+
opts = {}
|
354
|
+
opts.merge!(options) if options
|
355
|
+
|
356
|
+
it "should handle inputs #{inputs} with env (#{opts[:env]})" do
|
357
|
+
# allow some of these to fail for now if marked as such
|
358
|
+
if !opts[:allow_failure].nil?
|
359
|
+
pending(opts[:allow_failure])
|
360
|
+
end
|
361
|
+
|
362
|
+
if !opts[:setup].nil?
|
363
|
+
opts[:setup].apply_binding(binding)
|
364
|
+
end
|
365
|
+
|
366
|
+
inputs.each do |k, v|
|
367
|
+
subject.instance_variable_set("@#{k}", v)
|
368
|
+
end
|
369
|
+
|
370
|
+
if !opts[:env].nil?
|
371
|
+
opts[:env].each do |k, v|
|
372
|
+
fake_env[k] = v
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
subject.finalize!
|
377
|
+
|
378
|
+
# ensure failed output indicates which settings are incorrect in the failed test
|
379
|
+
got = subject.instance_variables.each_with_object({}) do |name, hash|
|
380
|
+
if outputs.key?(name.to_s[1..-1].to_sym)
|
381
|
+
hash["#{name.to_s[1..-1]}".to_sym] =subject.instance_variable_get(name)
|
382
|
+
end
|
383
|
+
end
|
384
|
+
expect(got).to eq(outputs)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
341
389
|
context '@proxy_command' do
|
342
390
|
before(:example) do
|
343
391
|
stub_const("ENV", fake_env)
|
data/spec/unit/driver_spec.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fog/libvirt/requests/compute/dhcp_leases'
|
4
|
+
|
3
5
|
require 'spec_helper'
|
4
6
|
require 'support/binding_proc'
|
5
7
|
require 'support/sharedcontext'
|
@@ -8,6 +10,7 @@ require 'vagrant-libvirt/driver'
|
|
8
10
|
|
9
11
|
describe VagrantPlugins::ProviderLibvirt::Driver do
|
10
12
|
include_context 'unit'
|
13
|
+
include_context 'libvirt'
|
11
14
|
|
12
15
|
subject { described_class.new(machine) }
|
13
16
|
|
@@ -27,6 +30,7 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
27
30
|
end
|
28
31
|
EOF
|
29
32
|
end
|
33
|
+
|
30
34
|
# need to override the default package iso_env as using a different
|
31
35
|
# name for the test machines above.
|
32
36
|
let(:machine) { iso_env.machine(:test1, :libvirt) }
|
@@ -36,6 +40,14 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
36
40
|
let(:system_connection1) { double("system connection 1") }
|
37
41
|
let(:system_connection2) { double("system connection 2") }
|
38
42
|
|
43
|
+
# make it easier for distros that want to switch the default value for
|
44
|
+
# qemu_use_session to true by ensuring it is explicitly false for tests.
|
45
|
+
before do
|
46
|
+
allow(machine.provider_config).to receive(:qemu_use_session).and_return(false)
|
47
|
+
allow(logger).to receive(:info)
|
48
|
+
allow(logger).to receive(:debug)
|
49
|
+
end
|
50
|
+
|
39
51
|
describe '#connection' do
|
40
52
|
it 'should configure a separate connection per machine' do
|
41
53
|
expect(Fog::Compute).to receive(:new).with(
|
@@ -68,15 +80,15 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
68
80
|
# system_uri should be 'qemu+ssh://user@remote1/system'
|
69
81
|
# and not 'qemu:///system'.
|
70
82
|
it 'should configure a separate connection per machine' do
|
71
|
-
expect(Libvirt).to receive(:
|
72
|
-
expect(Libvirt).to receive(:
|
83
|
+
expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://user@remote1/system').and_return(system_connection1)
|
84
|
+
expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://vms@remote2/system').and_return(system_connection2)
|
73
85
|
|
74
86
|
expect(machine.provider.driver.system_connection).to eq(system_connection1)
|
75
87
|
expect(machine2.provider.driver.system_connection).to eq(system_connection2)
|
76
88
|
end
|
77
89
|
|
78
90
|
it 'should configure the connection once' do
|
79
|
-
expect(Libvirt).to receive(:
|
91
|
+
expect(Libvirt).to receive(:open_read_only).with('qemu+ssh://user@remote1/system').and_return(system_connection1)
|
80
92
|
|
81
93
|
expect(machine.provider.driver.system_connection).to eq(system_connection1)
|
82
94
|
expect(machine.provider.driver.system_connection).to eq(system_connection1)
|
@@ -84,6 +96,129 @@ describe VagrantPlugins::ProviderLibvirt::Driver do
|
|
84
96
|
end
|
85
97
|
end
|
86
98
|
|
99
|
+
describe '#get_ipaddress' do
|
100
|
+
context 'when domain exists' do
|
101
|
+
# not used yet, but this is the form that is returned from addresses
|
102
|
+
let(:addresses) { {
|
103
|
+
:public => ["192.168.122.111"],
|
104
|
+
:private => ["192.168.122.111"],
|
105
|
+
} }
|
106
|
+
|
107
|
+
before do
|
108
|
+
allow(subject).to receive(:get_domain).and_return(domain)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should retrieve the address via domain fog-libvirt API' do
|
112
|
+
# ideally should be able to yield a block to wait_for and check that
|
113
|
+
# the 'addresses' function on the domain is called correctly.
|
114
|
+
expect(domain).to receive(:wait_for).and_return(nil)
|
115
|
+
expect(subject.get_ipaddress(machine)).to eq(nil)
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when qemu_use_agent is enabled' do
|
119
|
+
let(:qemu_agent_interfaces) {
|
120
|
+
<<-EOF
|
121
|
+
{
|
122
|
+
"return": [
|
123
|
+
{
|
124
|
+
"name": "lo",
|
125
|
+
"ip-addresses": [
|
126
|
+
{
|
127
|
+
"ip-address-type": "ipv4",
|
128
|
+
"ip-address": "127.0.0.1",
|
129
|
+
"prefix": 8
|
130
|
+
}
|
131
|
+
],
|
132
|
+
"hardware-address": "00:00:00:00:00:00"
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"name": "eth0",
|
136
|
+
"ip-addresses": [
|
137
|
+
{
|
138
|
+
"ip-address-type": "ipv4",
|
139
|
+
"ip-address": "192.168.122.42",
|
140
|
+
"prefix": 24
|
141
|
+
}
|
142
|
+
],
|
143
|
+
"hardware-address": "52:54:00:f8:67:98"
|
144
|
+
}
|
145
|
+
]
|
146
|
+
}
|
147
|
+
EOF
|
148
|
+
}
|
149
|
+
|
150
|
+
before do
|
151
|
+
allow(machine.provider_config).to receive(:qemu_use_agent).and_return(true)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should retrieve the address via the agent' do
|
155
|
+
expect(subject).to receive(:connection).and_return(connection)
|
156
|
+
expect(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
|
157
|
+
expect(libvirt_domain).to receive(:qemu_agent_command).and_return(qemu_agent_interfaces)
|
158
|
+
expect(domain).to receive(:mac).and_return("52:54:00:f8:67:98").exactly(2).times
|
159
|
+
|
160
|
+
expect(subject.get_ipaddress(machine)).to eq("192.168.122.42")
|
161
|
+
end
|
162
|
+
|
163
|
+
context 'when qemu_use_session is enabled' do
|
164
|
+
before do
|
165
|
+
allow(machine.provider_config).to receive(:qemu_use_session).and_return(true)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should still retrieve the address via the agent' do
|
169
|
+
expect(subject).to receive(:connection).and_return(connection)
|
170
|
+
expect(libvirt_client).to receive(:lookup_domain_by_uuid).and_return(libvirt_domain)
|
171
|
+
expect(libvirt_domain).to receive(:qemu_agent_command).and_return(qemu_agent_interfaces)
|
172
|
+
expect(domain).to receive(:mac).and_return("52:54:00:f8:67:98").exactly(2).times
|
173
|
+
|
174
|
+
expect(subject.get_ipaddress(machine)).to eq("192.168.122.42")
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context 'when qemu_use_session is enabled' do
|
180
|
+
let(:networks) { [instance_double('::Fog::Libvirt::Compute::Real')] }
|
181
|
+
let(:dhcp_leases) {
|
182
|
+
{
|
183
|
+
"iface" =>"virbr0",
|
184
|
+
"expirytime" =>1636287162,
|
185
|
+
"type" =>0,
|
186
|
+
"mac" =>"52:54:00:8b:dc:5f",
|
187
|
+
"ipaddr" =>"192.168.122.43",
|
188
|
+
"prefix" =>24,
|
189
|
+
"hostname" =>"vagrant-default_test",
|
190
|
+
"clientid" =>"ff:00:8b:dc:5f:00:01:00:01:29:1a:65:42:52:54:00:8b:dc:5f",
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
before do
|
195
|
+
allow(machine.provider_config).to receive(:qemu_use_session).and_return(true)
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should retreive the address via the system dhcp-leases API' do
|
199
|
+
expect(domain).to receive(:mac).and_return("52:54:00:8b:dc:5f")
|
200
|
+
expect(subject).to receive(:system_connection).and_return(system_connection1)
|
201
|
+
expect(system_connection1).to receive(:list_all_networks).and_return(networks)
|
202
|
+
expect(networks[0]).to receive(:dhcp_leases).and_return([dhcp_leases])
|
203
|
+
|
204
|
+
expect(subject.get_ipaddress(machine)).to eq("192.168.122.43")
|
205
|
+
end
|
206
|
+
|
207
|
+
context 'when qemu_use_agent is enabled' do
|
208
|
+
before do
|
209
|
+
allow(machine.provider_config).to receive(:qemu_use_agent).and_return(true)
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'should retrieve the address via the agent' do
|
213
|
+
expect(subject).to receive(:get_ipaddress_from_qemu_agent).and_return("192.168.122.44")
|
214
|
+
|
215
|
+
expect(subject.get_ipaddress(machine)).to eq("192.168.122.44")
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
87
222
|
describe '#state' do
|
88
223
|
let(:domain) { double('domain') }
|
89
224
|
|
@@ -81,10 +81,12 @@
|
|
81
81
|
<readonly/>
|
82
82
|
</disk>
|
83
83
|
|
84
|
-
<serial type='
|
84
|
+
<serial type='file'>
|
85
|
+
<source path='/var/log/vm_consoles/machine.log'/>
|
85
86
|
<target port='0'/>
|
86
87
|
</serial>
|
87
|
-
<console type='
|
88
|
+
<console type='file'>
|
89
|
+
<source path='/var/log/vm_consoles/machine.log'/>
|
88
90
|
<target port='0'/>
|
89
91
|
</console>
|
90
92
|
|
@@ -110,9 +112,13 @@
|
|
110
112
|
|
111
113
|
<input type='mouse' bus='ps2'/>
|
112
114
|
|
113
|
-
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'
|
115
|
+
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us' >
|
116
|
+
<gl enable='yes' />
|
117
|
+
</graphics>
|
114
118
|
<video>
|
115
|
-
<model type='cirrus' vram='9216' heads='1'
|
119
|
+
<model type='cirrus' vram='9216' heads='1'>
|
120
|
+
<acceleration accel3d='yes'/>
|
121
|
+
</model>
|
116
122
|
</video>
|
117
123
|
<rng model='virtio'>
|
118
124
|
<backend model='random'>/dev/random</backend>
|
@@ -89,6 +89,7 @@ describe 'templates/domain' do
|
|
89
89
|
target_port: '4242',
|
90
90
|
source_path: '/tmp/foo')
|
91
91
|
domain.random(model: 'random')
|
92
|
+
domain.serial(:type => 'file', :source => {:path => '/var/log/vm_consoles/machine.log'})
|
92
93
|
domain.pci(bus: '0x06', slot: '0x12', function: '0x5')
|
93
94
|
domain.pci(domain: '0x0001', bus: '0x03', slot: '0x00', function: '0x0')
|
94
95
|
domain.usb_controller(model: 'nec-xhci', ports: '4')
|
@@ -111,6 +112,8 @@ describe 'templates/domain' do
|
|
111
112
|
domain.shares = '1024'
|
112
113
|
domain.cpuset = '1-4,^3,6'
|
113
114
|
domain.nodeset = '1-4,^3,6'
|
115
|
+
|
116
|
+
domain.video_accel3d = true
|
114
117
|
end
|
115
118
|
let(:test_file) { 'domain_all_settings.xml' }
|
116
119
|
it 'renders template' do
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Stanek
|
8
8
|
- Dima Vasilets
|
9
9
|
- Brian Pitts
|
10
10
|
- Darragh Bailey
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-
|
14
|
+
date: 2021-11-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec-core
|
@@ -252,6 +252,7 @@ files:
|
|
252
252
|
- spec/unit/action/halt_domain_spec.rb
|
253
253
|
- spec/unit/action/handle_box_image_spec.rb
|
254
254
|
- spec/unit/action/package_domain_spec.rb
|
255
|
+
- spec/unit/action/prepare_nfs_settings_spec.rb
|
255
256
|
- spec/unit/action/set_name_of_domain_spec.rb
|
256
257
|
- spec/unit/action/shutdown_domain_spec.rb
|
257
258
|
- spec/unit/action/start_domain_spec.rb
|
@@ -264,7 +265,6 @@ files:
|
|
264
265
|
- spec/unit/action_spec.rb
|
265
266
|
- spec/unit/config_spec.rb
|
266
267
|
- spec/unit/driver_spec.rb
|
267
|
-
- spec/unit/provider_spec.rb
|
268
268
|
- spec/unit/templates/domain_all_settings.xml
|
269
269
|
- spec/unit/templates/domain_custom_cpu_model.xml
|
270
270
|
- spec/unit/templates/domain_defaults.xml
|
@@ -275,8 +275,9 @@ files:
|
|
275
275
|
homepage: https://github.com/vagrant-libvirt/vagrant-libvirt
|
276
276
|
licenses:
|
277
277
|
- MIT
|
278
|
-
metadata:
|
279
|
-
|
278
|
+
metadata:
|
279
|
+
source_code_uri: https://github.com/vagrant-libvirt/vagrant-libvirt
|
280
|
+
post_install_message:
|
280
281
|
rdoc_options: []
|
281
282
|
require_paths:
|
282
283
|
- lib
|
@@ -291,51 +292,51 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
292
|
- !ruby/object:Gem::Version
|
292
293
|
version: '0'
|
293
294
|
requirements: []
|
294
|
-
rubygems_version: 3.0.
|
295
|
-
signing_key:
|
295
|
+
rubygems_version: 3.0.8
|
296
|
+
signing_key:
|
296
297
|
specification_version: 4
|
297
298
|
summary: libvirt provider for Vagrant.
|
298
299
|
test_files:
|
299
|
-
- spec/support/matchers/have_file_content.rb
|
300
|
-
- spec/support/binding_proc.rb
|
301
|
-
- spec/support/environment_helper.rb
|
302
|
-
- spec/support/libvirt_context.rb
|
303
300
|
- spec/support/temporary_dir.rb
|
301
|
+
- spec/support/libvirt_context.rb
|
302
|
+
- spec/support/binding_proc.rb
|
304
303
|
- spec/support/sharedcontext.rb
|
305
|
-
- spec/
|
306
|
-
- spec/
|
304
|
+
- spec/support/matchers/have_file_content.rb
|
305
|
+
- spec/support/environment_helper.rb
|
306
|
+
- spec/unit/action_spec.rb
|
307
|
+
- spec/unit/templates/domain_all_settings.xml
|
308
|
+
- spec/unit/templates/domain_custom_cpu_model.xml
|
309
|
+
- spec/unit/templates/domain_defaults.xml
|
310
|
+
- spec/unit/templates/domain_spec.rb
|
311
|
+
- spec/unit/templates/tpm/version_1.2.xml
|
312
|
+
- spec/unit/templates/tpm/version_2.0.xml
|
307
313
|
- spec/unit/action/create_domain_spec/additional_disks_domain.xml
|
308
314
|
- spec/unit/action/create_domain_spec/default_domain.xml
|
309
|
-
- spec/unit/action/
|
310
|
-
- spec/unit/action/
|
315
|
+
- spec/unit/action/create_domain_spec/default_system_storage_pool.xml
|
316
|
+
- spec/unit/action/create_domain_spec/default_user_storage_pool.xml
|
317
|
+
- spec/unit/action/create_domain_spec.rb
|
318
|
+
- spec/unit/action/wait_till_up_spec.rb
|
319
|
+
- spec/unit/action/package_domain_spec.rb
|
320
|
+
- spec/unit/action/forward_ports_spec.rb
|
321
|
+
- spec/unit/action/destroy_domain_spec.rb
|
322
|
+
- spec/unit/action/halt_domain_spec.rb
|
323
|
+
- spec/unit/action/start_domain_spec.rb
|
324
|
+
- spec/unit/action/shutdown_domain_spec.rb
|
325
|
+
- spec/unit/action/clean_machine_folder_spec.rb
|
326
|
+
- spec/unit/action/create_domain_volume_spec.rb
|
327
|
+
- spec/unit/action/set_name_of_domain_spec.rb
|
328
|
+
- spec/unit/action/prepare_nfs_settings_spec.rb
|
311
329
|
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_1.xml
|
330
|
+
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_0.xml
|
312
331
|
- spec/unit/action/create_domain_volume_spec/three_disks_in_storage_disk_2.xml
|
332
|
+
- spec/unit/action/create_domain_volume_spec/one_disk_in_storage.xml
|
333
|
+
- spec/unit/action/start_domain_spec/default_added_tpm_path.xml
|
313
334
|
- spec/unit/action/start_domain_spec/clock_timer_rtc.xml
|
314
335
|
- spec/unit/action/start_domain_spec/default.xml
|
315
|
-
- spec/unit/action/start_domain_spec/default_added_tpm_path.xml
|
316
|
-
- spec/unit/action/start_domain_spec/default_added_tpm_version.xml
|
317
336
|
- spec/unit/action/start_domain_spec/existing.xml
|
318
|
-
- spec/unit/action/
|
319
|
-
- spec/unit/action/forward_ports_spec.rb
|
320
|
-
- spec/unit/action/set_name_of_domain_spec.rb
|
321
|
-
- spec/unit/action/wait_till_up_spec.rb
|
322
|
-
- spec/unit/action/create_domain_volume_spec.rb
|
323
|
-
- spec/unit/action/start_domain_spec.rb
|
324
|
-
- spec/unit/action/destroy_domain_spec.rb
|
325
|
-
- spec/unit/action/halt_domain_spec.rb
|
326
|
-
- spec/unit/action/create_domain_spec.rb
|
327
|
-
- spec/unit/action/package_domain_spec.rb
|
328
|
-
- spec/unit/action/shutdown_domain_spec.rb
|
337
|
+
- spec/unit/action/start_domain_spec/default_added_tpm_version.xml
|
329
338
|
- spec/unit/action/handle_box_image_spec.rb
|
330
|
-
- spec/unit/templates/tpm/version_1.2.xml
|
331
|
-
- spec/unit/templates/tpm/version_2.0.xml
|
332
|
-
- spec/unit/templates/domain_custom_cpu_model.xml
|
333
|
-
- spec/unit/templates/domain_defaults.xml
|
334
|
-
- spec/unit/templates/domain_spec.rb
|
335
|
-
- spec/unit/templates/domain_all_settings.xml
|
336
|
-
- spec/unit/util/byte_number_spec.rb
|
337
|
-
- spec/unit/provider_spec.rb
|
338
339
|
- spec/unit/config_spec.rb
|
340
|
+
- spec/unit/util/byte_number_spec.rb
|
339
341
|
- spec/unit/driver_spec.rb
|
340
|
-
- spec/unit/action_spec.rb
|
341
342
|
- spec/spec_helper.rb
|
data/spec/unit/provider_spec.rb
DELETED