[libvirt] [PATCH v2 20/39] virstoragefile: Introduce virStorageSourceChainHasNVMe

Michal Privoznik mprivozn at redhat.com
Thu Sep 26 16:12:16 UTC 2019


This function will return true if there's a storage source of
type VIR_STORAGE_TYPE_NVME, or false otherwise.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
ACKed-by: Peter Krempa <pkrempa at redhat.com>
---
 src/libvirt_private.syms  |  1 +
 src/util/virstoragefile.c | 14 ++++++++++++++
 src/util/virstoragefile.h |  2 ++
 3 files changed, 17 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 91b03afb17..4e2a74a31b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3024,6 +3024,7 @@ virStoragePRDefIsManaged;
 virStoragePRDefParseXML;
 virStorageSourceBackingStoreClear;
 virStorageSourceChainHasManagedPR;
+virStorageSourceChainHasNVMe;
 virStorageSourceClear;
 virStorageSourceCopy;
 virStorageSourceFindByNodeName;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 725d68a248..093d2403de 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2161,6 +2161,20 @@ virStorageSourceNVMeDefFree(virStorageSourceNVMeDefPtr def)
 }
 
 
+bool
+virStorageSourceChainHasNVMe(const virStorageSource *src)
+{
+    const virStorageSource *n;
+
+    for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) {
+        if (n->type == VIR_STORAGE_TYPE_NVME)
+            return true;
+    }
+
+    return false;
+}
+
+
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
                                     const char *model)
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 9e79c7c6ef..306f84b383 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -433,6 +433,8 @@ virStorageSourceChainHasManagedPR(virStorageSourcePtr src);
 void virStorageSourceNVMeDefFree(virStorageSourceNVMeDefPtr def);
 VIR_DEFINE_AUTOPTR_FUNC(virStorageSourceNVMeDef, virStorageSourceNVMeDefFree);
 
+bool virStorageSourceChainHasNVMe(const virStorageSource *src);
+
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
                                     const char *model);
-- 
2.21.0




More information about the libvir-list mailing list