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
|
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
|
## SSH Access To VM
|
||||||
|
|
||||||
vagrant-libvirt supports vagrant's [standard ssh settings](https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html).
|
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
|
@disks = config.disks
|
||||||
@cdroms = config.cdroms
|
@cdroms = config.cdroms
|
||||||
|
|
||||||
|
# Input
|
||||||
|
@inputs = config.inputs
|
||||||
|
|
||||||
config = env[:machine].provider_config
|
config = env[:machine].provider_config
|
||||||
@domain_type = config.driver
|
@domain_type = config.driver
|
||||||
|
|
||||||
@ -154,7 +157,9 @@ module VagrantPlugins
|
|||||||
@cdroms.each do |cdrom|
|
@cdroms.each do |cdrom|
|
||||||
env[:ui].info(" -- CDROM(#{cdrom[:dev]}): #{cdrom[:path]}")
|
env[:ui].info(" -- CDROM(#{cdrom[:dev]}): #{cdrom[:path]}")
|
||||||
end
|
end
|
||||||
|
@inputs.each do |input|
|
||||||
|
env[:ui].info(" -- INPUT(type=#{input[:type]}, bus=#{input[:bus]})")
|
||||||
|
end
|
||||||
env[:ui].info(" -- Command line : #{@cmd_line}")
|
env[:ui].info(" -- Command line : #{@cmd_line}")
|
||||||
|
|
||||||
# Create libvirt domain.
|
# Create libvirt domain.
|
||||||
|
@ -84,6 +84,9 @@ module VagrantPlugins
|
|||||||
attr_accessor :disks
|
attr_accessor :disks
|
||||||
attr_accessor :cdroms
|
attr_accessor :cdroms
|
||||||
|
|
||||||
|
# Inputs
|
||||||
|
attr_accessor :inputs
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@uri = UNSET_VALUE
|
@uri = UNSET_VALUE
|
||||||
@driver = UNSET_VALUE
|
@driver = UNSET_VALUE
|
||||||
@ -127,7 +130,10 @@ module VagrantPlugins
|
|||||||
@boot_order = []
|
@boot_order = []
|
||||||
# Storage
|
# Storage
|
||||||
@disks = []
|
@disks = []
|
||||||
@cdroms = []
|
@cdroms = []
|
||||||
|
|
||||||
|
# Inputs
|
||||||
|
@inputs = UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
def boot(device)
|
def boot(device)
|
||||||
@ -165,6 +171,21 @@ module VagrantPlugins
|
|||||||
raise "Only four cdroms may be attached at a time"
|
raise "Only four cdroms may be attached at a time"
|
||||||
end
|
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
|
# NOTE: this will run twice for each time it's needed- keep it idempotent
|
||||||
def storage(storage_type, options={})
|
def storage(storage_type, options={})
|
||||||
if storage_type == :file
|
if storage_type == :file
|
||||||
@ -324,6 +345,7 @@ module VagrantPlugins
|
|||||||
# Storage
|
# Storage
|
||||||
@disks = [] if @disks == UNSET_VALUE
|
@disks = [] if @disks == UNSET_VALUE
|
||||||
@cdroms = [] if @cdroms == UNSET_VALUE
|
@cdroms = [] if @cdroms == UNSET_VALUE
|
||||||
|
@inputs = [{:type => "mouse", :bus => "ps2"}] if @inputs == UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
|
@ -78,7 +78,11 @@
|
|||||||
<console type='pty'>
|
<console type='pty'>
|
||||||
<target port='0'/>
|
<target port='0'/>
|
||||||
</console>
|
</console>
|
||||||
<input type='mouse' bus='ps2'/>
|
|
||||||
|
<% @inputs.each do |input| %>
|
||||||
|
<input type='<%= input[:type] %>' bus='<%= input[:bus] %>'/>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%# Video device -%>
|
<%# Video device -%>
|
||||||
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd%> />
|
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd%> />
|
||||||
<video>
|
<video>
|
||||||
|
@ -19,7 +19,7 @@ class EnvironmentHelper
|
|||||||
1024
|
1024
|
||||||
end
|
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
|
define_method(name.to_sym) do
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user