Bug 1983493

Summary: Qemu should prompt fatal error and quit with an unsupported audiodev
Product: Red Hat Enterprise Linux 9 Reporter: Guo, Zhiyi <zhguo>
Component: qemu-kvmAssignee: Marc-Andre Lureau <marcandre.lureau>
qemu-kvm sub component: Audio QA Contact: Lili Zhu <lizhu>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: low CC: berrange, coli, jinzhao, juzhang, kraxel, lizhu, marcandre.lureau, mrezanin, virt-maint
Version: unspecifiedKeywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: All   
Whiteboard:
Fixed In Version: qemu-kvm-7.2.0-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 07:19:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 2135806    
Bug Blocks: 1788807    

Description Guo, Zhiyi 2021-07-18 23:54:46 UTC
Description of problem:
Qemu should prompt fatal error and quit with an unsupported audiodev

Version-Release number of selected component (if applicable):
qemu-kvm-6.0.0-23.module+el8.5.0+11740+35571f13.x86_64


How reproducible:
100%

Steps to Reproduce:
1.Start a qemu process with an unsupported audiodev:
# /usr/libexec/qemu-kvm  -audiodev id=audio1,driver=pa
audio: Unknown audio driver `pa'
audio: warning: Using timer based audio emulation
VNC server running on ::1:5900


Actual results:
qemu process reports warning and start

Expected results:
qemu should prompt fatal error and quit

Additional info:

Comment 1 Klaus Heinrich Kiwi 2021-07-19 18:00:53 UTC
(In reply to Guo, Zhiyi from comment #0)

> 
> Actual results:
> qemu process reports warning and start
> 
> Expected results:
> qemu should prompt fatal error and quit
> 
> Additional info:

Not a functional issue.. I'm going to re-set it to low priority / low severity - feel free to discuss

Comment 2 Klaus Heinrich Kiwi 2021-08-25 17:32:20 UTC
(In reply to Klaus Heinrich Kiwi from comment #1)
> (In reply to Guo, Zhiyi from comment #0)
> 
> > 
> > Actual results:
> > qemu process reports warning and start
> > 
> > Expected results:
> > qemu should prompt fatal error and quit
> > 
> > Additional info:
> 
> Not a functional issue.. I'm going to re-set it to low priority / low
> severity - feel free to discuss

FYI, I created a separate RFE bug to actually enable / support the Pulseaudio backend:
Bug 1997725

This bz is orthogonal, in that we need to fail in a more indicative way when the audio backend was not compiled-in. Probably an upstream discussion is needed.

Comment 3 John Ferlan 2021-09-09 13:29:52 UTC
Bulk update: Move RHEL-AV bugs to RHEL9. If necessary to resolve in RHEL8, then clone to the current RHEL8 release.

Comment 5 Yanan Fu 2022-12-20 09:18:03 UTC
QE bot(pre verify): Set 'Verified:Tested,SanityOnly' as gating/tier1 test pass.

Comment 8 Guo, Zhiyi 2022-12-28 11:36:30 UTC
Hi Lili, 

    I cannot verify whether the normal condition works: /usr/libexec/qemu-kvm  -audiodev id=audio1,driver=pa -vnc :2 on my server(dell 940xa, but any servers should not matter)
I guess this is due to the desktop environment need to be configured with normal user(for starting audio device normally) and properly there should be audio device on host as well, here is the strace hint I see:
# strace /usr/libexec/qemu-kvm  -audiodev id=audio1,driver=spice -vnc :2
...
munmap(0x7fbbd281f000, 43703)           = 0
newfstatat(AT_FDCWD, "/run/user/0/pulse/pid", 0x7fbbd431ef28, 0) = -1 ENOENT (No such file or directory)
write(2, "audio: ", 7audio: )                  = 7
write(2, "Could not init `pa' audio driver"..., 33Could not init `pa' audio driver
) = 33
exit_group(1)                           = ?
+++ exited with 1 +++
...

So can you help to verify this issue with a proper audio env?

Thanks!

Zhiyi

