From 2f091b1cdc50c6bb491909e235c7dc8f191b9e7d Mon Sep 17 00:00:00 2001 From: Liam Campbell Date: Wed, 5 Oct 2016 10:17:44 +1100 Subject: [PATCH 1/2] patch to include virtual sound card support --- README.md | 2 ++ lib/vagrant-libvirt/action/create_domain.rb | 2 ++ lib/vagrant-libvirt/action/start_domain.rb | 6 ++++++ lib/vagrant-libvirt/config.rb | 2 ++ lib/vagrant-libvirt/templates/domain.xml.erb | 7 ++++++- 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 090cdaa..960514b 100644 --- a/README.md +++ b/README.md @@ -332,6 +332,8 @@ end "cirrus", "vmvga", "xen", "vbox", or "qxl". * `video_vram` - Used by some graphics card types to vary the amount of RAM dedicated to video. Defaults to 9216. +* `sound_type` - [Set the virtual sound card](https://libvirt.org/formatdomain.html#elementsSound) + Defaults to "ich6". * `machine_type` - 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 diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb index a4866a8..750b3ce 100644 --- a/lib/vagrant-libvirt/action/create_domain.rb +++ b/lib/vagrant-libvirt/action/create_domain.rb @@ -61,6 +61,7 @@ module VagrantPlugins "passwd='#{config.graphics_passwd}'" end @video_type = config.video_type + @sound_type = config.sound_type @video_vram = config.video_vram @keymap = config.keymap @kvm_hidden = config.kvm_hidden @@ -192,6 +193,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(" -- Sound Type: #{@sound_type}") env[:ui].info(" -- Keymap: #{@keymap}") env[:ui].info(" -- TPM Path: #{@tpm_path}") diff --git a/lib/vagrant-libvirt/action/start_domain.rb b/lib/vagrant-libvirt/action/start_domain.rb index 9a7a3d9..26ee676 100644 --- a/lib/vagrant-libvirt/action/start_domain.rb +++ b/lib/vagrant-libvirt/action/start_domain.rb @@ -221,6 +221,12 @@ module VagrantPlugins end end + # Sound device + if config.sound_type + sound = REXML::XPath.first(xml_descr,'/domain/devices/sound/model') + end + + # dtb if config.dtb dtb = REXML::XPath.first(xml_descr, '/domain/os/dtb') diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 055850b..191e650 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -184,6 +184,7 @@ module VagrantPlugins @graphics_passwd = UNSET_VALUE @video_type = UNSET_VALUE @video_vram = UNSET_VALUE + @sound_type = UNSET_VALUE @keymap = UNSET_VALUE @kvm_hidden = UNSET_VALUE @@ -585,6 +586,7 @@ 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 + @sound_type = 'ich6' if @sound_type == UNSET_VALUE @keymap = 'en-us' if @keymap == UNSET_VALUE @kvm_hidden = false if @kvm_hidden == UNSET_VALUE @tpm_model = 'tpm-tis' if @tpm_model == UNSET_VALUE diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb index 5da9083..03d21fd 100644 --- a/lib/vagrant-libvirt/templates/domain.xml.erb +++ b/lib/vagrant-libvirt/templates/domain.xml.erb @@ -131,7 +131,12 @@ <% @inputs.each do |input| %> <% end %> - + <% if @sound_type != 'none' %> + <%# Sound device-%> + + + <%# End Sound%> + <% end %> <% if @graphics_type != 'none' %> <%# Video device -%> /> From 1248dc43e96e7fdd24fb8bfa574668d0d372e16a Mon Sep 17 00:00:00 2001 From: Dmitry Galkin Date: Sat, 7 Jan 2017 14:01:00 +0100 Subject: [PATCH 2/2] sound_type set to nil if UNSET_VALUE. --- lib/vagrant-libvirt/config.rb | 2 +- lib/vagrant-libvirt/templates/domain.xml.erb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 191e650..5f72b85 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -586,7 +586,7 @@ 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 - @sound_type = 'ich6' if @sound_type == 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 @tpm_model = 'tpm-tis' if @tpm_model == UNSET_VALUE diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb index 03d21fd..e4a270a 100644 --- a/lib/vagrant-libvirt/templates/domain.xml.erb +++ b/lib/vagrant-libvirt/templates/domain.xml.erb @@ -131,7 +131,8 @@ <% @inputs.each do |input| %> <% end %> - <% if @sound_type != 'none' %> + + <% if !@sound_type.nil? %> <%# Sound device-%>