1. 15 1月, 2014 1 次提交
    • P
      Fix coverity complain in commandtest.c · ab8692b6
      Pavel Hrdina 提交于
      For a "newfd1" the coverity tools thinks that the fd is closed in
      a "virCommandPassFD", but with "flags == 0" it cannot be closed.
      
      The code itself is ok, but coverity tool thinks that there is
      "double_close" of the "newfd1" and to prevent showing this error
      we simply add a comment before the proper close.
      
      This has been found by coverity.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      ab8692b6
  2. 21 10月, 2013 1 次提交
  3. 08 10月, 2013 1 次提交
  4. 18 7月, 2013 1 次提交
  5. 10 7月, 2013 1 次提交
  6. 10 5月, 2013 1 次提交
  7. 07 5月, 2013 1 次提交
  8. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  9. 16 2月, 2013 1 次提交
  10. 06 2月, 2013 1 次提交
    • E
      tests: reserve more fds for commandtest · 3a9382ca
      Eric Blake 提交于
      Commit 39c77fe5 triggered random failures, depending on the platform
      and what other fds leak into the testsuite (for me, it passed on
      RHEL 6 but failed on Fedora 18).  The reason was that we were
      expecting an fd that fell outside of our reserved range.  By reserving
      a larger range, the test once again passes on all platforms.
      
      * tests/commandtest.c (mymain): Reserve enough fds.
      3a9382ca
  11. 05 2月, 2013 2 次提交
  12. 23 1月, 2013 1 次提交
  13. 21 12月, 2012 4 次提交
  14. 02 11月, 2012 1 次提交
  15. 25 9月, 2012 1 次提交
    • E
      tests: test previous commit · d165c54d
      Eric Blake 提交于
      Add a test to avoid virCommand regressions.
      
      * tests/commandtest.c (test8): Explicitly test env-var overrides.
      d165c54d
  16. 21 9月, 2012 1 次提交
  17. 31 8月, 2012 1 次提交
    • E
      command: shell-quote when logging commands · 54e99644
      Eric Blake 提交于
      Without this patch, logged command executions can be ambiguous if
      the command contained any shell metacharacters.  This has caused
      more than one person to attempt to patch clients to add unnecessary
      quoting, without realizing that the command itself was run with
      correct args, and only the logged output was ambiguous.
      
      * src/util/command.c (virCommandToString): Add shell escapes.
      * tests/commandtest.c (test16): Test new behavior.
      * tests/commanddata/test16.log: Update expected output.
      * tests/qemuxml2argvdata/qemuxml2argv-*.args: Likewise.
      * tests/networkxml2argvdata/*.argv: Likewise.
      54e99644
  18. 23 7月, 2012 1 次提交
    • O
      Desert the FSF address in copyright · f9ce7dad
      Osier Yang 提交于
      Per the FSF address could be changed from time to time, and GNU
      recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)
      
        You should have received a copy of the GNU General Public License
        along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
      
      This patch removes the explicit FSF address, and uses above instead
      (of course, with inserting 'Lesser' before 'General').
      
      Except a bunch of files for security driver, all others are changed
      automatically, the copyright for securify files are not complete,
      that's why to do it manually:
      
        src/security/security_selinux.h
        src/security/security_driver.h
        src/security/security_selinux.c
        src/security/security_apparmor.h
        src/security/security_apparmor.c
        src/security/security_driver.c
      f9ce7dad
  19. 05 6月, 2012 1 次提交
    • E
      command: avoid deadlock on EPIPE situation · 858c2476
      Eric Blake 提交于
      It is possible to deadlock libvirt by having a domain with XML
      longer than PIPE_BUF, and by writing a hook script that closes
      stdin early.  This is because libvirt was keeping a copy of the
      child's stdin read fd open, which means the write fd in the
      parent will never see EPIPE (remember, libvirt should always be
      run with SIGPIPE ignored, so we should never get a SIGPIPE signal).
      Since there is no error, libvirt blocks waiting for a write to
      complete, even though the only reader is also libvirt.  The
      solution is to ensure that only the child can act as a reader
      before the parent does any writes; and then dealing with the
      fallout of dealing with EPIPE.
      
      Thankfully, this is not a security hole - since the only way to
      trigger the deadlock is to install a custom hook script, anyone
      that already has privileges to install a hook script already has
      privileges to do any number of other equally disruptive things
      to libvirt; it would only be a security hole if an unprivileged
      user could install a hook script to DoS a privileged user.
      
      * src/util/command.c (virCommandRun): Close parent's copy of child
      read fd earlier.
      (virCommandProcessIO): Don't let EPIPE be fatal; the child may
      be done parsing input.
      * tests/commandhelper.c (main): Set up a SIGPIPE situation.
      * tests/commandtest.c (test20): Trigger it.
      * tests/commanddata/test20.log: New file.
      858c2476
  20. 28 4月, 2012 1 次提交
    • S
      More coverity findings addressed · 59b935f5
      Stefan Berger 提交于
      More bug extermination in the category of:
      
      Error: CHECKED_RETURN:
      
      /libvirt/src/conf/network_conf.c:595:
      check_return: Calling function "virAsprintf" without checking return value (as is done elsewhere 515 out of 543 times).
      
      /libvirt/src/qemu/qemu_process.c:2780:
      unchecked_value: No check of the return value of "virAsprintf(&msg, "was paused (%s)", virDomainPausedReasonTypeToString(reason))".
      
      /libvirt/tests/commandtest.c:809:
      check_return: Calling function "setsid" without checking return value (as is done elsewhere 4 out of 5 times).
      
      /libvirt/tests/commandtest.c:830:
      unchecked_value: No check of the return value of "virTestGetDebug()".
      
      /libvirt/tests/commandtest.c:831:
      check_return: Calling function "virTestGetVerbose" without checking return value (as is done elsewhere 41 out of 42 times).
      
      /libvirt/tests/commandtest.c:833:
      check_return: Calling function "virInitialize" without checking return value (as is done elsewhere 18 out of 21 times).
      
      
      One note about the error in commandtest line 809: setsid() seems to fail when running the test -- could be removed ?
      59b935f5
  21. 27 3月, 2012 1 次提交
    • M
      Cleanup for a return statement in source files · 9943276f
      Martin Kletzander 提交于
      Return statements with parameter enclosed in parentheses were modified
      and parentheses were removed. The whole change was scripted, here is how:
      
      List of files was obtained using this command:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$'
      
      Found files were modified with this command:
      sed -i -e                                                                 \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      
      Then checked for nonsense.
      
      The whole command looks like this:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e                            \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      9943276f
  22. 04 2月, 2012 1 次提交
    • E
      command: allow merging stdout and stderr in string capture · c9ace552
      Eric Blake 提交于
      Sometimes, its easier to run children with 2>&1 in shell notation,
      and just deal with stdout and stderr interleaved.  This was already
      possible for fd handling; extend it to also work when doing string
      capture of a child process.
      
      * docs/internals/command.html.in: Document this.
      * src/util/command.c (virCommandSetErrorBuffer): Likewise.
      (virCommandRun, virExecWithHook): Implement it.
      * tests/commandtest.c (test14): Test it.
      * daemon/remote.c (remoteDispatchAuthPolkit): Use new command
      feature.
      c9ace552
  23. 28 1月, 2012 1 次提交
    • E
      tests: fix reversed comparisons · b2e13f9c
      Eric Blake 提交于
      Otherwise, a failed test gives misleading output.
      
      * tests/commandtest.c (test13, test14, test16): Pass arguments in
      correct order.
      b2e13f9c
  24. 07 1月, 2012 1 次提交
    • E
      tests: avoid test failure on rawhide gnutls · 74ff5750
      Eric Blake 提交于
      I hit a VERY weird testsuite failure on rawhide, which included
      _binary_ output to stderr, followed by a hang waiting for me
      to type something! (Here, using ^@ for NUL):
      
      $ ./commandtest
      TEST: commandtest
            WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
      .WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
      .WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
      WARNING: gnome-keyring:: couldn't send data: Bad file descriptor
      .8^@^@^@8^@^@^@^A^@^@^@^Bay^A^@^@^@)PRIVATE-GNOME-KEYRING-PKCS11-PROTOCOL-V-1
      
      I finally traced it to the fact that gnome-keyring, called via
      gnutls_global_init which is turn called by virNetTLSInit, opens
      an internal fd that it expects to communicate to via a
      pthread_atfork handler (never mind that it violates POSIX by
      using non-async-signal-safe functions in that handler:
      https://bugzilla.redhat.com/show_bug.cgi?id=772320).
      
      Our problem stems from the fact that we pulled the rug out from
      under the library's expectations by closing an fd that it had
      just opened.  While we aren't responsible for fixing the bugs
      in that pthread_atfork handler, we can at least avoid the bugs
      by not closing the fd in the first place.
      
      * tests/commandtest.c (mymain): Avoid closing fds that were opened
      by virInitialize.
      74ff5750
  25. 04 12月, 2011 1 次提交
    • E
      command: handle empty buffer argument correctly · 2b045d39
      Eric Blake 提交于
      virBufferContentAndReset (intentionally) returns NULL for a buffer
      with no content, but it is feasible to invoke a command with an
      explicit empty string.
      
      * src/util/command.c (virCommandAddEnvBuffer): Reject empty string.
      (virCommandAddArgBuffer): Allow explicit empty argument.
      * tests/commandtest.c (test9): Test it.
      * tests/commanddata/test9.log: Adjust.
      2b045d39
  26. 25 8月, 2011 1 次提交
    • D
      Fix command test wrt gnutls initialize & fix debugging · 2d533a46
      Daniel P. Berrange 提交于
      The VIR_TEST_DEBUG and VIR_TEST_VERBOSE env vars did not work
      because we replaced 'environ' with 'newenv'. Simply calling
      virTestGetDebug/Verbose() before replacing the 'environ' ensures
      we have processed the env variables.
      
      The gnutls initialization code opens /dev/urandom and keeps that
      FD around for later use. We have code which kills off FDs 3-5
      to avoid interfereing with our test case. Move the virInitialize
      call before this point, so it kills off the gnutls /dev/urandom
      FD which is irrelevant for testing purposes
      
      * tests/commandtest.c: Fix test debugging & make it robust against
        opened FDs
      2d533a46
  27. 13 8月, 2011 1 次提交
    • E
      build: fix recent build failures · be427e8b
      Eric Blake 提交于
      With gcc 4.5.1:
      
      util/virpidfile.c: In function 'virPidFileAcquirePath':
      util/virpidfile.c:308:66: error: nested extern declaration of '_gl_verify_function2' [-Wnested-externs]
      
      Then in tests/commandtest.c, the new virPidFile APIs need to be used.
      
      * src/util/virpidfile.c (virPidFileAcquirePath): Move verify to
      top level.
      * tests/commandtest.c: Use new pid APIs.
      be427e8b
  28. 29 7月, 2011 2 次提交
  29. 26 7月, 2011 1 次提交
    • L
      util: change virFile*Pid functions to return < 0 on failure · d6354c16
      Laine Stump 提交于
      Although most functions in libvirt return 0 on success and < 0 on
      failure, there are a few functions lingering around that return errno
      (a positive value) on failure, and sometimes code calling those
      functions incorrectly assumes the <0 standard. I noticed one of these
      the other day when auditing networkStartDhcpDaemon after Guido Gunther
      found a place where success was improperly returned on failure (that
      patch has been acked and is pending a push). The problem was that it
      expected the return value from virFileReadPid to be < 0 on failure,
      but it was actually positive (it was also neglected to set the return
      code in this case, similar to the bug found by Guido).
      
      This all led to the fact that *all* of the virFile*Pid functions in
      util.c are returning errno on failure. This patch remedies that
      problem by changing them all to return -errno on failure, and makes
      any necessary changes to callers of the functions. (In the meantime, I
      also properly set the return code on failure of virFileReadPid in
      networkStartDhcpDaemon).
      d6354c16
  30. 22 7月, 2011 1 次提交
    • E
      build: rename files.h to virfile.h · 8e22e089
      Eric Blake 提交于
      In preparation for a future patch adding new virFile APIs.
      
      * src/util/files.h, src/util/files.c: Move...
      * src/util/virfile.h, src/util/virfile.c: ...here, and rename
      functions to virFile prefix.  Macro names are intentionally
      left alone.
      * *.c: All '#include "files.h"' uses changed.
      * src/Makefile.am (UTIL_SOURCES): Reflect rename.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
      * src/libvirt_private.syms: Likewise.
      * docs/hacking.html.in: Likewise.
      * HACKING: Regenerate.
      8e22e089
  31. 11 5月, 2011 1 次提交
    • E
      tests: avoid crash when run under gcov · 70ea7dec
      Eric Blake 提交于
      Running ./autobuild.sh failed when gcov is installed, because
      commandtest ended up crashing during gcov's getenv() call after
      exit() had already started.  I traced this nasty bug back to
      a scoping issue present since the test introduction.
      
      * tests/commandtest.c (mymain): Move newenv...
      (newenv): ...to a scope that is still useful during exit().
      70ea7dec
  32. 04 5月, 2011 1 次提交
  33. 30 4月, 2011 2 次提交
    • E
      build: fix getcwd portability problems · e39c46a5
      Eric Blake 提交于
      * bootstrap.conf (gnulib_modules): Add getcwd-lgpl.
      * tests/commandtest.c (checkoutput): Drop unused cwd.
      * tests/commandhelper.c (main): Let getcwd malloc.
      * tests/testutils.c (virTestMain): Likewise.
      * tools/virsh.c (cmdPwd): Likewise.
      (virshCmds): Expose cmdPwd and cmdCd on mingw.
      e39c46a5
    • E
      tests: simplify common setup · 20986e58
      Eric Blake 提交于
      A few of the tests were missing basic sanity checks, while most
      of them were doing copy-and-paste initialization (in fact, some
      of them pasted the argc > 1 check more than once!).  It's much
      nicer to do things in one common place, and minimizes the size of
      the next patch that fixes getcwd usage.
      
      * tests/testutils.h (EXIT_AM_HARDFAIL): New define.
      (progname, abs_srcdir): Define for all tests.
      (VIRT_TEST_MAIN): Change callback signature.
      * tests/testutils.c (virtTestMain): Do more common init.
      * tests/commandtest.c (mymain): Simplify.
      * tests/cputest.c (mymain): Likewise.
      * tests/esxutilstest.c (mymain): Likewise.
      * tests/eventtest.c (mymain): Likewise.
      * tests/hashtest.c (mymain): Likewise.
      * tests/networkxml2xmltest.c (mymain): Likewise.
      * tests/nodedevxml2xmltest.c (myname): Likewise.
      * tests/nodeinfotest.c (mymain): Likewise.
      * tests/nwfilterxml2xmltest.c (mymain): Likewise.
      * tests/qemuargv2xmltest.c (mymain): Likewise.
      * tests/qemuhelptest.c (mymain): Likewise.
      * tests/qemuxml2argvtest.c (mymain): Likewise.
      * tests/qemuxml2xmltest.c (mymain): Likewise.
      * tests/qparamtest.c (mymain): Likewise.
      * tests/sexpr2xmltest.c (mymain): Likewise.
      * tests/sockettest.c (mymain): Likewise.
      * tests/statstest.c (mymain): Likewise.
      * tests/storagepoolxml2xmltest.c (mymain): Likewise.
      * tests/storagevolxml2xmltest.c (mymain): Likewise.
      * tests/virbuftest.c (mymain): Likewise.
      * tests/virshtest.c (mymain): Likewise.
      * tests/vmx2xmltest.c (mymain): Likewise.
      * tests/xencapstest.c (mymain): Likewise.
      * tests/xmconfigtest.c (mymain): Likewise.
      * tests/xml2sexprtest.c (mymain): Likewise.
      * tests/xml2vmxtest.c (mymain): Likewise.
      20986e58
  34. 25 3月, 2011 1 次提交
    • E
      command: add virCommandAbort for cleanup paths · 9ed54518
      Eric Blake 提交于
      Sometimes, an asynchronous helper is started (such as a compressor
      or iohelper program), but a later error means that we want to
      abort that child.  Make this easier.
      
      Note that since daemons and virCommandRunAsync can't mix, the only
      time virCommandFree can reap a process is if someone did
      virCommandRunAsync for a non-daemon and didn't stash the pid.
      
      * src/util/command.h (virCommandAbort): New prototype.
      * src/util/command.c (_virCommand): Add new field.
      (virCommandRunAsync, virCommandWait): Track whether pid was used.
      (virCommandFree): Reap child if caller did not request pid.
      (virCommandAbort): New function.
      * src/libvirt_private.syms (command.h): Export it.
      * tests/commandtest.c (test19): New test.
      9ed54518