mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
USB controller configuration (#861)
* Add USB controller configuration * Update README with USB controller configuration info * Rename USB controller parameter to usb_controller * Code style fixup
This commit is contained in:
committed by
Dmitry Vasilets
parent
c3e46a1f23
commit
60e93d4925
@@ -95,6 +95,9 @@ module VagrantPlugins
|
||||
# Watchdog device
|
||||
@watchdog_dev = config.watchdog_dev
|
||||
|
||||
# USB controller
|
||||
@usbctl_dev = config.usbctl_dev
|
||||
|
||||
# USB device passthrough
|
||||
@usbs = config.usbs
|
||||
|
||||
@@ -260,6 +263,12 @@ module VagrantPlugins
|
||||
env[:ui].info(" -- Watchdog device: model=#{@watchdog_dev[:model]}, action=#{@watchdog_dev[:action]}")
|
||||
end
|
||||
|
||||
if not @usbctl_dev.empty?
|
||||
msg = " -- USB controller: model=#{@usbctl_dev[:model]}"
|
||||
msg += ", ports=#{@usbctl_dev[:ports]}" if @usbctl_dev[:ports]
|
||||
env[:ui].info(msg)
|
||||
end
|
||||
|
||||
@usbs.each do |usb|
|
||||
usb_dev = []
|
||||
usb_dev.push("bus=#{usb[:bus]}") if usb[:bus]
|
||||
|
||||
@@ -132,6 +132,9 @@ module VagrantPlugins
|
||||
# Watchdog device
|
||||
attr_accessor :watchdog_dev
|
||||
|
||||
# USB controller
|
||||
attr_accessor :usbctl_dev
|
||||
|
||||
# USB device passthrough
|
||||
attr_accessor :usbs
|
||||
|
||||
@@ -245,6 +248,9 @@ module VagrantPlugins
|
||||
# Watchdog device
|
||||
@watchdog_dev = UNSET_VALUE
|
||||
|
||||
# USB controller
|
||||
@usbctl_dev = UNSET_VALUE
|
||||
|
||||
# USB device passthrough
|
||||
@usbs = UNSET_VALUE
|
||||
|
||||
@@ -434,6 +440,19 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
|
||||
def usb_controller(options = {})
|
||||
if options[:model].nil?
|
||||
raise 'USB controller model must be specified.'
|
||||
end
|
||||
|
||||
if @usbctl_dev == UNSET_VALUE
|
||||
@usbctl_dev = {}
|
||||
end
|
||||
|
||||
@usbctl_dev[:model] = options[:model]
|
||||
@usbctl_dev[:ports] = options[:ports]
|
||||
end
|
||||
|
||||
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.'
|
||||
@@ -709,6 +728,9 @@ module VagrantPlugins
|
||||
# Watchdog device
|
||||
@watchdog_dev = {} if @watchdog_dev == UNSET_VALUE
|
||||
|
||||
# USB controller
|
||||
@usbctl_dev = {} if @usbctl_dev == UNSET_VALUE
|
||||
|
||||
# USB device passthrough
|
||||
@usbs = [] if @usbs == UNSET_VALUE
|
||||
|
||||
|
||||
@@ -243,6 +243,10 @@
|
||||
</backend>
|
||||
</tpm>
|
||||
<% end -%>
|
||||
<% if not @usbctl_dev.empty? %>
|
||||
<%# USB Controller -%>
|
||||
<controller type='usb' model='<%= @usbctl_dev[:model] %>' <%= "ports=\"#{@usbctl_dev[:ports]}\" " if @usbctl_dev[:ports] %>/>
|
||||
<% end %>
|
||||
</devices>
|
||||
|
||||
<% unless @qargs.empty? %>
|
||||
|
||||
Reference in New Issue
Block a user