Class: VagrantPlugins::ProviderLibvirt::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-libvirt/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/vagrant-libvirt/config.rb', line 118

def initialize
  @uri               = UNSET_VALUE
  @driver            = UNSET_VALUE
  @host              = UNSET_VALUE
  @connect_via_ssh   = UNSET_VALUE
  @username          = UNSET_VALUE
  @password          = UNSET_VALUE
  @id_ssh_key_file   = UNSET_VALUE
  @storage_pool_name = UNSET_VALUE
  @random_hostname   = UNSET_VALUE
  @management_network_name    = UNSET_VALUE
  @management_network_address = UNSET_VALUE
  @management_network_mode = UNSET_VALUE
  @management_network_mac  = UNSET_VALUE
  @management_network_guest_ipv6  = UNSET_VALUE

  # Domain specific settings.
  @uuid              = UNSET_VALUE
  @memory            = UNSET_VALUE
  @cpus              = UNSET_VALUE
  @cpu_mode          = UNSET_VALUE
  @cpu_model         = UNSET_VALUE
  @cpu_fallback      = UNSET_VALUE
  @cpu_features      = UNSET_VALUE
  @loader            = UNSET_VALUE
  @machine_type      = UNSET_VALUE
  @machine_arch      = UNSET_VALUE
  @machine_virtual_size = UNSET_VALUE
  @disk_bus          = UNSET_VALUE
  @nic_model_type    = UNSET_VALUE
  @nested            = UNSET_VALUE
  @volume_cache      = UNSET_VALUE
  @kernel            = UNSET_VALUE
  @initrd            = UNSET_VALUE
  @dtb               = UNSET_VALUE
  @cmd_line          = UNSET_VALUE
  @emulator_path     = UNSET_VALUE
  @graphics_type     = UNSET_VALUE
  @graphics_autoport = UNSET_VALUE
  @graphics_port     = UNSET_VALUE
  @graphics_ip       = UNSET_VALUE
  @graphics_passwd   = UNSET_VALUE
  @video_type        = UNSET_VALUE
  @video_vram        = UNSET_VALUE
  @keymap            = UNSET_VALUE
  @kvm_hidden        = UNSET_VALUE

  @tpm_model         = UNSET_VALUE
  @tpm_type          = UNSET_VALUE
  @tpm_path          = UNSET_VALUE

  @nic_adapter_count = UNSET_VALUE

  # Boot order
  @boot_order = []
  # Storage
  @disks             = []
  @cdroms			   = []

  # Inputs
  @inputs            = UNSET_VALUE

  # PCI device passthrough
  @pcis              = UNSET_VALUE

  # USB device passthrough
  @usbs              = UNSET_VALUE

  # Suspend mode
  @suspend_mode      = UNSET_VALUE

  # Autostart
  @autostart         = UNSET_VALUE
end

Instance Attribute Details

#autostartObject

Autostart



116
117
118
# File 'lib/vagrant-libvirt/config.rb', line 116

def autostart
  @autostart
end

#boot_orderObject

Returns the value of attribute boot_order.



65
66
67
# File 'lib/vagrant-libvirt/config.rb', line 65

def boot_order
  @boot_order
end

#cdromsObject

Returns the value of attribute cdroms.



101
102
103
# File 'lib/vagrant-libvirt/config.rb', line 101

def cdroms
  @cdroms
end

#cmd_lineObject

Returns the value of attribute cmd_line.



74
75
76
# File 'lib/vagrant-libvirt/config.rb', line 74

def cmd_line
  @cmd_line
end

#connect_via_sshObject

If use ssh tunnel to connect to Libvirt.



26
27
28
# File 'lib/vagrant-libvirt/config.rb', line 26

def connect_via_ssh
  @connect_via_ssh
end

#cpu_fallbackObject

Returns the value of attribute cpu_fallback.



62
63
64
# File 'lib/vagrant-libvirt/config.rb', line 62

def cpu_fallback
  @cpu_fallback
end

#cpu_featuresObject

Returns the value of attribute cpu_features.



63
64
65
# File 'lib/vagrant-libvirt/config.rb', line 63

def cpu_features
  @cpu_features
