mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
libxl: MigratePrepare: use standard begin and end API pattern
libxlDomainMigrationPrepare adds the incoming domain def to the list of domains via virDomainObjListAdd, but never adds its own ref to the returned virDomainObj as other callers of virDomainObjListAdd do. libxlDomainMigrationPrepareTunnel3 suffers the same discrepancy. Change both to add a ref to the virDomainObj after a successful virDomainObjListAdd, similar to other callers. This ensures a consistent pattern throughout the drivers and allows using the virDomainObjEndAPI function for cleanup. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
fe51dbda56
commit
60b3fcd90c
@ -583,6 +583,7 @@ libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn,
|
|||||||
NULL)))
|
NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
virObjectRef(vm);
|
||||||
*def = NULL;
|
*def = NULL;
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
@ -635,13 +636,11 @@ libxlDomainMigrationPrepareTunnel3(virConnectPtr dconn,
|
|||||||
/* Remove virDomainObj from domain list */
|
/* Remove virDomainObj from domain list */
|
||||||
if (vm) {
|
if (vm) {
|
||||||
virDomainObjListRemove(driver->domains, vm);
|
virDomainObjListRemove(driver->domains, vm);
|
||||||
vm = NULL;
|
virObjectLock(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (vm)
|
virDomainObjEndAPI(&vm);
|
||||||
virObjectUnlock(vm);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,6 +682,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
|
|||||||
NULL)))
|
NULL)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
virObjectRef(vm);
|
||||||
*def = NULL;
|
*def = NULL;
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
|
|
||||||
@ -810,7 +810,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
|
|||||||
/* Remove virDomainObj from domain list */
|
/* Remove virDomainObj from domain list */
|
||||||
if (vm) {
|
if (vm) {
|
||||||
virDomainObjListRemove(driver->domains, vm);
|
virDomainObjListRemove(driver->domains, vm);
|
||||||
vm = NULL;
|
virObjectLock(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -820,8 +820,7 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
|
|||||||
VIR_FREE(hostname);
|
VIR_FREE(hostname);
|
||||||
else
|
else
|
||||||
virURIFree(uri);
|
virURIFree(uri);
|
||||||
if (vm)
|
virDomainObjEndAPI(&vm);
|
||||||
virObjectUnlock(vm);
|
|
||||||
virObjectUnref(cfg);
|
virObjectUnref(cfg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user