1. 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
  2. 29 4月, 2014 2 次提交
    • D
      Don't use SO_REUSEADDR on Win32 platforms · 37697d82
      Daniel P. Berrange 提交于
      SO_REUSEADDR on Windows is actually akin to SO_REUSEPORT
      on Linux/BSD. ie it allows 2 apps to listen to the same
      port at once. Thus we must not set it on Win32 platforms
      
      See http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspxSigned-off-by: NDaniel P. Berrange <berrange@redhat.com>
      37697d82
    • E
      util: use virDirRead API · ac1d42ac
      Eric Blake 提交于
      In making the conversion to the new API, I fixed a couple bugs:
      virSCSIDeviceGetSgName would leak memory if a directory
      unexpectedly contained multiple entries;
      virNetDevTapGetRealDeviceName could report a spurious error
      from a stale errno inherited before starting the readdir search.
      
      The decision on whether to store the result of virDirRead into
      a variable is based on whether the end of the loop falls through
      to cleanup code automatically.  In some cases, we have loops that
      are documented to return NULL on failure, and which raise an
      error on most failure paths but not in the case where the directory
      was unexpectedly empty; it may be worth a followup patch to
      explicitly report an error if readdir was successful but the
      directory was empty, so that a NULL return always has an error set.
      
      * src/util/vircgroup.c (virCgroupRemoveRecursively): Use new
      interface.
      (virCgroupKillRecursiveInternal, virCgroupSetOwner): Report
      readdir failures.
      * src/util/virfile.c (virFileLoopDeviceOpenSearch)
      (virFileNBDDeviceFindUnused, virFileDeleteTree): Use new
      interface.
      * src/util/virnetdevtap.c (virNetDevTapGetRealDeviceName):
      Properly check readdir errors.
      * src/util/virpci.c (virPCIDeviceIterDevices)
      (virPCIDeviceFileIterate, virPCIGetNetName): Report readdir
      failures.
      (virPCIDeviceAddressIOMMUGroupIterate): Use new interface.
      * src/util/virscsi.c (virSCSIDeviceGetSgName): Report readdir
      failures, and avoid memory leak.
      (virSCSIDeviceGetDevName): Report readdir failures.
      * src/util/virusb.c (virUSBDeviceSearch): Report readdir
      failures.
      * src/util/virutil.c (virGetFCHostNameByWWN)
      (virFindFCHostCapableVport): Report readdir failures.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ac1d42ac
  3. 25 3月, 2014 1 次提交
  4. 21 3月, 2014 1 次提交
  5. 18 3月, 2014 1 次提交
  6. 11 3月, 2014 1 次提交
  7. 23 1月, 2014 1 次提交
    • O
      storage: Fix the memory leak · 88ae5dc7
      Osier Yang 提交于
      The return value of virGetFCHostNameByWWN is a strdup'ed string.
      Also add comments to declare that the caller should take care of
      freeing it.
      88ae5dc7
  8. 21 10月, 2013 3 次提交
  9. 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
  10. 16 9月, 2013 1 次提交
  11. 05 9月, 2013 1 次提交
    • D
      virGet{User,Group}Ent() don't say success on fail · 4c7d1eab
      Doug Goldstein 提交于
      When virGetUserEnt() and virGetGroupEnt() fail due to the uid or gid not
      existing on the machine they'll print a message like:
      
      $ virsh -c vbox:///session list
      error: failed to connect to the hypervisor
      error: Failed to find user record for uid '32655': Success
      
      The success at the end is a bit confusing. This changes it to:
      
      $ virsh -c vbox:///session list
      error: failed to connect to the hypervisor
      error: Failed to find user record for uid '32655'
      4c7d1eab
  12. 08 8月, 2013 1 次提交
    • E
      maint: avoid C99 loop declaration · ed7e7c7d
      Eric Blake 提交于
      Commit 3d0e3c1a reintroduced a problem previously squelched in
      commit 7e5aa78d.  Add a syntax check this time around.
      
      util/virutil.c: In function 'virGetGroupList':
      util/virutil.c:1015: error: 'for' loop initial declaration used outside C99 mode
      
      * cfg.mk (sc_prohibit_loop_var_decl): New rule.
      * src/util/virutil.c (virGetGroupList): Fix offender.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ed7e7c7d
  13. 07 8月, 2013 1 次提交
    • G
      virGetGroupList: always include the primary group · 3d0e3c1a
      Guido Günther 提交于
      The change from initgroups to virGetGroupList/setgroups in
      cab36cfe71ba83b71e536ba5c98e596f02b697b0 dropped the primary group from
      processes group list iff the passed in group to virGetGroupList differs
      from the user's primary group.
      
      So always include the primary group to bring back the old behaviour.
      
      Debian has the kvm group as primary group but uses
      libvirt-qemu:libvirt-qemu as user:group to run the kvm process so
      without this change the /dev/kvm is inaccessible.
      3d0e3c1a
  14. 31 7月, 2013 1 次提交
  15. 29 7月, 2013 1 次提交
    • E
      build: fix virutil build on mingw · cd725c7a
      Eric Blake 提交于
      On platforms without decent group support, the build failed:
      
      Cannot export virGetGroupList: symbol not defined
      ./.libs/libvirt_security_manager.a(libvirt_security_manager_la-security_dac.o): In function `virSecurityDACPreFork':
      /home/eblake/libvirt-tmp/build/src/../../src/security/security_dac.c:248: undefined reference to `virGetGroupList'
      collect2: error: ld returned 1 exit status
      
      * src/util/virutil.c (virGetGroupList): Provide dummy implementation.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cd725c7a
  16. 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
  17. 12 7月, 2013 3 次提交
    • 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
    • E
      util: improve user lookup helper · c1983ba4
      Eric Blake 提交于
      A future patch needs to look up pw_gid; but it is wasteful
      to crawl through getpwuid_r twice for two separate pieces
      of information, and annoying to copy that much boilerplate
      code for doing the crawl.  The current internal-only
      virGetUserEnt is also a rather awkward interface; it's easier
      to just design it to let callers request multiple pieces of
      data as needed from one traversal.
      
      And while at it, I noticed that virGetXDGDirectory could deref
      NULL if the getpwuid_r lookup fails.
      
      * src/util/virutil.c (virGetUserEnt): Alter signature.
      (virGetUserDirectory, virGetXDGDirectory, virGetUserName): Adjust
      callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c1983ba4
  18. 11 7月, 2013 1 次提交
  19. 10 7月, 2013 1 次提交
  20. 28 6月, 2013 1 次提交
  21. 17 6月, 2013 1 次提交
  22. 06 6月, 2013 1 次提交
  23. 29 5月, 2013 1 次提交
    • E
      build: drop unused variable · 327d4db8
      Eric Blake 提交于
      Compilation for mingw failed:
      
      ../../src/util/virutil.c: In function 'virGetWin32DirectoryRoot':
      ../../src/util/virutil.c:1094:9: error: unused variable 'ret' [-Werror=unused-variable]
      
      * src/util/virutil.c (virGetWin32DirectoryRoot): Silence compiler
      warning.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      327d4db8
  24. 24 5月, 2013 1 次提交
  25. 21 5月, 2013 1 次提交
  26. 16 5月, 2013 1 次提交
  27. 13 5月, 2013 6 次提交
    • O
      util: Honor the passed sysfs_prefix · b7ab7195
      Osier Yang 提交于
      The helper works for default sysfs_prefix, but for user specified
      prefix, it doesn't work. (Detected when writing test cases. A later
      patch will add the test cases for fc_host).
      b7ab7195
    • O
      util: Update the comment for virGetFCHostNameByWWN · 1a59ae91
      Osier Yang 提交于
      The returned result is something like "host5" acutally.
      1a59ae91
    • O
      util: Change virIsCapable* to return bool · c56c273b
      Osier Yang 提交于
      Function name with "aIsB" generally means its return value is
      in Bi-state (true/false).
      c56c273b
    • O
      util: Don't miss the slash in constructed path · b595588f
      Osier Yang 提交于
      In case of the caller can pass a "prefix" (or "sysfs_prefix")
      without the trailing slash, and Unix-Like system always eats
      up the redundant "slash" in the filepath, let's add it explicitly.
      b595588f
    • O
      util: Fix regression introduced by commit 4360a098 · e106c011
      Osier Yang 提交于
      Which refactored the old code, and introduced new helper
      virIsCapableVport, but the path for checking with access() is not
      correctly constructed.
      e106c011
    • O
      util: Fix regression of wwn reading · b76284af
      Osier Yang 提交于
      Introduced by commit 244ce462, which refactored the helper for wwn
      reading, however, it forgot to change the old "strndup" and "sizeof(buf)",
      "sizeof(buf)" operates on the fixed length array ("buf") in the old code,
      but now "buf" is a pointer.
      
      Before the fix:
      
      % virsh nodedev-dumpxml scsi_host5
      <device>
        <name>scsi_host5</name>
        <parent>pci_0000_04_00_1</parent>
        <capability type='scsi_host'>
          <host>5</host>
          <capability type='fc_host'>
            <wwnn>2001001b</wwnn>
            <wwpn>2101001b</wwpn>
            <fabric_wwn>2001000d</fabric_wwn>
          </capability>
        </capability>
      </device>
      
      With the fix:
      
      % virsh nodedev-dumpxml scsi_host5
      <device>
        <name>scsi_host5</name>
        <parent>pci_0000_04_00_1</parent>
        <capability type='scsi_host'>
          <host>5</host>
          <capability type='fc_host'>
            <wwnn>0x2001001b32a9da4e</wwnn>
            <wwpn>0x2101001b32a9da4e</wwpn>
            <fabric_wwn>0x2001000dec9877c1</fabric_wwn>
          </capability>
        </capability>
      </device>
      b76284af
  28. 11 5月, 2013 2 次提交
    • E
      build: fix use of mmap · d34ef017
      Eric Blake 提交于
      Commit bfe7721d introduced a regression, but only on platforms
      like FreeBSD that lack posix_fallocate and where mmap serves as
      a nice fallback for safezero.
      
      util/virfile.c: In function 'safezero':
      util/virfile.c:837: error: 'PROT_READ' undeclared (first use in this function)
      
      * src/util/virutil.c (includes): Move use of <sys/mman.h>...
      * src/util/virfile.c (includes): ...to the file that uses mmap.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d34ef017
    • L
      util: move virFile* functions from virutil.c to virfile.c · bfe7721d
      Laine Stump 提交于
      These all existed before virfile.c was created, and for some reason
      weren't moved.
      
      This is mostly straightfoward, although the syntax rule prohibiting
      write() had to be changed to have an exception for virfile.c instead
      of virutil.c.
      
      This movement pointed out that there is a function called
      virBuildPath(), and another almost identical function called
      virFileBuildPath(). They really should be a single function, which
      I'll take care of as soon as I figure out what the arglist should look
      like.
      bfe7721d