1. 12 8月, 2014 1 次提交
    • G
      Include param.h in case of HAVE_BSD_CPU_AFFINITY · 712374d1
      Guido Günther 提交于
      This fixes compilation on kFreeBSD which otherwise fails like
      
        CC       util/libvirt_util_la-virprocess.lo
      In file included from /usr/include/sys/cpuset.h:35:0,
                       from util/virprocess.c:43:
      /usr/include/sys/_cpuset.h:49:43: error: 'NBBY' undeclared here (not in
      a function)
        long __bits[howmany(CPU_SETSIZE, _NCPUBITS)];
                                                 ^
      In file included from util/virprocess.c:43:0:
      /usr/include/sys/cpuset.h:215:12: error: unknown type name 'cpusetid_t'
       int cpuset(cpusetid_t *);
                  ^
      /usr/include/sys/cpuset.h:216:30: error: expected ')' before 'id_t'
       int cpuset_setid(cpuwhich_t, id_t, cpusetid_t);
                                    ^
      /usr/include/sys/cpuset.h:217:42: error: expected ')' before 'id_t'
       int cpuset_getid(cpulevel_t, cpuwhich_t, id_t, cpusetid_t *);
                                                ^
      /usr/include/sys/cpuset.h:218:48: error: expected ')' before 'id_t'
       int cpuset_getaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, cpuset_t
      *);
                                                      ^
      /usr/include/sys/cpuset.h:219:48: error: expected ')' before 'id_t'
       int cpuset_setaffinity(cpulevel_t, cpuwhich_t, id_t, size_t, const
      cpuset_t *);
      
      And it's the correct usage as documented in
      
        http://www.freebsd.org/cgi/man.cgi?query=cpuset_setid
      
      Also change the #ifdef HAVE_BSH_CPU_AFFINITY to #if for consistency.
      712374d1
  2. 27 3月, 2014 1 次提交
  3. 25 3月, 2014 1 次提交
  4. 18 3月, 2014 1 次提交
  5. 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 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
      util: preserve exit status from mount namespace callback · 8b24a803
      Eric Blake 提交于
      The documentation of namespace callbacks was inconsistent on whether
      it preserved positive return values.  Now that we have a dedicated
      EXIT_CANCELED to flag all errors before getting to the callback,
      it is possible to use positive return values (not that any of the
      current callers do, but it is better to match the docs).
      
      Also, while vircommand.c is careful to close fds that a child should
      not have, it's still better to be in the practice of setting
      FD_CLOEXEC up front.
      
      * src/util/virprocess.c (virProcessRunInMountNamespace): Tweak
      return value to pass back non-zero status.  Avoid leaking pipe fds
      to other threads.
      * src/util/virprocess.h: Fix comment.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      8b24a803
    • E
      util: make it easier to reflect child exit status · 2b4f162e
      Eric Blake 提交于
      Thanks to namespaces, we have a couple of places in the code
      base that want to reflect a child exit status, including the
      ability to detect death by a signal, back to a grandparent.
      Best to make it a reusable function.
      
      * src/util/virprocess.h (virProcessExitWithStatus): New prototype.
      * src/libvirt_private.syms (util/virprocess.h): Export it.
      * src/util/virprocess.c (virProcessExitWithStatus): New function.
      * tests/commandtest.c (test23): Test it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2b4f162e
  6. 18 2月, 2014 1 次提交
  7. 30 1月, 2014 1 次提交
  8. 28 1月, 2014 1 次提交
    • R
      BSD: implement virProcess{Get,Set}Affinity · c022fbc9
      Roman Bogorodskiy 提交于
      Implement virProcess{Get,Set}Affinity() using cpuset_getaffinity()
      and cpuset_setaffinity() calls. Quick search showed that they are
      only available on FreeBSD, so placed it inside existing #ifdef
      blocks for FreeBSD instead of adding configure checks.
      c022fbc9
  9. 11 7月, 2013 1 次提交
  10. 10 7月, 2013 1 次提交
  11. 08 6月, 2013 1 次提交
    • R
      Fix ordering of file open in virProcessGetNamespaces · 68eea850
      Richard Weinberger 提交于
      virProcessGetNamespaces() opens files in /proc/XXX/ns/ which will
      later be passed to setns(). We have to make sure that the file
      descriptors in the array are in the correct order. In particular
      the 'user' namespace must be first otherwise setns() may fail
      for other namespaces.
      
      The order has been taken from util-linux's sys-utils/nsenter.c
      
      Also we must ignore EINVAL in setns() which occurs if the
      namespace associated with the fd, matches the calling process'
      current namespace.
      Signed-off-by: NRichard Weinberger <richard@nod.at>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      68eea850
  12. 21 5月, 2013 1 次提交
  13. 17 5月, 2013 1 次提交
    • G
      qemu: report useful error failling to destroy domain gracefully · 6459af6a
      Guannan Ren 提交于
      Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=927620
      
       #kill -STOP `pidof qemu-kvm`
       #virsh destroy $guest --graceful
       error: Failed to destroy domain testVM
       error: An error occurred, but the cause is unknown
      
      With --graceful, SIGTERM always is emitted to kill driver
      process, but it won't success till burning out waiting time
      in case of process being stopped.
      But domain destroy without --graceful can work, SIGKILL will
      be emitted to the stopped process after 10 secs which always
      kills a process even one that is currently stopped.
      So report an error after burning out waiting time in this case.
      6459af6a
  14. 08 5月, 2013 1 次提交
  15. 03 5月, 2013 1 次提交
    • E
      build: fix mingw build of virprocess.c · 05f79a38
      Eric Blake 提交于
      Commit 776d49f4 added a static function that is only called
      conditionally; leading to this compile error on mingw:
      
        CC       libvirt_util_la-virprocess.lo
      ../../src/util/virprocess.c:624:26: error: 'struct rlimit' declared inside parameter list [-Werror]
      ../../src/util/virprocess.c:624:26: error: its scope is only this definition or declaration, which is probably not what you want [-Werror]
      ../../src/util/virprocess.c:622:1: error: 'virProcessPrLimit' defined but not used [-Werror=unused-function]
      
      * src/util/virprocess.c (virProcessPrLimit): Only declare
      virProcessPrLimit when used.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      05f79a38
  16. 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
  17. 26 4月, 2013 1 次提交
    • L
      util: new virCommandSetMax(MemLock|Processes|Files) · 776d49f4
      Laine Stump 提交于
      This patch adds two sets of functions:
      
      1) lower level virProcessSet*() functions that will immediately set
      the RLIMIT_MEMLOCK. RLIMIT_NPROC, or RLIMIT_NOFILE of either the
      current process (using setrlimit()) or any other process (using
      prlimit()). "current process" is indicated by passing a 0 for pid.
      
      2) functions for virCommand* that will setup a virCommand object to
      set those limits at a later time just after it has forked a new
      process, but before it execs the new program.
      
      configure.ac has prlimit and setrlimit added to the list of functions
      to check for, and the low level functions log an "unsupported" error)
      on platforms that don't support those functions.
      776d49f4
  18. 08 1月, 2013 1 次提交
  19. 21 12月, 2012 5 次提交
  20. 01 11月, 2012 1 次提交
  21. 16 10月, 2012 2 次提交
  22. 27 9月, 2012 1 次提交
  23. 26 9月, 2012 2 次提交