Merge pull request #581 from infernix/improved-arm-support

Improved arm support
This commit is contained in:
Dmitry Vasilets 2016-03-28 14:37:55 +02:00
commit 9d0e195035
5 changed files with 134 additions and 39 deletions

View File

@ -191,7 +191,9 @@ end
* `memory` - Amount of memory in MBytes. Defaults to 512 if not set.
* `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` - [CPU emulation mode](https://libvirt.org/formatdomain.html#elementsCPU). Defaults to 'host-model' if not set. Allowed values: host-model, host-passthrough.
* `cpu_mode` - [CPU emulation mode](https://libvirt.org/formatdomain.html#elementsCPU). Defaults to 'host-model' if not set. Allowed values: host-model, host-passthrough, custom.
* `cpu_model` - CPU Model. Defaults to 'qemu64' if not set. This can really only be used when setting `cpu_mode` to `custom`.
* `cpu_fallback` - Whether to allow libvirt to fall back to a CPU model close to the specified model if features in the guest CPU are not supported on the host. Defaults to 'allow' if not set. Allowed values: `allow`, `forbid`.
* `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`.
@ -218,6 +220,7 @@ end
* `tpm_model` - The model of the TPM to which you wish to connect.
* `tpm_type` - The type of TPM device to which you are connecting.
* `tpm_path` - The path to the TPM device on the host system.
* `dtb` - The device tree blob file, mostly used for non-x86 platforms. In case the device tree isn't added in-line to the kernel, it can be manually specified here.
* `autostart` - Automatically start the domain when the host boots. Defaults to 'false'.

View File

@ -35,6 +35,8 @@ module VagrantPlugins
@cpus = config.cpus.to_i
@cpu_features = config.cpu_features
@cpu_mode = config.cpu_mode
@cpu_model = config.cpu_model
@cpu_fallback = config.cpu_fallback
@loader = config.loader
@machine_type = config.machine_type
@machine_arch = config.machine_arch
@ -47,6 +49,7 @@ module VagrantPlugins
@cmd_line = config.cmd_line
@emulator_path = config.emulator_path
@initrd = config.initrd
@dtb = config.dtb
@graphics_type = config.graphics_type
@graphics_autoport = config.graphics_autoport
@graphics_port = config.graphics_port

View File

@ -88,7 +88,16 @@ module VagrantPlugins
descr_changed = true
cpu_model = REXML::Element.new('model', REXML::XPath.first(xml_descr,'/domain/cpu'))
cpu_model.attributes['fallback'] = 'allow'
cpu_model.text = 'qemu64'
cpu_model.text = config.cpu_model
else
if cpu_model.text != config.cpu_model
descr_changed = true
cpu_model.text = config.cpu_model
end
if cpu_model.attributes['fallback'] != config.cpu_fallback
descr_changed = true
cpu_model.attributes['fallback'] = config.cpu_fallback
end
end
vmx_feature = REXML::XPath.first(xml_descr,'/domain/cpu/feature[@name="vmx"]')
svm_feature = REXML::XPath.first(xml_descr,'/domain/cpu/feature[@name="svm"]')
@ -126,33 +135,44 @@ module VagrantPlugins
# Graphics
graphics = REXML::XPath.first(xml_descr,'/domain/devices/graphics')
if graphics.attributes['type'] != config.graphics_type
descr_changed = true
graphics.attributes['type'] = config.graphics_type
end
if graphics.attributes['listen'] != config.graphics_ip
descr_changed = true
graphics.attributes['listen'] = config.graphics_ip
graphics.delete_element('//listen')
end
if graphics.attributes['autoport'] != config.graphics_autoport
descr_changed = true
graphics.attributes['autoport'] = config.graphics_autoport
if config.graphics_autoport == 'no'
graphics.attributes['port'] = config.graphics_port
if config.graphics_type != 'none'
if graphics.nil?
descr_changed = true
graphics = REXML::Element.new('graphics', REXML::XPath.first(xml_descr,'/domain/devices'))
end
end
if graphics.attributes['keymap'] != config.keymap
descr_changed = true
graphics.attributes['keymap'] = config.keymap
end
if graphics.attributes['passwd'] != config.graphics_passwd
descr_changed = true
if config.graphics_passwd.nil?
graphics.attributes.delete 'passwd'
else
graphics.attributes['passwd'] = config.graphics_passwd
if graphics.attributes['type'] != config.graphics_type
descr_changed = true
graphics.attributes['type'] = config.graphics_type
end
if graphics.attributes['listen'] != config.graphics_ip
descr_changed = true
graphics.attributes['listen'] = config.graphics_ip
graphics.delete_element('//listen')
end
if graphics.attributes['autoport'] != config.graphics_autoport
descr_changed = true
graphics.attributes['autoport'] = config.graphics_autoport
if config.graphics_autoport == 'no'
graphics.attributes['port'] = config.graphics_port
end
end
if graphics.attributes['keymap'] != config.keymap
descr_changed = true
graphics.attributes['keymap'] = config.keymap
end
if graphics.attributes['passwd'] != config.graphics_passwd
descr_changed = true
if config.graphics_passwd.nil?
graphics.attributes.delete 'passwd'
else
graphics.attributes['passwd'] = config.graphics_passwd
end
end
else
# graphics_type = none, remove entire element
if !graphics.nil?
graphics.parent.delete_element(graphics)
end
end
#TPM
@ -185,12 +205,67 @@ module VagrantPlugins
end
# Video device
video = REXML::XPath.first(xml_descr,'/domain/devices/video/model')
if video.attributes['type'] != config.video_type || video.attributes['vram'] != config.video_vram
video = REXML::XPath.first(xml_descr,'/domain/devices/video')
if !video.nil? and config.graphics_type == 'none'
# graphics_type = none, video devices are removed since there is no possible output
descr_changed = true
video.attributes.each_attribute {|attr| video.attributes.delete attr}
video.attributes['type'] = config.video_type
video.attributes['vram'] = config.video_vram
video.parent.delete_element(video)
else
video_model = REXML::XPath.first(xml_descr,'/domain/devices/video/model')
if video_model.nil?
video_model = REXML::Element.new('model', REXML::XPath.first(xml_descr,'/domain/devices/video'))
video_model.attributes['type'] = config.video_type
video_model.attributes['vram'] = config.video_vram
else
if video_model.attributes['type'] != config.video_type || video_model.attributes['vram'] != config.video_vram
descr_changed = true
video_model.attributes['type'] = config.video_type
video_model.attributes['vram'] = config.video_vram
end
end
end
# dtb
if config.dtb
dtb = REXML::XPath.first(xml_descr,'/domain/os/dtb')
if dtb.nil?
descr_changed = true
dtb = REXML::Element.new('dtb', REXML::XPath.first(xml_descr,'/domain/os'))
dtb.text = config.dtb
else
if dtb.text != config.dtb
descr_changed = true
dtb.text = config.dtb
end
end
end
# kernel and initrd
if config.kernel
kernel= REXML::XPath.first(xml_descr,'/domain/os/kernel')
if kernel.nil?
descr_changed = true
kernel = REXML::Element.new('kernel', REXML::XPath.first(xml_descr,'/domain/os'))
kernel.text = config.kernel
else
if kernel.text != config.kernel
descr_changed = true
kernel.text = config.kernel
end
end
end
if config.initrd
initrd = REXML::XPath.first(xml_descr,'/domain/os/initrd')
if initrd.nil?
descr_changed = true
initrd = REXML::Element.new('initrd', REXML::XPath.first(xml_descr,'/domain/os'))
initrd.text = config.initrd
else
if initrd.text != config.initrd
descr_changed = true
initrd.text = config.initrd
end
end
end
# Apply

View File

@ -58,6 +58,8 @@ module VagrantPlugins
attr_accessor :memory
attr_accessor :cpus
attr_accessor :cpu_mode
attr_accessor :cpu_model
attr_accessor :cpu_fallback
attr_accessor :cpu_features
attr_accessor :loader
attr_accessor :boot_order
@ -71,6 +73,7 @@ module VagrantPlugins
attr_accessor :kernel
attr_accessor :cmd_line
attr_accessor :initrd
attr_accessor :dtb
attr_accessor :emulator_path
attr_accessor :graphics_type
attr_accessor :graphics_autoport
@ -133,6 +136,8 @@ module VagrantPlugins
@memory = UNSET_VALUE
@cpus = UNSET_VALUE
@cpu_mode = UNSET_VALUE
@cpu_model = UNSET_VALUE
@cpu_fallback = UNSET_VALUE
@cpu_features = UNSET_VALUE
@loader = UNSET_VALUE
@machine_type = UNSET_VALUE
@ -144,6 +149,7 @@ module VagrantPlugins
@volume_cache = UNSET_VALUE
@kernel = UNSET_VALUE
@initrd = UNSET_VALUE
@dtb = UNSET_VALUE
@cmd_line = UNSET_VALUE
@emulator_path = UNSET_VALUE
@graphics_type = UNSET_VALUE
@ -415,6 +421,8 @@ module VagrantPlugins
@memory = 512 if @memory == UNSET_VALUE
@cpus = 1 if @cpus == UNSET_VALUE
@cpu_mode = 'host-model' if @cpu_mode == UNSET_VALUE
@cpu_model = 'qemu64' if @cpu_model == UNSET_VALUE
@cpu_fallback = 'allow' if @cpu_fallback == UNSET_VALUE
@cpu_features = [] if @cpu_features == UNSET_VALUE
@loader = nil if @loader == UNSET_VALUE
@machine_type = nil if @machine_type == UNSET_VALUE
@ -427,6 +435,7 @@ module VagrantPlugins
@kernel = nil if @kernel == UNSET_VALUE
@cmd_line = '' if @cmd_line == UNSET_VALUE
@initrd = '' if @initrd == UNSET_VALUE
@dtb = nil if @dtb == UNSET_VALUE
@graphics_type = 'vnc' if @graphics_type == UNSET_VALUE
@graphics_autoport = 'yes' if @graphics_port == UNSET_VALUE
@graphics_autoport = 'no' if @graphics_port != UNSET_VALUE

View File

@ -7,7 +7,7 @@
<cpu mode='<%= @cpu_mode %>'>
<% if @cpu_mode != 'host-passthrough' %>
<model fallback='allow'>qemu64</model>
<model fallback='<%= @cpu_fallback %>'><%= @cpu_model %></model>
<% if @nested %>
<feature policy='optional' name='vmx'/>
<feature policy='optional' name='svm'/>
@ -42,6 +42,9 @@
<kernel><%= @kernel %></kernel>
<initrd><%= @initrd %></initrd>
<cmdline><%= @cmd_line %></cmdline>
<% if @dtb %>
<dtb><%= @dtb %></dtb>
<% end %>
</os>
<features>
<acpi/>
@ -97,12 +100,14 @@
<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>
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'/>
</video>
<%#End Video -%>
<% if @graphics_type != 'none' %>
<%# Video device -%>
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='<%= @keymap %>' <%= @graphics_passwd%> />
<video>
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'/>
</video>
<%#End Video -%>
<% end %>
<% @pcis.each do |pci| %>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source>