1. 11 4月, 2014 2 次提交
    • 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
    • E
      conf: provide details on network backing store · 7010768c
      Eric Blake 提交于
      So far, my work has been merely preserving the status quo of
      backing file analysis.  But this patch starts to tread in the
      territory of making the backing chain code more powerful - we
      will eventually support network storage containing non-raw
      formats.  Here, we expose metadata information about a network
      backing store, even if that information is still hardcoded to
      a raw format for now.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataRecurse):
      Also populate struct for non-file backing.
      (virStorageFileGetMetadata, virStorageFileGetMetadatainternal):
      Recognize non-file top image.
      (virFindBackingFile): Add comment.
      (virStorageFileChainGetBroken): Adjust comment, ensure output
      is set.
      * tests/virstoragetest.c (mymain): Update test to reflect it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7010768c
  2. 09 4月, 2014 5 次提交
    • 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
    • E
      conf: earlier allocation during backing chain crawl · 43f85b99
      Eric Blake 提交于
      Right now, we are allocating virStorageFileMetadata near the bottom
      of the callchain, only after we have identified that we are visiting
      a file (and not a network resource).  I'm hoping to eventually
      support parsing the backing chain from XML, where the backing chain
      crawl then validates what was parsed rather than allocating a fresh
      structure.  Likewise, I'm working towards a setup where we have a
      backing element even for networks.  Both of these use cases are
      easier to code if the allocation is hoisted earlier.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
      (virStorageFileGetMetadataFromFDInternal): Change signature.
      (virStorageFileGetMetadataFromBuf)
      (virStorageFileGetMetadataRecurse, virStorageFileGetMetadata):
      Update callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      43f85b99
    • E
      conf: track user vs. canonical name through full chain lookup · 79f11b35
      Eric Blake 提交于
      The previous patch started a separation of error messages
      reported against the user-specified name, vs. tracking the
      canonical path that was actually opened.  This patch extends
      that notion, by hoisting directory detection up front, passing
      the canonical path through the entire call chain, and
      simplifying lower-level functions that can now assume that
      a canonical path and directory have been supplied.
      
      * src/util/virstoragefile.c
      (virStorageFileGetMetadataFromFDInternal)
      (virStorageFileGetMetadataInternal): Add parameter, require
      directory.
      (virFindBackingFile): Require directory.
      (virStorageFileGetMetadataFromFD): Pass canonical path.
      (virStorageFileGetMetadataFromBuf): Likewise.
      (virStorageFileGetMetadata): Determine initial directory.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      79f11b35
    • 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
    • E
      conf: fix detection of infinite backing loop · af095bfa
      Eric Blake 提交于
      While trying to refactor the backing file chain, I noticed that
      if you have a self-referential qcow2 file via a relative name:
      
      qemu-img create -f qcow2 loop 10M
      qemu-img rebase -u -f qcow2 -F qcow2 -b loop loop
      
      then libvirt was creating a chain 2 deep before realizing it
      had hit a loop; furthermore, virStorageFileChainCheckBroken
      was not identifying the chain as broken.  With this patch,
      the loop is detected when the chain is only 1 deep; still
      enough for storage volume XML to display the file, but now
      with a proper error report about where the loop was found.
      
      This patch adds a parameter to virStorageFileGetMetadataRecurse,
      so that errors at the top of the chain remain unchanged; messages
      issued for backing files now use the name provided by the user
      instead of the canonical name (for VDSM, which uses relative
      symlinks to device mapper block devices, this is actually more
      useful).
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataRecurse):
      Add parameter, require canonical path up front.  Mark chain
      broken on OOM or loop detection.
      (virStorageFileGetMetadata): Pass in canonical name.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      af095bfa
  3. 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
  4. 05 4月, 2014 1 次提交
    • E
      conf: track when storage type is still undetermined · 9673418c
      Eric Blake 提交于
      Right now, virStorageFileMetadata tracks bool backingStoreIsFile
      for whether the backing string specified in metadata can be
      resolved as a file (covering both block and regular file
      resources) or is treated as a network protocol.  But when
      merging this struct with virStorageSource, it will be easier
      to just actually track which type of resource it is, as well
      as have a reserved value for the case where the resource type
      is unknown (or had an error during probing).
      
      * src/util/virstoragefile.h (virStorageType): Add a placeholder
      value, swap order to match similar public enum.
      * src/util/virstoragefile.c (virStorage): Update string mapping.
      * src/conf/domain_conf.c (virDomainDiskSourceParse)
      (virDomainDiskDefParseXML, virDomainDiskDefFormat)
      (virDomainDiskSourceFormat): Adjust clients.
      * src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML):
      Likewise.
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotPrepareDiskExternalBackingInactive)
      (qemuDomainSnapshotPrepareDiskExternalOverlayActive)
      (qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
      (qemuDomainSnapshotPrepareDiskInternal)
      (qemuDomainSnapshotCreateSingleDiskActive): Likewise.
      * src/qemu/qemu_command.c (qemuGetDriveSourceString): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      9673418c
  5. 02 4月, 2014 8 次提交
    • E
      conf: modify tracking of encrypted images · 2279d560
      Eric Blake 提交于
      A future patch will merge virStorageFileMetadata and virStorageSource,
      but I found it easier to do if both structs use the same information
      for tracking whether a source file needs encryption keys.
      
      * src/util/virstoragefile.h (_virStorageFileMetadata): Prepare
      full encryption struct instead of just a bool.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Use transfer semantics.
      * src/storage/storage_backend_gluster.c
      (virStorageBackendGlusterRefreshVol): Likewise.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
      Populate struct.
      (virStorageFileFreeMetadata): Adjust clients.
      * tests/virstoragetest.c (testStorageChain): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2279d560
    • E
      conf: move volume structs to util/ · 2a4fd228
      Eric Blake 提交于
      Another step towards unification of structures.  While we might
      not expose everything in XML via domain disk as we do for
      storage volume pointer, both places want to deal with (at least
      part of) the backing chain; therefore, moving towards a single
      struct usable from both contexts will make the backing chain
      code more reusable.
      
      * src/conf/storage_conf.h (_virStoragePerms)
      (virStorageTimestamps): Move...
      * src/util/virstoragefile.h: ...here.
      (_virStorageSource): Add more fields.
      * src/util/virstoragefile.c (virStorageSourceClear): Clean
      additional fields.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      2a4fd228
    • E
      conf: move common disk source functions · 7a4fd22b
      Eric Blake 提交于
      Move some functions out of domain_conf for use in the next
      patch where snapshot starts to directly use structs in
      virstoragefile.
      
      * src/conf/domain_conf.c (virDomainDiskDefFree)
      (virDomainDiskSourcePoolDefParse): Adjust callers.
      (virDomainDiskSourceDefClear, virDomainDiskSourcePoolDefFree)
      (virDomainDiskAuthClear): Move...
      * src/util/virstoragefile.c (virStorageSourceClear)
      (virStorageSourcePoolDefFree, virStorageSourceAuthClear): ...and
      rename.
      * src/conf/domain_conf.h (virDomainDiskAuthClear): Drop
      declaration.
      * src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Adjust
      caller.
      * src/util/virstoragefile.h: Declare them.
      * src/libvirt_private.syms (virstoragefile.h): Export them.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7a4fd22b
    • E
      util: move detection of shared filesystems · 5160ab79
      Eric Blake 提交于
      The code in virstoragefile.c is getting more complex as I
      consolidate backing chain handling code.  But for the setuid
      virt-login-shell, we don't need to crawl backing chains.  It's
      easier to audit things for setuid security if there are fewer
      files involved, so this patch moves the one function that
      virFileOpen() was actually relying on to also live in virfile.c.
      
      * src/util/virstoragefile.c (virStorageFileIsSharedFS)
      (virStorageFileIsSharedFSType): Move...
      * src/util/virfile.c (virFileIsSharedFS, virFileIsSharedFSType):
      ...to here, and rename.
      (virFileOpenAs): Update caller.
      * src/security/security_selinux.c
      (virSecuritySELinuxSetFileconHelper)
      (virSecuritySELinuxSetSecurityAllLabel)
      (virSecuritySELinuxRestoreSecurityImageLabelInt): Likewise.
      * src/security/security_dac.c
      (virSecurityDACRestoreSecurityImageLabelInt): Likewise.
      * src/qemu/qemu_driver.c (qemuOpenFileAs): Likewise.
      * src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
      * src/util/virstoragefile.h: Adjust declarations.
      * src/util/virfile.h: Likewise.
      * src/libvirt_private.syms (virfile.h, virstoragefile.h): Move
      symbols as appropriate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5160ab79
    • E
      conf: move source pool type to util/ · b6edf2bf
      Eric Blake 提交于
      Another struct being moved to util.  This one doesn't have as
      much use yet, thankfully.
      
      * src/conf/domain_conf.h (virDomainDiskSourcePoolMode)
      (virDomainDiskSourcePoolDef): Move...
      * src/util/virstoragefile.h (virStorageSourcePoolMode)
      (virStorageSourcePoolDef): ...and rename.
      * src/conf/domain_conf.c (virDomainDiskSourcePoolDefFree)
      (virDomainDiskSourceDefClear, virDomainDiskSourcePoolDefParse)
      (virDomainDiskDefParseXML, virDomainDiskSourceDefParse)
      (virDomainDiskSourceDefFormatInternal)
      (virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
      Adjust clients.
      * src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Likewise.
      * src/libvirt_private.syms (domain_conf.h): Move symbols...
      (virstoragefile.h): ...as appropriate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b6edf2bf
    • E
      conf: move network disk protocol type to util/ · 4220f76a
      Eric Blake 提交于
      Another enum moved to util/, this time the fallout from renaming
      is not quite as large.
      
      * src/conf/domain_conf.h (virDomainDiskProtocol): Move...
      * src/util/virstoragefile.h (virStorageNetProtocol): ...and
      rename.
      * src/conf/domain_conf.c: Update clients.
      * src/qemu/qemu_command.c: Likewise.
      * src/qemu/qemu_conf.c: Likewise.
      * src/qemu/qemu_driver.c: Likewise.
      * src/qemu/qemu_migration.c: Likewise.
      * src/storage/storage_backend.c: Likewise.
      * src/storage/storage_backend_gluster.c: Likewise.
      * src/libvirt_private.syms (domain_conf.h): Move symbols...
      (virstoragefile.h): ...as appropriate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      4220f76a
    • E
      conf: move host disk type to util/ · 16ac4c9d
      Eric Blake 提交于
      A continuation of the migration of disk details to virstoragefile.
      This patch moves a single enum, but converting the name has quite
      a bit of fallout.
      
      * src/conf/domain_conf.h (virDomainDiskType): Move...
      * src/util/virstoragefile.h (virStorageType): ...and rename.
      * src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
      (virBhyveProcessBuildLoadCmd): Update clients.
      * src/conf/domain_conf.c (virDomainDiskSourceDefParse)
      (virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
      (virDomainDiskDefFormat, virDomainDiskGetActualType)
      (virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
      Likewise.
      * src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
      * src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
      (virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
      Likewise.
      * src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
      (esxDomainDefineXML): Likewise.
      * src/locking/domain_lock.c (virDomainLockManagerAddDisk):
      Likewise.
      * src/lxc/lxc_controller.c
      (virLXCControllerSetupLoopDeviceDisk)
      (virLXCControllerSetupNBDDeviceDisk)
      (virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
      Likewise.
      * src/parallels/parallels_driver.c (parallelsGetHddInfo):
      Likewise.
      * src/phyp/phyp_driver.c (phypDiskType): Likewise.
      * src/qemu/qemu_command.c (qemuGetDriveSourceString)
      (qemuDomainDiskGetSourceString, qemuBuildDriveStr)
      (qemuBuildCommandLine, qemuParseCommandLineDisk)
      (qemuParseCommandLine): Likewise.
      * src/qemu/qemu_conf.c (qemuCheckSharedDevice)
      (qemuTranslateDiskSourcePool)
      (qemuTranslateSnapshotDiskSourcePool): Likewise.
      * src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
      (qemuDomainDetermineDiskChain): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
      (qemuDomainSnapshotPrepareDiskExternalBackingInactive)
      (qemuDomainSnapshotPrepareDiskExternalBackingActive)
      (qemuDomainSnapshotPrepareDiskExternalOverlayActive)
      (qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
      (qemuDomainSnapshotPrepareDiskInternal)
      (qemuDomainSnapshotPrepare)
      (qemuDomainSnapshotCreateSingleDiskActive): Likewise.
      * src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
      Likewise.
      * src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
      * src/security/security_apparmor.c
      (AppArmorRestoreSecurityImageLabel)
      (AppArmorSetSecurityImageLabel): Likewise.
      * src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
      (virSecurityDACRestoreSecurityImageLabelInt)
      (virSecurityDACSetSecurityAllLabel): Likewise.
      * src/security/security_selinux.c
      (virSecuritySELinuxRestoreSecurityImageLabelInt)
      (virSecuritySELinuxSetSecurityImageLabel)
      (virSecuritySELinuxSetSecurityAllLabel): Likewise.
      * src/storage/storage_backend.c (virStorageFileBackendForType):
      Likewise.
      * src/storage/storage_backend_fs.c (virStorageFileBackendFile)
      (virStorageFileBackendBlock): Likewise.
      * src/storage/storage_backend_gluster.c
      (virStorageFileBackendGluster): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
      (vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
      * src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
      * src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
      (virVMXFormatFloppy): Likewise.
      * src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
      (xenFormatSxprDisk): Likewise.
      * src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
      * tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
      Likewise.
      * src/libvirt_private.syms (domain_conf.h): Move symbols...
      (virstoragefile.h): ...as appropriate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      16ac4c9d
    • E
      conf: split network host structs to util/ · 52fb5311
      Eric Blake 提交于
      Continuing the refactoring of host-side storage descriptions out
      of conf/domain_conf and into util/virstoragefile, this patch
      focuses on details about a host name/port/transport as used by
      a network storage volume.
      
      * src/conf/domain_conf.h (virDomainDiskProtocolTransport)
      (virDomainDiskHostDef, virDomainDiskHostDefClear)
      (virDomainDiskHostDefFree, virDomainDiskHostDefCopy): Move...
      * src/util/virstoragefile.h (virStorageNetHostTransport)
      (virStorageNetHostDef, virStorageNetHostDefClear)
      (virStorageNetHostDefFree, virStorageNetHostDefCopy): ...here,
      with better names.
      * src/util/virstoragefile.c (virStorageNetHostDefClear)
      (virStorageNetHostDefFree, virStorageNetHostDefCopy): Moved from...
      * src/conf/domain_conf.c (virDomainDiskHostDefClear)
      (virDomainDiskHostDefFree, virDomainDiskHostDefCopy): ...here.
      (virDomainDiskSourceDefClear, virDomainDiskSourceDefParse)
      (virDomainDiskSourceDefFormatInternal): Adjust callers.
      * src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
      * src/conf/snapshot_conf.c (virDomainSnapshotDiskDefClear):
      Likewise.
      * src/qemu/qemu_command.c (qemuAddRBDHost)
      (qemuParseDriveURIString, qemuParseNBDString)
      (qemuBuildNetworkDriveURI, qemuParseCommandLineDisk)
      (qemuParseCommandLine, qemuGetDriveSourceString): Likewise.
      * src/qemu/qemu_command.h: Likewise.
      * src/qemu/qemu_conf.c (qemuAddISCSIPoolSourceHost)
      (qemuTranslateDiskSourcePool): Likewise.
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotCreateSingleDiskActive)
      (qemuDomainSnapshotUndoSingleDiskActive): Likewise.
      * src/storage/storage_backend_gluster.c
      (virStorageFileBackendGlusterInit): Likewise.
      * src/storage/storage_driver.c (virStorageFileFree)
      (virStorageFileInitInternal): Likewise.
      * src/storage/storage_driver.h (_virStorageFile): Likewise.
      * src/libvirt_private.syms (domain_conf.h): Move symbols...
      (virstoragefile.h): ...as appropriate.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      52fb5311
  6. 31 3月, 2014 1 次提交
    • P
      util: storagefile: Don't pursue backing chain of NULL image · 6c312b0d
      Peter Krempa 提交于
      When virStorageFileGetMetadata is called with NULL path argument, the
      invalid pointer boils down through the recursive worker and is caught by
      virHashAddEntry which is thankfully resistant to NULL arguments. As it
      doesn't make sense to pursue backing chains of NULL volumes, exit
      earlier.
      
      This was noticed in the virt-aahelper-test with a slightly modified
      codebase.
      6c312b0d
  7. 25 3月, 2014 1 次提交
  8. 18 3月, 2014 1 次提交
  9. 07 11月, 2013 4 次提交
    • E
      storage: always probe type with buffer · 348b4e25
      Eric Blake 提交于
      This gets rid of another stat() per volume, as well as cutting
      bytes read in half, when populating the volumes of a directory
      pool during a pool refresh.  Not to mention that it provides an
      interface that can let gluster pools also probe file types.
      
      * src/util/virstoragefile.h (virStorageFileProbeFormatFromFD):
      Delete.
      (virStorageFileProbeFormatFromBuf): New prototype.
      (VIR_STORAGE_MAX_HEADER): New constant, based on...
      * src/util/virstoragefile.c (STORAGE_MAX_HEAD): ...old name.
      (vmdk4GetBackingStore, virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormat): Adjust clients.
      (virStorageFileProbeFormatFromFD): Delete.
      (virStorageFileProbeFormatFromBuf): Export.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Adjust client.
      * src/libvirt_private.syms (virstoragefile.h): Adjust exports.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      348b4e25
    • E
      storage: refactor backing chain division of labor · 3ead2e7d
      Eric Blake 提交于
      Future patches will want to learn metadata about a file using
      a buffer that was already parsed in order to probe the file's
      format.  Rather than reopening and re-reading the file, it makes
      sense to separate getting file contents from actually parsing
      those contents.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf)
      (virStorageFileGetMetadataFromFDInternal): New functions.
      (virStorageFileGetMetadataInternal): Hoist fstat() and read() into
      callers.
      (virStorageFileGetMetadataFromFD)
      (virStorageFileGetMetadataRecurse): Rework clients.
      * src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
      New prototype.
      * src/libvirt_private.syms (virstoragefile.h): Export it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      3ead2e7d
    • E
      storage: avoid short reads while chasing backing chain · 5327fad4
      Eric Blake 提交于
      Our backing file chain code was not very robust to an ill-timed
      EINTR, which could lead to a short read causing us to randomly
      treat metadata differently than usual.  But the existing
      virFileReadLimFD forces an error if we don't read the entire
      file, even though we only care about the header of the file.
      So add a new virFile function that does what we want.
      
      * src/util/virfile.h (virFileReadHeaderFD): New prototype.
      * src/util/virfile.c (virFileReadHeaderFD): New function.
      * src/libvirt_private.syms (virfile.h): Export it.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormatFromFD): Use it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5327fad4
    • E
      storage: use simpler 'char *' · 5717ee6a
      Eric Blake 提交于
      'unsigned char *' makes sense if you are doing math on bytes and
      don't want to worry about wraparound from a signed 'char'; but
      since all we are doing is memcmp() or virReadBufInt*[LB]E(), which
      are both safe on either type of char, and since read() prefers to
      operate on 'char *', it's simpler to avoid casts by just typing
      things as 'char *' from the get-go.  [Technically, read can
      operate on an 'unsigned char *' thanks to the C rule that any
      pointer can be implicitly converted to 'char *' for legacy K&R
      compatibility; but where this patch saves us is if we try to use
      virfile.h functions that take 'char **' in order to allocate the
      buffer, where the compiler would barf on type mismatch.]
      
      * src/util/virstoragefile.c (FileTypeInfo): Avoid unsigned char.
      (cowGetBackingStore, qcow2GetBackingStoreFormat)
      (qcowXGetBackingStore, qcow1GetBackingStore)
      (qcow2GetBackingStore, vmdk4GetBackingStore, qedGetBackingStore)
      (virStorageFileMatchesMagic, virStorageFileMatchesVersion)
      (virStorageFileProbeFormatFromBuf, qcow2GetFeatures)
      (virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormatFromFD): Simplify clients.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5717ee6a
  10. 05 11月, 2013 1 次提交
  11. 21 10月, 2013 1 次提交
  12. 01 10月, 2013 1 次提交
    • L
      util: recognize SMB/CIFS filesystems as shared · e4e73337
      Laine Stump 提交于
      This should resolve:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1012085
      
      libvirt previously recognized NFS, GFS2, OCFS2, and AFS filesystems as
      "shared", and thus eligible for exceptions to certain rules/actions
      about chowning image files before handing them off to a guest. This
      patch widens the definition of "shared filesystem" to include SMB and
      CIFS filesystems (aka "Windows file sharing"); both of these use the
      same protocol, but different drivers so there are different magic
      numbers for each.
      e4e73337
  13. 01 8月, 2013 1 次提交
    • G
      qemu: add helper functions for diskchain checking · d7b7aa2c
      Guannan Ren 提交于
      *src/util/virstoragefile.c: Add a helper function to get
      the first name of missing backing files, if the name is NULL,
      it means the diskchain is not broken.
      *src/qemu/qemu_domain.c: qemuDiskChainCheckBroken(disk) to
      check if its chain is broken
      d7b7aa2c
  14. 11 7月, 2013 1 次提交
  15. 10 7月, 2013 2 次提交
  16. 21 6月, 2013 1 次提交
    • J
      util: add support for qcow2v3 image detection · a1ee8e18
      Ján Tomko 提交于
      Detect qcow2 images with version 3 in the image header as
      VIR_STORAGE_FILE_QCOW2.
      
      These images have a feature bitfield, with just one feature supported
      so far: lazy_refcounts.
      
      The header length changed too, moving the location of the backing
      format name.
      a1ee8e18
  17. 10 6月, 2013 1 次提交
  18. 06 6月, 2013 1 次提交
  19. 05 6月, 2013 1 次提交
    • O
      storage: Support preallocate the new capacity for vol-resize · aa2a4cff
      Osier Yang 提交于
      The document for "vol-resize" says the new capacity will be sparse
      unless "--allocate" is specified, however, the "--allocate" flag
      is never implemented. This implements the "--allocate" flag for
      fs backend's raw type volume, based on posix_fallocate and the
      syscall SYS_fallocate.
      aa2a4cff
  20. 24 5月, 2013 1 次提交
  21. 21 5月, 2013 1 次提交
  22. 11 5月, 2013 1 次提交
    • L
      util: fix virFileOpenAs return value and resulting error logs · a2c1bedb
      Laine Stump 提交于
      This resolves:
      
           https://bugzilla.redhat.com/show_bug.cgi?id=851411
           https://bugzilla.redhat.com/show_bug.cgi?id=955500
      
      The first problem was that virFileOpenAs was returning fd (-1) in one
      of the error cases rather than ret (-errno), so the caller thought
      that the error was EPERM rather than ENOENT.
      
      The second problem was that some log messages in the general purpose
      qemuOpenFile() function would always say "Failed to create" even if
      the caller hadn't included O_CREAT (i.e. they were trying to open an
      existing file).
      
      This fixes virFileOpenAs to jump down to the error return (which
      returns ret instead of fd) in the previously mentioned incorrect
      failure case of virFileOpenAs(), removes all error logging from
      virFileOpenAs() (since the callers report it), and modifies
      qemuOpenFile to appropriately use "open" or "create" in its log
      messages.
      
      NB: I seriously considered removing logging from all callers of
      virFileOpenAs(), but there is at least one case where the caller
      doesn't want virFileOpenAs() to log any errors, because it's just
      going to try again (qemuOpenFile()). We can't simply make a silent
      variation of virFileOpenAs() though, because qemuOpenFile() can't make
      the decision about whether or not it wants to retry until after
      virFileOpenAs() has already returned an error code.
      
      Likewise, I also considered changing virFileOpenAs() to return -1 with
      errno set on return, and may still do that, but only as a separate
      patch, as it obscures the intent of this patch too much.
      a2c1bedb
  23. 02 5月, 2013 1 次提交
    • M
      virutil: Move string related functions to virstring.c · 7c9a2d88
      Michal Privoznik 提交于
      The source code base needs to be adapted as well. Some files
      include virutil.h just for the string related functions (here,
      the include is substituted to match the new file), some include
      virutil.h without any need (here, the include is removed), and
      some require both.
      7c9a2d88
  24. 14 3月, 2013 1 次提交