[pve-devel] [PATCH qemu-server 2/2] vnc: connect to audio device if there is one

Dominik Csapak d.csapak at proxmox.com
Fri Apr 4 11:43:03 CEST 2025


this is in preparation of noVNC audio support. For that to work we have
to connect vnc to the audiodev, else qemu does not know which device
to encode audio from. Since we only can have one audio device, simply
use that if it exists.

This works simultaneously for SPICE and VNC. Live migration is not
impacted, since it's only a logical change and not a hardware change.
(Tested live-migration multiple times in both directions, worked without
any issues).

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/QemuServer.pm           | 4 +++-
 test/cfg2cmd/audio.conf.cmd | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 96786a96..dfdbee99 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -3706,7 +3706,9 @@ sub config_to_command {
 	push @$cmd, '-display', 'egl-headless,gl=core' if $vga->{type} eq 'virtio-gl'; # VIRGL
 
 	my $socket = PVE::QemuServer::Helpers::vnc_socket($vmid);
-	push @$cmd,  '-vnc', "unix:$socket,password=on";
+	my $audioconf = conf_has_audio($conf);
+	my $audiodev = defined($audioconf) ? ",audiodev=$audioconf->{backend_id}" : "";
+	push @$cmd,  '-vnc', "unix:$socket,password=on$audiodev";
     } else {
 	push @$cmd, '-vga', 'none' if $vga->{type} eq 'none';
 	push @$cmd, '-nographic';
diff --git a/test/cfg2cmd/audio.conf.cmd b/test/cfg2cmd/audio.conf.cmd
index add6f55d..7014bf51 100644
--- a/test/cfg2cmd/audio.conf.cmd
+++ b/test/cfg2cmd/audio.conf.cmd
@@ -12,7 +12,7 @@
   -smp '3,sockets=1,cores=3,maxcpus=3' \
   -nodefaults \
   -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
-  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
+  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on,audiodev=none-backend0' \
   -cpu kvm64,enforce,+kvm_pv_eoi,+kvm_pv_unhalt,+lahf_lm,+sep \
   -m 768 \
   -device 'pci-bridge,id=pci.1,chassis_nr=1,bus=pci.0,addr=0x1e' \
-- 
2.39.5





More information about the pve-devel mailing list