Comment 9 Lili Zhu 2023-01-10 08:42:41 UTC
(In reply to Guo, Zhiyi from comment #8)
> Hi Lili, 
> 
>     I cannot verify whether the normal condition works:
> /usr/libexec/qemu-kvm  -audiodev id=audio1,driver=pa -vnc :2 on my
> server(dell 940xa, but any servers should not matter)
> I guess this is due to the desktop environment need to be configured with
> normal user(for starting audio device normally) and properly there should be
> audio device on host as well, here is the strace hint I see:
> # strace /usr/libexec/qemu-kvm  -audiodev id=audio1,driver=spice -vnc :2
> ...
> munmap(0x7fbbd281f000, 43703)           = 0
> newfstatat(AT_FDCWD, "/run/user/0/pulse/pid", 0x7fbbd431ef28, 0) = -1 ENOENT
> (No such file or directory)
> write(2, "audio: ", 7audio: )                  = 7
> write(2, "Could not init `pa' audio driver"..., 33Could not init `pa' audio
> driver
> ) = 33
> exit_group(1)                           = ?
> +++ exited with 1 +++
> ...
> 
> So can you help to verify this issue with a proper audio env?
> 
> Thanks!
> 
> Zhiyi

Hi

1. I defined a guest with non-root user
$ virsh list --all
 Id   Name      State
--------------------------
 -    rhel9.2   shut off

2. check the pulseaudio service
$ systemctl --user status pipewire-pulse.service 
● pipewire-pulse.service - PipeWire PulseAudio
     Loaded: loaded (/usr/lib/systemd/user/pipewire-pulse.service; enabled; preset: disabled)
     Active: active (running) since Tue 2023-01-10 09:21:50 CST; 7h ago
TriggeredBy: ● pipewire-pulse.socket
   Main PID: 2503 (pipewire-pulse)
      Tasks: 2 (limit: 201947)
     Memory: 30.9M
        CPU: 29.697s
     CGroup: /user.slice/user-1000.slice/user/session.slice/pipewire-pulse.service
             └─2503 /usr/bin/pipewire-pulse

Jan 10 09:21:50 localhost.localdomain systemd[2485]: Started PipeWire PulseAudio.
Jan 10 09:21:50 localhost.localdomain pipewire-pulse[2530]: 536870912


3. configure the guest with pulseaudio backend
$ virsh dumpxml rhel9.2 |grep audio
    <audio id='1' type='pulseaudio' serverName='/run/user/1000/pulse/native'/>

4. start the guest
$ virsh start rhel9.2 
error: Failed to start domain 'rhel9.2'
error: internal error: process exited while connecting to monitor: pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver

I will check with the audio driver I installed later

Comment 10 Lili Zhu 2023-01-10 09:03:26 UTC
Tested the bug with:
qemu-kvm-7.2.0-3.el9.x86_64
libvirt-8.10.0-2.el9.x86_64

1. check the audiodev supported by this qemu
$ /usr/libexec/qemu-kvm -audiodev ?
Available audio drivers:
none
pa
wav

2. prepare a guest with non-root user
$ virsh list --all
 Id   Name      State
--------------------------
 -    rhel9.2   shut off

3. config the guest with an unsupported audiodev
$ virsh dumpxml rhel9.2 |grep audio
 <audio id='1' type='coreaudio'/>

4. start the guest
$ virsh start rhel9.2 
error: Failed to start domain 'rhel9.2'
error: internal error: process exited while connecting to monitor: audio: Unknown audio driver `coreaudio'

Qemu prompted fatal error and quit with an unsupported audiodev

Comment 12 Lili Zhu 2023-02-15 07:33:51 UTC
Tested with:
libvirt-9.0.0-3.el9.x86_64
qemu-kvm-7.2.0-6.el9.x86_64


1. define a guest with non-root user
$ virsh list --all
 Id   Name             State
--------------------------------
 1    avocado-vt-vm1   running

2. check the guest audio related definition
...
   <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <sound model='ich9'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1b' function='0x0'/>
    </sound>
    <audio id='1' type='pulseaudio' serverName='/run/user/1000/pulse/native'/>
...

3. start the guest
$ virsh start avocado-vt-vm1 
error: Failed to start domain 'avocado-vt-vm1'
error: internal error: process exited while connecting to monitor: pulseaudio: pa_context_connect() failed
pulseaudio: Reason: Connection refused
pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver

4. solve the issues mentioned by setroubleshoot
# setsebool -P virt_use_xserver 1
# ausearch -c 'qemu-kvm' --raw | audit2allow -M my-qemukvm
# semodule -X 300 -i my-qemukvm.pp

5. start the guest
$ virsh start avocado-vt-vm1
Domain 'avocado-vt-vm1' started

6. check the qemu cmd line
$ ps aux |grep audio
...
 -audiodev {"id":"audio1","driver":"pa","server":"/run/user/1000/pulse/native"} -vnc 127.0.0.1:0,audiodev=audio1 -device {"driver":"cirrus-vga","id":"video0","bus":"pcie.0","addr":"0x1"} -device {"driver":"ich9-intel-hda","id":"sound0","bus":"pcie.0","addr":"0x1b"} -device {"driver":"hda-duplex","id":"sound0-codec0","bus":"sound0.0","cad":0,"audiodev":"audio1"}
...

7. Using virt-viewer to VM and perform audio playback inside VM, can work.

Comment 13 Lili Zhu 2023-02-15 08:30:15 UTC
For the selinux issues in Comment #12, will be tracked in Bug #2169944

According to Comment #10 and Comment #12, mark the bug as verified.

Comment 15 errata-xmlrpc 2023-05-09 07:19:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: qemu-kvm security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:2162