[libvirt] [PATCH 8/8] test: Fix lock ordering in testDomainRevertToSnapshot
Michal Privoznik
mprivozn at redhat.com
Fri Jun 19 14:45:00 UTC 2015
On 16.06.2015 19:43, Peter Krempa wrote:
> The test driver lock should not be acquired while a domain object lock
> is held. Tweak the lock ordering to avoid possible deadlock.
> ---
> src/test/test_driver.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index cfec122..9e617a2 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -6603,13 +6603,13 @@ testDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
> * and use of FORCE can cause multiple transitions.
> */
>
> - if (!(vm = testDomObjFromSnapshot(snapshot)))
> - return -1;
> + testDriverLock(privconn);
>
> - if (!(snap = testSnapObjFromSnapshot(vm, snapshot)))
> + if (!(vm = testDomObjFromDomainLocked(privconn, snapshot->domain)))
> goto cleanup;
>
> - testDriverLock(privconn);
> + if (!(snap = testSnapObjFromSnapshot(vm, snapshot)))
> + goto cleanup;
>
> if (!vm->persistent &&
> snap->def->state != VIR_DOMAIN_RUNNING &&
>
Fortunately, the public API already checked that @snapshot is not NULL
and snapshot->domain is of virDomainClass class.
ACK
Michal
More information about the libvir-list
mailing list