Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> --- src/qemu/qemu_checkpoint.c | 2 +- src/qemu/qemu_checkpoint.h | 6 ++++++ src/qemu/qemu_domain.c | 7 +++++++ src/qemu/qemu_driver.c | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_checkpoint.c b/src/qemu/qemu_checkpoint.c index c06bfe6a21..c13a005403 100644 --- a/src/qemu/qemu_checkpoint.c +++ b/src/qemu/qemu_checkpoint.c @@ -76,7 +76,7 @@ qemuCheckpointObjFromCheckpoint(virDomainObjPtr vm, } -static int +int qemuCheckpointWriteMetadata(virDomainObjPtr vm, virDomainMomentObjPtr checkpoint, virDomainXMLOptionPtr xmlopt, diff --git a/src/qemu/qemu_checkpoint.h b/src/qemu/qemu_checkpoint.h index cf1e9e46cb..10e1198897 100644 --- a/src/qemu/qemu_checkpoint.h +++ b/src/qemu/qemu_checkpoint.h @@ -80,3 +80,9 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src, virJSONValuePtr actions, const char *diskdst, GSList **reopenimages); + +int +qemuCheckpointWriteMetadata(virDomainObjPtr vm, + virDomainMomentObjPtr checkpoint, + virDomainXMLOptionPtr xmlopt, + const char *checkpointDir); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0c4cb09158..45dbc1c7da 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -16732,10 +16732,12 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr cfg, g_autofree char *cfg_file = NULL; g_autofree char *autostart_link = NULL; g_autofree char *snap_dir = NULL; + g_autofree char *chk_dir = NULL; cfg_file = virDomainConfigFile(cfg->configDir, name); autostart_link = virDomainConfigFile(cfg->autostartDir, name); snap_dir = g_strdup_printf("%s/%s", cfg->snapshotDir, name); + chk_dir = g_strdup_printf("%s/%s", cfg->checkpointDir, name); if (virFileExists(cfg_file) && unlink(cfg_file) < 0) @@ -16754,5 +16756,10 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr cfg, return -1; } + if (virFileIsDir(chk_dir) && virFileDeleteTree(chk_dir) < 0) { + if (reportError) + return -1; + } + return 0; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6bde4d3de0..288067dd67 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -21962,6 +21962,24 @@ qemuDomainSnapshotWriteMetadataIter(void *payload, } +static int +qemuDomainCheckpointWriteMetadataIter(void *payload, + const void *name G_GNUC_UNUSED, + void *opaque) +{ + struct qemuDomainMomentWriteMetadataData *data = opaque; + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(data->driver); + int ret; + + ret = qemuCheckpointWriteMetadata(data->vm, payload, + data->driver->xmlopt, + cfg->snapshotDir); + + virObjectUnref(cfg); + return ret; +} + + static int qemuDomainRenameCallback(virDomainObjPtr vm, const char *new_name, @@ -22027,6 +22045,11 @@ qemuDomainRenameCallback(virDomainObjPtr vm, &data) < 0) goto cleanup; + if (virDomainCheckpointForEach(vm->checkpoints, + qemuDomainCheckpointWriteMetadataIter, + &data) < 0) + goto cleanup; + if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0) goto cleanup; -- 2.23.0