vagrant-libvirt 0.0.45 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +542 -167
  3. data/lib/vagrant-libvirt/action.rb +2 -2
  4. data/lib/vagrant-libvirt/action/create_domain.rb +112 -42
  5. data/lib/vagrant-libvirt/action/create_domain_volume.rb +14 -10
  6. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +8 -5
  7. data/lib/vagrant-libvirt/action/create_networks.rb +2 -2
  8. data/lib/vagrant-libvirt/action/destroy_domain.rb +1 -1
  9. data/lib/vagrant-libvirt/action/forward_ports.rb +10 -8
  10. data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
  11. data/lib/vagrant-libvirt/action/handle_box_image.rb +28 -60
  12. data/lib/vagrant-libvirt/action/handle_storage_pool.rb +4 -4
  13. data/lib/vagrant-libvirt/action/package_domain.rb +64 -12
  14. data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +3 -9
  15. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +19 -9
  16. data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +2 -2
  17. data/lib/vagrant-libvirt/action/remove_stale_volume.rb +17 -11
  18. data/lib/vagrant-libvirt/action/set_boot_order.rb +2 -2
  19. data/lib/vagrant-libvirt/action/set_name_of_domain.rb +6 -9
  20. data/lib/vagrant-libvirt/action/start_domain.rb +87 -30
  21. data/lib/vagrant-libvirt/action/wait_till_up.rb +10 -32
  22. data/lib/vagrant-libvirt/cap/public_address.rb +16 -0
  23. data/lib/vagrant-libvirt/cap/synced_folder.rb +3 -3
  24. data/lib/vagrant-libvirt/config.rb +294 -42
  25. data/lib/vagrant-libvirt/driver.rb +49 -34
  26. data/lib/vagrant-libvirt/errors.rb +5 -5
  27. data/lib/vagrant-libvirt/plugin.rb +7 -2
  28. data/lib/vagrant-libvirt/provider.rb +2 -9
  29. data/lib/vagrant-libvirt/templates/domain.xml.erb +52 -10
  30. data/lib/vagrant-libvirt/templates/public_interface.xml.erb +5 -1
  31. data/lib/vagrant-libvirt/util.rb +1 -0
  32. data/lib/vagrant-libvirt/util/erb_template.rb +6 -7
  33. data/lib/vagrant-libvirt/util/network_util.rb +6 -1
  34. data/lib/vagrant-libvirt/util/nfs.rb +17 -0
  35. data/lib/vagrant-libvirt/util/ui.rb +23 -0
  36. data/lib/vagrant-libvirt/version +1 -0
  37. data/lib/vagrant-libvirt/version.rb +72 -1
  38. data/locales/en.yml +6 -6
  39. data/spec/spec_helper.rb +28 -2
  40. data/spec/support/libvirt_context.rb +3 -1
  41. data/spec/support/sharedcontext.rb +7 -3
  42. data/spec/unit/action/create_domain_spec.rb +160 -0
  43. data/spec/unit/action/create_domain_spec/default_system_storage_pool.xml +17 -0
  44. data/spec/unit/action/create_domain_spec/default_user_storage_pool.xml +17 -0
  45. data/spec/unit/action/destroy_domain_spec.rb +2 -2
  46. data/spec/unit/action/set_name_of_domain_spec.rb +3 -3
  47. data/spec/unit/action/start_domain_spec.rb +231 -0
  48. data/spec/unit/action/start_domain_spec/clock_timer_rtc.xml +50 -0
  49. data/spec/unit/action/start_domain_spec/default.xml +48 -0
  50. data/spec/unit/action/start_domain_spec/default_added_tpm_path.xml +48 -0
  51. data/spec/unit/action/start_domain_spec/default_added_tpm_version.xml +48 -0
  52. data/spec/unit/action/wait_till_up_spec.rb +14 -9
  53. data/spec/unit/config_spec.rb +438 -0
  54. data/spec/unit/provider_spec.rb +11 -0
  55. data/spec/unit/templates/domain_all_settings.xml +20 -5
  56. data/spec/unit/templates/domain_custom_cpu_model.xml +4 -1
  57. data/spec/unit/templates/domain_defaults.xml +4 -1
  58. data/spec/unit/templates/domain_spec.rb +92 -4
  59. data/spec/unit/templates/tpm/version_1.2.xml +54 -0
  60. data/spec/unit/templates/tpm/version_2.0.xml +53 -0
  61. metadata +91 -36
  62. data/.coveralls.yml +0 -1
  63. data/.github/issue_template.md +0 -37
  64. data/.gitignore +0 -21
  65. data/.travis.yml +0 -24
  66. data/Gemfile +0 -26
  67. data/Rakefile +0 -8
  68. data/example_box/README.md +0 -29
  69. data/example_box/Vagrantfile +0 -60
  70. data/example_box/metadata.json +0 -5
  71. data/lib/vagrant-libvirt/templates/default_storage_volume.xml.erb +0 -14
  72. data/tools/create_box.sh +0 -130
  73. data/tools/prepare_redhat_for_box.sh +0 -119
  74. data/vagrant-libvirt.gemspec +0 -51
