]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemusecuritymock: Introduce and use freePaths()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Apr 2019 14:15:10 +0000 (16:15 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Jul 2019 06:36:03 +0000 (08:36 +0200)
Problem with current approach is that if
qemuSecuritySetAllLabel() fails, then the @chown_paths and
@xattr_paths hash tables are not freed and preserve values
already stored there into the next test case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
tests/qemusecuritymock.c
tests/qemusecuritytest.c
tests/qemusecuritytest.h

index e52a41067a954e5740813eab7eb7018aa0c6819f..815bd44d7652c504a71d9d2fb7d567472324f908 100644 (file)
@@ -411,13 +411,23 @@ int checkPaths(void)
 
     ret = 0;
  cleanup:
-    virHashRemoveAll(chown_paths);
-    virHashRemoveAll(xattr_paths);
     virMutexUnlock(&m);
     return ret;
 }
 
 
+void freePaths(void)
+{
+    virMutexLock(&m);
+    init_hash();
+
+    virHashFree(chown_paths);
+    virHashFree(xattr_paths);
+    chown_paths = xattr_paths = NULL;
+    virMutexUnlock(&m);
+}
+
+
 int
 virProcessRunInFork(virProcessForkCallback cb,
                     void *opaque)
index 79d4f744b68709b830e949cdb00a187d3b1bf870..9ac953f388a635fbab795400e26fee8b8ae810fa 100644 (file)
@@ -125,6 +125,7 @@ testDomain(const void *opaque)
     unsetenv(ENVVAR);
     virObjectUnref(vm);
     virObjectUnref(securityManager);
+    freePaths();
     return ret;
 }
 
index f166eac3aca942cd0e9d2295fea97bc5e8367392..812d73f073f8147778d43bf0d9b02bf6985e4100 100644 (file)
@@ -21,3 +21,5 @@
 #define ENVVAR "LIBVIRT_QEMU_SECURITY_TEST"
 
 extern int checkPaths(void);
+
+extern void freePaths(void);