pulseaudio issue on QEMU/KVM guest VM when microphone is replugged/unplugged pulseaudio: pa_threaded_mainloop_lock failed pulseaudio: Reason: Invalid argument

Here is the scenario, you are using QEMU/KVM and are using something like the AC97 sound driver to pass the host audio to the guest via pulseaudio.  This is useful because you can transparently pass your mic input from the host which means you can mute your microphone from the host, which prevents the guest from receiving any mic input even if unmuted.

Mute / Unmute Fix

This issue also seems to happen even if you press the mute button on the microphone and then unmute, it has virtually the same effect as unplugging and replugging the USB microphone.

One thing that seems to help with muting and unmuting button issue, is if you set your Microphone as a single input only (no dual input/output / duplex).

In Mint/Ubuntu, it means going to Sound Settings, Hardware, clicking on your Microphone and just choosing "Input"


Here is the relevant CLI that makes this audio config happen that gets passed to QEMU:

-audiodev driver=pa,id=pa1,server=unix:/run/user/1000/pulse/native -device intel-hda -device AC97,audiodev=pa1

You would change the /run/user/1000 with your numeric uid which can be retrieved with id -u

But the problem is that input/mic audio will break (note that output is unaffected though) on the guest if there is any change to the pulseaudio on the host side during this time:

You will get pulseaudio errors like this:

pulseaudio: pa_threaded_mainloop_lock failed
pulseaudio: Reason: Invalid argument
pulseaudio: pa_threaded_mainloop_lock failed
pulseaudio: Reason: Invalid argument
pulseaudio: pa_threaded_mainloop_lock failed
pulseaudio: Reason: Invalid argument


I am not aware of any solution for this other than to hard restart the guest VM (not just a graceful reset initiated from the VM but a full hard poweroff of the VM).

One other config that I have tried is to use the -device hda-duplex but this seems to be buggy as shortly after starting the VM, mic audio input seems to fail on the guest which means the mic stops working.  This is why I use AC97, as it seems to be persistent so long as you don't unpug the microphone (config CLI below).

-audiodev driver=pa,id=pa1,server=unix:/run/user/1000/pulse/native -device intel-hda -device hda-duplex,audiodev=pa1


pulseaudio, qemu, kvm, vm, microphone, replugged, unpluggedhere, ac, audio, via, transparently, mic, input, mute, prevents, receiving, unmuted, relevant, cli, config, audiodev, server, unix, user, native, intel, hda, numeric, uid, retrieved, output, unaffected, errors, pa_threaded_mainloop_lock, invalid, restart, graceful, reset, initiated, poweroff, duplex, buggy, persistent, unpug,

Latest Articles

  • CentOS 7 / 8 cannot boot with with mdadm RAID array solution
  • How To Add Default Gateway in Linux using the ip route command routing
  • Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist Solution for Centos8 yum package install error
  • md mdadm array inactive how to start and activate the RAID array
  • Loaded: masked (Reason: Unit hostapd.service is masked.) Solution in Linux Debian Mint Ubuntu
  • Linux Mint Ubuntu Ubiquity Installer Bug EFI Installed To Wrong Partition Solution
  • Libreoffice Impress How To Change The Color of Links
  • ecryptfs How To Backup / Migrate Linux Mint Ubuntu Debian system ecryptfs properly and restore access
  • i915 nouveau Nvidia GPU not starting lightdm Xorg failing solution for Could not determine valid watermarks for inherited state
  • br0: received packet on bond0 with own address as source address Linux Solution Mint Debian Redhat CentOS bridge bridging
  • Debian Mint Ubuntu Howto Disable Network Manager
  • AMD GPU Xorg Won't Start [3576284.324] (EE) Segmentation fault at address 0x0 [3576284.325] (EE) Fatal server error: [3576284.325] (EE) Caught signal 11 (Segmentation fault). Server aborting
  • symbol 'grub_calloc' not found grub boot error solution / fix
  • /var/log/journal huge/too large solution in Debian Mint Ubuntu Linux Howot Fix
  • Libreoffice Calc Opens CSV Spreadsheet File as Asian Language/Chinese Characters Solution Fix
  • RTL8821AU Setup Configure Wifi Realtek 8821 in Linux Debian Mint Ubuntu Howto
  • How To Tell Which Repository a Package Comes From Debian Mint Ubuntu
  • How To Reload All Kernel Modules And List Required Moduels for Each Device - Linux Mint Debian Ubuntu Troubleshooting
  • Debian Ubuntu Mint How To Change Default Display Manager
  • Ubuntu Mint Debian Howto Execute Command / Script / Program Upon Wakeup From Sleep