@@ -8,7 +8,7 @@ module VagrantPlugins
8
8
  include Vagrant::Action::Builtin
9
9
  @logger = Log4r::Logger.new('vagrant_libvirt::action')
10
10
 
11
- # remove image from libvirt storage pool
11
+ # remove image from Libvirt storage pool
12
12
  def self.remove_libvirt_image
13
13
  Vagrant::Action::Builder.new.tap do |b|
14
14
  b.use RemoveLibvirtImage
@@ -187,7 +187,7 @@ module VagrantPlugins
187
187
  b2.use Call, DestroyConfirm do |env2, b3|
188
188
  if env2[:result]
189
189
  b3.use ClearForwardedPorts
190
- # b3.use PruneNFSExports
190
+ b3.use PruneNFSExports
191
191
  b3.use DestroyDomain
192
192
  b3.use DestroyNetworks
193
193
  b3.use ProvisionerCleanup
@@ -5,6 +5,7 @@ module VagrantPlugins
5
5
  module Action
6
6
  class CreateDomain
7
7
  include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
8
+ include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
8
9
 
9
10
  def initialize(app, _env)
10
11
  @logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')
@@ -31,12 +32,19 @@ module VagrantPlugins
31
32
 
32
33
  # Gather some info about domain
33
34
  @name = env[:domain_name]
35
+ @title = config.title
36
+ @description = config.description
34
37
  @uuid = config.uuid
35
38
  @cpus = config.cpus.to_i
39
+ @cpuset = config.cpuset
36
40
  @cpu_features = config.cpu_features
37
41
  @cpu_topology = config.cpu_topology
42
+ @nodeset = config.nodeset
38
43
  @features = config.features
39
44
  @features_hyperv = config.features_hyperv
45
+ @clock_offset = config.clock_offset
46
+ @clock_timers = config.clock_timers
47
+ @shares = config.shares
40
48
  @cpu_mode = config.cpu_mode
41
49
  @cpu_model = config.cpu_model
42
50
  @cpu_fallback = config.cpu_fallback
@@ -47,11 +55,12 @@ module VagrantPlugins
47
55
  @machine_arch = config.machine_arch
48
56
  @disk_bus = config.disk_bus
49
57
  @disk_device = config.disk_device
58
+ @disk_driver_opts = config.disk_driver_opts
50
59
  @nested = config.nested
51
60
  @memory_size = config.memory.to_i * 1024
52
61
  @memory_backing = config.memory_backing
53
62
  @management_network_mac = config.management_network_mac
54
- @domain_volume_cache = config.volume_cache
63
+ @domain_volume_cache = config.volume_cache || 'default'
55
64
  @kernel = config.kernel
56
65
  @cmd_line = config.cmd_line
57
66
  @emulator_path = config.emulator_path
@@ -75,12 +84,14 @@ module VagrantPlugins
75
84
  @tpm_model = config.tpm_model
76
85
  @tpm_type = config.tpm_type
77
86
  @tpm_path = config.tpm_path
87
+ @tpm_version = config.tpm_version
78
88
 
79
89
  # Boot order
