mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
qemusecuritymock: Introduce and use freePaths()
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>
This commit is contained in:
parent
80cf6ec6f2
commit
8ffb5f2738
@ -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)
|
||||
|
@ -125,6 +125,7 @@ testDomain(const void *opaque)
|
||||
unsetenv(ENVVAR);
|
||||
virObjectUnref(vm);
|
||||
virObjectUnref(securityManager);
|
||||
freePaths();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -21,3 +21,5 @@
|
||||
#define ENVVAR "LIBVIRT_QEMU_SECURITY_TEST"
|
||||
|
||||
extern int checkPaths(void);
|
||||
|
||||
extern void freePaths(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user