1. 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
  2. 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
  3. 16 4月, 2013 16 次提交
  4. 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
  5. 13 4月, 2013 2 次提交
  6. 11 4月, 2013 2 次提交
  7. 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
  8. 09 4月, 2013 1 次提交
  9. 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
  10. 06 4月, 2013 1 次提交
  11. 05 4月, 2013 2 次提交
  12. 04 4月, 2013 2 次提交
  13. 02 4月, 2013 1 次提交