The check for ICH6 || ICH9 is repeated in many places in the code. The
new virDomainSoundModelSupportsCodecs() method provides a helper to
standardize this check.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/conf/domain_conf.c | 11 +++++++++--
src/conf/domain_conf.h | 2 ++
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 4 +---
src/qemu/qemu_validate.c | 3 +--
5 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b6c50f54e5..2837ad67a7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -13764,8 +13764,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;
@@ -30376,6 +30375,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,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 930eed60de..8f2e559884 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3785,6 +3785,8 @@ int virDomainDefFindDevice(virDomainDefPtr def,
virDomainAudioDefPtr
virDomainDefFindAudioForSound(virDomainDefPtr def,
virDomainSoundDefPtr sound);
+bool
+virDomainSoundModelSupportsCodecs(virDomainSoundDefPtr def);
const char *virDomainChrSourceDefGetPath(virDomainChrSourceDefPtr chr);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6b7261b987..2b7bfe76b5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -618,6 +618,7 @@ virDomainSmbiosModeTypeToString;
virDomainSoundDefFind;
virDomainSoundDefFree;
virDomainSoundDefRemove;
+virDomainSoundModelSupportsCodecs;
virDomainSoundModelTypeFromString;
virDomainSoundModelTypeToString;
virDomainStartupPolicyTypeFromString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f255b0f881..4785dfb791 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -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");
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index b9971b66bb..d24300b305 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4199,8 +4199,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;
--
2.29.2