mirror of https://gitee.com/openkylin/libvirt.git
qemuSnapshotCreate: Standardize handling of the reference on @snapdef
As with qemuSnapshotRedefine, make an extra reference in a temporary autocleaned variable and use that instead of refing the definition after it's stolen. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
c0fd70c1e1
commit
2d0f7d779d
|
@ -1750,11 +1750,12 @@ qemuSnapshotRedefine(virDomainObj *vm,
|
|||
static virDomainSnapshotPtr
|
||||
qemuSnapshotCreate(virDomainObj *vm,
|
||||
virDomainPtr domain,
|
||||
virDomainSnapshotDef *snapdef,
|
||||
virDomainSnapshotDef *snapdeftmp,
|
||||
virQEMUDriver *driver,
|
||||
virQEMUDriverConfig *cfg,
|
||||
unsigned int flags)
|
||||
{
|
||||
g_autoptr(virDomainSnapshotDef) snapdef = virObjectRef(snapdeftmp);
|
||||
g_autoptr(virDomainMomentObj) tmpsnap = NULL;
|
||||
virDomainMomentObj *snap = NULL;
|
||||
virDomainMomentObj *current = NULL;
|
||||
|
@ -1769,17 +1770,17 @@ qemuSnapshotCreate(virDomainObj *vm,
|
|||
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) {
|
||||
snap = tmpsnap = virDomainMomentObjNew();
|
||||
snap->def = &snapdef->parent;
|
||||
snapdef = NULL;
|
||||
} else {
|
||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
|
||||
return NULL;
|
||||
snapdef = NULL;
|
||||
|
||||
if ((current = virDomainSnapshotGetCurrent(vm->snapshots))) {
|
||||
snap->def->parent_name = g_strdup(current->def->name);
|
||||
}
|
||||
}
|
||||
|
||||
virObjectRef(snapdef);
|
||||
|
||||
/* actually do the snapshot */
|
||||
if (virDomainObjIsActive(vm)) {
|
||||
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY ||
|
||||
|
|
Loading…
Reference in New Issue