1. 22 3月, 2018 1 次提交
  2. 03 11月, 2017 1 次提交
    • A
      Remove backslash alignment attempts · 3e7db8d3
      Andrea Bolognani 提交于
      Right-aligning backslashes when defining macros or using complex
      commands in Makefiles looks cute, but as soon as any changes is
      required to the code you end up with either distractingly broken
      alignment or unnecessarily big diffs where most of the changes
      are just pushing all backslashes a few characters to one side.
      
      Generated using
      
        $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
          grep -E '*\.([chx]|am|mk)$$' | \
          while read f; do \
            sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
          done
      Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
      3e7db8d3
  3. 13 10月, 2017 1 次提交
    • J
      util: Resolve resource leak · 0c691e98
      John Ferlan 提交于
      Need to free @groups in the parent on success similar to other
      APIs (virFile*) which use virGetGroupList and virFork.
      
      Reported by Coverity.
      0c691e98
  4. 10 10月, 2017 2 次提交
  5. 11 7月, 2017 1 次提交
    • C
      util: share code between virExec and virCommandExec · 0980764d
      Cédric Bosdonnat 提交于
      virCommand is a version of virExec that doesn't fork, however it is
      just calling execve and doesn't honors setting uid/gid and pwd.
      
      This commit extrac those pieces from virExec() to a virExecCommon()
      function that is called from both virExec() and virCommandExec().
      0980764d
  6. 25 11月, 2016 1 次提交
    • M
      virstring: Unify string list function names · c2a5a4e7
      Michal Privoznik 提交于
      We have couple of functions that operate over NULL terminated
      lits of strings. However, our naming sucks:
      
      virStringJoin
      virStringFreeList
      virStringFreeListCount
      virStringArrayHasString
      virStringGetFirstWithPrefix
      
      We can do better:
      
      virStringListJoin
      virStringListFree
      virStringListFreeCount
      virStringListHasString
      virStringListGetFirstWithPrefix
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      c2a5a4e7
  7. 06 9月, 2016 1 次提交
  8. 12 7月, 2016 1 次提交
  9. 18 5月, 2016 1 次提交
  10. 03 3月, 2016 1 次提交
    • M
      Drop inline keyword from some functions. · be8b536a
      Michal Privoznik 提交于
      While trying to build with -Os I've encountered some build
      failures.
      
      util/vircommand.c: In function 'virCommandAddEnvFormat':
      util/vircommand.c:1257:1: error: inlining failed in call to 'virCommandAddEnv': call is unlikely and code size would grow [-Werror=inline]
       virCommandAddEnv(virCommandPtr cmd, char *env)
       ^
      util/vircommand.c:1308:5: error: called from here [-Werror=inline]
           virCommandAddEnv(cmd, env);
           ^
      This function is big enough for the compiler to be not inlined.
      This is the error message I'm seeing:
      
      Then virDomainNumatuneNodeSpecified is exported and called from
      other places. It shouldn't be inlined then.
      
      In file included from network/bridge_driver_platform.h:30:0,
                       from network/bridge_driver_platform.c:26:
      network/bridge_driver_linux.c: In function 'networkRemoveRoutingFirewallRules':
      ./conf/network_conf.h:350:1: error: inlining failed in call to 'virNetworkDefForwardIf.constprop': call is unlikely and code size would grow [-Werror=inline]
       virNetworkDefForwardIf(const virNetworkDef *def, size_t n)
       ^
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      be8b536a
  11. 25 12月, 2015 1 次提交
  12. 24 11月, 2015 1 次提交
  13. 22 4月, 2015 2 次提交
    • R
      vircommand: fix polling in virCommandProcessIO · e34cccf7
      Roman Bogorodskiy 提交于
      When running on FreeBSD, there's a bug in virCommandProcessIO
      polling that is triggered by the commandtest.
      
      A test that triggers EPIPE in commandtest (named "test20") hungs
      forever on FreeBSD.
      
      Apparently, this happens because FreeBSD sets POLLHUP flag on revents
      when stdin in closed. And as the current implementation only checks for
      POLLOUT and POLLERR, it ends up looping forever inside
      virCommandProcessIO and not trying to do one more write() that would
      trigger EPIPE.
      
      To fix that check for the POLLHUP flag along with POLLOUT and POLLERR.
      e34cccf7
    • P
      util: command: Deduplicate code in virCommandNewArgList · 64a9d2fa
      Peter Krempa 提交于
      virCommandNewArgList can use virCommandNewVAList.
      64a9d2fa
  14. 06 3月, 2015 1 次提交
  15. 15 11月, 2014 1 次提交
  16. 03 9月, 2014 2 次提交
  17. 22 8月, 2014 2 次提交
  18. 03 7月, 2014 1 次提交
    • J
      Use virBufferCheckError everywhere we report OOM error · 92a8e72f
      Ján Tomko 提交于
      Replace:
      if (virBufferError(&buf)) {
          virBufferFreeAndReset(&buf);
          virReportOOMError();
          ...
      }
      
      with:
      if (virBufferCheckError(&buf) < 0)
          ...
      
      This should not be a functional change (unless some callers
      misused the virBuffer APIs - a different error would be reported
      then)
      92a8e72f
  19. 26 3月, 2014 5 次提交
  20. 25 3月, 2014 1 次提交
  21. 21 3月, 2014 2 次提交
  22. 19 3月, 2014 1 次提交
  23. 18 3月, 2014 1 次提交
  24. 12 3月, 2014 1 次提交
  25. 04 3月, 2014 4 次提交
    • E
      virFork: simplify semantics · 25f87817
      Eric Blake 提交于
      The old semantics of virFork() violates the priciple of good
      usability: it requires the caller to check the pid argument
      after use, *even when virFork returned -1*, in order to properly
      abort a child process that failed setup done immediately after
      fork() - that is, the caller must call _exit() in the child.
      While uses in virfile.c did this correctly, uses in 'virsh
      lxc-enter-namespace' and 'virt-login-shell' would happily return
      from the calling function in both the child and the parent,
      leading to very confusing results. [Thankfully, I found the
      problem by inspection, and can't actually trigger the double
      return on error without an LD_PRELOAD library.]
      
      It is much better if the semantics of virFork are impossible
      to abuse.  Looking at virFork(), the parent could only ever
      return -1 with a non-negative pid if it misused pthread_sigmask,
      but this never happens.  Up until this patch series, the child
      could return -1 with non-negative pid if it fails to set up
      signals correctly, but we recently fixed that to make the child
      call _exit() at that point instead of forcing the caller to do
      it.  Thus, the return value and contents of the pid argument are
      now redundant (a -1 return now happens only for failure to fork,
      a child 0 return only happens for a successful 0 pid, and a
      parent 0 return only happens for a successful non-zero pid),
      so we might as well return the pid directly rather than an
      integer of whether it succeeded or failed; this is also good
      from the interface design perspective as users are already
      familiar with fork() semantics.
      
      One last change in this patch: before returning the pid directly,
      I found cases where using virProcessWait unconditionally on a
      cleanup path of a virFork's -1 pid return would be nicer if there
      were a way to avoid it overwriting an earlier message.  While
      such paths are a bit harder to come by with my change to a direct
      pid return, I decided to keep the virProcessWait change in this
      patch.
      
      * src/util/vircommand.h (virFork): Change signature.
      * src/util/vircommand.c (virFork): Guarantee that child will only
      return on success, to simplify callers.  Return pid rather than
      status, now that the situations are always the same.
      (virExec): Adjust caller, also avoid open-coding process death.
      * src/util/virprocess.c (virProcessWait): Tweak semantics when pid
      is -1.
      (virProcessRunInMountNamespace): Adjust caller.
      * src/util/virfile.c (virFileAccessibleAs, virFileOpenForked)
      (virDirCreate): Likewise.
      * tools/virt-login-shell.c (main): Likewise.
      * tools/virsh-domain.c (cmdLxcEnterNamespace): Likewise.
      * tests/commandtest.c (test23): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      25f87817
    • E
      util: make it easier to grab only regular command exit · b9dd878f
      Eric Blake 提交于
      Auditing all callers of virCommandRun and virCommandWait that
      passed a non-NULL pointer for exit status turned up some
      interesting observations.  Many callers were merely passing
      a pointer to avoid the overall command dying, but without
      caring what the exit status was - but these callers would
      be better off treating a child death by signal as an abnormal
      exit.  Other callers were actually acting on the status, but
      not all of them remembered to filter by WIFEXITED and convert
      with WEXITSTATUS; depending on the platform, this can result
      in a status being reported as 256 times too big.  And among
      those that correctly parse the output, it gets rather verbose.
      Finally, there were the callers that explicitly checked that
      the status was 0, and gave their own message, but with fewer
      details than what virCommand gives for free.
      
      So the best idea is to move the complexity out of callers and
      into virCommand - by default, we return the actual exit status
      already cleaned through WEXITSTATUS and treat signals as a
      failed command; but the few callers that care can ask for raw
      status and act on it themselves.
      
      * src/util/vircommand.h (virCommandRawStatus): New prototype.
      * src/libvirt_private.syms (util/command.h): Export it.
      * docs/internals/command.html.in: Document it.
      * src/util/vircommand.c (virCommandRawStatus): New function.
      (virCommandWait): Adjust semantics.
      * tests/commandtest.c (test1): Test it.
      * daemon/remote.c (remoteDispatchAuthPolkit): Adjust callers.
      * src/access/viraccessdriverpolkit.c (virAccessDriverPolkitCheck):
      Likewise.
      * src/fdstream.c (virFDStreamCloseInt): Likewise.
      * src/lxc/lxc_process.c (virLXCProcessStart): Likewise.
      * src/qemu/qemu_command.c (qemuCreateInBridgePortWithHelper):
      Likewise.
      * src/xen/xen_driver.c (xenUnifiedXendProbe): Simplify.
      * tests/reconnect.c (mymain): Likewise.
      * tests/statstest.c (mymain): Likewise.
      * src/bhyve/bhyve_process.c (virBhyveProcessStart)
      (virBhyveProcessStop): Don't overwrite virCommand error.
      * src/libvirt.c (virConnectAuthGainPolkit): Likewise.
      * src/openvz/openvz_driver.c (openvzDomainGetBarrierLimit)
      (openvzDomainSetBarrierLimit): Likewise.
      * src/util/virebtables.c (virEbTablesOnceInit): Likewise.
      * src/util/viriptables.c (virIpTablesOnceInit): Likewise.
      * src/util/virnetdevveth.c (virNetDevVethCreate): Fix debug
      message.
      * src/qemu/qemu_capabilities.c (virQEMUCapsInitQMP): Add comment.
      * src/storage/storage_backend_iscsi.c
      (virStorageBackendISCSINodeUpdate): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b9dd878f
    • E
      util: make it easier to grab only regular process exit · c72e76c3
      Eric Blake 提交于
      Right now, a caller waiting for a child process either requires
      the child to have status 0, or must use WIFEXITED() and friends
      itself.  But in many cases, we want the middle ground of treating
      fatal signals as an error, and directly accessing the normal exit
      value without having to use WEXITSTATUS(), in order to easily
      detect an expected non-zero exit status.  This adds the middle
      ground to the low-level virProcessWait; the next patch will add
      it to virCommand.
      
      * src/util/virprocess.h (virProcessWait): Alter signature.
      * src/util/virprocess.c (virProcessWait): Add parameter.
      (virProcessRunInMountNamespace): Adjust caller.
      * src/util/vircommand.c (virCommandWait): Likewise.
      * src/util/virfile.c (virFileAccessibleAs): Likewise.
      * src/lxc/lxc_container.c (lxcContainerHasReboot)
      (lxcContainerAvailable): Likewise.
      * daemon/libvirtd.c (daemonForkIntoBackground): Likewise.
      * tools/virt-login-shell.c (main): Likewise.
      * tools/virsh-domain.c (cmdLxcEnterNamespace): Likewise.
      * tests/testutils.c (virtTestCaptureProgramOutput): Likewise.
      * tests/commandtest.c (test23): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c72e76c3
    • E
      virFork: give specific status on failure prior to exec · 631923e7
      Eric Blake 提交于
      When a child fails without exec'ing, we want a well-known status;
      best is to match what env(1), nice(1), su(1), and other wrapper
      programs do.  This patch adds enum values that later patches will
      use, and sets up virFork as the first client of EXIT_CANCELED
      for errors detected prior to even attempting exec, as well as
      virExec to distinguish between a missing executable vs. a binary
      that cannot be executed.
      
      This is a slight semantic change in the unlikely case of a child
      process failing to restore its signal mask - we now kill the
      child with a known status instead of relying on the caller to
      notice and do an appropriate _exit().  A subsequent patch will
      make further cleanups based on an audit of all callers.
      
      * src/internal.h (EXIT_CANCELED, EXIT_CANNOT_INVOKE)
      (EXIT_ENOENT): New enum.
      * src/util/vircommand.c (virFork): Document specific exit value if
      child aborts early.
      (virExec): Distinguish between various exec failures.
      * tests/commandtest.c (test1): Enhance test.
      (test22): New test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      631923e7
  26. 30 1月, 2014 1 次提交
    • M
      virCommand: Introduce virCommandSetDryRun · 550a2cef
      Michal Privoznik 提交于
      There are some units within libvirt that utilize virCommand API to run
      some commands and deserve own unit testing. These units are, however,
      not desired to be rewritten to dig virCommand API usage out. As a great
      example virNetDevBandwidth could be used. The problem with the bandwidth
      unit is: it uses virCommand API heavily. Therefore we need a mechanism
      to not really run a command, but rather see its string representation
      after which we can decide if the unit construct the correct sequence of
      commands or not.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      550a2cef
  27. 21 11月, 2013 1 次提交
    • E
      maint: fix comma style issues: util · c7c84fa5
      Eric Blake 提交于
      Most of our code base uses space after comma but not before;
      fix the remaining uses before adding a syntax check.
      
      * src/util/vircommand.c: Consistently use commas.
      * src/util/virlog.c: Likewise.
      * src/util/virnetdevbandwidth.c: Likewise.
      * src/util/virnetdevmacvlan.c: Likewise.
      * src/util/virnetdevvportprofile.c: Likewise.
      * src/util/virnetlink.c: Likewise.
      * src/util/virpci.c: Likewise.
      * src/util/virsysinfo.c: Likewise.
      * src/util/virusb.c: Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c7c84fa5
  28. 21 10月, 2013 1 次提交