You are not logged in.

#1 2015-08-22 12:57:28

Registered: 2014-09-23
Posts: 64

Qemu as root can't connect to pulseaudio

I'm running a VGA passthrough setup with Qemu, and it has direct access to 2 hard drives in my pc. For this I need to run Qemu as root (sudo).

While in Xfce4 it works fine, with i3, Qemu fails to connect with the following error:

pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextaudio: Could not init 'pa' audio driver

Because it runs fine when not running Qemu as root, I'm thinking that it can not connect to the Pulseaudio daemon running as my user.
I just find it weird that it works when I'm in Xfce4.

How can I give Qemu as root access to Pulseaudio running as a daemon as my user?


#2 2015-10-09 15:24:11

Registered: 2009-05-23
Posts: 118

Re: Qemu as root can't connect to pulseaudio


#3 2015-10-10 08:00:01

From: California
Registered: 2008-03-05
Posts: 185

Re: Qemu as root can't connect to pulseaudio

I've found a solution for this that works for me and doesn't need to run pulseaudio in system-mode (based on this blog post).

Steps I took:
1. Disabled system-mode (I was using a systemd unit)
2. Edit the /etc/pulse/ Find and update the following line to match below:

load-module module-native-protocol-unix auth-anonymous=1 socket=/tmp/pulseaudio.sock

3. Edit the /etc/pulse/client.conf and uncomment/update the following line to match below:

default-server = unix:/tmp/pulseaudio.sock

4. Added the following to my ~/.xinitrc

pulse -D

This may not be secure in a sense as I believe anything could write to the socket. However, this to me was a better solution than running in system-mode..

Hope this helps anyone struggling with the same issue..


#4 2015-10-10 08:18:10

From: Germany
Registered: 2007-08-14
Posts: 1,913

Re: Qemu as root can't connect to pulseaudio

the correct solution is to copy your users pulse cookie file to your root home folder

cp /home/YOUR_USER/.config/pulse/cookie /root/.config/pulse/cookie

of course create the destination directory

Last edited by Rasi (2015-10-10 08:18:59)

He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams


Board footer

Powered by FluxBB