[PATCH 13/15] qemu: move qemuDomainDeviceDefValidateSound() to qemu_validate.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx>
---
 src/qemu/qemu_domain.c   | 76 +---------------------------------------
 src/qemu/qemu_validate.c | 76 ++++++++++++++++++++++++++++++++++++++++
 src/qemu/qemu_validate.h |  2 ++
 3 files changed, 79 insertions(+), 75 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 110d5b3fb2..ddcc0551db 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5061,80 +5061,6 @@ qemuDomainDeviceDefValidateHub(virDomainHubDefPtr hub,
 }
 
 
-static int
-qemuSoundCodecTypeToCaps(int type)
-{
-    switch (type) {
-    case VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX:
-        return QEMU_CAPS_HDA_DUPLEX;
-    case VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO:
-        return QEMU_CAPS_HDA_MICRO;
-    case VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT:
-        return QEMU_CAPS_HDA_OUTPUT;
-    default:
-        return -1;
-    }
-}
-
-
-static int
-qemuDomainDeviceDefValidateSound(virDomainSoundDefPtr sound,
-                                 virQEMUCapsPtr qemuCaps)
-{
-    size_t i;
-
-    switch ((virDomainSoundModel) sound->model) {
-    case VIR_DOMAIN_SOUND_MODEL_USB:
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_USB_AUDIO)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("usb-audio controller is not supported "
-                             "by this QEMU binary"));
-            return -1;
-        }
-        break;
-    case VIR_DOMAIN_SOUND_MODEL_ICH9:
-        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA)) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("The ich9-intel-hda audio controller "
-                             "is not supported in this QEMU binary"));
-            return -1;
-        }
-        break;
-
-    case VIR_DOMAIN_SOUND_MODEL_ES1370:
-    case VIR_DOMAIN_SOUND_MODEL_AC97:
-    case VIR_DOMAIN_SOUND_MODEL_ICH6:
-    case VIR_DOMAIN_SOUND_MODEL_SB16:
-    case VIR_DOMAIN_SOUND_MODEL_PCSPK:
-        break;
-    case VIR_DOMAIN_SOUND_MODEL_LAST:
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("sound card model '%s' is not supported by qemu"),
-                       virDomainSoundModelTypeToString(sound->model));
-        return -1;
-    }
-
-    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
-        sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
-        for (i = 0; i < sound->ncodecs; i++) {
-            const char *stype;
-            int type, flags;
-
-            type = sound->codecs[i]->type;
-            stype = qemuSoundCodecTypeToString(type);
-            flags = qemuSoundCodecTypeToCaps(type);
-
-            if (flags == -1 || !virQEMUCapsGet(qemuCaps, flags)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                               _("%s not supported in this QEMU binary"), stype);
-                return -1;
-            }
-        }
-    }
-
-    return 0;
-}
-
 static int
 qemuDomainDeviceDefValidateMemory(virDomainMemoryDefPtr mem,
                                   virQEMUCapsPtr qemuCaps)
@@ -5835,7 +5761,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
         break;
 
     case VIR_DOMAIN_DEVICE_SOUND:
-        ret = qemuDomainDeviceDefValidateSound(dev->data.sound, qemuCaps);
+        ret = qemuValidateDomainDeviceDefSound(dev->data.sound, qemuCaps);
         break;
 
     case VIR_DOMAIN_DEVICE_MEMORY:
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 79fc56b849..58ed2512d4 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -22,6 +22,7 @@
 
 #include "qemu_validate.h"
 #include "qemu_block.h"
+#include "qemu_command.h"
 #include "qemu_domain.h"
 #include "domain_conf.h"
 #include "virlog.h"
@@ -3012,3 +3013,78 @@ qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
 
     return 0;
 }
+
+
+static int
+qemuSoundCodecTypeToCaps(int type)
+{
+    switch (type) {
+    case VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX:
+        return QEMU_CAPS_HDA_DUPLEX;
+    case VIR_DOMAIN_SOUND_CODEC_TYPE_MICRO:
+        return QEMU_CAPS_HDA_MICRO;
+    case VIR_DOMAIN_SOUND_CODEC_TYPE_OUTPUT:
+        return QEMU_CAPS_HDA_OUTPUT;
+    default:
+        return -1;
+    }
+}
+
+
+int
+qemuValidateDomainDeviceDefSound(virDomainSoundDefPtr sound,
+                                 virQEMUCapsPtr qemuCaps)
+{
+    size_t i;
+
+    switch ((virDomainSoundModel) sound->model) {
+    case VIR_DOMAIN_SOUND_MODEL_USB:
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_USB_AUDIO)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("usb-audio controller is not supported "
+                             "by this QEMU binary"));
+            return -1;
+        }
+        break;
+    case VIR_DOMAIN_SOUND_MODEL_ICH9:
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ICH9_INTEL_HDA)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("The ich9-intel-hda audio controller "
+                             "is not supported in this QEMU binary"));
+            return -1;
+        }
+        break;
+
+    case VIR_DOMAIN_SOUND_MODEL_ES1370:
+    case VIR_DOMAIN_SOUND_MODEL_AC97:
+    case VIR_DOMAIN_SOUND_MODEL_ICH6:
+    case VIR_DOMAIN_SOUND_MODEL_SB16:
+    case VIR_DOMAIN_SOUND_MODEL_PCSPK:
+        break;
+    case VIR_DOMAIN_SOUND_MODEL_LAST:
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("sound card model '%s' is not supported by qemu"),
+                       virDomainSoundModelTypeToString(sound->model));
+        return -1;
+    }
+
+    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
+        sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
+        for (i = 0; i < sound->ncodecs; i++) {
+            const char *stype;
+            int type, flags;
+
+            type = sound->codecs[i]->type;
+            stype = qemuSoundCodecTypeToString(type);
+            flags = qemuSoundCodecTypeToCaps(type);
+
+            if (flags == -1 || !virQEMUCapsGet(qemuCaps, flags)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("%s not supported in this QEMU binary"), stype);
+                return -1;
+            }
+        }
+    }
+
+    return 0;
+}
diff --git a/src/qemu/qemu_validate.h b/src/qemu/qemu_validate.h
index 623f80fcb2..e61a932809 100644
--- a/src/qemu/qemu_validate.h
+++ b/src/qemu/qemu_validate.h
@@ -60,3 +60,5 @@ int qemuValidateDomainDeviceDefFS(virDomainFSDefPtr fs,
                                   const virDomainDef *def,
                                   virQEMUDriverPtr driver,
                                   virQEMUCapsPtr qemuCaps);
+int qemuValidateDomainDeviceDefSound(virDomainSoundDefPtr sound,
+                                     virQEMUCapsPtr qemuCaps);
-- 
2.25.1






[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux