[PATCH] test: fix potential lock corruption in test driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Laine Stump <laine@xxxxxxxxxx>

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.
---
 src/test/test_driver.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index ce94a17..89f7df1 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -1861,6 +1861,8 @@ testDomainRestoreFlags(virConnectPtr conn,
         return -1;
     }
 
+    testDriverLock(privconn);
+
     if ((fd = open(path, O_RDONLY)) < 0) {
         virReportSystemError(errno,
                              _("cannot read domain image '%s'"),
@@ -1900,7 +1902,6 @@ testDomainRestoreFlags(virConnectPtr conn,
     }
     xml[len] = '\0';
 
-    testDriverLock(privconn);
     def = virDomainDefParseString(privconn->caps, xml,
                                   1 << VIR_DOMAIN_VIRT_TEST,
                                   VIR_DOMAIN_XML_INACTIVE);
-- 
1.7.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]