43fe83
From 2d3d991158a202c50c6c74c6b910b0facb5dcc37 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <2d3d991158a202c50c6c74c6b910b0facb5dcc37.1380703761.git.jdenemar@redhat.com>
43fe83
From: Laine Stump <laine@laine.org>
43fe83
Date: Fri, 27 Sep 2013 05:19:42 -0600
43fe83
Subject: [PATCH] qemu: replace multiple strcmps with a switch on an enum
43fe83
43fe83
I'm not sure why this code was written to compare the strings that it
43fe83
had just retrieved from an enum->string conversion, rather than just
43fe83
look at the original enum values, but this yields the same results,
43fe83
and is much more efficient (especially as you add more devices).
43fe83
43fe83
This is a prerequisite for patches to resolve:
43fe83
43fe83
   https://bugzilla.redhat.com/show_bug.cgi?id=1003983
43fe83
43fe83
(cherry picked from commit 8e0dab3a8e2e4b0c580739587fa4a474c7a4afc8)
43fe83
43fe83
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
43fe83
---
43fe83
 src/qemu/qemu_command.c | 13 +++++++++----
43fe83
 1 file changed, 9 insertions(+), 4 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
43fe83
index f025e8c..8b03470 100644
43fe83
--- a/src/qemu/qemu_command.c
43fe83
+++ b/src/qemu/qemu_command.c
43fe83
@@ -5131,13 +5131,18 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
43fe83
         goto error;
43fe83
     }
43fe83
 
43fe83
-    /* Hack for weirdly unusual devices name in QEMU */
43fe83
-    if (STREQ(model, "es1370"))
43fe83
+    /* Hack for devices with different names in QEMU and libvirt */
43fe83
+    switch (sound->model) {
43fe83
+    case VIR_DOMAIN_SOUND_MODEL_ES1370:
43fe83
         model = "ES1370";
43fe83
-    else if (STREQ(model, "ac97"))
43fe83
+        break;
43fe83
+    case VIR_DOMAIN_SOUND_MODEL_AC97:
43fe83
         model = "AC97";
43fe83
-    else if (STREQ(model, "ich6"))
43fe83
+        break;
43fe83
+    case VIR_DOMAIN_SOUND_MODEL_ICH6:
43fe83
         model = "intel-hda";
43fe83
+        break;
43fe83
+    }
43fe83
 
43fe83
     virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);
43fe83
     if (qemuBuildDeviceAddressStr(&buf, def, &sound->info, qemuCaps) < 0)
43fe83
-- 
43fe83
1.8.3.2
43fe83