[libvirt] [PATCH 1/4] util: storage: Add helper for determining whether a backing chain requires PR

Peter Krempa pkrempa at redhat.com
Thu May 31 17:30:22 UTC 2018


With blockdev support we will need to introspect whether any of the
backing chain members requires PR rather just one of them. Add a helper
and reuse it in virDomainDefHasManagedPR.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/conf/domain_conf.c    |  2 +-
 src/libvirt_private.syms  |  1 +
 src/util/virstoragefile.c | 14 ++++++++++++++
 src/util/virstoragefile.h |  3 +++
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index bfe863d76d..be78d388df 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -29928,7 +29928,7 @@ virDomainDefHasManagedPR(const virDomainDef *def)
     size_t i;

     for (i = 0; i < def->ndisks; i++) {
-        if (virStoragePRDefIsManaged(def->disks[i]->src->pr))
+        if (virStorageSourceChainHasManagedPR(def->disks[i]->src))
             return true;
     }

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 6001635916..68a1056f83 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2813,6 +2813,7 @@ virStoragePRDefIsEqual;
 virStoragePRDefIsManaged;
 virStoragePRDefParseXML;
 virStorageSourceBackingStoreClear;
+virStorageSourceChainHasManagedPR;
 virStorageSourceClear;
 virStorageSourceCopy;
 virStorageSourceFindByNodeName;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 54de2c1c30..6c71d0cdf9 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -2025,6 +2025,20 @@ virStoragePRDefIsManaged(virStoragePRDefPtr prd)
 }


+bool
+virStorageSourceChainHasManagedPR(virStorageSourcePtr src)
+{
+    virStorageSourcePtr n;
+
+    for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) {
+        if (virStoragePRDefIsManaged(src->pr))
+            return true;
+    }
+
+    return false;
+}
+
+
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
                                     const char *model)
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 1631c4cf66..b1ff5142fb 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -401,6 +401,9 @@ bool virStoragePRDefIsEqual(virStoragePRDefPtr a,
                             virStoragePRDefPtr b);
 bool virStoragePRDefIsManaged(virStoragePRDefPtr prd);

+bool
+virStorageSourceChainHasManagedPR(virStorageSourcePtr src);
+
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
                                     const char *model);
-- 
2.16.2




More information about the libvir-list mailing list