1. 26 4月, 2013 1 次提交
    • E
      build: avoid unsafe functions in libgen.h · 1fbf1905
      Eric Blake 提交于
      POSIX says that both basename() and dirname() may return static
      storage (aka they need not be thread-safe); and that they may but
      not must modify their input argument.  Furthermore, <libgen.h>
      is not available on all platforms.  For these reasons, you should
      never use these functions in a multi-threaded library.
      
      Gnulib instead recommends a way to avoid the portability nightmare:
      gnulib's "dirname.h" provides useful thread-safe counterparts.  The
      obvious dir_name() and base_name() are GPL (because they malloc(),
      but call exit() on failure) so we can't use them; but the LGPL
      variants mdir_name() (malloc's or returns NULL) and last_component
      (always points into the incoming string without modifying it,
      differing from basename semantics only on corner cases like the
      empty string that we shouldn't be hitting in the first place) are
      already in use in libvirt.  This finishes the swap over to the safe
      functions.
      
      * cfg.mk (sc_prohibit_libgen): New rule.
      * src/util/vircgroup.c: Fix offenders.
      * src/parallels/parallels_storage.c (parallelsPoolAddByDomain):
      Likewise.
      * src/parallels/parallels_network.c (parallelsGetBridgedNetInfo):
      Likewise.
      * src/node_device/node_device_udev.c (udevProcessSCSIHost)
      (udevProcessSCSIDevice): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskDeleteVol): Likewise.
      * src/util/virpci.c (virPCIGetDeviceAddressFromSysfsLink):
      Likewise.
      * src/util/virstoragefile.h (_virStorageFileMetadata): Avoid false
      positive.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1fbf1905
  2. 24 4月, 2013 1 次提交
  3. 23 4月, 2013 3 次提交
    • P
      qemu: Fix setting of memory tunables · fa006c4f
      Peter Krempa 提交于
      Refactoring done in 19c6ad9a didn't
      correctly take into account the order cgroup limit modification needs to
      be done in. This resulted into errors when decreasing the limits.
      
      The operations need to take place in this order:
      
      decrease hard limit
      change swap hard limit
      
      or
      
      change swap hard limit
      increase hard limit
      
      This patch also fixes the check if the hard_limit is less than
      swap_hard_limit to print better error messages. For this purpose I
      introduced a helper function virCompareLimitUlong to compare limit
      values where value of 0 is equal to unlimited. Additionally the check is
      now applied also when the user does not provide all of the tunables
      through the API and in that case the currently set values are used.
      
      This patch resolves:
      https://bugzilla.redhat.com/show_bug.cgi?id=950478
      fa006c4f
    • J
      fd2e5530
    • G
      create virSocketAddrGetIpPrefix utility function · bd7c7c1b
      Gene Czarcinski 提交于
      Create the utility function virSocketAddrGetIpPrefix() to
      determine the prefix for this network.  The code in this
      function was adapted from virNetworkIpDefPrefix().
      
      Update virNetworkIpDefPrefix() in src/conf/network_conf.c
      to use the new utility function.
      Signed-off-by: NGene Czarcinski <gene@czarc.net>
      bd7c7c1b
  4. 20 4月, 2013 1 次提交
    • E
      docs: fix usage of 'onto' · 1bf25ba2
      Eric Blake 提交于
      http://www.uhv.edu/ac/newsletters/writing/grammartip2009.07.01.htm
      (and several other sites) give hints that 'onto' is best used if
      you can also add 'up' just before it and still make sense. In many
      cases in the code base, we really want the two-word form, or even
      a simplification to just 'on' or 'to'.
      
      * docs/hacking.html.in: Use correct 'on to'.
      * python/libvirt-override.c: Likewise.
      * src/lxc/lxc_controller.c: Likewise.
      * src/util/virpci.c: Likewise.
      * daemon/THREADS.txt: Use simpler 'on'.
      * docs/formatdomain.html.in: Better usage.
      * docs/internals/rpc.html.in: Likewise.
      * src/conf/domain_event.c: Likewise.
      * src/rpc/virnetclient.c: Likewise.
      * tests/qemumonitortestutils.c: Likewise.
      * HACKING: Regenerate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1bf25ba2
  5. 19 4月, 2013 2 次提交
    • P
      util: allow using virCommandAllowCap with setuid helpers · 5c1cfea4
      Paolo Bonzini 提交于
      When running unprivileged, virSetUIDGIDWithCaps will fail because it
      tries to add the requested capabilities to the permitted and effective
      sets.
      
      Detect this case, and invoke the child with cleared permitted and
      effective sets.  If it is a setuid program, it will get them.
      
      Some care is needed also because you cannot drop capabilities from the
      bounding set without CAP_SETPCAP.  Because of that, ignore errors from
      setting the bounding set.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      5c1cfea4
    • P
      util: simplify virSetUIDGIDWithCaps · 65871845
      Paolo Bonzini 提交于
      The need_prctl variable is not really needed.  If it is false,
      capng_apply will be called twice with the same set, causing
      a little extra work but no problem.  This keeps the code a bit
      simpler.
      
      It is also clearer to invoke capng_apply(CAPNG_SELECT_BOUNDS)
      separately, to make sure it is done while we have CAP_SETPCAP.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      65871845
  6. 17 4月, 2013 3 次提交
    • O
      qemu: Allow the disk wwn to have "0x" prefix · 09d2547f
      Osier Yang 提交于
      The recent qemu requires "0x" prefix for the disk wwn, this patch
      changes virValidateWWN to allow the prefix, and prepend "0x" if
      it's not specified. E.g.
      
      qemu-kvm: -device scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
      drive=drive-scsi0-0-0-0,id=scsi0-0-0-0,wwn=6000c60016ea71ad:
      Property 'scsi-hd.wwn' doesn't take value '6000c60016ea71ad'
      
      Though it's a qemu regression, but it's nice to allow the prefix,
      and doesn't hurt for us to always output "0x".
      09d2547f
    • O
      cleanup: Don't include libvirt/libvirt.h · 2d25fd4f
      Osier Yang 提交于
      Which is already included by "internal.h", later patch will add
      syntax-check to avoid it.
      2d25fd4f
    • O
      cleanup: Remove the duplicate header · bc95be5d
      Osier Yang 提交于
      Detected by a simple Shell script:
      
      for i in $(git ls-files -- '*.[ch]'); do
          awk 'BEGIN {
              fail=0
          }
          /# *include.*\.h/{
              match($0, /["<][^">]*[">]/)
              arr[substr($0, RSTART+1, RLENGTH-2)]++
          }
          END {
              for (key in arr) {
                  if (arr[key] > 1) {
                      fail=1
                      printf("%d %s\n", arr[key], key)
                  }
              }
              if (fail == 1)
                  exit 1
          }' $i
      
          if test $? != 0; then
              echo "Duplicate header(s) in $i"
          fi
      done;
      
      A later patch will add the syntax-check to avoid duplicate
      headers.
      bc95be5d
  7. 16 4月, 2013 16 次提交
  8. 15 4月, 2013 1 次提交
    • O
      Use unsigned int instead of unsigned · b1ea781e
      Osier Yang 提交于
      Though they are the same thing, mixed use of them is uncomfortable.
      "unsigned" is used a lot in old codes, this just tries to change the
      ones in utils.
      b1ea781e
  9. 13 4月, 2013 2 次提交
  10. 11 4月, 2013 2 次提交
  11. 10 4月, 2013 1 次提交
    • L
      Fix crash in virNetDevGetVirtualFunctions · 9579b6bc
      Laine Stump 提交于
      Commit 9a3ff01d (which was ACKed at
      the end of January, but for some reason didn't get pushed until during
      the 1.0.4 freeze) fixed the logic in virPCIGetVirtualFunctions().
      Unfortunately, a typo in the fix (replacing VIR_REALLOC_N with
      VIR_ALLOC_N during code movement) caused not only a memory leak, but
      also resulted in most of the elements of the result array being
      replaced with NULL. virNetDevGetVirtualFunctions() assumed (and I think
      rightly so) that virPCIGetVirtualFunctions() wouldn't return any NULL
      elements in the array, so it ended up segfaulting.
      
      This was found when attempting to use a virtual network with an
      auto-created pool of SRIOV VFs, e.g.:
      
          <forward mode='hostdev' managed='yes'>
            <pf dev='eth4'/>
          </forward>
      
      (the pool of PCI addresses is discovered by calling
      virNetDevGetVirtualFunctions() on the PF dev).
      9579b6bc
  12. 09 4月, 2013 1 次提交
  13. 08 4月, 2013 6 次提交
    • D
      Rename virCgroupMounted to virCgroupHasController & make it more robust · dca927c8
      Daniel P. Berrange 提交于
      The virCgroupMounted method is badly named, since a controller can be
      mounted, but disabled in the current object. Rename the method to be
      virCgroupHasController. Also make it tolerant to a  NULL virCgroupPtr
      and out-of-range controller index, to avoid duplication of these
      checks in all callers
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      dca927c8
    • O
      storage: Guess the parent if it's not specified for vHBA · f5a61087
      Osier Yang 提交于
      This finds the parent for vHBA by iterating over all the HBA
      which supports vport_ops capability on the host, and return
      the first one which is online, not saturated (vports in use
      is less than max_vports).
      f5a61087
    • O
      util: Add helper to get the scsi host name by iterating over sysfs · b52fbad1
      Osier Yang 提交于
      The helper iterates over sysfs, to find out the matched scsi host
      name by comparing the wwnn,wwpn pair. It will be used by checkPool
      and refreshPool of storage scsi backend. New helper getAdapterName
      is introduced in storage_backend_scsi.c, which uses the new util
      helper virGetFCHostNameByWWN to get the fc_host adapter name.
      b52fbad1
    • D
      Use VIR_ALLOC_VAR instead of VIR_ALLOC_N for creating virObject · c4f9edf1
      Daniel P. Berrange 提交于
      The current way virObject instances are allocated using
      VIR_ALLOC_N causes alignment warnings
      
      util/virobject.c: In function 'virObjectNew':
      util/virobject.c:195:11: error: cast increases required alignment of target type [-Werror=cast-align]
      
      Changing to use VIR_ALLOC_VAR will avoid the need todo
      the casts entirely.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c4f9edf1
    • D
      Avoid casts between unsigned char * and struct nlmsghdr · e95de74d
      Daniel P. Berrange 提交于
      The virNetlinkCommand() method takes an 'unsigned char **'
      parameter to be filled with the received netlink message.
      The callers then immediately cast this to 'struct nlmsghdr',
      triggering (bogus) warnings about increasing alignment
      requirements
      
      util/virnetdev.c: In function 'virNetDevLinkDump':
      util/virnetdev.c:1300:12: warning: cast increases required alignment of target type [-Wcast-align]
           resp = (struct nlmsghdr *)*recvbuf;
                  ^
      util/virnetdev.c: In function 'virNetDevSetVfConfig':
      util/virnetdev.c:1429:12: warning: cast increases required alignment of target type [-Wcast-align]
           resp = (struct nlmsghdr *)recvbuf;
      
      Since all callers cast to 'struct nlmsghdr' we can avoid
      the warning problem entirely by simply changing the
      signature of virNetlinkCommand to return a 'struct nlmsghdr **'
      instead of 'unsigned char **'. The way we do the cast inside
      virNetlinkCommand does not have any alignment issues.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      e95de74d
    • D
      Rewrite keycode map to avoid a struct · d27efd8e
      Daniel P. Berrange 提交于
      Playing games with field offsets in a struct causes all sorts
      of alignment warnings on ARM platforms
      
      util/virkeycode.c: In function '__virKeycodeValueFromString':
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:91:28: note: in expansion of macro 'getfield'
               const char *name = getfield(virKeycodes + i, const char *, name_offset);
                                  ^
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:94:20: note: in expansion of macro 'getfield'
                   return getfield(virKeycodes + i, unsigned short, code_offset);
                          ^
      util/virkeycode.c: In function '__virKeycodeValueTranslate':
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:127:13: note: in expansion of macro 'getfield'
               if (getfield(virKeycodes + i, unsigned short, from_offset) == key_value)
                   ^
      util/virkeycode.c:26:7: warning: cast increases required alignment of target type [-Wcast-align]
           (*(typeof(field_type) *)((char *)(object) + field_offset))
             ^
      util/virkeycode.c:128:20: note: in expansion of macro 'getfield'
                   return getfield(virKeycodes + i, unsigned short, to_offset);
      
      There is no compelling reason to use a struct for the keycode
      tables. It can easily just use an array of arrays instead,
      avoiding all alignment problems
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      d27efd8e