1. 28 10月, 2010 1 次提交
  2. 20 8月, 2010 2 次提交
    • E
      storage: avoid s[n]printf · 4bcac75b
      Eric Blake 提交于
      * src/storage/storage_backend.c (virStorageBackendCreateQemuImg)
      (virStorageBackendCreateQcowCreate): Use virAsprintf instead.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskCreateVol, virStorageBackendDiskPartFormat):
      Likewise.
      4bcac75b
    • E
      maint: whitespace cleanups · 57ae4c04
      Eric Blake 提交于
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskPartFormat): Fix spacing.
      57ae4c04
  3. 03 8月, 2010 1 次提交
  4. 31 7月, 2010 1 次提交
    • E
      storage: kill dead stores · 549b8399
      Eric Blake 提交于
      Found by clang.  Clang complained that virStorageBackendProbeTarget
      could dereference NULL if backingStoreFormat was NULL, but since all
      callers passed a valid pointer, I added attributes instead of null
      checks.
      
      * src/storage/storage_backend.c
      (virStorageBackendQEMUImgBackingFormat): Kill dead store.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Likewise.  Skip null checks, by adding attributes.
      549b8399
  5. 22 7月, 2010 4 次提交
    • L
      Remove erroneous setting of return value to errno. · ae3d31bf
      Laine Stump 提交于
      One error exit in virStorageBackendCreateBlockFrom was setting the
      return value to errno. The convention for volume build functions is to
      return 0 on success or -1 on failure. Not only was it not necessary to
      set the return value (it defaults to -1, and is set to 0 when
      everything has been successfully completed), in the case that some
      caller were checking for < 0 rather than != 0, they would incorrectly
      believe that it completed successfully.
      ae3d31bf
    • L
      Change virDirCreate to return -errno on failure. · 3e0f05fc
      Laine Stump 提交于
      virDirCreate also previously returned 0 on success and errno on
      failure. This makes it fit the recommended convention of returning 0
      on success, -errno (ie a negative number) on failure.
      3e0f05fc
    • L
      Make virStorageBackendCopyToFD return -errno. · ace1a2ba
      Laine Stump 提交于
      Previously virStorageBackendCopyToFD would simply return -1 on
      error. This made the error return from one of its callers inconsistent
      (createRawFileOpHook is supposed to return -errno, but if
      virStorageBackendCopyToFD failed, createRawFileOpHook would just
      return -1). Since there is a useful errno in every case of error
      return from virStorageBackendCopyToFD, and since the other uses of
      that function ignore the return code (beyond simply checking to see if
      it is < 0), this is a safe change.
      ace1a2ba
    • L
      Change virFileOperation to return -errno (ie < 0) on error. · 2ad04f78
      Laine Stump 提交于
      virFileOperation previously returned 0 on success, or the value of
      errno on failure. Although there are other functions in libvirt that
      use this convention, the preferred (and more common) convention is to
      return 0 on success and -errno (or simply -1 in some cases) on
      failure. This way the check for failure is always (ret < 0).
      
      * src/util/util.c - change virFileOperation and virFileOperationNoFork to
                          return -errno on failure.
      
      * src/storage/storage_backend.c, src/qemu/qemu_driver.c
        - change the hook functions passed to virFileOperation to return
          -errno on failure.
      2ad04f78
  6. 20 7月, 2010 5 次提交
    • L
      fsync new storage volumes even if new volume was copied. · e0f26c46
      Laine Stump 提交于
      Originally the storage volume files were opened with O_DSYNC to make
      sure they were flushed to disk immediately. It turned out that this
      was extremely slow in some cases, so the O_DSYNC was removed in favor
      of just calling fsync() after all the data had been written. However,
      this call to fsync was inside the block that is executed to zero-fill
      the end of the volume file. In cases where the new volume is copied
      from an old volume, and they are the same length, this fsync would
      never take place.
      
      Now the fsync is *always* done, unless there is an error (in which
      case it isn't important, and is most likely inappropriate.
      e0f26c46
    • L
      Don't skip zero'ing end of volume file when inputvol is shorter than newvol · 35bebb57
      Laine Stump 提交于
      A missing set of braces around an error condition caused us to skip
      zero'ing out the remainder of a new volume file if the new volume was
      longer than the original (the goto was supposed to be taken only in
      the case of error, but was always being taken).
      35bebb57
    • D
      Use the extract backing store format in storage volume lookup · 187da82f
      Daniel P. Berrange 提交于
      The storage volume lookup code was probing for the backing store
      format, instead of using the format extracted from the file
      itself. This meant it could report in accurate information. If
      a format is included in the file, then use that in preference,
      with probing as a fallback.
      
      * src/storage/storage_backend_fs.c: Use extracted backing store
        format
      187da82f
    • D
      Rewrite qemu-img backing store format handling · 27f45438
      Daniel P. Berrange 提交于
      When creating qcow2 files with a backing store, it is important
      to set an explicit format to prevent QEMU probing. The storage
      backend was only doing this if it found a 'kvm-img' binary. This
      is wrong because plenty of kvm-img binaries don't support an
      explicit format, and plenty of 'qemu-img' binaries do support
      a format. The result was that most qcow2 files were not getting
      a backing store format.
      
      This patch runs 'qemu-img -h' to check for the two support
      argument formats
      
        '-o backing_format=raw'
        '-F raw'
      
      and use whichever option it finds
      
      * src/storage/storage_backend.c: Query binary to determine
        how to set the backing store format
      27f45438
    • D
      Require format to be passed into virStorageFileGetMetadata · bf80fc68
      Daniel P. Berrange 提交于
      Require the disk image to be passed into virStorageFileGetMetadata.
      If this is set to VIR_STORAGE_FILE_AUTO, then the format will be
      resolved using probing. This makes it easier to control when
      probing will be used
      
      * src/qemu/qemu_driver.c, src/qemu/qemu_security_dac.c,
        src/security/security_selinux.c, src/security/virt-aa-helper.c:
        Set VIR_STORAGE_FILE_AUTO when calling virStorageFileGetMetadata.
      * src/storage/storage_backend_fs.c: Probe for disk format before
        calling virStorageFileGetMetadata.
      * src/util/storage_file.h, src/util/storage_file.c: Remove format
        from virStorageFileMeta struct & require it to be passed into
        method.
      bf80fc68
  7. 16 7月, 2010 1 次提交
    • D
      RFC: Canonicalize block device paths · ae3275c0
      David Allan 提交于
      There are many naming conventions for partitions associated with a
      block device.  Some of the major ones are:
      
      /dev/foo -> /dev/foo1
      /dev/foo1 -> /dev/foo1p1
      /dev/mapper/foo -> /dev/mapper/foop1
      /dev/disk/by-path/foo -> /dev/disk/by-path/foo-part1
      
      The universe of possible conventions isn't clear.  Rather than trying
      to understand all possible conventions, this patch divides devices
      into two groups, device mapper devices and everything else.  Device
      mapper devices seem always to follow the convention of device ->
      devicep1; everything else is canonicalized.
      ae3275c0
  8. 15 6月, 2010 2 次提交
    • E
      parthelper: fix compilation without optimization · 352b6df3
      Eric Blake 提交于
      Daniel's patch works with gcc and CFLAGS containing -O (the
      autoconf default), but fails with non-gcc or with other
      CFLAGS (such as -g), since c-ctype.h declares c_isdigit as
      a macro only for certain compilation settings.
      
      * src/Makefile.am (libvirt_parthelper_LDFLAGS): Add gnulib
      library, for when c_isdigit is not a macro.
      * src/storage/parthelper.c (main): Avoid out-of-bounds
      dereference, noticed by Jim Meyering.
      352b6df3
    • D
      Fix enumeration of partitions in disks with a trailing digit in path · bc8d9f20
      Daniel P. Berrange 提交于
      Disks with a trailing digit in their path (eg /dev/loop0 or
      /dev/dm0) have an extra 'p' appended before the partition
      number (eg, to form /dev/loop0p1 not /dev/loop01). Fix the
      partition lookup to append this extra 'p' when required
      
      * src/storage/parthelper.c: Add a 'p' before partition
        number if required
      bc8d9f20
  9. 08 6月, 2010 2 次提交
    • D
      Fix error codes for missing storage pools · 627409d1
      Daniel P. Berrange 提交于
      The storage pool driver is mistakenly using the error code
      VIR_ERR_INVALID_STORAGE_POOL which is for diagnosing invalid
      pointers. This patch switches it to use VIR_ERR_NO_STORAGE_POOL
      which is the correct code for cases where the storage pool does
      not exist
      
      * src/storage/storage_driver.c: Replace VIR_ERR_INVALID_STORAGE_POOL
        with VIR_ERR_NO_STORAGE_POOL
      627409d1
    • D
      Storage pool duplicate UUID/name checking · e9364d9f
      Daniel P. Berrange 提交于
      The storage pool driver is not doing correct checking for
      duplicate UUID/name values. This introduces a new method
      virStoragePoolObjIsDuplicate, based on the previously
      written virDomainObjIsDuplicate.
      
      * src/conf/storage_conf.c, src/conf/storage_conf.c,
        src/libvirt_private.syms: Add virStoragePoolObjIsDuplicate,
      * src/storage/storage_driver.c: Call virStoragePoolObjIsDuplicate
        for checking uniqueness of uuid/names
      e9364d9f
  10. 29 5月, 2010 2 次提交
    • J
      build: make cpp indentation conform · f9a4df5a
      Jim Meyering 提交于
      * src/storage/storage_backend.h (VIR_STORAGE_VOL_OPEN_DEFAULT):
      Adjust s/#define/# define/, and align continued lines.
      f9a4df5a
    • C
      storage: Check for invalid storage mode before opening · 4a1abb3f
      Cole Robinson 提交于
      If a directory pool contains pipes or sockets, a pool start can fail or hang:
      
      https://bugzilla.redhat.com/show_bug.cgi?id=589577
      
      We already try to avoid these special files, but only attempt after
      opening the path, which is where the problems lie. Unify volume opening
      into helper functions, which use the proper open() flags to avoid error,
      followed by fstat to validate storage mode.
      
      Previously, virStorageBackendUpdateVolTargetInfoFD attempted to enforce the
      storage mode check, but allowed callers to detect this case and silently
      continue. In practice, only the FS backend was using this feature, the rest
      were treating unknown mode as an error condition. Unfortunately the InfoFD
      function wasn't raising an error message here, so error reporting was
      busted.
      
      This patch adds 2 functions: virStorageBackendVolOpen, and
      virStorageBackendVolOpenModeSkip. The latter retains the original opt out
      semantics, the former now throws an explicit error.
      
      This patch maintains the previous volume mode checks: allowing specific
      modes for specific pool types requires a bit of surgery, since VolOpen
      is called through several different helper functions.
      
      v2: Use ATTRIBUTE_NONNULL. Drop stat check, just open with
          O_NONBLOCK|O_NOCTTY.
      
      v3: Move mode check logic back to VolOpen. Use 2 VolOpen functions with
          different error semantics.
      
      v4: Make second VolOpen function more extensible. Didn't opt to change
          FS backend defaults, this can just be to fix the original bug.
      
      v5: Prefix default flags with VIR_, use ATTRIBUTE_RETURN_CHECK
      4a1abb3f
  11. 26 5月, 2010 1 次提交
  12. 25 5月, 2010 1 次提交
  13. 24 5月, 2010 2 次提交
    • C
      storage: Combine some duplicate code · e40a285b
      Cole Robinson 提交于
      Volume detection in the scsi backend was duplicating code already
      present in storage_backend.c. Let's drop the duplicate code.
      
      Also, change the shared function name to be less generic, and remove
      some error squashing in the other call site.
      e40a285b
    • C
      storage: mpath: Clean up some error handling · 5086f85c
      Cole Robinson 提交于
      We were squashing error messages in a few cases. Recode to follow common
      ret = -1 convention.
      
      v2: Handle more error squashing issues further up in MakeNewVol and
          CreateVols. Use ret = -1 convention in MakeVols.
      5086f85c
  14. 21 5月, 2010 2 次提交
  15. 18 5月, 2010 1 次提交
    • E
      virFileResolveLink: fix return value · d533a98e
      Eric Blake 提交于
      virFileResolveLink was returning a positive value on error,
      thus confusing callers that assumed failure was < 0.  The
      confusion is further evidenced by callers that would have
      ended up calling virReportSystemError with a negative value
      instead of a valid errno.
      
      Fixes Red Hat BZ #591363.
      
      * src/util/util.c (virFileResolveLink): Live up to documentation.
      * src/qemu/qemu_security_dac.c
      (qemuSecurityDACRestoreSecurityFileLabel): Adjust callers.
      * src/security/security_selinux.c
      (SELinuxRestoreSecurityFileLabel): Likewise.
      * src/storage/storage_backend_disk.c
      (virStorageBackendDiskDeleteVol): Likewise.
      d533a98e
  16. 07 5月, 2010 1 次提交
    • E
      build: use gnulib's sys/wait.h · 8acaeb73
      Eric Blake 提交于
      * configure.ac: Drop sys/wait.h check.
      * src/libvirt.c (includes): Use header unconditionally.
      * src/remote/remote_driver.c (includes): Likewise.
      * src/storage/storage_backend.c (includes): Likewise.
      * src/util/ebtables.c (includes): Likewise.
      * src/util/hooks.c (includes): Likewise.
      * src/util/iptables.c (includes): Likewise.
      * src/util/util.c (includes): Likewise.
      8acaeb73
  17. 04 5月, 2010 1 次提交
    • E
      build: prefer WIN32 over __MINGW32__ checks · 9f87b631
      Eric Blake 提交于
      WIN32 is always defined when __MINGW32__ is defined, but the
      converse is not true.  WIN32 is more generic, if someone were
      to ever attempt porting to a microsoft compiler.  This does
      not affect Cygwin, which intentionally does not define WIN32.
      
      * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Use more
      generic flag macro.
      * src/storage/storage_backend.c
      (virStorageBackendUpdateVolTargetInfoFD)
      (virStorageBackendRunProgRegex): Likewise.
      * tools/console.h (vshRunConsole): Likewise.
      9f87b631
  18. 30 4月, 2010 1 次提交
  19. 16 4月, 2010 1 次提交
  20. 14 4月, 2010 2 次提交
  21. 08 4月, 2010 1 次提交
  22. 06 4月, 2010 1 次提交
  23. 20 3月, 2010 1 次提交
  24. 16 3月, 2010 1 次提交
  25. 10 3月, 2010 1 次提交
  26. 05 3月, 2010 1 次提交
    • L
      Change default for storage uid/gid from getuid()/getgid() to -1/-1 · 219305df
      Laine Stump 提交于
      This allows the config to have a setting that means "leave it alone",
      eg when building a pool where the directory already exists the user
      may want the current uid/gid of the directory left intact. This
      actually gets us back to older behavior - before recent changes to the
      pool building code, we weren't as insistent about honoring the uid/gid
      settings in the XML, and virt-manager was taking advantage of this
      behavior.
      
      As a side benefit, removing calls to getuid/getgid from the XML
      parsing functions also seems like a good idea. And having a default
      that is different from a common/useful value (0 == root) is a good
      thing in general, as it removes ambiguity from decisions (at least one
      place in the code was checking for (perms.uid == 0) to see if a
      special uid was requested).
      
      Note that this will only affect newly created pools and volumes. Due
      to the way that the XML is parsed, then formatted for newly created
      volumes, all existing pools/volumes already have an explicit uid and
      gid set.
      
      src/conf/storage_conf.c: Remove calls to setuid/setgid for default values
                               of uid/gid, and set them to -1 instead
      
      src/storage/storage_backend.c:
      src/storage/storage_backend_fs.c:
              Make account for the new default values of perms.uid
              and perms.gid.
      219305df