vagrant-libvirt 0.0.37 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -0
- data/lib/vagrant-libvirt.rb +1 -1
- data/lib/vagrant-libvirt/action.rb +8 -2
- data/lib/vagrant-libvirt/action/create_domain.rb +21 -0
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +30 -1
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +84 -17
- data/lib/vagrant-libvirt/action/destroy_domain.rb +12 -6
- data/lib/vagrant-libvirt/action/package_domain.rb +25 -4
- data/lib/vagrant-libvirt/action/start_domain.rb +12 -4
- data/lib/vagrant-libvirt/cap/synced_folder.rb +13 -1
- data/lib/vagrant-libvirt/config.rb +64 -2
- data/lib/vagrant-libvirt/templates/domain.xml.erb +29 -4
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +7 -0
- data/lib/vagrant-libvirt/util/erb_template.rb +1 -0
- data/lib/vagrant-libvirt/version.rb +1 -1
- data/spec/support/environment_helper.rb +1 -1
- data/spec/unit/templates/domain_all_settings.xml +3 -0
- data/spec/unit/templates/domain_defaults.xml +1 -0
- data/spec/unit/templates/domain_spec.rb +3 -0
- data/tools/create_box.sh +2 -2
- metadata +2 -6
- data/lib/vagrant-libvirt/templates/filesystem.xml.erb +0 -8
- data/lib/vagrant-libvirt/templates/interface.xml.erb +0 -14
- data/lib/vagrant-libvirt/templates/tunnel_interface.xml.erb +0 -17
- data/lib/vagrant-libvirt/templates/volume_snapshot.xml.erb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec76a65b6a28f5c9f4160ed84a12d4ed452e125d
|
4
|
+
data.tar.gz: 1cb52a45beb2a74567a70b8633fbddb2581745ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4d955916b17fb3a513d091fe031435d293e766c6ae2cb87af4b6e49e23a4daa0388afc3596d64e7733d052c22cfdf6a699471039dd6b358d6202f9594f276ea
|
7
|
+
data.tar.gz: '092d61e503d19f5a7ff51e6ab36af403f1dcba747ee5a7f5e0695199bf1e82aaf28c9b29b7ea9901d62f0dab748b2bd8caff34bae3cb47e75e8ed60fcb44a92f'
|
data/README.md
CHANGED
@@ -52,6 +52,8 @@ In the table below, build passing means that specific version combination of Vag
|
|
52
52
|
- [PCI device passthrough](#pci-device-passthrough)
|
53
53
|
- [USB Redirector Devices](#usb-redirector-devices)
|
54
54
|
- [Random number generator passthrough](#random-number-generator-passthrough)
|
55
|
+
- [Watchdog·Device](#watchdog-device)
|
56
|
+
- [Smartcard device](#smartcard-device)
|
55
57
|
- [CPU Features](#cpu-features)
|
56
58
|
- [No box and PXE boot](#no-box-and-pxe-boot)
|
57
59
|
- [SSH Access To VM](#ssh-access-to-vm)
|
@@ -275,6 +277,10 @@ end
|
|
275
277
|
_target_](http://libvirt.org/formatdomain.html#elementsDisks). NOTE: this
|
276
278
|
option applies only to disks associated with a box image. To set the bus type
|
277
279
|
on additional disks, see the [Additional Disks](#additional-disks) section.
|
280
|
+
* `disk_device` - The disk device to emulate. Defaults to vda if not
|
281
|
+
set, which should be fine for paravirtualized guests, but some fully
|
282
|
+
virtualized guests may require hda. NOTE: this option also applies only to
|
283
|
+
disks associated with a box image.
|
278
284
|
* `nic_model_type` - parameter specifies the model of the network adapter when
|
279
285
|
you create a domain value by default virtio KVM believe possible values, see
|
280
286
|
the [documentation for
|
@@ -330,6 +336,8 @@ end
|
|
330
336
|
"cirrus", "vmvga", "xen", "vbox", or "qxl".
|
331
337
|
* `video_vram` - Used by some graphics card types to vary the amount of RAM
|
332
338
|
dedicated to video. Defaults to 9216.
|
339
|
+
* `sound_type` - [Set the virtual sound card](https://libvirt.org/formatdomain.html#elementsSound)
|
340
|
+
Defaults to "ich6".
|
333
341
|
* `machine_type` - Sets machine type. Equivalent to qemu `-machine`. Use
|
334
342
|
`qemu-system-x86_64 -machine help` to get a list of supported machines.
|
335
343
|
* `machine_arch` - Sets machine architecture. This helps libvirt to determine
|
@@ -600,6 +608,11 @@ starts with `libvirt__` string. Here is a list of those options:
|
|
600
608
|
* `:model_type` - parameter specifies the model of the network adapter when you
|
601
609
|
create a domain value by default virtio KVM believe possible values, see the
|
602
610
|
documentation for libvirt
|
611
|
+
* `:libvirt__driver_name` - Define which network driver to use. [More
|
612
|
+
info](https://libvirt.org/formatdomain.html#elementsDriverBackendOptions)
|
613
|
+
* `:libvirt__driver_queues` - Define a number of queues to be used for network
|
614
|
+
interface. Set equal to numer of vCPUs for best performance. [More
|
615
|
+
info](http://www.linux-kvm.org/page/Multiqueue)
|
603
616
|
* `:autostart` - Automatic startup of network by the libvirt daemon.
|
604
617
|
If not specified the default is 'false'.
|
605
618
|
|
@@ -680,6 +693,7 @@ It has a number of options:
|
|
680
693
|
pre-existing disk. If the disk doesn't exist it will be created.
|
681
694
|
Disks with this option set to true need to be removed manually.
|
682
695
|
* `shareable` - Set to true if you want to simulate shared SAN storage.
|
696
|
+
* `serial` - Serial number of the disk device.
|
683
697
|
|
684
698
|
The following example creates two additional disks.
|
685
699
|
|
@@ -854,6 +868,80 @@ end
|
|
854
868
|
|
855
869
|
At the moment only the `random` backend is supported.
|
856
870
|
|
871
|
+
## Watchdog device
|
872
|
+
A virtual hardware watchdog device can be added to the guest via the `libvirt.watchdog` element. The option `model` is mandatory and could have on of the following values.
|
873
|
+
|
874
|
+
* `i6300esb` - the recommended device, emulating a PCI Intel 6300ESB
|
875
|
+
* 'ib700` - emulating an ISA iBase IB700
|
876
|
+
* `diag288` - emulating an S390 DIAG288 device
|
877
|
+
|
878
|
+
The optional action attribute describes what `action` to take when the watchdog expires. Valid values are specific to the underlying hypervisor. The default behavior is `reset`.
|
879
|
+
|
880
|
+
* `reset` - default, forcefully reset the guest
|
881
|
+
* `shutdown` - gracefully shutdown the guest (not recommended)
|
882
|
+
* `poweroff` - forcefully power off the guest
|
883
|
+
* `pause` - pause the guest
|
884
|
+
* `none` - do nothing
|
885
|
+
* `dump` - automatically dump the guest
|
886
|
+
* `inject-nmi` - inject a non-maskable interrupt into the guest
|
887
|
+
|
888
|
+
```ruby
|
889
|
+
Vagrant.configure("2") do |config|
|
890
|
+
config.vm.provider :libvirt do |libvirt|
|
891
|
+
# Add libvirt watchdog device model i6300esb
|
892
|
+
libvirt.watchdog :model => 'i6300esb', :action => 'reset'
|
893
|
+
end
|
894
|
+
end
|
895
|
+
```
|
896
|
+
|
897
|
+
## Smartcard device
|
898
|
+
A virtual smartcard device can be supplied to the guest via the `libvirt.smartcard` element. The option `mode` is mandatory and currently only value `passthrough` is supported. The value `spicevmc` for option `type` is default value and can be supressed. On using `type = tcp`, the options `source_mode`, `source_host` and `source_service` are mandatory.
|
899
|
+
|
900
|
+
```ruby
|
901
|
+
Vagrant.configure("2") do |config|
|
902
|
+
config.vm.provider :libvirt do |libvirt|
|
903
|
+
# Add smartcard device with type 'spicevmc'
|
904
|
+
libvirt.smartcard :mode => 'passthrough', :type => 'spicevmc'
|
905
|
+
end
|
906
|
+
end
|
907
|
+
```
|
908
|
+
|
909
|
+
```ruby
|
910
|
+
Vagrant.configure("2") do |config|
|
911
|
+
config.vm.provider :libvirt do |libvirt|
|
912
|
+
# Add smartcard device with type 'tcp'
|
913
|
+
domain.smartcard :mode => 'passthrough', :type => 'tcp', :source_mode => 'bind', :source_host => '127.0.0.1', :source_service => '2001'
|
914
|
+
end
|
915
|
+
end
|
916
|
+
```
|
917
|
+
## Features
|
918
|
+
|
919
|
+
Hypervisor features can be specified via `libvirt.features` as a list. The default
|
920
|
+
options that are enabled are `acpi`, `apic` and `pae`. If you define `libvirt.features`
|
921
|
+
you overwrite the defaults, so keep that in mind.
|
922
|
+
|
923
|
+
An example:
|
924
|
+
|
925
|
+
```ruby
|
926
|
+
Vagrant.configure("2") do |config|
|
927
|
+
config.vm.provider :libvirt do |libvirt|
|
928
|
+
# Specify the default hypervisor features
|
929
|
+
libvirt.features = ['acpi', 'apic', 'pae' ]
|
930
|
+
end
|
931
|
+
end
|
932
|
+
```
|
933
|
+
|
934
|
+
A different example for ARM boards:
|
935
|
+
|
936
|
+
```ruby
|
937
|
+
Vagrant.configure("2") do |config|
|
938
|
+
config.vm.provider :libvirt do |libvirt|
|
939
|
+
# Specify the default hypervisor features
|
940
|
+
libvirt.features = ["apic", "gic version='2'" ]
|
941
|
+
end
|
942
|
+
end
|
943
|
+
```
|
944
|
+
|
857
945
|
## CPU features
|
858
946
|
|
859
947
|
You can specify CPU feature policies via `libvirt.cpu_feature`. Available
|
data/lib/vagrant-libvirt.rb
CHANGED
@@ -22,7 +22,7 @@ end
|
|
22
22
|
# This is a sanity check to make sure no one is attempting to install
|
23
23
|
# this into an early Vagrant version.
|
24
24
|
if Vagrant::VERSION < '1.5.0'
|
25
|
-
raise 'The Vagrant Libvirt plugin is only compatible with Vagrant 1.5
|
25
|
+
raise 'The Vagrant Libvirt plugin is only compatible with Vagrant 1.5+.'
|
26
26
|
end
|
27
27
|
|
28
28
|
# make sure base module class defined before loading plugin
|
@@ -67,12 +67,16 @@ module VagrantPlugins
|
|
67
67
|
Vagrant::Action::Builder.new.tap do |b|
|
68
68
|
b.use ConfigValidate
|
69
69
|
b.use Call, IsRunning do |env, b2|
|
70
|
-
# If the VM is running,
|
71
|
-
|
70
|
+
# If the VM is running, run the necessary provisioners
|
71
|
+
if env[:result]
|
72
|
+
b2.use action_provision
|
73
|
+
next
|
74
|
+
end
|
72
75
|
|
73
76
|
b2.use Call, IsSuspended do |env2, b3|
|
74
77
|
# if vm is suspended resume it then exit
|
75
78
|
if env2[:result]
|
79
|
+
b3.use CreateNetworks
|
76
80
|
b3.use ResumeDomain
|
77
81
|
next
|
78
82
|
end
|
@@ -124,6 +128,7 @@ module VagrantPlugins
|
|
124
128
|
end
|
125
129
|
|
126
130
|
b2.use Call, IsSuspended do |env2, b3|
|
131
|
+
b3.use CreateNetworks if env2[:result]
|
127
132
|
b3.use ResumeDomain if env2[:result]
|
128
133
|
end
|
129
134
|
|
@@ -269,6 +274,7 @@ module VagrantPlugins
|
|
269
274
|
b3.use MessageNotSuspended
|
270
275
|
next
|
271
276
|
end
|
277
|
+
b3.use CreateNetworks
|
272
278
|
b3.use ResumeDomain
|
273
279
|
end
|
274
280
|
end
|
@@ -34,6 +34,7 @@ module VagrantPlugins
|
|
34
34
|
@uuid = config.uuid
|
35
35
|
@cpus = config.cpus.to_i
|
36
36
|
@cpu_features = config.cpu_features
|
37
|
+
@features = config.features
|
37
38
|
@cpu_mode = config.cpu_mode
|
38
39
|
@cpu_model = config.cpu_model
|
39
40
|
@cpu_fallback = config.cpu_fallback
|
@@ -42,6 +43,7 @@ module VagrantPlugins
|
|
42
43
|
@machine_type = config.machine_type
|
43
44
|
@machine_arch = config.machine_arch
|
44
45
|
@disk_bus = config.disk_bus
|
46
|
+
@disk_device = config.disk_device
|
45
47
|
@nested = config.nested
|
46
48
|
@memory_size = config.memory.to_i * 1024
|
47
49
|
@management_network_mac = config.management_network_mac
|
@@ -61,6 +63,7 @@ module VagrantPlugins
|
|
61
63
|
"passwd='#{config.graphics_passwd}'"
|
62
64
|
end
|
63
65
|
@video_type = config.video_type
|
66
|
+
@sound_type = config.sound_type
|
64
67
|
@video_vram = config.video_vram
|
65
68
|
@keymap = config.keymap
|
66
69
|
@kvm_hidden = config.kvm_hidden
|
@@ -85,6 +88,9 @@ module VagrantPlugins
|
|
85
88
|
|
86
89
|
# PCI device passthrough
|
87
90
|
@pcis = config.pcis
|
91
|
+
|
92
|
+
# Watchdog device
|
93
|
+
@watchdog_dev = config.watchdog_dev
|
88
94
|
|
89
95
|
# USB device passthrough
|
90
96
|
@usbs = config.usbs
|
@@ -93,6 +99,9 @@ module VagrantPlugins
|
|
93
99
|
@redirdevs = config.redirdevs
|
94
100
|
@redirfilters = config.redirfilters
|
95
101
|
|
102
|
+
# smartcard device
|
103
|
+
@smartcard_dev = config.smartcard_dev
|
104
|
+
|
96
105
|
# RNG device passthrough
|
97
106
|
@rng = config.rng
|
98
107
|
|
@@ -169,6 +178,9 @@ module VagrantPlugins
|
|
169
178
|
@cpu_features.each do |cpu_feature|
|
170
179
|
env[:ui].info(" -- CPU Feature: name=#{cpu_feature[:name]}, policy=#{cpu_feature[:policy]}")
|
171
180
|
end
|
181
|
+
@features.each do |feature|
|
182
|
+
env[:ui].info(" -- Feature: #{feature}")
|
183
|
+
end
|
172
184
|
env[:ui].info(" -- Memory: #{@memory_size / 1024}M")
|
173
185
|
env[:ui].info(" -- Management MAC: #{@management_network_mac}")
|
174
186
|
env[:ui].info(" -- Loader: #{@loader}")
|
@@ -186,6 +198,7 @@ module VagrantPlugins
|
|
186
198
|
env[:ui].info(" -- Graphics Password: #{@graphics_passwd.empty? ? 'Not defined' : 'Defined'}")
|
187
199
|
env[:ui].info(" -- Video Type: #{@video_type}")
|
188
200
|
env[:ui].info(" -- Video VRAM: #{@video_vram}")
|
201
|
+
env[:ui].info(" -- Sound Type: #{@sound_type}")
|
189
202
|
env[:ui].info(" -- Keymap: #{@keymap}")
|
190
203
|
env[:ui].info(" -- TPM Path: #{@tpm_path}")
|
191
204
|
|
@@ -230,6 +243,10 @@ module VagrantPlugins
|
|
230
243
|
env[:ui].info(" -- RNG device model: #{@rng[:model]}")
|
231
244
|
end
|
232
245
|
|
246
|
+
if not @watchdog_dev.empty?
|
247
|
+
env[:ui].info(" -- Watchdog device: model=#{@watchdog_dev[:model]}, action=#{@watchdog_dev[:action]}")
|
248
|
+
end
|
249
|
+
|
233
250
|
@usbs.each do |usb|
|
234
251
|
usb_dev = []
|
235
252
|
usb_dev.push("bus=#{usb[:bus]}") if usb[:bus]
|
@@ -259,6 +276,10 @@ module VagrantPlugins
|
|
259
276
|
end
|
260
277
|
end
|
261
278
|
|
279
|
+
if not @smartcard_dev.empty?
|
280
|
+
env[:ui].info(" -- smartcard device: mode=#{@smartcard_dev[:mode]}, type=#{@smartcard_dev[:type]}")
|
281
|
+
end
|
282
|
+
|
262
283
|
env[:ui].info(" -- Command line : #{@cmd_line}")
|
263
284
|
|
264
285
|
# Create libvirt domain.
|
@@ -41,8 +41,37 @@ module VagrantPlugins
|
|
41
41
|
# Create new volume from xml template. Fog currently doesn't support
|
42
42
|
# volume snapshots directly.
|
43
43
|
begin
|
44
|
+
xml = Nokogiri::XML::Builder.new do |xml|
|
45
|
+
xml.volume do
|
46
|
+
xml.name(@name)
|
47
|
+
xml.capacity(@capacity, unit: 'G')
|
48
|
+
xml.target do
|
49
|
+
xml.format(type: 'qcow2')
|
50
|
+
xml.permissions do
|
51
|
+
xml.owner 0
|
52
|
+
xml.group 0
|
53
|
+
xml.mode '0600'
|
54
|
+
xml.label 'virt_image_t'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
xml.backingStore do
|
58
|
+
xml.path(@backing_file)
|
59
|
+
xml.format(type: 'qcow2')
|
60
|
+
xml.permissions do
|
61
|
+
xml.owner 0
|
62
|
+
xml.group 0
|
63
|
+
xml.mode '0600'
|
64
|
+
xml.label 'virt_image_t'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end.to_xml(
|
69
|
+
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
|
70
|
+
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
71
|
+
Nokogiri::XML::Node::SaveOptions::FORMAT
|
72
|
+
)
|
44
73
|
domain_volume = env[:machine].provider.driver.connection.volumes.create(
|
45
|
-
xml:
|
74
|
+
xml: xml,
|
46
75
|
pool_name: config.storage_pool_name
|
47
76
|
)
|
48
77
|
rescue Fog::Errors::Error => e
|
@@ -17,7 +17,7 @@ module VagrantPlugins
|
|
17
17
|
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_network_interfaces')
|
18
18
|
@management_network_name = env[:machine].provider_config.management_network_name
|
19
19
|
config = env[:machine].provider_config
|
20
|
-
@nic_model_type = config.nic_model_type
|
20
|
+
@nic_model_type = config.nic_model_type || 'virtio'
|
21
21
|
@nic_adapter_count = config.nic_adapter_count
|
22
22
|
@app = app
|
23
23
|
end
|
@@ -64,11 +64,17 @@ module VagrantPlugins
|
|
64
64
|
end
|
65
65
|
|
66
66
|
# Create each interface as new domain device.
|
67
|
+
@macs_per_network = Hash.new(0)
|
67
68
|
adapters.each_with_index do |iface_configuration, slot_number|
|
68
69
|
@iface_number = slot_number
|
69
70
|
@network_name = iface_configuration[:network_name]
|
71
|
+
@source_options = {
|
72
|
+
network: @network_name
|
73
|
+
}
|
70
74
|
@mac = iface_configuration.fetch(:mac, false)
|
71
75
|
@model_type = iface_configuration.fetch(:model_type, @nic_model_type)
|
76
|
+
@driver_name = iface_configuration.fetch(:driver_name, false)
|
77
|
+
@driver_queues = iface_configuration.fetch(:driver_queues, false)
|
72
78
|
@device_name = iface_configuration.fetch(:iface_name, false)
|
73
79
|
template_name = 'interface'
|
74
80
|
# Configuration for public interfaces which use the macvtap driver
|
@@ -77,6 +83,8 @@ module VagrantPlugins
|
|
77
83
|
@mode = iface_configuration.fetch(:mode, 'bridge')
|
78
84
|
@type = iface_configuration.fetch(:type, 'direct')
|
79
85
|
@model_type = iface_configuration.fetch(:model_type, @nic_model_type)
|
86
|
+
@driver_name = iface_configuration.fetch(:driver_name, false)
|
87
|
+
@driver_queues = iface_configuration.fetch(:driver_queues, false)
|
80
88
|
@portgroup = iface_configuration.fetch(:portgroup, nil)
|
81
89
|
@network_name = iface_configuration.fetch(:network_name, @network_name)
|
82
90
|
template_name = 'public_interface'
|
@@ -90,8 +98,10 @@ module VagrantPlugins
|
|
90
98
|
raise Errors::TunnelPortNotDefined if @tunnel_port.nil?
|
91
99
|
if @type == 'udp'
|
92
100
|
# default udp tunnel source to 127.0.0.1
|
93
|
-
@
|
94
|
-
|
101
|
+
@udp_tunnel={
|
102
|
+
address: iface_configuration.fetch(:tunnel_local_ip,'127.0.0.1'),
|
103
|
+
port: iface_configuration.fetch(:tunnel_local_port)
|
104
|
+
}
|
95
105
|
end
|
96
106
|
# default mcast tunnel to 239.255.1.1. Web search says this
|
97
107
|
# 239.255.x.x is a safe range to use for general use mcast
|
@@ -100,8 +110,13 @@ module VagrantPlugins
|
|
100
110
|
else
|
101
111
|
'127.0.0.1'
|
102
112
|
end
|
103
|
-
@
|
104
|
-
|
113
|
+
@source_options = {
|
114
|
+
address: iface_configuration.fetch(:tunnel_ip, default_ip),
|
115
|
+
port: @tunnel_port
|
116
|
+
}
|
117
|
+
@tunnel_type = iface_configuration.fetch(:model_type, @nic_model_type)
|
118
|
+
@driver_name = iface_configuration.fetch(:driver_name, false)
|
119
|
+
@driver_queues = iface_configuration.fetch(:driver_queues, false)
|
105
120
|
template_name = 'tunnel_interface'
|
106
121
|
@logger.info("Setting up #{@type} tunnel interface using #{@tunnel_ip} port #{@tunnel_port}")
|
107
122
|
end
|
@@ -115,27 +130,46 @@ module VagrantPlugins
|
|
115
130
|
@logger.info(message)
|
116
131
|
|
117
132
|
begin
|
118
|
-
|
133
|
+
# FIXME: all options for network driver should be hash from Vagrantfile
|
134
|
+
driver_options = {}
|
135
|
+
driver_options[:name] = @driver_name if @driver_name
|
136
|
+
driver_options[:queues] = @driver_queues if @driver_queues
|
137
|
+
@udp_tunnel ||= {}
|
138
|
+
xml = if template_name == 'interface' or
|
139
|
+
template_name == 'tunnel_interface'
|
140
|
+
interface_xml(@type,
|
141
|
+
@source_options,
|
142
|
+
@mac,
|
143
|
+
@device_name,
|
144
|
+
@iface_number,
|
145
|
+
@model_type,
|
146
|
+
driver_options,
|
147
|
+
@udp_tunnel)
|
148
|
+
else
|
149
|
+
to_xml(template_name)
|
150
|
+
end
|
151
|
+
domain.attach_device(xml)
|
119
152
|
rescue => e
|
120
153
|
raise Errors::AttachDeviceError,
|
121
154
|
error_message: e.message
|
122
155
|
end
|
123
156
|
|
124
157
|
# Re-read the network configuration and grab the MAC address
|
125
|
-
next if @mac
|
126
|
-
xml = Nokogiri::XML(domain.xml_desc)
|
127
158
|
if iface_configuration[:iface_type] == :public_network
|
159
|
+
xml = Nokogiri::XML(domain.xml_desc)
|
160
|
+
source = "@network='#{@network_name}'"
|
128
161
|
if @type == 'direct'
|
129
|
-
|
130
|
-
elsif
|
131
|
-
|
132
|
-
else
|
133
|
-
@mac = xml.xpath("/domain/devices/interface[source[@bridge='#{@device}']]/mac/@address")
|
162
|
+
source = "@dev='#{@device}'"
|
163
|
+
elsif @portgroup.nil?
|
164
|
+
source = "@bridge='#{@device}'"
|
134
165
|
end
|
135
|
-
|
136
|
-
|
166
|
+
if not @mac
|
167
|
+
macs = xml.xpath("/domain/devices/interface[source[#{source}]]/mac/@address")
|
168
|
+
@mac = macs[@macs_per_network[source]]
|
169
|
+
iface_configuration[:mac] = @mac.to_s
|
170
|
+
end
|
171
|
+
@macs_per_network[source] += 1
|
137
172
|
end
|
138
|
-
iface_configuration[:mac] = @mac.to_s
|
139
173
|
end
|
140
174
|
|
141
175
|
# Continue the middleware chain.
|
@@ -150,7 +184,7 @@ module VagrantPlugins
|
|
150
184
|
# Skip configuring the management network, which is on the first interface.
|
151
185
|
# It's used for provisioning and it has to be available during provisioning,
|
152
186
|
# ifdown command is not acceptable here.
|
153
|
-
next if slot_number
|
187
|
+
next if slot_number.zero?
|
154
188
|
next if options[:auto_config] === false
|
155
189
|
@logger.debug "Configuring interface slot_number #{slot_number} options #{options}"
|
156
190
|
|
@@ -187,6 +221,39 @@ module VagrantPlugins
|
|
187
221
|
|
188
222
|
private
|
189
223
|
|
224
|
+
def target_dev_name(device_name, type, iface_number)
|
225
|
+
if device_name
|
226
|
+
device_name
|
227
|
+
elsif type == 'netwrok'
|
228
|
+
"vnet#{iface_number}"
|
229
|
+
else
|
230
|
+
# TODO can we use same name vnet#ifnum?
|
231
|
+
#"tnet#{iface_number}" FIXME plugin vagrant-libvirt trying to create second tnet0 interface
|
232
|
+
"vnet#{iface_number}"
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def interface_xml(type, source_options, mac, device_name,
|
237
|
+
iface_number, model_type, driver_options,
|
238
|
+
udp_tunnel={})
|
239
|
+
Nokogiri::XML::Builder.new do |xml|
|
240
|
+
xml.interface(type: type || 'network') do
|
241
|
+
xml.source(source_options) do
|
242
|
+
xml.local(udp_tunnel) if type == 'udp'
|
243
|
+
end
|
244
|
+
xml.mac(address: mac) if mac
|
245
|
+
xml.target(dev: target_dev_name(device_name, type, iface_number))
|
246
|
+
xml.alias(name: "net#{iface_number}")
|
247
|
+
xml.model(type: model_type.to_s)
|
248
|
+
xml.driver(driver_options)
|
249
|
+
end
|
250
|
+
end.to_xml(
|
251
|
+
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
|
252
|
+
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
253
|
+
Nokogiri::XML::Node::SaveOptions::FORMAT
|
254
|
+
)
|
255
|
+
end
|
256
|
+
|
190
257
|
def find_empty(array, start = 0, stop = @nic_adapter_count)
|
191
258
|
(start..stop).each do |i|
|
192
259
|
return i unless array[i]
|
@@ -20,13 +20,19 @@ module VagrantPlugins
|
|
20
20
|
libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(
|
21
21
|
env[:machine].id
|
22
22
|
)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
begin
|
24
|
+
libvirt_domain.list_snapshots.each do |name|
|
25
|
+
@logger.info("Deleting snapshot '#{name}'")
|
26
|
+
begin
|
27
|
+
libvirt_domain.lookup_snapshot_by_name(name).delete
|
28
|
+
rescue => e
|
29
|
+
raise Errors::DeleteSnapshotError, error_message: e.message
|
30
|
+
end
|
29
31
|
end
|
32
|
+
rescue
|
33
|
+
# Some drivers (xen) don't support getting list of snapshots,
|
34
|
+
# not much can be done here about it
|
35
|
+
@logger.warn("Failed to get list of snapshots")
|
30
36
|
end
|
31
37
|
|
32
38
|
# must remove managed saves
|
@@ -39,11 +39,29 @@ module VagrantPlugins
|
|
39
39
|
# remove hw association with interface
|
40
40
|
# working for centos with lvs default disks
|
41
41
|
`virt-sysprep --no-logfile --operations defaults,-ssh-userdir -a #{@tmp_img}`
|
42
|
+
# add any user provided file
|
43
|
+
extra = ''
|
44
|
+
@tmp_include = @tmp_dir + '/_include'
|
45
|
+
if env['package.include']
|
46
|
+
extra = './_include'
|
47
|
+
Dir.mkdir(@tmp_include)
|
48
|
+
env['package.include'].each do |f|
|
49
|
+
env[:ui].info("Including user file: #{f}")
|
50
|
+
FileUtils.cp(f, @tmp_include)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
if env['package.vagrantfile']
|
54
|
+
extra = './_include'
|
55
|
+
Dir.mkdir(@tmp_include) unless File.directory?(@tmp_include)
|
56
|
+
env[:ui].info('Including user Vagrantfile')
|
57
|
+
FileUtils.cp(env['package.vagrantfile'], @tmp_include + '/Vagrantfile')
|
58
|
+
end
|
42
59
|
Dir.chdir(@tmp_dir)
|
43
|
-
|
60
|
+
info = JSON.parse(`qemu-img info --output=json #{@tmp_img}`)
|
61
|
+
img_size = (Float(info['virtual-size'])/(1024**3)).ceil
|
44
62
|
File.write(@tmp_dir + '/metadata.json', metadata_content(img_size))
|
45
63
|
File.write(@tmp_dir + '/Vagrantfile', vagrantfile_content)
|
46
|
-
|
64
|
+
assemble_box(boxname, extra)
|
47
65
|
FileUtils.mv(@tmp_dir + '/' + boxname, '../' + boxname)
|
48
66
|
FileUtils.rm_rf(@tmp_dir)
|
49
67
|
env[:ui].info('Box created')
|
@@ -52,8 +70,8 @@ module VagrantPlugins
|
|
52
70
|
@app.call(env)
|
53
71
|
end
|
54
72
|
|
55
|
-
def
|
56
|
-
`tar cvzf "#{boxname}" --totals ./metadata.json ./Vagrantfile ./box.img`
|
73
|
+
def assemble_box(boxname, extra)
|
74
|
+
`tar cvzf "#{boxname}" --totals ./metadata.json ./Vagrantfile ./box.img #{extra}`
|
57
75
|
end
|
58
76
|
|
59
77
|
def vagrantfile_content
|
@@ -66,6 +84,9 @@ module VagrantPlugins
|
|
66
84
|
libvirt.storage_pool_name = "default"
|
67
85
|
end
|
68
86
|
end
|
87
|
+
|
88
|
+
user_vagrantfile = File.expand_path('../_include/Vagrantfile', __FILE__)
|
89
|
+
load user_vagrantfile if File.exists?(user_vagrantfile)
|
69
90
|
EOF
|
70
91
|
end
|
71
92
|
|
@@ -54,10 +54,12 @@ module VagrantPlugins
|
|
54
54
|
end
|
55
55
|
|
56
56
|
# Iterface type
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
unless config.nic_model_type.nil?
|
58
|
+
REXML::XPath.each(xml_descr, '/domain/devices/interface/model') do |iface_model|
|
59
|
+
if iface_model.attributes['type'] != config.nic_model_type
|
60
|
+
descr_changed = true
|
61
|
+
iface_model.attributes['type'] = config.nic_model_type
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
63
65
|
|
@@ -221,6 +223,12 @@ module VagrantPlugins
|
|
221
223
|
end
|
222
224
|
end
|
223
225
|
|
226
|
+
# Sound device
|
227
|
+
if config.sound_type
|
228
|
+
sound = REXML::XPath.first(xml_descr,'/domain/devices/sound/model')
|
229
|
+
end
|
230
|
+
|
231
|
+
|
224
232
|
# dtb
|
225
233
|
if config.dtb
|
226
234
|
dtb = REXML::XPath.first(xml_descr, '/domain/os/dtb')
|
@@ -46,7 +46,19 @@ module VagrantPlugins
|
|
46
46
|
|
47
47
|
machine.ui.info "================\nMachine id: #{machine.id}\nShould be mounting folders\n #{id}, opts: #{folder_opts}"
|
48
48
|
|
49
|
-
xml = to_xml('filesystem', folder_opts)
|
49
|
+
#xml = to_xml('filesystem', folder_opts)
|
50
|
+
xml = Nokogiri::XML::Builder.new do |xml|
|
51
|
+
xml.filesystem(type: 'mount', accessmode: folder_opts[:accessmode]) do
|
52
|
+
xml.driver(type: 'path', wrpolicy: 'immediate')
|
53
|
+
xml.source(dir: folder_opts[:hostpath])
|
54
|
+
xml.target(dir: mount_tag)
|
55
|
+
xml.readonly unless folder_opts[:readonly].nil?
|
56
|
+
end
|
57
|
+
end.to_xml(
|
58
|
+
save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION |
|
59
|
+
Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
|
60
|
+
Nokogiri::XML::Node::SaveOptions::FORMAT
|
61
|
+
)
|
50
62
|
# puts "<<<<< XML:\n #{xml}\n >>>>>"
|
51
63
|
@conn.lookup_domain_by_uuid(machine.id).attach_device(xml, 0)
|
52
64
|
end
|
@@ -64,6 +64,7 @@ module VagrantPlugins
|
|
64
64
|
attr_accessor :cpu_model
|
65
65
|
attr_accessor :cpu_fallback
|
66
66
|
attr_accessor :cpu_features
|
67
|
+
attr_accessor :features
|
67
68
|
attr_accessor :numa_nodes
|
68
69
|
attr_accessor :loader
|
69
70
|
attr_accessor :boot_order
|
@@ -71,6 +72,7 @@ module VagrantPlugins
|
|
71
72
|
attr_accessor :machine_arch
|
72
73
|
attr_accessor :machine_virtual_size
|
73
74
|
attr_accessor :disk_bus
|
75
|
+
attr_accessor :disk_device
|
74
76
|
attr_accessor :nic_model_type
|
75
77
|
attr_accessor :nested
|
76
78
|
attr_accessor :volume_cache
|
@@ -88,6 +90,7 @@ module VagrantPlugins
|
|
88
90
|
attr_accessor :video_vram
|
89
91
|
attr_accessor :keymap
|
90
92
|
attr_accessor :kvm_hidden
|
93
|
+
attr_accessor :sound_type
|
91
94
|
|
92
95
|
# Sets the information for connecting to a host TPM device
|
93
96
|
# Only supports socket-based TPMs
|
@@ -116,6 +119,9 @@ module VagrantPlugins
|
|
116
119
|
# Random number device passthrough
|
117
120
|
attr_accessor :rng
|
118
121
|
|
122
|
+
# Watchdog device
|
123
|
+
attr_accessor :watchdog_dev
|
124
|
+
|
119
125
|
# USB device passthrough
|
120
126
|
attr_accessor :usbs
|
121
127
|
|
@@ -123,6 +129,9 @@ module VagrantPlugins
|
|
123
129
|
attr_accessor :redirdevs
|
124
130
|
attr_accessor :redirfilters
|
125
131
|
|
132
|
+
# smartcard device
|
133
|
+
attr_accessor :smartcard_dev
|
134
|
+
|
126
135
|
# Suspend mode
|
127
136
|
attr_accessor :suspend_mode
|
128
137
|
|
@@ -157,12 +166,14 @@ module VagrantPlugins
|
|
157
166
|
@cpu_model = UNSET_VALUE
|
158
167
|
@cpu_fallback = UNSET_VALUE
|
159
168
|
@cpu_features = UNSET_VALUE
|
169
|
+
@features = UNSET_VALUE
|
160
170
|
@numa_nodes = UNSET_VALUE
|
161
171
|
@loader = UNSET_VALUE
|
162
172
|
@machine_type = UNSET_VALUE
|
163
173
|
@machine_arch = UNSET_VALUE
|
164
174
|
@machine_virtual_size = UNSET_VALUE
|
165
175
|
@disk_bus = UNSET_VALUE
|
176
|
+
@disk_device = UNSET_VALUE
|
166
177
|
@nic_model_type = UNSET_VALUE
|
167
178
|
@nested = UNSET_VALUE
|
168
179
|
@volume_cache = UNSET_VALUE
|
@@ -178,6 +189,7 @@ module VagrantPlugins
|
|
178
189
|
@graphics_passwd = UNSET_VALUE
|
179
190
|
@video_type = UNSET_VALUE
|
180
191
|
@video_vram = UNSET_VALUE
|
192
|
+
@sound_type = UNSET_VALUE
|
181
193
|
@keymap = UNSET_VALUE
|
182
194
|
@kvm_hidden = UNSET_VALUE
|
183
195
|
|
@@ -205,6 +217,9 @@ module VagrantPlugins
|
|
205
217
|
# Random number device passthrough
|
206
218
|
@rng = UNSET_VALUE
|
207
219
|
|
220
|
+
# Watchdog device
|
221
|
+
@watchdog_dev = UNSET_VALUE
|
222
|
+
|
208
223
|
# USB device passthrough
|
209
224
|
@usbs = UNSET_VALUE
|
210
225
|
|
@@ -212,6 +227,9 @@ module VagrantPlugins
|
|
212
227
|
@redirdevs = UNSET_VALUE
|
213
228
|
@redirfilters = UNSET_VALUE
|
214
229
|
|
230
|
+
# smartcard device
|
231
|
+
@smartcard_dev = UNSET_VALUE
|
232
|
+
|
215
233
|
# Suspend mode
|
216
234
|
@suspend_mode = UNSET_VALUE
|
217
235
|
|
@@ -344,6 +362,20 @@ module VagrantPlugins
|
|
344
362
|
function: options[:function])
|
345
363
|
end
|
346
364
|
|
365
|
+
def watchdog(options = {})
|
366
|
+
if options[:model].nil?
|
367
|
+
raise 'Model must be specified.'
|
368
|
+
end
|
369
|
+
|
370
|
+
if @watchdog_dev == UNSET_VALUE
|
371
|
+
@watchdog_dev = {}
|
372
|
+
end
|
373
|
+
|
374
|
+
@watchdog_dev[:model] = options[:model]
|
375
|
+
@watchdog_dev[:action] = options[:action] || 'reset'
|
376
|
+
end
|
377
|
+
|
378
|
+
|
347
379
|
def usb(options = {})
|
348
380
|
if (options[:bus].nil? || options[:device].nil?) && options[:vendor].nil? && options[:product].nil?
|
349
381
|
raise 'Bus and device and/or vendor and/or product must be specified. Check `lsusb` for these.'
|
@@ -378,6 +410,26 @@ module VagrantPlugins
|
|
378
410
|
allow: options[:allow])
|
379
411
|
end
|
380
412
|
|
413
|
+
def smartcard(options = {})
|
414
|
+
if options[:mode].nil?
|
415
|
+
raise 'Option mode must be specified.'
|
416
|
+
elsif options[:mode] != 'passthrough'
|
417
|
+
raise 'Currently only passthrough mode is supported!'
|
418
|
+
elsif options[:type] == 'tcp' && (options[:source_mode].nil? || options[:source_host].nil? || options[:source_service].nil?)
|
419
|
+
raise 'If using type "tcp", option "source_mode", "source_host" and "source_service" must be specified.'
|
420
|
+
end
|
421
|
+
|
422
|
+
if @smartcard_dev == UNSET_VALUE
|
423
|
+
@smartcard_dev = {}
|
424
|
+
end
|
425
|
+
|
426
|
+
@smartcard_dev[:mode] = options[:mode]
|
427
|
+
@smartcard_dev[:type] = options[:type] || 'spicevmc'
|
428
|
+
@smartcard_dev[:source_mode] = options[:source_mode] if @smartcard_dev[:type] == 'tcp'
|
429
|
+
@smartcard_dev[:source_host] = options[:source_host] if @smartcard_dev[:type] == 'tcp'
|
430
|
+
@smartcard_dev[:source_service] = options[:source_service] if @smartcard_dev[:type] == 'tcp'
|
431
|
+
end
|
432
|
+
|
381
433
|
# NOTE: this will run twice for each time it's needed- keep it idempotent
|
382
434
|
def storage(storage_type, options = {})
|
383
435
|
if storage_type == :file
|
@@ -430,7 +482,8 @@ module VagrantPlugins
|
|
430
482
|
bus: options[:bus],
|
431
483
|
cache: options[:cache] || 'default',
|
432
484
|
allow_existing: options[:allow_existing],
|
433
|
-
shareable: options[:shareable]
|
485
|
+
shareable: options[:shareable],
|
486
|
+
serial: options[:serial]
|
434
487
|
}
|
435
488
|
|
436
489
|
@disks << disk # append
|
@@ -515,13 +568,15 @@ module VagrantPlugins
|
|
515
568
|
end
|
516
569
|
@cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE
|
517
570
|
@cpu_features = [] if @cpu_features == UNSET_VALUE
|
571
|
+
@features = ['acpi','apic','pae'] if @features == UNSET_VALUE
|
518
572
|
@numa_nodes = @numa_nodes == UNSET_VALUE ? nil : _generate_numa
|
519
573
|
@loader = nil if @loader == UNSET_VALUE
|
520
574
|
@machine_type = nil if @machine_type == UNSET_VALUE
|
521
575
|
@machine_arch = nil if @machine_arch == UNSET_VALUE
|
522
576
|
@machine_virtual_size = nil if @machine_virtual_size == UNSET_VALUE
|
523
577
|
@disk_bus = 'virtio' if @disk_bus == UNSET_VALUE
|
524
|
-
@
|
578
|
+
@disk_device = 'vda' if @disk_device == UNSET_VALUE
|
579
|
+
@nic_model_type = nil if @nic_model_type == UNSET_VALUE
|
525
580
|
@nested = false if @nested == UNSET_VALUE
|
526
581
|
@volume_cache = 'default' if @volume_cache == UNSET_VALUE
|
527
582
|
@kernel = nil if @kernel == UNSET_VALUE
|
@@ -539,6 +594,7 @@ module VagrantPlugins
|
|
539
594
|
@graphics_ip = '127.0.0.1' if @graphics_ip == UNSET_VALUE
|
540
595
|
@video_type = 'cirrus' if @video_type == UNSET_VALUE
|
541
596
|
@video_vram = 9216 if @video_vram == UNSET_VALUE
|
597
|
+
@sound_type = nil if @sound_type == UNSET_VALUE
|
542
598
|
@keymap = 'en-us' if @keymap == UNSET_VALUE
|
543
599
|
@kvm_hidden = false if @kvm_hidden == UNSET_VALUE
|
544
600
|
@tpm_model = 'tpm-tis' if @tpm_model == UNSET_VALUE
|
@@ -574,6 +630,9 @@ module VagrantPlugins
|
|
574
630
|
# Random number generator passthrough
|
575
631
|
@rng = {} if @rng == UNSET_VALUE
|
576
632
|
|
633
|
+
# Watchdog device
|
634
|
+
@watchdog_dev = {} if @watchdog_dev == UNSET_VALUE
|
635
|
+
|
577
636
|
# USB device passthrough
|
578
637
|
@usbs = [] if @usbs == UNSET_VALUE
|
579
638
|
|
@@ -581,6 +640,9 @@ module VagrantPlugins
|
|
581
640
|
@redirdevs = [] if @redirdevs == UNSET_VALUE
|
582
641
|
@redirfilters = [] if @redirfilters == UNSET_VALUE
|
583
642
|
|
643
|
+
# smartcard device
|
644
|
+
@smartcard_dev = {} if @smartcard_dev == UNSET_VALUE
|
645
|
+
|
584
646
|
# Suspend mode
|
585
647
|
@suspend_mode = 'pause' if @suspend_mode == UNSET_VALUE
|
586
648
|
|
@@ -55,9 +55,9 @@
|
|
55
55
|
<% end %>
|
56
56
|
</os>
|
57
57
|
<features>
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
<% @features.each do |feature| %>
|
59
|
+
<<%= feature %>/>
|
60
|
+
<% end %>
|
61
61
|
<% if @kvm_hidden %>
|
62
62
|
<kvm>
|
63
63
|
<hidden state='on'/>
|
@@ -74,7 +74,7 @@
|
|
74
74
|
<driver name='qemu' type='qcow2' cache='<%= @domain_volume_cache %>'/>
|
75
75
|
<source file='<%= @domain_volume_path %>'/>
|
76
76
|
<%# we need to ensure a unique target dev -%>
|
77
|
-
<target dev='
|
77
|
+
<target dev='<%= @disk_device %>' bus='<%= @disk_bus %>'/>
|
78
78
|
</disk>
|
79
79
|
<% end %>
|
80
80
|
<%# additional disks -%>
|
@@ -86,6 +86,9 @@
|
|
86
86
|
<% if d[:shareable] %>
|
87
87
|
<shareable/>
|
88
88
|
<% end %>
|
89
|
+
<% if d[:serial] %>
|
90
|
+
<serial><%= d[:serial] %></serial>
|
91
|
+
<% end %>
|
89
92
|
<%# this will get auto generated by libvirt
|
90
93
|
<address type='pci' domain='0x0000' bus='0x00' slot='???' function='0x0'/>
|
91
94
|
-%>
|
@@ -132,6 +135,12 @@
|
|
132
135
|
<input type='<%= input[:type] %>' bus='<%= input[:bus] %>'/>
|
133
136
|
<% end %>
|
134
137
|
|
138
|
+
<% if !@sound_type.nil? %>
|
139
|
+
<%# Sound device-%>
|
140
|
+
<sound model='<%= @sound_type %>'>
|
141
|
+
</sound>
|
142
|
+
<%# End Sound%>
|
143
|
+
<% end %>
|
135
144
|
<% if @graphics_type != 'none' %>
|
136
145
|
<%# Video device -%>
|
137
146
|
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd%> />
|
@@ -183,6 +192,22 @@
|
|
183
192
|
</redirfilter>
|
184
193
|
<% end %>
|
185
194
|
<% end %>
|
195
|
+
<% unless @watchdog_dev.empty? %>
|
196
|
+
<%# Watchdog Device -%>
|
197
|
+
<watchdog model='<%= @watchdog_dev[:model] %>' action='<%= @watchdog_dev[:action] %>'/>
|
198
|
+
<% end %>
|
199
|
+
|
200
|
+
<% unless @smartcard_dev.empty? -%>
|
201
|
+
<% if @smartcard_dev[:mode] == 'passthrough' %>
|
202
|
+
<% if @smartcard_dev[:type] == 'tcp' %>
|
203
|
+
<smartcard mode='<%= @smartcard_dev[:mode] %>' type='<%= @smartcard_dev[:type] %>'>
|
204
|
+
<source mode='<%= @smartcard_dev[:source_mode] %>' host='<%= @smartcard_dev[:source_host] %>' service='<%= @smartcard_dev[:source_service] %>'/>
|
205
|
+
</smartcard>
|
206
|
+
<% else %>
|
207
|
+
<smartcard mode='<%= @smartcard_dev[:mode] %>' type='<%= @smartcard_dev[:type] %>'/>
|
208
|
+
<% end %>
|
209
|
+
<% end %>
|
210
|
+
<% end -%>
|
186
211
|
|
187
212
|
<% if @tpm_path -%>
|
188
213
|
<%# TPM Device -%>
|
@@ -10,6 +10,13 @@
|
|
10
10
|
<source bridge='<%=@device%>'/>
|
11
11
|
<% end %>
|
12
12
|
<model type='<%=@model_type%>'/>
|
13
|
+
<% if @driver_name and @driver_queues %>
|
14
|
+
<driver name='<%=@driver_name%>' queues='<%=@driver_queues%>'/>
|
15
|
+
<% elsif @driver_queues %>
|
16
|
+
<driver queues='<%=@driver_queues%>'/>
|
17
|
+
<% elsif @driver_name %>
|
18
|
+
<driver name='<%=@driver_name%>'/>
|
19
|
+
<% end %>
|
13
20
|
<% if @ovs %>
|
14
21
|
<virtualport type='openvswitch'/>
|
15
22
|
<% end %>
|
@@ -4,6 +4,7 @@ module VagrantPlugins
|
|
4
4
|
module ProviderLibvirt
|
5
5
|
module Util
|
6
6
|
module ErbTemplate
|
7
|
+
# TODO: remove and use nokogiri builder
|
7
8
|
# TODO: might be a chance to use vagrant template system according to https://github.com/mitchellh/vagrant/issues/3231
|
8
9
|
def to_xml(template_name = nil, data = binding)
|
9
10
|
erb = template_name || self.class.to_s.split('::').last.downcase
|
@@ -18,7 +18,7 @@ class EnvironmentHelper
|
|
18
18
|
1024
|
19
19
|
end
|
20
20
|
|
21
|
-
%w(cpus cpu_mode loader boot_order machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
|
21
|
+
%w(cpus cpu_mode loader boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
|
22
22
|
define_method(name.to_sym) do
|
23
23
|
nil
|
24
24
|
end
|
@@ -115,6 +115,9 @@
|
|
115
115
|
<redirfilter>
|
116
116
|
<usbdev class='0x0b' vendor='0x0b' product='0x0b' version='0x0b' allow='yes'/>
|
117
117
|
</redirfilter>
|
118
|
+
<watchdog model='i6300esb' action='reset'/>
|
119
|
+
|
120
|
+
<smartcard mode='passthrough' type='spicevmc'/>
|
118
121
|
|
119
122
|
<tpm model='tpm-tis'>
|
120
123
|
<backend type='passthrough'>
|
@@ -36,6 +36,7 @@ describe 'templates/domain' do
|
|
36
36
|
domain.instance_variable_set('@domain_volume_path', '/var/lib/libvirt/images/test.qcow2')
|
37
37
|
domain.instance_variable_set('@domain_volume_cache', 'unsafe')
|
38
38
|
domain.disk_bus = 'ide'
|
39
|
+
domain.disk_device = 'vda'
|
39
40
|
domain.storage(:file, path: 'test-disk1.qcow2')
|
40
41
|
domain.storage(:file, path: 'test-disk2.qcow2')
|
41
42
|
domain.disks.each do |disk|
|
@@ -58,6 +59,8 @@ describe 'templates/domain' do
|
|
58
59
|
domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
|
59
60
|
domain.redirfilter(class: '0x0b', vendor: '0x08e6',
|
60
61
|
product: '0x3437', version: '2.00', allow: 'yes')
|
62
|
+
domain.watchdog(model: 'i6300esb', action: 'reset')
|
63
|
+
domain.smartcard(mode: 'passthrough')
|
61
64
|
domain.tpm_path = '/dev/tpm0'
|
62
65
|
end
|
63
66
|
let(:test_file) { 'domain_all_settings.xml' }
|
data/tools/create_box.sh
CHANGED
@@ -88,7 +88,7 @@ cd "$TMP_DIR"
|
|
88
88
|
#Using the awk int function here to truncate the virtual image size to an
|
89
89
|
#integer since the fog-libvirt library does not seem to properly handle
|
90
90
|
#floating point.
|
91
|
-
IMG_SIZE=$(qemu-img info "$TMP_IMG" | awk '/virtual
|
91
|
+
IMG_SIZE=$(qemu-img info --output=json "$TMP_IMG" | awk '/virtual-size/{s=int($2)/(1024^3); print (s == int(s)) ? s : int(s)+1 }')
|
92
92
|
|
93
93
|
echo "{$IMG_SIZE}"
|
94
94
|
|
@@ -118,7 +118,7 @@ EOF
|
|
118
118
|
|
119
119
|
echo "==> Creating box, tarring and gzipping"
|
120
120
|
|
121
|
-
tar cvzf "$BOX" --totals ./metadata.json ./Vagrantfile ./box.img
|
121
|
+
tar cvzf "$BOX" -S --totals ./metadata.json ./Vagrantfile ./box.img
|
122
122
|
|
123
123
|
# if box is in tmpdir move it to CWD before removing tmpdir
|
124
124
|
if ! isabspath "$BOX"; then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Stanek
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec-core
|
@@ -160,12 +160,8 @@ files:
|
|
160
160
|
- lib/vagrant-libvirt/provider.rb
|
161
161
|
- lib/vagrant-libvirt/templates/default_storage_pool.xml.erb
|
162
162
|
- lib/vagrant-libvirt/templates/domain.xml.erb
|
163
|
-
- lib/vagrant-libvirt/templates/filesystem.xml.erb
|
164
|
-
- lib/vagrant-libvirt/templates/interface.xml.erb
|
165
163
|
- lib/vagrant-libvirt/templates/private_network.xml.erb
|
166
164
|
- lib/vagrant-libvirt/templates/public_interface.xml.erb
|
167
|
-
- lib/vagrant-libvirt/templates/tunnel_interface.xml.erb
|
168
|
-
- lib/vagrant-libvirt/templates/volume_snapshot.xml.erb
|
169
165
|
- lib/vagrant-libvirt/util.rb
|
170
166
|
- lib/vagrant-libvirt/util/collection.rb
|
171
167
|
- lib/vagrant-libvirt/util/erb_template.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<interface type='network'>
|
2
|
-
<source network='<%= @network_name %>'/>
|
3
|
-
<% if @mac %>
|
4
|
-
<mac address='<%= @mac %>'/>
|
5
|
-
<% end %>
|
6
|
-
<% if @device_name %>
|
7
|
-
<target dev='<%= @device_name %>'/>
|
8
|
-
<% else %>
|
9
|
-
<target dev='vnet<%= @iface_number %>'/>
|
10
|
-
<% end %>
|
11
|
-
<alias name='net<%= @iface_number %>'/>
|
12
|
-
<model type='<%=@model_type%>'/>
|
13
|
-
</interface>
|
14
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<interface type='<%= @type %>'>
|
2
|
-
<% if @mac %>
|
3
|
-
<mac address='<%= @mac %>'/>
|
4
|
-
<% end %>
|
5
|
-
<source address='<%=@tunnel_ip%>' port='<%= @tunnel_port %>'>
|
6
|
-
<% if @type == 'udp' %>
|
7
|
-
<local address='<%=@udp_tunnel_local_ip%>' port='<%=@udp_tunnel_local_port%>' />
|
8
|
-
<% end %>
|
9
|
-
</source>
|
10
|
-
<% if @device_name %>
|
11
|
-
<target dev='<%= @device_name %>'/>
|
12
|
-
<% else %>
|
13
|
-
<target dev='tnet<%= @iface_number %>'/>
|
14
|
-
<% end %>
|
15
|
-
<alias name='net<%= @iface_number %>'/>
|
16
|
-
<model type='<%=@model_type%>'/>
|
17
|
-
</interface>
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<volume>
|
2
|
-
<name><%= @name %></name>
|
3
|
-
<capacity unit="G"><%= @capacity %></capacity>
|
4
|
-
|
5
|
-
<target>
|
6
|
-
<format type='qcow2'/>
|
7
|
-
<permissions>
|
8
|
-
<owner>0</owner>
|
9
|
-
<group>0</group>
|
10
|
-
<mode>0600</mode>
|
11
|
-
<label>virt_image_t</label>
|
12
|
-
</permissions>
|
13
|
-
</target>
|
14
|
-
|
15
|
-
<backingStore>
|
16
|
-
<path><%= @backing_file %></path>
|
17
|
-
<format type='qcow2'/>
|
18
|
-
<permissions>
|
19
|
-
<owner>0</owner>
|
20
|
-
<group>0</group>
|
21
|
-
<mode>0600</mode>
|
22
|
-
<label>virt_image_t</label>
|
23
|
-
</permissions>
|
24
|
-
</backingStore>
|
25
|
-
</volume>
|
26
|
-
|