提交 b20ec49e 编写于 作者: E Erik Skultety

conf: nodedev: Convert virNodeDevObjHasCapStr to a simple wrapper

This patch drops the capability matching redundancy by simply converting
the string input to our internal types which are then in turn used for
the actual capability matching.
Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 54cab105
......@@ -125,55 +125,12 @@ static bool
virNodeDeviceObjHasCapStr(const virNodeDeviceObj *obj,
const char *cap)
{
virNodeDevCapsDefPtr caps = obj->def->caps;
const char *fc_host_cap =
virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_FC_HOST);
const char *vports_cap =
virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_VPORTS);
const char *mdev_types =
virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_MDEV_TYPES);
int type;
while (caps) {
if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type))) {
return true;
} else {
switch (caps->data.type) {
case VIR_NODE_DEV_CAP_PCI_DEV:
if ((STREQ(cap, mdev_types)) &&
(caps->data.pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV))
return true;
break;
case VIR_NODE_DEV_CAP_SCSI_HOST:
if ((STREQ(cap, fc_host_cap) &&
(caps->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)) ||
(STREQ(cap, vports_cap) &&
(caps->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS)))
return true;
break;
case VIR_NODE_DEV_CAP_SYSTEM:
case VIR_NODE_DEV_CAP_USB_DEV:
case VIR_NODE_DEV_CAP_USB_INTERFACE:
case VIR_NODE_DEV_CAP_NET:
case VIR_NODE_DEV_CAP_SCSI_TARGET:
case VIR_NODE_DEV_CAP_SCSI:
case VIR_NODE_DEV_CAP_STORAGE:
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_SCSI_GENERIC:
case VIR_NODE_DEV_CAP_DRM:
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_CCW_DEV:
case VIR_NODE_DEV_CAP_LAST:
break;
}
}
if ((type = virNodeDevCapTypeFromString(cap)) < 0)
return false;
caps = caps->next;
}
return false;
return virNodeDeviceObjHasCap(obj, type);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册