]> xenbits.xensource.com Git - libvirt.git/commitdiff
utils: storage: Add copying of PR definition to virStorageSource
authorPeter Krempa <pkrempa@redhat.com>
Fri, 13 Jul 2018 14:19:38 +0000 (16:19 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 20 Jul 2018 12:40:59 +0000 (14:40 +0200)
Despite the warning that virStorageSourceCopy needs to be populated on
additions to the structure commit 687730540e4 neglected to implement the
copy function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virstoragefile.c

index 58f67278da9cca520b0f57541dff7714215eb277..b6a2b415e98d2b8993f32452c9ee192ae703e7cf 100644 (file)
@@ -2041,6 +2041,29 @@ virStorageSourceChainHasManagedPR(virStorageSourcePtr src)
 }
 
 
+static virStoragePRDefPtr
+virStoragePRDefCopy(virStoragePRDefPtr src)
+{
+    virStoragePRDefPtr copy = NULL;
+    virStoragePRDefPtr ret = NULL;
+
+    if (VIR_ALLOC(copy) < 0)
+        return NULL;
+
+    copy->managed = src->managed;
+
+    if (VIR_STRDUP(copy->path, src->path) < 0 ||
+        VIR_STRDUP(copy->mgralias, src->mgralias) < 0)
+        goto cleanup;
+
+    VIR_STEAL_PTR(ret, copy);
+
+ cleanup:
+    virStoragePRDefFree(copy);
+    return ret;
+}
+
+
 virSecurityDeviceLabelDefPtr
 virStorageSourceGetSecurityLabelDef(virStorageSourcePtr src,
                                     const char *model)
@@ -2245,6 +2268,10 @@ virStorageSourceCopy(const virStorageSource *src,
         !(ret->auth = virStorageAuthDefCopy(src->auth)))
         goto error;
 
+    if (src->pr &&
+        !(ret->pr = virStoragePRDefCopy(src->pr)))
+        goto error;
+
     if (backingChain && src->backingStore) {
         if (!(ret->backingStore = virStorageSourceCopy(src->backingStore,
                                                        true)))