From nobody Mon Feb 9 09:15:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1633622945; cv=none; d=zohomail.com; s=zohoarc; b=CWlw7xZpDeskIJQHMJdDmKEsmdRfDLaxy8O6OVXiOKcCMW6LZhd8GXr2uga0kdvu05YOvjtxxH2VcLVG4F8nYFLddGTZkG9T1QD0en2q2Gus9xRmDv2d6ZzE0AD1YUKisj4zDOv8hGmh/2CIRyyR9fYbuMEs34AfaU11H0HR7J8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1633622945; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LUTFxG5srmOhJ951rt2yPkMpTAMfXjUHErA51fckjtI=; b=eSXDFLVrYXHBvM4yCozPDhEP+aV/S9ve/MO/gBR/iwi2XXH2nIKPpXgachCjR0iTpGN3hsvShnlrIC4S2jrEzrlJPxya3fHB9K984DCXHvZqi8qdBLFbVpLvbF3us+wIuTma+83kWn2J4UaV6tt6afKwiG35pMbOHXckg/MBhus= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1633622945645718.0273510901574; Thu, 7 Oct 2021 09:09:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-dMaGlMTjNtSJPmVIA0fNqA-1; Thu, 07 Oct 2021 12:09:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D0EB5351C51; Thu, 7 Oct 2021 15:51:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E58B5E65E; Thu, 7 Oct 2021 15:50:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 257AA4EA30; Thu, 7 Oct 2021 15:50:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 197FLO5M024637 for ; Thu, 7 Oct 2021 11:21:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 538A16CA5D; Thu, 7 Oct 2021 15:21:23 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B9BD70E63 for ; Thu, 7 Oct 2021 15:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1633622944; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LUTFxG5srmOhJ951rt2yPkMpTAMfXjUHErA51fckjtI=; b=GH4TOe4P6yhzz24NM9g8NjylgRRHhUJidJqaVMDISOmIZ3o9bW0aKglIthF7RKk1+nDUWo 2fXHQjbRfSRLcDdW/OGlFxzHZqJvU3rxOHTlcur6Ril3cBjZ1VHixpKItNu3tnUt/UMql1 e2AM73pqH/Zhbe+7dkjCjB1TEBJ6kVI= X-MC-Unique: dMaGlMTjNtSJPmVIA0fNqA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 099/103] qemuBuildSoundCommandLine: Generate via JSON Date: Thu, 7 Oct 2021 17:18:27 +0200 Message-Id: <4e18a41754a8c10fc7b61996de744dfc9b762c4d.1633619630.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1633622946675100001 Content-Type: text/plain; charset="utf-8" The sound devices have only the 'audiodev' property which is a string. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 324da4adc5..cf56ec3a76 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4447,15 +4447,16 @@ qemuGetAudioIDString(const virDomainDef *def, int i= d) return g_strdup_printf("audio%d", audio->id); } -static char * -qemuBuildSoundDevStr(const virDomainDef *def, +static int +qemuBuildSoundDevCmd(virCommand *cmd, + const virDomainDef *def, virDomainSoundDef *sound, virQEMUCaps *qemuCaps) { - g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + g_autoptr(virJSONValue) props =3D NULL; const char *model =3D NULL; + g_autofree char *audioid =3D NULL; - /* Hack for devices with different names in QEMU and libvirt */ switch (sound->model) { case VIR_DOMAIN_SOUND_MODEL_ES1370: model =3D "ES1370"; @@ -4478,21 +4479,29 @@ qemuBuildSoundDevStr(const virDomainDef *def, case VIR_DOMAIN_SOUND_MODEL_PCSPK: /* pc-speaker is handled separately= */ case VIR_DOMAIN_SOUND_MODEL_ICH7: case VIR_DOMAIN_SOUND_MODEL_LAST: - return NULL; + return -1; } - virBufferAsprintf(&buf, "%s,id=3D%s", model, sound->info.alias); if (!virDomainSoundModelSupportsCodecs(sound) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_AUDIODEV)) { - g_autofree char *audioid =3D qemuGetAudioIDString(def, sound->audi= oId); - if (!audioid) - return NULL; - virBufferAsprintf(&buf, ",audiodev=3D%s", audioid); + if (!(audioid =3D qemuGetAudioIDString(def, sound->audioId))) + return -1; } - if (qemuBuildDeviceAddressStr(&buf, def, &sound->info) < 0) - return NULL; - return virBufferContentAndReset(&buf); + if (virJSONValueObjectCreate(&props, + "s:driver", model, + "s:id", sound->info.alias, + "S:audiodev", audioid, + NULL) < 0) + return -1; + + if (qemuBuildDeviceAddressProps(props, def, &sound->info) < 0) + return -1; + + if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0) + return -1; + + return 0; } @@ -4532,7 +4541,6 @@ qemuBuildSoundCommandLine(virCommand *cmd, for (i =3D 0; i < def->nsounds; i++) { virDomainSoundDef *sound =3D def->sounds[i]; - g_autofree char *str =3D 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 @@ -4543,11 +4551,9 @@ qemuBuildSoundCommandLine(virCommand *cmd, if (qemuCommandAddExtDevice(cmd, &sound->info, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, "-device"); - if (!(str =3D qemuBuildSoundDevStr(def, sound, qemuCaps))) + if (qemuBuildSoundDevCmd(cmd, def, sound, qemuCaps) < 0) return -1; - virCommandAddArg(cmd, str); if (virDomainSoundModelSupportsCodecs(sound)) { for (j =3D 0; j < sound->ncodecs; j++) { g_autofree char *codecstr =3D NULL; --=20 2.31.1