mirror of https://gitee.com/openkylin/libvirt.git
qemu: snapshot: Extract setup of snapshot disk definition for transient disks
The code will be later reused when adding support for sharing the backing image of the snapshot. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
92a3eddd03
commit
81db8b6d89
|
@ -1168,26 +1168,11 @@ qemuSnapshotDiskPrepareActiveExternal(virDomainObj *vm,
|
|||
}
|
||||
|
||||
|
||||
static qemuSnapshotDiskContext *
|
||||
qemuSnapshotDiskPrepareDisksTransient(virDomainObj *vm,
|
||||
virQEMUDriverConfig *cfg,
|
||||
GHashTable *blockNamedNodeData,
|
||||
qemuDomainAsyncJob asyncJob)
|
||||
static virDomainSnapshotDiskDef *
|
||||
qemuSnapshotGetTransientDiskDef(virDomainDiskDef *domdisk)
|
||||
{
|
||||
g_autoptr(qemuSnapshotDiskContext) snapctxt = NULL;
|
||||
size_t i;
|
||||
|
||||
snapctxt = qemuSnapshotDiskContextNew(vm->def->ndisks, vm, asyncJob);
|
||||
|
||||
for (i = 0; i < vm->def->ndisks; i++) {
|
||||
virDomainDiskDef *domdisk = vm->def->disks[i];
|
||||
g_autoptr(virDomainSnapshotDiskDef) snapdisk = g_new0(virDomainSnapshotDiskDef, 1);
|
||||
|
||||
if (!domdisk->transient)
|
||||
continue;
|
||||
|
||||
/* validation code makes sure that we do this only for local disks
|
||||
* with a file source */
|
||||
snapdisk->name = g_strdup(domdisk->dst);
|
||||
snapdisk->snapshot = VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
|
||||
snapdisk->src = virStorageSourceNew();
|
||||
|
@ -1202,6 +1187,34 @@ qemuSnapshotDiskPrepareDisksTransient(virDomainObj *vm,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
return g_steal_pointer(&snapdisk);
|
||||
}
|
||||
|
||||
|
||||
static qemuSnapshotDiskContext *
|
||||
qemuSnapshotDiskPrepareDisksTransient(virDomainObj *vm,
|
||||
virQEMUDriverConfig *cfg,
|
||||
GHashTable *blockNamedNodeData,
|
||||
qemuDomainAsyncJob asyncJob)
|
||||
{
|
||||
g_autoptr(qemuSnapshotDiskContext) snapctxt = NULL;
|
||||
size_t i;
|
||||
|
||||
snapctxt = qemuSnapshotDiskContextNew(vm->def->ndisks, vm, asyncJob);
|
||||
|
||||
for (i = 0; i < vm->def->ndisks; i++) {
|
||||
virDomainDiskDef *domdisk = vm->def->disks[i];
|
||||
g_autoptr(virDomainSnapshotDiskDef) snapdisk = NULL;
|
||||
|
||||
if (!domdisk->transient)
|
||||
continue;
|
||||
|
||||
/* validation code makes sure that we do this only for local disks
|
||||
* with a file source */
|
||||
|
||||
if (!(snapdisk = qemuSnapshotGetTransientDiskDef(domdisk)))
|
||||
return NULL;
|
||||
|
||||
if (qemuSnapshotDiskPrepareOne(vm, cfg, domdisk, snapdisk,
|
||||
snapctxt->dd + snapctxt->ndd++,
|
||||
blockNamedNodeData,
|
||||
|
|
Loading…
Reference in New Issue