[libvirt] [PATCH v2 2/2] conf: nodedev: Set PCI_PHYSICAL_FUNCTION flag more carefully

Laine Stump laine at laine.org
Tue May 24 15:27:41 UTC 2016


On 05/24/2016 07:11 AM, Andrea Bolognani wrote:
> Instead of setting the flag before parsing the PCI address, set
> it afterwards. This ensure we can never end up in a situation
> where the flag has been set but pci_dev.physical_function has
> not been filled in.
> ---
>   src/conf/node_device_conf.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
> index aed95d5..a23d8ef 100644
> --- a/src/conf/node_device_conf.c
> +++ b/src/conf/node_device_conf.c
> @@ -1293,8 +1293,6 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt,
>           if (VIR_ALLOC(data->pci_dev.physical_function) < 0)
>               goto out;
>   
> -        data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
> -
>           if (!address) {
>               virReportError(VIR_ERR_XML_ERROR, "%s",
>                              _("Missing address in 'phys_function' capability"));
> @@ -1304,6 +1302,8 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt,
>           if (virPCIDeviceAddressParseXML(address,
>                                           data->pci_dev.physical_function) < 0)
>               goto out;
> +
> +        data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
>       } else if (STREQ(type, "virt_functions")) {
>           int naddresses;
>   

ACK, although it currently doesn't matter (I checked and made sure that 
the memory at pci_dev.physical_function is free'd even if the 
PHYSICAL_FUNCTION flag isn't set)




More information about the libvir-list mailing list