mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: rename: support renaming checkpoints directory
This is basically just saves checkpoints metadata on disk after name is changed in memory as path to domain checkpoints directory depends on name. After that old checkpoint directory is deleted with checkpoint metadata files. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
parent
4770a96c66
commit
3b1244bffd
@ -76,7 +76,7 @@ qemuCheckpointObjFromCheckpoint(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
int
|
||||||
qemuCheckpointWriteMetadata(virDomainObjPtr vm,
|
qemuCheckpointWriteMetadata(virDomainObjPtr vm,
|
||||||
virDomainMomentObjPtr checkpoint,
|
virDomainMomentObjPtr checkpoint,
|
||||||
virDomainXMLOptionPtr xmlopt,
|
virDomainXMLOptionPtr xmlopt,
|
||||||
|
@ -79,3 +79,9 @@ qemuCheckpointDiscardDiskBitmaps(virStorageSourcePtr src,
|
|||||||
virJSONValuePtr actions,
|
virJSONValuePtr actions,
|
||||||
const char *diskdst,
|
const char *diskdst,
|
||||||
GSList **reopenimages);
|
GSList **reopenimages);
|
||||||
|
|
||||||
|
int
|
||||||
|
qemuCheckpointWriteMetadata(virDomainObjPtr vm,
|
||||||
|
virDomainMomentObjPtr checkpoint,
|
||||||
|
virDomainXMLOptionPtr xmlopt,
|
||||||
|
const char *checkpointDir);
|
||||||
|
@ -11103,10 +11103,12 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr cfg,
|
|||||||
g_autofree char *cfg_file = NULL;
|
g_autofree char *cfg_file = NULL;
|
||||||
g_autofree char *autostart_link = NULL;
|
g_autofree char *autostart_link = NULL;
|
||||||
g_autofree char *snap_dir = NULL;
|
g_autofree char *snap_dir = NULL;
|
||||||
|
g_autofree char *chk_dir = NULL;
|
||||||
|
|
||||||
cfg_file = virDomainConfigFile(cfg->configDir, name);
|
cfg_file = virDomainConfigFile(cfg->configDir, name);
|
||||||
autostart_link = virDomainConfigFile(cfg->autostartDir, name);
|
autostart_link = virDomainConfigFile(cfg->autostartDir, name);
|
||||||
snap_dir = g_strdup_printf("%s/%s", cfg->snapshotDir, 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) &&
|
if (virFileExists(cfg_file) &&
|
||||||
unlink(cfg_file) < 0) {
|
unlink(cfg_file) < 0) {
|
||||||
@ -11127,5 +11129,10 @@ qemuDomainNamePathsCleanup(virQEMUDriverConfigPtr cfg,
|
|||||||
!bestEffort)
|
!bestEffort)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (virFileIsDir(chk_dir) &&
|
||||||
|
virFileDeleteTree(chk_dir) < 0 &&
|
||||||
|
!bestEffort)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -19120,6 +19120,24 @@ qemuDomainSnapshotWriteMetadataIter(void *payload,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainCheckpointWriteMetadataIter(void *payload,
|
||||||
|
const char *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
|
static int
|
||||||
qemuDomainRenameCallback(virDomainObjPtr vm,
|
qemuDomainRenameCallback(virDomainObjPtr vm,
|
||||||
const char *new_name,
|
const char *new_name,
|
||||||
@ -19186,6 +19204,11 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
|
|||||||
&data) < 0)
|
&data) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virDomainCheckpointForEach(vm->checkpoints,
|
||||||
|
qemuDomainCheckpointWriteMetadataIter,
|
||||||
|
&data) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0)
|
if (virDomainDefSave(vm->def, driver->xmlopt, cfg->configDir) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user