]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: sound: Handle all possible sound cards in switch statement
authorPeter Krempa <pkrempa@redhat.com>
Fri, 25 Jul 2014 08:24:40 +0000 (10:24 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 28 Jul 2014 08:46:33 +0000 (10:46 +0200)
Use correct type in the switch and handle all sound card models in it so
that the compiler tracks additions.

src/qemu/qemu_command.c

index cdf77401c92181a3461a29b05b1efa0ea533ee57..cb3c5847862c4ab8ab16e5cbdd4278a480866a7b 100644 (file)
@@ -4674,16 +4674,10 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
                      virQEMUCapsPtr qemuCaps)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
-    const char *model = virDomainSoundModelTypeToString(sound->model);
-
-    if (!model) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("invalid sound model"));
-        goto error;
-    }
+    const char *model;
 
     /* Hack for devices with different names in QEMU and libvirt */
-    switch (sound->model) {
+    switch ((virDomainSoundModel) sound->model) {
     case VIR_DOMAIN_SOUND_MODEL_ES1370:
         model = "ES1370";
         break;
@@ -4702,6 +4696,15 @@ qemuBuildSoundDevStr(virDomainDefPtr def,
             goto error;
         }
         break;
+    case VIR_DOMAIN_SOUND_MODEL_SB16:
+        model = "sb16";
+        break;
+    case VIR_DOMAIN_SOUND_MODEL_PCSPK: /* pc-speaker is handled separately */
+    case VIR_DOMAIN_SOUND_MODEL_LAST:
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("sound card model '%s' is not supported by qemu"),
+                       virDomainSoundModelTypeToString(sound->model));
+        goto error;
     }
 
     virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);