mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Merge pull request #440 from d0c-s4vage/feature-inputs
Added ability to specify inputs for the VM via the Vagrantfile
This commit is contained in:
commit
e7450a6723
20
README.md
20
README.md
@ -404,6 +404,26 @@ Vagrant.configure("2") do |config|
|
||||
end
|
||||
```
|
||||
|
||||
## Input
|
||||
|
||||
You can specify 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).
|
||||
|
@ -63,6 +63,9 @@ module VagrantPlugins
|
||||
@disks = config.disks
|
||||
@cdroms = config.cdroms
|
||||
|
||||
# Input
|
||||
@inputs = config.inputs
|
||||
|
||||
config = env[:machine].provider_config
|
||||
@domain_type = config.driver
|
||||
|
||||
@ -154,7 +157,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.
|
||||
|
@ -84,6 +84,9 @@ module VagrantPlugins
|
||||
attr_accessor :disks
|
||||
attr_accessor :cdroms
|
||||
|
||||
# Inputs
|
||||
attr_accessor :inputs
|
||||
|
||||
def initialize
|
||||
@uri = UNSET_VALUE
|
||||
@driver = UNSET_VALUE
|
||||
@ -128,6 +131,9 @@ module VagrantPlugins
|
||||
# Storage
|
||||
@disks = []
|
||||
@cdroms = []
|
||||
|
||||
# Inputs
|
||||
@inputs = UNSET_VALUE
|
||||
end
|
||||
|
||||
def boot(device)
|
||||
@ -165,6 +171,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
|
||||
@ -324,6 +345,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)
|
||||
|
@ -78,7 +78,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>
|
||||
|
@ -19,7 +19,7 @@ class EnvironmentHelper
|
||||
1024
|
||||
end
|
||||
|
||||
%w(cpus cpu_mode boot_order machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
|
||||
%w(cpus cpu_mode boot_order machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver inputs).each do |name|
|
||||
define_method(name.to_sym) do
|
||||
nil
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user