mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Can now specify inputs for the VM. E.g.
```ruby Vagrant.configure("2") do |config| config.vm.provider :libvirt do |libvirt| # very useful when having mouse issues when viewing VMs via VNC libvirt.input :type => "tablet", :bus => "usb" end end ```
This commit is contained in:
parent
57c860e884
commit
d82c1a3f95
20
README.md
20
README.md
@ -333,6 +333,26 @@ Vagrant.configure("2") do |config|
|
||||
end
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
You can multiple inputs to the VM via `libvirt.input`. Available options are
|
||||
listed below. Note that both options are required:
|
||||
|
||||
* `type` - The type of the input
|
||||
* `bus` - The bust of the input
|
||||
|
||||
```ruby
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.provider :libvirt do |libvirt|
|
||||
# this is the default
|
||||
# libvirt.input :type => "mouse", :bus => "ps2"
|
||||
|
||||
# very useful when having mouse issues when viewing VM via VNC
|
||||
libvirt.input :type => "tablet", :bus => "usb"
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
## SSH Access To VM
|
||||
|
||||
vagrant-libvirt supports vagrant's [standard ssh settings](https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html).
|
||||
|
@ -58,6 +58,9 @@ module VagrantPlugins
|
||||
@disks = config.disks
|
||||
@cdroms = config.cdroms
|
||||
|
||||
# Input
|
||||
@inputs = config.inputs
|
||||
|
||||
config = env[:machine].provider_config
|
||||
@domain_type = config.driver
|
||||
|
||||
@ -133,6 +136,9 @@ module VagrantPlugins
|
||||
@cdroms.each do |cdrom|
|
||||
env[:ui].info(" -- CDROM(#{cdrom[:dev]}): #{cdrom[:path]}")
|
||||
end
|
||||
@inputs.each do |input|
|
||||
env[:ui].info(" -- INPUT(type=#{input[:type]}, bus=#{input[:bus]})")
|
||||
end
|
||||
env[:ui].info(" -- Command line : #{@cmd_line}")
|
||||
|
||||
# Create libvirt domain.
|
||||
|
@ -76,6 +76,9 @@ module VagrantPlugins
|
||||
attr_accessor :disks
|
||||
attr_accessor :cdroms
|
||||
|
||||
# Inputs
|
||||
attr_accessor :inputs
|
||||
|
||||
def initialize
|
||||
@uri = UNSET_VALUE
|
||||
@driver = UNSET_VALUE
|
||||
@ -113,7 +116,10 @@ module VagrantPlugins
|
||||
|
||||
# Storage
|
||||
@disks = []
|
||||
@cdroms = []
|
||||
@cdroms = []
|
||||
|
||||
# Inputs
|
||||
@inputs = UNSET_VALUE
|
||||
end
|
||||
|
||||
def _get_device(disks)
|
||||
@ -147,6 +153,21 @@ module VagrantPlugins
|
||||
raise "Only four cdroms may be attached at a time"
|
||||
end
|
||||
|
||||
def input(options={})
|
||||
if options[:type] == nil or 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
|
||||
|
||||
# NOTE: this will run twice for each time it's needed- keep it idempotent
|
||||
def storage(storage_type, options={})
|
||||
if storage_type == :file
|
||||
@ -297,6 +318,7 @@ module VagrantPlugins
|
||||
# Storage
|
||||
@disks = [] if @disks == UNSET_VALUE
|
||||
@cdroms = [] if @cdroms == UNSET_VALUE
|
||||
@inputs = [{:type => "mouse", :bus => "ps2"}] if @inputs == UNSET_VALUE
|
||||
end
|
||||
|
||||
def validate(machine)
|
||||
|
@ -63,7 +63,11 @@
|
||||
<console type='pty'>
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
|
||||
<% @inputs.each do |input| %>
|
||||
<input type='<%= input[:type] %>' bus='<%= input[:bus] %>'/>
|
||||
<% end %>
|
||||
|
||||
<%# Video device -%>
|
||||
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd%> />
|
||||
<video>
|
||||
|
Loading…
Reference in New Issue
Block a user