[PATCH v2 17/19] qemuDomainBlockPivot: Handle merging of bitmaps when pivoting an active block-commit

Peter Krempa posted 19 patches 5 years, 11 months ago
[PATCH v2 17/19] qemuDomainBlockPivot: Handle merging of bitmaps when pivoting an active block-commit
Posted by Peter Krempa 5 years, 11 months ago
Active layer block commit makes the 'base' image the new top image of
the disk after it finishes. This means that all bitmap operations need
to be handled prior to this happening as we'd lose writes otherwise.

The ideal place is to handle it when pivoting to the new image as only
guest-writes would be happening after this point.

Use qemuBlockBitmapsHandleCommitFinish to calculate the merging
transaction.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_driver.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 628fe9b107..3afdecda1b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17301,6 +17301,23 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
         break;

     case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
+        /* we technically don't need reopen here, but we couldn't prepare
+         * the bitmaps if it wasn't present thus must skip this */
+        if (blockdev &&
+            virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) {
+            g_autoptr(virHashTable) blockNamedNodeData = NULL;
+
+            if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
+                return -1;
+
+            if (qemuBlockBitmapsHandleCommitFinish(job->data.commit.top,
+                                                   job->data.commit.base,
+                                                   blockNamedNodeData,
+                                                   &actions,
+                                                   job->data.commit.disabledBitmapsBase) < 0)
+                return -1;
+        }
+
         break;
     }

-- 
2.24.1

Re: [PATCH v2 17/19] qemuDomainBlockPivot: Handle merging of bitmaps when pivoting an active block-commit
Posted by Eric Blake 5 years, 11 months ago
On 3/11/20 7:56 AM, Peter Krempa wrote:
> Active layer block commit makes the 'base' image the new top image of
> the disk after it finishes. This means that all bitmap operations need
> to be handled prior to this happening as we'd lose writes otherwise.
> 
> The ideal place is to handle it when pivoting to the new image as only
> guest-writes would be happening after this point.
> 
> Use qemuBlockBitmapsHandleCommitFinish to calculate the merging
> transaction.
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   src/qemu/qemu_driver.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 628fe9b107..3afdecda1b 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -17301,6 +17301,23 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
>           break;
> 
>       case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
> +        /* we technically don't need reopen here, but we couldn't prepare
> +         * the bitmaps if it wasn't present thus must skip this */
> +        if (blockdev &&
> +            virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV_REOPEN)) {
> +            g_autoptr(virHashTable) blockNamedNodeData = NULL;
> +
> +            if (!(blockNamedNodeData = qemuBlockGetNamedNodeData(vm, QEMU_ASYNC_JOB_NONE)))
> +                return -1;
> +
> +            if (qemuBlockBitmapsHandleCommitFinish(job->data.commit.top,
> +                                                   job->data.commit.base,
> +                                                   blockNamedNodeData,
> +                                                   &actions,
> +                                                   job->data.commit.disabledBitmapsBase) < 0)
> +                return -1;
> +        }
> +

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org