mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
nodedev: Introduce two new flags for listAll API
VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST to filter the FC HBA, and VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS to filter the FC HBA which supports vport.
This commit is contained in:
parent
ab4b000188
commit
652a2ec630
@ -3247,15 +3247,17 @@ int virNodeListDevices (virConnectPtr conn,
|
||||
* type.
|
||||
*/
|
||||
typedef enum {
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM = 1 << 0, /* System capability */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV = 1 << 1, /* PCI device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV = 1 << 2, /* USB device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE = 1 << 3, /* USB interface */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET = 1 << 4, /* Network device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST = 1 << 5, /* SCSI Host Bus Adapter */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET = 1 << 6, /* SCSI Target */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI = 1 << 7, /* SCSI device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE = 1 << 8, /* Storage device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM = 1 << 0, /* System capability */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV = 1 << 1, /* PCI device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV = 1 << 2, /* USB device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE = 1 << 3, /* USB interface */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET = 1 << 4, /* Network device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST = 1 << 5, /* SCSI Host Bus Adapter */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET = 1 << 6, /* SCSI Target */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI = 1 << 7, /* SCSI device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE = 1 << 8, /* Storage device */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST = 1 << 9, /* FC Host Bus Adapter */
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS = 1 << 10, /* Capable of vport */
|
||||
} virConnectListAllNodeDeviceFlags;
|
||||
|
||||
int virConnectListAllNodeDevices (virConnectPtr conn,
|
||||
|
@ -49,7 +49,9 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
|
||||
"scsi_host",
|
||||
"scsi_target",
|
||||
"scsi",
|
||||
"storage")
|
||||
"storage",
|
||||
"fc_host",
|
||||
"vports")
|
||||
|
||||
VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST,
|
||||
"80203",
|
||||
@ -466,8 +468,10 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDefPtr def)
|
||||
virBufferAddLit(&buf,
|
||||
" <capability type='hotpluggable' />\n");
|
||||
break;
|
||||
case VIR_NODE_DEV_CAP_FC_HOST:
|
||||
case VIR_NODE_DEV_CAP_VPORTS:
|
||||
case VIR_NODE_DEV_CAP_LAST:
|
||||
/* ignore special LAST value */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1408,7 +1412,10 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
|
||||
VIR_FREE(data->storage.serial);
|
||||
VIR_FREE(data->storage.media_label);
|
||||
break;
|
||||
case VIR_NODE_DEV_CAP_FC_HOST:
|
||||
case VIR_NODE_DEV_CAP_VPORTS:
|
||||
case VIR_NODE_DEV_CAP_LAST:
|
||||
default:
|
||||
/* This case is here to shutup the compiler */
|
||||
break;
|
||||
}
|
||||
@ -1436,6 +1443,18 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj,
|
||||
for (cap = devobj->def->caps; cap; cap = cap->next) {
|
||||
if (type == cap->type)
|
||||
return true;
|
||||
|
||||
if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) {
|
||||
if (type == VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST &&
|
||||
(cap->data.scsi_host.flags &
|
||||
VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST))
|
||||
return true;
|
||||
|
||||
if (type == VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS &&
|
||||
(cap->data.scsi_host.flags &
|
||||
VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1465,7 +1484,11 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
|
||||
(MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI) &&
|
||||
virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI)) ||
|
||||
(MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE) &&
|
||||
virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_STORAGE))))
|
||||
virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_STORAGE)) ||
|
||||
(MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST) &&
|
||||
virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_FC_HOST)) ||
|
||||
(MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS) &&
|
||||
virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_VPORTS))))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,8 @@ enum virNodeDevCapType {
|
||||
VIR_NODE_DEV_CAP_SCSI_TARGET, /* SCSI Target */
|
||||
VIR_NODE_DEV_CAP_SCSI, /* SCSI device */
|
||||
VIR_NODE_DEV_CAP_STORAGE, /* Storage device */
|
||||
VIR_NODE_DEV_CAP_FC_HOST, /* FC Host Bus Adapter */
|
||||
VIR_NODE_DEV_CAP_VPORTS, /* HBA which is capable of vports */
|
||||
VIR_NODE_DEV_CAP_LAST
|
||||
};
|
||||
|
||||
@ -263,7 +265,9 @@ void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj);
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST | \
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET | \
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI | \
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE)
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE | \
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST | \
|
||||
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS)
|
||||
|
||||
int virNodeDeviceList(virConnectPtr conn,
|
||||
virNodeDeviceObjList devobjs,
|
||||
|
@ -14253,6 +14253,8 @@ error:
|
||||
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET
|
||||
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI
|
||||
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE
|
||||
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST
|
||||
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS
|
||||
*
|
||||
* Returns the number of node devices found or -1 and sets @devices to NULL in
|
||||
* case of error. On success, the array stored into @devices is guaranteed to
|
||||
|
@ -447,6 +447,12 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
|
||||
case VIR_NODE_DEV_CAP_STORAGE:
|
||||
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE;
|
||||
break;
|
||||
case VIR_NODE_DEV_CAP_FC_HOST:
|
||||
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST;
|
||||
break;
|
||||
case VIR_NODE_DEV_CAP_VPORTS:
|
||||
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1998,9 +1998,10 @@ List all of the devices available on the node that are known by libvirt.
|
||||
I<cap> is used to filter the list by capability types, the types must be
|
||||
separated by comma, e.g. --cap pci,scsi, valid capability types include
|
||||
'system', 'pci', 'usb_device', 'usb', 'net', 'scsi_host', 'scsi_target',
|
||||
'scsi', 'storage'. If I<--tree> is used, the output is formatted in a tree
|
||||
representing parents of each node. I<cap> and I<--tree> are mutually
|
||||
exclusive.
|
||||
'scsi', 'storage', 'fc_host', 'vports'. If I<--tree> is used, the output
|
||||
is formatted in a tree representing parents of each node. I<cap> and
|
||||
I<--tree> are mutually exclusive.
|
||||
|
||||
=item B<nodedev-reattach> I<nodedev>
|
||||
|
||||
Declare that I<nodedev> is no longer in use by any guests, and that
|
||||
|
Loading…
Reference in New Issue
Block a user