Re: [libvirt PATCH 1/6] conf: add support for <acpi index='NNN'/> for PCI devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 06, 2021 at 16:31:32 +0100, Daniel Berrange wrote:
> 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é <berrange@xxxxxxxxxx>
> ---
>  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
>         <mac address='52:54:00:5d:c7:9e'/>
>         <boot order='1'/>
>         <rom bar='off'/>
> +       <acpi index='4'/>
>       </interface>
>     </devices>
>     ...
> @@ -4389,6 +4390,11 @@ when it's in the reserved VMware range by adding a ``type="static"`` attribute
>  to the ``<mac/>`` element. Note that this attribute is useless if the provided
>  MAC address is outside of the reserved VMWare ranges.
>  
> +:since:`Since 7.3.0`, one can set the ACPI index against network interfaces.
> +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.

Any range limits or uniqueness requirements worth mentioning?

> +
>  :anchor:`<a id="elementsNICSVirtual"/>`
>  
>  Virtual network


[...]

> 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;
>  
>      /* 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");
>      }
>  
> +    if (info->acpiIndex != 0)
> +        virBufferAsprintf(buf, "<acpi index='%u'/>\n", info->acpiIndex);
> +
>      if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE ||
>          info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
>          /* We're done here */
> @@ -6661,6 +6664,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt,
>      g_autofree char *romenabled = NULL;
>      g_autofree char *rombar = NULL;
>      g_autofree char *aliasStr = NULL;
> +    g_autofree char *acpiIndex = NULL;
>      VIR_XPATH_NODE_AUTORESTORE(ctxt)
>  
>      virDomainDeviceInfoClear(info);
> @@ -6709,6 +6713,14 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt,
>          }
>      }
>  
> +    acpiIndex = 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 = virXPathNode("./address", ctxt)) &&
>          virDomainDeviceAddressParseXML(address, info) < 0)
>          goto cleanup;

ABI stability check is missing.




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux