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. 21 7月, 2014 1 次提交
    • P
      util: Check return value from virStrToLong* functions · 5df81317
      Peter Krempa 提交于
      We do so in the vast majority of places, so there's no problem of adding
      the attribute to enforce it by the complier and fix a few leftover
      places.
      
      This was originally pointed out by Coverity as a recent change triggered
      it's warning that our code checked the vast majority of returns from
      virStrToLong_ui.
      5df81317
  3. 18 7月, 2014 2 次提交
    • M
      Kill last strto{l,ll,d} scouts · 50281605
      Michal Privoznik 提交于
      There's no need to use it since we have this shiny functions
      that even checks for conversion and overflow errors.
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      50281605
    • J
      storage: Disallow vol_wipe for sparse logical volumes · 8a9f7cbe
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1091866
      
      Add a new boolean 'sparse'.  This will be used by the logical backend
      storage driver to determine whether the target volume is sparse or not
      (also known by a snapshot or thin logical volume). Although setting sparse
      to true at creation could be seen as duplicitous to setting during
      virStorageBackendLogicalMakeVol() in case there are ever other code paths
      between Create and FindLVs that need to know about the volume be sparse.
      
      Use the 'sparse' in a new virStorageBackendLogicalVolWipe() to decide whether
      to attempt to wipe the logical volume or not. For now, I have found no
      means to wipe the volume without writing to it. Writing to the sparse
      volume causes it to be filled. A sparse logical volume is not completely
      writeable as there exists metadata which if overwritten will cause the
      sparse lv to go INACTIVE which means pool-refresh will not find it.
      Access to whatever lvm uses to manage data blocks is not provided by
      any API I could find.
      8a9f7cbe
  4. 17 7月, 2014 4 次提交
  5. 16 7月, 2014 4 次提交
    • E
      util: forbid freeing const pointers · a0b5ace2
      Eric Blake 提交于
      Now that we've finally fixed all the violators, it's time to
      enforce that any pointer to a const object is never freed (it
      is aliasing some other memory, where the non-const original
      should be freed instead).  Alas, the code still needs a normal
      vs. Coverity version, but at least we are still guaranteeing
      that the macro call evaluates its argument exactly once.
      
      I verified that we still get the following compiler warnings,
      which in turn halts the build thanks to -Werror on gcc (hmm,
      gcc 4.8.3's placement of the ^ for ?: type mismatch is a bit
      off, but that's not our problem):
      
          int oops1 = 0;
          VIR_FREE(oops1);
          const char *oops2 = NULL;
          VIR_FREE(oops2);
          struct blah { int dummy; } oops3;
          VIR_FREE(oops3);
      
      util/virauthconfig.c:159:35: error: pointer/integer type mismatch in conditional expression [-Werror]
           VIR_FREE(oops1);
                                         ^
      util/virauthconfig.c:161:5: error: passing argument 1 of 'virFree' discards 'const' qualifier from pointer target type [-Werror]
           VIR_FREE(oops2);
           ^
      In file included from util/virauthconfig.c:28:0:
      util/viralloc.h:79:6: note: expected 'void *' but argument is of type 'const void *'
       void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
            ^
      util/virauthconfig.c:163:35: error: type mismatch in conditional expression
           VIR_FREE(oops3);
                                         ^
      
      * src/util/viralloc.h (VIR_FREE): No longer cast away const.
      * src/xenapi/xenapi_utils.c (xenSessionFree): Work around bogus
      header.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a0b5ace2
    • C
      storagevol: add nocow to vol xml · a9fd30e6
      Chunyan Liu 提交于
      Add 'nocow' to storage volume xml so that user can have an option
      to set NOCOW flag to the newly created volume. It's useful on btrfs
      file system to enhance performance.
      
      Btrfs has low performance when hosting VM images, even more when the guest
      in those VM are also using btrfs as file system. One way to mitigate this
      bad performance is to turn off COW attributes on VM files. Generally, there
      are two ways to turn off COW on btrfs: a) by mounting fs with nodatacow,
      then all newly created files will be NOCOW. b) per file. Add the NOCOW file
      attribute. It could only be done to empty or new files.
      
      This patch tries the second way, according to 'nocow' option, it could set
      NOCOW flag per file:
      for raw file images, handle 'nocow' in libvirt code; for non-raw file images,
      pass 'nocow=on' option to qemu-img, and let qemu-img to handle that (requires
      qemu-img version >= 2.1).
      Signed-off-by: NChunyan Liu <cyliu@suse.com>
      a9fd30e6
    • R
      Implement interface stats for BSD · 61bbdbb9
      Roman Bogorodskiy 提交于
      61bbdbb9
    • R
      util: virstatslinux: make more generic · 5559a8b8
      Roman Bogorodskiy 提交于
      Rename linuxDomainInterfaceStats to virNetInterfaceStats in order
      to allow adding platform specific implementations without
      making consumer worrying about specific implementation to be used.
      
      Also, rename util/virstatslinux.c to util/virstats.c so placing
      other platform specific implementations into this file don't
      look unexpected from the file name.
      5559a8b8
  6. 14 7月, 2014 2 次提交
  7. 11 7月, 2014 2 次提交
  8. 09 7月, 2014 6 次提交
    • P
      util: storage: Fix build after 25924dec · 61e45dfb
      Peter Krempa 提交于
      The commit referenced above changed function arguments of
      virStorageFileGetMetadataFromBuf() but didn't tweak the
      ATTRIBUTE_NONNULL tied to them. This was caught by coverity as it
      actually obeys them. We disabled them for GCC and thus it didn't show
      up.
      
      Additionally in commit 3ea661de I passed
      NULL to the backingFormat argument which was also marked as nonnull. Use
      a dummy int's address when the argument isn't supplied so that the code
      doesn't need to change much.
      61e45dfb
    • P
      util: storage: Return complete parent info from virStorageFileChainLookup · 75017710
      Peter Krempa 提交于
      Instead of just returning the parent path, return the complete parent
      source structure.
      75017710
    • P
      util: storage: Make virStorageFileChainLookup more network storage aware · 09cea692
      Peter Krempa 提交于
      Add a few checks and avoid resolving relative links on networked
      storage.
      09cea692
    • M
      virEventPollDispatchHandles: Honour array boundaries · 52f50a71
      Michal Privoznik 提交于
      When dispatching events from the event loop, the array of registered
      handles is searched to see what handles happened an event on. However,
      the array is searched in weird way: the check for the array boundaries
      is at the end, so we may touch the elements after the end of the
      array:
      
      ==10434== Invalid read of size 4
      ==10434==    at 0x52D06B6: virEventPollDispatchHandles (vireventpoll.c:486)
      ==10434==    by 0x52D10E4: virEventPollRunOnce (vireventpoll.c:660)
      ==10434==    by 0x52CF207: virEventRunDefaultImpl (virevent.c:308)
      ==10434==    by 0x1639D1: virNetServerRun (virnetserver.c:1139)
      ==10434==    by 0x1220DC: main (libvirtd.c:1507)
      ==10434==  Address 0xc11ff04 is 4 bytes after a block of size 960 alloc'd
      ==10434==    at 0x4C2CA5E: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==10434==    by 0x52AD378: virReallocN (viralloc.c:245)
      ==10434==    by 0x52AD46E: virExpandN (viralloc.c:294)
      ==10434==    by 0x52AD5B1: virResizeN (viralloc.c:352)
      ==10434==    by 0x52CF2EC: virEventPollAddHandle (vireventpoll.c:116)
      ==10434==    by 0x52CEF5B: virEventAddHandle (virevent.c:78)
      ==10434==    by 0x11F69A90: nodeStateInitialize (node_device_udev.c:1797)
      ==10434==    by 0x53C3C89: virStateInitialize (libvirt.c:743)
      ==10434==    by 0x120563: daemonRunStateInit (libvirtd.c:919)
      ==10434==    by 0x5317719: virThreadHelper (virthread.c:197)
      ==10434==    by 0x8376F39: start_thread (in /lib64/libpthread-2.17.so)
      ==10434==    by 0x8A7F9FC: clone (in /lib64/libc-2.17.so)
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      52f50a71
    • P
      util: XML: Avoid forward function declaration · 036dd423
      Peter Krempa 提交于
      Recursive functions apparently don't need them, but I originally thought
      they do.
      036dd423
    • P
      util: cgroup: Fix build on non-cgroup platforms · 464f7678
      Peter Krempa 提交于
      Commit a48f4451 introduced a helper
      function to convert cgroup device mode to string. The function was only
      conditionally compiled on platforms that support cgroup. This broke the
      build when attempting to export the symbol:
      
        CCLD     libvirt.la
        Cannot export virCgroupGetDevicePermsString: symbol not defined
      
      Move the function out of the ifdef, as it doesn't really depend on the
      cgroup code being present.
      464f7678
  9. 08 7月, 2014 8 次提交
  10. 04 7月, 2014 3 次提交
    • P
      util: storage: Add helper to determine whether storage is local · ea43f5f9
      Peter Krempa 提交于
      There's a lot of places where we skip doing actions based on the
      locality of given storage type. The usual pattern is to skip it if:
      
      virStorageSourceGetActualType(src) == VIR_STORAGE_TYPE_NETWORK
      
      Add a simple helper to simplify the pattern to
      virStorageSourceIsLocalStorage(src)
      ea43f5f9
    • J
      Utilize virDomainDiskAuth for domain disk · 6887af39
      John Ferlan 提交于
      Replace the inline "auth" struct in virStorageSource with a pointer
      to a virStorageAuthDefPtr and utilize between the domain_conf, qemu_conf,
      and qemu_command sources for finding the auth data for a domain disk
      6887af39
    • J
      virstorage: Introduce virStorageAuthDef · 1c36b944
      John Ferlan 提交于
      Introduce virStorageAuthDef and friends.  Future patches will merge/utilize
      their view of storage source/pool auth/secret definitions.
      
      New API's include:
          virStorageAuthDefParse:  Parse the "<auth/>" XML data for either the
                                   domain disk or storage pool returning a
                                   virStorageAuthDefPtr
          virStorageAuthDefCopy:   Copy a virStorageAuthDefPtr - to be used by
                                   the qemuTranslateDiskSourcePoolAuth when it
                                   copies storage pool auth data into domain
                                   disk auth data
          virStorageAuthDefFormat: Common output of the "<auth" in the domain
                                   disk or storage pool XML
          virStorageAuthDefFree:   Free memory associated with virStorageAuthDef
      
      Subsequent patches will utilize the new functions for the domain disk and
      storage pools.
      
      Future work in the hostdev pass through can then make use of common data
      structures and code.
      1c36b944
  11. 03 7月, 2014 4 次提交
    • J
      Remove double OOM error reporting · 5656d9bb
      Ján Tomko 提交于
      5656d9bb
    • J
      Use virBufferCheckError everywhere we report OOM error · 92a8e72f
      Ján Tomko 提交于
      Replace:
      if (virBufferError(&buf)) {
          virBufferFreeAndReset(&buf);
          virReportOOMError();
          ...
      }
      
      with:
      if (virBufferCheckError(&buf) < 0)
          ...
      
      This should not be a functional change (unless some callers
      misused the virBuffer APIs - a different error would be reported
      then)
      92a8e72f
    • J
      Introduce virBufferCheckError · 058d89b9
      Ján Tomko 提交于
      Check if the buffer is in error state and report an error if it is.
      
      This replaces the pattern:
      if (virBufferError(buf)) {
          virReportOOMError();
          goto cleanup;
      }
      with:
      
      if (virBufferCheckError(buf) < 0)
          goto cleanup;
      
      Document typical buffer usage to favor this.
      Also remove the redundant FreeAndReset - if an error has
      been set via virBufferSetError, the content is already freed.
      058d89b9
    • J
      usb: Remove redundant comment · a1228523
      Ján Tomko 提交于
      a1228523
  12. 02 7月, 2014 1 次提交
  13. 01 7月, 2014 1 次提交
    • J
      Report one error less when getting net dev speed · 1c7601f5
      Ján Tomko 提交于
      virFileReadAll already logs an error. If reading the 'speed' file
      fails with EINVAL, we log an error even though we ignore it. If it
      fails with other errors, we log two errors.
      
      Use virFileReadAllQuiet - ignore EINVAL and report just one error
      in other cases.
      
      Fixes this error on libvirtd startup:
      2014-06-30 12:47:14.583+0000: 20971: error : virFileReadAll:1297 :
      Failed to read file '/sys/class/net/wlan0/speed': Invalid argument
      1c7601f5