1. 20 7月, 2010 1 次提交
    • 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
  2. 29 5月, 2010 1 次提交
    • 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
  3. 24 5月, 2010 1 次提交
    • 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
  4. 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
  5. 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
  6. 30 4月, 2010 1 次提交
  7. 08 4月, 2010 1 次提交
  8. 16 3月, 2010 1 次提交
  9. 10 3月, 2010 1 次提交
  10. 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
  11. 03 3月, 2010 1 次提交
    • J
      Fix safezero() · a64e3b3e
      Jiri Denemark 提交于
      Various safezero() implementations used either -1, errno or -errno
      return values. This patch fixes them all to return -1 and set errno
      appropriately.
      
      There was also a bug in size parameter passed to safewrite() which could
      result in an attempt to write gigabytes out of a megabyte buffer.
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      a64e3b3e
  12. 22 2月, 2010 1 次提交
    • J
      Create raw storage files with O_DSYNC (again) · 9568c1d9
      Jiri Denemark 提交于
      Recently we introduced O_DSYNC flag when creating raw storage files to
      avoid filling all disk cache with dirty pages. However, the patch got
      lost when virStorageBackendCreateRaw was reworked using
      virFileOperation. Let's use O_DSYNC again.
      9568c1d9
  13. 20 2月, 2010 2 次提交
    • L
      Use virFileOperation hook function in virStorageBackendFileSystemVolBuild · 6ef20bb7
      Laine Stump 提交于
      There were a few operations on the storage volume file that were still
      being done as root, which will fail if the file is on a root-squashed
      NFS share. The result was that attempts to create a storage volume of
      type "raw" on a root-squashed NFS share would fail.
      
      This patch uses the newly introduced "hook" function in
      virFileOperation to execute all those file operations in the child
      process that's run under the uid that owns the file (and, presumably,
      has permission to write to the NFS share)
      
      * src/storage/storage_backend.c: use virFileOperation() in
        virStorageBackendCreateRaw, turning virStorageBackendCreateRaw()
        into a new createRawFileOpHook() hook
      6ef20bb7
    • L
      Rename virFileCreate to virFileOperation, add hook function · fbadc2b6
      Laine Stump 提交于
      It turns out it is also useful to be able to perform other operations
      on a file created while running as a different uid (eg, write things
      to that file), and possibly to do this to a file that already
      exists. This patch adds an optional hook function to the renamed (for
      more accuracy of purpose) virFileOperation; the hook will be called
      after the file has been opened (possibly created) and gid/mode
      checked/set, before closing it.
      
      As with the other operations on the file, if the VIR_FILE_OP_AS_UID
      flag is set, this hook function will be called in the context of a
      child process forked from the process that called virFileOperation.
      The implication here is that, while all data in memory is available to
      this hook function, any modification to that data will not be seen by
      the caller - the only indication in memory of what happened in the
      hook will be the return value (which the hook should set to 0 on
      success, or one of the standard errno values on failure).
      
      Another piece of making the function more flexible was to add an
      "openflags" argument. This arg should contain exactly the flags to be
      passed to open(2), eg O_RDWR | O_EXCL, etc.
      
      In the process of adding the hook to virFileOperation, I also realized
      that the bits to fix up file owner/group/mode settings after creation
      were being done in the parent process, which could fail, so I moved
      them to the child process where they should be.
      
      * src/util/util.[ch]: rename and rework virFileCreate-->virFileOperation,
        and redo flags in virDirCreate
      * storage/storage_backend.c, storage/storage_backend_fs.c: update the
        calls to virFileOperation/virDirCreate to reflect changes in the API,
        but don't yet take advantage of the hook.
      fbadc2b6
  14. 10 2月, 2010 2 次提交
    • D
      Remove virConnectPtr from secret XML APIs · c4dcf043
      Daniel P. Berrange 提交于
      The virConnectPtr is no longer required for error reporting since
      that is recorded in a thread local. Remove use of virConnectPtr
      from all APIs in secret_conf.{h,c} and update all callers to
      match
      c4dcf043
    • D
      Remove virConnectPtr from storage APIs & driver · 03136638
      Daniel P. Berrange 提交于
      The virConnectPtr is no longer required for error reporting since
      that is recorded in a thread local. Remove use of virConnectPtr
      from all APIs in storage_conf.{h,c} and storage_encryption_conf.{h,c}
      and update all callers to match
      03136638
  15. 09 2月, 2010 4 次提交
  16. 02 2月, 2010 1 次提交
  17. 21 1月, 2010 1 次提交
    • L
      Create storage volumes directly with desired uid/gid · e1f27784
      Laine Stump 提交于
      In order to avoid problems trying to chown files that were created by
      root on a root-squashing nfs server, fork a new process that setuid's
      to the desired uid before creating the file. (It's only done this way
      if the pool containing the new volume is of type 'netfs', otherwise
      the old method of creating the file followed by chown() is used.)
      
      This changes the semantics of the "create_func" slightly - previously
      it was assumed that this function just created the file, then the
      caller would chown it to the desired uid. Now, create_func does both
      operations.
      
      There are multiple functions that can take on the role of create_func:
      
      createFileDir - previously called mkdir(), now calls virDirCreate().
      virStorageBackendCreateRaw - previously called open(),
                                   now calls virFileCreate().
      virStorageBackendCreateQemuImg - use virRunWithHook() to setuid/gid.
      virStorageBackendCreateQcowCreate - same.
      virStorageBackendCreateBlockFrom - preserve old behavior (but attempt
                                         chown when necessary even if not root)
      
      * src/storage/storage_backend.[ch] src/storage/storage_backend_disk.c
        src/storage/storage_backend_fs.c src/storage/storage_backend_logical.c
        src/storage/storage_driver.c: change the create_func implementations,
        also propagate the pool information to be able to detect NETFS ones.
      e1f27784
  18. 11 12月, 2009 1 次提交
  19. 10 12月, 2009 1 次提交
    • M
      Add virBufferFreeAndReset() and replace free() · 1b9d0744
      Matthias Bolte 提交于
      Replace free(virBufferContentAndReset()) with virBufferFreeAndReset().
      Update documentation and replace all remaining calls to free() with
      calls to VIR_FREE(). Also add missing calls to virBufferFreeAndReset()
      and virReportOOMError() in OOM error cases.
      1b9d0744
  20. 03 11月, 2009 1 次提交
    • C
      Fix up NLS warnings. · 991be604
      Chris Lalancette 提交于
      When building with --disable-nls, I got a few messages like this:
      
      storage/storage_backend.c: In function 'virStorageBackendCreateQemuImg':
      storage/storage_backend.c:571: warning: format not a string literal and no format arguments
      
      Fix these up.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      991be604
  21. 30 9月, 2009 1 次提交
    • M
      Move file format enum to libvirt_util · 00fd3ff4
      Mark McLoughlin 提交于
      Rename virStorageVolFormatFileSystem to virStorageFileFormat and
      move to src/util/storage_file.[ch]
      
      * src/Makefile.am: add src/util/storage_file.[ch]
      
      * src/conf/storage_conf.[ch]: move enum from here ...
      
      * src/util/storage_file.[ch]: .. to here
      
      * src/libvirt_private.syms: update To/FromString exports
      
      * src/storage/storage_backend.c, src/storage/storage_backend_fs.c,
        src/vbox/vbox_tmpl.c: update for above changes
      00fd3ff4
  22. 21 9月, 2009 2 次提交
  23. 15 9月, 2009 1 次提交
    • D
      Fix UUID handling in secrets/storage encryption APIs · 47e7a258
      Daniel P. Berrange 提交于
      Convert all the secret/storage encryption APIs / wire format to
      handle UUIDs in raw format instead of non-canonical printable
      format. Guarentees data format correctness.
      
      * docs/schemas/storageencryption.rng: Make UUID mandatory for a secret
        and validate fully
      * docs/schemas/secret.rng: Fully validate UUID
      * include/libvirt/libvirt.h, include/libvirt/libvirt.h.in, Add
        virSecretLookupByUUID and virSecretGetUUID. Make
        virSecretGetUUIDString follow normal API design pattern
      * python/generator.py: Skip generation of virSecretGetUUID,
        virSecretGetUUIDString and virSecretLookupByUUID
      * python/libvir.c, python/libvirt-python-api.xml: Manual impl
        of virSecretGetUUID,virSecretGetUUIDString and virSecretLookupByUUID
      * qemud/remote.c: s/virSecretLookupByUUIDString/virSecretLookupByUUID/
        Fix get_nonnull_secret/make_nonnull_secret to use unsigned char
      * qemud/remote_protocol.x: Fix remote_nonnull_secret to use a
        remote_uuid instead of remote_nonnull_string for UUID field.
        Rename REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING to
        REMOTE_PROC_SECRET_LOOKUP_BY_UUID_STRING and make it take an
        remote_uuid  value
      * qemud/remote_dispatch_args.h, qemud/remote_dispatch_prototypes.h,
        qemud/remote_dispatch_ret.h, qemud/remote_dispatch_table.h,
        qemud/remote_protocol.c, qemud/remote_protocol.h: Re-generate
      * src/datatypes.h, src/datatypes.c: Store UUID in raw format instead
        of printable. Change virGetSecret to use raw format UUID
      * src/driver.h: Rename virDrvSecretLookupByUUIDString to
        virDrvSecretLookupByUUID and use raw format UUID
      * src/libvirt.c: Add virSecretLookupByUUID and virSecretGetUUID
        and re-implement virSecretLookupByUUIDString and
        virSecretGetUUIDString in terms of those
      * src/libvirt_public.syms: Add virSecretLookupByUUID and
        virSecretGetUUID
      * src/remote_internal.c: Rename remoteSecretLookupByUUIDString
        to remoteSecretLookupByUUID. Fix typo in args for
        remoteSecretDefineXML impl. Use raw UUID format for
        get_nonnull_secret and make_nonnull_secret
      * src/storage_encryption_conf.c, src/storage_encryption_conf.h:
        Storage UUID in raw format, and require it to be present in
        XML. Use UUID parser to validate.
      * secret_conf.h, secret_conf.c: Generate a UUID if none is provided.
        Storage UUID in raw format.
      * src/secret_driver.c: Adjust to deal with raw UUIDs. Save secrets
        in a filed with printable UUID, instead of base64 UUID.
      * src/virsh.c: Adjust for changed public API contract of
        virSecretGetUUIDString.
      * src/storage_Backend.c: DOn't undefine secret we just generated
        upon successful volume creation. Fix to handle raw UUIDs. Generate
        a non-clashing UUID
      * src/qemu_driver.c: Change to use lookupByUUID instead of
        lookupByUUIDString
      47e7a258
  24. 11 9月, 2009 1 次提交
    • M
      Provide missing passphrase when creating a volume. · cd6a9334
      Miloslav Trmač 提交于
      If the <encryption format='qcow'> element does not specify a secret
      during volume creation, generate a suitable secret and add it to the
      <encryption> tag.  The caller can view the updated <encryption> tag
      using virStorageVolGetXMLDesc().
      
      Similarly, when <encryption format='default'/> is specified while
      creating a qcow or qcow2-formatted volume, change the format to "qcow"
      and generate a secret as described above.
      
      * src/storage_encryption_conf.h (VIR_STORAGE_QCOW_PASSPHRASE_SIZE,
        virStorageGenerateQcowPasphrase),
        src/storage_encryption_conf.c (virStorageGenerateQcowPasphrase),
        src/libvirt_private.syms: Add virStorageGenerateQcowPasphrase().
      * src/storage_backend.c (virStoragegenerateQcowEncryption,
        virStorageBackendCreateQemuImg): Generate a passphrase and
        <encryption> when creating a qcow-formatted encrypted volume and the
        user did not supply the information.
      cd6a9334
  25. 10 9月, 2009 1 次提交
    • D
      Fix use of dlopen modules · fcd4e269
      Daniel P. Berrange 提交于
      Remove the bogus dependancy between node_device.c & storage_backend.c
      by moving the virWaitForDevices into util.h where it can be shared
      safely
      
      * src/storage_backend_disk.c, src/storage_backend_logical.c,
        src/storage_backend_mpath.c, src/storage_backend_scsi.c: Replace
        virStorageBackendWaitForDevices with virFileWaitForDevices
      * src/storage_backend.c, src/storage_backend.h: Remove
        virStorageBackendWaitForDevices, virWaitForDevices
      * src/util.h, src/util.c: Add virFileWaitForDevices
      * configure.in: Move xmlrpc check further down after pkgconfig
        is detected
      * src/Makefile.am: Add missing XMLRPC_CFLAGS/LIBS to opennebula
      * src/libvirt_private.syms: Add many missing exports
      fcd4e269
  26. 08 9月, 2009 1 次提交
    • D
      Multipath storage support module · ee8a06f8
      Dave Allan 提交于
      * configure.in src/Makefile.am src/storage_backend.[ch]
        src/storage_conf.[ch] src/storage_backend_mpath.[ch] po/POTFILES.in:
        add a new module for storage multipath, it requires device-mapper
      ee8a06f8
  27. 04 9月, 2009 1 次提交
  28. 02 9月, 2009 1 次提交
    • M
      Add support for encrypted (qcow) volume creation. · 46acb0f2
      Miloslav Trmač 提交于
      Supports only virStorageVolCreateXML, not virStorageVolCreateXMLFrom.
      
      Curiously, qemu-img does not need the passphrase for anything to create
      an encrypted volume.  This implementation thus does not need to touch
      any secrets to work with cooperating clients.  More generic passphrase
      handling is added in the next patch.
      
      * src/storage_backend.c: Request encryption when creating qcow/qcow2
        files
      * src/storage_backend_disk.c, src/storage_backend_fs.c,
        src/storage_backend_logical.c: Refuse to create volumes with
        encryption params set.
      46acb0f2
  29. 05 8月, 2009 1 次提交
  30. 24 7月, 2009 1 次提交
  31. 22 7月, 2009 1 次提交
  32. 17 7月, 2009 3 次提交