mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 07:42:56 +00:00
nodedev: Use switch for virNodeDeviceObjHasCap and virNodeDeviceCapMatch
In order to ensure that whenever something is added to virNodeDevCapType that both functions are considered for processing of a new capability, change the if-then-else construct into a switch statement. Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
51ed8907a3
commit
944b8de83e
@ -48,19 +48,39 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *dev,
|
|||||||
while (caps) {
|
while (caps) {
|
||||||
if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type))) {
|
if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type))) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
|
} else {
|
||||||
if ((STREQ(cap, fc_host_cap) &&
|
switch (caps->data.type) {
|
||||||
(caps->data.scsi_host.flags &
|
case VIR_NODE_DEV_CAP_PCI_DEV:
|
||||||
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 1;
|
|
||||||
} else if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
|
||||||
if ((STREQ(cap, mdev_types)) &&
|
if ((STREQ(cap, mdev_types)) &&
|
||||||
(caps->data.pci_dev.flags &
|
(caps->data.pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV))
|
||||||
VIR_NODE_DEV_CAP_FLAG_PCI_MDEV))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
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 1;
|
||||||
|
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;
|
caps = caps->next;
|
||||||
@ -468,23 +488,39 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj,
|
|||||||
if (type == cap->data.type)
|
if (type == cap->data.type)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
|
switch (cap->data.type) {
|
||||||
|
case VIR_NODE_DEV_CAP_PCI_DEV:
|
||||||
|
if (type == VIR_NODE_DEV_CAP_MDEV_TYPES &&
|
||||||
|
(cap->data.pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV))
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VIR_NODE_DEV_CAP_SCSI_HOST:
|
||||||
if (type == VIR_NODE_DEV_CAP_FC_HOST &&
|
if (type == VIR_NODE_DEV_CAP_FC_HOST &&
|
||||||
(cap->data.scsi_host.flags &
|
(cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST))
|
||||||
VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST))
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (type == VIR_NODE_DEV_CAP_VPORTS &&
|
if (type == VIR_NODE_DEV_CAP_VPORTS &&
|
||||||
(cap->data.scsi_host.flags &
|
(cap->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS))
|
||||||
VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
break;
|
||||||
|
|
||||||
if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) {
|
case VIR_NODE_DEV_CAP_SYSTEM:
|
||||||
if (type == VIR_NODE_DEV_CAP_MDEV_TYPES &&
|
case VIR_NODE_DEV_CAP_USB_DEV:
|
||||||
(cap->data.pci_dev.flags &
|
case VIR_NODE_DEV_CAP_USB_INTERFACE:
|
||||||
VIR_NODE_DEV_CAP_FLAG_PCI_MDEV))
|
case VIR_NODE_DEV_CAP_NET:
|
||||||
return true;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user