1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

Introduce API virNodeDeviceLookupSCSIHostByWWN

Since the name (like scsi_host10) is not stable for vHBA, (it can
be changed either after recreating or system rebooting), current
API virNodeDeviceLookupByName is not nice to use for management app
in this case. (E.g. one wants to destroy the vHBA whose name has
been changed after system rebooting, he has to find out current
name first).

Later patches will support the persistent vHBA via storage pool,
with which one can identify the vHBA stably by the wwnn && wwpn
pair.

So this new API comes.
This commit is contained in:
Osier Yang 2013-02-04 21:03:09 +08:00
parent 0ab49601a8
commit efed366eb7
4 changed files with 62 additions and 0 deletions

View File

@ -3257,6 +3257,11 @@ int virConnectListAllNodeDevices (virConnectPtr conn,
virNodeDevicePtr virNodeDeviceLookupByName (virConnectPtr conn,
const char *name);
virNodeDevicePtr virNodeDeviceLookupSCSIHostByWWN (virConnectPtr conn,
const char *wwnn,
const char *wwpn,
unsigned int flags);
const char * virNodeDeviceGetName (virNodeDevicePtr dev);
const char * virNodeDeviceGetParent (virNodeDevicePtr dev);

View File

@ -1553,6 +1553,11 @@ typedef int (*virDevMonListAllNodeDevices)(virConnectPtr conn,
typedef virNodeDevicePtr (*virDevMonDeviceLookupByName)(virConnectPtr conn,
const char *name);
typedef virNodeDevicePtr (*virDevMonDeviceLookupSCSIHostByWWN)(virConnectPtr conn,
const char *wwnn,
const char *wwpn,
unsigned int flags);
typedef char * (*virDevMonDeviceGetXMLDesc)(virNodeDevicePtr dev,
unsigned int flags);
@ -1584,6 +1589,7 @@ struct _virDeviceMonitor {
virDevMonListDevices listDevices;
virDevMonListAllNodeDevices listAllNodeDevices;
virDevMonDeviceLookupByName deviceLookupByName;
virDevMonDeviceLookupSCSIHostByWWN deviceLookupSCSIHostByWWN;
virDevMonDeviceGetXMLDesc deviceGetXMLDesc;
virDevMonDeviceGetParent deviceGetParent;
virDevMonDeviceNumOfCaps deviceNumOfCaps;

View File

@ -14334,6 +14334,52 @@ error:
return NULL;
}
/**
* virNodeDeviceLookupSCSIHostByWWN:
* @conn: pointer to the hypervisor connection
* @wwnn: WWNN of the SCSI Host.
* @wwpn: WWPN of the SCSI Host.
* @flags: extra flags; not used yet, so callers should always pass 0
*
* Lookup SCSI Host which is capable with 'fc_host' by its WWNN and WWPN.
*
* Returns a virNodeDevicePtr if found, NULL otherwise.
*/
virNodeDevicePtr
virNodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
const char *wwnn,
const char *wwpn,
unsigned int flags)
{
VIR_DEBUG("conn=%p, wwnn=%p, wwpn=%p, flags=%x", conn, wwnn, wwpn, flags);
virResetLastError();
if (!VIR_IS_CONNECT(conn)) {
virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
virDispatchError(NULL);
return NULL;
}
virCheckNonNullArgGoto(wwnn, error);
virCheckNonNullArgGoto(wwpn, error);
if (conn->deviceMonitor &&
conn->deviceMonitor->deviceLookupSCSIHostByWWN) {
virNodeDevicePtr ret;
ret = conn->deviceMonitor->deviceLookupSCSIHostByWWN(conn, wwnn,
wwpn, flags);
if (!ret)
goto error;
return ret;
}
virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
error:
virDispatchError(conn);
return NULL;
}
/**
* virNodeDeviceGetXMLDesc:

View File

@ -603,4 +603,9 @@ LIBVIRT_1.0.2 {
virTypedParamsGetULLong;
} LIBVIRT_1.0.1;
LIBVIRT_1.0.3 {
global:
virNodeDeviceLookupSCSIHostByWWN;
} LIBVIRT_1.0.2;
# .... define new API here using predicted next version number ....