mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 15:15:25 +00:00
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: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
54cab10518
commit
b20ec49e57
@ -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;
|
||||
if ((type = virNodeDevCapTypeFromString(cap)) < 0)
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
caps = caps->next;
|
||||
}
|
||||
return false;
|
||||
return virNodeDeviceObjHasCap(obj, type);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user