From nobody Mon May 6 02:47:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571122237; cv=none; d=zoho.com; s=zohoarc; b=GG4nGMLXgLstQy3MfhIa1Mmv0PRQI+N0Yod5e6ZJ/i2KPIca7tbWQqQeZ+lt2GHLnylG+2ZIBalJqLeJsCUsQq3l5ERopMuSLZJsKnNojerWAhB5s44v93/2cqQAMO5lkgnCacPi41cAHSz8eFzeox+MFud9Y89fuTum0rfMOLI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571122237; h=Content-Type:Content-Transfer-Encoding:Cc: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=z5NOcDZ4IShjcN3RFU27dacXIt2vwaFiIIKF45ASm2o=; b=Pyl04QE7bqJYyvlBWuLfOM355yjrUKQ67xL2SrOo2KF/ZE6fiw2GnHRgn2hauM7KTY/DBOso3nqyWdkzFJaIQQiFXO/aQLs85IyHExGctzE9A/2PRYERVEN8ePzBXSxwabgAWdiutlEyAVONJULirdejulK1PR1nAA3y5QPJcCE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571122237871674.442037410539; Mon, 14 Oct 2019 23:50:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D31EF308212D; Tue, 15 Oct 2019 06:50:35 +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 96C001001B23; Tue, 15 Oct 2019 06:50:35 +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 E68B14E58A; Tue, 15 Oct 2019 06:50:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9F6gtUN028804 for ; Tue, 15 Oct 2019 02:42:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id B13425CC21; Tue, 15 Oct 2019 06:42:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9B2A610C6 for ; Tue, 15 Oct 2019 06:42:53 +0000 (UTC) Received: from cmccmta3.chinamobile.com (cmccmta3.chinamobile.com [221.176.66.81]) by mx1.redhat.com (Postfix) with ESMTP id 4C9D15D66B for ; Tue, 15 Oct 2019 06:42:41 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by rmmx-syy-dmz-app09-12009 (RichMail) with SMTP id 2ee95da56a4e98f-85c90; Tue, 15 Oct 2019 14:42:23 +0800 (CST) Received: from xiajidong001.localdomain (unknown[223.105.0.241]) by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee75da56a42f00-6f03c; Tue, 15 Oct 2019 14:42:22 +0800 (CST) X-RM-TRANSID: 2ee95da56a4e98f-85c90 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee75da56a42f00-6f03c From: Jidong Xia To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 14:41:27 +0800 Message-Id: <1571121688-31997-2-git-send-email-xiajidong@cmss.chinamobile.com> In-Reply-To: <1571121688-31997-1-git-send-email-xiajidong@cmss.chinamobile.com> References: <1571121688-31997-1-git-send-email-xiajidong@cmss.chinamobile.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 15 Oct 2019 06:42:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 15 Oct 2019 06:42:45 +0000 (UTC) for IP:'221.176.66.81' DOMAIN:'cmccmta3.chinamobile.com' HELO:'cmccmta3.chinamobile.com' FROM:'xiajidong@cmss.chinamobile.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 221.176.66.81 cmccmta3.chinamobile.com 221.176.66.81 cmccmta3.chinamobile.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Jidong Xia Subject: [libvirt] [PATCH 1/2] qemu: cold-plug of sound 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 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 15 Oct 2019 06:50:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" With this patch users can cold plug some sound devices. use "virsh attach-device vm sound.xml --config" command. Consider the following sound.xml for a domain:
Signed-off-by: Jidong Xia --- src/qemu/qemu_driver.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index bc0ede2..8e7156c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8266,6 +8266,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, { virDomainDiskDefPtr disk; virDomainNetDefPtr net; + virDomainSoundDefPtr sound; virDomainHostdevDefPtr hostdev; virDomainLeaseDefPtr lease; virDomainControllerDefPtr controller; @@ -8300,6 +8301,13 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, dev->data.net =3D NULL; break; + case VIR_DOMAIN_DEVICE_SOUND: + sound =3D dev->data.sound; + if (VIR_APPEND_ELEMENT(vmdef->sounds, vmdef->nsounds, sound) < 0) + return -1; + dev->data.sound =3D NULL; + break; + case VIR_DOMAIN_DEVICE_HOSTDEV: hostdev =3D dev->data.hostdev; if (virDomainHostdevFind(vmdef, hostdev, NULL) >=3D 0) { @@ -8434,7 +8442,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, VIR_STEAL_PTR(vmdef->vsock, dev->data.vsock); break; - case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 02:47:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571122069; cv=none; d=zoho.com; s=zohoarc; b=JfIKmwc+ngFbjyJdDz5bA4MHBXdLXlBqL9nR+D5/AWs2F2AX3xmLaHnQw3ZonG2Vb0odYLDuJE7x0vv8+brcdMCe353IaKAI53HcXIUMtvdBHpj8SP2/wrD6mStn7UfXi0TQHhXc5/KLhqwCt61l01FPoPDkbT9utPB/0TQGltQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571122069; h=Content-Type:Content-Transfer-Encoding:Cc: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=jVs/HBXw5NKnAJK88watIhVtTOlqBHSGjQNWhDvo4uk=; b=a3wWjIzEnT7Zd1AJD6YvB3JO2WHQAItSV5Ngu4ZZas5309XeyRy6j7KnPYnMjK6v6q2vvbqVdaX0VwoI+1CvyK9VNvR5BBxBoOmUQRGvBagHptgGK7mU/l7TtFXeNKrjhgtmdHaCOLeZkjMjySzHtwuf0CnL9I6/TwA38OTTMFk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571122068237672.9919074437502; Mon, 14 Oct 2019 23:47:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D36D63003194; Tue, 15 Oct 2019 06:47:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 236BF6012D; Tue, 15 Oct 2019 06:47:45 +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 D3A0018005A0; Tue, 15 Oct 2019 06:47:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9F6h5ss028816 for ; Tue, 15 Oct 2019 02:43:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 642BB60C57; Tue, 15 Oct 2019 06:43:05 +0000 (UTC) Received: from mx1.redhat.com (ext-mx22.extmail.prod.ext.phx2.redhat.com [10.5.110.63]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C89B60C63 for ; Tue, 15 Oct 2019 06:43:02 +0000 (UTC) Received: from cmccmta1.chinamobile.com (cmccmta1.chinamobile.com [221.176.66.79]) by mx1.redhat.com (Postfix) with ESMTP id 5102618CB8FE for ; Tue, 15 Oct 2019 06:42:47 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by rmmx-syy-dmz-app02-12002 (RichMail) with SMTP id 2ee25da56a4fafb-85ebe; Tue, 15 Oct 2019 14:42:23 +0800 (CST) Received: from xiajidong001.localdomain (unknown[223.105.0.241]) by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id 2ee75da56a42f00-6f040; Tue, 15 Oct 2019 14:42:23 +0800 (CST) X-RM-TRANSID: 2ee25da56a4fafb-85ebe X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee75da56a42f00-6f040 From: Jidong Xia To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 14:41:28 +0800 Message-Id: <1571121688-31997-3-git-send-email-xiajidong@cmss.chinamobile.com> In-Reply-To: <1571121688-31997-1-git-send-email-xiajidong@cmss.chinamobile.com> References: <1571121688-31997-1-git-send-email-xiajidong@cmss.chinamobile.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Tue, 15 Oct 2019 06:42:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Tue, 15 Oct 2019 06:42:58 +0000 (UTC) for IP:'221.176.66.79' DOMAIN:'cmccmta1.chinamobile.com' HELO:'cmccmta1.chinamobile.com' FROM:'xiajidong@cmss.chinamobile.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 221.176.66.79 cmccmta1.chinamobile.com 221.176.66.79 cmccmta1.chinamobile.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.63 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Jidong Xia Subject: [libvirt] [PATCH 2/2] qemu: cold-unplug of sound 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 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 15 Oct 2019 06:47:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" With this patch users can cold unplug some sound devices. use "virsh detach-device vm sound.xml --config" command. Signed-off-by: Jidong Xia --- src/conf/domain_conf.c | 61 ++++++++++++++++++++++++++++++++++++++++++++= ++++ src/conf/domain_conf.h | 2 ++ src/libvirt_private.syms | 2 ++ src/qemu/qemu_driver.c | 9 ++++++- 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c1705a0..4083b7c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2754,6 +2754,15 @@ void virDomainSmartcardDefFree(virDomainSmartcardDef= Ptr def) VIR_FREE(def); } +virDomainSoundDefPtr +virDomainSoundDefRemove(virDomainDefPtr def, size_t idx) +{ + virDomainSoundDefPtr ret =3D def->sounds[idx]; + VIR_DELETE_ELEMENT(def->sounds, idx, def->nsounds); + return ret; + } + + void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def) { if (!def) @@ -17211,6 +17220,58 @@ virDomainNetUpdate(virDomainDefPtr def, return 0; } +/** + * virDomainSoundFindIdx: + * @def: domain definition + * @sound: sound definition + * + * Lookup domain's sound interface based on passed @sound + * definition. + * + * Return: index of match if unique match found, + * -1 otherwise and an error is logged. + */ + +int +virDomainSoundFindIdx(virDomainDefPtr def, virDomainSoundDefPtr sound) +{ + size_t i; + int matchidx =3D -1; + bool PCIAddrSpecified =3D virDomainDeviceAddressIsValid(&sound->info, + VIR_DOMAIN_DEVIC= E_ADDRESS_TYPE_PCI); + + for (i =3D 0; i < def->nsounds; i++) { + + if (PCIAddrSpecified && + !virPCIDeviceAddressEqual(&def->sounds[i]->info.addr.pci, + &sound->info.addr.pci)) + continue; + + if (matchidx >=3D 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("multiple matching devices found")); + + return -1; + } + + matchidx =3D i; + } + + if (matchidx < 0) { + if (PCIAddrSpecified) { + virReportError(VIR_ERR_DEVICE_MISSING, + _("no device found on %.4x:%.2x:%.2x.%.1x"), + sound->info.addr.pci.domain, + sound->info.addr.pci.bus, + sound->info.addr.pci.slot, + sound->info.addr.pci.function); + } else { + virReportError(VIR_ERR_DEVICE_MISSING, "%s", + _("no matching device found")); + } + } + return matchidx; +} int virDomainControllerInsert(virDomainDefPtr def, virDomainControllerDefPtr controller) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f7404b8..676c076 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2873,6 +2873,8 @@ void virDomainSmartcardDefFree(virDomainSmartcardDefP= tr def); void virDomainChrDefFree(virDomainChrDefPtr def); int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest, virDomainChrSourceDefPtr src); +int virDomainSoundFindIdx(virDomainDefPtr def, virDomainSoundDefPtr sound); +virDomainSoundDefPtr virDomainSoundDefRemove(virDomainDefPtr def, size_t i= dx); void virDomainSoundCodecDefFree(virDomainSoundCodecDefPtr def); void virDomainSoundDefFree(virDomainSoundDefPtr def); void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7d62df8..c2d9175 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -579,6 +579,8 @@ virDomainSmartcardTypeToString; virDomainSmbiosModeTypeFromString; virDomainSmbiosModeTypeToString; virDomainSoundDefFree; +virDomainSoundDefRemove; +virDomainSoundFindIdx; virDomainSoundModelTypeFromString; virDomainSoundModelTypeToString; virDomainStartupPolicyTypeFromString; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8e7156c..3281bca 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8476,6 +8476,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, { virDomainDiskDefPtr disk, det_disk; virDomainNetDefPtr net; + virDomainSoundDefPtr sound; virDomainHostdevDefPtr hostdev, det_hostdev; virDomainLeaseDefPtr lease, det_lease; virDomainControllerDefPtr cont, det_cont; @@ -8504,6 +8505,13 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, virDomainNetDefFree(virDomainNetRemove(vmdef, idx)); break; + case VIR_DOMAIN_DEVICE_SOUND: + sound =3D dev->data.sound; + if ((idx =3D virDomainSoundFindIdx(vmdef, sound)) < 0) + return -1; + virDomainSoundDefFree(virDomainSoundDefRemove(vmdef, idx)); + break; + case VIR_DOMAIN_DEVICE_HOSTDEV: { hostdev =3D dev->data.hostdev; if ((idx =3D virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) <= 0) { @@ -8634,7 +8642,6 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, vmdef->vsock =3D NULL; break; - case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: -- 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list