Signed-off-by: Povilas Kanapickas <povilas@xxxxxxxx> --- src/qemu/qemu_driver.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7cd44d6957..227ec1c6d9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16600,6 +16600,23 @@ struct _virQEMUSnapReparent { }; +static int +qemuDomainSnapshotReparentChildrenMetadata(virDomainSnapshotObjPtr snap, + virQEMUSnapReparentPtr rep) +{ + VIR_FREE(snap->def->parent); + snap->parent = rep->parent; + + if (rep->parent->def && + VIR_STRDUP(snap->def->parent, rep->parent->def->name) < 0) { + return -1; + } + + return qemuDomainSnapshotWriteMetadata(rep->vm, snap, + rep->caps, rep->xmlopt, + rep->cfg->snapshotDir); +} + static int qemuDomainSnapshotReparentChildren(void *payload, const void *name ATTRIBUTE_UNUSED, @@ -16611,21 +16628,14 @@ qemuDomainSnapshotReparentChildren(void *payload, if (rep->err < 0) return 0; - VIR_FREE(snap->def->parent); - snap->parent = rep->parent; - - if (rep->parent->def && - VIR_STRDUP(snap->def->parent, rep->parent->def->name) < 0) { + if (qemuDomainSnapshotReparentChildrenMetadata(snap, rep) < 0) { rep->err = -1; - return 0; + goto cleanup; } +cleanup: if (!snap->sibling) rep->last = snap; - - rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, - rep->caps, rep->xmlopt, - rep->cfg->snapshotDir); return 0; } -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list