[pve-devel] [PATCH qemu-server] cfg2cmd: Fix audio device backend config

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Mar 16 08:04:22 CET 2020


On March 13, 2020 4:21 pm, Aaron Lauterer wrote:
> Add the `,audiodev=` property to audio devices when machine version is
> 4.2 or higher.
> 
> With Qemu 4.2 a new `audiodev` property was introduced [0] to explicitly
> specify the backend to be used for the audio device. This is accompanied
> with a warning that the fallback to the default audio backend is
> deprecated.
> 
> [0] https://wiki.qemu.org/ChangeLog/4.2#Audio
> 
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
> 
> tested this with all 3 audio devices available in a local VM and one
> live migration from a qemu 4.1 node to a 4.2 node with the default
> ich9-intel-hda dev.
> 
>  PVE/QemuServer.pm | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index b2ff515..6808623 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -3220,12 +3220,18 @@ sub config_to_command {
>  	my $audiopciaddr = print_pci_addr("audio0", $bridges, $arch, $machine_type);
>  
>  	my $id = $audio->{dev_id};
> +
> +	my $audiodevsuffix = '';

this is not a very good variable name

> +	if (min_version($machine_version, 4, 2)) {
> +	    $audiodevsuffix = ",audiodev=$audio->{backend_id}";
> +	}
> +
>  	if ($audio->{dev} eq 'AC97') {
> -	    push @$devices, '-device', "AC97,id=${id}${audiopciaddr}";
> +	    push @$devices, '-device', "AC97,id=${id}${audiopciaddr}${audiodevsuffix}";

because now it looks like this is some suffix of the 'id' option

how about $audio_backend ? would it work to just add 
',audiodev=$audio->{backend_id}' unconditionally? the -audiodev gets 
added unconditionally, so it should always be available?

>  	} elsif ($audio->{dev} =~ /intel\-hda$/) {
>  	    push @$devices, '-device', "$audio->{dev},id=${id}${audiopciaddr}";
> -	    push @$devices, '-device', "hda-micro,id=${id}-codec0,bus=${id}.0,cad=0";
> -	    push @$devices, '-device', "hda-duplex,id=${id}-codec1,bus=${id}.0,cad=1";
> +	    push @$devices, '-device', "hda-micro,id=${id}-codec0,bus=${id}.0,cad=0${audiodevsuffix}";
> +	    push @$devices, '-device', "hda-duplex,id=${id}-codec1,bus=${id}.0,cad=1${audiodevsuffix}";
>  	} else {
>  	    die "unkown audio device '$audio->{dev}', implement me!";
>  	}
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 




More information about the pve-devel mailing list