From nobody Mon Sep 16 19:09:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1683632760; cv=none; d=zohomail.com; s=zohoarc; b=P+5cPzpeZSBtTxpcyF/zA3Vg9WQehBk/E07jPQOXY+fVWjcca/VX21Fwa4IbYqMvpPP8TSgGpWOfjzUd7vLhPmZXVpkquPpK+2+dq03ECRXWnA4dntNanI6IBUBMB1Echa/RLZv3aiNutJJNg1DtfgP4rgRK7sGTRY2stbf+gYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683632760; 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=1QgprO4RlkaPZ7JZ9foGfdpgdnGnVmMJ9LZwWhwXOwg=; b=fGf6eBevBij/bmVOo+vr2qXgUSyliMXQfF9bTIqKoUIGP5QeyaCwOpqbyDslBbjrUQq7WhrtMeLyKT4QS3+sJydSyfhO3nTpSDvHddB+j2eNfCVz79aXZ3e03NGtT2Yr4QYJC/95mz8JoFIT7JXyaDoTYAbu5Evx+o6V9ngRbRc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1683632760512165.61911127233543; Tue, 9 May 2023 04:46:00 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-fntbKU_NPCuN55Si4rebhw-1; Tue, 09 May 2023 07:45:56 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EADC488D037; Tue, 9 May 2023 11:45:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D661D40F15C; Tue, 9 May 2023 11:45:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BC9AE19452D1; Tue, 9 May 2023 11:45:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2A96319465BC for ; Tue, 9 May 2023 11:45:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1057D492C13; Tue, 9 May 2023 11:45:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80200492C3F for ; Tue, 9 May 2023 11:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683632759; 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=1QgprO4RlkaPZ7JZ9foGfdpgdnGnVmMJ9LZwWhwXOwg=; b=G4bM5fVKpY42M4SKPScNMYfxQ8Dmb0h9Qi+EEAR8KXN6Rr5rQPXdjjZjK0A0XOBOpFGZ/a RHTwWaKPtb0RN5hBUWhChQ+ei552SM+qwsa0U1TKIGj4qJsnoiSd0sw7Si1t30SZ/kwv0k Ph0T6tHLXkNRjgxRK7x4O/hdVj0AemM= X-MC-Unique: fntbKU_NPCuN55Si4rebhw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 5/5] conf: qemu: Add support for multi-channel mode for 'usb' sound cards Date: Tue, 9 May 2023 13:45:46 +0200 Message-Id: <09ff6ca77f04809b87fd9ce09ab54e61ba747254.1683632708.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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: 1683632761697100007 Content-Type: text/plain; charset="utf-8" Allow users controlling the multi-channel mode by adding a 'multichannel' property parsed for USB audio devices and wire up the support in the qemu driver. Closes: https://gitlab.com/libvirt/libvirt/-/issues/472 Signed-off-by: Peter Krempa --- docs/formatdomain.rst | 5 ++++ src/conf/domain_conf.c | 23 +++++++++++++++++++ src/conf/domain_conf.h | 4 ++++ src/conf/schemas/domaincommon.rng | 5 ++++ src/qemu/qemu_command.c | 3 +++ .../sound-device.x86_64-4.2.0.args | 2 +- .../sound-device.x86_64-latest.args | 2 +- tests/qemuxml2argvdata/sound-device.xml | 2 +- .../sound-device.x86_64-latest.xml | 2 +- 9 files changed, 44 insertions(+), 4 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index d62bda9adb..99383e725c 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -7235,6 +7235,11 @@ Valid values are: ... +:since:`Since 9.4.0` the ``usb`` sound device can be optionally switched i= nto +multi-channel mode by using the ``multichannel`` attribute:: + + + Each ``sound`` element has an optional sub-element ``
`` which can= tie the device to a particular PCI slot. See `Device Addresses`_. diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 204b6a85e1..6a864a8db9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11689,6 +11689,12 @@ virDomainSoundDefParseXML(virDomainXMLOption *xmlo= pt, } } + if (def->model =3D=3D VIR_DOMAIN_SOUND_MODEL_USB) { + if (virXMLPropTristateBool(node, "multichannel", VIR_XML_PROP_NONE, + &def->multichannel) < 0) + return NULL; + } + audioNode =3D virXPathNode("./audio", ctxt); if (audioNode) { if (virXMLPropUInt(audioNode, "id", 10, @@ -11721,6 +11727,9 @@ virDomainSoundDefEquals(const virDomainSoundDef *a, return false; } + if (a->multichannel !=3D b->multichannel) + return false; + if (a->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && !virDomainDeviceInfoAddressIsEqual(&a->info, &b->info)) return false; @@ -20010,6 +20019,14 @@ virDomainSoundDefCheckABIStability(virDomainSoundD= ef *src, return false; } + if (src->multichannel !=3D dst->multichannel) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target sound card multichannel setting '%1$s' do= es not match source '%2$s'"), + virTristateBoolTypeToString(dst->multichannel), + virTristateBoolTypeToString(src->multichannel)); + return false; + } + if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) return false; @@ -24531,6 +24548,12 @@ virDomainSoundDefFormat(virBuffer *buf, virBufferAsprintf(&attrBuf, " model=3D'%s'", model); + if (def->model =3D=3D VIR_DOMAIN_SOUND_MODEL_USB && + def->multichannel !=3D VIR_TRISTATE_BOOL_ABSENT) { + virBufferAsprintf(&attrBuf, " multichannel=3D'%s'", + virTristateBoolTypeToString(def->multichannel)); + } + virXMLFormatElement(buf, "sound", &attrBuf, &childBuf); return 0; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index a04f7decc6..c1cb2ed69d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1596,6 +1596,10 @@ struct _virDomainSoundDef { size_t ncodecs; virDomainSoundCodecDef **codecs; + /* VIR_DOMAIN_SOUND_MODEL_USB can be optionally switched to + * multi-channel mode */ + virTristateBool multichannel; + unsigned int audioId; }; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 57fb4a5e33..f8c7b6a648 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -4969,6 +4969,11 @@ usb + + + + + diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index dcad449413..2a6d9408f6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4384,6 +4384,7 @@ qemuBuildSoundDevCmd(virCommand *cmd, g_autoptr(virJSONValue) props =3D NULL; const char *model =3D NULL; g_autofree char *audioid =3D NULL; + virTristateBool multichannel =3D VIR_TRISTATE_BOOL_ABSENT; switch (sound->model) { case VIR_DOMAIN_SOUND_MODEL_ES1370: @@ -4397,6 +4398,7 @@ qemuBuildSoundDevCmd(virCommand *cmd, break; case VIR_DOMAIN_SOUND_MODEL_USB: model =3D "usb-audio"; + multichannel =3D sound->multichannel; break; case VIR_DOMAIN_SOUND_MODEL_ICH9: model =3D "ich9-intel-hda"; @@ -4419,6 +4421,7 @@ qemuBuildSoundDevCmd(virCommand *cmd, "s:driver", model, "s:id", sound->info.alias, "S:audiodev", audioid, + "T:multi", multichannel, NULL) < 0) return -1; diff --git a/tests/qemuxml2argvdata/sound-device.x86_64-4.2.0.args b/tests/= qemuxml2argvdata/sound-device.x86_64-4.2.0.args index 121b37ff99..b2a5afd8c8 100644 --- a/tests/qemuxml2argvdata/sound-device.x86_64-4.2.0.args +++ b/tests/qemuxml2argvdata/sound-device.x86_64-4.2.0.args @@ -44,7 +44,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -device hda-micro,id=3Dsound7-codec0,bus=3Dsound7.0,cad=3D0,audiodev=3Daud= io1 \ -device hda-duplex,id=3Dsound7-codec1,bus=3Dsound7.0,cad=3D1,audiodev=3Dau= dio1 \ -device hda-output,id=3Dsound7-codec2,bus=3Dsound7.0,cad=3D2,audiodev=3Dau= dio1 \ --device usb-audio,id=3Dsound8,audiodev=3Daudio1,bus=3Dusb.0,port=3D1 \ +-device usb-audio,id=3Dsound8,audiodev=3Daudio1,multi=3Don,bus=3Dusb.0,por= t=3D1 \ -device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x8 \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/sound-device.x86_64-latest.args b/tests= /qemuxml2argvdata/sound-device.x86_64-latest.args index 3132760fe0..e0a2f21b31 100644 --- a/tests/qemuxml2argvdata/sound-device.x86_64-latest.args +++ b/tests/qemuxml2argvdata/sound-device.x86_64-latest.args @@ -44,7 +44,7 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGue= st1/.config \ -device '{"driver":"hda-micro","id":"sound7-codec0","bus":"sound7.0","cad"= :0,"audiodev":"audio1"}' \ -device '{"driver":"hda-duplex","id":"sound7-codec1","bus":"sound7.0","cad= ":1,"audiodev":"audio1"}' \ -device '{"driver":"hda-output","id":"sound7-codec2","bus":"sound7.0","cad= ":2,"audiodev":"audio1"}' \ --device '{"driver":"usb-audio","id":"sound8","audiodev":"audio1","bus":"us= b.0","port":"1"}' \ +-device '{"driver":"usb-audio","id":"sound8","audiodev":"audio1","multi":t= rue,"bus":"usb.0","port":"1"}' \ -device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x8"}' \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ -msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/sound-device.xml b/tests/qemuxml2argvda= ta/sound-device.xml index 35a60da197..c58033235c 100644 --- a/tests/qemuxml2argvdata/sound-device.xml +++ b/tests/qemuxml2argvdata/sound-device.xml @@ -34,7 +34,7 @@ - + diff --git a/tests/qemuxml2xmloutdata/sound-device.x86_64-latest.xml b/test= s/qemuxml2xmloutdata/sound-device.x86_64-latest.xml index 89f537bb01..29d700cebb 100644 --- a/tests/qemuxml2xmloutdata/sound-device.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/sound-device.x86_64-latest.xml @@ -52,7 +52,7 @@
- +