Add options for 3d acceleration (#1386)

When enabling video_accel3d, as graphics_gl is typically required, will 
by default set it to true unless explicitly set to false.

Enabling these should result in a significant performance improvement 
for any VM where the desktop is being used.

Fixes: #893
Fixes: #1009
This commit is contained in:
Aleksandr Mezin
2021-10-26 15:11:30 +06:00
committed by GitHub
parent 6c9ec5a190
commit dcbfea2f49
7 changed files with 63 additions and 4 deletions

View File

@@ -78,9 +78,11 @@ module VagrantPlugins
else
"passwd='#{config.graphics_passwd}'"
end
@graphics_gl = config.graphics_gl
@video_type = config.video_type
@sound_type = config.sound_type
@video_vram = config.video_vram
@video_accel3d = config.video_accel3d
@keymap = config.keymap
@kvm_hidden = config.kvm_hidden
@@ -299,6 +301,7 @@ module VagrantPlugins
env[:ui].info(" -- Graphics Password: #{@graphics_passwd.empty? ? 'Not defined' : 'Defined'}")
env[:ui].info(" -- Video Type: #{@video_type}")
env[:ui].info(" -- Video VRAM: #{@video_vram}")
env[:ui].info(" -- Video 3D accel: #{@video_accel3d}")
env[:ui].info(" -- Sound Type: #{@sound_type}")
env[:ui].info(" -- Keymap: #{@keymap}")
env[:ui].info(" -- TPM Backend: #{@tpm_type}")

View File

@@ -222,6 +222,24 @@ module VagrantPlugins
graphics.attributes['passwd'] = config.graphics_passwd
end
end
graphics_gl = REXML::XPath.first(xml_descr, '/domain/devices/graphics/gl')
if graphics_gl.nil?
if config.graphics_gl
graphics_gl = REXML::Element.new('gl', REXML::XPath.first(xml_descr, '/domain/devices/graphics'))
graphics_gl.attributes['enable'] = 'yes'
descr_changed = true
end
else
if config.graphics_gl
if graphics_gl.attributes['enable'] != 'yes'
graphics_gl.attributes['enable'] = 'yes'
descr_changed = true
end
else
graphics_gl.parent.delete_element(graphics_gl)
descr_changed = true
end
end
else
# graphics_type = none, remove entire element
graphics.parent.delete_element(graphics) unless graphics.nil?
@@ -280,6 +298,24 @@ module VagrantPlugins
video_model.attributes['vram'] = config.video_vram
end
end
video_accel = REXML::XPath.first(xml_descr, '/domain/devices/video/model/acceleration')
if video_accel.nil?
if config.video_accel3d
video_accel = REXML::Element.new('acceleration', REXML::XPath.first(xml_descr, '/domain/devices/video/model'))
video_accel.attributes['accel3d'] = 'yes'
descr_changed = true
end
else
if config.video_accel3d
if video_accel.attributes['accel3d'] != 'yes'
video_accel.attributes['accel3d'] = 'yes'
descr_changed = true
end
else
video_accel.parent.delete_element(video_accel)
descr_changed = true
end
end
end
# Sound device

View File

@@ -119,8 +119,10 @@ module VagrantPlugins
attr_accessor :graphics_port
attr_accessor :graphics_passwd
attr_accessor :graphics_ip
attr_accessor :graphics_gl
attr_accessor :video_type
attr_accessor :video_vram
attr_accessor :video_accel3d
attr_accessor :keymap
attr_accessor :kvm_hidden
attr_accessor :sound_type
@@ -270,8 +272,10 @@ module VagrantPlugins
@graphics_port = UNSET_VALUE
@graphics_ip = UNSET_VALUE
@graphics_passwd = UNSET_VALUE
@graphics_gl = UNSET_VALUE
@video_type = UNSET_VALUE
@video_vram = UNSET_VALUE
@video_accel3d = UNSET_VALUE
@sound_type = UNSET_VALUE
@keymap = UNSET_VALUE
@kvm_hidden = UNSET_VALUE
@@ -890,6 +894,8 @@ module VagrantPlugins
@graphics_ip = '127.0.0.1' if @graphics_ip == UNSET_VALUE
@video_type = 'cirrus' if @video_type == UNSET_VALUE
@video_vram = 9216 if @video_vram == UNSET_VALUE
@video_accel3d = false if @video_accel3d == UNSET_VALUE
@graphics_gl = @video_accel3d if @graphics_gl == UNSET_VALUE
@sound_type = nil if @sound_type == UNSET_VALUE
@keymap = 'en-us' if @keymap == UNSET_VALUE
@kvm_hidden = false if @kvm_hidden == UNSET_VALUE

View File

@@ -216,9 +216,13 @@
<% end %>
<% if @graphics_type != 'none' %>
<%# 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 %> <% if not @graphics_gl %>/><% else %>>
<gl enable='yes' />
</graphics><% end %>
<video>
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'/>
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'<% if not @video_accel3d %>/><% else %>>
<acceleration accel3d='yes'/>
</model><% end %>
</video>
<%#End Video -%>
<% end %>