diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8792bf7f54..d5b1b9cb72 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2354,6 +2354,7 @@ virFindFileInPath; # util/virfilecache.h +virFileCacheClear; virFileCacheGetPriv; virFileCacheInsertData; virFileCacheLookup; diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index bad37c9f00..b9e06545c0 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -407,3 +407,19 @@ virFileCacheInsertData(virFileCache *cache, return ret; } + + +/** + * virFileCacheClear: + * @cache: existing cache object + * + * Drops all entries from the cache. This is useful in tests to clean out + * previous usage. + */ +void +virFileCacheClear(virFileCache *cache) +{ + virObjectLock(cache); + virHashRemoveAll(cache->table); + virObjectUnlock(cache); +} diff --git a/src/util/virfilecache.h b/src/util/virfilecache.h index 81be8feef5..c3bc0f529c 100644 --- a/src/util/virfilecache.h +++ b/src/util/virfilecache.h @@ -135,3 +135,7 @@ int virFileCacheInsertData(virFileCache *cache, const char *name, void *data); + +/* for testing usage */ +void +virFileCacheClear(virFileCache *cache);