end

#cpu_modeObject

Returns the value of attribute cpu_mode.



60
61
62
# File 'lib/vagrant-libvirt/config.rb', line 60

def cpu_mode
  @cpu_mode
end

#cpu_modelObject

Returns the value of attribute cpu_model.



61
62
63
# File 'lib/vagrant-libvirt/config.rb', line 61

def cpu_model
  @cpu_model
end

#cpusObject

Returns the value of attribute cpus.



59
60
61
# File 'lib/vagrant-libvirt/config.rb', line 59

def cpus
  @cpus
end

#default_prefixObject

Default host prefix (alternative to use project folder name)



54
55
56
# File 'lib/vagrant-libvirt/config.rb', line 54

def default_prefix
  @default_prefix
end

#disk_busObject

Returns the value of attribute disk_bus.



69
70
71
# File 'lib/vagrant-libvirt/config.rb', line 69

def disk_bus
  @disk_bus
end

#disksObject

Storage



100
101
102
# File 'lib/vagrant-libvirt/config.rb', line 100

def disks
  @disks
end

#driverObject

A hypervisor name to access via Libvirt.



20
21
22
# File 'lib/vagrant-libvirt/config.rb', line 20

def driver
  @driver
end

#dtbObject

Returns the value of attribute dtb.



76
77
78
# File 'lib/vagrant-libvirt/config.rb', line 76

def dtb
  @dtb
end

#emulator_pathObject

Returns the value of attribute emulator_path.



77
78
79
# File 'lib/vagrant-libvirt/config.rb', line 77

def emulator_path
  @emulator_path
end

#graphics_autoportObject

Returns the value of attribute graphics_autoport.



79
80
81
# File 'lib/vagrant-libvirt/config.rb', line 79

def graphics_autoport
  @graphics_autoport
end

#graphics_ipObject

Returns the value of attribute graphics_ip.



82
83
84
# File 'lib/vagrant-libvirt/config.rb', line 82

def graphics_ip
  @graphics_ip
end

#graphics_passwdObject

Returns the value of attribute graphics_passwd.



81
82
83
# File 'lib/vagrant-libvirt/config.rb', line 81

def graphics_passwd
  @graphics_passwd
end

#graphics_portObject

Returns the value of attribute graphics_port.



80
81
82
# File 'lib/vagrant-libvirt/config.rb', line 80

def graphics_port
  @graphics_port
end

#graphics_typeObject

Returns the value of attribute graphics_type.



78
79
80
# File 'lib/vagrant-libvirt/config.rb', line 78

def graphics_type
  @graphics_type
end

#hostObject

The name of the server, where libvirtd is running.



23
24
25
# File 'lib/vagrant-libvirt/config.rb', line 23

def host
  @host
end

#id_ssh_key_fileObject

ID SSH key file



37
38
39
# File 'lib/vagrant-libvirt/config.rb', line 37

def id_ssh_key_file
  @id_ssh_key_file
end

#initrdObject

Returns the value of attribute initrd.



75
76
77
# File 'lib/vagrant-libvirt/config.rb', line 75

def initrd
  @initrd
end

#inputsObject

Inputs



104
105
106
# File 'lib/vagrant-libvirt/config.rb', line 104

def inputs
  @inputs
end

#kernelObject

Returns the value of attribute kernel.



73
74
75
# File 'lib/vagrant-libvirt/config.rb', line 73

def kernel
  @kernel
end

#keymapObject

Returns the value of attribute keymap.



85
86
87
# File 'lib/vagrant-libvirt/config.rb', line 85

def keymap
  @keymap
end

#kvm_hiddenObject

Returns the value of attribute kvm_hidden.



86
87
88
# File 'lib/vagrant-libvirt/config.rb', line 86

def kvm_hidden
  @kvm_hidden
end

#loaderObject

Returns the value of attribute loader.



64
65
66
# File 'lib/vagrant-libvirt/config.rb', line 64

def loader
  @loader
end

#machine_archObject

Returns the value of attribute machine_arch.



67
68
69
# File 'lib/vagrant-libvirt/config.rb', line 67

def machine_arch
  @machine_arch
