[PATCH v2 1/7] qemuSnapshotDiskPrepareOne: Get available even if snapdisk is NULL

Masayoshi Mizuma posted 7 patches 5 years, 5 months ago
There is a newer version of this series
[PATCH v2 1/7] qemuSnapshotDiskPrepareOne: Get available even if snapdisk is NULL
Posted by Masayoshi Mizuma 5 years, 5 months ago
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>

Get available even if snapdisk argument is NULL at qemuSnapshotDiskPrepareOne()
so that the caller can setup dd->src.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
 src/qemu/qemu_snapshot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 1e8ea80b22..d310e6ff02 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -953,8 +953,9 @@ qemuSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
     if (qemuDomainStorageSourceValidateDepth(disk->src, 1, disk->dst) < 0)
         return -1;
 
-    if (!(dd->src = virStorageSourceCopy(snapdisk->src, false)))
-        return -1;
+    if (snapdisk)
+        if (!(dd->src = virStorageSourceCopy(snapdisk->src, false)))
+            return -1;
 
     if (virStorageSourceInitChainElement(dd->src, dd->disk->src, false) < 0)
         return -1;
-- 
2.27.0

Re: [PATCH v2 1/7] qemuSnapshotDiskPrepareOne: Get available even if snapdisk is NULL
Posted by Peter Krempa 5 years, 5 months ago
On Fri, Aug 28, 2020 at 10:08:30 -0400, Masayoshi Mizuma wrote:
> From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> 
> Get available even if snapdisk argument is NULL at qemuSnapshotDiskPrepareOne()
> so that the caller can setup dd->src.
> 
> Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> ---
>  src/qemu/qemu_snapshot.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
> index 1e8ea80b22..d310e6ff02 100644
> --- a/src/qemu/qemu_snapshot.c
> +++ b/src/qemu/qemu_snapshot.c
> @@ -953,8 +953,9 @@ qemuSnapshotDiskPrepareOne(virQEMUDriverPtr driver,
>      if (qemuDomainStorageSourceValidateDepth(disk->src, 1, disk->dst) < 0)
>          return -1;
>  
> -    if (!(dd->src = virStorageSourceCopy(snapdisk->src, false)))
> -        return -1;
> +    if (snapdisk)
> +        if (!(dd->src = virStorageSourceCopy(snapdisk->src, false)))
> +            return -1;

NACK, you can pass in a 'snapdisk' with the correct data to create the
overlay which will be a cleaner solution.