diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index cf7f45e4bf..147de2135b 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -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); }