diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php
index 49345df28..f46d829ca 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/libvirt.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt.php
@@ -839,6 +839,7 @@ class Libvirt {
}
}
$audiodevs_used=[];
+ $soundcards = "";
if (!empty($audios)) {
foreach ($audios as $i => $audio) {
$strSpecialAddressAudio = "";
@@ -847,21 +848,28 @@ class Libvirt {
continue;
}
[$audio_bus, $audio_slot, $audio_function] = my_explode(":", str_replace('.', ':', $audio['id']), 3);
- if ($audio_function != 0) {
- if (isset($multidevices[$audio_bus])) {
- $newaudio_bus = $multidevices[$audio_bus];
- if ($machine_type == "pc") $newaudio_slot = "0x01"; else $newaudio_slot = "0x00";
- $strSpecialAddressAudio = "
";
+ if ($audio_bus == "virtual")
+ {
+ $soundcards .= "
+
+ ";
+ } else {
+ if ($audio_function != 0) {
+ if (isset($multidevices[$audio_bus])) {
+ $newaudio_bus = $multidevices[$audio_bus];
+ if ($machine_type == "pc") $newaudio_slot = "0x01"; else $newaudio_slot = "0x00";
+ $strSpecialAddressAudio = "";
+ }
}
+ $pcidevs .= "
+
+
+
+
+ $strSpecialAddressAudio
+ ";
+ $audiodevs_used[] = $audio['id'];
}
- $pcidevs .= "
-
-
-
-
- $strSpecialAddressAudio
- ";
- $audiodevs_used[] = $audio['id'];
}
}
$pcidevs_used=[];
@@ -951,6 +959,7 @@ class Libvirt {
$vmrc
$scsicontroller
+ $soundcards
$pcidevs
$usbstr
@@ -2257,6 +2266,23 @@ class Libvirt {
return ['pci' => $devs_pci, 'usb' => $devs_usb];
}
+ function domain_get_sound_cards($domain) {
+ $soundcardslist = [];
+ $strDOMXML = $this->domain_get_xml($domain);
+ $xmldoc = new DOMDocument();
+ $xmldoc->loadXML($strDOMXML);
+ $xpath = new DOMXPath($xmldoc);
+ $objNodes = $xpath->query('//domain/devices/sound');
+ if ($objNodes->length > 0) {
+ foreach ($objNodes as $objNode) {
+ $soundcardslist[] = [
+ 'model' => $xpath->query('@model', $objNode)->Item(0)->nodeValue
+ ];
+ }
+ }
+ return $soundcardslist;
+ }
+
function domain_get_vm_pciids($domain) {
$hostdevs=$this->domain_get_host_devices_pci($domain);
$vmpcidevs=[];
diff --git a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
index e5b7be2eb..35461b16a 100644
--- a/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
+++ b/emhttp/plugins/dynamix.vm.manager/include/libvirt_helpers.php
@@ -971,6 +971,21 @@ class Array2XML {
return $arrValidAudioDevices;
}
+ function getValidSoundCards() {
+ $arrValidSoundCards = [
+ 'ich6' => ['name' => 'ich6','id' => 'virtual::ich6'],
+ 'ich7' => ['name' => 'ich7','id' => 'virtual::ich7'],
+ 'ich9' => ['name' => 'ich9','id' => 'virtual::ich9'],
+ 'ac97' => ['name' => 'ac97','id' => 'virtual::ac97'],
+ 'es1370' => ['name' => 'es1370','id' => 'virtual::es1370'],
+ 'pcspk' => ['name' => 'pcspk','id' => 'virtual::pcspk'],
+ 'sb16' => ['name' => 'sb16','id' => 'virtual::sb16'],
+ 'usb' => ['name' => 'usb','id' => 'virtual::usb'],
+ 'virtio' => ['name' => 'virtio','id' => 'virtual::virtio'],
+ ];
+ return $arrValidSoundCards;
+ }
+
function getValidOtherDevices() {
$arrValidPCIDevices = getValidPCIDevices();
@@ -1277,6 +1292,7 @@ class Array2XML {
$arrNICs = $lv->get_nic_info($res);
$arrHostDevs = $lv->domain_get_host_devices_pci($res);
$arrUSBDevs = $lv->domain_get_host_devices_usb($res);
+ $arrSoundCards = $lv->domain_get_sound_cards($res);
$getcopypaste=getcopypaste($res);
// Metadata Parsing
@@ -1348,6 +1364,10 @@ class Array2XML {
];
}
+ if (!empty($arrSoundCards)) {
+ foreach ($arrSoundCards as $sckey => $soundcard) $arrAudioDevices[] = ['id' => "virtual::".$soundcard['model']];
+ }
+
// Add claimed USB devices by this VM to the available USB devices
/*
foreach($arrUSBDevs as $arrUSB) {
@@ -1532,6 +1552,7 @@ class Array2XML {
unset($old['devices']['input']);
// preserve vnc/spice port settings
// unset($new['devices']['graphics']['@attributes']['port'],$new['devices']['graphics']['@attributes']['autoport']);
+ unset($old['devices']['sound']);
unset($old['devices']['graphics']);
if (!isset($new['devices']['graphics']['@attributes']['keymap']) && isset($old['devices']['graphics']['@attributes']['keymap'])) unset($old['devices']['graphics']['@attributes']['keymap']);
// update parent arrays
diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
index 120804553..5382cb95b 100644
--- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
+++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php
@@ -27,6 +27,7 @@ $arrValidMachineTypes = getValidMachineTypes();
$arrValidPCIDevices = getValidPCIDevices();
$arrValidGPUDevices = getValidGPUDevices();
$arrValidAudioDevices = getValidAudioDevices();
+$arrValidSoundCards = getValidSoundCards();
$arrValidOtherDevices = getValidOtherDevices();
$arrValidUSBDevices = getValidUSBDevices();
$arrValidDiskDrivers = getValidDiskDrivers();
@@ -1445,6 +1446,7 @@ foreach ($arrConfig['shares'] as $i => $arrShare) {
echo mk_option($arrAudio['id'], '', _('None'));
foreach ($arrValidAudioDevices as $arrDev) echo mk_option($arrAudio['id'], $arrDev['id'], $arrDev['name'].' ('.$arrDev['id'].')');
+ foreach ($arrValidSoundCards as $arrSound) echo mk_option($arrAudio['id'], $arrSound['id'], $arrSound['name'].' ('._("Virtual").')');
?>
@@ -1470,6 +1472,7 @@ foreach ($arrConfig['shares'] as $i => $arrShare) {