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

Aaron Lauterer a.lauterer at proxmox.com
Mon Mar 16 09:11:50 CET 2020



On 3/16/20 8:04 AM, Fabian Grünbichler wrote:
> 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

yep, naming is hard ;)
> 
>> +	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?

I will have to test if this will break live migration. Otherwise naming 
it $audio_backend does seem like a decent name.

> 
>>   	} 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
>>
>>
> 
> _______________________________________________
> 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