end

#machine_typeObject

Returns the value of attribute machine_type.



66
67
68
# File 'lib/vagrant-libvirt/config.rb', line 66

def machine_type
  @machine_type
end

#machine_virtual_sizeObject

Returns the value of attribute machine_virtual_size.



68
69
70
# File 'lib/vagrant-libvirt/config.rb', line 68

def machine_virtual_size
  @machine_virtual_size
end

#management_network_addressObject

Returns the value of attribute management_network_address.



48
49
50
# File 'lib/vagrant-libvirt/config.rb', line 48

def management_network_address
  @management_network_address
end

#management_network_guest_ipv6Object

Returns the value of attribute management_network_guest_ipv6.



51
52
53
# File 'lib/vagrant-libvirt/config.rb', line 51

def management_network_guest_ipv6
  @management_network_guest_ipv6
end

#management_network_macObject

Returns the value of attribute management_network_mac.



50
51
52
# File 'lib/vagrant-libvirt/config.rb', line 50

def management_network_mac
  @management_network_mac
end

#management_network_modeObject

Returns the value of attribute management_network_mode.



49
50
51
# File 'lib/vagrant-libvirt/config.rb', line 49

def management_network_mode
  @management_network_mode
end

#management_network_nameObject

Libvirt default network



47
48
49
# File 'lib/vagrant-libvirt/config.rb', line 47

def management_network_name
  @management_network_name
end

#memoryObject

Returns the value of attribute memory.



58
59
60
# File 'lib/vagrant-libvirt/config.rb', line 58

def memory
  @memory
end

#nestedObject

Returns the value of attribute nested.



71
72
73
# File 'lib/vagrant-libvirt/config.rb', line 71

def nested
  @nested
end

#nic_adapter_countObject

Sets the max number of NICs that can be created Default set to 8. Don’t change the default unless you know what are doing



97
98
99
# File 'lib/vagrant-libvirt/config.rb', line 97

def nic_adapter_count
  @nic_adapter_count
end

#nic_model_typeObject

Returns the value of attribute nic_model_type.



70
71
72
# File 'lib/vagrant-libvirt/config.rb', line 70

def nic_model_type
  @nic_model_type
end

#passwordObject

Password for Libvirt connection.



34
35
36
# File 'lib/vagrant-libvirt/config.rb', line 34

def password
  @password
end

#pcisObject

PCI device passthrough



107
108
109
# File 'lib/vagrant-libvirt/config.rb', line 107

def pcis
  @pcis
end

#random_hostnameObject

Turn on to prevent hostname conflicts



44
45
46
# File 'lib/vagrant-libvirt/config.rb', line 44

def random_hostname
  @random_hostname
end

#socketObject

Path towards the libvirt socket



28
29
30
# File 'lib/vagrant-libvirt/config.rb', line 28

def socket
  @socket
end

#storage_pool_nameObject

Libvirt storage pool name, where box image and instance snapshots will be stored.



41
42
43
# File 'lib/vagrant-libvirt/config.rb', line 41

def storage_pool_name
  @storage_pool_name
end

#suspend_modeObject

Suspend mode



113
114
115
# File 'lib/vagrant-libvirt/config.rb', line 113

def suspend_mode
  @suspend_mode
end

#tpm_modelObject

Sets the information for connecting to a host TPM device Only supports socket-based TPMs



90
91
92
# File 'lib/vagrant-libvirt/config.rb', line 90

def tpm_model
  @tpm_model
end

#tpm_pathObject

Returns the value of attribute tpm_path.



92
93
94
# File 'lib/vagrant-libvirt/config.rb', line 92

def tpm_path
  @tpm_path
end

#tpm_typeObject

Returns the value of attribute tpm_type.



91
92
93
# File 'lib/vagrant-libvirt/config.rb', line 91

def tpm_type
  @tpm_type
end

#uriObject

manually specify URI will supercede most other options if provided



17
18
19
# File 'lib/vagrant-libvirt/config.rb', line 17

def uri
  @uri
end

#usbsObject

USB device passthrough



110
111
112
# File 'lib/vagrant-libvirt/config.rb', line 110