80
90
  @boot_order = config.boot_order
81
91
 
82
92
  # Storage
83
93
  @storage_pool_name = config.storage_pool_name
94
+ @snapshot_pool_name = config.snapshot_pool_name
84
95
  @disks = config.disks
85
96
  @cdroms = config.cdroms
86
97
 
@@ -106,6 +117,12 @@ module VagrantPlugins
106
117
  @redirdevs = config.redirdevs
107
118
  @redirfilters = config.redirfilters
108
119
 
120
+ # Additional QEMU commandline arguments
121
+ @qemu_args = config.qemu_args
122
+
123
+ # Additional QEMU commandline environment variables
124
+ @qemu_env = config.qemu_env
125
+
109
126
  # smartcard device
110
127
  @smartcard_dev = config.smartcard_dev
111
128
 
@@ -119,13 +136,15 @@ module VagrantPlugins
119
136
 
120
137
  # Get path to domain image from the storage pool selected if we have a box.
121
138
  if env[:machine].config.vm.box
122
- actual_volumes =
123
- env[:machine].provider.driver.connection.volumes.all.select do |x|
124
- x.pool_name == @storage_pool_name
125
- end
126
- domain_volume = ProviderLibvirt::Util::Collection.find_matching(
127
- actual_volumes, "#{@name}.img"
128
- )
139
+ if @snapshot_pool_name != @storage_pool_name
140
+ pool_name = @snapshot_pool_name
141
+ else
142
+ pool_name = @storage_pool_name
143
+ end
144
+ @logger.debug "Search for volume in pool: #{pool_name}"
145
+ domain_volume = env[:machine].provider.driver.connection.volumes.all(
146
+ name: "#{@name}.img"
147
+ ).find { |x| x.pool_name == pool_name }
129
148
  raise Errors::DomainVolumeExists if domain_volume.nil?
130
149
  @domain_volume_path = domain_volume.path
131
150
  end
@@ -133,15 +152,10 @@ module VagrantPlugins
133
152
  # If we have a box, take the path from the domain volume and set our storage_prefix.
134
153
  # If not, we dump the storage pool xml to get its defined path.
135
154
  # the default storage prefix is typically: /var/lib/libvirt/images/
136
- if !config.qemu_use_session
137
- if env[:machine].config.vm.box
138
- storage_prefix = File.dirname(@domain_volume_path) + '/' # steal
139
- else
140
- storage_pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(@storage_pool_name)
141
- raise Errors::NoStoragePool if storage_pool.nil?
142
- xml = Nokogiri::XML(storage_pool.xml_desc)
143
- storage_prefix = xml.xpath('/pool/target/path').inner_text.to_s + '/'
144
- end
155
+ if env[:machine].config.vm.box
156
+ storage_prefix = File.dirname(@domain_volume_path) + '/' # steal
157
+ else
158
+ storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
145
159
  end
146
160
 
147
161
  @disks.each do |disk|
@@ -155,35 +169,54 @@ module VagrantPlugins
155
169
 
156
170
  disk[:absolute_path] = storage_prefix + disk[:path]
157
171
 
