1. 04 2月, 2016 2 次提交
    • J
      logical: Clarify pieces of lvs regex · 7de8b442
      John Ferlan 提交于
      Rather than have a unwieldy regex string - split it up into its components
      each having it's own #define and then combine in a different #define
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      7de8b442
    • R
      storage: zfs: flexible use of 'volmode' option · c94f6d4d
      Roman Bogorodskiy 提交于
      There are slight differences in various ZFS implementations.
      Specifically, ZFS on FreeBSD requires to set value of 'volmode'
      option to 'dev' to expose volumes as raw disk device (that's what
      we need) rather than geom provides, for example.
      
      With ZFS on Linux, however, such option is not available and
      volumes exposed like we need by default.
      
      To make our implementation more flexible, only pass 'volmode'
      when it's supported. Support is checked by parsing usage
      information of the 'zfs get' command.
      c94f6d4d
  2. 03 2月, 2016 3 次提交
  3. 30 1月, 2016 5 次提交
    • J
      logical: Create helper virStorageBackendLogicalParseVolExtents · 63e15ad5
      John Ferlan 提交于
      Create a helper routine in order to parse any extents information
      including the extent size, length, and the device string contained
      within the generated 'lvs' output string.
      
      A future patch would then be able to avoid the code more cleanly
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      63e15ad5
    • W
      rbd: Open in Read-Only mode when refreshing a volume · 84678267
      Wido den Hollander 提交于
      By opening a RBD volume in Read-Only we do not register a
      watcher on the header object inside the Ceph cluster.
      
      Refreshing a volume only calls rbd_stat() which is a operation
      which does not write to a RBD image.
      
      This allows us to use a cephx user which has no write
      permissions if we would want to use the libvirt storage pool
      for informational purposes only.
      
      It also saves us a write into the Ceph cluster which should
      speed up refreshing a RBD pool.
      
      rbd_open_read_only() is available in all librbd versions which
      also support rbd_open().
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      84678267
    • W
      rbd: Implement buildVolFrom using RBD cloning · 0b15f920
      Wido den Hollander 提交于
      RBD supports cloning by creating a snapshot, protecting it and create
      a child image based on that snapshot afterwards.
      
      The RBD storage driver will try to find a snapshot with zero deltas between
      the current state of the original volume and the snapshot.
      
      If such a snapshot is found a clone/child image will be created using
      the rbd_clone2() function from librbd.
      
      rbd_clone2() is available in librbd since Ceph version Dumpling (0.67) which
      dates back to August 2013.
      
      It will use the same features, strip size and stripe count as the parent image.
      
      This implementation will only create a single snapshot on the parent image if
      never changes. This reduces the amount of snapshots created for that RBD image
      which benefits the performance of the Ceph cluster.
      
      During build the decision will be made to use either rbd_diff_iterate() or
      rbd_diff_iterate2().
      
      The latter is faster, but only available on Ceph versions after 0.94 (Hammer).
      
      Cloning is only supported if RBD format 2 is used. All images created by libvirt
      are already format 2.
      
      If a RBD format 1 image is used as the original volume the backend will report
      a VIR_ERR_OPERATION_UNSUPPORTED error.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      0b15f920
    • W
      rbd: Add support for wiping RBD volumes using TRIM. · 34872ca4
      Wido den Hollander 提交于
      Using VIR_STORAGE_VOL_WIPE_ALG_TRIM a RBD volume can be trimmed down
      to 0 bytes using rbd_discard()
      
      Effectively all the data on the volume will be lost/gone, but the volume
      remains available for use afterwards.
      
      Starting at offset 0 the storage pool will call rbd_discard() in stripe
      size * count increments which is usually 4MB. Stripe size being 4MB and
      count 1.
      
      rbd_discard() is available since Ceph version Dumpling (0.67) which dates
      back to August 2013.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      34872ca4
    • W
      storage: Add TRIM algorithm to storage volume API · 63cdc92f
      Wido den Hollander 提交于
      This new algorithm adds support for wiping volumes using TRIM.
      
      It does not overwrite all the data in a volume, but it tells the
      backing storage pool/driver that all bytes in a volume can be
      discarded.
      
      It depends on the backing storage pool how this is handled.
      
      A SCSI backend might send UNMAP commands to remove all data present
      on a LUN.
      
      A Ceph backend might use rbd_discard() to instruct the Ceph cluster
      that all data on that RBD volume can be discarded.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      63cdc92f
  4. 29 1月, 2016 3 次提交
    • W
      rbd: Add support for wiping RBD volumes · f226ecbf
      Wido den Hollander 提交于
      When wiping the RBD image will be filled with zeros started
      at offset 0 and until the end of the volume.
      
      This will result in the RBD volume growing to it's full allocation
      on the Ceph cluster. All data on the volume will be overwritten
      however, making it unavailable.
      
      It does NOT take any RBD snapshots into account. The original data
      might still be in a snapshot of that RBD volume.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      f226ecbf
    • W
      storage: Adjust fix virStorageBackendVolWipeLocal switch · 69535c61
      Wido den Hollander 提交于
      Use the cast of (virStorageVolWipeAlgorithm) adding the missing case:'s
      (VIR_STORAGE_VOL_WIPE_ALG_ZERO and VIR_STORAGE_VOL_WIPE_ALG_LAST).
      
      Additionally, the old code would also still run the SCRUB command on
      default since it didn't go to cleanup when a invalid flag was supplied.
      We now go to cleanup and exit if a invalid flag would be provided.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      69535c61
    • J
      logical: Fix comment examples for virStorageBackendLogicalFindLVs · 680030c4
      John Ferlan 提交于
      When commit id '82c1740a' made changes to the output format (changing from
      using a ',' separator to '#'), the examples in the lvs output from the
      comments weren't changed.
      
      Additionally, the two new fields added ('segtype' and 'stripes') were
      not included in the output, leaving it well confusing.
      
      This patch fixes the sample output, adds a 'striped' example, and makes
      other comment related adjustments for long line and spacing between followup
      'NB' remarks (while I'm there).
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      680030c4
  5. 20 1月, 2016 1 次提交
    • J
      storage: Add new flag for libvirt_parthelper · 020135dc
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1265694
      
      In order to be able to process disk storage pool's using a multipath
      device to handle the partitions, libvirt_parthelper will need a way to
      not automatically add a partition separator "p" to the generated device
      name for each partition found. This is designed to mimic the multipath
      features known as 'user_friendly_names' and custom 'alias' name.
      
      If the part_separator attribute is set to "no", then generation of the
      multipath partition name will not include the "p" partition separator
      unless the source device path name ends with a number. The generated
      partition names that get passed back to libvirt are processed in order
      to find the device mapper multipath (dm-#) path device.
      
      For example, device path "/dev/mapper/mpatha" would create partitions
      "/dev/mapper/mpatha1", "/dev/mapper/mpatha2", etc. instead of
      "/dev/mapper/mpathap1", "/dev/mapper/mpathap2", etc. If the device
      path ends with a number "/dev/mapper/mpatha1", then the algorithm
      to generate names "/dev/mapper/mpatha1p1", "/dev/mapper/mpatha1p2", etc.
      would be utilized.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      020135dc
  6. 18 1月, 2016 1 次提交
  7. 06 1月, 2016 3 次提交
    • W
      rbd: Do not append Ceph monitor port number 6789 if not provided · 6343018f
      Wido den Hollander 提交于
      If no port number was provided for a storage pool libvirt defaults to
      port 6789; however, librbd/librados already default to 6789 when no port
      number is provided.
      
      In the future Ceph will switch to a new port for the Ceph monitors since
      port 6789 is already assigned to a different application by IANA.
      
      Port 6789 is assigned to SMC-HTTPS and Ceph now has port 3300 assigned as
      the 'Ceph monitor' port.
      
      In this case it is the best solution to not hardcode any port number into
      libvirt and let librados handle the connection.
      
      Only if a user specifies a different port number we pass it down to librados,
      otherwise we leave it blank.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      
      merge
      6343018f
    • W
      rbd: Do not error out on a single image during pool refresh · f46d137e
      Wido den Hollander 提交于
      It could happen that rbd_list() returns X names, but that while
      refreshing the pool one of those RBD images is removed from Ceph
      through a different route then libvirt.
      
      We do not need to error out in such case, we can simply ignore the
      volume and continue.
      
        error : volStorageBackendRBDRefreshVolInfo:289 :
          failed to open the RBD image 'vol-998': No such file or directory
      
      It could also be that one or more Placement Groups (PGs) inside Ceph
      are inactive due to a system failure.
      
      If that happens it could be that some RBD images can not be refreshed
      and a timeout will be raised by librados.
      
        error : volStorageBackendRBDRefreshVolInfo:289 :
          failed to open the RBD image 'vol-893': Connection timed out
      
      Ignore the error and continue to refresh the rest of the pool's
      contents.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      f46d137e
    • W
      rbd: Only close RBD image if it has been opened · 10028a9d
      Wido den Hollander 提交于
      It could be that we error out while the RBD image has not been
      opened yet. This would cause us to call rbd_close() on pointer
      which has not been initialized.
      
      Set it to NULL by default and only close if it is not NULL.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      10028a9d
  8. 05 1月, 2016 1 次提交
  9. 04 1月, 2016 2 次提交
    • W
      rbd: Return VIR_STORAGE_FILE_RAW as format for RBD volumes · 688623b5
      Wido den Hollander 提交于
      This used to return 'unkown' and that was not correct.
      
      A vol-dumpxml now returns:
      
      <volume type='network'>
        <name>image3</name>
        <key>libvirt/image3</key>
        <source>
        </source>
        <capacity unit='bytes'>10737418240</capacity>
        <allocation unit='bytes'>10737418240</allocation>
        <target>
          <path>libvirt/image3</path>
          <format type='raw'/>
        </target>
      </volume>
      
      The RBD driver will now error out if a different format than RAW
      is provided when creating a volume.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      688623b5
    • M
      storage: do not leak storage pool XML filename · c494db8f
      Michael Chapman 提交于
      Valgrind complained:
      
      ==28277== 38 bytes in 1 blocks are definitely lost in loss record 298 of 957
      ==28277==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
      ==28277==    by 0x82D7F57: __vasprintf_chk (in /lib64/libc-2.12.so)
      ==28277==    by 0x52EF16A: virVasprintfInternal (stdio2.h:199)
      ==28277==    by 0x52EF25C: virAsprintfInternal (virstring.c:514)
      ==28277==    by 0x52B1FA9: virFileBuildPath (virfile.c:2831)
      ==28277==    by 0x19B1947C: storageDriverAutostart (storage_driver.c:191)
      ==28277==    by 0x19B196A7: storageStateAutoStart (storage_driver.c:307)
      ==28277==    by 0x538527E: virStateInitialize (libvirt.c:793)
      ==28277==    by 0x11D7CF: daemonRunStateInit (libvirtd.c:947)
      ==28277==    by 0x52F4694: virThreadHelper (virthread.c:206)
      ==28277==    by 0x6E08A50: start_thread (in /lib64/libpthread-2.12.so)
      ==28277==    by 0x82BE93C: clone (in /lib64/libc-2.12.so)
      Signed-off-by: NMichael Chapman <mike@very.puzzling.org>
      c494db8f
  10. 18 12月, 2015 2 次提交
    • J
      storage: Add virCheckFlags to virStorageBackendRBDDeleteVol · be783825
      John Ferlan 提交于
      The initial commit '74951ead' did not include the proper check for whether
      any flags are supported by the driver.
      
      Even though the driver doesn't support VIR_STORAGE_VOL_DELETE_ZEROED,
      it still checks and allows the processing to continue
      
      Also add the new VIR_STORAGE_VOL_DELETE_WITH_SNAPSHOTS since it is handled
      as of commit id '3c7590e0'.
      be783825
    • J
      storage: Add flags to allow building pool during create processing · aeb1078a
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=830056
      
      Add flags handling to the virStoragePoolCreate and virStoragePoolCreateXML
      API's which will allow the caller to provide the capability for the storage
      pool create API's to also perform a pool build during creation rather than
      requiring the additional buildPool step. This will allow transient pools
      to be defined, built, and started.
      
      The new flags are:
      
          * VIR_STORAGE_POOL_CREATE_WITH_BUILD
            Perform buildPool without any flags passed.
      
          * VIR_STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE
            Perform buildPool using VIR_STORAGE_POOL_BUILD_OVERWRITE flag.
      
          * VIR_STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE
            Perform buildPool using VIR_STORAGE_POOL_BUILD_NO_OVERWRITE flag.
      
      It is up to the backend to handle the processing of build flags. The
      overwrite and no-overwrite flags are mutually exclusive.
      
      NB:
      This patch is loosely based upon code originally authored by Osier
      Yang that were not reviewed and pushed, see:
      
      https://www.redhat.com/archives/libvir-list/2012-July/msg01328.html
      aeb1078a
  11. 17 12月, 2015 6 次提交
  12. 16 12月, 2015 5 次提交
  13. 12 12月, 2015 1 次提交
    • E
      CVE-2015-5313: storage: don't allow '/' in filesystem volume names · 034e47c3
      Eric Blake 提交于
      The libvirt file system storage driver determines what file to
      act on by concatenating the pool location with the volume name.
      If a user is able to pick names like "../../../etc/passwd", then
      they can escape the bounds of the pool.  For that matter,
      virStoragePoolListVolumes() doesn't descend into subdirectories,
      so a user really shouldn't use a name with a slash.
      
      Normally, only privileged users can coerce libvirt into creating
      or opening existing files using the virStorageVol APIs; and such
      users already have full privilege to create any domain XML (so it
      is not an escalation of privilege).  But in the case of
      fine-grained ACLs, it is feasible that a user can be granted
      storage_vol:create but not domain:write, and it violates
      assumptions if such a user can abuse libvirt to access files
      outside of the storage pool.
      
      Therefore, prevent all use of volume names that contain "/",
      whether or not such a name is actually attempting to escape the
      pool.
      
      This changes things from:
      
      $ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
      Vol ../../../../../../etc/haha created
      $ rm /etc/haha
      
      to:
      
      $ virsh vol-create-as default ../../../../../../etc/haha --capacity 128
      error: Failed to create vol ../../../../../../etc/haha
      error: Requested operation is not valid: volume name '../../../../../../etc/haha' cannot contain '/'
      Signed-off-by: NEric Blake <eblake@redhat.com>
      034e47c3
  14. 10 12月, 2015 5 次提交
    • J
      storage: Ignore block devices that fail format detection · a523770c
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1276198
      
      Prior to commit id '98322052' failure to saferead the block device would
      cause an error to be logged and the device to be skipped while attempting
      to discover/create a stable target path for a new LUN (NPIV).
      
      This was because virStorageBackendSCSIFindLUs ignored errors from
      processLU and virStorageBackendSCSINewLun.
      
      Ignoring the failure allowed a multipath device with an "active" and
      "ghost" to be present on the host with the "ghost" block device being
      ignored. This patch will return a -2 to the caller indicating the desire
      to ignore the block device since it cannot be used directly rather than
      fail the pool startup.
      a523770c
    • J
      storage: Add debug message · b3df72c4
      John Ferlan 提交于
      I found this useful while processing a volume that wouldn't end up
      showing up in the resulting list of block volumes. In this case, the
      partition type wasn't found in the disk_types table.
      b3df72c4
    • J
      storage: Handle readflags errors · 1bc84b0a
      John Ferlan 提交于
      Similar to the openflags VIR_STORAGE_VOL_OPEN_NOERROR processing, if some
      read processing operation fails, check the readflags for the corresponding
      error flag being set. If so, rather then causing an error - use VIR_WARN
      to flag the error, but return -2 which some callers can use to perform
      specific actions. Use a new VIR_STORAGE_VOL_READ_NOERROR flag in a new
      VolReadErrorMode enum.
      1bc84b0a
    • J
      storage: Set ret = -1 on failures in virStorageBackendUpdateVolTargetInfo · 1edfce9b
      John Ferlan 提交于
      While processing the volume for lseek, virFileReadHeaderFD, and
      virStorageFileGetMetadataFromBuf - failure would cause an error,
      but ret would not be set. That would result in an error message being
      sent, but successful status being returned.
      1edfce9b
    • J
      storage: Add comments for backend APIs · af4028dc
      John Ferlan 提交于
      Just so it's clearer what to expect upon input and what types of return
      values could be generated.  These were loosely copied from existing
      virStorageBackendUpdateVolTargetInfoFD.
      af4028dc