From b51b563c4614270802f98d263e67eb97ae47e3f3 Mon Sep 17 00:00:00 2001 From: Vilmos Nebehaj Date: Mon, 2 Mar 2015 17:44:01 +0100 Subject: [PATCH] Add 'machine_type' parameter. This parameter will be used by libvirt to set the machine type qemu will use. For example, setting it to `pc-1.0` will generate this `os` definition: hvm --- lib/vagrant-libvirt/action/create_domain.rb | 1 + lib/vagrant-libvirt/config.rb | 3 +++ lib/vagrant-libvirt/templates/domain.xml.erb | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb index a552f2e..e200bae 100644 --- a/lib/vagrant-libvirt/action/create_domain.rb +++ b/lib/vagrant-libvirt/action/create_domain.rb @@ -28,6 +28,7 @@ module VagrantPlugins @name = env[:domain_name] @cpus = config.cpus.to_i @cpu_mode = config.cpu_mode + @machine_type = config.machine_type @disk_bus = config.disk_bus @nested = config.nested @memory_size = config.memory.to_i*1024 diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 12e049e..abe4213 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 :machine_type attr_accessor :disk_bus attr_accessor :nic_model_type attr_accessor :nested @@ -91,6 +92,7 @@ module VagrantPlugins @memory = UNSET_VALUE @cpus = UNSET_VALUE @cpu_mode = UNSET_VALUE + @machine_type = UNSET_VALUE @disk_bus = UNSET_VALUE @nic_model_type = UNSET_VALUE @nested = UNSET_VALUE @@ -219,6 +221,7 @@ module VagrantPlugins @memory = 512 if @memory == UNSET_VALUE @cpus = 1 if @cpus == UNSET_VALUE @cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE + @machine_type = nil if @machine_type == UNSET_VALUE @disk_bus = 'virtio' if @disk_bus == UNSET_VALUE @nic_model_type = 'virtio' if @nic_model_type == UNSET_VALUE @nested = false if @nested == UNSET_VALUE diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb index 0ac20f1..747ca59 100644 --- a/lib/vagrant-libvirt/templates/domain.xml.erb +++ b/lib/vagrant-libvirt/templates/domain.xml.erb @@ -14,7 +14,11 @@ <% end %> + <% if @machine_type %> + hvm + <% else %> hvm + <% end %> <%= @kernel %> <%= @initrd %>