]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: nodedev: Set PCI_PHYSICAL_FUNCTION flag more carefully
authorAndrea Bolognani <abologna@redhat.com>
Mon, 23 May 2016 09:54:44 +0000 (11:54 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 25 May 2016 08:38:01 +0000 (10:38 +0200)
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

index aed95d56d0542038789714c70909869a8bea6a1c..a23d8ef99ed92f02b3cc8db32c9173fe9e620f33 100644 (file)
@@ -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;