158
- if env[:machine].provider.driver.connection.volumes.select do |x|
159
- x.name == disk[:name] && x.pool_name == @storage_pool_name
160
- end.empty?
161
- # make the disk. equivalent to:
162
- # qemu-img create -f qcow2 <path> 5g
163
- begin
164
- env[:machine].provider.driver.connection.volumes.create(
165
- name: disk[:name],
166
- format_type: disk[:type],
167
- path: disk[:absolute_path],
168
- capacity: disk[:size],
169
- #:allocation => ?,
170
- pool_name: @storage_pool_name
171
- )
172
- rescue Fog::Errors::Error => e
173
- raise Errors::FogDomainVolumeCreateError,
172
+ if not disk[:pool].nil?
173
+ disk_pool_name = disk[:pool]
174
+ @logger.debug "Overriding pool name with: #{disk_pool_name}"
175
+ disk_storage_prefix = get_disk_storage_prefix(env, disk_pool_name)
176
+ disk[:absolute_path] = disk_storage_prefix + disk[:path]
177
+ @logger.debug "Overriding disk path with: #{disk[:absolute_path]}"
178
+ else
179
+ disk_pool_name = @storage_pool_name
180
+ end
181
+
182
+ # make the disk. equivalent to:
183
+ # qemu-img create -f qcow2 <path> 5g
184
+ begin
185
+ env[:machine].provider.driver.connection.volumes.create(
186
+ name: disk[:name],
187
+ format_type: disk[:type],
188
+ path: disk[:absolute_path],
189
+ capacity: disk[:size],
190
+ owner: storage_uid(env),
191
+ group: storage_uid(env),
192
+ #:allocation => ?,
193
+ pool_name: disk_pool_name
194
+ )
195
+ rescue Libvirt::Error => e
196
+ # It is hard to believe that e contains just a string
197
+ # and no useful error code!
198
+ msg = "Call to virStorageVolCreateXML failed: " +
199
+ "storage volume '#{disk[:path]}' exists already"
200
+ if e.message == msg and disk[:allow_existing]
201
+ disk[:preexisting] = true
202
+ else
203
+ raise Errors::FogCreateDomainVolumeError,
174
204
  error_message: e.message
175
205
  end
176
- else
177
- disk[:preexisting] = true
178
206
  end
179
207
  end
180
208
 
181
209
  # Output the settings we're going to use to the user
182
210
  env[:ui].info(I18n.t('vagrant_libvirt.creating_domain'))
183
211
  env[:ui].info(" -- Name: #{@name}")
212
+ env[:ui].info(" -- Title: #{@title}") if @title != ''
213
+ env[:ui].info(" -- Description: #{@description}") if @description != ''
184
214
  env[:ui].info(" -- Forced UUID: #{@uuid}") if @uuid != ''
185
215
  env[:ui].info(" -- Domain type: #{@domain_type}")
186
216
  env[:ui].info(" -- Cpus: #{@cpus}")
217
+ unless @cpuset.nil?
218
+ env[:ui].info(" -- Cpuset: #{@cpuset}")
219
+ end
187
220
  if not @cpu_topology.empty?
188
221
  env[:ui].info(" -- CPU topology: sockets=#{@cpu_topology[:sockets]}, cores=#{@cpu_topology[:cores]}, threads=#{@cpu_topology[:threads]}")
189
222
  end
@@ -196,10 +229,20 @@ module VagrantPlugins
196
229
  @features_hyperv.each do |feature|
197
230
  env[:ui].info(" -- Feature (HyperV): name=#{feature[:name]}, state=#{feature[:state]}")
198
231
  end
