Merge pull request #383 from dc-bradwadsworth/add_boot_order

Add boot order
This commit is contained in:
Dmitry Vasilets 2015-06-03 08:18:25 +02:00
commit 33850c2567
5 changed files with 44 additions and 2 deletions

View File

@ -170,6 +170,7 @@ end
* `video_vram` - Used by some graphics card types to vary the amount of RAM dedicated to video. Defaults to 9216.
* `machine` - Sets machine type. Equivalent to qemu `-machine`. Use `qemu-system-x86_64 -machine help` to get a list of supported machines.
* `machine_arch` - Sets machine architecture. This helps libvirt to determine the correct emulator type. Possible values depend on your version of qemu. For possible values, see which emulator executable `qemu-system-*` your system provides. Common examples are `aarch64`, `alpha`, `arm`, `cris`, `i386`, `lm32`, `m68k`, `microblaze`, `microblazeel`, `mips`, `mips64`, `mips64el`, `mipsel`, `moxie`, `or32`, `ppc`, `ppc64`, `ppcemb`, `s390x`, `sh4`, `sh4eb`, `sparc`, `sparc64`, `tricore`, `unicore32`, `x86_64`, `xtensa`, `xtensaeb`.
* `boot` - Change the boot order and enables the boot menu. Possible options are "hd" or "network". Defaults to "hd" with boot menu disabled.
Specific domain settings can be set for each domain separately in multi-VM
@ -191,6 +192,23 @@ Vagrant.configure("2") do |config|
# ...
```
The following example shows part of a Vagrantfile that enables the VM to
boot from a network interface first and a hard disk second. This could be
used to run VMs that are meant to be a PXE booted machines.
```ruby
Vagrant.configure("2") do |config|
config.vm.define :pxeclient do |pxeclient|
pxeclient.vm.box = "centos64"
pxeclient.vm.provider :libvirt do |domain|
domain.boot 'network'
domain.boot 'hd'
end
end
# ...
```
## Networks
Networking features in the form of `config.vm.network` support private networks

View File

@ -54,6 +54,9 @@ module VagrantPlugins
@video_type = config.video_type
@video_vram = config.video_vram
@keymap = config.keymap
# Boot order
@boot_order = config.boot_order
# Storage
@storage_pool_name = config.storage_pool_name
@ -124,6 +127,10 @@ module VagrantPlugins
env[:ui].info(" -- Video Type: #{@video_type}")
env[:ui].info(" -- Video VRAM: #{@video_vram}")
env[:ui].info(" -- Keymap: #{@keymap}")
@boot_order.each do |device|
env[:ui].info(" -- Boot device: #{device}")
end
if @disks.length > 0
env[:ui].info(" -- Disks: #{_disks_print(@disks)}")

View File

@ -55,6 +55,7 @@ module VagrantPlugins
attr_accessor :memory
attr_accessor :cpus
attr_accessor :cpu_mode
attr_accessor :boot_order
attr_accessor :machine_type
attr_accessor :machine_arch
attr_accessor :disk_bus
@ -113,10 +114,16 @@ module VagrantPlugins
@video_vram = UNSET_VALUE
@keymap = UNSET_VALUE
# Boot order
@boot_order = []
# Storage
@disks = []
@cdroms = []
end
def boot(device)
@boot_order << device # append
end
def _get_device(disks)
# skip existing devices and also the first one (vda)
@ -299,6 +306,9 @@ module VagrantPlugins
@video_type = 'cirrus' if @video_type == UNSET_VALUE
@video_vram = 9216 if @video_vram == UNSET_VALUE
@keymap = 'en-us' if @keymap == UNSET_VALUE
# Boot order
@boot_order = [] if @boot_order == UNSET_VALUE
# Storage
@disks = [] if @disks == UNSET_VALUE

View File

@ -27,7 +27,14 @@
<type>hvm</type>
<% end %>
<% end %>
<boot dev='hd'/>
<% if @boot_order.count >= 1 %>
<% @boot_order.each do |b| %>
<boot dev='<%= b %>'/>
<% end %>
<bootmenu enable='yes'/>
<% else %>
<boot dev='hd' />
<% end %>
<kernel><%= @kernel %></kernel>
<initrd><%= @initrd %></initrd>
<cmdline><%= @cmd_line %></cmdline>

View File

@ -19,7 +19,7 @@ class EnvironmentHelper
1024
end
%w(cpus cpu_mode 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).each do |name|
define_method(name.to_sym) do
nil
end