]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
npiv: Expose fabric_name outside
authorOsier Yang <jyang@redhat.com>
Tue, 6 Dec 2011 12:09:03 +0000 (07:09 -0500)
committerOsier Yang <jyang@redhat.com>
Wed, 7 Dec 2011 10:42:08 +0000 (18:42 +0800)
This patch is to expose the fabric_name of fc_host class, which
might be useful for users who wants to known which fabric the
(v)HBA connects to.

The patch also adds the missed capabilities' XML schema of scsi_host,
(of course, with fabric_wwn added), and update the documents
(docs/formatnode.html.in)

docs/formatnode.html.in
docs/schemas/nodedev.rng
src/conf/node_device_conf.c
src/conf/node_device_conf.h
src/node_device/node_device_linux_sysfs.c

index 126f8de5cbad6c8c12d5f1e57566cd55771f7742..c04d04d1c2554f5a191728686d449f28dd774025 100644 (file)
               <dd>A network protocol exposed by the device, where the
                 attribute <code>type</code> can be "80203" for IEEE
                 802.3, or "80211" for various flavors of IEEE 802.11.
+              </dd>
             </dl>
           </dd>
           <dt><code>scsi_host</code></dt>
             <dl>
               <dt><code>host</code></dt>
               <dd>The SCSI host number.</dd>
+              <dt><code>capability</code></dt>
+              <dd>Current capabilities include "vports_ops" (indicates
+                vport operations are supported) and "fc_host", the later
+                implies following sub-elements: <code>wwnn</code>,
+                <code>wwpn</code>, <code>fabric_wwn</code>.
+              </dd>
             </dl>
           </dd>
           <dt><code>scsi</code></dt>
index 55191d990ad89c5a1f92227151345b476fa78120..1b9a2d122621fe94676a18685900c5ed4bf9b757 100644 (file)
     </attribute>
   </define>
 
+  <define name='wwn'>
+    <data type='string'>
+      <param name='pattern'>(0-9a-fA-F){16}</param>
+    </data>
+  </define>
+
+  <define name='capsfchost'>
+    <attribute name='type'>
+      <value>fc_host</value>
+    </attribute>
+
+    <element name='wwnn'>
+      <ref name='wwn'/>
+    </element>
+
+    <element name='wwpn'>
+      <ref name='wwn'/>
+    </element>
+
+    <element name='fabric_wwn'>
+      <ref name='wwn'/>
+    </element>
+  </define>
+
+  <define name='capsvports'>
+    <attribute name='type'>
+      <value>vports_ops</value>
+    </attribute>
+  </define>
 
   <define name='capscsihost'>
     <attribute name='type'>
     <element name='host'>
       <ref name='uint'/>
     </element>
+
+    <optional>
+      <zeroOrMore>
+        <element name='capability'>
+          <choice>
+            <ref name='capsfchost'/>
+            <ref name='capsvports'/>
+          </choice>
+        </element>
+      </zeroOrMore>
+    </optional>
   </define>
 
   <define name='capscsi'>
index 084121f26dc6c474f6789d2dfea8f375d5f0e48f..d9dc9ac7778e5d6e3974faa793f3afe6db69c434 100644 (file)
@@ -396,6 +396,8 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDefPtr def)
                                       data->scsi_host.wwnn);
                 virBufferEscapeString(&buf, "      <wwpn>%s</wwpn>\n",
                                       data->scsi_host.wwpn);
+                virBufferEscapeString(&buf, "      <fabric_wwn>%s</fabric_wwn>\n",
+                                      data->scsi_host.fabric_wwn);
                 virBufferAddLit(&buf, "    </capability>\n");
             }
             if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) {
@@ -1378,6 +1380,7 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
     case VIR_NODE_DEV_CAP_SCSI_HOST:
         VIR_FREE(data->scsi_host.wwnn);
         VIR_FREE(data->scsi_host.wwpn);
+        VIR_FREE(data->scsi_host.fabric_wwn);
         break;
     case VIR_NODE_DEV_CAP_SCSI_TARGET:
         VIR_FREE(data->scsi_target.name);
index 17be0313a396364b840afab4091a9876bfdbd8b6..a1833a0e62b3810b79e45d480ef081b7f3ae5356 100644 (file)
@@ -141,6 +141,7 @@ struct _virNodeDevCapsDef {
             unsigned int host;
             char *wwnn;
             char *wwpn;
+            char *fabric_wwn;
             unsigned int flags;
         } scsi_host;
         struct {
index d3528007b592338a72a7d81e3c9b23103f9c23c0..380be9c61be1b6cf66a21c15dd0737572f74060f 100644 (file)
@@ -149,10 +149,20 @@ int check_fc_host_linux(union _virNodeDevCapData *d)
         retval = -1;
     }
 
+    if (read_wwn(d->scsi_host.host,
+                 "fabric_name",
+                 &d->scsi_host.fabric_wwn) == -1) {
+        VIR_ERROR(_("Failed to read fabric WWN for host%d"),
+                  d->scsi_host.host);
+        retval = -1;
+        goto out;
+    }
+
 out:
     if (retval == -1) {
         VIR_FREE(d->scsi_host.wwnn);
         VIR_FREE(d->scsi_host.wwpn);
+        VIR_FREE(d->scsi_host.fabric_wwn);
     }
     VIR_FREE(sysfs_path);
     return retval;