mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +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;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virHashRemoveAll(chown_paths);
|
|
||||||
virHashRemoveAll(xattr_paths);
|
|
||||||
virMutexUnlock(&m);
|
virMutexUnlock(&m);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void freePaths(void)
|
||||||
|
{
|
||||||
|
virMutexLock(&m);
|
||||||
|
init_hash();
|
||||||
|
|
||||||
|
virHashFree(chown_paths);
|
||||||
|
virHashFree(xattr_paths);
|
||||||
|
chown_paths = xattr_paths = NULL;
|
||||||
|
virMutexUnlock(&m);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virProcessRunInFork(virProcessForkCallback cb,
|
virProcessRunInFork(virProcessForkCallback cb,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
|
@ -125,6 +125,7 @@ testDomain(const void *opaque)
|
|||||||
unsetenv(ENVVAR);
|
unsetenv(ENVVAR);
|
||||||
virObjectUnref(vm);
|
virObjectUnref(vm);
|
||||||
virObjectUnref(securityManager);
|
virObjectUnref(securityManager);
|
||||||
|
freePaths();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,3 +21,5 @@
|
|||||||
#define ENVVAR "LIBVIRT_QEMU_SECURITY_TEST"
|
#define ENVVAR "LIBVIRT_QEMU_SECURITY_TEST"
|
||||||
|
|
||||||
extern int checkPaths(void);
|
extern int checkPaths(void);
|
||||||
|
|
||||||
|
extern void freePaths(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user