]> xenbits.xensource.com Git - libvirt.git/commitdiff
Introduce API virNodeDeviceLookupSCSIHostByWWN
authorOsier Yang <jyang@redhat.com>
Mon, 4 Feb 2013 13:03:09 +0000 (21:03 +0800)
committerOsier Yang <jyang@redhat.com>
Mon, 11 Feb 2013 16:23:57 +0000 (00:23 +0800)
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.

include/libvirt/libvirt.h.in
src/driver.h
src/libvirt.c
src/libvirt_public.syms

index 30762b1be90462ffc8b1e0ac83e6198ca1919844..ad30cd04c24e9be0b161f1e7bd783fb0d4b1829f 100644 (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);
index 02ddd83d117e9461a279d2f75b4ecb726612e6db..8d0f0a56e11b964c5cf15f94f5515c53c06fdc69 100644 (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;
index f81a3de76b6252bea0e0314f70a9cefff9ee2fe9..1e78500c194f4df94b100aa4211cde9812f06799 100644 (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:
index 9777703a914ee3b659da56f42c01239ffc691270..3bdfd57dcf9cb3ca8aff560b2e07abe48af88660 100644 (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 ....