From nobody Sun Feb 8 05:59:07 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=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