1. 13 7月, 2017 1 次提交
    • D
      Revert "Prevent more compiler optimization of mockable functions" · 407a281a
      Daniel P. Berrange 提交于
      This reverts commit e4b980c8.
      
      When a binary links against a .a archive (as opposed to a shared library),
      any symbols which are marked as 'weak' get silently dropped. As a result
      when the binary later runs, those 'weak' functions have an address of
      0x0 and thus crash when run.
      
      This happened with virtlogd and virtlockd because they don't link to
      libvirt.so, but instead just libvirt_util.a and libvirt_rpc.a. The
      virRandomBits symbols was weak and so left out of the virtlogd &
      virtlockd binaries, despite being required by virHashTable functions.
      
      Various other binaries like libvirt_lxc, libvirt_iohelper, etc also
      link directly to .a files instead of libvirt.so, so are potentially
      at risk of dropping symbols leading to a later runtime crash.
      
      This is normal linker behaviour because a weak symbol is not treated
      as undefined, so nothing forces it to be pulled in from the .a You
      have to force the linker to pull in weak symbols using -u$SYMNAME
      which is not a practical approach.
      
      This risk is silent bad linkage that affects runtime behaviour is
      not acceptable for a fix that was merely trying to fix the test
      suite. So stop using __weak__ again.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      407a281a
  2. 11 7月, 2017 1 次提交
    • D
      Prevent more compiler optimization of mockable functions · e4b980c8
      Daniel P. Berrange 提交于
      Currently all mockable functions are annotated with the 'noinline'
      attribute. This is insufficient to guarantee that a function can
      be reliably mocked with an LD_PRELOAD. The C language spec allows
      the compiler to assume there is only a single implementation of
      each function. It can thus do things like propagating constant
      return values into the caller at compile time, or creating
      multiple specialized copies of the function body each optimized
      for a different caller. To prevent these optimizations we must
      also set the 'noclone' and 'weak' attributes.
      
      This fixes the test suite when libvirt.so is built with CLang
      with optimization enabled.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e4b980c8
  3. 22 6月, 2017 1 次提交
  4. 19 4月, 2017 1 次提交
    • D
      annotate all mocked functions with noinline · 728cacc8
      Daniel P. Berrange 提交于
      CLang's optimizer is more aggressive at inlining functions than
      gcc and so will often inline functions that our tests want to
      mock-override. This causes the test to fail in bizarre ways.
      
      We don't want to disable inlining completely, but we must at
      least prevent inlining of mocked functions. Fortunately there
      is a 'noinline' attribute that lets us control this per function.
      
      A syntax check rule is added that parses tests/*mock.c to extract
      the list of functions that are mocked (restricted to names starting
      with 'vir' prefix). It then checks that src/*.h header file to
      ensure it has a 'ATTRIBUTE_NOINLINE' annotation. This should prevent
      use from bit-rotting in future.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      728cacc8
  5. 16 3月, 2017 1 次提交
    • J
      util: Rename virFileWaitForDevices · 97e0d3c3
      John Ferlan 提交于
      The function is actually in virutil.c, but prototyped in virfile.h.
      This patch fixes that by renaming the function to virWaitForDevices,
      adding the prototype in virutil.h and libvirt_private.syms, and then
      changing the callers to use the new name.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      97e0d3c3
  6. 19 2月, 2017 2 次提交
    • J
      util: Move scsi_host specific functions from virutil · 03346def
      John Ferlan 提交于
      Create a virscsihost.c and place the functions there. That removes the
      last #ifdef __linux__ from virutil.c.
      
      Take the opporunity to also change the function names and in one case
      the parameters slightly
      03346def
    • J
      util: Create a new virvhba module and move/rename API's · 16416816
      John Ferlan 提交于
      Rather than have them mixed in with the virutil apis, create a separate
      virvhba.c module and move the vHBA related calls into there. Soon there
      will be more added.
      
      Also modify the names of the functions and some arguments to be more
      indicative of what is really happening. Adjust the callers respectively.
      
      While I was changing fchosttest, rather than the non-descriptive names
      test1...test6, rename them to match what the test is doing.
      16416816
  7. 07 1月, 2017 1 次提交
  8. 14 10月, 2016 1 次提交
    • J
      util: Alter return value of virReadFCHost and fix mem leak · f29b13f8
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1357416
      
      Rather than return a 0 or -1 and the *result string, return just the result
      string to the caller.  Alter all the callers to handle the different return.
      
      As a side effect or result of this, it's much clearer that we cannot just
      assign the returned string into the scsi_host wwnn, wwpn, and fabric_wwn
      fields - rather we should fetch a temporary string, then as long as our
      fetch was good, VIR_FREE what may have been there, and STEAL what we just got.
      This fixes a memory leak in the virNodeDeviceCreateXML code path through
      find_new_device and nodeDeviceLookupSCSIHostByWWN which will continually
      call nodeDeviceSysfsGetSCSIHostCaps until the expected wwnn/wwpn is found
      in the device object capabilities.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      f29b13f8
  9. 10 6月, 2016 1 次提交
  10. 13 4月, 2016 1 次提交
  11. 22 2月, 2016 1 次提交
  12. 11 12月, 2015 1 次提交
    • D
      log: include hostname in initial log message · 1ce92960
      Daniel P. Berrange 提交于
      On the very first log message we send to any output, we include
      the libvirt version number and package string. In some bug reports
      we have been given libvirtd.log files that came from a different
      host than the corresponding /var/log/libvirt/qemu log files. So
      extend the initial log message to include the hostname too.
      
      eg on first log message we would now see:
      
       $ libvirtd
       2015-12-04 17:35:36.610+0000: 20917: info : libvirt version: 1.3.0
       2015-12-04 17:35:36.610+0000: 20917: info : hostname: dhcp-1-180.lcy.redhat.com
       2015-12-04 17:35:36.610+0000: 20917: error : qemuMonitorIO:687 : internal error: End of file from monitor
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      1ce92960
  13. 19 11月, 2015 1 次提交
  14. 03 6月, 2015 1 次提交
  15. 14 5月, 2015 1 次提交
  16. 02 4月, 2015 1 次提交
  17. 06 3月, 2015 2 次提交
    • P
      memtune: change the way how we store unlimited value · cf521fc8
      Pavel Hrdina 提交于
      There was a mess in the way how we store unlimited value for memory
      limits and how we handled values provided by user.  Internally there
      were two possible ways how to store unlimited value: as 0 value or as
      VIR_DOMAIN_MEMORY_PARAM_UNLIMITED.  Because we chose to store memory
      limits as unsigned long long, we cannot use -1 to represent unlimited.
      It's much easier for us to say that everything greater than
      VIR_DOMAIN_MEMORY_PARAM_UNLIMITED means unlimited and leave 0 as valid
      value despite that it makes no sense to set limit to 0.
      
      Remove unnecessary function virCompareLimitUlong.  The update of test
      is to prevent the 0 to be miss-used as unlimited in future.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1146539Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      cf521fc8
    • P
      virutil: introduce helper functions for memory limits · a73395ae
      Pavel Hrdina 提交于
      The first one is to truncate the memory limit to
      VIR_DOMAIN_MEMORY_PARAM_UNLIMITED if the value is greater and the second
      one is to decide whether the memory limit is set or not, unlimited means
      that it's not set.
      Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
      a73395ae
  18. 03 2月, 2015 1 次提交
  19. 29 10月, 2014 2 次提交
  20. 09 9月, 2014 1 次提交
  21. 22 8月, 2014 1 次提交
  22. 23 7月, 2014 2 次提交
    • J
      Introduce virTristateSwitch enum · 3227e17d
      Ján Tomko 提交于
      For the values "default", "on", "off"
      
      Replaces
      virDeviceAddressPCIMulti
      virDomainFeatureState
      virDomainIoEventFd
      virDomainVirtioEventIdx
      virDomainDiskCopyOnRead
      virDomainMemDump
      virDomainPCIRombarMode
      virDomainGraphicsSpicePlaybackCompression
      3227e17d
    • J
      Introduce virTristateBool enum type · bb018ce6
      Ján Tomko 提交于
      Replace all three-state (default/yes/no) enums with it:
      virDomainBIOSUseserial
      virDomainBootMenu
      virDomainPMState
      virDomainGraphicsSpiceClipboardCopypaste
      virDomainGraphicsSpiceAgentFileTransfer
      virNetworkDNSForwardPlainNames
      bb018ce6
  23. 22 7月, 2014 2 次提交
    • J
      scsi_host: Introduce virFindSCSIHostByPCI · ef48a1b6
      John Ferlan 提交于
      Introduce a new function to parse the provided scsi_host parent address
      and unique_id value in order to find the /sys/class/scsi_host directory
      which will allow a stable SCSI host address
      
      Add a test to scsihosttest to lookup the host# name by using the PCI address
      and unique_id value
      ef48a1b6
    • J
      virutil: Introduce virReadSCSIUniqueId · fbd91d49
      John Ferlan 提交于
      Introduce a new function to read the current scsi_host entry and return
      the value found in the 'unique_id' file.
      
      Add a 'scsihosttest' test (similar to the fchosttest, but incorporating some
      of the concepts of the mocked pci test library) in order to read the
      unique_id file like would be found in the /sys/class/scsi_host tree.
      fbd91d49
  24. 29 4月, 2014 1 次提交
  25. 21 3月, 2014 1 次提交
  26. 11 3月, 2014 1 次提交
  27. 14 1月, 2014 1 次提交
    • E
      build: fix build on mingw with winpthreads · c91d13bd
      Eric Blake 提交于
      On my Fedora 20 box with mingw cross-compiler, the build failed with:
      
      ../../src/rpc/virnetclient.c: In function 'virNetClientSetTLSSession':
      ../../src/rpc/virnetclient.c:745:14: error: unused variable 'oldmask' [-Werror=unused-variable]
           sigset_t oldmask, blockedsigs;
                    ^
      
      I traced it to the fact that mingw64-winpthreads installs a header
      that does #define pthread_sigmask(...) 0, which means any argument
      only ever passed to pthread_sigmask is reported as unused.  This
      patch works around the compilation failure, with behavior no worse
      than what mingw already gives us regarding the function being a
      no-op.
      
      * configure.ac (pthread_sigmask): Probe for broken mingw macro.
      * src/util/virutil.h (pthread_sigmask): Rewrite to something that
      avoids unused variables.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c91d13bd
  28. 21 10月, 2013 2 次提交
  29. 11 10月, 2013 1 次提交
    • B
      util: fix two virCompareLimitUlong bugs · 19e7c04d
      Bing Bu Cao 提交于
      The helper function virCompareLimitUlong compares limit values,
      where value of 0 is equal to unlimited. If the latter parameter is 0,
      it should return -1 instead of 1, hence the user can only set hard_limit when
      swap_hard_limit currently is unlimited.
      
      Worse, all callers pass 2 64-bit values, but on 32-bit platforms,
      the second argument was silently truncated to 32 bits, which
      could lead to incorrect computations.
      Signed-off-by: NBing Bu Cao <mars@linux.vnet.ibm.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      19e7c04d
  30. 31 7月, 2013 1 次提交
  31. 24 7月, 2013 1 次提交
    • M
      Expose ownership ID parsing · bba579b6
      Martin Kletzander 提交于
      Parsing 'user:group' is useful even outside the DAC security driver,
      so expose the most abstract function which has no DAC security driver
      bits in itself.
      bba579b6
  32. 12 7月, 2013 2 次提交
    • E
      util: make virSetUIDGID async-signal-safe · ee777e99
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=964358
      
      POSIX states that multi-threaded apps should not use functions
      that are not async-signal-safe between fork and exec, yet we
      were using getpwuid_r and initgroups.  Although rare, it is
      possible to hit deadlock in the child, when it tries to grab
      a mutex that was already held by another thread in the parent.
      I actually hit this deadlock when testing multiple domains
      being started in parallel with a command hook, with the following
      backtrace in the child:
      
       Thread 1 (Thread 0x7fd56bbf2700 (LWP 3212)):
       #0  __lll_lock_wait ()
           at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:136
       #1  0x00007fd5761e7388 in _L_lock_854 () from /lib64/libpthread.so.0
       #2  0x00007fd5761e7257 in __pthread_mutex_lock (mutex=0x7fd56be00360)
           at pthread_mutex_lock.c:61
       #3  0x00007fd56bbf9fc5 in _nss_files_getpwuid_r (uid=0, result=0x7fd56bbf0c70,
           buffer=0x7fd55c2a65f0 "", buflen=1024, errnop=0x7fd56bbf25b8)
           at nss_files/files-pwd.c:40
       #4  0x00007fd575aeff1d in __getpwuid_r (uid=0, resbuf=0x7fd56bbf0c70,
           buffer=0x7fd55c2a65f0 "", buflen=1024, result=0x7fd56bbf0cb0)
           at ../nss/getXXbyYY_r.c:253
       #5  0x00007fd578aebafc in virSetUIDGID (uid=0, gid=0) at util/virutil.c:1031
       #6  0x00007fd578aebf43 in virSetUIDGIDWithCaps (uid=0, gid=0, capBits=0,
           clearExistingCaps=true) at util/virutil.c:1388
       #7  0x00007fd578a9a20b in virExec (cmd=0x7fd55c231f10) at util/vircommand.c:654
       #8  0x00007fd578a9dfa2 in virCommandRunAsync (cmd=0x7fd55c231f10, pid=0x0)
           at util/vircommand.c:2247
       #9  0x00007fd578a9d74e in virCommandRun (cmd=0x7fd55c231f10, exitstatus=0x0)
           at util/vircommand.c:2100
       #10 0x00007fd56326fde5 in qemuProcessStart (conn=0x7fd53c000df0,
           driver=0x7fd55c0dc4f0, vm=0x7fd54800b100, migrateFrom=0x0, stdin_fd=-1,
           stdin_path=0x0, snapshot=0x0, vmop=VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
           flags=1) at qemu/qemu_process.c:3694
       ...
      
      The solution is to split the work of getpwuid_r/initgroups into the
      unsafe portions (getgrouplist, called pre-fork) and safe portions
      (setgroups, called post-fork).
      
      * src/util/virutil.h (virSetUIDGID, virSetUIDGIDWithCaps): Adjust
      signature.
      * src/util/virutil.c (virSetUIDGID): Add parameters.
      (virSetUIDGIDWithCaps): Adjust clients.
      * src/util/vircommand.c (virExec): Likewise.
      * src/util/virfile.c (virFileAccessibleAs, virFileOpenForked)
      (virDirCreate): Likewise.
      * src/security/security_dac.c (virSecurityDACSetProcessLabel):
      Likewise.
      * src/lxc/lxc_container.c (lxcContainerSetID): Likewise.
      * configure.ac (AC_CHECK_FUNCS_ONCE): Check for setgroups, not
      initgroups.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ee777e99
    • E
      util: add virGetGroupList · 75c12564
      Eric Blake 提交于
      Since neither getpwuid_r() nor initgroups() are safe to call in
      between fork and exec (they obtain a mutex, but if some other
      thread in the parent also held the mutex at the time of the fork,
      the child will deadlock), we have to split out the functionality
      that is unsafe.  At least glibc's initgroups() uses getgrouplist
      under the hood, so the ideal split is to expose getgrouplist for
      use before a fork.  Gnulib already gives us a nice wrapper via
      mgetgroups; we wrap it once more to look up by uid instead of name.
      
      * bootstrap.conf (gnulib_modules): Add mgetgroups.
      * src/util/virutil.h (virGetGroupList): New declaration.
      * src/util/virutil.c (virGetGroupList): New function.
      * src/libvirt_private.syms (virutil.h): Export it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      75c12564
  33. 13 5月, 2013 1 次提交