test: fix potential lock corruption in test driver
test: fix potential lock corruption in test driver

In some error situations, the function testDomainRestoreFlags() could
unlock the test driver mutex without first locking it. This patch
moves the lock operation earlier, so that it occurs before any
potential jump down to the unlock call.

I found this problem while auditing the test driver lock usage to
determine the cause of a hang while running the following test:

  cd tests; while true; do printf x; ./undefine; done

This patch *does not* solve that problem, but we now understand its
actual source, and danpb is working on a patch.

crobinso/libvirt,siboulet/libvirt-openvz,trainstack/libvirt,iam-TJ/libvirt,andreabolognani/libvirt,wiedi/libvirt,shugaoye/libvirt,elmarco/libvirt,zhlcindy/libvirt-1.1.4-maintain,crobinso/libvirt,danwent/libvirt-ovs,nertpinx/libvirt,dumbbell/libvirt,jeckersb/libvirt,rmarwaha/libvirt,novel/fbsd-libvirt,wiedi/libvirt,datto/libvirt,siboulet/libvirt-openvz,rmarwaha/libvirt1,warewolf/libvirt,andreabolognani/libvirt,wiedi/libvirt,foomango/libvirt,iam-TJ/libvirt,warewolf/libvirt,emaste/libvirt,rlaager/libvirt,rmarwaha/libvirt,nertpinx/libvirt,datto/libvirt,andreabolognani/libvirt,jardasgit/libvirt,zippy2/libvirt,danwent/libvirt-ovs,novel/fbsd-libvirt,zhlcindy/libvirt-1.1.4-maintain,danwent/libvirt-ovs,cbosdo/libvirt,taget/libvirt,trainstack/libvirt,dumbbell/libvirt,crobinso/libvirt,andreabolognani/libvirt,wiedi/libvirt,jeckersb/libvirt,jardasgit/libvirt,dumbbell/libvirt,fabianfreyer/libvirt,emaste/libvirt,rmarwaha/libvirt,emaste/libvirt,dumbbell/libvirt,warewolf/libvirt,novel/fbsd-libvirt,VenkatDatta/libvirt,libvirt/libvirt,wiedi/libvirt,foomango/libvirt,trainstack/libvirt,novel/fbsd-libvirt,shugaoye/libvirt,warewolf/libvirt,agx/libvirt,jeckersb/libvirt,rmarwaha/libvirt1,zhlcindy/libvirt-1.1.4-maintain,emaste/libvirt,rmarwaha/libvirt,iam-TJ/libvirt,wiedi/libvirt,nertpinx/libvirt,cbosdo/libvirt,novel/fbsd-libvirt,eskultety/libvirt,cbosdo/libvirt,cbosdo/libvirt,jfehlig/libvirt,agx/libvirt,rlaager/libvirt,rlaager/libvirt,emaste/libvirt,taget/libvirt,bjzhang/libvirt,shugaoye/libvirt,datto/libvirt,novel/fbsd-libvirt,jfehlig/libvirt,taget/libvirt,eskultety/libvirt,eskultety/libvirt,taget/libvirt,nertpinx/libvirt,shugaoye/libvirt,jfehlig/libvirt,fabianfreyer/libvirt,trainstack/libvirt,fabianfreyer/libvirt,VenkatDatta/libvirt,trainstack/libvirt,trainstack/libvirt,agx/libvirt,dumbbell/libvirt,siboulet/libvirt-openvz,jeckersb/libvirt,eskultety/libvirt,warewolf/libvirt,andreabolognani/libvirt,danwent/libvirt-ovs,rmarwaha/libvirt,libvirt/libvirt,warewolf/libvirt,dumbbell/libvirt,elmarco/libvirt,zhlcindy/libvirt-1.1.4-maintain,jardasgit/libvirt,VenkatDatta/libvirt,olafhering/libvirt,warewolf/libvirt,libvirt/libvirt,rmarwaha/libvirt1,foomango/libvirt,datto/libvirt,jeckersb/libvirt,shugaoye/libvirt,elmarco/libvirt,rmarwaha/libvirt1,iam-TJ/libvirt,zippy2/libvirt,olafhering/libvirt,rlaager/libvirt,VenkatDatta/libvirt,bjzhang/libvirt,foomango/libvirt,zhlcindy/libvirt-1.1.4-maintain,nertpinx/libvirt,wiedi/libvirt,olafhering/libvirt,iam-TJ/libvirt,zippy2/libvirt,agx/libvirt,bjzhang/libvirt,jeckersb/libvirt,novel/fbsd-libvirt,VenkatDatta/libvirt,fabianfreyer/libvirt,elmarco/libvirt,eskultety/libvirt,jardasgit/libvirt,trainstack/libvirt,rlaager/libvirt,iam-TJ/libvirt,fabianfreyer/libvirt,zippy2/libvirt,emaste/libvirt,siboulet/libvirt-openvz,novel/fbsd-libvirt,agx/libvirt,datto/libvirt,rmarwaha/libvirt1,jfehlig/libvirt,taget/libvirt,jeckersb/libvirt,emaste/libvirt,jardasgit/libvirt,bjzhang/libvirt,danwent/libvirt-ovs,elmarco/libvirt,foomango/libvirt,novel/fbsd-libvirt,iam-TJ/libvirt,rmarwaha/libvirt,crobinso/libvirt,libvirt/libvirt,cbosdo/libvirt,bjzhang/libvirt,rmarwaha/libvirt1,olafhering/libvirt,siboulet/libvirt-openvz