vagrant-libvirt 0.10.8 → 0.11.2
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 -7
- data/lib/vagrant-libvirt/action/create_domain.rb +45 -22
- data/lib/vagrant-libvirt/action/create_domain_volume.rb +3 -0
- data/lib/vagrant-libvirt/action/create_network_interfaces.rb +15 -6
- data/lib/vagrant-libvirt/action/create_networks.rb +2 -6
- data/lib/vagrant-libvirt/action/destroy_domain.rb +2 -10
- data/lib/vagrant-libvirt/action/forward_ports.rb +1 -1
- data/lib/vagrant-libvirt/action/is_suspended.rb +2 -2
- data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +7 -5
- data/lib/vagrant-libvirt/action/resolve_disk_settings.rb +2 -0
- data/lib/vagrant-libvirt/action/resume_domain.rb +3 -1
- data/lib/vagrant-libvirt/action/snapshot_delete.rb +1 -1
- data/lib/vagrant-libvirt/action/snapshot_restore.rb +1 -1
- data/lib/vagrant-libvirt/action/snapshot_save.rb +1 -2
- data/lib/vagrant-libvirt/action/start_domain.rb +149 -62
- data/lib/vagrant-libvirt/action/wait_till_up.rb +2 -2
- data/lib/vagrant-libvirt/action.rb +18 -13
- data/lib/vagrant-libvirt/cap/mount_9p.rb +9 -1
- data/lib/vagrant-libvirt/cap/snapshots.rb +1 -1
- data/lib/vagrant-libvirt/config.rb +198 -26
- data/lib/vagrant-libvirt/driver.rb +94 -55
- data/lib/vagrant-libvirt/provider.rb +4 -4
- data/lib/vagrant-libvirt/templates/domain.xml.erb +73 -27
- data/lib/vagrant-libvirt/templates/public_interface.xml.erb +6 -3
- data/lib/vagrant-libvirt/util/network_util.rb +5 -10
- data/lib/vagrant-libvirt/version +1 -1
- data/locales/en.yml +4 -0
- data/spec/acceptance/additional_storage_spec.rb +1 -4
- data/spec/acceptance/networking_spec.rb +41 -0
- data/spec/acceptance/package_domain_spec.rb +2 -2
- data/spec/acceptance/provider_settings_spec.rb +1 -1
- data/spec/acceptance/simple_vm_provision_via_shell_spec.rb +1 -1
- data/spec/acceptance/snapshots_spec.rb +1 -1
- data/spec/acceptance/two_disks_spec.rb +1 -1
- data/spec/acceptance/use_qemu_agent_for_connectivity_spec.rb +1 -1
- data/spec/spec_helper.rb +31 -8
- data/spec/support/acceptance/isolated_environment.rb +1 -1
- data/spec/support/environment_helper.rb +1 -1
- data/spec/support/libvirt_acceptance_context.rb +15 -1
- data/spec/support/{sharedcontext.rb → unit_context.rb} +20 -5
- data/spec/unit/action/clean_machine_folder_spec.rb +1 -2
- data/spec/unit/action/cleanup_on_failure_spec.rb +1 -2
- data/spec/unit/action/create_domain_spec/additional_disks_domain.xml +4 -2
- data/spec/unit/action/create_domain_spec/custom_disk_settings.xml +4 -2
- data/spec/unit/action/create_domain_spec/default_domain.xml +4 -2
- data/spec/unit/action/create_domain_spec/sysinfo.xml +4 -2
- data/spec/unit/action/create_domain_spec/sysinfo_only_required.xml +4 -2
- data/spec/unit/action/create_domain_spec/two_disk_settings.xml +4 -2
- data/spec/unit/action/create_domain_spec.rb +51 -3
- data/spec/unit/action/create_domain_volume_spec.rb +2 -4
- data/spec/unit/action/destroy_domain_spec/additional_disks_domain.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_and_custom_disks_no_aliases.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/box_multiple_disks_and_additional_disks.xml +1 -0
- data/spec/unit/action/destroy_domain_spec/cdrom_domain.xml +1 -0
- data/spec/unit/action/destroy_domain_spec.rb +1 -18
- data/spec/unit/action/forward_ports_spec.rb +1 -3
- data/spec/unit/action/halt_domain_spec.rb +2 -3
- data/spec/unit/action/handle_box_image_spec.rb +3 -4
- data/spec/unit/action/package_domain_spec.rb +2 -3
- data/spec/unit/action/prepare_nfs_settings_spec.rb +25 -9
- data/spec/unit/action/remove_libvirt_image_spec.rb +1 -2
- data/spec/unit/action/resolve_disk_settings_spec/default_domain.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/default_no_aliases.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_and_custom_no_aliases.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec/multi_volume_box_additional_storage.xml +1 -0
- data/spec/unit/action/resolve_disk_settings_spec.rb +1 -1
- data/spec/unit/action/resume_domain_spec.rb +66 -0
- data/spec/unit/action/set_boot_order_spec/default.xml +1 -0
- data/spec/unit/action/set_boot_order_spec/explicit_boot_order.xml +1 -0
- data/spec/unit/action/set_boot_order_spec.rb +1 -3
- data/spec/unit/action/set_name_of_domain_spec.rb +3 -1
- data/spec/unit/action/shutdown_domain_spec.rb +4 -3
- data/spec/unit/action/start_domain_spec/clock_timer_removed.xml +1 -1
- data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +1 -1
- data/spec/unit/action/start_domain_spec/clock_timer_rtc_tsc.xml +1 -1
- data/spec/unit/action/start_domain_spec/default.xml +1 -1
- data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +1 -1
- data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +1 -1
- data/spec/unit/action/start_domain_spec/default_with_different_formatting.xml +1 -1
- data/spec/unit/action/start_domain_spec/existing.xml +2 -1
- data/spec/unit/action/start_domain_spec/existing_added_nvram.xml +2 -1
- data/spec/unit/action/start_domain_spec/existing_reordered.xml +2 -1
- data/spec/unit/action/start_domain_spec/nvram_domain.xml +1 -0
- data/spec/unit/action/start_domain_spec/nvram_domain_other_setting.xml +2 -1
- data/spec/unit/action/start_domain_spec/nvram_domain_removed.xml +2 -1
- data/spec/unit/action/start_domain_spec.rb +192 -3
- data/spec/unit/action/wait_till_up_spec.rb +3 -5
- data/spec/unit/action_spec.rb +403 -10
- data/spec/unit/cap/mount_9p_spec.rb +75 -0
- data/spec/unit/cap/synced_folder_9p_spec.rb +1 -2
- data/spec/unit/cap/synced_folder_virtiofs_spec.rb +1 -2
- data/spec/unit/config_spec.rb +365 -25
- data/spec/unit/driver_spec.rb +217 -80
- data/spec/unit/plugin_spec.rb +6 -3
- data/spec/unit/templates/domain_all_settings.xml +26 -4
- data/spec/unit/templates/domain_cpu_mode_passthrough.xml +4 -2
- data/spec/unit/templates/domain_custom_cpu_model.xml +4 -2
- data/spec/unit/templates/domain_defaults.xml +4 -2
- data/spec/unit/templates/domain_scsi_bus_storage.xml +4 -2
- data/spec/unit/templates/domain_scsi_device_storage.xml +4 -2
- data/spec/unit/templates/domain_scsi_multiple_controllers_storage.xml +4 -2
- data/spec/unit/templates/domain_spec.rb +11 -3
- data/spec/unit/templates/tpm/version_1.2.xml +4 -2
- data/spec/unit/templates/tpm/version_2.0.xml +4 -2
- data/spec/unit/util/byte_number_spec.rb +1 -1
- data/spec/unit/util/network_util_spec/default.xml +16 -0
- data/spec/unit/util/network_util_spec/hostdev.xml +6 -0
- data/spec/unit/util/network_util_spec/vagrant-libvirt.xml +16 -0
- data/spec/unit/util/network_util_spec.rb +59 -0
- data/spec/unit/util/resolvers_spec.rb +1 -1
- metadata +87 -73
@@ -66,65 +66,48 @@ module VagrantPlugins
|
|
66
66
|
@system_connection
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
70
|
-
|
71
|
-
domain = connection.servers.get(machine.id)
|
72
|
-
rescue Libvirt::RetrieveError => e
|
73
|
-
raise e unless e.libvirt_code == ProviderLibvirt::Util::ErrorCodes::VIR_ERR_NO_DOMAIN
|
74
|
-
|
75
|
-
@logger.debug("machine #{machine.name} domain not found #{e}.")
|
76
|
-
return nil
|
77
|
-
end
|
78
|
-
|
79
|
-
domain
|
80
|
-
end
|
81
|
-
|
82
|
-
def created?(machine)
|
83
|
-
domain = get_domain(machine)
|
69
|
+
def created?
|
70
|
+
domain = get_domain()
|
84
71
|
!domain.nil?
|
85
72
|
end
|
86
73
|
|
87
|
-
def get_ipaddress(
|
74
|
+
def get_ipaddress(domain=nil)
|
88
75
|
# Find the machine
|
89
|
-
domain = get_domain(
|
76
|
+
domain = get_domain() if domain.nil?
|
90
77
|
|
91
78
|
if domain.nil?
|
92
79
|
# The machine can't be found
|
93
80
|
return nil
|
94
81
|
end
|
95
82
|
|
96
|
-
get_domain_ipaddress(machine, domain)
|
97
|
-
end
|
98
|
-
|
99
|
-
def get_domain_ipaddress(machine, domain)
|
100
83
|
# attempt to get ip address from qemu agent
|
101
|
-
if machine.provider_config.qemu_use_agent == true
|
84
|
+
if @machine.provider_config.qemu_use_agent == true
|
102
85
|
@logger.info('Get IP via qemu agent')
|
103
|
-
return get_ipaddress_from_qemu_agent(
|
86
|
+
return get_ipaddress_from_qemu_agent(@machine.config.vm.boot_timeout, domain)
|
104
87
|
end
|
105
88
|
|
106
|
-
return get_ipaddress_from_system domain.mac if machine.provider_config.qemu_use_session
|
89
|
+
return get_ipaddress_from_system domain.mac if @machine.provider_config.qemu_use_session
|
107
90
|
|
108
91
|
# Get IP address from dhcp leases table
|
109
92
|
begin
|
110
93
|
ip_address = get_ipaddress_from_domain(domain)
|
111
94
|
rescue Fog::Errors::TimeoutError
|
112
|
-
@logger.info("Timeout at waiting for an ip address for machine #{machine.name}")
|
95
|
+
@logger.info("Timeout at waiting for an ip address for machine #{@machine.name}")
|
113
96
|
|
114
97
|
raise
|
115
98
|
end
|
116
99
|
|
117
100
|
unless ip_address
|
118
|
-
@logger.info("No arp table entry found for machine #{machine.name}")
|
101
|
+
@logger.info("No arp table entry found for machine #{@machine.name}")
|
119
102
|
return nil
|
120
103
|
end
|
121
104
|
|
122
105
|
ip_address
|
123
106
|
end
|
124
107
|
|
125
|
-
def restore_snapshot(
|
126
|
-
domain = get_libvirt_domain(
|
127
|
-
snapshot = get_snapshot_if_exists(
|
108
|
+
def restore_snapshot(snapshot_name)
|
109
|
+
domain = get_libvirt_domain()
|
110
|
+
snapshot = get_snapshot_if_exists(snapshot_name)
|
128
111
|
begin
|
129
112
|
# 4 is VIR_DOMAIN_SNAPSHOT_REVERT_FORCE
|
130
113
|
# needed due to https://bugzilla.redhat.com/show_bug.cgi?id=1006886
|
@@ -134,52 +117,52 @@ module VagrantPlugins
|
|
134
117
|
end
|
135
118
|
end
|
136
119
|
|
137
|
-
def list_snapshots
|
138
|
-
get_libvirt_domain(
|
120
|
+
def list_snapshots
|
121
|
+
get_libvirt_domain().list_snapshots
|
139
122
|
rescue Fog::Errors::Error => e
|
140
123
|
raise Errors::SnapshotListError, error_message: e.message
|
141
124
|
end
|
142
125
|
|
143
|
-
def delete_snapshot(
|
144
|
-
get_snapshot_if_exists(
|
126
|
+
def delete_snapshot(snapshot_name)
|
127
|
+
get_snapshot_if_exists(snapshot_name).delete
|
145
128
|
rescue Errors::SnapshotMissing => e
|
146
129
|
raise Errors::SnapshotDeletionError, error_message: e.message
|
147
130
|
end
|
148
131
|
|
149
|
-
def create_new_snapshot(
|
132
|
+
def create_new_snapshot(snapshot_name)
|
150
133
|
snapshot_desc = <<-EOF
|
151
134
|
<domainsnapshot>
|
152
135
|
<name>#{snapshot_name}</name>
|
153
136
|
<description>Snapshot for vagrant sandbox</description>
|
154
137
|
</domainsnapshot>
|
155
138
|
EOF
|
156
|
-
get_libvirt_domain(
|
139
|
+
get_libvirt_domain().snapshot_create_xml(snapshot_desc)
|
157
140
|
rescue Fog::Errors::Error => e
|
158
141
|
raise Errors::SnapshotCreationError, error_message: e.message
|
159
142
|
end
|
160
143
|
|
161
|
-
def create_snapshot(
|
144
|
+
def create_snapshot(snapshot_name)
|
162
145
|
begin
|
163
|
-
delete_snapshot(
|
146
|
+
delete_snapshot(snapshot_name)
|
164
147
|
rescue Errors::SnapshotDeletionError
|
165
148
|
end
|
166
|
-
create_new_snapshot(
|
149
|
+
create_new_snapshot(snapshot_name)
|
167
150
|
end
|
168
151
|
|
169
152
|
# if we can get snapshot description without exception it exists
|
170
|
-
def get_snapshot_if_exists(
|
171
|
-
snapshot = get_libvirt_domain(
|
153
|
+
def get_snapshot_if_exists(snapshot_name)
|
154
|
+
snapshot = get_libvirt_domain().lookup_snapshot_by_name(snapshot_name)
|
172
155
|
return snapshot if snapshot.xml_desc
|
173
156
|
rescue Libvirt::RetrieveError => e
|
174
157
|
raise Errors::SnapshotMissing, error_message: e.message
|
175
158
|
end
|
176
159
|
|
177
|
-
def state
|
160
|
+
def state
|
178
161
|
# may be other error states with initial retreival we can't handle
|
179
162
|
begin
|
180
|
-
domain = get_domain
|
163
|
+
domain = get_domain
|
181
164
|
rescue Libvirt::RetrieveError => e
|
182
|
-
@logger.debug("Machine #{machine.id} not found #{e}.")
|
165
|
+
@logger.debug("Machine #{@machine.id} not found #{e}.")
|
183
166
|
return :not_created
|
184
167
|
end
|
185
168
|
|
@@ -191,9 +174,9 @@ module VagrantPlugins
|
|
191
174
|
state = domain.state.tr('-', '_').to_sym
|
192
175
|
if state == :running
|
193
176
|
begin
|
194
|
-
|
177
|
+
get_ipaddress(domain)
|
195
178
|
rescue Fog::Errors::TimeoutError => e
|
196
|
-
@logger.debug("Machine #{machine.id} running but no IP address available: #{e}.")
|
179
|
+
@logger.debug("Machine #{@machine.id} running but no IP address available: #{e}.")
|
197
180
|
return :inaccessible
|
198
181
|
end
|
199
182
|
end
|
@@ -201,12 +184,68 @@ module VagrantPlugins
|
|
201
184
|
state
|
202
185
|
end
|
203
186
|
|
204
|
-
def
|
205
|
-
|
187
|
+
def get_domain
|
188
|
+
begin
|
189
|
+
domain = connection.servers.get(@machine.id)
|
190
|
+
rescue Libvirt::RetrieveError => e
|
191
|
+
raise e unless e.libvirt_code == ProviderLibvirt::Util::ErrorCodes::VIR_ERR_NO_DOMAIN
|
192
|
+
|
193
|
+
@logger.debug("machine #{@machine.name} domain not found #{e}.")
|
194
|
+
return nil
|
195
|
+
end
|
196
|
+
|
197
|
+
domain
|
198
|
+
end
|
199
|
+
|
200
|
+
def list_all_networks
|
201
|
+
client = if @machine.provider_config.qemu_use_session
|
202
|
+
system_connection
|
203
|
+
else
|
204
|
+
connection.client
|
205
|
+
end
|
206
|
+
|
207
|
+
client.list_all_networks.select do |net|
|
208
|
+
begin
|
209
|
+
net.bridge_name
|
210
|
+
rescue Libvirt::Error
|
211
|
+
# there does not appear to be a mechanism to determine the type of network, only by
|
212
|
+
# querying the attribute and catching the error is it possible to ignore unsupported.
|
213
|
+
@logger.debug "Ignoring #{net.name} as it does not support retrieval of bridge_name attribute"
|
214
|
+
next
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def host_devices
|
220
|
+
@host_devices ||= begin
|
221
|
+
cmd = []
|
222
|
+
unless @machine.provider_config.proxy_command.nil? || @machine.provider_config.proxy_command.empty?
|
223
|
+
cmd = ['ssh', @machine.provider_config.host]
|
224
|
+
cmd += ['-p', @machine.provider_config.port.to_s] if @machine.provider_config.port
|
225
|
+
cmd += ['-l', @machine.provider_config.username] if @machine.provider_config.username
|
226
|
+
cmd += ['-i', @machine.provider_config.id_ssh_key_file] if @machine.provider_config.id_ssh_key_file
|
227
|
+
end
|
228
|
+
ip_cmd = cmd + %W(ip -j link show)
|
229
|
+
|
230
|
+
result = Vagrant::Util::Subprocess.execute(*ip_cmd)
|
231
|
+
raise Errors::FogLibvirtConnectionError unless result.exit_code == 0
|
232
|
+
|
233
|
+
info = JSON.parse(result.stdout)
|
234
|
+
|
235
|
+
(
|
236
|
+
info.map { |iface| iface['ifname'] } +
|
237
|
+
connection.client.list_all_interfaces.map { |iface| iface.name } +
|
238
|
+
list_all_networks.map { |net| net.bridge_name }
|
239
|
+
).uniq.reject(&:empty?)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
def attach_device(xml)
|
244
|
+
get_libvirt_domain.attach_device(xml)
|
206
245
|
end
|
207
246
|
|
208
|
-
def
|
209
|
-
|
247
|
+
def detach_device(xml)
|
248
|
+
get_libvirt_domain.detach_device(xml)
|
210
249
|
end
|
211
250
|
|
212
251
|
private
|
@@ -214,7 +253,7 @@ module VagrantPlugins
|
|
214
253
|
def get_ipaddress_from_system(mac)
|
215
254
|
ip_address = nil
|
216
255
|
|
217
|
-
|
256
|
+
list_all_networks.each do |net|
|
218
257
|
leases = net.dhcp_leases(mac, 0)
|
219
258
|
# Assume the lease expiring last is the current IP address
|
220
259
|
ip_address = leases.max_by { |lse| lse['expirytime'] }['ipaddr'] unless leases.empty?
|
@@ -224,10 +263,10 @@ module VagrantPlugins
|
|
224
263
|
ip_address
|
225
264
|
end
|
226
265
|
|
227
|
-
def get_ipaddress_from_qemu_agent(
|
266
|
+
def get_ipaddress_from_qemu_agent(timeout, domain=nil)
|
228
267
|
ip_address = nil
|
229
268
|
addresses = nil
|
230
|
-
libvirt_domain =
|
269
|
+
libvirt_domain = get_libvirt_domain()
|
231
270
|
begin
|
232
271
|
response = libvirt_domain.qemu_agent_command('{"execute":"guest-network-get-interfaces"}', timeout)
|
233
272
|
@logger.debug('Got Response from qemu agent')
|
@@ -274,13 +313,13 @@ module VagrantPlugins
|
|
274
313
|
ip_address
|
275
314
|
end
|
276
315
|
|
277
|
-
def get_libvirt_domain
|
316
|
+
def get_libvirt_domain
|
278
317
|
begin
|
279
|
-
libvirt_domain = connection.client.lookup_domain_by_uuid(machine.id)
|
318
|
+
libvirt_domain = connection.client.lookup_domain_by_uuid(@machine.id)
|
280
319
|
rescue Libvirt::RetrieveError => e
|
281
320
|
raise e unless e.libvirt_code == ProviderLibvirt::Util::ErrorCodes::VIR_ERR_NO_DOMAIN
|
282
321
|
|
283
|
-
@logger.debug("machine #{machine.name} not found #{e}.")
|
322
|
+
@logger.debug("machine #{@machine.name} not found #{e}.")
|
284
323
|
return nil
|
285
324
|
end
|
286
325
|
|
@@ -57,7 +57,7 @@ module VagrantPlugins
|
|
57
57
|
# be called from other threads of execution.
|
58
58
|
return nil if state.id != :running
|
59
59
|
|
60
|
-
ip = driver.get_ipaddress
|
60
|
+
ip = driver.get_ipaddress
|
61
61
|
|
62
62
|
# if can't determine the IP, just return nil and let the core
|
63
63
|
# deal with it, similar to the docker provider
|
@@ -70,7 +70,7 @@ module VagrantPlugins
|
|
70
70
|
forward_x11: @machine.config.ssh.forward_x11
|
71
71
|
}
|
72
72
|
|
73
|
-
ssh_info[:proxy_command] = @machine.provider_config.proxy_command if @machine.provider_config.proxy_command
|
73
|
+
ssh_info[:proxy_command] = @machine.provider_config.proxy_command if @machine.provider_config.proxy_command && !@machine.provider_config.proxy_command.empty?
|
74
74
|
|
75
75
|
ssh_info
|
76
76
|
end
|
@@ -93,9 +93,9 @@ module VagrantPlugins
|
|
93
93
|
state_id = nil
|
94
94
|
state_id = :not_created unless @machine.id
|
95
95
|
state_id = :not_created if
|
96
|
-
!state_id && (!@machine.id || !driver.created?
|
96
|
+
!state_id && (!@machine.id || !driver.created?)
|
97
97
|
# Query the driver for the current state of the machine
|
98
|
-
state_id = driver.state
|
98
|
+
state_id = driver.state if @machine.id && !state_id
|
99
99
|
state_id = :unknown unless state_id
|
100
100
|
|
101
101
|
# This is a special pseudo-state so that we don't set the
|
@@ -5,33 +5,35 @@
|
|
5
5
|
<uuid><%= @uuid %></uuid>
|
6
6
|
<memory><%= @memory_size %></memory>
|
7
7
|
<vcpu<% if @cpuset %> cpuset='<%= @cpuset %>'<% end %>><%= @cpus %></vcpu>
|
8
|
+
<%- unless @cpu_mode.nil? -%>
|
8
9
|
<cpu mode='<%= @cpu_mode %>'>
|
9
|
-
<%- if @cpu_mode != 'host-passthrough' -%>
|
10
|
+
<%- if @cpu_mode != 'host-passthrough' -%>
|
10
11
|
<model fallback='<%= @cpu_fallback %>'><% if @cpu_mode == 'custom' %><%= @cpu_model %><% end %></model>
|
11
|
-
<%- end -%>
|
12
|
-
<%- if @nested -%>
|
13
|
-
<%- if @cpu_features.select{|x| x[:name] == 'vmx'}.empty? -%>
|
14
|
-
<feature policy='optional' name='vmx'/>
|
15
12
|
<%- end -%>
|
16
|
-
<%- if @
|
13
|
+
<%- if @nested -%>
|
14
|
+
<%- if @cpu_features.select{|x| x[:name] == 'vmx'}.empty? -%>
|
15
|
+
<feature policy='optional' name='vmx'/>
|
16
|
+
<%- end -%>
|
17
|
+
<%- if @cpu_features.select{|x| x[:name] == 'svm'}.empty? -%>
|
17
18
|
<feature policy='optional' name='svm'/>
|
19
|
+
<%- end -%>
|
18
20
|
<%- end -%>
|
19
|
-
<%-
|
20
|
-
<%- @cpu_features.each do |cpu_feature| -%>
|
21
|
+
<%- @cpu_features.each do |cpu_feature| -%>
|
21
22
|
<feature name='<%= cpu_feature[:name] %>' policy='<%= cpu_feature[:policy] %>'/>
|
22
|
-
<%- end -%>
|
23
|
-
<%- unless @cpu_topology.empty? -%>
|
23
|
+
<%- end -%>
|
24
|
+
<%- unless @cpu_topology.empty? -%>
|
24
25
|
<%# CPU topology -%>
|
25
26
|
<topology sockets='<%= @cpu_topology[:sockets] %>' cores='<%= @cpu_topology[:cores] %>' threads='<%= @cpu_topology[:threads] %>'/>
|
26
|
-
<%- end -%>
|
27
|
-
<%- if @numa_nodes -%>
|
27
|
+
<%- end -%>
|
28
|
+
<%- if @numa_nodes -%>
|
28
29
|
<numa>
|
29
|
-
|
30
|
+
<%- @numa_nodes.each_with_index do |node, index| -%>
|
30
31
|
<cell id='<%= index %>' cpus='<%= node[:cpus] %>' memory='<%= node[:memory] %>'<% if node.key?(:memAccess) %> memAccess='<%= node[:memAccess] %>'<% end %>/>
|
31
|
-
|
32
|
+
<%- end -%>
|
32
33
|
</numa>
|
33
|
-
<%- end -%>
|
34
|
+
<%- end -%>
|
34
35
|
</cpu>
|
36
|
+
<%- end -%>
|
35
37
|
<%- if @nodeset -%>
|
36
38
|
<numatune>
|
37
39
|
<memory nodeset='<%= @nodeset %>'/>
|
@@ -43,10 +45,22 @@
|
|
43
45
|
<<%= backing[:name] %> <%= backing[:config].map { |k,v| "#{k}='#{v}'"}.join(' ') %>/>
|
44
46
|
<%- end -%>
|
45
47
|
</memoryBacking>
|
48
|
+
<%- end -%>
|
49
|
+
<%- unless @memtunes.empty? -%>
|
50
|
+
<memtune>
|
51
|
+
<%- @memtunes.each do |name, options| -%>
|
52
|
+
<<%= name %> <%= options[:config].map { |k,v| "#{k}='#{v}'"}.join(' ') %>><%= options[:value] %></<%= name %>>
|
53
|
+
<%- end -%>
|
54
|
+
</memtune>
|
46
55
|
<%- end%>
|
47
|
-
<%- if @shares -%>
|
56
|
+
<%- if !@cpu_affinity.empty? || @shares -%>
|
48
57
|
<cputune>
|
58
|
+
<%- @cpu_affinity.each do |vcpu, cpuset| -%>
|
59
|
+
<vcpupin vcpu="<%= vcpu %>" cpuset="<%= cpuset %>" />
|
60
|
+
<%- end -%>
|
61
|
+
<%- if @shares -%>
|
49
62
|
<shares><%= @shares %></shares>
|
63
|
+
<%- end -%>
|
50
64
|
</cputune>
|
51
65
|
<%- end -%>
|
52
66
|
<os>
|
@@ -73,9 +87,7 @@
|
|
73
87
|
<%- if @nvram -%>
|
74
88
|
<nvram><%= @nvram %></nvram>
|
75
89
|
<%- end -%>
|
76
|
-
|
77
|
-
<bootmenu enable='yes'/>
|
78
|
-
<%- end -%>
|
90
|
+
<bootmenu enable='<%= @boot_order.count >= 1 ? "yes" : "no" %>'/>
|
79
91
|
<kernel><%= @kernel %></kernel>
|
80
92
|
<initrd><%= @initrd %></initrd>
|
81
93
|
<cmdline><%= @cmd_line %></cmdline>
|
@@ -140,6 +152,9 @@
|
|
140
152
|
<source file='<%= volume[:absolute_path] %>'/>
|
141
153
|
<%# we need to ensure a unique target dev -%>
|
142
154
|
<target dev='<%= volume[:device] %>' bus='<%= volume[:bus] %>'/>
|
155
|
+
<%- if volume[:address_type] -%>
|
156
|
+
<address type='<%= volume[:address_type] %>'/>
|
157
|
+
<%- end -%>
|
143
158
|
</disk>
|
144
159
|
<%- end -%>
|
145
160
|
<%- scsi_volumes = @domain_volumes.select { |x| x[:bus] == 'scsi' } %>
|
@@ -160,6 +175,9 @@
|
|
160
175
|
-%>/>
|
161
176
|
<source file='<%= d[:absolute_path] %>'/>
|
162
177
|
<target dev='<%= d[:device] %>' bus='<%= d[:bus] %>'/>
|
178
|
+
<%- if d[:address_type] || @disk_address_type -%>
|
179
|
+
<address type='<%= d[:address_type] || @disk_address_type %>'/>
|
180
|
+
<%- end -%>
|
163
181
|
<%- if d[:shareable] -%>
|
164
182
|
<shareable/>
|
165
183
|
<%- end -%>
|
@@ -182,6 +200,12 @@
|
|
182
200
|
<readonly/>
|
183
201
|
</disk>
|
184
202
|
<%- end -%>
|
203
|
+
<%- @floppies.each do |f| -%>
|
204
|
+
<disk type='file' device='floppy'>
|
205
|
+
<source file='<%= f[:path] %>'/>
|
206
|
+
<target dev='<%= f[:dev] %>' bus='<%= f[:bus] %>'/>
|
207
|
+
</disk>
|
208
|
+
<%- end -%>
|
185
209
|
<%- @serials.each_with_index do |serial, port| -%>
|
186
210
|
<serial type='<%= serial[:type] %>'>
|
187
211
|
<%- unless serial[:source].nil? -%>
|
@@ -218,7 +242,11 @@
|
|
218
242
|
</channel>
|
219
243
|
<%- end -%>
|
220
244
|
<%- @inputs.each do |input| -%>
|
221
|
-
<input type='<%= input[:type] %>' bus='<%= input[:bus] %>'
|
245
|
+
<input type='<%= input[:type] %>' bus='<%= input[:bus] %>'>
|
246
|
+
<%- unless @launchsecurity_data.nil? -%>
|
247
|
+
<driver iommu='on' />
|
248
|
+
<%- end -%>
|
249
|
+
</input>
|
222
250
|
<%- end -%>
|
223
251
|
<%- if !@sound_type.nil? -%>
|
224
252
|
<%# Sound device-%>
|
@@ -228,12 +256,13 @@
|
|
228
256
|
<%- end -%>
|
229
257
|
<%- if @graphics_type != 'none'
|
230
258
|
graphics = {
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
259
|
+
'type' => @graphics_type,
|
260
|
+
'port' => @graphics_port,
|
261
|
+
'autoport' => @graphics_autoport,
|
262
|
+
'websocket' => @graphics_websocket,
|
263
|
+
'listen' => @graphics_ip,
|
264
|
+
'keymap' => @keymap,
|
265
|
+
'passwd' => @graphics_passwd,
|
237
266
|
}
|
238
267
|
-%>
|
239
268
|
<%# Video device -%>
|
@@ -254,6 +283,9 @@
|
|
254
283
|
<%- if @rng[:model] == "random"%>
|
255
284
|
<rng model='virtio'>
|
256
285
|
<backend model='random'>/dev/random</backend>
|
286
|
+
<%- unless @launchsecurity_data.nil? -%>
|
287
|
+
<driver iommu='on' />
|
288
|
+
<%- end -%>
|
257
289
|
</rng>
|
258
290
|
<%- end -%>
|
259
291
|
<%-
|
@@ -327,18 +359,32 @@
|
|
327
359
|
<%- end -%>
|
328
360
|
<%- if not @usbctl_dev.empty? -%>
|
329
361
|
<%# USB Controller -%>
|
330
|
-
<controller type='usb' model='<%= @usbctl_dev[:model] %>' <%= "ports=\"#{@usbctl_dev[:ports]}\" " if @usbctl_dev[:ports]
|
362
|
+
<controller type='usb' model='<%= @usbctl_dev[:model] %>' <%= "ports=\"#{@usbctl_dev[:ports]}\" " if @usbctl_dev[:ports] %>>
|
363
|
+
<%- unless @launchsecurity_data.nil? -%>
|
364
|
+
<driver iommu='on' />
|
365
|
+
<%- end -%>
|
366
|
+
</controller>
|
331
367
|
<%- end -%>
|
332
368
|
<%- unless @memballoon_enabled.nil? -%>
|
333
369
|
<%- if @memballoon_enabled -%>
|
334
370
|
<memballoon model='<%= @memballoon_model %>'>
|
335
371
|
<address type='pci' domain='0x0000' bus='<%= @memballoon_pci_bus %>' slot='<%= @memballoon_pci_slot %>' function='0x0'/>
|
372
|
+
<%- unless @launchsecurity_data.nil? -%>
|
373
|
+
<driver iommu='on' />
|
374
|
+
<%- end -%>
|
336
375
|
</memballoon>
|
337
376
|
<%- else -%>
|
338
377
|
<memballoon model='none'/>
|
339
378
|
<%- end -%>
|
340
379
|
<%- end -%>
|
341
380
|
</devices>
|
381
|
+
<%- unless @launchsecurity_data.nil? -%>
|
382
|
+
<launchSecurity type='<%= @launchsecurity_data[:type] %>'>
|
383
|
+
<cbitpos><%= @launchsecurity_data[:cbitpos] %></cbitpos>
|
384
|
+
<reducedPhysBits><%= @launchsecurity_data[:reducedPhysBits] %></reducedPhysBits>
|
385
|
+
<policy><%= @launchsecurity_data[:policy] %></policy>
|
386
|
+
</launchSecurity>
|
387
|
+
<%- end -%>
|
342
388
|
<%- if not @qemu_args.empty? or not @qemu_env.empty? -%>
|
343
389
|
<qemu:commandline>
|
344
390
|
<%- @qemu_args.each do |arg| -%>
|
@@ -12,12 +12,15 @@
|
|
12
12
|
<% end %>
|
13
13
|
<model type='<%=@model_type%>'/>
|
14
14
|
<% if @driver_name and @driver_queues %>
|
15
|
-
<driver name='<%=@driver_name%>' queues='<%=@driver_queues%>'/>
|
15
|
+
<driver <% if @driver_iommu %> iommu="on" <% end %> name='<%=@driver_name%>' queues='<%=@driver_queues%>'/>
|
16
16
|
<% elsif @driver_queues %>
|
17
|
-
<driver queues='<%=@driver_queues%>'/>
|
17
|
+
<driver <% if @driver_iommu %> iommu="on" <% end %> queues='<%=@driver_queues%>'/>
|
18
18
|
<% elsif @driver_name %>
|
19
|
-
<driver name='<%=@driver_name%>'/>
|
19
|
+
<driver <% if @driver_iommu %> iommu="on" <% end %> name='<%=@driver_name%>'/>
|
20
|
+
<% elsif @driver_iommu %>
|
21
|
+
<driver iommu='on' />
|
20
22
|
<% end %>
|
23
|
+
|
21
24
|
<% if @ovs %>
|
22
25
|
<virtualport type='openvswitch'>
|
23
26
|
<% if @ovs_interfaceid %>
|
@@ -33,6 +33,7 @@ module VagrantPlugins
|
|
33
33
|
management_network_domain = env[:machine].provider_config.management_network_domain
|
34
34
|
management_network_mtu = env[:machine].provider_config.management_network_mtu
|
35
35
|
management_network_keep = env[:machine].provider_config.management_network_keep
|
36
|
+
management_network_driver_iommu = env[:machine].provider_config.management_network_driver_iommu
|
36
37
|
logger.info "Using #{management_network_name} at #{management_network_address} as the management network #{management_network_mode} is the mode"
|
37
38
|
|
38
39
|
begin
|
@@ -74,7 +75,7 @@ module VagrantPlugins
|
|
74
75
|
}
|
75
76
|
end
|
76
77
|
|
77
|
-
|
78
|
+
management_network_options[:driver_iommu] = management_network_driver_iommu
|
78
79
|
|
79
80
|
unless management_network_mac.nil?
|
80
81
|
management_network_options[:mac] = management_network_mac
|
@@ -149,17 +150,11 @@ module VagrantPlugins
|
|
149
150
|
|
150
151
|
# Return a list of all (active and inactive) Libvirt networks as a list
|
151
152
|
# of hashes with their name, network address and status (active or not)
|
152
|
-
def libvirt_networks(
|
153
|
+
def libvirt_networks(driver)
|
153
154
|
libvirt_networks = []
|
154
155
|
|
155
|
-
active = libvirt_client.list_networks
|
156
|
-
inactive = libvirt_client.list_defined_networks
|
157
|
-
|
158
156
|
# Iterate over all (active and inactive) networks.
|
159
|
-
|
160
|
-
libvirt_network = libvirt_client.lookup_network_by_name(
|
161
|
-
network_name
|
162
|
-
)
|
157
|
+
driver.list_all_networks.each do |libvirt_network|
|
163
158
|
|
164
159
|
# Parse ip address and netmask from the network xml description.
|
165
160
|
xml = Nokogiri::XML(libvirt_network.xml_desc)
|
@@ -182,7 +177,7 @@ module VagrantPlugins
|
|
182
177
|
network_address = (network_address(ip, netmask) if ip && netmask)
|
183
178
|
|
184
179
|
libvirt_networks << {
|
185
|
-
name:
|
180
|
+
name: libvirt_network.name,
|
186
181
|
ip_address: ip,
|
187
182
|
netmask: netmask,
|
188
183
|
network_address: network_address,
|
data/lib/vagrant-libvirt/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.11.2
|
data/locales/en.yml
CHANGED
@@ -29,6 +29,8 @@ en:
|
|
29
29
|
Updating domain definition due to configuration change
|
30
30
|
starting_domain: |-
|
31
31
|
Starting domain.
|
32
|
+
starting_domain_with_graphics: |-
|
33
|
+
Domain launching with graphics connection settings...
|
32
34
|
terminating: |-
|
33
35
|
Removing domain...
|
34
36
|
poweroff_domain: |-
|
@@ -203,6 +205,8 @@ en:
|
|
203
205
|
states:
|
204
206
|
paused: |-
|
205
207
|
The Libvirt domain is suspended. Run `vagrant resume` to resume it.
|
208
|
+
pmsuspended: |-
|
209
|
+
The Libvirt domain is suspended. Run `vagrant resume` to resume it.
|
206
210
|
shutting_down: |-
|
207
211
|
The Libvirt domain is shutting down. Wait for it to complete and
|
208
212
|
then run `vagrant up` to start it or `vagrant destroy` to remove.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../spec_helper'
|
4
4
|
|
5
5
|
describe 'additional storage configured', acceptance: true do
|
6
6
|
include_context 'libvirt_acceptance'
|
@@ -25,8 +25,5 @@ describe 'additional storage configured', acceptance: true do
|
|
25
25
|
status('Test: reload handles additional storage correctly')
|
26
26
|
result = environment.execute('vagrant', 'reload')
|
27
27
|
expect(result).to exit_with(0)
|
28
|
-
|
29
|
-
status('Test: additional storage reported correctly')
|
30
|
-
expect(result.stdout).to match(/\(vdb\).*work_default-vdb\.qcow2/)
|
31
28
|
end
|
32
29
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../spec_helper'
|
4
|
+
|
5
|
+
describe 'package domain', acceptance: true do
|
6
|
+
include_context 'libvirt_acceptance'
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
expect(Vagrant::Util::Which.which('virsh')).to be_truthy,
|
10
|
+
'networking tests require virsh, please install'
|
11
|
+
expect(system('virsh --connect=qemu:///system uri >/dev/null')).to be_truthy,
|
12
|
+
'network tests require access to qemu:///system context, please ensure test user has correct permissions'
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:each) do
|
16
|
+
assert_execute('vagrant', 'destroy', '--force')
|
17
|
+
end
|
18
|
+
|
19
|
+
before do
|
20
|
+
environment.skeleton('network_no_autostart')
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when host is rebooted' do
|
24
|
+
before do
|
25
|
+
result = environment.execute('vagrant', 'up')
|
26
|
+
expect(result).to exit_with(0)
|
27
|
+
|
28
|
+
result = environment.execute('vagrant', 'halt')
|
29
|
+
expect(result).to exit_with(0)
|
30
|
+
|
31
|
+
result = environment.execute('virsh', '--connect=qemu:///system', 'net-destroy', 'vagrant-libvirt-test')
|
32
|
+
expect(result).to exit_with(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should start networking on restart' do
|
36
|
+
status('Test: machine restarts networking')
|
37
|
+
result = environment.execute('vagrant', 'up')
|
38
|
+
expect(result).to exit_with(0)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require_relative '../spec_helper'
|
4
4
|
|
5
5
|
describe 'package domain', acceptance: true do
|
6
6
|
include_context 'libvirt_acceptance'
|
@@ -49,7 +49,7 @@ describe 'package domain', acceptance: true do
|
|
49
49
|
status('Test: machine from packaged box is created successfully')
|
50
50
|
result = environment.execute('vagrant', 'up', extra_env: testbox_envvars)
|
51
51
|
expect(result).to exit_with(0)
|
52
|
-
expect(result.stdout).to match(/test-package-
|
52
|
+
expect(result.stdout).to match(/test-package-simple-domain/)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|