def usbs
  @usbs
end

#usernameObject

The username to access Libvirt.



31
32
33
# File 'lib/vagrant-libvirt/config.rb', line 31

def username
  @username
end

#uuidObject

Domain specific settings used while creating new domain.



57
58
59
# File 'lib/vagrant-libvirt/config.rb', line 57

def uuid
  @uuid
end

#video_typeObject

Returns the value of attribute video_type.



83
84
85
# File 'lib/vagrant-libvirt/config.rb', line 83

def video_type
  @video_type
end

#video_vramObject

Returns the value of attribute video_vram.



84
85
86
# File 'lib/vagrant-libvirt/config.rb', line 84

def video_vram
  @video_vram
end

#volume_cacheObject

Returns the value of attribute volume_cache.



72
73
74
# File 'lib/vagrant-libvirt/config.rb', line 72

def volume_cache
  @volume_cache
end

Instance Method Details

#_generate_uriObject

code to generate URI from a config moved out of the connect action



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/vagrant-libvirt/config.rb', line 352

def _generate_uri
  # builds the libvirt connection URI from the given driver config
  # Setup connection uri.
  uri = @driver.dup
  virt_path = case uri
  when 'qemu', 'openvz', 'uml', 'phyp', 'parallels', 'kvm'
    '/system'
  when '@en', 'esx'
    '/'
  when 'vbox', 'vmwarews', 'hyperv'
    '/session'
  else
    raise "Require specify driver #{uri}"
  end
  if uri == 'kvm'
    uri = 'qemu'	# use qemu uri for kvm domain type
  end

  if @connect_via_ssh
    uri << '+ssh://'
    if @username
      uri << @username + '@'
    end

    if @host
      uri << @host
    else
      uri << 'localhost'
    end
  else
    uri << '://'
    uri << @host if @host
  end

  uri << virt_path
  uri << '?no_verify=1'

  if @id_ssh_key_file
    # set ssh key for access to libvirt host
    uri << "\&keyfile="
    # if no slash, prepend $HOME/.ssh/
    @id_ssh_key_file.prepend("#{`echo ${HOME}`.chomp}/.ssh/") if @id_ssh_key_file !~ /\A\//
    uri << @id_ssh_key_file
  end
  # set path to libvirt socket
  uri << "\&socket="+@socket if @socket
  return uri
end

#_get_cdrom_dev(cdroms) ⇒ Object



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/vagrant-libvirt/config.rb', line 210

def _get_cdrom_dev(cdroms)
  exist = Hash[cdroms.collect{|x| [x[:dev],true]}]
  # hda - hdc
  curr = "a".ord
  while curr <= "d".ord
    dev = "hd" + curr.chr
    if exist[dev]
      curr += 1
      next
    else
      return dev
    end
  end

  # is it better to raise our own error, or let libvirt cause the exception?
  raise 'Only four cdroms may be attached at a time'
end

#_get_device(disks) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/vagrant-libvirt/config.rb', line 197

def _get_device(disks)
  # skip existing devices and also the first one (vda)
  exist = disks.collect {|x| x[:device]}+[1.vdev.to_s]
  skip = 1		# we're 1 based, not 0 based...
  while true do
    dev = skip.vdev	# get lettered device
    if !exist.include?(dev)
      return dev
    end
    skip+=1
  end
end

#_handle_cdrom_storage(options = {}) ⇒ Object



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/vagrant-libvirt/config.rb', line 303

def _handle_cdrom_storage(options={})
  # <disk type="file" device="cdrom">
  #   <source file="/home/user/virtio-win-0.1-100.iso"/>
  #   <target dev="hdc"/>
  #   <readonly/>
  #   <address type='drive' controller='0' bus='1' target='0' unit='0'/>
  # </disk>
  #
  # note the target dev will need to be changed with each cdrom drive (hdc, hdd, etc),
  # as will the address unit number (unit=0, unit=1, etc)

  options = {
    :dev => self._get_cdrom_dev(@cdroms),
    :bus => "ide",
    :path => nil,
  }.merge(options)

  cdrom = {
    :dev => options[:dev],
    :bus => options[:bus],
    :path => options[:path]
  }

  @cdroms << cdrom
