[libvirt] [PATCH RFC 23/40] qemu: checkpoint: Split out checkpoint creation code

Ján Tomko jtomko at redhat.com
Wed Oct 23 23:44:28 UTC 2019


On Fri, Oct 18, 2019 at 06:11:08PM +0200, Peter Krempa wrote:
>Separate out individual steps of creating a checkpoint from
>qemuCheckpointCreateXML into separate functions. This makes the function
>more readable and understandable and also some of the new functions will
>be reusable when we will be creating a checkpoint along with a backup
>in the upcoming patches.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/qemu/qemu_checkpoint.c | 160 ++++++++++++++++++++++++-------------
> src/qemu/qemu_checkpoint.h |   8 ++
> 2 files changed, 111 insertions(+), 57 deletions(-)
>
>diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c
>index 54719e7f5c..946ae78368 100644
>--- a/src/qemu/qemu_checkpoint.c
>+++ b/src/qemu/qemu_checkpoint.c
>@@ -348,6 +348,90 @@ qemuCheckpointAddActions(virDomainObjPtr vm,
> }
>
>
>+static virDomainMomentObjPtr
>+qemuCheckpointRedefine(virQEMUDriverPtr driver,
>+                       virDomainObjPtr vm,
>+                       virDomainCheckpointDefPtr *def,
>+                       bool *update_current)
>+{
>+    virDomainMomentObjPtr chk = NULL;
>+
>+    if (virDomainCheckpointRedefinePrep(vm, def, &chk, driver->xmlopt,
>+                                        update_current) < 0)
>+        return NULL;
>+
>+    /* XXX Should we validate that the redefined checkpoint even
>+     * makes sense, such as checking that qemu-img recognizes the
>+     * checkpoint bitmap name in at least one of the domain's disks?  */
>+
>+    if (chk)
>+        return chk;
>+
>+    chk = virDomainCheckpointAssignDef(vm->checkpoints, *def);
>+    *def = NULL;
>+    return chk;
>+}
>+
>+
>+int
>+qemuCheckpointCreateCommon(virQEMUDriverPtr driver,
>+                           virDomainObjPtr vm,
>+                           virCapsPtr caps,
>+                           virDomainCheckpointDefPtr *def,
>+                           virJSONValuePtr *actions,
>+                           virDomainMomentObjPtr *chk)
>+{
>+    g_autoptr(virJSONValue) tmpactions = NULL;
>+    virDomainMomentObjPtr parent;
>+
>+    if (qemuCheckpointPrepare(driver, caps, vm, *def) < 0)
>+        return -1;
>+
>+    if ((parent = virDomainCheckpointGetCurrent(vm->checkpoints))) {
>+        if (VIR_STRDUP((*def)->parent.parent_name, parent->def->name) < 0)
>+            return -1;

g_strdup

>+    }
>+

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

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20191024/89f97ec6/attachment-0001.sig>


More information about the libvir-list mailing list