]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: add helper to test for sound device codec support
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 2 Mar 2021 13:46:28 +0000 (13:46 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 9 Mar 2021 22:58:04 +0000 (22:58 +0000)
The check for ICH6 || ICH9 is repeated in many places in the code. The
new virDomainSoundModelSupportsCodecs() method provides a helper to
standardize this check.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/domain_conf.c
src/conf/domain_conf.h
src/libvirt_private.syms
src/qemu/qemu_command.c
src/qemu/qemu_validate.c

index 756459eacbc6237af6bd0ec0254b487fdfc32805..5831c3b77b472427bf4df6da0f9cdca1e7f16bc1 100644 (file)
@@ -13774,8 +13774,7 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xmlopt,
         goto error;
     }
 
-    if (def->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
-        def->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
+    if (virDomainSoundModelSupportsCodecs(def)) {
         int ncodecs;
         g_autofree xmlNodePtr *codecNodes = NULL;
 
@@ -30356,6 +30355,14 @@ virDomainDefFindAudioForSound(virDomainDefPtr def,
 }
 
 
+bool
+virDomainSoundModelSupportsCodecs(virDomainSoundDefPtr def)
+{
+    return def->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
+        def->model == VIR_DOMAIN_SOUND_MODEL_ICH9;
+}
+
+
 char *
 virDomainObjGetMetadata(virDomainObjPtr vm,
                         int type,
index 39b678af8086b81105fecae6afdeb8b8b30804db..d613d304958d61be81bac5df76bf4c5a55100e43 100644 (file)
@@ -3786,6 +3786,8 @@ int virDomainDefFindDevice(virDomainDefPtr def,
 virDomainAudioDefPtr
 virDomainDefFindAudioForSound(virDomainDefPtr def,
                               virDomainSoundDefPtr sound);
+bool
+virDomainSoundModelSupportsCodecs(virDomainSoundDefPtr def);
 
 const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);
 
index d6d3f7b6775bfc225e5c15bd71adf0efb4d0c84b..a1ff1130e258f445c7eec38d7ff9e852293ef532 100644 (file)
@@ -618,6 +618,7 @@ virDomainSmbiosModeTypeToString;
 virDomainSoundDefFind;
 virDomainSoundDefFree;
 virDomainSoundDefRemove;
+virDomainSoundModelSupportsCodecs;
 virDomainSoundModelTypeFromString;
 virDomainSoundModelTypeToString;
 virDomainStartupPolicyTypeFromString;
index 4461c2762fed5ab1e5809b5141e6718b53f65bcc..e64d966222071bcc7d01e7e86cb77b52eeaecabb 100644 (file)
@@ -4101,9 +4101,7 @@ qemuBuildSoundCommandLine(virCommandPtr cmd,
                 return -1;
 
             virCommandAddArg(cmd, str);
-            if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
-                sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
-
+            if (virDomainSoundModelSupportsCodecs(sound)) {
                 for (j = 0; j < sound->ncodecs; j++) {
                     g_autofree char *codecstr = NULL;
                     virCommandAddArg(cmd, "-device");
index f97d09ff8095056e7d6145eeddae0c1036a06814..23f5363dd0cfb74aa6823fe83827d86b6d59f9b9 100644 (file)
@@ -4219,8 +4219,7 @@ qemuValidateDomainDeviceDefSound(virDomainSoundDefPtr sound,
         return -1;
     }
 
-    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
-        sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
+    if (virDomainSoundModelSupportsCodecs(sound)) {
         for (i = 0; i < sound->ncodecs; i++) {
             const char *stype;
             int type, flags;