end

#_handle_disk_storage(options = {}) ⇒ Object



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/vagrant-libvirt/config.rb', line 329

def _handle_disk_storage(options={})
  options = {
    :device => _get_device(@disks),
    :type => 'qcow2',
    :size => '10G',	# matches the fog default
    :path => nil,
    :bus => 'virtio'
  }.merge(options)

  disk = {
    :device => options[:device],
    :type => options[:type],
    :size => options[:size],
    :path => options[:path],
    :bus => options[:bus],
    :cache => options[:cache] || 'default',
    :allow_existing => options[:allow_existing],
  }

  @disks << disk	# append
end

#boot(device) ⇒ Object



193
194
195
# File 'lib/vagrant-libvirt/config.rb', line 193

def boot(device)
  @boot_order << device	# append
end

#cpu_feature(options = {}) ⇒ Object



228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/vagrant-libvirt/config.rb', line 228

def cpu_feature(options={})
  if options[:name].nil? || options[:policy].nil?
    raise 'CPU Feature name AND policy must be specified'
  end

  if @cpu_features == UNSET_VALUE
    @cpu_features = []
  end

  @cpu_features.push({
    name:   options[:name],
    policy: options[:policy]
  })
end

#finalize!Object



401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/vagrant-libvirt/config.rb', line 401

def finalize!
  @driver = 'kvm' if @driver == UNSET_VALUE
  @host = nil if @host == UNSET_VALUE
  @connect_via_ssh = false if @connect_via_ssh == UNSET_VALUE
  @username = nil if @username == UNSET_VALUE
  @password = nil if @password == UNSET_VALUE
  @id_ssh_key_file = 'id_rsa' if @id_ssh_key_file == UNSET_VALUE
  @storage_pool_name = 'default' if @storage_pool_name == UNSET_VALUE
  @random_hostname = false if @random_hostname == UNSET_VALUE
  @management_network_name = 'vagrant-libvirt' if @management_network_name == UNSET_VALUE
  @management_network_address = '192.168.121.0/24' if @management_network_address == UNSET_VALUE
  @management_network_mode = 'nat' if @management_network_mode == UNSET_VALUE
  @management_network_mac = nil if @management_network_mac == UNSET_VALUE
  @management_network_guest_ipv6 = 'yes' if @management_network_guest_ipv6 == UNSET_VALUE

  # generate a URI if none is supplied
  @uri = _generate_uri() if @uri == UNSET_VALUE

  # Domain specific settings.
  @uuid = '' if @uuid == UNSET_VALUE
  @memory = 512 if @memory == UNSET_VALUE
  @cpus = 1 if @cpus == UNSET_VALUE
  @cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE
  @cpu_model = 'qemu64' if @cpu_model == UNSET_VALUE
  @cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE
  @cpu_features = [] if @cpu_features == UNSET_VALUE
  @loader = nil if @loader == UNSET_VALUE
  @machine_type = nil if @machine_type == UNSET_VALUE
  @machine_arch = nil if @machine_arch == UNSET_VALUE
  @machine_virtual_size = nil if @machine_virtual_size == UNSET_VALUE
  @disk_bus = 'virtio' if @disk_bus == UNSET_VALUE
  @nic_model_type = 'virtio' if @nic_model_type == UNSET_VALUE
  @nested = false if @nested == UNSET_VALUE
  @volume_cache = 'default' if @volume_cache == UNSET_VALUE
  @kernel = nil if @kernel == UNSET_VALUE
  @cmd_line = '' if @cmd_line == UNSET_VALUE
  @initrd = '' if @initrd == UNSET_VALUE
  @dtb = nil if @dtb == UNSET_VALUE
  @graphics_type = 'vnc' if @graphics_type == UNSET_VALUE
  @graphics_autoport = 'yes' if @graphics_port == UNSET_VALUE
  @graphics_autoport = 'no' if @graphics_port != UNSET_VALUE
  if (@graphics_type != 'vnc' && @graphics_type != 'spice') ||
      @graphics_passwd == UNSET_VALUE
    @graphics_passwd = nil
  end
  @graphics_port = 5900 if @graphics_port == UNSET_VALUE
  @graphics_ip = '127.0.0.1' if @graphics_ip == UNSET_VALUE
  @video_type = 'cirrus' if @video_type == UNSET_VALUE
  @video_vram = 9216 if @video_vram == UNSET_VALUE
  @keymap = 'en-us' if @keymap == UNSET_VALUE
  @kvm_hidden = false if @kvm_hidden == UNSET_VALUE
  @tpm_model = 'tpm-tis' if @tpm_model == UNSET_VALUE
  @tpm_type = 'passthrough' if @tpm_type == UNSET_VALUE
  @tpm_path = nil if @tpm_path == UNSET_VALUE
  @nic_adapter_count = 8 if @nic_adapter_count == UNSET_VALUE
  @emulator_path = nil if @emulator_path == UNSET_VALUE

  # Boot order
  @boot_order = [] if @boot_order == UNSET_VALUE

  # Storage
  @disks = [] if @disks == UNSET_VALUE
  @cdroms = [] if @cdroms == UNSET_VALUE

  # Inputs
  @inputs = [{:type => "mouse", :bus => "ps2"}] if @inputs == UNSET_VALUE

  # PCI device passthrough
  @pcis = [] if @pcis == UNSET_VALUE

  # USB device passthrough
  @usbs = [] if @usbs == UNSET_VALUE

  # Suspend mode
  @suspend_mode = "pause" if @suspend_mode == UNSET_VALUE

  # Autostart
  @autostart = false if @autostart == UNSET_VALUE
