[libvirt] [PATCH 13/13] backup: qemu: Implement VIR_DOMAIN_CHECKPOINT_XML_SIZE flag

Peter Krempa pkrempa at redhat.com
Wed Jun 19 16:35:16 UTC 2019


On Tue, Jun 18, 2019 at 22:47:54 -0500, Eric Blake wrote:
> Once a checkpoint has been created, it is desirable to estimate the
> size of the disk delta that is represented between the checkpoint and
> the current operation. To do this, we have to scrape information out
> of QMP query-block on a request from the user.
> ---
>  src/qemu/qemu_monitor.h      |  4 ++
>  src/qemu/qemu_monitor_json.h |  3 ++
>  src/qemu/qemu_driver.c       | 56 +++++++++++++++++++++++++-
>  src/qemu/qemu_monitor.c      | 11 ++++++
>  src/qemu/qemu_monitor_json.c | 76 ++++++++++++++++++++++++++++++++++++
>  5 files changed, 149 insertions(+), 1 deletion(-)

[...]

> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 0cdb2dd1e2..585a0203eb 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c

[....]

> @@ -17399,9 +17403,59 @@ qemuDomainCheckpointGetXMLDesc(virDomainCheckpointPtr checkpoint,
>          goto cleanup;
>      chkdef = virDomainCheckpointObjGetDef(chk);
> 
> +    if (flags & VIR_DOMAIN_CHECKPOINT_XML_SIZE) {
> +        /* TODO: for non-current checkpoint, this requires a QMP sequence per
> +           disk, since the stat of one bitmap in isolation is too low,
> +           and merely adding bitmap sizes may be too high:
> +             block-dirty-bitmap-create tmp
> +             for each bitmap from checkpoint to current:
> +               add bitmap to src_list
> +             block-dirty-bitmap-merge dst=tmp src_list
> +             query-block and read tmp size
> +             block-dirty-bitmap-remove tmp
> +           So for now, go with simpler query-blocks only for current.
> +        */
> +        if (virDomainCheckpointGetCurrent(vm->checkpoints) != chk) {
> +            virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
> +                           _("cannot compute size for non-current checkpoint '%s'"),
> +                           checkpoint->name);
> +            goto cleanup;
> +        }
> +
> +        if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
> +            goto cleanup;
> +
> +        if (virDomainObjCheckActive(vm) < 0)
> +            goto endjob;
> +
> +        if (qemuBlockNodeNamesDetect(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
> +            goto endjob;

Again, I pointed out multiple times that this should not be done, or at
least only in non-blockdev case.

> +
> +        /* TODO: Shouldn't need to recompute node names. */

Well, they are not meant to be stable so if you want to match it with
the saved definition it may become fun.

Also after a snapshot the checkpoint def and VM def will differ same as
the positioning of the nodenames.

This code does not seem to take it into account in any way.

And this is getting into bigger amount of technical debt which will need
to be addressed if we want to allow checkpoints and snapshots together.

> +        for (i = 0; i < chkdef->ndisks; i++) {
> +            virDomainCheckpointDiskDef *disk = &chkdef->disks[i];
> +
> +            if (disk->type != VIR_DOMAIN_CHECKPOINT_TYPE_BITMAP)
> +                continue;
> +            VIR_FREE(chk->def->dom->disks[disk->idx]->src->nodeformat);


> +            if (VIR_STRDUP(chk->def->dom->disks[disk->idx]->src->nodeformat,
> +                           qemuBlockNodeLookup(vm, disk->name)) < 0)
> +                goto endjob;
> +        }
> +
> +        priv = vm->privateData;
> +        qemuDomainObjEnterMonitor(driver, vm);
> +        rc = qemuMonitorUpdateCheckpointSize(priv->mon, chkdef);
> +        if (qemuDomainObjExitMonitor(driver, vm) < 0)

[...]

> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 2dcd65d86f..4c232105c2 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -2760,6 +2760,82 @@ int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
>      return ret;
>  }
> 
> +int qemuMonitorJSONUpdateCheckpointSize(qemuMonitorPtr mon,
> +                                        virDomainCheckpointDefPtr chk)
> +{
> +    int ret = -1;
> +    size_t i, j;
> +    virJSONValuePtr devices;
> +
> +    if (!(devices = qemuMonitorJSONQueryBlock(mon)))
> +        return -1;

Isn't this data available in 'query-named-block-nodes'?

> +
> +    for (i = 0; i < virJSONValueArraySize(devices); i++) {
> +        virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
> +        virJSONValuePtr inserted;
> +        virJSONValuePtr bitmaps = NULL;
> +        const char *node;
> +        virDomainCheckpointDiskDefPtr disk;
> +
> +        if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
> +            goto cleanup;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190619/1d2d43f7/attachment-0001.sig>


More information about the libvir-list mailing list