1. 19 3月, 2014 1 次提交
    • E
      maint: avoid unbalanced {} across vbox #ifdef · b0b54221
      Eric Blake 提交于
      Emacs is fairly good about navigating across function and scope
      boundaries, provided that the code has balanced {}.  The vbox
      code, however, violated that premise, by splitting 'if () {'
      across several #ifdef branches, but sharing the '} else {...}'
      outside of the branches.  The extra lines of code is worth my
      sanity, in a function that is already a horrendous 1100+ lines
      long.
      
      * src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc) Duplicate code
      rather than trying to share else branch across #ifdef.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b0b54221
  2. 18 3月, 2014 34 次提交
    • 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
      Move dtrace probe macros into separate header file · b29275d9
      Daniel P. Berrange 提交于
      The dtrace probe macros rely on the logging API. We can't make
      the internal.h header include the virlog.h header though since
      that'd be a circular include. Instead simply split the dtrace
      probes into their own header file, since there's no compelling
      reason for them to be in the main internal.h header.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      b29275d9
    • 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
    • M
      virNetServerNewPostExecRestart: Initialize @max_anonymous_clients · 1a8d91d9
      Michal Privoznik 提交于
      Coverity spotted a use of possibly undefined variable. If a server is
      restarting as an result of update, the JSON file that keeps current
      value of some variables will not contain the new variables. This is
      the case of @max_anonymous_clients too. We are correctly querying if
      there's "max_anonymous_clients" in the JSON, however, we are not
      setting a sane default if there's none.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      1a8d91d9
    • M
      qemuDomainSetInterfaceParameters: Allow bandwidth clear out · 14973382
      Michal Privoznik 提交于
      We allow translation from no_bandwidth to has_bandwidth for a vnic.
      However, going in the opposite direction is not implemented. It's not
      limitation of the API rather than internal implementation. The problem
      is, we correctly detect that user hasn't specified any outbound (say
      he wants to clear out outbound). However, this gets overwritten by
      current vnic outbound settings. Then, virNetDevBandwidthSet doesn't
      change anything. We need to stop overwriting the outbound if users
      don't want us to. Same applies for inbound.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      14973382
    • M
      cfg.mk: Fix whitespaces · 11c5c9a9
      Martin Kletzander 提交于
      Just to align the backslashes with most of the file.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      11c5c9a9
    • J
      Remove double space in file name comment check · 80ac0176
      Ján Tomko 提交于
      Reported by Martin Kletzander
      80ac0176
    • M
      Don't leave empty first line in C source files · 14fc041f
      Martin Kletzander 提交于
      If there should be some sort of separator it is better to use comment
      with the filename, copyright, description, license information and
      authors.
      
      Found by:
      
      git grep -nH '^$' | grep '\.[ch]:1:'
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      14fc041f
    • M
      Explicitly cast some switch parameters to enum · 2bc46827
      Martin Kletzander 提交于
      This patch is not trying to fix every switch, just the ones I worked
      with last time, because some of these were especially unreadable.
      Covers enums virDomainGraphicsType and virDomainChrType (where
      applicable).
      
      Also sort its cases by their value.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      2bc46827
    • M
      Require spaces around equality comparisons · cc9c62fe
      Martin Kletzander 提交于
      Commit a1cbe4b5 added a check for spaces around assignments and this
      patch extends it to checks for spaces around '=='.  One exception is
      virAssertCmpInt where comma after '==' is acceptable (since it is a
      macro and '==' is its argument).
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      cc9c62fe
    • M
      123a881d
    • M
      tests: cleanup object-locking test · db272ebf
      Martin Kletzander 提交于
      When ran, cil is throwing out some errors and warnings for obsolete
      'or' unused variables and wrong module name (it should not contain a
      hyphen; hence the rename).
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      db272ebf
    • M
      qemu: agent availability cleanup · ef8f4761
      Martin Kletzander 提交于
      Eliminate all the code re-use which checks for priv->agentError or
      priv->agent.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      ef8f4761
    • N
      Fix memory leak in virDomainChrSourceDefClear() · 24b3fcf9
      Nehal J Wani 提交于
      While running qemuxml2xmltest, it was found that valgrind pointed out
      the following memory leak:
      
      ==21905== 26 bytes in 1 blocks are definitely lost in loss record 23 of 69
      ==21905==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
      ==21905==    by 0x3E782A754D: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
      ==21905==    by 0x4CD986D: virDomainChrSourceDefParseXML (domain_conf.c:7233)
      ==21905==    by 0x4CE4199: virDomainChrDefParseXML (domain_conf.c:7512)
      ==21905==    by 0x4CFAF3F: virDomainDefParseXML (domain_conf.c:12303)
      ==21905==    by 0x4CFB46E: virDomainDefParseNode (domain_conf.c:13031)
      ==21905==    by 0x4CFB5E9: virDomainDefParse (domain_conf.c:12973)
      ==21905==    by 0x41E9D8: testCompareXMLToXMLFiles (qemuxml2xmltest.c:40)
      ==21905==    by 0x41EBAA: testCompareXMLToXMLHelper (qemuxml2xmltest.c:93)
      ==21905==    by 0x421D21: virtTestRun (testutils.c:199)
      ==21905==    by 0x41FCE9: mymain.part.0 (qemuxml2xmltest.c:244)
      ==21905==    by 0x42249D: virtTestMain (testutils.c:782)
      ==21905==
      ... and 7 more
      24b3fcf9
    • M
      virsh: Prohibit virConnectOpen* functions in virsh · b0cf7d64
      Martin Kletzander 提交于
      Addition of vshConnect() makes virConnectOpen() functions obsolete in
      virsh.  Thus all virsh-*.[ch] files should be left only with
      vshConnect() in the case of need.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      b0cf7d64
    • M
      virsh: Add keepalive in new vshConnect function · 676cb4f4
      Martin Kletzander 提交于
      Introducing keepalive similarly to Guannan around 2 years ago.  Since
      we want to introduce keepalive for every connection, it makes sense to
      wrap the connecting function into new virsh one that can deal
      keepalive as well.
      
      Function vshConnect() is now used for connecting and keepalive added
      in that function (if possible) helps preventing long waits e.g. while
      nework goes down during migration.
      
      This patch also adds the options for keepalive tuning into virsh and
      fails connecting only when keepalives are explicitly requested and
      cannot be set (whether it is due to missing support in connected
      driver or remote server).  If not explicitely requested, a debug
      message is printed (hence the addition to virsh-optparse test).
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1073506
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=822839Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      676cb4f4
    • F
      virt-aa-helper: handle 9pfs · 29ea8a9b
      Felix Geyer 提交于
      Make virt-aa-helper create rules to allow VMs access to filesystem
      mounts from the host.
      Signed-off-by: NFelix Geyer <debfx@fobos.de>
      Signed-off-by: NHiroshi Miura <miurahr@linux.com>
      Signed-off-by: NSerge Hallyn <serge.hallyn@ubuntu.com>
      Signed-off-by: NGuido Günther <agx@sigxcpu.org>
      29ea8a9b
    • N
      Fix memory leak in virDomainSnapshotDiskDefClear() · 7d949aa9
      Nehal J Wani 提交于
      While running domainsnapshotxml2xmltest, it was found that valgrind pointed out
      the following memory leak:
      
      ==32176== 42 (32 direct, 10 indirect) bytes in 1 blocks are definitely lost in loss record 42 of 66
      ==32176==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
      ==32176==    by 0x4A06B62: realloc (vg_replace_malloc.c:662)
      ==32176==    by 0x4C65A07: virReallocN (viralloc.c:243)
      ==32176==    by 0x4C65B2E: virExpandN (viralloc.c:292)
      ==32176==    by 0x4C65E30: virInsertElementsN (viralloc.c:434)
      ==32176==    by 0x4CD71F3: virDomainDiskSourceDefParse (domain_conf.c:5078)
      ==32176==    by 0x4CF6EF4: virDomainSnapshotDefParseNode (snapshot_conf.c:151)
      ==32176==    by 0x4CF7314: virDomainSnapshotDefParseString (snapshot_conf.c:410)
      ==32176==    by 0x41FB8D: testCompareXMLToXMLHelper (domainsnapshotxml2xmltest.c:100)
      ==32176==    by 0x420FD1: virtTestRun (testutils.c:199)
      ==32176==    by 0x41F859: mymain (domainsnapshotxml2xmltest.c:222)
      ==32176==    by 0x42174D: virtTestMain (testutils.c:782)
      ==32176==
      ... and one more.
      7d949aa9
    • R
      bhyve: allow to destroy only active domains · 08bd268c
      Roman Bogorodskiy 提交于
      Add a check that domain is active before attempting to destroy it.
      08bd268c
    • D
      Give virNWFilterVarCombIterNext saner semantics · ef2c4c96
      Daniel P. Berrange 提交于
      The virNWFilterVarCombIterNext method will free its
      parameter when it gets to the end of the iterator.
      This is somewhat misleading design, making it appear
      as if the caller has a memory leak. Remove the free'ing
      of the parameter and ensure that the calling method
      ebiptablesCreateRuleInstanceIterate free's it instead.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      ef2c4c96
    • D
      Fix leak on OOM when creating nwfilter rule instances · 9f7da130
      Daniel P. Berrange 提交于
      The ebiptablesAddRuleInst method would leak an instance
      of ebiptablesRuleInstPtr if it hit OOM when adding it
      to the list of instances. Remove the pointless helper
      method virNWFilterRuleInstAddData and just inline the
      call to VIR_APPEND_ELEMENT and free the instance on
      failure.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      9f7da130
    • D
      Avoid warning message from libxl driver on non-Xen kernels · e23ca83a
      Daniel P. Berrange 提交于
      The libxl driver reads /proc/xen/capabilities to see if it
      is on a Dom0 kernel. If that file does not even exist though,
      an error is logged. Check for the file existance before trying
      to read its contents to avoid the log message.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e23ca83a
    • R
      bhyve: fix hostbridge device command generation · e8bb1adf
      Roman Bogorodskiy 提交于
      Addition of the hostbridge device was mistakenly placed to
      bhyveBuildNetArgStr(). This could result in hostbridge device not being
      added to the commandline if there are no network devices specified, but
      hostbridge device should be added unconditionally.
      
      Fix by placing it to virBhyveProcessBuildBhyveCmd().
      e8bb1adf
    • R
      bhyve: add support for virtio block devices · 7fcb6d05
      Roman Bogorodskiy 提交于
      7fcb6d05
    • P
      0e56aac5
    • M
      daemon: Introduce max_anonymous_clients · 68f60f66
      Michal Privoznik 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=992980
      
      This config tunable allows users to determine the maximum number of
      accepted but yet not authenticated users.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      68f60f66
    • M
      virNetServer: Introduce unauth clients counter · 4015396b
      Michal Privoznik 提交于
      The counter gets incremented on each unauthenticated client added to the
      server and decremented whenever the client authenticates.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      4015396b
    • M
      datatypes: Fix comments · 030cbd63
      Michael Chapman 提交于
      - As of commit 2ff4c137, all virGet*() functions in datatypes.c always
        return pointers to new objects. Objects are not cached in a
        per-connection hashtable.
      
      - Fix variable names in comments for all vir*Dispose() functions in
        datatypes.c.
      
      - Add comments for virGetStream(), virStreamDispose(),
        virGetDomainSnapshot(), virDomainSnapshotDispose().
      Signed-off-by: NMichael Chapman <mike@very.puzzling.org>
      030cbd63
    • R
      bhyve: implement nodeGetInfo() · 41d92462
      Roman Bogorodskiy 提交于
      Add bhyveNodeGetInfo() which is a simple wrapper around nodeGetInfo()
      from src/nodeinfo.c.
      41d92462
    • N
      Add parameter to wait for lock in file locking APIs · 2250a2b5
      Nehal J Wani 提交于
      Our current pidfile acquire APis (virPidFileAcquire) simply return -1 upon
      failure to acquire a lock. This patch adds a parameter 'bool waitForLock'
      which instructs the APIs if we want to make it block and wait for the lock
      or not.
      2250a2b5
  3. 17 3月, 2014 3 次提交
    • D
      Fix mistakes in checking return values · cb873e9d
      Daniel P. Berrange 提交于
      Thre was a syntax error in checking virRegisterStateDriver in
      the remote driver, and bogus checking of a void return type
      of virDomainConfNWFilterRegister in nwfilter.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      cb873e9d
    • M
      spec: move some dirs into appropriate subpackages · 9add02a0
      Michael Chapman 提交于
      This commit moves a few directories into more appropriate subpackages.
      In a few cases a directory is owned by two subpackages, however this is
      OK as long as the permissions and ownership for the directory are
      consistent between them.
      
      - %{_sysconfdir}/libvirt/qemu/
      
        Used by the qemu and network drivers.
      
        When building with separate driver modules, this directory is only
        owned by l-d-d-network. l-d-d-qemu has a hard dependency on
        l-d-d-network, which means this directory is created with the
        correct permissions and ownership, however it's clearer if both
        subpackages own the directory independently.
      
      - %{_sysconfdir}/libvirt/nwfilter/
      
        Used by the nwfilter driver only.
      
        This directory is currently always owned by libvirt-daemon. This
        commit moves it into l-d-d-nwfilter when building with separate
        driver modules.
      
      - %{_localstatedir}/run/libvirt/network/
      
        Used by the network and nwfilter drivers.
      
        When building without separate driver modules, this directory is
        should be owned by libvirt-daemon only if either of these drivers
        are enabled. When building with separate driver modules, this
        directory should be owned by l-d-d-nwfilter in addition to
        l-d-d-network.
      
      - %{_datadir}/libvirt/networks/ and
        %{_datadir}/libvirt/networks/default.xml
      
        Used only by the %post scriptlet in libvirt-daemon-config-network.
      Signed-off-by: NMichael Chapman <mike@very.puzzling.org>
      9add02a0
    • P
      Fix issue found by coverity and cleanup · b396fae9
      Pavel Hrdina 提交于
      Coverity found an issue in lxc_driver and uml_driver that we don't
      check the return value of register functions.
      
      I've also updated all other places and unify the way we check the
      return value.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      b396fae9
  4. 15 3月, 2014 2 次提交
    • C
      XMLToNative: Parse XML as INACTIVE · fbf14e82
      Cole Robinson 提交于
      Right now we are parsing the XML as though it's live, which for example
      will choke on hardcoded XML like:
      
        <seclabel type='dynamic' model='selinux' relabel='yes'/>
      
      Erroring with:
      
        $ sudo virsh domxml-to-native qemu-argv f
        error: XML error: security label is missing
      
      All drivers are fixed, but only qemu was tested.
      fbf14e82
    • C
      qemu: XMLToNative: Don't open vhostfd · 3b79321a
      Cole Robinson 提交于
      Just skip the vhost command line generation, since this won't work if
      attempting to run manually.
      3b79321a