[pve-devel] [PATCH v2 qemu-server] cfg2cmd: Add the audiodev property to audio devs

Aaron Lauterer a.lauterer at proxmox.com
Fri Mar 27 13:24:57 CET 2020



On 3/27/20 12:22 PM, Thomas Lamprecht wrote:
> On 3/16/20 11:02 AM, Aaron Lauterer wrote:
>> 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>
>> ---
>> v1 [1]->v2:
>> the audiodev property is always set, omitting the machine version check.
> 
> Why is that OK, doesn't that breaks using a 4.1 QEMU?

Interestingly enough not in my tests.

In the v1 version of this code I did have a version check to only add it 
with qemu >=4.2. Live migration from qemu 4.2 (with the parameter set) 
to 4.1 did not show any problems in my tests.

The same goes with this code now. Starting a VM in qemu 4.1 works as 
well as migrating between 4.2 and 4.1.

My guess is that qemu 4.1 just ignores the audiodev property and falls 
back to the only audiodev that we define just below the area the patch 
touches (-audiodev spice,id=...)

If I am not mistaken, the audiodev backend seems to be a qemu backend 
thing that does not affect the hardware of the VM.

The following blog post [0] by one of the qemu devs explains the new 
property and what can be done with it quite nicely. At the bottom is an 
example that is similar to our use case.

[0] https://www.kraxel.org/blog/2020/01/qemu-sound-audiodev/

> 
>>
>> tested live migration with all 3 audio devs in both directions.
>>
>>
>> [1] https://pve.proxmox.com/pipermail/pve-devel/2020-March/042381.html
>>
>>   PVE/QemuServer.pm | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
>> index b2ff515..0905e04 100644
>> --- a/PVE/QemuServer.pm
>> +++ b/PVE/QemuServer.pm
>> @@ -3221,11 +3221,11 @@ sub config_to_command {
>>   
>>   	my $id = $audio->{dev_id};
>>   	if ($audio->{dev} eq 'AC97') {
>> -	    push @$devices, '-device', "AC97,id=${id}${audiopciaddr}";
>> +	    push @$devices, '-device', "AC97,id=${id}${audiopciaddr},audiodev=$audio->{backend_id}";
>>   	} 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,audiodev=$audio->{backend_id}";
>> +	    push @$devices, '-device', "hda-duplex,id=${id}-codec1,bus=${id}.0,cad=1,audiodev=$audio->{backend_id}";
>>   	} else {
>>   	    die "unkown audio device '$audio->{dev}', implement me!";
>>   	}
>>
> 




More information about the pve-devel mailing list