提交 7ec3f805 编写于 作者: H Huanle Han 提交者: John Ferlan

hostdev: Create virHostdevIsPCINetDevice

Refactor some code to create a static function virHostdevIsPCINetDevice
which will detect whether the hostdev is a pci net device or not.
Signed-off-by: NHuanle Han <hanxueluo@gmail.com>
上级 19425d11
......@@ -351,6 +351,16 @@ virHostdevNetDevice(virDomainHostdevDefPtr hostdev, char **linkdev,
}
static int
virHostdevIsPCINetDevice(virDomainHostdevDefPtr hostdev)
{
return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
hostdev->parent.data.net;
}
static int
virHostdevNetConfigVirtPortProfile(const char *linkdev, int vf,
virNetDevVPortProfilePtr virtPort,
......@@ -481,10 +491,7 @@ virHostdevNetConfigRestore(virDomainHostdevDefPtr hostdev,
/* This is only needed for PCI devices that have been defined
* using <interface type='hostdev'>. For all others, it is a NOP.
*/
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI ||
hostdev->parent.type != VIR_DOMAIN_DEVICE_NET ||
!hostdev->parent.data.net)
if (!virHostdevIsPCINetDevice(hostdev))
return 0;
isvf = virHostdevIsVirtualFunction(hostdev);
......@@ -604,16 +611,11 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
* the network device, set the netdev config */
for (i = 0; i < nhostdevs; i++) {
virDomainHostdevDefPtr hostdev = hostdevs[i];
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
continue;
if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
if (!virHostdevIsPCINetDevice(hostdev))
continue;
if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET &&
hostdev->parent.data.net) {
if (virHostdevNetConfigReplace(hostdev, uuid,
hostdev_mgr->stateDir) < 0) {
goto resetvfnetconfig;
}
if (virHostdevNetConfigReplace(hostdev, uuid,
hostdev_mgr->stateDir) < 0) {
goto resetvfnetconfig;
}
last_processed_hostdev_vf = i;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册