提交 5c8d622f 编写于 作者: L Laine Stump

network: better validation of devices in hostdev network pool

This adds a few validations to the devices listed for a hostdev network:

* devices must be listed by PCI address, not by netdev name

* listing a device by PCI address is valid only for hostdev networks, not
  for other types of network (e.g. macvtap passthrough).

* each device in a hostdev pool must be an SR-IOV VF

Resolves: https://bugzilla.redhat.com/1004676
上级 76107bf1
...@@ -3224,14 +3224,55 @@ networkValidate(virNetworkDriverStatePtr driver, ...@@ -3224,14 +3224,55 @@ networkValidate(virNetworkDriverStatePtr driver,
* the type of each. * the type of each.
*/ */
for (i = 0; i < def->forward.nifs; i++) { for (i = 0; i < def->forward.nifs; i++) {
switch ((virNetworkForwardHostdevDeviceType) virNetworkForwardIfDefPtr iface = &def->forward.ifs[i];
def->forward.ifs[i].type) { char *sysfs_path = NULL;
switch ((virNetworkForwardHostdevDeviceType) iface->type) {
case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV: case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV:
usesInterface = true; usesInterface = true;
if (def->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("hostdev network '%s' lists '%s' "
"in the device pool, but hostdev "
"networks require all devices to "
"be listed by PCI address, not "
"network device name"),
def->name, iface->device.dev);
return -1;
}
break; break;
case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI:
case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI: {
usesAddress = true; usesAddress = true;
if (def->forward.type != VIR_NETWORK_FORWARD_HOSTDEV) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("network '%s' has forward mode '%s' "
" but lists a device by PCI address "
"in the device pool. This is only "
"supported for networks with forward "
"mode 'hostdev'"),
def->name,
virNetworkForwardTypeToString(def->forward.type));
return -1;
}
if (virPCIDeviceAddressGetSysfsFile(&iface->device.pci, &sysfs_path) < 0)
return -1;
if (!virPCIIsVirtualFunction(sysfs_path)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("device '%s' in network '%s' is not "
"an SR-IOV Virtual Function"),
sysfs_path, def->name);
VIR_FREE(sysfs_path);
return -1;
}
VIR_FREE(sysfs_path);
break; break;
}
case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NONE: case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NONE:
case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST: case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_LAST:
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册