232
+ env[:ui].info(" -- Clock offset: #{@clock_offset}")
233
+ @clock_timers.each do |timer|
234
+ env[:ui].info(" -- Clock timer: #{timer.map { |k,v| "#{k}=#{v}"}.join(', ')}")
235
+ end
199
236
  env[:ui].info(" -- Memory: #{@memory_size / 1024}M")
237
+ unless @nodeset.nil?
238
+ env[:ui].info(" -- Nodeset: #{@nodeset}")
239
+ end
200
240
  @memory_backing.each do |backing|
201
241
  env[:ui].info(" -- Memory Backing: #{backing[:name]}: #{backing[:config].map { |k,v| "#{k}='#{v}'"}.join(' ')}")
202
242
  end
243
+ unless @shares.nil?
244
+ env[:ui].info(" -- Shares: #{@shares}")
245
+ end
203
246
  env[:ui].info(" -- Management MAC: #{@management_network_mac}")
204
247
  env[:ui].info(" -- Loader: #{@loader}")
205
248
  env[:ui].info(" -- Nvram: #{@nvram}")
@@ -208,7 +251,13 @@ module VagrantPlugins
208
251
  end
209
252
  env[:ui].info(" -- Storage pool: #{@storage_pool_name}")
210
253
  env[:ui].info(" -- Image: #{@domain_volume_path} (#{env[:box_virtual_size]}G)")
211
- env[:ui].info(" -- Volume Cache: #{@domain_volume_cache}")
254
+
255
+ if not @disk_driver_opts.empty?
256
+ env[:ui].info(" -- Disk driver opts: #{@disk_driver_opts.reject { |k,v| v.nil? }.map { |k,v| "#{k}='#{v}'"}.join(' ')}")
257
+ else
258
+ env[:ui].info(" -- Disk driver opts: cache='#{@domain_volume_cache}'")
259
+ end
260
+
212
261
  env[:ui].info(" -- Kernel: #{@kernel}")
213
262
  env[:ui].info(" -- Initrd: #{@initrd}")
214
263
  env[:ui].info(" -- Graphics Type: #{@graphics_type}")
@@ -219,7 +268,13 @@ module VagrantPlugins
219
268
  env[:ui].info(" -- Video VRAM: #{@video_vram}")
220
269
  env[:ui].info(" -- Sound Type: #{@sound_type}")
221
270
  env[:ui].info(" -- Keymap: #{@keymap}")
222
- env[:ui].info(" -- TPM Path: #{@tpm_path}")
271
+ env[:ui].info(" -- TPM Backend: #{@tpm_type}")
272
+ if @tpm_type == 'emulator'
273
+ env[:ui].info(" -- TPM Model: #{@tpm_model}")
274
+ env[:ui].info(" -- TPM Version: #{@tpm_version}")
275
+ else
276
+ env[:ui].info(" -- TPM Path: #{@tpm_path}")
277
+ end
223
278
 
224
279
  @boot_order.each do |device|
225
280
  env[:ui].info(" -- Boot device: #{device}")
@@ -255,7 +310,7 @@ module VagrantPlugins
255
310
  end
256
311
 
257
312
  @pcis.each do |pci|
258
- env[:ui].info(" -- PCI passthrough: #{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
313
+ env[:ui].info(" -- PCI passthrough: #{pci[:domain]}:#{pci[:bus]}:#{pci[:slot]}.#{pci[:function]}")
259
314
  end
260
315
 
261
316
  unless @rng[:model].nil?
@@ -305,18 +360,25 @@ module VagrantPlugins
305
360
  env[:ui].info(" -- smartcard device: mode=#{@smartcard_dev[:mode]}, type=#{@smartcard_dev[:type]}")
306
361
  end
307
362
 
308
- @qargs = config.qemu_args
309
- if not @qargs.empty?
363
+ unless @qemu_args.empty?
310
364
  env[:ui].info(' -- Command line args: ')
311
- @qargs.each do |arg|
365
+ @qemu_args.each do |arg|
312
366
  msg = " -> value=#{arg[:value]}, "
313
367
  env[:ui].info(msg)
314
368
  end
315
369
  end
316
370
 
371
+ unless @qemu_env.empty?
372
+ env[:ui].info(' -- Command line environment variables: ')
373
+ @qemu_env.each do |env_var, env_value|
374
+ msg = " -> #{env_var}=#{env_value}, "
375
+ env[:ui].info(msg)
376
+ end
377
+ end
378
+
317
379
  env[:ui].info(" -- Command line : #{@cmd_line}") unless @cmd_line.empty?
318
380
 
319
- # Create libvirt domain.
381
+ # Create Libvirt domain.
320
382
  # Is there a way to tell fog to create new domain with already
321
383
  # existing volume? Use domain creation from template..
322
384
  begin
@@ -332,6 +394,14 @@ module VagrantPlugins
332
394
 
333
395
  @app.call(env)
334
396
  end
397
+
398
+ private
399
+ def get_disk_storage_prefix(env, disk_pool_name)
400
+ disk_storage_pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(disk_pool_name)
401
+ raise Errors::NoStoragePool if disk_storage_pool.nil?
402
+ xml = Nokogiri::XML(disk_storage_pool.xml_desc)
403
+ disk_storage_prefix = xml.xpath('/pool/target/path').inner_text.to_s + '/'
404
+ end
335
405
  end
336
406
  end
337
407
  end
@@ -25,15 +25,15 @@ module VagrantPlugins
25
25
  @name = "#{env[:domain_name]}.img"
26
26
 
27
27
  # Verify the volume doesn't exist already.
28
- domain_volume = ProviderLibvirt::Util::Collection.find_matching(
29
- env[:machine].provider.driver.connection.volumes.all, @name
30
- )
31
- raise Errors::DomainVolumeExists if domain_volume
28
+ domain_volume = env[:machine].provider.driver.connection.volumes.all(
29
+ name: @name
30
+ ).first
31
+ raise Errors::DomainVolumeExists if domain_volume && domain_volume.id
32
32
 
33
33
  # Get path to backing image - box volume.
34
- box_volume = ProviderLibvirt::Util::Collection.find_matching(
35
- env[:machine].provider.driver.connection.volumes.all, env[:box_volume_name]
36
- )
34
+ box_volume = env[:machine].provider.driver.connection.volumes.all(
35
+ name: env[:box_volume_name]
36
+ ).first
37
37
  @backing_file = box_volume.path
38
38
 
39
39
  # Virtual size of image. Take value worked out by HandleBoxImage
@@ -51,7 +51,6 @@ module VagrantPlugins
51
51
  xml.permissions do
52
52
  xml.owner storage_uid(env)
53
53
  xml.group storage_gid(env)
54
- xml.mode '0600'
55
54
  xml.label 'virt_image_t'
56
55
  end
57
56
  end
@@ -61,7 +60,6 @@ module VagrantPlugins
61
60
  xml.permissions do
62
61
  xml.owner storage_uid(env)
63
62
  xml.group storage_gid(env)
64
- xml.mode '0600'
65
63
  xml.label 'virt_image_t'
66
64
  end
67
65
  end
@@ -71,9 +69,15 @@ module VagrantPlugins
71
69
  Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS |
72
70
  Nokogiri::XML::Node::SaveOptions::FORMAT
73
71
  )
72
+ if config.snapshot_pool_name != config.storage_pool_name
73
+ pool_name = config.snapshot_pool_name
74
+ else
75
+ pool_name = config.storage_pool_name
76
+ end
77
+ @logger.debug "Using pool #{pool_name} for base box snapshot"
74
78
  domain_volume = env[:machine].provider.driver.connection.volumes.create(
75
79
  xml: xml,
76
- pool_name: config.storage_pool_name
80
+ pool_name: pool_name
77
81
  )
78
82
  rescue Fog::Errors::Error => e
79
83
  raise Errors::FogDomainVolumeCreateError,
@@ -95,6 +95,7 @@ module VagrantPlugins
95
95
  template_name = 'public_interface'
96
96
  @logger.info("Setting up public interface using device #{@device} in mode #{@mode}")
97
97
  @ovs = iface_configuration.fetch(:ovs, false)
98
+ @ovs_interfaceid = iface_configuration.fetch(:ovs_interfaceid, false)
98
99
  @trust_guest_rx_filters = iface_configuration.fetch(:trust_guest_rx_filters, false)
99
100
  # configuration for udp or tcp tunnel interfaces (p2p conn btwn guest OSes)
100
101
  elsif iface_configuration.fetch(:tunnel_type, nil)
@@ -219,10 +220,12 @@ module VagrantPlugins
219
220
  networks_to_configure << network
220
221
  end
221
222
 
222
- env[:ui].info I18n.t('vagrant.actions.vm.network.configuring')
223
- env[:machine].guest.capability(
224
- :configure_networks, networks_to_configure
225
- )
223
+ unless networks_to_configure.empty?
224
+ env[:ui].info I18n.t('vagrant.actions.vm.network.configuring')
225
+ env[:machine].guest.capability(
226
+ :configure_networks, networks_to_configure
227
+ )
228
+ end
226
229
 
227
230
  end
228
231
  end
@@ -281,7 +284,7 @@ module VagrantPlugins
281
284
  return options[:network_name]
282
285
  end
283
286
 
284
- # Get list of all (active and inactive) libvirt networks.
287
+ # Get list of all (active and inactive) Libvirt networks.
285
288
  available_networks = libvirt_networks(libvirt_client)
286
289
 
287
290
  return 'public' if options[:iface_type] == :public_network
@@ -47,9 +47,9 @@ module VagrantPlugins
47
47
  # should fix other methods so this doesn't have to be instance var
48
48
  @options = options
49
49
 
50
- # Get a list of all (active and inactive) libvirt networks. This
50
+ # Get a list of all (active and inactive) Libvirt networks. This
51
51
  # list is used throughout this class and should be easier to
52
- # process than libvirt API calls.
52
+ # process than Libvirt API calls.
53
53
  @available_networks = libvirt_networks(
54
54
  env[:machine].provider.driver.connection.client
55
55
  )
@@ -14,7 +14,7 @@ module VagrantPlugins
14
14
  env[:ui].info(I18n.t('vagrant_libvirt.destroy_domain'))
15
15
 
16
16
  # Must delete any snapshots before domain can be destroyed
17
- # Fog libvirt currently doesn't support snapshots. Use
17
+ # Fog Libvirt currently doesn't support snapshots. Use
18
18
  # ruby-libvirt client directly. Note this is racy, see
19
19
  # http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListNames
20
20
  libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(
@@ -54,7 +54,7 @@ module VagrantPlugins
54
54
 
55
55
  ssh_pid = redirect_port(
56
56
  @env[:machine],
57
- fp[:host_ip] || 'localhost',
57
+ fp[:host_ip] || '*',
58
58
  fp[:host],
59
59
  fp[:guest_ip] || @env[:machine].provider.ssh_info[:host],
60
60
  fp[:guest],
@@ -97,6 +97,8 @@ module VagrantPlugins
97
97
  User=#{ssh_info[:username]}
98
98
  Port=#{ssh_info[:port]}
99
99
  UserKnownHostsFile=/dev/null
100
+ ExitOnForwardFailure=yes
101
+ ControlMaster=no
100
102
  StrictHostKeyChecking=no
101
103
  PasswordAuthentication=no
102
104
  ForwardX11=#{ssh_info[:forward_x11] ? 'yes' : 'no'}
@@ -105,10 +107,10 @@ module VagrantPlugins
105
107
  "IdentityFile='\"#{pk}\"'"
106
108
  end).map { |s| s.prepend('-o ') }.join(' ')
107
109
 
108
- options += " -o ProxyCommand=\"#{ssh_info[:proxy_command]}\"" if machine.provider_config.connect_via_ssh
110
+ options += " -o ProxyCommand=\"#{ssh_info[:proxy_command]}\"" if machine.provider_config.proxy_command
109
111
 
110
112
  # TODO: instead of this, try and lock and get the stdin from spawn...
111
- ssh_cmd = 'exec '
113
+ ssh_cmd = ''
112
114
  if host_port <= 1024
113
115
  @@lock.synchronize do
114
116
  # TODO: add i18n
@@ -120,13 +122,13 @@ module VagrantPlugins
120
122
  end
121
123
  end
122
124
 
123
- ssh_cmd << "ssh #{options} #{params}"
125
+ ssh_cmd << "ssh -n #{options} #{params}"
124
126
 
125
127
  @logger.debug "Forwarding port with `#{ssh_cmd}`"
126
128
  log_file = ssh_forward_log_file(host_ip, host_port,
127
129
  guest_ip, guest_port)
128
130
  @logger.info "Logging to #{log_file}"
129
- spawn(ssh_cmd, [:out, :err] => [log_file, 'w'])
131
+ spawn(ssh_cmd, [:out, :err] => [log_file, 'w'], :pgroup => true)
130
132
  end
131
133
 
132
134
  def ssh_forward_log_file(host_ip, host_port, guest_ip, guest_port)
@@ -210,9 +212,9 @@ module VagrantPlugins
210
212
  end
211
213
 
212
214
  def ssh_pid?(pid)
213
- @logger.debug 'Checking if #{pid} is an ssh process '\
214
- 'with `ps -o cmd= #{pid}`'
215
- `ps -o cmd= #{pid}`.strip.chomp =~ /ssh/
215
+ @logger.debug "Checking if #{pid} is an ssh process "\
216
+ "with `ps -o command= #{pid}`"
217
+ `ps -o command= #{pid}`.strip.chomp =~ /ssh/
216
218
  end
217
219
 
218
220
  def remove_ssh_pids