1. 25 6月, 2014 3 次提交
    • P
      util: storage: Remove now redundant backingRelative from virStorageSource · 84b1f5d8
      Peter Krempa 提交于
      Now that we store only relative names in virStorageSource's member
      relPath the backingRelative member is obsolete. Remove it and adapt the
      code to the removal.
      84b1f5d8
    • P
      storage: Store relative path only for relatively backed storage · 7ba6a6f9
      Peter Krempa 提交于
      Due to various refactors and compatibility with the virstoragetest the
      relPath field of the virStorageSource structure was always filled either
      with the relative name or the full path in case of absolutely backed
      storage. Return its original purpose to store only the relative name of
      the disk if it is backed relatively and tweak the tests.
      7ba6a6f9
    • P
      util: storage: Add helper to resolve relative path difference · 157a33a7
      Peter Krempa 提交于
      This patch introduces a function that will allow us to resolve a
      relative difference between two elements of a disk backing chain. This
      function will be used to allow relative block commit and block pull
      where we need to specify the new relative name of the image to qemu.
      
      This patch also adds unit tests for the function to verify that it works
      correctly.
      157a33a7
  2. 24 6月, 2014 1 次提交
  3. 20 6月, 2014 1 次提交
  4. 03 6月, 2014 3 次提交
    • P
      storage: Add infrastructure to parse remote network backing names · ed68eb86
      Peter Krempa 提交于
      Add parsers for relative and absolute backing names for local and remote
      storage files.
      
      This parser parses relative paths as relative to their parents and
      absolute paths according to the protocol or local access.
      
      For remote storage volumes, all URI based backing file names are
      supported and for the qemu colon syntax the NBD protocol is supported.
      ed68eb86
    • P
      storage: Switch metadata crawler to use storage driver to read headers · 2bdb8b96
      Peter Krempa 提交于
      Use virStorageFileReadHeader() to read headers of storage files possibly
      on remote storage to retrieve the image metadata.
      
      The backend information is now parsed by
      virStorageFileGetMetadataInternal which is now exported from the util
      source and virStorageFileGetMetadataFromFDInternal now doesn't need to
      be exported.
      2bdb8b96
    • P
      storage: Move virStorageFileGetMetadata to the storage driver · 713cc3b0
      Peter Krempa 提交于
      My future work will modify the metadata crawler function to use the
      storage driver file APIs to access the files instead of accessing them
      directly so that we will be able to request the metadata for remote
      files too. To avoid linking the storage driver to every helper file
      using the utils code, the backing chain traversal function needs to be
      moved to the storage driver source.
      
      Additionally the virt-aa-helper and virstoragetest programs need to be
      linked with the storage driver as a result of this change.
      713cc3b0
  5. 29 5月, 2014 1 次提交
  6. 23 5月, 2014 2 次提交
    • P
      storage: Add NONE protocol type for network disks · a01d9357
      Peter Krempa 提交于
      Currently the protocol type with index 0 was NBD which made it hard to
      distinguish whether the protocol type was actually assigned. Add a new
      protocol type with index 0 to distinguish it explicitly.
      a01d9357
    • P
      storage: Store gluster volume name separately · 1115f975
      Peter Krempa 提交于
      The gluster volume name was previously stored as part of the source path
      string. This is unfortunate when we want to do operations on the path as
      the volume is used separately.
      
      Parse and store the volume name separately for gluster storage volumes
      and use the newly stored variable appropriately.
      1115f975
  7. 19 5月, 2014 2 次提交
    • E
      Revert "maint: prefer enum over int for virstoragefile structs" · 71bce84a
      Eric Blake 提交于
      This partially reverts commits b279e52f and ea18f8b2.
      
      It turns out our code base is full of:
      
      if ((struct.member = virBlahFromString(str)) < 0)
          goto error;
      
      Meanwhile, the C standard says it is up to the compiler whether
      an enum is signed or unsigned when all of its declared values
      happen to be positive.  In my testing (Fedora 20, gcc 4.8.2),
      the compiler picked signed, and nothing changed.  But others
      testing with gcc 4.7 got compiler warnings, because it picked
      the enum to be unsigned, but no unsigned value is less than 0.
      Even worse:
      
      if ((struct.member = virBlahFromString(str)) <= 0)
          goto error;
      
      is silently compiled without warning, but incorrectly treats -1
      from a bad parse as a large positive number with no warning; and
      without the compiler's help to find these instances, it is a
      nightmare to maintain correctly.  We could force signed enums
      with a dummy negative declaration in each enum, or cast the
      result of virBlahFromString back to int after assigning to an
      enum value, or use a temporary int for collecting results from
      virBlahFromString, but those actions are all uglier than what we
      were trying to cure by directly using enum types for struct
      values in the first place.  It's better off to just live with int
      members, and use 'switch ((virFoo) struct.member)' where we want
      the compiler to help, than to track down all the conversions from
      string to enum and ensure they don't suffer from type problems.
      
      * src/util/virstorageencryption.h: Revert back to int declarations
      with comment about enum usage.
      * src/util/virstoragefile.h: Likewise.
      * src/conf/domain_conf.c: Restore back to casts in switches.
      * src/qemu/qemu_driver.c: Likewise.
      * src/qemu/qemu_command.c: Add cast rather than revert.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      71bce84a
    • D
      parallels: add VIR_STORAGE_FILE_PLOOP format · 13f229aa
      Dmitry Guryanov 提交于
      Add VIR_STORAGE_FILE_PLOOP format. This format is used
      to store disk images for virtual machines in PCS and containers
      in PCS, OpenVZ and also in Parallels Desktop for Mac.
      
      This format is described on OpenVZ site -
      https://openvz.org/Ploop (together with ploop devices). It
      consists of XML descriptor and one or more image files: base
      image and deltas. Format of the image files described here:
      https://openvz.org/Ploop/format.
      
      This patch only adds VIR_STORAGE_FILE_PLOOP constant, consequent
      patches will use it in parallels driver.
      Signed-off-by: NDmitry Guryanov <dguryanov@parallels.com>
      13f229aa
  8. 16 5月, 2014 1 次提交
    • E
      maint: prefer enum over int for virstoragefile structs · b279e52f
      Eric Blake 提交于
      For internal structs, we might as well be type-safe and let the
      compiler help us with less typing required on our part (getting
      rid of casts is always nice).  In trying to use enums directly,
      I noticed two problems in virstoragefile.h that can't be fixed
      without more invasive refactoring: virStorageSource.format is
      used as more of a union of multiple enums in storage volume
      code (so it has to remain an int), and virStorageSourcePoolDef
      refers to pooltype whose enum is declared in src/conf, but where
      src/util can't pull in headers from src/conf.
      
      * src/util/virstoragefile.h (virStorageNetHostDef)
      (virStorageSourcePoolDef, virStorageSource): Use enums instead of
      int for fields of internal types.
      * src/qemu/qemu_command.c (qemuParseCommandLine): Cover all values.
      * src/conf/domain_conf.c (virDomainDiskSourceParse)
      (virDomainDiskSourceFormat): Simplify clients.
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotCreateSingleDiskActive)
      (qemuDomainSnapshotPrepareDiskExternalBackingInactive)
      (qemuDomainSnapshotPrepareDiskExternalOverlayActive)
      (qemuDomainSnapshotPrepareDiskInternal): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b279e52f
  9. 15 5月, 2014 1 次提交
  10. 06 5月, 2014 2 次提交
    • J
      util: use typedefs for enums in "src/util/" directory · 1b14c449
      Julio Faracco 提交于
      In "src/util/" there are many enumeration (enum) declarations.
      Sometimes, it's better using a typedef for variable types,
      function types and other usages. Other enumeration will be
      changed to typedef's in the future.
      Signed-off-by: NJulio Faracco <jcfaracco@gmail.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1b14c449
    • E
      conf: drop extra storage probe · fff74b27
      Eric Blake 提交于
      All callers of virStorageFileGetMetadataFromBuf were first calling
      virStorageFileProbeFormatFromBuf, to learn what format to pass in.
      But this function is already wired to do the exact same probe if
      the incoming format is VIR_STORAGE_FILE_AUTO, so it's simpler to
      just refactor the probing into the central function.
      
      * src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
      Drop parameter.
      (virStorageFileProbeFormatFromBuf): Drop declaration.
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
      Do probe here instead of in callers.
      (virStorageFileProbeFormatFromBuf): Make static.
      * src/libvirt_private.syms (virstoragefile.h): Drop function.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Update caller.
      * src/storage/storage_backend_gluster.c
      (virStorageBackendGlusterRefreshVol): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      fff74b27
  11. 01 5月, 2014 1 次提交
  12. 25 4月, 2014 2 次提交
  13. 24 4月, 2014 9 次提交
  14. 15 4月, 2014 1 次提交
    • E
      conf: restrict external snapshots to backing store formats · db7d7c0e
      Eric Blake 提交于
      Domain snapshots should only permit an external snapshot into
      a storage format that permits a backing chain, since the new
      snapshot file necessarily must be backed by the existing file.
      The C code for the qemu driver is a little bit stricter in
      currently enforcing only qcow2 or qed, but at the XML parser
      level, including virt-xml-validate, it is fairly easy to
      enforce that a user can't request a 'raw' external snapshot.
      
      * docs/schemas/storagecommon.rng (storageFormat): Split out...
      (storageFormatBacking): ...new sublist.
      * docs/schemas/domainsnapshot.rng (disksnapshotdriver): Use new
      type.
      * src/util/virstoragefile.h (virStorageFileFormat): Rearrange for
      easier code management.
      * src/util/virstoragefile.c (virStorageFileFormat, fileTypeInfo):
      Likewise.
      * src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML): Use
      new marker to limit selection of formats.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      db7d7c0e
  15. 12 4月, 2014 2 次提交
    • E
      conf: delete internal directory field · e0292e0c
      Eric Blake 提交于
      Another field no longer needed, getting us one step closer to
      merging virStorageFileMetadata and virStorageSource.
      
      * src/util/virstoragefile.h (_virStorageFileMetadata): Drop
      field.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
      (virStorageFileGetMetadataFromFDInternal): Alter signature.
      (virStorageFileFreeMetadata, virStorageFileGetMetadataFromBuf)
      (virStorageFileGetMetadataFromFD): Adjust clients.
      * tests/virstoragetest.c (_testFileData, testStorageChain)
      (mymain): Simplify test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      e0292e0c
    • E
      conf: drop redundant parameter to chain lookup · 74430fe3
      Eric Blake 提交于
      The original chain lookup code had to pass in the starting name,
      because it was not available in the chain.  But now that we have
      added fields to the struct, this parameter is redundant.
      
      * src/util/virstoragefile.h (virStorageFileChainLookup): Alter
      signature.
      * src/util/virstoragefile.c (virStorageFileChainLookup): Adjust
      handling of top of chain.
      * src/qemu/qemu_driver.c (qemuDomainBlockCommit): Adjust caller.
      * tests/virstoragetest.c (testStorageLookup, mymain): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      74430fe3
  16. 11 4月, 2014 4 次提交
    • E
      conf: delete useless backingStoreFormat field · 86cfa1f6
      Eric Blake 提交于
      Drop another redundant field from virStorageFileMetadata.
      
      * src/util/virstoragefile.h (_virStorageFileMetadata): Drop
      field.
      * src/util/virstoragefile.c
      (virStorageFileGetMetadataFromFDInternal)
      (virStorageFileGetMetadataFromFD)
      (virStorageFileGetMetadataRecurse): Adjust callers.
      * tests/virstoragetest.c (_testFileData, testStorageChain)
      (mymain): Simplify test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      86cfa1f6
    • E
      conf: return backing information separately from metadata · a4dfc8d3
      Eric Blake 提交于
      A couple pieces of virStorageFileMetadata are used only while
      collecting information about the chain, and don't need to
      live permanently in the struct.  This patch refactors external
      callers to collect the information separately, so that the
      next patch can remove the fields.
      
      * src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
      Alter signature.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
      Likewise.
      (virStorageFileGetMetadataFromFDInternal): Adjust callers.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Likewise.
      * src/storage/storage_backend_gluster.c
      (virStorageBackendGlusterRefreshVol): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a4dfc8d3
    • E
      conf: delete useless backingStoreIsFile field · c919ed7e
      Eric Blake 提交于
      Finally starting to prune away some of the old fields that have
      been made redundant by the new fields, on my way towards directly
      reusing virStorageSource.
      
      * src/util/virstoragefile.h (_virStorageFileMetadata): Drop
      field.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
      (virStorageFileChainLookup): Adjust callers.
      * tests/virstoragetest.c (_testFileData, testStorageChain)
      (mymain): Simplify test.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c919ed7e
    • E
      conf: expose probe for non-local storage · 86f71e0a
      Eric Blake 提交于
      Deciding if a user string represents a local file instead of a
      network path is an operation worth exposing directly, particularly
      since the next patch will be removing a redundant variable that
      was caching the information.
      
      * src/util/virstoragefile.h (virStorageIsFile): New declaration.
      * src/util/virstoragefile.c (virBackingStoreIsFile): Rename...
      (virStorageIsFile): ...export, and allow NULL input.
      (virStorageFileGetMetadataInternal)
      (virStorageFileGetMetadataRecurse, virStorageFileGetMetadata):
      Update callers.
      * src/conf/domain_conf.c (virDomainDiskDefForeachPath): Use it.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Likewise.
      * src/libvirt_private.syms (virstoragefile.h): Export function.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      86f71e0a
  17. 09 4月, 2014 3 次提交
    • E
      conf: track more fields in backing chain metadata · 5976a9ac
      Eric Blake 提交于
      The current use of virStorageFileMetadata is awkward; to learn
      some of the information about a child node, you have to read
      fields in the parent node.  This does not lend itself well to
      modifying backing chains (whether inserting a new node in the
      chain, or consolidating existing nodes); better would be to
      learn about a child node directly in that node.  This patch
      sets up some new fields which contain redundant information,
      although not necessarily in the final desired state for the
      new fields (see the next patch for actual tests of what is there
      now).  Then later patches will do any refactoring necessary to
      get the fields to their desired states, and update clients to
      get the information from the new fields, so we can finally
      delete the fields that are tracking information about the wrong
      node.
      
      More concretely, compare these three example backing chains:
      
      good <- one
      missing <- two
      gluster://server/vol/img <- three
      
      Pre-patch, querying the chains gives:
      { .backingStore = "/path/to/good",
        .backingStoreRaw = "good",
        .backingStoreIsFile = true,
        .backingStoreFormat = VIR_STORAGE_FILE_RAW,
        .backingMeta = {
          .backingStore = NULL,
          .backingStoreRaw = NULL,
          .backingStoreIsFile = false,
          .backingMeta = NULL,
        }
      }
      { .backingStore = NULL,
        .backingStoreRaw = "missing",
        .backingStoreIsFile = false,
        .backingStoreFormat = VIR_STORAGE_FILE_NONE,
        .backingMeta = NULL,
      }
      { .backingStore = "gluster://server/vol/img",
        .backingStoreRaw = NULL,
        .backingStoreIsFile = false,
        .backingStoreFormat = VIR_STORAGE_FILE_RAW,
        .backingMeta = NULL,
      }
      
      Deciding whether to ignore a missing backing file (as in virsh
      vol-dumpxml) or report an error (as in security manager sVirt
      labeling) requires reading multiple fields.  Plus, the format
      is hard-coded to treat all network protocols as end-of-the-chain,
      as if they were raw.  By the end of this patch series, the goal
      is to instead represent these three situations as:
      
      { .path = "one",
        .canonPath = "/path/to/one",
        .type = VIR_STORAGE_TYPE_FILE,
        .format = VIR_STORAGE_FILE_QCOW2,
        .backingStoreRaw = "good",
        .backingMeta = {
          .path = "good",
          .canonPath = "/path/to/good",
          .type = VIR_STORAGE_TYPE_FILE,
          .format = VIR_STORAGE_FILE_RAW,
          .backingStoreRaw = NULL,
          .backingMeta = NULL,
        }
      }
      { .path = "two",
        .canonPath = "/path/to/two",
        .type = VIR_STORAGE_TYPE_FILE,
        .format = VIR_STORAGE_FILE_QCOW2,
        .backingStoreRaw = "missing",
        .backingMeta = NULL,
      }
      { .path = "three",
        .canonPath = "/path/to/three",
        .type = VIR_STORAGE_TYPE_FILE,
        .format = VIR_STORAGE_FILE_QCOW2,
        .backingStoreRaw = "gluster://server/vol/img",
        .backingMeta = {
          .path = "gluster://server/vol/img",
          .canonPath = "gluster://server/vol/img",
          .type = VIR_STORAGE_TYPE_NETWORK,
          .format = VIR_STORAGE_FILE_RAW,
          .backingStoreRaw = NULL,
          .backingMeta = NULL,
        }
      }
      
      or, for the second file, maybe also allowing:
      { .path = "two",
        .canonPath = "/path/to/two",
        .type = VIR_STORAGE_TYPE_FILE,
        .format = VIR_STORAGE_FILE_QCOW2,
        .backingStoreRaw = "missing",
        .backingMeta = {
          .path = "missing",
          .canonPath = NULL,
          .type = VIR_STORAGE_TYPE_NONE,
          .format = VIR_STORAGE_FILE_NONE,
          .backingStoreRaw = NULL,
          .backingMeta = NULL,
        }
      }
      
      * src/util/virstoragefile.h (_virStorageFileMetadata): Add
      path, canonPath, relDir, type, and format fields.  Reorder
      existing fields, and add lots of comments.
      * src/util/virstoragefile.c (virStorageFileFreeMetadata): Clean
      new fields.
      (virStorageFileGetMetadataInternal)
      (virStorageFileGetMetadataFromFDInternal): Start populating new
      fields.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5976a9ac
    • P
      storage: Refactor location of metadata for storage drive access to files · cecd6566
      Peter Krempa 提交于
      Now that we store all metadata about a storage image in a
      virStorageSource struct let's use it also to store information needed by
      the storage driver to access and do operations on the files.
      cecd6566
    • P
      conf: Refactor helpers to retrieve actual storage type · 93c1f2cd
      Peter Krempa 提交于
      Now that the storage source definition is uniform convert the helpers to
      retrieve the actual storage type to a single one.
      93c1f2cd
  18. 08 4月, 2014 1 次提交
    • E
      conf: avoid memleak on NULL path · 87333039
      Eric Blake 提交于
      I noticed that the apparmor code could request metadata even
      for a cdrom with no media, which would cause a memory leak of
      the hash table used to look for loops in the backing chain.
      But even before that, we blindly dereferenced the path for
      printing a debug statement, so it is just better to enforce
      that this is only used on non-NULL names.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadata): Assume
      non-NULL path.
      * src/util/virstoragefile.h: Annotate this.
      * src/security/virt-aa-helper.c (get_files): Fix caller.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      87333039