[pve-devel] [PATCH manager 1/3] Add audio device support
Aaron Lauterer
a.lauterer at proxmox.com
Mon Jul 15 15:34:10 CEST 2019
Used `audio0` with the extra `0` to be able to add support for multiple
audio devices in the future if it will ever be necessary.
Cleaned some old commented out code regarding audio device support.
Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
---
PVE/QemuServer.pm | 36 ++++++++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 6 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 9f29927..779ae7c 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -234,6 +234,14 @@ my $agent_fmt = {
},
};
+my $audio_fmt = {
+ type => {
+ description => "Select the audio device.",
+ type => 'string',
+ enum => [qw(ich9-intel-hda intel-hda AC97)]
+ },
+};
+
my $vga_fmt = {
type => {
description => "Select the VGA type.",
@@ -637,7 +645,13 @@ EODESCR
format => $ivshmem_fmt,
description => "Inter-VM shared memory. Useful for direct communication between VMs, or to the host.",
optional => 1,
- }
+ },
+ audio0 => {
+ type => 'string',
+ format => $audio_fmt,
+ description => "Configure a audio device.",
+ optional => 1
+ },
};
my $cicustom_fmt = {
@@ -3780,6 +3794,21 @@ sub config_to_command {
}
}
+ # audio devices
+ if ($conf->{"audio0"}) {
+ my $audioproperties = PVE::JSONSchema::parse_property_string($audio_fmt, $conf->{audio0});
+ my $audiodevice = $audioproperties->{type};
+ my $audiopciaddr = print_pci_addr("audio0", $bridges, $arch, $machine_type);
+
+ if ($audiodevice eq 'AC97') {
+ push @$devices, '-device', "AC97,id=sound0$audiopciaddr";
+ }
+ else {
+ push @$devices, '-device', "$audiodevice,id=sound5$audiopciaddr";
+ push @$devices, '-device', "hda-micro,id=sound5-codec0,bus=sound5.0,cad=0";
+ push @$devices, '-device', "hda-duplex,id=sound5-codec1,bus=sound5.0,cad=1";
+ }
+ }
my $sockets = 1;
$sockets = $conf->{smp} if $conf->{smp}; # old style - no longer iused
@@ -3877,11 +3906,6 @@ sub config_to_command {
push @$cmd, '-k', $conf->{keyboard} if defined($conf->{keyboard});
- # enable sound
- #my $soundhw = $conf->{soundhw} || $defaults->{soundhw};
- #push @$cmd, '-soundhw', 'es1370';
- #push @$cmd, '-soundhw', $soundhw if $soundhw;
-
if (parse_guest_agent($conf)->{enabled}) {
my $qgasocket = qmp_socket($vmid, 1);
my $pciaddr = print_pci_addr("qga0", $bridges, $arch, $machine_type);
--
2.20.1
More information about the pve-devel
mailing list