Add the function virHostdevIsSCSIDevice() which detects whether a
hostdev is a SCSI device or not.
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk(a)linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.vnet.ibm.com>
---
src/libvirt_private.syms | 1 +
src/util/virhostdev.c | 14 ++++++++++++++
src/util/virhostdev.h | 3 +++
3 files changed, 18 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index baff82b..b7d26fd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1677,6 +1677,7 @@ virHookPresent;
# util/virhostdev.h
virHostdevFindUSBDevice;
+virHostdevIsSCSIDevice;
virHostdevManagerGetDefault;
virHostdevPCINodeDeviceDetach;
virHostdevPCINodeDeviceReAttach;
diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 9c2262e..d283306 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -337,6 +337,20 @@ virHostdevIsPCINetDevice(virDomainHostdevDefPtr hostdev)
}
+/**
+ * virHostdevIsSCSIDevice:
+ * @hostdev: host device to check
+ *
+ * Returns true if @hostdev is a SCSI device, false otherwise.
+ */
+bool
+virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev)
+{
+ return hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
+ hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI;
+}
+
+
static int
virHostdevNetConfigVirtPortProfile(const char *linkdev, int vf,
virNetDevVPortProfilePtr virtPort,
diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
index f2f51bd..aa056eb 100644
--- a/src/util/virhostdev.h
+++ b/src/util/virhostdev.h
@@ -149,6 +149,9 @@ virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
unsigned int flags,
const char *oldStateDir)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+bool
+virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev)
+ ATTRIBUTE_NONNULL(1);
/* functions used by NodeDevDetach/Reattach/Reset */
int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr,
--
2.5.5