1. 03 9月, 2011 31 次提交
    • E
      snapshot: correctly escape generated xml · 8352e04d
      Eric Blake 提交于
      Commit 69278878 fixed one direction of arbitrarily-named snapshots,
      but not the round trip path.  While auditing domain_conf, I found
      a couple other instances that weren't escaping arbitrary strings.
      
      * src/conf/domain_conf.c (virDomainFSDefFormat)
      (virDomainGraphicsListenDefFormat, virDomainSnapshotDefFormat):
      Escape arbitrary strings.
      8352e04d
    • E
      snapshot: allow full domain xml in snapshot · f609cb85
      Eric Blake 提交于
      Just like VM saved state images (virsh save), snapshots MUST
      track the inactive domain xml to detect any ABI incompatibilities.
      
      The indentation is not perfect, but functionality comes before form.
      
      Later patches will actually supply a full domain; for now, this
      wires up the storage to support one, but doesn't ever generate one
      in dumpxml output.
      
      Happily, libvirt.c was already rejecting use of VIR_DOMAIN_XML_SECURE
      from read-only connections, even though before this patch, there was
      no information to be secured by the use of that flag.
      
      And while we're at it, mark the libvirt snapshot metadata files
      as internal-use only.
      
      * src/libvirt.c (virDomainSnapshotGetXMLDesc): Document flag.
      * src/conf/domain_conf.h (_virDomainSnapshotDef): Add member.
      (virDomainSnapshotDefParseString, virDomainSnapshotDefFormat):
      Update signature.
      * src/conf/domain_conf.c (virDomainSnapshotDefFree): Clean up.
      (virDomainSnapshotDefParseString): Optionally parse domain.
      (virDomainSnapshotDefFormat): Output full domain.
      * src/esx/esx_driver.c (esxDomainSnapshotCreateXML)
      (esxDomainSnapshotGetXMLDesc): Update callers.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotCreateXML)
      (vboxDomainSnapshotGetXMLDesc): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML)
      (qemuDomainSnapshotLoad, qemuDomainSnapshotGetXMLDesc)
      (qemuDomainSnapshotWriteMetadata): Likewise.
      * docs/formatsnapshot.html.in: Rework doc example.
      Based on a patch by Philipp Hahn.
      f609cb85
    • E
      snapshot: refactor domain xml output · 0ce68c66
      Eric Blake 提交于
      Minor semantic change - allow domain xml to be generated in place
      within a larger buffer, rather than having to go through a
      temporary string.
      
      * src/conf/domain_conf.c (virDomainDefFormatInternal): Add
      parameter.
      (virDomainDefFormat, virDomainObjFormat): Update callers.
      0ce68c66
    • E
      snapshot: prevent migration from stranding snapshot data · e2fb96d9
      Eric Blake 提交于
      Migration is another case of stranding metadata.  And since
      snapshot metadata is arbitrarily large, there's no way to
      shoehorn it into the migration cookie of migration v3.
      
      This patch consolidates two existing locations for migration
      validation into one helper function, then enhances that function
      to also do the new checks.  If we could always trust the source
      to validate migration, then the destination would not have to
      do anything; but since older servers that did not do checking
      can migrate to newer destinations, we have to repeat some of
      the same checks on the destination; meanwhile, we want to
      detect failures as soon as possible.  With migration v2, this
      means that validation will reject things at Prepare on the
      destination if the XML exposes the problem, otherwise at Perform
      on the source; with migration v3, this means that validation
      will reject things at Begin on the source, or if the source
      is old and the XML exposes the problem, then at Prepare on the
      destination.
      
      This patch is necessarily over-strict.  Once a later patch
      properly handles auto-cleanup of snapshot metadata on the
      death of a transient domain, then the only time we actually
      need snapshots to prevent migration is when using the
      --undefinesource flag on a persistent source domain.
      
      It is possible to recreate snapshot metadata on the destination
      with VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and
      VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT.  But for now, that is limited,
      since if we delete the snapshot metadata prior to migration,
      then we won't know the name of the current snapshot to pass
      along; and if we delete the snapshot metadata after migration
      and use the v3 migration cookie to pass along the name of the
      current snapshot, then we need a way to bypass the fact that
      this patch refuses migration with snapshot metadata present.
      
      So eventually, we may have to introduce migration protocol v4
      that allows feature negotiation and an arbitrary number of
      handshake exchanges, so as to pass as many rpc calls as needed
      to transfer all the snapshot xml hierarchy.
      
      But all of that is thoughts for the future; for now, the best
      course of action is to quit early, rather than get into a
      funky state of stale metadata; then relax restrictions later.
      
      * src/qemu/qemu_migration.h (qemuMigrationIsAllowed): Make static.
      * src/qemu/qemu_migration.c (qemuMigrationIsAllowed): Alter
      signature, and allow checks for both outgoing and incoming.
      (qemuMigrationBegin, qemuMigrationPrepareAny)
      (qemuMigrationPerformJob): Update callers.
      e2fb96d9
    • E
      snapshot: support new undefine flags in qemu · 19f8c980
      Eric Blake 提交于
      A nice benefit of deleting all snapshots at undefine time is that
      you don't have to do any reparenting or subtree identification - since
      everything goes, this is an O(n) process, whereas using multiple
      virDomainSnapshotDelete calls would be O(n^2) or worse.  But it is
      only doable for snapshot metadata, where we are in control of the
      data being deleted; for the actual snapshots, there's too much
      likelihood of something going wrong, and requiring even more API
      calls to figure out what failed in the meantime, so callers are
      better off deleting the snapshot data themselves one snapshot at
      a time where they can deal with failures as they happen.
      
      * src/qemu/qemu_driver.c (qemuDomainUndefineFlags): Honor new flags.
      19f8c980
    • E
      snapshot: cache qemu-img location · 3881a470
      Eric Blake 提交于
      As more clients start to want to know this information, doing
      a PATH stat walk and malloc for every client adds up.
      
      We are only caching the location, not the capabilities, so even
      if qemu-img is updated in the meantime, it will still probably
      live in the same location.  So there is no need to worry about
      clearing this particular cache.
      
      * src/qemu/qemu_conf.h (qemud_driver): Add member.
      * src/qemu/qemu_driver.c (qemudShutdown): Cleanup.
      (qemuFindQemuImgBinary): Add an argument, and cache result.
      (qemuDomainSnapshotForEachQcow2, qemuDomainSnapshotDiscard)
      (qemuDomainSnapshotCreateInactive, qemuDomainSnapshotRevertInactive)
      (qemuDomainSnapshotCreateXML, qemuDomainRevertToSnapshot): Update
      callers.
      3881a470
    • E
      snapshot: refactor some qemu code · 8055e5af
      Eric Blake 提交于
      Prepare for code sharing.  No semantic change.
      
      * src/qemu/qemu_driver.c (qemuFindQemuImgBinary)
      (qemuDomainSnapshotWriteMetadata)
      (qemuDomainSnapshotDiscard)
      (qemuDomainSnapshotForEachQcow2): Float up.
      (qemuDomainSnapshotDiscardDescendant): Likewise, and rename...
      (qemuDomainSnapshotDiscardAll): ...for generic use.
      (qemuDomainSnapshotDelete): Update caller.
      8055e5af
    • E
      snapshot: teach virsh about new undefine flags · e88872e9
      Eric Blake 提交于
      Similar to 'undefine --managed-save' (commit 83e849c1), we must
      assume that the old API is unsafe; however, we cannot emulate
      metadata-only deletion on older servers.  Additionally, we have
      the wrinkle that while virDomainUndefineFlags and managed save
      cleanup were introduced in 0.9.4, it wasn't until 0.9.5 that
      snapshots block undefine of a domain.  Do the best we can given
      the server we are talking to.
      
      * tools/virsh.c (cmdUndefine): Add --snapshots-metadata flag.
      * tools/virsh.pod (undefine, destroy, shutdown): Document effect
      of snapshots.
      e88872e9
    • E
      snapshot: prevent stranding snapshot data on domain destruction · 282fe1f0
      Eric Blake 提交于
      Just as leaving managed save metadata behind can cause problems
      when creating a new domain that happens to collide with the name
      of the just-deleted domain, the same is true of leaving any
      snapshot metadata behind.  For safety sake, extend the semantic
      change of commit b26a9fa9 to also cover snapshot metadata as a
      reason to reject undefining an inactive domain.  A future patch
      will make sure that shutdown of a transient domain automatically
      deletes snapshot metadata (whether by destroy, shutdown, or
      guest-initiated action).  Management apps of transient domains
      should take care to capture xml of snapshots, if it is necessary
      to recreate the snapshot metadata on a later transient domain
      with the same name and uuid.
      
      This also documents a new flag that hypervisors can choose to
      support as a shortcut for taking care of the metadata as part of
      the undefine process; however, nontrivial driver support for these
      flags will be deferred to future patches.
      
      Note that ESX and VBox can never be transient; therefore, they
      do not have to worry about automatic cleanup after shutdown
      (the persistent domain still remains); likewise they never
      store snapshot metadata, so the undefine flag is trivial.
      The nontrivial work remaining is thus in the qemu driver.
      
      * include/libvirt/libvirt.h.in
      (VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA): New flag.
      * src/libvirt.c (virDomainUndefine, virDomainUndefineFlags):
      Document new limitations and flag.
      * src/esx/esx_driver.c (esxDomainUndefineFlags): Trivial
      implementation.
      * src/vbox/vbox_tmpl.c (vboxDomainUndefineFlags): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainUndefineFlags): Enforce
      the limitations.
      282fe1f0
    • E
      snapshot: add qemu snapshot redefine support · bd18b967
      Eric Blake 提交于
      Redefining a qemu snapshot requires a bit of a tweak to the common
      snapshot parsing code, but the end result is quite nice.
      
      Be careful that redefinitions do not introduce circular parent
      chains.  Also, we don't want to allow conversion between online
      and offline existing snapshots.  We could probably do some more
      validation for snapshots that don't already exist to make sure
      they are even feasible, by parsing qemu-img output, but that
      can come later.
      
      * src/conf/domain_conf.h (virDomainSnapshotParseFlags): New
      internal flags.
      * src/conf/domain_conf.c (virDomainSnapshotDefParseString): Alter
      signature to take internal flags.
      * src/esx/esx_driver.c (esxDomainSnapshotCreateXML): Update caller.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotCreateXML): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Support
      new public flags.
      bd18b967
    • E
      snapshot: add qemu snapshot creation without metadata · ece197e9
      Eric Blake 提交于
      Supporting NO_METADATA on snapshot creation is interesting - we must
      still return a valid opaque snapshot object, but the user can't get
      anything out of it (unless we add a virDomainSnapshotGetName()),
      since it is no longer registered with the domain.
      
      Also, virsh now tries to query for secure xml, in anticipation of
      when we store <domain> xml inside <domainsnapshot>; for now, we
      can trivially support it, since we have nothing secure.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateXML): Support
      new flag.
      (qemuDomainSnapshotGetXMLDesc): Trivially support VIR_DOMAIN_XML_SECURE.
      ece197e9
    • E
      snapshot: improve virsh snapshot-create, add snapshot-edit · 2b4d8deb
      Eric Blake 提交于
      Wire up the new snapshot creation flags in virsh.  For convenience,
      teach 'snapshot-current' how to make an existing snapshot become
      current (can be used after upgrading to newer libvirt to recover
      from the fact that the older libvirt lost track of the current
      snapshot after a restart).  The snapshot-create-as command is
      intentionally not taught --redefine or --current, as this would
      imply adding a lot of other options for everything else that can
      appear in the <domainsnapshot> xml, but which is normally read-only.
      Besides, redefining will usually be done on files created by
      snapshot-dumpxml, rather than something built up by hand on the
      command line.  And now that we can redefine, we can edit.
      
      * tools/virsh.c (cmdSnapshotCreate): Add --redefine, --current,
      and --no-metadata.
      (cmdSnapshotCreateAs): Add --no-metadata.
      (cmdSnapshotCurrent): Add snapshotname to alter current snapshot.
      (cmdSnapshotEdit): New command.
      * tools/virsh.pod (snapshot-create, snapshot-create-as)
      (snapshot-current, snapshot-edit):  Document these.
      2b4d8deb
    • E
      snapshot: refactor virsh snapshot creation · 90ec08ed
      Eric Blake 提交于
      The next patch will make snapshot creation more complex, so it's
      better to avoid repetition of the complexity.
      
      * tools/virsh.c (vshSnapshotCreate): New helper function.
      (cmdSnapshotCreate, cmdSnapshotCreateAs): Use it.
      90ec08ed
    • E
      snapshot: allow recreation of metadata · af65695a
      Eric Blake 提交于
      The first two flags are essential for being able to replicate
      snapshot hierarchies across multiple hosts, which will come in
      handy for supervised migrations.  It also allows a management app
      to take a snapshot of a transient domain, save the metadata, stop
      the domain, recreate a new transient domain by the same name,
      redefine the snapshot, then revert to it.
      
      This is not quite as convenient as leaving the metadata behind
      after a domain is no longer around, but doing that has a few
      problems: 1. the libvirt API can only delete snapshot metadata
      if there is a valid domain handle to use to get to that snapshot
      object - if stale data is left behind without a domain, there is
      no way to request that the data be cleaned up. 2. creating a new
      domain with the same name but different uuid than the older
      domain where a snapshot existed cannot use the older snapshot
      data; this risks confusing libvirt, and forbidding the stale
      data is similar to the recent patch to forbid stale managed save.
      
      The first two flags might be useful on hypervisors with no metadata,
      but only for modifying the notion of the current snapshot;
      however, I don't know how to do that for ESX or VBox.
      
      The third flag is a convenience option, to combine a creation with
      a delete metadata into one step.  It is trivial for hypervisors
      with no metadata.
      
      The qemu changes will be involved enough to warrant a separate patch.
      
      * include/libvirt/libvirt.h.in
      (VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE)
      (VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT)
      (VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA): New flags.
      * src/libvirt.c (virDomainSnapshotCreateXML): Document them, and
      enforce mutual exclusion.
      * src/esx/esx_driver.c (esxDomainSnapshotCreateXML): Trivial
      implementation.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotCreateXML): Likewise.
      * docs/formatsnapshot.html.in: Document re-creation.
      af65695a
    • E
      snapshot: identify qemu snapshot roots · 6b3801b0
      Eric Blake 提交于
      Filtering for roots is pretty easy to do.
      
      * src/conf/domain_conf.h (virDomainSnapshotObjListGetNames)
      (virDomainSnapshotObjListNum): Update prototype.
      * src/conf/domain_conf.c (virDomainSnapshotObjListCopyNames)
      (virDomainSnapshotObjListGetNames, virDomainSnapshotObjListCount)
      (virDomainSnapshotObjListNum): Support filtering.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotNum)
      (qemuDomainSnapshotListNames): Update callers.
      6b3801b0
    • E
      snapshot: reflect new dumpxml and list options in virsh · 22a833e7
      Eric Blake 提交于
      New flag bits are worth exposing via virsh.  In the case of
      snapshot-list --roots, it's possible to emulate this even when
      talking to an older server that lacks the bit; whereas
      --metadata requires a newer server.
      
      Although we don't use --security-info yet, the flag is already
      documented for other dumpxml operations, and turning it on now
      will make it useful when a future patch actually has to honor it.
      
      * tools/virsh.c (cmdSnapshotDumpXML, cmdSnapshotCurrent): Add
      --security-info.
      (cmdSnapshotList): Add --roots, --metadata.
      * tools/virsh.pod (snapshot-dumpxml, snapshot-current)
      (snapshot-list): Document these.
      22a833e7
    • E
      snapshot: identify which snapshots have metadata · 9f5e53e2
      Eric Blake 提交于
      To make it easier to know when undefine will fail because of existing
      snapshot metadata, we need to know how many snapshots have metadata.
      
      Also, it is handy to filter the list of snapshots to just those that
      have no parents; document that flag now, but implement it in later patches.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_SNAPSHOT_LIST_ROOTS)
      (VIR_DOMAIN_SNAPSHOT_LIST_METADATA): New flags.
      * src/libvirt.c (virDomainSnapshotNum)
      (virDomainSnapshotListNames): Document them.
      * src/esx/esx_driver.c (esxDomainSnapshotNum)
      (esxDomainSnapshotListNames): Implement trivial flag.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotNum)
      (vboxDomainSnapshotListNames): Likewise.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotNum)
      (qemuDomainSnapshotListNames): Likewise.
      9f5e53e2
    • E
      snapshot: let qemu discard only snapshot metadata · 7afa6b41
      Eric Blake 提交于
      Adding this was trivial compared to the previous patch for fixing
      qemu snapshot deletion in the first place.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotDiscard): Add
      parameter.
      (qemuDomainSnapshotDiscardDescendant, qemuDomainSnapshotDelete):
      Update callers.
      7afa6b41
    • E
      snapshot: allow deletion of just snapshot metadata · 795fe9b2
      Eric Blake 提交于
      A future patch will make it impossible to remove a domain if it
      would leave behind any libvirt-tracked metadata about snapshots,
      since stale metadata interferes with a new domain by the same name.
      But requiring snaphot contents to be deleted before removing a
      domain is harsh; with qemu, qemu-img can still make use of the
      contents after the libvirt domain is gone.  Therefore, we need
      an option to get rid of libvirt tracking information, but not
      the actual contents.  For hypervisors that do not track any
      metadata in libvirt, the implementation is trivial; all remaining
      hypervisors (really, just qemu) will be dealt with separately.
      
      * include/libvirt/libvirt.h.in
      (VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY): New flag.
      * src/libvirt.c (virDomainSnapshotDelete): Document it.
      * src/esx/esx_driver.c (esxDomainSnapshotDelete): Trivially
      supported when there is no libvirt metadata.
      * src/vbox/vbox_tmpl.c (vboxDomainSnapshotDelete): Likewise.
      795fe9b2
    • E
      snapshot: simplify acting on just children · 67555b24
      Eric Blake 提交于
      Similar to the last patch in isolating the filtering from the
      client actions, so that clients don't have to reinvent the
      filtering.
      
      * src/conf/domain_conf.h (virDomainSnapshotForEachChild): New
      prototype.
      * src/libvirt_private.syms (domain_conf.h): Export it.
      * src/conf/domain_conf.c (virDomainSnapshotActOnChild)
      (virDomainSnapshotForEachChild): New functions.
      (virDomainSnapshotCountChildren): Delete.
      (virDomainSnapshotHasChildren): Simplify.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotReparentChildren)
      (qemuDomainSnapshotDelete): Likewise.
      67555b24
    • E
      snapshot: track current domain across deletion of children · 90ea06b8
      Eric Blake 提交于
      Deleting a snapshot and all its descendants had problems with
      tracking the current snapshot.  The deletion does not necessarily
      proceed in depth-first order, so a parent could be deleted
      before a child, wreaking havoc on passing the notion of the
      current snapshot to the parent.  Furthermore, even if traversal
      were depth-first, doing multiple file writes to pass current up
      the chain one snapshot at a time is wasteful, comparing to a
      single update to the current snapshot at the end of the algorithm.
      
      * src/qemu/qemu_driver.c (snap_remove): Add field.
      (qemuDomainSnapshotDiscard): Add parameter.
      (qemuDomainSnapshotDiscardDescendant): Adjust accordingly.
      (qemuDomainSnapshotDelete): Properly reset current.
      90ea06b8
    • E
      snapshot: avoid crash when deleting qemu snapshots · cb231b4b
      Eric Blake 提交于
      This one's nasty.  Ever since we fixed virHashForEach to prevent
      nested hash iterations for safety reasons (commit fba550f6),
      virDomainSnapshotDelete with VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN
      has been broken for qemu: it deletes children, while leaving
      grandchildren intact but pointing to a no-longer-present parent.
      But even before then, the code would often appear to succeed to
      clean up grandchildren, but risked memory corruption if you have
      a large and deep hierarchy of snapshots.
      
      For acting on just children, a single virHashForEach is sufficient.
      But for acting on an entire subtree, it requires iteration; and
      since we declared recursion as invalid, we have to switch to a
      while loop.  Doing this correctly requires quite a bit of overhaul,
      so I added a new helper function to isolate the algorithm from the
      actions, so that callers do not have to reinvent the iteration.
      
      Note that this _still_ does not handle CHILDREN correctly if one
      of the children is the current snapshot; that will be next.
      
      * src/conf/domain_conf.h (_virDomainSnapshotDef): Add mark.
      (virDomainSnapshotForEachDescendant): New prototype.
      * src/libvirt_private.syms (domain_conf.h): Export it.
      * src/conf/domain_conf.c (virDomainSnapshotMarkDescendant)
      (virDomainSnapshotActOnDescendant)
      (virDomainSnapshotForEachDescendant): New functions.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotDiscardChildren):
      Replace...
      (qemuDomainSnapshotDiscardDescenent): ...with callback that
      doesn't nest hash traversal.
      (qemuDomainSnapshotDelete): Use new function.
      cb231b4b
    • E
      snapshot: speed up snapshot location · a31d6569
      Eric Blake 提交于
      Each snapshot lookup was iterating over the entire hash table, O(n),
      instead of honing in directly on the hash key, amortized O(1).
      
      Besides, fixing this means that virDomainSnapshotFindByName can now
      be used inside another virHashForeach iteration (without this patch,
      attempts to lookup a snapshot by name during a hash iteration will
      fail due to nested iteration).
      
      * src/conf/domain_conf.c (virDomainSnapshotFindByName): Simplify.
      (virDomainSnapshotObjListSearchName): Delete unused function.
      a31d6569
    • E
      snapshot: add snapshot-list --parent to virsh · d4a965c6
      Eric Blake 提交于
      Even though I recently added 'virsh snapshot-parent', doing it one
      snapshot at a time is painful, so make it possible to expand the
      snapshot-list table at once.
      
      * tools/virsh.c (cmdSnapshotList): Add --parent.
      * tools/virsh.pod (snapshot-list): Document it.
      d4a965c6
    • E
      snapshot: fine-tune qemu snapshot revert states · 7dc44eb0
      Eric Blake 提交于
      For a system checkpoint of a running or paused domain, it's fairly
      easy to honor new flags for altering which state to use after the
      revert.  For an inactive snapshot, the revert has to be done while
      there is no qemu process, so do back-to-back transitions; this also
      lets us revert to inactive snapshots even for transient domains.
      
      * src/qemu/qemu_driver.c (qemuDomainRevertToSnapshot): Support new
      flags.
      7dc44eb0
    • E
      snapshot: properly revert qemu to offline snapshots · 25fb3ef1
      Eric Blake 提交于
      Commit 5e47785b broke reverts to offline system checkpoint snapshots
      with older qemu, since there is no longer any code path to use
      qemu -loadvm on next boot.  Meanwhile, reverts to offline system
      checkpoints have been broken for newer qemu, both before and
      after that commit, since -loadvm no longer works to revert to
      disk state without accompanying vm state.  Fix both of these by
      using qemu-img to revert disk state.
      
      Meanwhile, consolidate the (now 3) clients of a qemu-img iteration
      over all disks of a VM into one function, so that any future
      algorithmic fixes to the FIXMEs in that function after partial
      loop iterations are dealt with at once.  That does mean that this
      patch doesn't handle partial reverts very well, but we're not
      making the situation any worse in this patch.
      
      * src/qemu/qemu_driver.c (qemuDomainRevertToSnapshot): Use
      qemu-img rather than 'qemu -loadvm' to revert to offline snapshot.
      (qemuDomainSnapshotRevertInactive): New helper.
      (qemuDomainSnapshotCreateInactive): Factor guts...
      (qemuDomainSnapshotForEachQcow2): ...into new helper.
      (qemuDomainSnapshotDiscard): Use it.
      25fb3ef1
    • E
      snapshot: improve reverting to qemu paused snapshots · 88fe7a4b
      Eric Blake 提交于
      If you take a checkpoint snapshot of a running domain, then pause
      qemu, then restore the snapshot, the result should be a running
      domain, but the code was leaving things paused.  Furthermore, if
      you take a checkpoint of a paused domain, then run, then restore,
      there was a brief but non-deterministic window of time where the
      domain was running rather than paused.  Fix both of these
      discrepancies by always pausing before restoring.
      
      Also, check that the VM is active every time lock is dropped
      between two monitor calls.
      
      Finally, straighten out the events that get emitted on each
      transition.
      
      * src/qemu/qemu_driver.c (qemuDomainRevertToSnapshot): Always
      pause before reversion, and improve events.
      88fe7a4b
    • E
      snapshot: fine-tune qemu saved images starting paused · 7381aaff
      Eric Blake 提交于
      Implement the new running/paused overrides for saved state management.
      
      Unfortunately, for virDomainSaveImageDefineXML, the saved state
      updates are write-only - I don't know of any way to expose a way
      to query the current run/pause setting of an existing save image
      file to the user without adding a new API or modifying the domain
      xml of virDomainSaveImageGetXMLDesc to include a new element to
      reflect the state bit encoded into the save image.  However, I
      don't think this is a show-stopper, since the API is designed to
      leave the state bit alone unless an explicit flag is used to
      change it.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal)
      (qemuDomainSaveImageOpen): Adjust signature.
      (qemuDomainSaveFlags, qemuDomainManagedSave)
      (qemuDomainRestoreFlags, qemuDomainSaveImageGetXMLDesc)
      (qemuDomainSaveImageDefineXML, qemuDomainObjRestore): Adjust
      callers.
      7381aaff
    • E
      snapshot: expose --running and --paused in virsh · 42c52d53
      Eric Blake 提交于
      Pretty straight-forward exposure of new flags.  For most commands,
      we let the API reject mutually exclusive flags; but for save-image-edit,
      we do the sanity check ourselves to avoid looping on flag failure if
      the edit cycle is ever enhanced to allow the user to retry an edit
      to fix up an xml validation error.
      
      * tools/virsh.c (cmdManagedSave, cmdRestore, cmdSave)
      (cmdSaveImageDefine, cmdSaveImageEdit): Add new flags.
      * tools/virsh.pod (managedsave, restore, save, save-image-define)
      (save-image-edit): Document them.
      42c52d53
    • E
      snapshot: fine-tune ability to start paused · 3cff66f4
      Eric Blake 提交于
      While it is nice that snapshots and saved images remember whether
      the domain was running or paused, sometimes the restoration phase
      wants to guarantee a particular state (paused to allow hot-plugging,
      or running without needing to call resume).  This introduces new
      flags to allow the control, and a later patch will implement the
      flags for qemu.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_SAVE_RUNNING)
      (VIR_DOMAIN_SAVE_PAUSED, VIR_DOMAIN_SNAPSHOT_REVERT_RUNNING)
      (VIR_DOMAIN_SNAPSHOT_REVERT_PAUSED): New flags.
      * src/libvirt.c (virDomainSaveFlags, virDomainRestoreFlags)
      (virDomainManagedSave, virDomainSaveImageDefineXML)
      (virDomainRevertToSnapshot): Document their use, and enforce
      mutual exclusion.
      3cff66f4
    • E
      snapshot: better events when starting paused · c1ff5dc6
      Eric Blake 提交于
      There are two classes of management apps that track events - one
      that only cares about on/off (and only needs to track EVENT_STARTED
      and EVENT_STOPPED), and one that cares about paused/running (also
      tracks EVENT_SUSPENDED/EVENT_RESUMED).  To keep both classes happy,
      any transition that can go from inactive to paused must emit two
      back-to-back events - one for started and one for suspended (since
      later resuming of the domain will only send RESUMED, but the first
      class isn't tracking that).
      
      This also fixes a bug where virDomainCreateWithFlags with the
      VIR_DOMAIN_START_PAUSED flag failed to start paused when restoring
      from a managed save image.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_EVENT_SUSPENDED_RESTORED)
      (VIR_DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT)
      (VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT): New sub-events.
      * src/qemu/qemu_driver.c (qemuDomainRevertToSnapshot): Use them.
      (qemuDomainSaveImageStartVM): Likewise, and add parameter.
      (qemudDomainCreate, qemuDomainObjStart): Send suspended event when
      starting paused.
      (qemuDomainObjRestore): Add parameter.
      (qemuDomainObjStart, qemuDomainRestoreFlags): Update callers.
      * examples/domain-events/events-c/event-test.c
      (eventDetailToString): Map new detail strings.
      c1ff5dc6
  2. 02 9月, 2011 9 次提交