[PATCH 14/17] qemu: command: Drop old style -soundhw usage

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

 



Even platforms that don't handle -device well cannot use this... they
either have sound hardware baked in, or none at all. So this can be
safely dropped.

I changed the code a bit short circuit the loop for the pcspk case,
which allows us to unindent the main logic some more
---
 src/qemu/qemu_command.c | 104 ++++++++++++++++--------------------------------
 1 file changed, 35 insertions(+), 69 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 278f4f6..733d498 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10697,84 +10697,50 @@ qemuBuildCommandLine(virConnectPtr conn,
     }
 
     /* Add sound hardware */
-    if (def->nsounds) {
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-            for (i = 0; i < def->nsounds; i++) {
-                virDomainSoundDefPtr sound = def->sounds[i];
-                char *str = NULL;
-
-                /* Sadly pcspk device doesn't use -device syntax. Fortunately
-                 * we don't need to set any PCI address on it, so we don't
-                 * mind too much */
-                if (sound->model == VIR_DOMAIN_SOUND_MODEL_PCSPK) {
-                    virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL);
-                } else {
-                    virCommandAddArg(cmd, "-device");
-                    if (!(str = qemuBuildSoundDevStr(def, sound, qemuCaps)))
-                        goto error;
+    for (i = 0; i < def->nsounds; i++) {
+        virDomainSoundDefPtr sound = def->sounds[i];
+        char *str = NULL;
+
+        /* Sadly pcspk device doesn't use -device syntax. Fortunately
+         * we don't need to set any PCI address on it, so we don't
+         * mind too much */
+        if (sound->model == VIR_DOMAIN_SOUND_MODEL_PCSPK) {
+            virCommandAddArgList(cmd, "-soundhw", "pcspk", NULL);
+            continue;
+        }
 
-                    virCommandAddArg(cmd, str);
-                    VIR_FREE(str);
-                    if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
-                        sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
-                        char *codecstr = NULL;
+        virCommandAddArg(cmd, "-device");
+        if (!(str = qemuBuildSoundDevStr(def, sound, qemuCaps)))
+            goto error;
 
-                        for (j = 0; j < sound->ncodecs; j++) {
-                            virCommandAddArg(cmd, "-device");
-                            if (!(codecstr = qemuBuildSoundCodecStr(sound, sound->codecs[j], qemuCaps))) {
-                                goto error;
+        virCommandAddArg(cmd, str);
+        VIR_FREE(str);
+        if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
+            sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
+            char *codecstr = NULL;
 
-                            }
-                            virCommandAddArg(cmd, codecstr);
-                            VIR_FREE(codecstr);
-                        }
-                        if (j == 0) {
-                            virDomainSoundCodecDef codec = {
-                                VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
-                                0
-                            };
-                            virCommandAddArg(cmd, "-device");
-                            if (!(codecstr = qemuBuildSoundCodecStr(sound, &codec, qemuCaps))) {
-                                goto error;
+            for (j = 0; j < sound->ncodecs; j++) {
+                virCommandAddArg(cmd, "-device");
+                if (!(codecstr = qemuBuildSoundCodecStr(sound, sound->codecs[j], qemuCaps))) {
+                    goto error;
 
-                            }
-                            virCommandAddArg(cmd, codecstr);
-                            VIR_FREE(codecstr);
-                        }
-                    }
                 }
-            }
-        } else {
-            int size = 100;
-            char *modstr;
-            if (VIR_ALLOC_N(modstr, size+1) < 0)
-                goto error;
-
-            for (i = 0; i < def->nsounds && size > 0; i++) {
-                virDomainSoundDefPtr sound = def->sounds[i];
-                const char *model = virDomainSoundModelTypeToString(sound->model);
-                if (!model) {
-                    VIR_FREE(modstr);
-                    virReportError(VIR_ERR_INTERNAL_ERROR,
-                                   "%s", _("invalid sound model"));
+                virCommandAddArg(cmd, codecstr);
+                VIR_FREE(codecstr);
+            }
+            if (j == 0) {
+                virDomainSoundCodecDef codec = {
+                    VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
+                    0
+                };
+                virCommandAddArg(cmd, "-device");
+                if (!(codecstr = qemuBuildSoundCodecStr(sound, &codec, qemuCaps))) {
                     goto error;
-                }
 
-                if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6 ||
-                    sound->model == VIR_DOMAIN_SOUND_MODEL_ICH9) {
-                    VIR_FREE(modstr);
-                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                                   _("this QEMU binary lacks hda support"));
-                    goto error;
                 }
-
-                strncat(modstr, model, size);
-                size -= strlen(model);
-                if (i < (def->nsounds - 1))
-                    strncat(modstr, ",", size--);
+                virCommandAddArg(cmd, codecstr);
+                VIR_FREE(codecstr);
             }
-            virCommandAddArgList(cmd, "-soundhw", modstr, NULL);
-            VIR_FREE(modstr);
         }
     }
 
-- 
2.5.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]