提交 fc9ba9d5 编写于 作者: A Andrea Bolognani

pci: Fix virPCIGetPhysicalFunction()'s callers

Commit c8b1a836 changed the function, making it
impossible for callers to be able to tell whether a
non-negative return value means "physical function
address found and parsed correctly" or "couldn't find
corresponding physical function".

The important difference between the two being that,
in the latter case, the returned pointer is NULL and
should never, ever be dereferenced.

In order to cope with these changes, the callers
have to be updated.
上级 063da393
...@@ -154,19 +154,25 @@ nodeDeviceSysfsGetPCISRIOVCaps(const char *sysfsPath, ...@@ -154,19 +154,25 @@ nodeDeviceSysfsGetPCISRIOVCaps(const char *sysfsPath,
data->pci_dev.flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; data->pci_dev.flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
data->pci_dev.flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; data->pci_dev.flags &= ~VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
if (!virPCIGetPhysicalFunction(sysfsPath, &data->pci_dev.physical_function)) ret = virPCIGetPhysicalFunction(sysfsPath,
&data->pci_dev.physical_function);
if (ret < 0)
goto cleanup;
if (data->pci_dev.physical_function)
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION;
ret = virPCIGetVirtualFunctions(sysfsPath, &data->pci_dev.virtual_functions, ret = virPCIGetVirtualFunctions(sysfsPath, &data->pci_dev.virtual_functions,
&data->pci_dev.num_virtual_functions, &data->pci_dev.num_virtual_functions,
&data->pci_dev.max_virtual_functions); &data->pci_dev.max_virtual_functions);
if (ret < 0) if (ret < 0)
return ret; goto cleanup;
if (data->pci_dev.num_virtual_functions > 0 || if (data->pci_dev.num_virtual_functions > 0 ||
data->pci_dev.max_virtual_functions > 0) data->pci_dev.max_virtual_functions > 0)
data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; data->pci_dev.flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION;
cleanup:
return ret; return ret;
} }
......
...@@ -2732,6 +2732,9 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path, ...@@ -2732,6 +2732,9 @@ virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path,
if (virPCIGetPhysicalFunction(vf_sysfs_device_path, &pf_config_address) < 0) if (virPCIGetPhysicalFunction(vf_sysfs_device_path, &pf_config_address) < 0)
return ret; return ret;
if (!pf_config_address)
return ret;
if (virPCIDeviceAddressGetSysfsFile(pf_config_address, if (virPCIDeviceAddressGetSysfsFile(pf_config_address,
&pf_sysfs_device_path) < 0) { &pf_sysfs_device_path) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册