1. 17 12月, 2015 1 次提交
    • J
      storage: fix return values of virStorageBackendWipeExtentLocal · 09cbfc04
      Ján Tomko 提交于
      Return -1:
      * on all failures of fdatasync. Instead of propagating -errno
        all the way up to the virStorageVolWipe API, which is documented
        to return 0 or -1.
      * after a partial wipe. If safewrite failed, we would re-use the
        non-negative return value of lseek (which should be 0 in this case,
        because that's the only offset we seek to).
      09cbfc04
  2. 10 12月, 2015 5 次提交
    • 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
    • J
      storage: Add readflags for backend error processing · 22346003
      John Ferlan 提交于
      Similar to the openflags which allow VIR_STORAGE_VOL_OPEN_NOERROR to be
      passed to avoid open errors, add a 'readflags' variable so that in the
      future read failures could also be ignored.
      22346003
  3. 21 11月, 2015 2 次提交
    • J
      storage: Change virStorageBackendVolOpen to use virFileOpenAs · 5e3ad0b7
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1282288
      
      Rather than using just open on the path, allow for the possibility that
      the path to be opened resides on an NFS root-squash target and was created
      under a different uid/gid.
      
      Without using virFileOpenAs an attempt to get the volume size data may fail
      if the current user doesn't have permissions to read the volume, such as
      would be the case if mode wasn't supplied in the volume XML and the default
      VIR_STORAGE_DEFAULT_VOL_PERM_MODE (e.g. 0600) was used. Under this scenario
      the owner/group is not root:root, thus this path run under root would fail
      to open/read the volume.
      
      NB: The virFileOpenAs code using OPEN_FORK will only work when the failure
      is not EACESS/EPERM and the path resolves to a shared file system.
      5e3ad0b7
    • J
      storage: Really fix setting mode for backend exec in NFS root-squash env · ce6506b0
      John Ferlan 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1282288
      
      Although commit id '77346f27' resolves part of the problem regarding creating
      a qemu-img image in an NFS root-squash environment, it really didn't fix the
      entire problem. Unfortunately it only masked the problem. It seems qemu-img
      must open/create the image using 0644, which if used by target.perms would
      result in the chmod not being called since the mode desired and set match.
      
      Although qemu-img could conceivably ignore the mode when creating, libvirt
      has more knowledge of the environment and can make the adjustment to the
      mode far more easily by using virFileOpenAs with VIR_FILE_OPEN_FORCE_MODE.
      If that's successful, then we know on return the file will have the right
      owner and mode, so we can declare success
      ce6506b0
  4. 04 11月, 2015 3 次提交
    • J
      storage: Cleanup failures in virStorageBackendCreateRaw · 2265e7dd
      John Ferlan 提交于
      After successfully returning from virFileOpenAs, if subsequent calls fail,
      then we need to remove the file since our caller expects that failures after
      creation will remove the created file.
      2265e7dd
    • J
      storage: Cleanup failures virStorageBackendCreateExecCommand · 9345c2bf
      John Ferlan 提交于
      After a successful qemu-img/qcow-create of the backing file, if we
      fail to stat the file, change it owner/group, or mode, then the
      cleanup path should remove the file.
      9345c2bf
    • J
      storage: Fix setting mode in virStorageBackendCreateExecCommand · 77346f27
      John Ferlan 提交于
      Currently the code does not handle the NFS root squash environment
      properly since if the file gets created, then the subsequent chmod
      will fail in a root squash environment where we're creating a file
      in the pool with qemu tools, such as seen via:
      
         $ virsh vol-create-from $pool $file.xml file.img --inputpool $pool
      
      assuming $file.xml is creating a file of "<format type='qcow2'"> from
      an existing file.img in the pool of "<format type='raw'>".
      
      This patch will utilize the virCommandSetUmask when creating the file
      in the NETFS pool. The virCommandSetUmask API was added in commit id
      '0e1a1a8c', which was after the original code was developed in commit
      id 'e1f27784' to attempt to handle the root squash environment.
      
      Also, rather than blindly attempting to chmod, check to see if the
      st_mode bits from the stat match what we're trying to set and only
      make the chmod if they don't.
      
      Also, a slight adjustment to the fallback algorithm to move the
      virCommandSetUID/virCommandSetGID inside the if (!filecreated) since
      they're only useful if we need to attempt to create the file again.
      77346f27
  5. 14 10月, 2015 1 次提交
  6. 08 10月, 2015 1 次提交
  7. 02 9月, 2015 1 次提交
    • J
      storage: Correct the 'mode' check · 691dd388
      John Ferlan 提交于
      Commit id '7c2d65dd' changed the default value of mode to be -1 if not
      supplied in the XML, which should cause creation of the volume using the
      default mode of VIR_STORAGE_DEFAULT_VOL_PERM_MODE; however, the check
      made was whether mode was '0' or not to use default or provided value.
      
      This patch fixes the issue to check if the 'mode' was provided in the XML
      and use that value.
      691dd388
  8. 24 8月, 2015 1 次提交
    • G
      storage: only run safezero if allocation is > 0 · 269d39af
      Guido Günther 提交于
      While a zero allocation in safezero should be fine it isn't when we use
      posix_fallocate which returns EINVAL on a zero allocation.
      
      While we could skip the zero allocation in safezero_posix_fallocate it's
      an optimization to do it for all allocations.
      
      This fixes vm installation via virtinst for me which otherwise aborts
      like:
      
         Starting install...
         Retrieving file linux...               | 5.9 MB     00:01 ...
         Retrieving file initrd.gz...           |  29 MB     00:07 ...
         ERROR    Couldn't create storage volume 'virtinst-linux.sBgds4': 'cannot fill file '/var/lib/libvirt/boot/virtinst-linux.sBgds4': Invalid argument'
      
      The error was introduced by e30297b0 as spotted by Chunyan Liu
      269d39af
  9. 24 7月, 2015 1 次提交
  10. 10 7月, 2015 2 次提交
  11. 26 5月, 2015 1 次提交
    • C
      storage: conf: Don't set any default <mode> in the XML · 7c2d65dd
      Cole Robinson 提交于
      The XML parser sets a default <mode> if none is explicitly passed in.
      This is then used at pool/vol creation time, and unconditionally reported
      in the XML.
      
      The problem with this approach is that it's impossible for other code
      to determine if the user explicitly requested a storage mode. There
      are some cases where we want to make this distinction, but we currently
      can't.
      
      Handle <mode> parsing like we handle <owner>/<group>: if no value is
      passed in, set it to -1, and adjust the internal consumers to handle
      it.
      7c2d65dd
  12. 28 4月, 2015 1 次提交
    • C
      storage: fs: Ignore volumes that fail to open with EACCESS/EPERM · 56476f6a
      Cole Robinson 提交于
      Trying to use qemu:///session to create a storage pool pointing at
      /tmp will usually fail with something like:
      
      $ virsh pool-start tmp
      error: Failed to start pool tmp
      error: cannot open volume '/tmp/systemd-private-c38cf0418d7a4734a66a8175996c384f-colord.service-kEyiTA': Permission denied
      
      If any volume in an FS pool can't be opened by the daemon, the refresh
      fails, and the pool can't be used.
      
      This causes pain for virt-install/virt-manager though. Imaging a user
      downloads a disk image to /tmp. virt-manager wants to import /tmp as
      a storage pool, so we can detect what disk format it is, and set the
      XML correctly. However this case will likely fail as explained above.
      
      Change the logic here to skip volumes that fail to open. This could
      conceivably cause user complaints along the lines of 'why doesn't
      libvirt show $ROOT-OWNED-VOLUME-FOO', but figuring that currently
      the pool won't even startup, I don't think there are any current
      users that care about that case.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1103308
      56476f6a
  13. 21 4月, 2015 2 次提交
    • J
      storage: Fix check for stable path check · 9e5e1ca1
      John Ferlan 提交于
      Fix the if (!STRPREFIX(path, "/dev")) to be if (!STRPREFIX(path, "/dev/"))
      to ensure a path such as "/device" isn't declared stable.
      9e5e1ca1
    • J
      storage: Split out the stable path check · 9126161d
      John Ferlan 提交于
      For virStorageBackendStablePath, in order to make decisions in other code
      split out the checks regarding whether the pool's target is empty, using /dev,
      using /dev/, or doesn't start with /dev
      9126161d
  14. 13 4月, 2015 3 次提交
  15. 13 3月, 2015 1 次提交
    • J
      Introduce virBitmapIsBitSet · 22fd3ac3
      Ján Tomko 提交于
      A helper that never returns an error and treats bits out of bitmap range
      as false.
      
      Use it everywhere we use ignore_value on virBitmapGetBit, or loop over
      the bitmap size.
      22fd3ac3
  16. 02 3月, 2015 3 次提交
  17. 29 1月, 2015 1 次提交
    • J
      storage: Adjust how to refresh extended partition disk data · bce671b7
      John Ferlan 提交于
      During virStorageBackendDiskMakeDataVol processing, if we find an extended
      partition, then handle it specially when updating the capacity/allocation
      rather than calling virStorageBackendUpdateVolInfo.
      
      As it turns out, once a logical partition exists, any attempt to refresh
      the pool or after libvirtd restart/reload will result in a failure to open
      the extended partition device resulting in the inability to start the pool.
      The downside to this is we will lose the <permissions> and <timestamps> for
      the extended partition upon subsequent restart, refresh, reload since the
      stat() in virStorageBackendUpdateVolTargetInfoFD will not be called. However,
      since it's really only a container and shouldn't directly be used for
      storage that seems reasonable.
      
      Therefore, only use the existing code that already had a comment about
      getting the allocation wrong for extended partitions for just the setting
      of the extended partition data.
      bce671b7
  18. 27 1月, 2015 2 次提交
  19. 09 1月, 2015 1 次提交
    • J
      safezero: fall back to writing zeroes even when resizing · 1390c268
      Ján Tomko 提交于
      Remove the resize flag and use the same code path for all callers.
      This flag was added by commit 18f03166 to allow virStorageFileResize
      use 'safezero' while preserving the behavior.
      
      Explicitly return -2 when a fallback to a different method should
      be done, to make the code path more obvious.
      
      Fail immediately when ftruncate fails in the mmap method,
      as we did before commit 18f03166.
      1390c268
  20. 17 12月, 2014 1 次提交
    • J
      virstoragefile: Have virStorageFileResize use safezero · 18f03166
      John Ferlan 提交于
      Currently virStorageFileResize() function uses build conditionals to
      choose either the posix_fallocate() or syscall(SYS_fallocate) with no
      fallback in order to preallocate the space in the newly resized file.
      
      Since the safezero code has a similar set of conditionals modify the
      resize and safezero code in order to allow the resize logic to make use
      of safezero to unify the look/feel of the code paths.
      
      Add a new boolean (resize) to safezero() to make the optional decision
      whether to try syscall(SYS_fallocate) if the posix_fallocate fails because
      HAVE_POSIX_FALLOCATE is not defined (eg, return -1 and errno == 0).
      
      Create a local safezero_sys_fallocate in order to handle the resize
      code paths that support that.  If not present, the set errno = ENOSYS
      in order to allow the caller to handle the failure scenarios.
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      18f03166
  21. 03 12月, 2014 1 次提交
    • J
      Replace virSecretFree with virObjectUnref · a0b13d35
      John Ferlan 提交于
      Since virSecretFree will call virObjectUnref anyway, let's just use that
      directly so as to avoid the possibility that we inadvertently clear out
      a pending error message when using the public API.
      a0b13d35
  22. 15 11月, 2014 1 次提交
  23. 25 8月, 2014 1 次提交
    • R
      fdstream: introduce virFDStreamOpenBlockDevice · f5b4c141
      Roman Bogorodskiy 提交于
      virStorageBackendVolDownloadLocal and virStorageBackendVolUploadLocal
      use virFDStreamOpenFile function to work with the volume fd.
      
      virFDStreamOpenFile calls virFDStreamOpenFileInternal that implements
      handling of the non-blocking I/O. If a file is not a character device and
      not a fifo, it uses libvirt_iohelper.
      
      On FreeBSD, it doesn't work as expected because disk devices (including
      ZFS volumes) are exposed as character devices, and ZFS volumes do not
      support open(2) with O_NONBLOCK.
      
      To overcome this, introduce a forceIOHelper flag to
      virFDStreamOpenFileInternal that forces using libvirt_iohelper. And
      introduce virFDStreamOpenBlockDevice that calls
      virFDStreamOpenFileInternal with the forceIOHelper set to true.
      f5b4c141
  24. 13 8月, 2014 1 次提交
    • E
      maint: improve syntax check for space around = · b50c8603
      Eric Blake 提交于
      Laine Stump noted on IRC that syntax check wasn't flagging his
      typo of 'i= 0'.  This fixes it.
      
      * build-aux/bracket-spacing.pl: Tighten 'space around =' rule.
      * src/storage/storage_backend.c
      (virStorageBackendCreateExecCommand): Fix offenders.
      * src/util/virnuma.c (virNumaGetDistances): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotDeleteMetadataOnly)
      (vboxNetworkGetXMLDesc): Likewise.
      * src/xenapi/xenapi_driver.c (xenapiDomainLookupByName):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b50c8603
  25. 12 8月, 2014 1 次提交
    • R
      storage: ZFS support · 0257d06b
      Roman Bogorodskiy 提交于
      Implement ZFS storage backend driver. Currently supported
      only on FreeBSD because of ZFS limitations on Linux.
      
      Features supported:
      
       - pool-start, pool-stop
       - pool-info
       - vol-list
       - vol-create / vol-delete
      
      Pool definition looks like that:
      
       <pool type='zfs'>
        <name>myzfspool</name>
        <source>
          <name>actualpoolname</name>
        </source>
       </pool>
      
      The 'actualpoolname' value is a name of the pool on the system,
      such as shown by 'zpool list' command. Target makes no sense
      here because volumes path is always /dev/zvol/$poolname/$volname.
      
      User has to create a pool on his own, this driver doesn't
      support pool creation currently.
      
      A volume could be used with Qemu by adding an entry like this:
      
          <disk type='volume' device='disk'>
            <driver name='qemu' type='raw'/>
            <source pool='myzfspool' volume='vol5'/>
            <target dev='hdc' bus='ide'/>
          </disk>
      0257d06b
  26. 01 8月, 2014 1 次提交