Skip to Content

KVM Windows No Sound? – Let’s fix it.

When you install a VM on the KVM hypervisor, especially windows VM, you will end up not having a sound on the guest os. For me, I am okay with not having sound on the guest operating system. However, there are times you might require to have sound on your machine and when you try to fix it, nothing seems to work. As a result,  you will end up wasting so much time trying to fix the problem.

In my previous blogs, I have covered how you can install a windows operating system in KVM, and in this one, we are going to fix the sound issue on the windows operating system on a KVM hypervisor.

This is tested with KVM running on Ubuntu and verified it is working, and it should work fine on all the Linux distributions running KVM.

1. Get the numeric ID of the user.

If your machine has only a single user it will most likely be 1000.

Type id -u

You can even confirm with the username at the end by typing id -u usernameas you can see below.

saif@gns3vm:/$ id -u
1000
saif@gns3vm:/$


saif@gns3vm:/$ id -u saif
1000
saif@gns3vm:/$

The numeric value is 1000.

2. Add the below variables in /etc/libvirt/qemu.conf file.

In your KVM host, open the file /etc/libvirt/qemu.conf file and add the below variables. Use your favorite editor, I am using nano editor for this. You may type below to edit the file.

sudo nano /etc/libvirt/qemu.conf

Scroll a little down, you should see something like # vnc_allow_host_audio = 0, change 0 to 1 and uncomment the line, as below.

vnc_allow_host_audio = 1

From this 

Kvm no sound

To this.

Kvm no sound

3. Make the KVM run with a normal user.

Scroll all the way down, you should see a line start with user. Change the value as below. The second value is the ID of the user, which we found in step 1.

User =”saif”
User =”+1000” 
enable kvm run with a normal user.

Save the /etc/libvirt/qemu.conf file. To save the file in nano editor press CTRL+O and hit enter.

4. Make the KVM use an ALSA driver.

Take the backup of the current KVM configuration.

sudo cp /usr/bin/kvm /usr/bin/kvm.bak

Open the KVM config.

sudo nano /usr/bin/kvm 

remove the existing values and replace them with the below values.

#!/bin/sh
QEMU_AUDIO_DRV=alsa /usr/bin/kvm.bin $@

5. Restart the libvirt services.

service libvirtd restart

Or 

systemctl restart libvirtd

6. Restart the Windows operating system.

In order for the windows machine to start using the audio, you will have to reboot the windows machine once. After it is rebooted you should be good to go.

Leo

Monday 25th of March 2024

Great work though. I made it here through other guides

Leo

Monday 25th of March 2024

Same issue here. Editing a binary file will never work

Chris Gaskins

Thursday 23rd of November 2023

Hi. I followed your other articles to get Windows 11 working under Linux Host via QEMU. Works great - thank you for the information. Now I am trying to get audio working in my Windows Guest under QEMU / KVM. When I get to the step of editing the KVM file, I have an issue: "sudo nano /usr/bin/kvm" On my system, that is a binary file. There is a link in my /usr/bin pointing kvm to qemu-system-x86_64 so I am not sure how to continue. I am running Ubuntu Jammy. Can you help?

Andrew

Wednesday 10th of January 2024

@Chris Gaskins, Same for me - are we supposed to select all and delete the contents of the entire file at /usr/bin/kvm?