[libvirt PATCH 10/18] conf: rename and improve virDomainDefFindAudioForSound

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

 



The virDomainDefFindAudioForSound only takes a virDomainSoundDefPtr as
its arg, but we want to use the same functionality for VNC graphics.
In addition if audio ID is zero, then we want to return the first
available audio backend.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/bhyve/bhyve_command.c |  2 +-
 src/conf/domain_conf.c    | 14 +++++++++-----
 src/conf/domain_conf.h    |  4 ++--
 src/libvirt_private.syms  |  2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index b03a1f26b7..f5a20208d7 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -765,7 +765,7 @@ virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver, virDomainDefPtr def,
 
     for (i = 0; i < def->nsounds; i++) {
         if (bhyveBuildSoundArgStr(def, def->sounds[i],
-                                  virDomainDefFindAudioForSound(def, def->sounds[i]),
+                                  virDomainDefFindAudioByID(def, def->sounds[i]->audioId),
                                   driver, cmd) < 0)
             goto error;
     }
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c3a21b4c78..c51a1d3bea 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -30545,13 +30545,17 @@ virDomainDefFindDevice(virDomainDefPtr def,
 
 
 virDomainAudioDefPtr
-virDomainDefFindAudioForSound(virDomainDefPtr def,
-                              virDomainSoundDefPtr sound)
+virDomainDefFindAudioByID(const virDomainDef *def,
+                          int id)
 {
     size_t i;
-    for (i = 0; i < def->naudios; i++)
-        if (def->audios[i]->id == sound->audioId)
-            return def->audios[i];
+    if (id != 0) {
+        for (i = 0; i < def->naudios; i++)
+            if (def->audios[i]->id == id)
+                return def->audios[i];
+    } else if (def->naudios) {
+        return def->audios[0];
+    }
 
     return NULL;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a3432f7e8a..586fd7761f 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3811,8 +3811,8 @@ int virDomainDefFindDevice(virDomainDefPtr def,
                            bool reportError);
 
 virDomainAudioDefPtr
-virDomainDefFindAudioForSound(virDomainDefPtr def,
-                              virDomainSoundDefPtr sound);
+virDomainDefFindAudioByID(const virDomainDef *def,
+                          int id);
 bool
 virDomainSoundModelSupportsCodecs(virDomainSoundDefPtr def);
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2b7bfe76b5..5af6339674 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -300,7 +300,7 @@ virDomainDefCheckABIStability;
 virDomainDefCheckABIStabilityFlags;
 virDomainDefCompatibleDevice;
 virDomainDefCopy;
-virDomainDefFindAudioForSound;
+virDomainDefFindAudioByID;
 virDomainDefFindDevice;
 virDomainDefFormat;
 virDomainDefFormatConvertXMLFlags;
-- 
2.29.2




[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