From nobody Sun Feb 8 11:45:45 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=1617723114; cv=none; d=zohomail.com; s=zohoarc; b=Q7BSKTTd+qH6bjqLFNbQBe8aGbqt+JLBemIOkB+/xyvoiMS3jfJeItQqY4EpwOourDcMllQippCAcxzJmteBP8LeGZrO7I0qYbpu9DmrGJBxS2+abHnNH/xMkJF0iUbZP6tRW4ThfEGwGel8cmxLUXJRHj5j2EnlGdbximg7mhU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617723114; 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=wsTu1zCAsVa/k1bsiHKAbUXQoy26EhBiTb0U47VIgNs=; b=DjZxg5PsRwEjjbOJiszfwDEQd1dmT/yYi67+GqcPhpj7dmVDLk/NhJC4d3y4CcDZACiYVTKIoI6HMUnQSOqmZg7RDR8blyGou8/MbfyxIdzX9O6NGeDkC4R93nFMUlRbqsC0v0tNHDIcpffc5mE6WwVlqvMw1RzNN2m3HqdBxho= 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 1617723114679414.3025030694033; Tue, 6 Apr 2021 08:31:54 -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-272--lsxI-p9PFGvTurVv5Yd8g-1; Tue, 06 Apr 2021 11:31:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0EE41083E81; Tue, 6 Apr 2021 15:31: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 D4EB560854; Tue, 6 Apr 2021 15:31:43 +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 2BF8A1809C83; Tue, 6 Apr 2021 15:31:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 136FVfik023687 for ; Tue, 6 Apr 2021 11:31:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 437415DAA5; Tue, 6 Apr 2021 15:31:41 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-114-172.ams2.redhat.com [10.36.114.172]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DCE45D9D0; Tue, 6 Apr 2021 15:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617723113; 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=wsTu1zCAsVa/k1bsiHKAbUXQoy26EhBiTb0U47VIgNs=; b=fEmS6PxQ/rJD816EvhSAUtEi5UcHXEJcbzo0K19CFh3wMIBc85htHLlo8yXp4EjwrVjW+r 4mL2Y40+0R6npf+YPQ/eh1/qVnrpkSL5RgqgPrd9ae4gst0svyS3Tr1Mbi4WpWgIc3W7vi YoAChLvUrg6zllC/15XwNmWzs5HGSnI= X-MC-Unique: -lsxI-p9PFGvTurVv5Yd8g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/6] conf: add support for for PCI devices Date: Tue, 6 Apr 2021 16:31:32 +0100 Message-Id: <20210406153137.314183-2-berrange@redhat.com> In-Reply-To: <20210406153137.314183-1-berrange@redhat.com> References: <20210406153137.314183-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.13 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 | 6 +++ docs/schemas/domaincommon.rng | 73 +++++++++++++++++++++++++++++++++++ src/conf/device_conf.h | 3 ++ src/conf/domain_conf.c | 12 ++++++ 4 files changed, 94 insertions(+) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 7ba32ea9c1..5db0aac77a 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -4363,6 +4363,7 @@ Network interfaces + ... @@ -4389,6 +4390,11 @@ 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. + :anchor:`` =20 Virtual network diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 2ff7862539..30108b6d4c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1441,6 +1441,9 @@ + + + @@ -2432,6 +2435,9 @@ + + + @@ -2860,6 +2866,9 @@ + + + @@ -3517,6 +3526,9 @@ + + + @@ -4143,6 +4155,9 @@ + + + @@ -4283,6 +4298,9 @@ + + + @@ -4535,6 +4553,9 @@ + + + @@ -4939,6 +4960,9 @@ + + + @@ -5008,6 +5032,9 @@ + + + @@ -5040,6 +5067,9 @@ + + + @@ -5118,6 +5148,9 @@ + + + @@ -5162,6 +5195,9 @@ + + + @@ -5189,6 +5225,9 @@ + + + @@ -5284,6 +5323,9 @@ + + + @@ -5386,6 +5428,9 @@ + + + @@ -5401,6 +5446,9 @@ + + + @@ -5420,6 +5468,9 @@ + + + @@ -5451,6 +5502,9 @@ + + + @@ -6422,6 +6476,16 @@ =20 + + + + + + + + + + @@ -6460,6 +6524,9 @@ + + + @@ -6551,6 +6618,9 @@ + + + @@ -7530,6 +7600,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 1e72171586..ef921ae41a 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; --=20 2.30.2