1. 17 12月, 2015 2 次提交
  2. 20 11月, 2015 1 次提交
  3. 04 11月, 2015 1 次提交
  4. 28 10月, 2015 1 次提交
  5. 27 8月, 2015 1 次提交
  6. 18 8月, 2015 1 次提交
    • E
      build: fix mingw build · 0a617b53
      Eric Blake 提交于
      Ever since commit e44b0269, 64-bit mingw compilation fails with:
      
      ../../src/util/virprocess.c: In function 'virProcessGetPids':
      ../../src/util/virprocess.c:628:50: error: passing argument 4 of 'virStrToLong_i' from incompatible pointer type [-Werror=incompatible-pointer-types]
               if (virStrToLong_i(ent->d_name, NULL, 10, &tmp_pid) < 0)
                                                        ^
      In file included from ../../src/util/virprocess.c:59:0:
      ../../src/util/virstring.h:53:5: note: expected 'int *' but argument is of type 'pid_t * {aka long long int *}'
       int virStrToLong_i(char const *s,
           ^
      cc1: all warnings being treated as errors
      
      Although mingw won't be using this function, it does compile the
      file, and the fix is relatively simple.
      
      * src/util/virprocess.c (virProcessGetPids): Don't assume pid_t
      fits in int.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      0a617b53
  7. 16 6月, 2015 2 次提交
  8. 11 6月, 2015 1 次提交
  9. 08 6月, 2015 1 次提交
    • R
      util: process: fix build on FreeBSD · 5ceb34ee
      Roman Bogorodskiy 提交于
      Commit 825df8c3 refactored virProcess{Set,Get}Affinity routines,
      however broke BSD implementation because of the incorrect variable
      name. Fix build by using a proper variable name.
      
      Pushing as trivial and build break fix.
      5ceb34ee
  10. 03 6月, 2015 1 次提交
    • P
      util: process: Refactor and fix virProcessSetAffinity · 825df8c3
      Peter Krempa 提交于
      Refactor the function to return the bitmap instead of an integer and the
      inner workings so that they make more sense.
      
      This patch also fixes possible segfault on old systems that was
      introduced by commit:
      
      commit f1a43a8e
      Author: Hu Tao <hutao@cn.fujitsu.com>
      Date:   Fri Sep 14 15:46:59 2012 +0800
      
          use virBitmap to store cpu affinity info
      825df8c3
  11. 02 6月, 2015 1 次提交
  12. 09 4月, 2015 1 次提交
  13. 23 3月, 2015 1 次提交
  14. 13 3月, 2015 1 次提交
    • J
      Introduce virBitmapIsBitSet · 22fd3ac3
      Ján Tomko 提交于
      A helper that never returns an error and treats bits out of bitmap range
      as false.
      
      Use it everywhere we use ignore_value on virBitmapGetBit, or loop over
      the bitmap size.
      22fd3ac3
  15. 13 2月, 2015 1 次提交
    • P
      virprocess: fix MinGW build and RHEL-5 build · 94cc5778
      Pavel Hrdina 提交于
      Commit b6a2828e introduced new functions to set process scheduler. There
      is a small typo in ELSE path for systems where scheduler is not
      available.
      
      Also some of the definitions were introduced later in kernel. For
      example RHEL-5 is running on kernel 2.6.18, but SCHED_IDLE was introduces
      in 2.6.23 [1] and SCHED_BATCH in 2.6.16 [1]. We should not count only on
      existence of function sched_setscheduler(), we must also check for
      existence of used macros as they might not be defined.
      
      [1] see 'man 7 sched'
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      94cc5778
  16. 12 2月, 2015 1 次提交
  17. 19 12月, 2014 1 次提交
    • D
      Don't setup fake CPU pids for old QEMU · b07f3d82
      Daniel P. Berrange 提交于
      The code assumes that def->vcpus == nvcpupids, so when we setup
      fake CPU pids for old QEMU with nvcpupids == 1, we cause the
      later code to read off the end of the array. This has fun results
      like sche_setaffinity(0, ...) which changes libvirtd's own CPU
      affinity, or even better sched_setaffinity($RANDOM, ...) which
      changes the affinity of a random OS process.
      b07f3d82
  18. 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
  19. 12 10月, 2014 1 次提交
    • M
      Fix leftover typo '&' -> '&&' · 4d2a8a0a
      Martin Kletzander 提交于
      The actual origin of this so called typo are two commits.  The first one
      was commit 72f8a7f1 that came up with the following condition:
      
      if ((i == 8) & (flags & VIR_QEMU_PROCESS_KILL_FORCE))
      
      Fortunately this succeeded thanks to bool being (int)1 and
      VIR_QEMU_PROCESS_KILL_FORCE having the value of 1 << 0.  The check was
      then moved and altered in 8fd38231 to
      current state:
      
      if ((i == 50) & force)
      
      that will work again (both sides of '&' being booleans), but since this
      was missed so many times, it may pose a problem in the future in case it
      gets copy-pasted again.
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      4d2a8a0a
  20. 02 10月, 2014 1 次提交
    • E
      build: fix build on non-Linux · 4acc03ae
      Eric Blake 提交于
      A cygwin build of 1.2.9 fails with:
      
      util/virprocess.c:87:27: fatal error: sys/syscall.h: No such file or directory
       #  include <sys/syscall.h>
      
      But in reality, the ONLY user of setns() is lxc, which is Linux-only.
      It's easiest to just limit the setns workarounds to Linux.
      
      * src/util/virprocess.c (setns): Limit definition to Linux.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4acc03ae
  21. 16 9月, 2014 1 次提交
    • M
      virprocess: Extend list of platforms for setns wrapper · 735a15a6
      Michal Privoznik 提交于
      Currently, the setns() wrapper is supported only for x86_64 and i686
      which leaves us failing to build on other platforms like arm, aarch64
      and so on. This means, that the wrapper needs to be extended to those
      platforms and make to fail on runtime not compile time.
      
      The syscall numbers for other platforms was fetched using this
      command:
      
      kernel.git $ git grep "define.*__NR_setns" | grep -e arm -e powerpc -e s390
      arch/arm/include/uapi/asm/unistd.h:#define __NR_setns                   (__NR_SYSCALL_BASE+375)
      arch/arm64/include/asm/unistd32.h:#define __NR_setns 375
      arch/powerpc/include/uapi/asm/unistd.h:#define __NR_setns               350
      arch/s390/include/uapi/asm/unistd.h:#define __NR_setns          339
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      735a15a6
  22. 11 9月, 2014 1 次提交
  23. 10 9月, 2014 2 次提交
  24. 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
  25. 27 3月, 2014 1 次提交
  26. 25 3月, 2014 1 次提交
  27. 18 3月, 2014 1 次提交
  28. 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
  29. 18 2月, 2014 1 次提交
  30. 30 1月, 2014 1 次提交
  31. 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
  32. 11 7月, 2013 1 次提交
  33. 10 7月, 2013 1 次提交
  34. 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