1. 10 10月, 2016 12 次提交
    • E
      virlog: Introduce virLogParseFilter · 77a45f2f
      Erik Skultety 提交于
      Same as for outputs, introduce a new method, that is basically the same as
      virLogParseAndDefineFilter with the difference that it does not define the
      filter. It rather returns a newly created object that needs to be inserted into
      a list and then defined separately.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      77a45f2f
    • E
      virlog: Introduce virLogParseOutput · 09b7cbb1
      Erik Skultety 提交于
      Introduce a method to parse an individual logging output. The difference
      compared to the virLogParseAndDefineOutput is that this method does not define
      the output, instead it makes use of the virLogNewOutputTo* methods introduced
      in the previous patch and just returns the virLogOutput object that has to be
      added to a list of object which then can be defined as a whole via
      virLogDefineOutputs. The idea remains still the same - split parsing and
      defining of the logging primitives (outputs, filters).
      Additionally, since virLogNewOutputTo* methods are now finally used,
      ATTRIBUTE_UNUSED can be successfully removed from the methods' definitions,
      since that was just to avoid compiler complaints about unused static functions.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      09b7cbb1
    • E
      virlog: Take a special care of syslog when setting new set of log outputs · 640b58ab
      Erik Skultety 提交于
      Now that we're in the critical section, syslog connection can be re-opened
      by issuing openlog, which is something that cannot be done beforehand, since
      syslog keeps its file descriptor private and changing the tag earlier might
      introduce a log inconsistency if something went wrong with preparing a new set
      of logging outputs in order to replace the existing one.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      640b58ab
    • E
      virlog: Introduce virLogNewOutputTo* as a replacement for virLogAddOutputTo* · 4c352295
      Erik Skultety 提交于
      Continuing with the effort to split output parsing and defining, these new
      functions return a logging object reference instead of defining the output.
      Eventually, these functions will replace the existing ones (virLogAddOutputTo*)
      which will then be dropped.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      4c352295
    • E
      virlog: Introduce virLogDefineFilters · 58ab1b6f
      Erik Skultety 提交于
      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: NErik Skultety <eskultet@redhat.com>
      58ab1b6f
    • E
      virlog: Introduce virLogDefineOutputs · d9d6b61f
      Erik Skultety 提交于
      Prepare a method that only defines a set of outputs. It takes a list of
      outputs, preferably created by virLogParseOutputs. The original set of outputs
      is reset and replaced by the new user-provided set of outputs.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      d9d6b61f
    • E
      virlog: Introduce virLogFindOutput · b5004b09
      Erik Skultety 提交于
      Outputs are a bit trickier than filters, since the user(config)-specified
      set of outputs can contain duplicates. That would lead to logging the same
      message twice. 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: NErik Skultety <eskultet@redhat.com>
      b5004b09
    • E
      virlog: Introduce virLogFilterNew · 435200ca
      Erik Skultety 提交于
      This method allocates a new filter object which it then returns back to caller.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      435200ca
    • E
      virlog: Introduce virLogOutputNew · b0f5dc91
      Erik Skultety 提交于
      In order to later split output parsing and output defining, introduce a new
      function which will create a new virLogOutput object which the parser will
      insert into a list with the list being eventually defined.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      b0f5dc91
    • E
      virlog: Store the journald fd within the output object · a2405a88
      Erik Skultety 提交于
      There is really no reason why we could not keep journald's fd within the
      journald output object the same way as we do for regular file-based outputs.
      By doing this we later won't have to special case the journald-based output
      (due to the fd being globally shared) when replacing the existing set of outputs
      with a new one. Additionally, by making this change, we don't need the
      virLogCloseJournald routine anymore, plain virLogCloseFd will suffice.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      a2405a88
    • E
      virlog: Rename virLogParse* to virLogParseAndDefine* · b8c370a9
      Erik Skultety 提交于
      Right now virLogParse* functions are doing both parsing and defining of filters
      and outputs which should be two separate operations. Since the naming is
      apparently a bit poor this patch renames these functions to
      virLogParseAndDefine* which eventually will be replaced by virLogSet*.
      Additionally, virLogParse{Filter,Output} will be later (after the split) reused,
      so that these functions do exactly what the their name suggests.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      b8c370a9
    • E
      virlog: Remove unused macro IS_SPACE · 6aa3a6a4
      Erik Skultety 提交于
      During first stage of virlog.c refactor, commit 0b231195 forgot to remove the
      macro definition along with its usage.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      6aa3a6a4
  2. 12 9月, 2016 1 次提交
  3. 04 7月, 2016 7 次提交
  4. 24 3月, 2016 1 次提交
  5. 17 3月, 2016 1 次提交
  6. 16 3月, 2016 2 次提交
    • E
      virlog: Refactor virLogParseOutputs · 0b231195
      Erik Skultety 提交于
      The problem with the original virLogParseOutputs method was that the way it
      parsed the input, walking the string char by char and using absolute jumps
      depending on the virLogDestination type, was rather complicated to read.
      This patch utilizes virStringSplit method twice, first time to filter out any
      spaces and split the input to individual log outputs and then for each
      individual output to tokenize it by to the parts according to our
      PRIORITY:DESTINATION?(:DATA) format. Also, to STREQLEN for matching destination
      was replaced with virDestinationTypeFromString call.
      0b231195
    • E
      virlog: Introduce Type{To,From}String for virLogDestination · 034337fb
      Erik Skultety 提交于
      In order to refactor the ugly virLogParseOutputs method, this is a neat way of
      finding out whether the destination type (in the form of a string) user
      provided is a valid one. As a bonus, if it turns out it is valid, we get the
      actual enum which will later be passed to any of virLogAddOutput methods right
      away.
      034337fb
  7. 08 1月, 2016 2 次提交
    • M
      virLogVMessage: Don't leak rawinitmsg · 587fd105
      Michal Privoznik 提交于
      Instead of misusing a const string to hold up runtime allocated
      data, introduce new variable @hoststr and obey const correctness.
      
      ==6879== 15 bytes in 1 blocks are definitely lost in loss record 68 of 1,064
      ==6879==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==6879==    by 0xA7DDF97: vasprintf (in /lib64/libc-2.21.so)
      ==6879==    by 0x552BBC6: virVasprintfInternal (virstring.c:493)
      ==6879==    by 0x552BCDB: virAsprintfInternal (virstring.c:514)
      ==6879==    by 0x54FA44C: virLogHostnameString (virlog.c:468)
      ==6879==    by 0x54FAB0F: virLogVMessage (virlog.c:645)
      ==6879==    by 0x54FA680: virLogMessage (virlog.c:531)
      ==6879==    by 0x54FBBF4: virLogParseOutputs (virlog.c:1130)
      ==6879==    by 0x11CB4F: daemonSetupLogging (libvirtd.c:685)
      ==6879==    by 0x11E137: main (libvirtd.c:1297)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      587fd105
    • M
      virLogHostnameString: Don't leak hostname · 9f750648
      Michal Privoznik 提交于
      Once @hostname is printed into @hoststr we don't need it anymore.
      
      ==6879== 5 bytes in 1 blocks are definitely lost in loss record 10 of 1,064
      ==6879==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==6879==    by 0xA7ED599: strdup (in /lib64/libc-2.21.so)
      ==6879==    by 0x552C126: virStrdup (virstring.c:726)
      ==6879==    by 0x553B13E: virGetHostnameImpl (virutil.c:720)
      ==6879==    by 0x553B1BF: virGetHostnameQuiet (virutil.c:741)
      ==6879==    by 0x54FA3FD: virLogHostnameString (virlog.c:462)
      ==6879==    by 0x54FAB0F: virLogVMessage (virlog.c:645)
      ==6879==    by 0x54FA680: virLogMessage (virlog.c:531)
      ==6879==    by 0x54FBBF4: virLogParseOutputs (virlog.c:1130)
      ==6879==    by 0x11CB4F: daemonSetupLogging (libvirtd.c:685)
      ==6879==    by 0x11E137: main (libvirtd.c:1297)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      9f750648
  8. 11 12月, 2015 1 次提交
    • D
      log: include hostname in initial log message · 1ce92960
      Daniel P. Berrange 提交于
      On the very first log message we send to any output, we include
      the libvirt version number and package string. In some bug reports
      we have been given libvirtd.log files that came from a different
      host than the corresponding /var/log/libvirt/qemu log files. So
      extend the initial log message to include the hostname too.
      
      eg on first log message we would now see:
      
       $ libvirtd
       2015-12-04 17:35:36.610+0000: 20917: info : libvirt version: 1.3.0
       2015-12-04 17:35:36.610+0000: 20917: info : hostname: dhcp-1-180.lcy.redhat.com
       2015-12-04 17:35:36.610+0000: 20917: error : qemuMonitorIO:687 : internal error: End of file from monitor
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      1ce92960
  9. 25 9月, 2015 1 次提交
  10. 06 2月, 2015 1 次提交
  11. 15 11月, 2014 1 次提交
  12. 29 10月, 2014 1 次提交
    • E
      maint: avoid static zero init in core files · 39871fce
      Eric Blake 提交于
      C guarantees that static variables are zero-initialized.  Some older
      compilers (and also gcc -fno-zero-initialized-in-bss) create larger
      binaries if you explicitly zero-initialize a static variable.
      
      * src/libvirt.c: Fix initialization.
      * src/util/viralloc.c: Likewise.
      * src/util/virdbus.c: Likewise.
      * src/util/virevent.c: Likewise.
      * src/util/virfile.c (safezero): Likewise.
      * src/util/virlog.c: Likewise.
      * src/util/virnetlink.c: Likewise.
      * src/util/virthread.h (VIR_ONCE_GLOBAL_INIT): Likewise.
      * src/util/virprocess.c (virProcessGetStartTime): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      39871fce
  13. 26 3月, 2014 1 次提交
    • J
      Coverity: Resolve a CHECKED_RETURN message · b2e4ace2
      John Ferlan 提交于
      Recent changes to the module seemed to have caused Coverity to find a new
      issue regarding the failure to check the return from a sendmsg. The code
      doesn't seem to care about the return status, so just added an ignore_value
      to keep Coverity quiet.
      b2e4ace2
  14. 25 3月, 2014 1 次提交
  15. 21 3月, 2014 1 次提交
  16. 18 3月, 2014 6 次提交
    • D
      Remove global log buffer feature entirely · c0c8c1d7
      Daniel P. Berrange 提交于
      A earlier commit changed the global log buffer so that it only
      records messages that are explicitly requested via the log
      filters setting. This removes the performance burden, and
      improves the signal/noise ratio for messages in the global
      buffer. At the same time though, it is somewhat pointless, since
      all the recorded log messages are already going to be sent to an
      explicit log output like syslog, stderr or the journal. The
      global log buffer is thus just duplicating this data on stderr
      upon crash.
      
      The log_buffer_size config parameter is left in the augeas
      lens to prevent breakage for users on upgrade. It is however
      completely ignored hereafter.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c0c8c1d7
    • D
      Switch to filtering based on log source name instead of filename · 975b2392
      Daniel P. Berrange 提交于
      Currently the log filter strings are used in a string comparison
      against the source filename each time log message is emitted.
      If no log filters at all are set, there's obviously no string
      comparison to be done. If any single log filter is set though,
      this imposes a compute burden on every logging call even if logs
      from the file in question are disabled. This string comparison
      must also be done while the logging mutex is held, which has
      implications for concurrency when multiple threads are emitting
      log messages.
      
      This changes the log filtering to be done based on the virLogSource
      object name. The virLogSource struct is extended to contain
      'serial' and 'priority' fields. Any time the global log filter
      rules are changed a global serial number is incremented. When a
      log message is emitted, the serial in the virLogSource instance
      is compared with the global serial number. If out of date, then
      the 'priority' field in the virLogSource instance is updated based
      on the new filter rules. The 'priority' field is checked to see
      whether the log message should be sent to the log outputs.
      
      The comparisons of the 'serial' and 'priority' fields are done
      with no locks held. So in the common case each logging call has
      an overhead of 2 integer comparisons, with no locks held. Only
      if the decision is made to forward the message to the log output,
      or if the 'serial' value is out of date do locks need to be
      acquired.
      
      Technically the comparisons of the 'serial' and 'priority' fields
      should be done with locks held, or using atomic operations. Both
      of these options have a notable performance impact, however, and
      since all writes a protected by a global mutex, it is believed
      that worst case behaviour where the fields are read concurrently
      with being written would merely result in an mistaken emission
      or dropping of the log message in question. This is an acceptable
      tradeoff for the performance benefit of avoiding locking.
      
      As a quick benchmark, a demo program that registers 500 file
      descriptors with the event loop (eg equiv of 500 QEMU monitor
      commands), creates pending read I/O on every FD, and then runs
      virEventRunDefaultImpl() took 4.6 seconds to do 51200 iterations.
      After this optimization it only takes 3.3 seconds, with the log
      APIs no longer being a relevant factor in the running time.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      975b2392
    • D
      Add virLogSource variables to all source files · 2835c1e7
      Daniel P. Berrange 提交于
      Any source file which calls the logging APIs now needs
      to have a VIR_LOG_INIT("source.name") declaration at
      the start of the file. This provides a static variable
      of the virLogSource type.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      2835c1e7
    • D
      Turn virLogSource into a struct instead of an enum · 098dd79e
      Daniel P. Berrange 提交于
      As part of the goal to get away from doing string matching on
      filenames when deciding whether to emit a log message, turn
      the virLogSource enum into a struct which contains a log
      "name". There will eventually be one virLogSource instance
      statically declared per source file. To minimise churn in this
      commit though, a single global instance is used.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      098dd79e
    • D
      Refactor code that skips logging of error messages · 3887c5d8
      Daniel P. Berrange 提交于
      The error reporting code will invoke a callback when any error
      is raised and the default callback will print to stderr. The
      virRaiseErrorFull method also sends all error messages on to the
      logging code, which also prints to stderr by default. To avoid
      duplicated data on stderr, the logging code has some logic to
      skip emission when no log outputs are configured, which checks
      whether the virLogSource == VIR_LOG_FROM_ERROR.
      
      Meanwhile the libvirtd daemon can register another callback which
      is used to reduce log message priority from error to a lower level.
      When this is used we do want messages to end up on stderr, so the
      error code will conditionally use either VIR_LOG_FROM_FILE or
      VIR_LOG_FROM_ERROR depending on whether such a callback is provided.
      
      This will all complicate later refactoring. By pushing the checks
      for whether a log output is present up a level into the error code,
      the special cases can be isolated in one place.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      3887c5d8
    • D
      Reduce performance overhead of the global log buffer · 27f2edf9
      Daniel P. Berrange 提交于
      With the vast number of log debug statements in the code, the
      logging framework has a measurable performance impact on libvirt
      code, particularly in the daemon event loop.
      
      The global log buffer records every single log message triggered
      whether anyone cares to see them or not. This makes it impossible
      to eliminate the overhead of printf format expansions in any of
      the logging code. It is possible to disable the global log buffer
      in libvirtd itself, but this doesn't help client side library
      code. Also even if disabled by the config file, the existence of
      the feature makes other performance improvements in the logging
      layer impossible.
      
      Instead of logging every single message to the global buffer, only
      log messages that pass the log filters. This if libvirtd is set
      to have log_filters="1:libvirt 1:qemu" the global log buffer will
      only get filled with those messages instead of everything. This
      reduces the performance burden, as well as improving the signal
      to noise ratio of the log buffer.
      
      As a quick benchmark, a demo program that registers 500 file
      descriptors with the event loop (eg equiv of 500 QEMU monitor
      commands), creates pending read I/O on every FD, and then runs
      virEventRunDefaultImpl() took 1 minute 40 seconds to do 51200
      iterations with nearly all the time shown against the logging
      code. After this optimization it only takes 4.6 seconds.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      27f2edf9