On 08/18/2016 07:47 AM, Erik Skultety wrote: > Outputs are a bit trickier than filters, because if the user(config)-specified > set of outputs does contain duplicates. So, not only we would log twice, but "because the user(config) specified set of outputs can contain duplicates." > we would also leek FD for journald, since that one is global and is overwritten s/leek/leak Which may not be true any more if patch 19 is moved. ACK - John > every time a journald output was specified. For compatibility reasons, we > cannot just error out and forbid the daemon to start if we find duplicate > outputs which do not make sense. Instead, we could silently take into account > only the last occurrence of the duplicate output and remove all the previous > ones, so that the logger will not try to use them when it is looping over all > of its registered outputs. > > Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx> > --- > src/libvirt_private.syms | 1 + > src/util/virlog.c | 32 ++++++++++++++++++++++++++++++++ > src/util/virlog.h | 2 ++ > 3 files changed, 35 insertions(+) > > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms > index 088f9f3..d28405c 100644 > --- a/src/libvirt_private.syms > +++ b/src/libvirt_private.syms > @@ -1847,6 +1847,7 @@ virLogDefineOutput; > virLogFilterFree; > virLogFilterListFree; > virLogFilterNew; > +virLogFindOutput; > virLogGetDefaultPriority; > virLogGetFilters; > virLogGetNbFilters; > diff --git a/src/util/virlog.c b/src/util/virlog.c > index e4dc84b..5916ac8 100644 > --- a/src/util/virlog.c > +++ b/src/util/virlog.c > @@ -1650,3 +1650,35 @@ virLogFilterNew(const char *match, > > return ret; > } > + > + > +/** > + * virLogFindOutput: > + * @outputs: a list of outputs where to look for the output of type @dest > + * @noutputs: number of elements in @outputs > + * @dest: destination type of an output > + * @opaque: opaque data to the method (only filename at the moment) > + * > + * Looks for an output of destination type @dest in the source list @outputs. > + * If such an output exists, index of the object in the list is returned. > + * In case of the destination being of type FILE also a comparison of the > + * output's filename with @opaque is performed first. > + * > + * Returns the index of the object in the list or -1 if no object matching the > + * specified @dest type and/or @opaque data one was found. > + */ > +int > +virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs, > + virLogDestination dest, const void *opaque) > +{ > + size_t i; > + const char *name = opaque; > + > + for (i = 0; i < noutputs; i++) { > + if (dest == outputs[i]->dest && > + (dest != VIR_LOG_TO_FILE || STREQ(outputs[i]->name, name))) > + return i; > + } > + > + return -1; > +} > diff --git a/src/util/virlog.h b/src/util/virlog.h > index a56d297..2045c06 100644 > --- a/src/util/virlog.h > +++ b/src/util/virlog.h > @@ -235,5 +235,7 @@ virLogOutputPtr virLogOutputNew(virLogOutputFunc f, > virLogFilterPtr virLogFilterNew(const char *match, > virLogPriority priority, > unsigned int flags); > +int virLogFindOutput(virLogOutputPtr *outputs, size_t noutputs, > + virLogDestination dest, const void *opaque); > > #endif > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list