virlog: Introduce virLogDefineFilters

Prepare a method that only defines a set of filters. It takes a list of
filters, preferably created by virLogParseFilters. The original set of filters
is reset and replaced by the new user-provided set of filters.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Erik Skultety 2016-03-29 17:04:36 +02:00
parent d9d6b61f6d
commit 58ab1b6f89
3 changed files with 29 additions and 0 deletions

View File

@ -1870,6 +1870,7 @@ virLockSpaceReleaseResourcesForOwner;
# util/virlog.h # util/virlog.h
virLogDefineFilter; virLogDefineFilter;
virLogDefineFilters;
virLogDefineOutput; virLogDefineOutput;
virLogDefineOutputs; virLogDefineOutputs;
virLogFilterFree; virLogFilterFree;

View File

@ -1706,3 +1706,30 @@ virLogDefineOutputs(virLogOutputPtr *outputs, size_t noutputs)
return 0; return 0;
} }
/**
* virLogDefineFilters:
* @filters: new set of filters to be defined
* @nfilters: number of filters in @filters
*
* Resets any existing set of filters and defines a completely new one. The
* resulting set can also be empty in which case NULL should be passed to
* @filters.
*
* Returns 0 on success or -1 in case of error.
*/
int
virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters)
{
if (virLogInitialize() < 0)
return -1;
virLogLock();
virLogResetFilters();
virLogFilters = filters;
virLogNbFilters = nfilters;
virLogUnlock();
return 0;
}

View File

@ -239,5 +239,6 @@ int virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs,
virLogDestination dest, const void *opaque); virLogDestination dest, const void *opaque);
int virLogDefineOutputs(virLogOutputPtr *outputs, int virLogDefineOutputs(virLogOutputPtr *outputs,
size_t noutputs) ATTRIBUTE_NONNULL(1); size_t noutputs) ATTRIBUTE_NONNULL(1);
int virLogDefineFilters(virLogFilterPtr *filters, size_t nfilters);
#endif #endif