[libvirt] [PATCH] utils: storage: Add copying of PR definition to virStorageSource

Peter Krempa posted 1 patch 5 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/44fa3db0725c680d3b1b79fe1e6cb539c9b572ba.1531836229.git.pkrempa@redhat.com
Test syntax-check passed
src/util/virstoragefile.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
[libvirt] [PATCH] utils: storage: Add copying of PR definition to virStorageSource
Posted by Peter Krempa 5 years, 8 months ago
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>
---
 src/util/virstoragefile.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 58f67278da..b6a2b415e9 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -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)))
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] utils: storage: Add copying of PR definition to virStorageSource
Posted by Ján Tomko 5 years, 8 months ago
On Tue, Jul 17, 2018 at 04:03:49PM +0200, Peter Krempa wrote:
>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>
>---
> src/util/virstoragefile.c | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Also not copied:
    bool authInherited;
    bool encryptionInherited;
    bool nocow;
    bool sparse;
and all the properties from the last section (starting at 'iomode')

It would be nice to mention the properties that do not need to be copied
and copy them in the same order they are declared in.

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list