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
|
static virDomainSnapshotPtr
|
||||||
qemuSnapshotCreate(virDomainObj *vm,
|
qemuSnapshotCreate(virDomainObj *vm,
|
||||||
virDomainPtr domain,
|
virDomainPtr domain,
|
||||||
virDomainSnapshotDef *snapdef,
|
virDomainSnapshotDef *snapdeftmp,
|
||||||
virQEMUDriver *driver,
|
virQEMUDriver *driver,
|
||||||
virQEMUDriverConfig *cfg,
|
virQEMUDriverConfig *cfg,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
g_autoptr(virDomainSnapshotDef) snapdef = virObjectRef(snapdeftmp);
|
||||||
g_autoptr(virDomainMomentObj) tmpsnap = NULL;
|
g_autoptr(virDomainMomentObj) tmpsnap = NULL;
|
||||||
virDomainMomentObj *snap = NULL;
|
virDomainMomentObj *snap = NULL;
|
||||||
virDomainMomentObj *current = NULL;
|
virDomainMomentObj *current = NULL;
|
||||||
|
@ -1769,17 +1770,17 @@ qemuSnapshotCreate(virDomainObj *vm,
|
||||||
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) {
|
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA) {
|
||||||
snap = tmpsnap = virDomainMomentObjNew();
|
snap = tmpsnap = virDomainMomentObjNew();
|
||||||
snap->def = &snapdef->parent;
|
snap->def = &snapdef->parent;
|
||||||
|
snapdef = NULL;
|
||||||
} else {
|
} else {
|
||||||
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
|
if (!(snap = virDomainSnapshotAssignDef(vm->snapshots, snapdef)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
snapdef = NULL;
|
||||||
|
|
||||||
if ((current = virDomainSnapshotGetCurrent(vm->snapshots))) {
|
if ((current = virDomainSnapshotGetCurrent(vm->snapshots))) {
|
||||||
snap->def->parent_name = g_strdup(current->def->name);
|
snap->def->parent_name = g_strdup(current->def->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virObjectRef(snapdef);
|
|
||||||
|
|
||||||
/* actually do the snapshot */
|
/* actually do the snapshot */
|
||||||
if (virDomainObjIsActive(vm)) {
|
if (virDomainObjIsActive(vm)) {
|
||||||
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY ||
|
if (flags & VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY ||
|
||||||
|
|
Loading…
Reference in New Issue