[libvirt] [PATCH v3 12/30] virstoragefile: Introduce virStorageSourceChainHasNVMe

Michal Privoznik mprivozn at redhat.com
Mon Dec 2 14:26:35 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 d37d3867a6..a7f94feb0a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3057,6 +3057,7 @@ virStoragePRDefIsManaged;
 virStoragePRDefParseXML;
 virStorageSourceBackingStoreClear;
 virStorageSourceChainHasManagedPR;
+virStorageSourceChainHasNVMe;
 virStorageSourceClear;
 virStorageSourceCopy;
 virStorageSourceFindByNodeName;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index b4ec9624be..5a5a16aef7 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2138,6 +2138,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 42ca49bc64..39e50a989d 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -433,6 +433,8 @@ virStorageSourceChainHasManagedPR(virStorageSourcePtr src);
 void virStorageSourceNVMeDefFree(virStorageSourceNVMeDefPtr def);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virStorageSourceNVMeDef, virStorageSourceNVMeDefFree);
 
+bool virStorageSourceChainHasNVMe(const virStorageSource *src);
+
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
                                     const char *model);
-- 
2.23.0




More information about the libvir-list mailing list