diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 45b56387a1491e973288bb003ecbc14a477f0545..518f0fe5ec1c61772b784ba43538dca2894f0ae5 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -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, diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index e7072981a4277d4a8fe672ebb3a4e2ff98f29d1b..f743b26b1bc41d4ce7ee48c9a0cfad044fb48bbf 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -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, " \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; } diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h index fb1267f987bcef0de3b1a836b5f98568a0264d44..2946026c4035291c11e99cfe3a858465a0899ff7 100644 --- a/src/conf/node_device_conf.h +++ b/src/conf/node_device_conf.h @@ -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, diff --git a/src/libvirt.c b/src/libvirt.c index 02d5dd94a7a6776d2299b29d264bef2ad38ebcdd..1624776be1bb7246131b97e9a9bda73f0a998613 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -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 diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 394208e4dfc51015242875846ce095c129885354..9c0bd90e933837098540a7f8d44beb2a4b4345a5 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -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; } diff --git a/tools/virsh.pod b/tools/virsh.pod index 07e7c24aba9be996a82606f6e4251d860d71f271..e7e82e35d437810cda25ebe248d2713fc14bcf15 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1998,9 +1998,10 @@ List all of the devices available on the node that are known by libvirt. I 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 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 and +I<--tree> are mutually exclusive. + =item B I Declare that I is no longer in use by any guests, and that