Re: [libvirt PATCH 1/6] nodedev: factor out nodeDeviceHasCapability()

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

 



On 4/30/20 11:42 PM, Jonathon Jongsma wrote:
Currently nodeDeviceCreateXML() and nodeDeviceDestroy() only support
NPIV HBAs, but we want to be able to create mdev devices as well. This
is a first step to enabling that support.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
  src/node_device/node_device_driver.c | 90 ++++++++++++++++++----------
  1 file changed, 57 insertions(+), 33 deletions(-)

diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index ee175e1095..6a96a77d92 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -487,6 +487,20 @@ nodeDeviceFindNewDevice(virConnectPtr conn,
      return device;
  }
+static bool
+nodeDeviceHasCapability(virNodeDeviceDefPtr def, virNodeDevCapType type)
+{
+    virNodeDevCapsDefPtr cap = NULL;
+
+    cap = def->caps;

This variable can be initialized to def->caps directly. No need to go through NULL, IMO.

+    while (cap != NULL) {
+        if (cap->data.type == type)
+            return true;
+        cap = cap->next;
+    }
+
+    return false;
+}


Also, here and for the rest of the patchset - the file uses two spaces between functions. Please keep that.

Michal




[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]

  Powered by Linux