From patchwork Fri Jan 22 19:30:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 60196 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp51395lbb; Fri, 22 Jan 2016 11:33:26 -0800 (PST) X-Received: by 10.194.156.199 with SMTP id wg7mr5573324wjb.114.1453491196220; Fri, 22 Jan 2016 11:33:16 -0800 (PST) Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com. [209.132.183.25]) by mx.google.com with ESMTPS id e8si10051481wjx.113.2016.01.22.11.33.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 22 Jan 2016 11:33:16 -0800 (PST) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0MJUxNA001613; Fri, 22 Jan 2016 14:30:59 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u0MJUnlU019979 for ; Fri, 22 Jan 2016 14:30:49 -0500 Received: from colepc.redhat.com (ovpn-113-198.phx2.redhat.com [10.3.113.198]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0MJUaPb002518; Fri, 22 Jan 2016 14:30:48 -0500 From: Cole Robinson To: libvirt-list@redhat.com Date: Fri, 22 Jan 2016 14:30:29 -0500 Message-Id: <876a5b94f4d289c59b465259037a8e26729bd441.1453489952.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/17] qemu: command: Drop old style -soundhw usage X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com 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(-) -- 2.5.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list 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); } }