Discussion:
audio support in libvirt with qemu/kvm
(too old to reply)
Rainer Dorsch
2021-01-24 22:00:02 UTC
Permalink
Hi,

I created a virtual machine using libvirt with qemu/kvm. To make it simple, I
installed a Debian 10 guest on a Debian 10 host. I am wondering, if it is
possible to access (pulse-)audio from the guest.

Any hint or advice is welcome.

Thanks
Rainer
--
Rainer Dorsch
http://bokomoko.de/
Linux-Fan
2021-01-24 22:10:01 UTC
Permalink
Post by Rainer Dorsch
Hi,
I created a virtual machine using libvirt with qemu/kvm. To make it simple, I
installed a Debian 10 guest on a Debian 10 host. I am wondering, if it is
possible to access (pulse-)audio from the guest.
Any hint or advice is welcome.
For me it works out of the box in the way that I can hear sound played
inside the VM and the VM can record from the microphone attached to the PC.

In virt-manager it appears as "Sound ich9" device added to the respective
VMs. Host and guest both use Pulseaudio. In case you do not use GUI, it
might be enough to add the following device in the VM's XML:

<sound model='ich9'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x1b' function='0x0'/>
</sound>

I do not know if it can be made to work in a way that just a single pulse
audio server is running -- in my configuration, the guest and host both have
their respective pulse audio instances although the sound itself passes from
the one to the other wihtout explicit configuration :)

HTH
Linux-Fan

öö

[...]
Rainer Dorsch
2021-01-25 11:50:01 UTC
Permalink
Post by Linux-Fan
Post by Rainer Dorsch
Hi,
I created a virtual machine using libvirt with qemu/kvm. To make it
simple, I installed a Debian 10 guest on a Debian 10 host. I am
wondering, if it is possible to access (pulse-)audio from the guest.
Any hint or advice is welcome.
For me it works out of the box in the way that I can hear sound played
inside the VM and the VM can record from the microphone attached to the PC.
In virt-manager it appears as "Sound ich9" device added to the respective
VMs. Host and guest both use Pulseaudio. In case you do not use GUI, it
<sound model='ich9'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x1b'
function='0x0'/> </sound>
I do not know if it can be made to work in a way that just a single pulse
audio server is running -- in my configuration, the guest and host both have
their respective pulse audio instances although the sound itself passes
from the one to the other wihtout explicit configuration :)
Thanks for the quick reply. I tried again and it seems sound works now :-)

I also used virt-manager, but I did not find any sound devices in there. Are
you using Debian 10? virt-manager from stable or stable-backports? Where do
you see the "Sound ich9" device?

Thanks
Rainer
--
Rainer Dorsch
http://bokomoko.de/
Linux-Fan
2021-01-25 12:30:02 UTC
Permalink
Post by Rainer Dorsch
Post by Rainer Dorsch
Hi,
I created a virtual machine using libvirt with qemu/kvm. To make it
simple, I installed a Debian 10 guest on a Debian 10 host. I am
wondering, if it is possible to access (pulse-)audio from the guest.
[...]
Post by Rainer Dorsch
Thanks for the quick reply. I tried again and it seems sound works now :-)
I also used virt-manager, but I did not find any sound devices in there. Are
you using Debian 10? virt-manager from stable or stable-backports? Where do
you see the "Sound ich9" device?
[...]

Open the VM in virt-manager, go to View > Details and then it either appears
in the left pane (see attached screenshot if it makes it to the list...) or
you can click on "Add Hardware" at the bottom left corner and then chose
"Sound" from the left panel to add a virtual sound device.

I am using Debian 10 stable "Help > About" says version 2.0.0 of virt-
manager. Debian package virt-manager is at version 1:2.0.0-3.

Various screenshots can be found on my KVM+virt-manager page at:
https://masysma.lima-city.de/37/how_to_transition_from_virtualbox_to_kvm.xhtml

HTH
Linux-Fan

öö
Rainer Dorsch
2021-01-25 19:50:01 UTC
Permalink
Post by Linux-Fan
https://masysma.lima-city.de/37/how_to_transition_from_virtualbox_to_kvm.xht
ml
I found it, thanks for sharing the URL, very useful.

Rainer
--
Rainer Dorsch
http://bokomoko.de/
Christian Ehrhardt
2021-01-27 08:40:02 UTC
Permalink
Post by Rainer Dorsch
Hi,
I created a virtual machine using libvirt with qemu/kvm. To make it simple, I
installed a Debian 10 guest on a Debian 10 host. I am wondering, if it is
possible to access (pulse-)audio from the guest.
If you have - the optional but usually installed - package
qemu-system-gui then qemu is generally able to produce sound.
You said you drive your guest via libvirt, depending on your front end
to this it might just not have a sound device [1] configured.
You can usually add a sound device and select the type it emulates,
something like the following should do it:
<sound model="ich9">

You can then check these things (in order)
1. is the sound device in the guest seen and initialized?
2. play some continuous sound/music from the guest - is there any error?
3. check hosts pavucontrol if you need to assign the qemu process to a
particular output?


[1]: https://libvirt.org/formatdomain.html#sound-devices
Post by Rainer Dorsch
Any hint or advice is welcome.
Thanks
Rainer
--
Rainer Dorsch
http://bokomoko.de/
_______________________________________________
pkg-qemu-devel mailing list
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-qemu-devel
--
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd
Loading...