end

#input(options = {}) ⇒ Object



243
244
245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/vagrant-libvirt/config.rb', line 243

def input(options={})
  if options[:type].nil? || options[:bus].nil?
    raise 'Input type AND bus must be specified'
  end

  if @inputs == UNSET_VALUE
    @inputs = []
  end

  @inputs.push({
    type: options[:type],
    bus:  options[:bus]
  })
end

#merge(other) ⇒ Object



493
494
495
496
497
498
499
# File 'lib/vagrant-libvirt/config.rb', line 493

def merge(other)
  super.tap do |result|
    c = disks.dup
    c += other.disks
    result.disks = c
  end
end

#pci(options = {}) ⇒ Object



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/vagrant-libvirt/config.rb', line 258

def pci(options={})
  if options[:bus].nil? || options[:slot].nil? || options[:function].nil?
    raise 'Bus AND slot AND function must be specified. Check `lspci` for that numbers.'
  end

  if @pcis == UNSET_VALUE
    @pcis = []
  end

  @pcis.push({
    bus:       options[:bus],
    slot:      options[:slot],
    function:  options[:function]
  })
end

#storage(storage_type, options = {}) ⇒ Object

NOTE: this will run twice for each time it’s needed- keep it idempotent



293
294
295
296
297
298
299
300
301
# File 'lib/vagrant-libvirt/config.rb', line 293

def storage(storage_type, options={})
  if storage_type == :file
    if options[:device] == :cdrom
      _handle_cdrom_storage(options)
    else
      _handle_disk_storage(options)
    end
  end
end

#usb(options = {}) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/vagrant-libvirt/config.rb', line 274

def usb(options={})
  if (options[:bus].nil? || options[:device].nil?) && options[:vendor].nil? && options[:product].nil?
    raise 'Bus and device and/or vendor and/or product must be specified. Check `lsusb` for these.'
  end

  if @usbs == UNSET_VALUE
    @usbs = []
  end

  @usbs.push({
    bus:           options[:bus],
    device:        options[:device],
    vendor:        options[:vendor],
    product:       options[:product],
    startupPolicy: options[:startupPolicy],
  })
end

#validate(machine) ⇒ Object



481
482
483
484
485
486
487
488
489
490
491
# File 'lib/vagrant-libvirt/config.rb', line 481

def validate(machine)
  errors = _detected_errors

  machine.provider_config.disks.each do |disk|
    if disk[:path] and disk[:path][0] == '/'
      errors << "absolute volume paths like '#{disk[:path]}' not yet supported"
    end
  end

   { "Libvirt Provider" => errors }
end