[PATCH 2/9] nodedev: Introduce two new flags for listAll API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
---
 include/libvirt/libvirt.h.in |   20 +++++++++++---------
 src/conf/node_device_conf.c  |   29 ++++++++++++++++++++++++++---
 src/conf/node_device_conf.h  |    6 +++++-
 src/libvirt.c                |    2 ++
 tools/virsh-nodedev.c        |    6 ++++++
 tools/virsh.pod              |    7 ++++---
 6 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 563ca27..6c5dfe6 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -3138,15 +3138,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 48e8190..819e6af 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -50,7 +50,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",
@@ -467,8 +469,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;
         }
 
@@ -1409,7 +1413,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;
     }
@@ -1437,6 +1444,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;
@@ -1466,7 +1485,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 36bf5ac..145d699 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -45,6 +45,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
 };
 
@@ -262,7 +264,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 0a2ade7..f0c452e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -14202,6 +14202,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 ddbf7ed..ef4a1a4 100644
--- a/tools/virsh-nodedev.c
+++ b/tools/virsh-nodedev.c
@@ -420,6 +420,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 a2da9ef..368618c 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1980,9 +1980,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
-- 
1.7.7.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]