From 71ca7cab1f90ce1ce69e3564200f77bc5124dfd0 Mon Sep 17 00:00:00 2001 From: Gabriel Briones Sayeg Date: Mon, 3 Aug 2015 16:24:55 -0500 Subject: [PATCH 1/2] Include custom UEFI loader Domain XML has loader tag to read specific OVMF.fd path Signed-off-by: Gabriel Briones Sayeg --- lib/vagrant-libvirt/action/create_domain.rb | 2 ++ lib/vagrant-libvirt/config.rb | 3 +++ lib/vagrant-libvirt/templates/domain.xml.erb | 3 +++ spec/support/environment_helper.rb | 2 +- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb index 92f2041..81d1ad0 100644 --- a/lib/vagrant-libvirt/action/create_domain.rb +++ b/lib/vagrant-libvirt/action/create_domain.rb @@ -33,6 +33,7 @@ module VagrantPlugins @name = env[:domain_name] @cpus = config.cpus.to_i @cpu_mode = config.cpu_mode + @loader = config.loader @machine_type = config.machine_type @machine_arch = config.machine_arch @disk_bus = config.disk_bus @@ -118,6 +119,7 @@ module VagrantPlugins env[:ui].info(" -- Domain type: #{@domain_type}") env[:ui].info(" -- Cpus: #{@cpus}") env[:ui].info(" -- Memory: #{@memory_size / 1024}M") + env[:ui].info(" -- Loader: #{@loader}") env[:ui].info(" -- Base box: #{env[:machine].box.name}") env[:ui].info(" -- Storage pool: #{@storage_pool_name}") env[:ui].info(" -- Image: #{@domain_volume_path} (#{env[:box_virtual_size]}G)") diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 8618711..17c8b3a 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -55,6 +55,7 @@ module VagrantPlugins attr_accessor :memory attr_accessor :cpus attr_accessor :cpu_mode + attr_accessor :loader attr_accessor :boot_order attr_accessor :machine_type attr_accessor :machine_arch @@ -102,6 +103,7 @@ module VagrantPlugins @memory = UNSET_VALUE @cpus = UNSET_VALUE @cpu_mode = UNSET_VALUE + @loader = UNSET_VALUE @machine_type = UNSET_VALUE @machine_arch = UNSET_VALUE @machine_virtual_size = UNSET_VALUE @@ -294,6 +296,7 @@ module VagrantPlugins @memory = 512 if @memory == UNSET_VALUE @cpus = 1 if @cpus == UNSET_VALUE @cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE + @loader = nil if @loader == UNSET_VALUE @machine_type = nil if @machine_type == UNSET_VALUE @machine_arch = nil if @machine_arch == UNSET_VALUE @machine_virtual_size = nil if @machine_virtual_size == UNSET_VALUE diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb index 22a57a9..a493b00 100644 --- a/lib/vagrant-libvirt/templates/domain.xml.erb +++ b/lib/vagrant-libvirt/templates/domain.xml.erb @@ -27,6 +27,9 @@ hvm <% end %> <% end %> + <% if @loader %> + <%= @loader %> + <% end %> <% if @boot_order.count >= 1 %> <% end %> diff --git a/spec/support/environment_helper.rb b/spec/support/environment_helper.rb index ddfa43b..e362d88 100644 --- a/spec/support/environment_helper.rb +++ b/spec/support/environment_helper.rb @@ -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 loader 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 From 32775066278c56a0f24c8e75ef7a08ac3a88f808 Mon Sep 17 00:00:00 2001 From: Gabriel Briones Sayeg Date: Mon, 3 Aug 2015 16:24:55 -0500 Subject: [PATCH 2/2] Include custom UEFI loader Domain XML has loader tag to read specific OVMF.fd path Signed-off-by: Gabriel Briones Sayeg --- README.md | 1 + lib/vagrant-libvirt/action/create_domain.rb | 2 ++ lib/vagrant-libvirt/config.rb | 3 +++ lib/vagrant-libvirt/templates/domain.xml.erb | 3 +++ spec/support/environment_helper.rb | 2 +- 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e4d5180..3657fd0 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,7 @@ end * `cpus` - Number of virtual cpus. Defaults to 1 if not set. * `nested` - [Enable nested virtualization](https://github.com/torvalds/linux/blob/master/Documentation/virtual/kvm/nested-vmx.txt). Default is false. * `cpu_mode` - What cpu mode to use for nested virtualization. Defaults to 'host-model' if not set. +* `loader` - Sets path to custom UEFI loader. * `volume_cache` - Controls the cache mechanism. Possible values are "default", "none", "writethrough", "writeback", "directsync" and "unsafe". [See driver->cache in libvirt documentation](http://libvirt.org/formatdomain.html#elementsDisks). * `kernel` - To launch the guest with a kernel residing on host filesystems. Equivalent to qemu `-kernel`. * `initrd` - To specify the initramfs/initrd to use for the guest. Equivalent to qemu `-initrd`. diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb index 92f2041..81d1ad0 100644 --- a/lib/vagrant-libvirt/action/create_domain.rb +++ b/lib/vagrant-libvirt/action/create_domain.rb @@ -33,6 +33,7 @@ module VagrantPlugins @name = env[:domain_name] @cpus = config.cpus.to_i @cpu_mode = config.cpu_mode + @loader = config.loader @machine_type = config.machine_type @machine_arch = config.machine_arch @disk_bus = config.disk_bus @@ -118,6 +119,7 @@ module VagrantPlugins env[:ui].info(" -- Domain type: #{@domain_type}") env[:ui].info(" -- Cpus: #{@cpus}") env[:ui].info(" -- Memory: #{@memory_size / 1024}M") + env[:ui].info(" -- Loader: #{@loader}") env[:ui].info(" -- Base box: #{env[:machine].box.name}") env[:ui].info(" -- Storage pool: #{@storage_pool_name}") env[:ui].info(" -- Image: #{@domain_volume_path} (#{env[:box_virtual_size]}G)") diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 8618711..17c8b3a 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -55,6 +55,7 @@ module VagrantPlugins attr_accessor :memory attr_accessor :cpus attr_accessor :cpu_mode + attr_accessor :loader attr_accessor :boot_order attr_accessor :machine_type attr_accessor :machine_arch @@ -102,6 +103,7 @@ module VagrantPlugins @memory = UNSET_VALUE @cpus = UNSET_VALUE @cpu_mode = UNSET_VALUE + @loader = UNSET_VALUE @machine_type = UNSET_VALUE @machine_arch = UNSET_VALUE @machine_virtual_size = UNSET_VALUE @@ -294,6 +296,7 @@ module VagrantPlugins @memory = 512 if @memory == UNSET_VALUE @cpus = 1 if @cpus == UNSET_VALUE @cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE + @loader = nil if @loader == UNSET_VALUE @machine_type = nil if @machine_type == UNSET_VALUE @machine_arch = nil if @machine_arch == UNSET_VALUE @machine_virtual_size = nil if @machine_virtual_size == UNSET_VALUE diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb index 22a57a9..a493b00 100644 --- a/lib/vagrant-libvirt/templates/domain.xml.erb +++ b/lib/vagrant-libvirt/templates/domain.xml.erb @@ -27,6 +27,9 @@ hvm <% end %> <% end %> + <% if @loader %> + <%= @loader %> + <% end %> <% if @boot_order.count >= 1 %> <% end %> diff --git a/spec/support/environment_helper.rb b/spec/support/environment_helper.rb index ddfa43b..e362d88 100644 --- a/spec/support/environment_helper.rb +++ b/spec/support/environment_helper.rb @@ -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 loader 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