From nobody Thu Mar 28 18:01:59 2024 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=1617812742; cv=none; d=zohomail.com; s=zohoarc; b=KhFn3zzGgrFnQAsEDkunh0aB3MsvfpiOllaCAPe5TR7uz75G2vIsLQhoImjLoJCB44rimaZiXzDRmvto/sTLZLUr/SU2lV02k6DhX7vGFzR4dLAWX2aujtRen19dlL9+pnZyCu8ziA09fWzZZTWDnciqK283aiffRrWJtXFS2iY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617812742; 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=hNv+h5Bq5ct1MQgFGp/ToG7MZjvPCSDrq+IKaPaNgPU=; b=KG0JBwm5UvzMX2c8gN0/s4lX1QDWOb7Ds3hFU4hlQwYJXLoDf8hdsLkxd/X8nPodmG7J7ItbZqtK1BbxHHWXVxRbLEPTrDJv9KZMVx7PDwj3Tsn3jsXMXcCo2V7K+pWoJKhN41fXcbgnOkx72TtxOFefLfLtup9THXICTeogcFg= 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) header.from= 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 1617812742470386.69073058113156; Wed, 7 Apr 2021 09:25:42 -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-358-Xywj1t4tOtmsE8Ky3LwL_w-1; Wed, 07 Apr 2021 12:25:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 10A7B8189CB; Wed, 7 Apr 2021 16:25:34 +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 DF3E05C27C; Wed, 7 Apr 2021 16:25:33 +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 9CC1D1806D14; Wed, 7 Apr 2021 16:25:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 137GOloJ010984 for ; Wed, 7 Apr 2021 12:24:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0397F1822A; Wed, 7 Apr 2021 16:24:47 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-28.ams2.redhat.com [10.36.115.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A1CC1DB; Wed, 7 Apr 2021 16:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617812741; 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=hNv+h5Bq5ct1MQgFGp/ToG7MZjvPCSDrq+IKaPaNgPU=; b=YSSNhG5ej3JOfbWvFmqZkhL1C2pJIOYeV1hK/r0AYJUQd7ejsibtS2JxQkBzoeWPx7unJ8 VVe3UfD1D5+UadkGSsGL0nZ0qRRqblCtScOTa0+GVUpqcD1MA9XK1uTntO35vWGOXP63ca IGCUcPuN5CATAoUA6teZNqqIVOEHozg= X-MC-Unique: Xywj1t4tOtmsE8Ky3LwL_w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 1/5] conf: add support for for PCI devices Date: Wed, 7 Apr 2021 17:24:36 +0100 Message-Id: <20210407162440.421508-2-berrange@redhat.com> In-Reply-To: <20210407162440.421508-1-berrange@redhat.com> References: <20210407162440.421508-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) PCI devices can be associated with a unique integer index that is exposed via ACPI. In Linux OS with systemd, this value is used for provide a NIC device naming scheme that is stable across changes in PCI slot configuration. Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/formatdomain.rst | 7 ++++ docs/schemas/domaincommon.rng | 73 +++++++++++++++++++++++++++++++++++ src/conf/device_conf.h | 3 ++ src/conf/domain_conf.c | 19 +++++++++ 4 files changed, 102 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 782ebc8564..29d2e02da1 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -4363,6 +4363,7 @@ Network interfaces + ... @@ -4389,6 +4390,12 @@ when it's in the reserved VMware range by adding a `= `type=3D"static"`` attribute to the ```` element. Note that this attribute is useless if the prov= ided MAC address is outside of the reserved VMWare ranges. =20 +:since:`Since 7.3.0`, one can set the ACPI index against network interface= s. +With some operating systems (eg Linux with systemd), the ACPI index is used +to provide network interface device naming, that is stable across changes +in PCI addresses assigned to the device. This value is required to be uniq= ue +across all devices and be between 1 and (16*1024-1). + :anchor:`` =20 Virtual network diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 73ce253821..99cd873832 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1444,6 +1444,9 @@ + + + @@ -2435,6 +2438,9 @@ + + + @@ -2863,6 +2869,9 @@ + + + @@ -3520,6 +3529,9 @@ + + + @@ -4146,6 +4158,9 @@ + + + @@ -4286,6 +4301,9 @@ + + + @@ -4538,6 +4556,9 @@ + + + @@ -4942,6 +4963,9 @@ + + + @@ -5011,6 +5035,9 @@ + + + @@ -5043,6 +5070,9 @@ + + + @@ -5121,6 +5151,9 @@ + + + @@ -5165,6 +5198,9 @@ + + + @@ -5192,6 +5228,9 @@ + + + @@ -5287,6 +5326,9 @@ + + + @@ -5389,6 +5431,9 @@ + + + @@ -5404,6 +5449,9 @@ + + + @@ -5423,6 +5471,9 @@ + + + @@ -5454,6 +5505,9 @@ + + + @@ -6425,6 +6479,16 @@ =20 + + + + + + + + + + @@ -6463,6 +6527,9 @@ + + + @@ -6554,6 +6621,9 @@ + + + @@ -7546,6 +7616,9 @@ + + + diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index a51bdf10ee..af9a43bff2 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -159,6 +159,9 @@ struct _virDomainDeviceInfo { /* bootIndex is only used for disk, network interface, hostdev * and redirdev devices */ unsigned int bootIndex; + /* Valid for any PCI device. Can be used for NIC to get + * stable numbering in Linux */ + unsigned int acpiIndex; =20 /* pciConnectFlags is only used internally during address * assignment, never saved and never reported. diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f93af0a85c..83415f9271 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6335,6 +6335,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } =20 + if (info->acpiIndex !=3D 0) + virBufferAsprintf(buf, "\n", info->acpiIndex); + if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) /* We're done here */ @@ -6661,6 +6664,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xml= opt, g_autofree char *romenabled =3D NULL; g_autofree char *rombar =3D NULL; g_autofree char *aliasStr =3D NULL; + g_autofree char *acpiIndex =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 virDomainDeviceInfoClear(info); @@ -6709,6 +6713,14 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xm= lopt, } } =20 + acpiIndex =3D virXPathString("string(./acpi/@index)", ctxt); + if (acpiIndex && + virStrToLong_ui(acpiIndex, NULL, 10, &info->acpiIndex) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Cannot parse ACPI index value '%s'"), acpiIndex); + goto cleanup; + } + if ((address =3D virXPathNode("./address", ctxt)) && virDomainDeviceAddressParseXML(address, info) < 0) goto cleanup; @@ -22193,6 +22205,13 @@ virDomainDeviceInfoCheckABIStability(virDomainDevi= ceInfoPtr src, break; } =20 + if (src->acpiIndex !=3D dst->acpiIndex) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target ACPI index '%u' does not match source '%u= '"), + dst->acpiIndex, src->acpiIndex); + return false; + } + return true; } =20 --=20 2.30.2 From nobody Thu Mar 28 18:01:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1617812748; cv=none; d=zohomail.com; s=zohoarc; b=BTy2udPHKqP+JkCbruJYqNWQhB98KaqKe6WE6KSepdc4kbQ3K1pdz9A6pi8kCPxYVSwlBtU0xesxlKFyd4GiIIjDJ1UO6dq0iKlfn4qAi7nBBY4VVs6tkgiwB2ofMcHIrA+sAunImAU9L3scuupd4PKbLGsV2845gUkocEs3Qjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617812748; 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=tiv6bBVHE1Iiilej8Fcd+hCSx7zwC4C9j8hWXLwLaDc=; b=FKqGCHQ2kwOs0kZ7jeYJzsc70ZqnmqsxMWBKQaPeLX/nrPKczAQWSviFCwDL5mKNrZdgHzSjRZjJWDBJF5pYNi2HYYkQBysrk8q3MhHrC/spojCwDNRvUJMBTv5x/JPL227KYuw4ioDO+Zh8bIluCtss+0NCbzjwZmUDvm8F4+U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1617812748671477.4706089798651; Wed, 7 Apr 2021 09:25:48 -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-571-dRSI3WNROlWrknke07Z-0Q-1; Wed, 07 Apr 2021 12:25:44 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55408107ACF2; Wed, 7 Apr 2021 16:25:37 +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 2EB5419CB4; Wed, 7 Apr 2021 16:25:37 +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 E2FA255343; Wed, 7 Apr 2021 16:25:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 137GOmv1010994 for ; Wed, 7 Apr 2021 12:24:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2840A58823; Wed, 7 Apr 2021 16:24:48 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-28.ams2.redhat.com [10.36.115.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50A905C27C; Wed, 7 Apr 2021 16:24:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617812747; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=tiv6bBVHE1Iiilej8Fcd+hCSx7zwC4C9j8hWXLwLaDc=; b=FviZC040mMZmM0AOZ0jVI4a0OqpVVxUaQfMnRymstGP1mrbn4L1lGE5d6M7umHyBzJ7q9I mxeKysbcqiNHaF6t94bTEAo4TGfeoRjCtCKdFkXlFQ3uMcySqLQx7TwSnydqw6soEZOgu+ XbDfZv0IOrdenyw9Fdt6cYnQoAlSSO8= X-MC-Unique: dRSI3WNROlWrknke07Z-0Q-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/5] qemu: fix indentation off-by-1 Date: Wed, 7 Apr 2021 17:24:37 +0100 Message-Id: <20210407162440.421508-3-berrange@redhat.com> In-Reply-To: <20210407162440.421508-1-berrange@redhat.com> References: <20210407162440.421508-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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.11 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7cb07306f3..20fba45780 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -418,7 +418,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, virBufferAddLit(buf, ",multifunction=3Doff"); virBufferAsprintf(buf, ",addr=3D0x%x", info->addr.pci.slot); if (info->addr.pci.function !=3D 0) - virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); + virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); } else if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { if (!(contAlias =3D virDomainControllerAliasFind(domainDef, VIR_DOMAIN_CONTROLL= ER_TYPE_USB, --=20 2.30.2 From nobody Thu Mar 28 18:01:59 2024 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=1617812748; cv=none; d=zohomail.com; s=zohoarc; b=DTf1l5NnavYxXgv6iYKUmRlYThh7mYmnA82ReoTF0o+ifgTuGSHcIJ177/lNgFU1TbKsZRE4CwTp2mM1oBg58oiFH8mvxzQsSsOU3ITeOwtcxxh4fQsG6lBIz485d0GQqBcjqL2LoHi+xyP5IkSmOEREHUs1uE9vOh5jZBi3EMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617812748; 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=7QcM+kxxVAMq1vTDCIvi/w5L0mM/huoQJQgupHbvnmI=; b=eWeXnTs8XbvkLPOIs6+YASw8vqGTesRmGdQXRoxWeIg8yJHN1Vh0xie1ZHkjSKIaiFA2v6oZhmUR2XUV2lI0tDJzaLH0WIfvAqL5Kpx8pwpeyODBWoSdZArl7D1eStPHY57BN+xMzf1l83pwnfmMNXKI2vdugygh5QlN6Fhi1lI= 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) header.from= 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 161781274895121.192881805855563; Wed, 7 Apr 2021 09:25:48 -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-220-dyEYlwudOlO0FLJUY16cZw-1; Wed, 07 Apr 2021 12:25:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C8AD107ACC7; Wed, 7 Apr 2021 16:25:40 +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 59F50610AE; Wed, 7 Apr 2021 16:25:40 +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 1A0D81806D17; Wed, 7 Apr 2021 16:25:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 137GOnve011009 for ; Wed, 7 Apr 2021 12:24:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 41EAE5C27C; Wed, 7 Apr 2021 16:24:49 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-28.ams2.redhat.com [10.36.115.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7587C58823; Wed, 7 Apr 2021 16:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617812747; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=7QcM+kxxVAMq1vTDCIvi/w5L0mM/huoQJQgupHbvnmI=; b=fCZM+u2pbGAwX6kEX/UV+3FEY0/l7WPcWh9RkuLtfsKY2YkHZSedquflXQIGPvS3XyNnrG WgpfpxX97HC4vCpJPxHGX4kh3VCMQ2PKclEbrYrnN1Df4Pp9IFIKh76LfyH8Pf7RcshySB kSStRxpzLzXywPUJAGjhXeqjaI/l8dI= X-MC-Unique: dyEYlwudOlO0FLJUY16cZw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 3/5] qemu: use a switch when building device addresses Date: Wed, 7 Apr 2021 17:24:38 +0100 Message-Id: <20210407162440.421508-4-berrange@redhat.com> In-Reply-To: <20210407162440.421508-1-berrange@redhat.com> References: <20210407162440.421508-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Peter Krempa 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The compiler can more easily optimize a switch, and more importantly can also warn when new address types are added which are not handled. Reviewed-by: Peter Krempa Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 20fba45780..02f9d16f63 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -351,7 +351,8 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, bool contIsPHB =3D false; int contTargetIndex =3D 0; =20 - if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + switch ((virDomainDeviceAddressType)info->type) { + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: { size_t i; =20 if (!(devStr =3D virPCIDeviceAddressAsString(&info->addr.pci))) @@ -419,7 +420,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, virBufferAsprintf(buf, ",addr=3D0x%x", info->addr.pci.slot); if (info->addr.pci.function !=3D 0) virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); - } else if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { + } + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: if (!(contAlias =3D virDomainControllerAliasFind(domainDef, VIR_DOMAIN_CONTROLL= ER_TYPE_USB, info->addr.usb.bus)= )) @@ -429,23 +433,45 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, virBufferAddLit(buf, ",port=3D"); virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port); } - } else if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: if (info->addr.spaprvio.has_reg) virBufferAsprintf(buf, ",reg=3D0x%08llx", info->addr.spaprvio.= reg); - } else if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) { + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: if (info->addr.ccw.assigned) virBufferAsprintf(buf, ",devno=3D%x.%x.%04x", info->addr.ccw.cssid, info->addr.ccw.ssid, info->addr.ccw.devno); - } else if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA) { + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: virBufferAsprintf(buf, ",iobase=3D0x%x,irq=3D0x%x", info->addr.isa.iobase, info->addr.isa.irq); - } else if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) { + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: virBufferAsprintf(buf, ",slot=3D%d", info->addr.dimm.slot); if (info->addr.dimm.base) virBufferAsprintf(buf, ",addr=3D%llu", info->addr.dimm.base); + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO: + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED: + break; + + case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST: + virReportEnumRangeError(virDomainDeviceAddressType, info->type); + return -1; } =20 return 0; --=20 2.30.2 From nobody Thu Mar 28 18:01:59 2024 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=1617812735; cv=none; d=zohomail.com; s=zohoarc; b=AdWjxIRPr8cxaeEu/zGMnYOwDF5Q00WAzL0vgx5TiZhffwy3tVr/qXggwYiecX3j/fXb8Pj5k9JMmWx/vShY434+xxJI8sv5O1ktFI+miFfeP2dMiRL3M0Gg0HepALICW2p0vGpAm8jy3yBoNOc0uU+cOP758hLCdRcEfz/ASic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617812735; 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=Aez2Wld+ddc1iskjAr2ku6DWukN84gCKjzcEjA1ATtQ=; b=UEi4eaB+8Naenk+e9CWVPwmA+XqJl5ii8TtWyUeuDifBeJvMXbFtiVXJPc++cV+uGFVHrwEy152QuLAro25ZxREQKg1TMRZsXOftYiA7GQTeS9NTRRIz/NeJvgSj5tz8sOPOVoHGa3ee/d8RdT2WBbcWmEif5xTPRkxpdTPA7Oc= 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) header.from= 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 1617812735086248.46779060778658; Wed, 7 Apr 2021 09:25:35 -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-94-EUMiD5LSOkCSxKN41YaEOA-1; Wed, 07 Apr 2021 12:25:31 -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 EC6D08030B5; Wed, 7 Apr 2021 16:25:25 +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 8B4375D6CF; Wed, 7 Apr 2021 16:25:24 +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 DE1601806D11; Wed, 7 Apr 2021 16:25:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 137GOoH4011020 for ; Wed, 7 Apr 2021 12:24:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 37EF518811; Wed, 7 Apr 2021 16:24:50 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-28.ams2.redhat.com [10.36.115.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E19F58823; Wed, 7 Apr 2021 16:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617812734; 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=Aez2Wld+ddc1iskjAr2ku6DWukN84gCKjzcEjA1ATtQ=; b=Zklc4cB5AhD+Lxt4NSDjPm6FlEwvF+qLEhPPFILC74kDWXSyQ4HYUjgJGKnXz2TfkH0mWB InoeKrZ+NQBiDWDi2l4ebUtFMnQN6/1j1jZ2jnwSX9m48PhbrSsfX7gwh075vA/syHL9V8 yyHg3PsnaRwhrR7UchuhHdFotWftv5k= X-MC-Unique: EUMiD5LSOkCSxKN41YaEOA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 4/5] qemu: probe for "acpi-index" property Date: Wed, 7 Apr 2021 17:24:39 +0100 Message-Id: <20210407162440.421508-5-berrange@redhat.com> In-Reply-To: <20210407162440.421508-1-berrange@redhat.com> References: <20210407162440.421508-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) This property is exposed by QEMU on any PCI device, but we have to pick some specific device(s) to probe it against. We expect that at least one of the virtio devices will be present, so probe against them. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 6 ++++++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml | 1 + 3 files changed, 8 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 41ef199a79..37ed750f8b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -628,6 +628,7 @@ VIR_ENUM_IMPL(virQEMUCaps, =20 /* 400 */ "compat-deprecated", + "acpi-index", ); =20 =20 @@ -1366,6 +1367,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsVirtioBalloon[] { "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL }, { "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL }, { "free-page-reporting", QEMU_CAPS_VIRTIO_BALLOON_FREE_PAGE_REPORTING,= NULL }, + { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, }; =20 =20 @@ -1398,6 +1400,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsVirtioBlk[] =3D { { "write-cache", QEMU_CAPS_DISK_WRITE_CACHE, NULL }, { "werror", QEMU_CAPS_STORAGE_WERROR, NULL }, { "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL }, + { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, }; =20 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVirtioNet[= ] =3D { @@ -1411,6 +1414,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsVirtioNet[] =3D { { "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL }, { "failover", QEMU_CAPS_VIRTIO_NET_FAILOVER, NULL }, { "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL }, + { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, }; =20 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsPCIeRootPo= rt[] =3D { @@ -1431,6 +1435,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsVirtioSCSI[] =3D { { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, NULL }, { "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL }, { "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL }, + { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, }; =20 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsVfioPCI[] = =3D { @@ -1502,6 +1507,7 @@ static struct virQEMUCapsDevicePropsFlags virQEMUCaps= DevicePropsVirtioGpu[] =3D { { "iommu_platform", QEMU_CAPS_VIRTIO_PCI_IOMMU_PLATFORM, NULL }, { "ats", QEMU_CAPS_VIRTIO_PCI_ATS, NULL }, { "packed", QEMU_CAPS_VIRTIO_PACKED_QUEUES, NULL }, + { "acpi-index", QEMU_CAPS_ACPI_INDEX, NULL }, }; =20 static struct virQEMUCapsDevicePropsFlags virQEMUCapsDevicePropsICH9[] =3D= { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index c553a5f4a4..1ca9c1ea7b 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -608,6 +608,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ =20 /* 400 */ QEMU_CAPS_COMPAT_DEPRECATED, /* -compat deprecated-(input|output) is s= upported */ + QEMU_CAPS_ACPI_INDEX, /* PCI device 'acpi-index' property */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_6.0.0.x86_64.xml index 8d12645a8e..8cc949d735 100644 --- a/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_6.0.0.x86_64.xml @@ -262,6 +262,7 @@ + 5002092 0 43100242 --=20 2.30.2 From nobody Thu Mar 28 18:01:59 2024 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=1617812791; cv=none; d=zohomail.com; s=zohoarc; b=bq8/ZKGDf8xGtKywTNVgVTLPw0HmKWPewzH4yrtMjI5uyHOt1mujLg8bpfW2iJHCuQHtNWXHfmiiYNklQftEhF7s9BN7EUYorF2VnG75sVkin+pUm+BeiupTXqw1VMGP6NgvQL2UZw2KHEM5NadJIDuEEanjrXPY68tPCpBUm+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617812791; 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=ArUpT9Y4AUM3sX8gCrP0GDp3aJm0aTtD8DQ5BHXYYDA=; b=RYa7qP5i6DANw9DYu1KJx+lXrwE2Tv2hwsKbSrtHBz9qtG6hhwmANInE5tiD2WJoImYHwhQn2fMYyx5GhlbPyGjfeCNnStCiRrGoh3Cv0zXGMQ6Mo7mrggGViyF5SFjytF5nDorWZiWnD3hKnq+oEhfzOWueH6L5yOIBs/3ocoQ= 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) header.from= 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 161781279155427.019778495525657; Wed, 7 Apr 2021 09:26:31 -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-38-XgcbyIOaOR60FGvhFtOVgg-1; Wed, 07 Apr 2021 12:26:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45861E99C1; Wed, 7 Apr 2021 16:26:23 +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 1FF45610AF; Wed, 7 Apr 2021 16:26:23 +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 D6ACF55344; Wed, 7 Apr 2021 16:26:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 137GOpws011030 for ; Wed, 7 Apr 2021 12:24:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 38DB11822A; Wed, 7 Apr 2021 16:24:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-28.ams2.redhat.com [10.36.115.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 819001DB; Wed, 7 Apr 2021 16:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617812790; 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=ArUpT9Y4AUM3sX8gCrP0GDp3aJm0aTtD8DQ5BHXYYDA=; b=My0Kj/jPG6FV60sDLIAh+wojXVIcRf9YyeHz3tYP8z1H2i3Q5kRw+K5saetWtkIUydvaLn e88R1xq11sXFSCXGf3PAN+3XKjQL9XmIZr2XFWgImSYmtXVLzC1HVmqriRMXvzEw1CUlp/ 3ifAtlOj8/XAXmFxVfHtcrulTU+nrEA= X-MC-Unique: XgcbyIOaOR60FGvhFtOVgg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 5/5] qemu: wire up command line support for ACPI index Date: Wed, 7 Apr 2021 17:24:40 +0100 Message-Id: <20210407162440.421508-6-berrange@redhat.com> In-Reply-To: <20210407162440.421508-1-berrange@redhat.com> References: <20210407162440.421508-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) This makes it possible to enable stable NIC device names in most modern Linux distros. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 2 + src/qemu/qemu_validate.c | 35 +++++++++ .../devices-acpi-index.x86_64-latest.args | 57 +++++++++++++++ tests/qemuxml2argvdata/devices-acpi-index.xml | 62 ++++++++++++++++ tests/qemuxml2argvtest.c | 2 + .../devices-acpi-index.x86_64-latest.xml | 73 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 7 files changed, 233 insertions(+) create mode 100644 tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest= .args create mode 100644 tests/qemuxml2argvdata/devices-acpi-index.xml create mode 100644 tests/qemuxml2xmloutdata/devices-acpi-index.x86_64-late= st.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 02f9d16f63..45eb0dc976 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -420,6 +420,8 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, virBufferAsprintf(buf, ",addr=3D0x%x", info->addr.pci.slot); if (info->addr.pci.function !=3D 0) virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); + if (info->acpiIndex !=3D 0) + virBufferAsprintf(buf, ",acpi-index=3D%u", info->acpiIndex); } break; =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 09778085a8..27afcab9aa 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1069,6 +1069,32 @@ qemuValidateDomainDefPanic(const virDomainDef *def, } =20 =20 +static int +qemuValidateDomainDeviceInfo(virDomainDefPtr def G_GNUC_UNUSED, + virDomainDeviceDefPtr dev G_GNUC_UNUSED, + virDomainDeviceInfoPtr info, + void *opaque) +{ + virQEMUCapsPtr qemuCaps =3D opaque; + + if (info->acpiIndex) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_INDEX)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ACPI index is not supported with this QEMU")= ); + return -1; + } + + if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ACPI index is only supported for PCI devices= ")); + return -1; + } + } + + return 0; +} + int qemuValidateDomainDef(const virDomainDef *def, void *opaque, @@ -1235,6 +1261,15 @@ qemuValidateDomainDef(const virDomainDef *def, return -1; } =20 + /* Explicitly discarding 'const' from 'def' is ok because + * we know our callback qemuValidateDomainDeviceInfo will + * not modify it + */ + if (virDomainDeviceInfoIterate((virDomainDefPtr)def, + qemuValidateDomainDeviceInfo, + qemuCaps) < 0) + return -1; + return 0; } =20 diff --git a/tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args b= /tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args new file mode 100644 index 0000000000..07a8b0d189 --- /dev/null +++ b/tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args @@ -0,0 +1,57 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-fdr-br \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-fdr-br/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-fdr-br/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-fdr-br/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dfdr-br,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw",\ +"file":"/tmp/lib/domain--1-fdr-br/master-key.aes"}' \ +-machine pc-i440fx-5.0,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,\ +memory-backend=3Dpc.ram \ +-cpu qemu64 \ +-m 2048 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":2147483648}= ' \ +-overcommit mem-lock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-uuid 3ec6cbe1-b5a2-4515-b800-31a61855df41 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test.img",\ +"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw= ",\ +"file":"libvirt-2-storage"}' \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x3,acpi-index=3D1,drive=3Dlibvi= rt-2-format,\ +id=3Dvirtio-disk0,bootindex=3D1 \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test1.img"= ,\ +"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ",\ +"file":"libvirt-1-storage"}' \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,acpi-index=3D42,drive=3Dlibv= irt-1-format,\ +id=3Dvirtio-disk1 \ +-netdev user,id=3Dhostnet0 \ +-device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D00:11:22:33:44:55= ,bus=3Dpci.0,\ +addr=3D0x5,acpi-index=3D100 \ +-netdev user,id=3Dhostnet1 \ +-device virtio-net-pci,netdev=3Dhostnet1,id=3Dnet1,mac=3D00:11:22:33:44:55= ,bus=3Dpci.0,\ +addr=3D0x7,acpi-index=3D200 \ +-netdev user,id=3Dhostnet2 \ +-device virtio-net-pci,netdev=3Dhostnet2,id=3Dnet2,mac=3D00:11:22:33:44:55= ,bus=3Dpci.0,\ +addr=3D0x8,acpi-index=3D300 \ +-audiodev id=3Daudio1,driver=3Dnone \ +-device cirrus-vga,id=3Dvideo0,bus=3Dpci.0,addr=3D0x2,acpi-index=3D1729 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x6 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/devices-acpi-index.xml b/tests/qemuxml2= argvdata/devices-acpi-index.xml new file mode 100644 index 0000000000..5d0176e7fe --- /dev/null +++ b/tests/qemuxml2argvdata/devices-acpi-index.xml @@ -0,0 +1,62 @@ + + fdr-br + 3ec6cbe1-b5a2-4515-b800-31a61855df41 + 2097152 + 2097152 + 2 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + +