1. 18 7月, 2019 1 次提交
  2. 13 7月, 2019 1 次提交
  3. 11 7月, 2019 1 次提交
  4. 09 5月, 2019 4 次提交
  5. 07 5月, 2019 1 次提交
    • E
      conf: Add parameter to virDomainDiskSourceFormat · 1ec3e397
      Eric Blake 提交于
      Commits 4bc42986 and 218c81ea removed virDomainStorageSourceFormat on
      the grounds that there were no external callers; however, the upcoming
      backup code wants to output a <target> (push mode) or <scratch> (pull
      mode) element that is in all other respects identical to a domain's
      <source> element, where the previous virDomainStorageSourceFormat fit
      the bill nicely. But rather than reverting the commits, it's easier to
      just add an additional parameter for the element name to use, and
      update all callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1ec3e397
  6. 17 4月, 2019 3 次提交
    • E
      snapshot: Allow for post-parse override · df2ae0d0
      Eric Blake 提交于
      Wire up the accessor functions necessary for the testsuite to install
      an alternative post-parse handler from normal drivers. I could have
      modified the signature for virDomainXMLOptionNew() to take another
      parameter, but thought it was easier to add a new set function rather
      than chase down all existing callers. Until code actually sets the
      override, there is no change in behavior.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NCole Robinson <crobinso@redhat.com>
      df2ae0d0
    • E
      snapshot: Factor out post-parse code · 5ba4d81c
      Eric Blake 提交于
      Move the non-deterministic code that sets snapshot properties
      independently of what the incoming XML described to instead live in a
      default post-parse function common to virDomainMoment (as checkpoints
      will also reuse it in later patches). This patch is just code motion,
      with no difference to any callers; but the next patch will further
      refactor things to allow for a per-driver override, used by the
      testsuite to perform deterministic post-parse actions for better
      coverage of parser/formatter code.
      
      Note that the post-parse code is intentionally not run during a
      snapshot redefine, since that code path already requires a valid
      snapshot name and creation time from the XML.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NCole Robinson <crobinso@redhat.com>
      5ba4d81c
    • E
      snapshot: Don't expose testsuite-only state in snapshot XML · a007fcab
      Eric Blake 提交于
      None of the existing drivers actually use the 0-valued 'nostate'
      snapshot state; rather, it was a fluke of implementation. In fact,
      some drivers, like qemu, actively reject 'nostate' as invalid during a
      snapshot redefine. Normally, a driver computes the state post-parse
      from the current domain, and thus virDomainSnapshotGetXMLDesc() will
      never expose the state. However, since the testsuite lacks any
      associated domain to copy state from, and lacks post-parse processing
      that normal drivers have, the testsuite output had several spots with
      the state, coupled with a regex filter to ignore the oddity.
      
      It is better to follow the lead of other XML defaults, by not
      outputting anything during format if post-parse defaults have not been
      applied, and rejecting the default value during parsing. The testsuite
      needs a bit of an update, by adding another flag for when to simulate
      a post-parse action of setting a snapshot state, but none of the
      drivers are impacted other than rejecting XML that was previously
      already suspicious in nature.
      
      Similarly, don't expose creation time 0 (for now, only possible if a
      user redefined a snapshot to claim creation at the Epoch, but also
      happens once setting the creation time is deferred to a post-parse
      handler).
      
      This is also a step towards cleaning up snapshot_conf.c to separate
      its existing post-parse work (namely, setting the creationTime and
      default snapshot name) from the pure parsing work, so that we can get
      rid of the testsuite hack of regex filtering of the XML and instead
      have more accurate testing of our parser/formatter code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NCole Robinson <crobinso@redhat.com>
      a007fcab
  7. 12 4月, 2019 1 次提交
  8. 03 4月, 2019 2 次提交
  9. 27 3月, 2019 3 次提交
    • E
      Revert "snapshot: Allow NULL to virDomainSnapshotObjGetDef" · a6d822ce
      Eric Blake 提交于
      This reverts commit 6b90a847.
      
      It turns out gcc -O2 is not happy with it, complaining:
      
      /home/pipo/libvirt/src/qemu/qemu_driver.c: In function 'qemuDomainSnapshotCreateXML':
      /home/pipo/libvirt/src/qemu/qemu_driver.c:15389:26: error: potential null pointer dereference [-Werror=null-dereference]
           bool memory = snapdef->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL;
                         ~~~~~~~^~~~~~~~
      /home/pipo/libvirt/src/qemu/qemu_driver.c:15389:26: error: potential null pointer dereference [-Werror=null-dereference]
      In file included from /home/pipo/libvirt/src/util/virbuffer.h:27,
                       from /home/pipo/libvirt/src/conf/capabilities.h:27,
                       from /home/pipo/libvirt/src/conf/domain_conf.h:32,
                       from /home/pipo/libvirt/src/qemu/qemu_agent.h:26,
                       from /home/pipo/libvirt/src/qemu/qemu_driver.c:40:
      /home/pipo/libvirt/src/util/viralloc.h:125:34: error: potential null pointer dereference [-Werror=null-dereference]
       # define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count), true, \
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                  VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      /home/pipo/libvirt/src/qemu/qemu_driver.c:15103:9: note: in expansion of macro 'VIR_ALLOC_N'
           if (VIR_ALLOC_N(ret, snapdef->ndisks) < 0)
               ^~~~~~~~~~~
      /home/pipo/libvirt/src/qemu/qemu_driver.c:15798:45: error: null pointer dereference [-Werror=null-dereference]
                   virDomainSnapshotObjGetDef(snap)->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) {
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
      
      As the patch simplified one or two callers at the risk of making
      many other callers now candidates to trigger aggressive compiler
      warnings, it isn't worth it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a6d822ce
    • E
      snapshot: Allow NULL to virDomainSnapshotObjGetDef · 6b90a847
      Eric Blake 提交于
      Doing so can simplify some callers.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      6b90a847
    • E
      Revert "snapshot: Add virDomainSnapshotObjListFormat" · 0b4fac6a
      Eric Blake 提交于
      This reverts commit 86c0ed6f, and
      subsequent refactorings of the function into new files.  There are no
      callers of this function - I had originally proposed it for
      implementing a new bulk snapshot API, but that proved to be too
      invasive given RPC limits. I also tried using it for streamlining how
      the qemu driver stores snapshot state across libvirtd restarts
      internally, but in the end, the risks of a new internal format
      outweighed the benefits of one file per snapshot.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      0b4fac6a
  10. 25 3月, 2019 1 次提交
  11. 22 3月, 2019 6 次提交
    • E
      snapshot: Rename virDomainSnapshotObjPtr · e055a816
      Eric Blake 提交于
      Now that the core of SnapshotObj is agnostic to snapshots and can be
      shared with upcoming checkpoint code, it is time to rename the struct
      and the functions specific to list operations. A later patch will
      shuffle which file holds the common code. This is a fairly mechanical
      patch.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      e055a816
    • E
      snapshot: Switch type of virDomainSnapshotObj.def · 1ab05da2
      Eric Blake 提交于
      Another step towards making the object list reusable for both
      snapshots and checkpoints: the list code only ever needs items that
      are in the common virDomainMomentDef base type. This undoes a lot of
      the churn in accessing common members added in the previous patch, and
      the bulk of the patch is mechanical. But there was one spot where I
      had to unroll a VIR_STEAL_PTR to work around changed types.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      1ab05da2
    • E
      snapshot: Factor out virDomainMomentDef class · ffc0fbeb
      Eric Blake 提交于
      Pull out the common parts of virDomainSnapshotDef that will be reused
      for virDomainCheckpointDef into a new base class.  Adjust all callers
      that use the direct fields (some of it is churn that disappears when
      the next patch refactors virDomainSnapshotObj; oh well...).
      
      Someday, I hope to switch this type to be a subclass of virObject, but
      that requires a more thorough audit of cleanup paths, and besides
      minimal incremental changes are easier to review.
      
      As for the choice of naming:
      I promised my teenage daughter Evelyn that I'd give her credit for her
      contribution to this commit. I asked her "What would be a good name
      for a base class for DomainSnapshot and DomainCheckpoint". After
      explaining what a base class was (using the classic OOB Square and
      Circle inherit from Shape), she came up with "DomainMoment", which is
      way better than my initial thought of "DomainPointInTime" or
      "DomainPIT".
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      ffc0fbeb
    • E
      snapshot: Access snapshot def directly when needed · 55c2ab3e
      Eric Blake 提交于
      An upcoming patch will rework virDomainSnapshotObjList to be generic
      for both snapshots and checkpoints; reduce the churn by adding a new
      accessor virDomainSnapshotObjGetDef() which returns the
      snapshot-specific definition even when the list is rewritten to
      operate only on a base class, then using it at sites that that are
      specific to snapshots.  Use VIR_STEAL_PTR when appropriate in the
      affected lines.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      55c2ab3e
    • E
      snapshot: Track current snapshot in virDomainSnapshotObjList · 4819f54b
      Eric Blake 提交于
      It is easier to track the current snapshot as part of the list of
      snapshots. In particular, doing so lets us guarantee that the current
      snapshot is cleared if that snapshot is removed from the list (rather
      than depending on the caller to do so, and risking a use-after-free
      problem, such as the one recently patched in 1db9d0ef).  This
      requires the addition of several new accessor functions, as well as a
      useful return type for virDomainSnapshotObjListRemove().  A few error
      handling sites that were previously setting vm->current_snapshot =
      NULL can now be dropped, because the previous function call has now
      done it already.  Also, qemuDomainRevertToSnapshot() was setting the
      current vm twice, so keep only the one used on the success path.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      4819f54b
    • E
      snapshot: Drop virDomainSnapshotDef.current · f1056279
      Eric Blake 提交于
      The only use for the 'current' member of virDomainSnapshotDef was with
      the PARSE/FORMAT_INTERNAL flag for controlling an internal-use
      <active> element marking whether a particular snapshot definition was
      current, and even then, only by the qemu driver on output, and by qemu
      and test driver on input. But this duplicates vm->snapshot_current,
      and gets in the way of potential simplifications to have qemu store a
      single file for all snapshots rather than one file per snapshot.  Get
      rid of the member by adding a bool* parameter during parse (ignored if
      the PARSE_INTERNAL flag is not set), and by adding a new flag during
      format (if FORMAT_INTERNAL is set, the value printed in <active>
      depends on the new FORMAT_CURRENT).
      
      Then update the qemu driver accordingly, which involves hoisting
      assignments to vm->current_snapshot to occur prior to any point where
      a snapshot XML file is written (although qemu kept
      vm->current_snapshot and snapshot->def_current in sync by the end of
      the function, they were not always identical in the middle of
      functions, so the shuffling gets a bit interesting). Later patches
      will clean up some of that confusing churn to vm->current_snapshot.
      
      Note: even if later patches refactor qemu to no longer use
      FORMAT_INTERNAL for output (by storing bulk snapshot XML instead), we
      will always need PARSE_INTERNAL for input (because on upgrade, a new
      libvirt still has to parse XML left from a previous libvirt).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      f1056279
  12. 16 3月, 2019 3 次提交
  13. 13 3月, 2019 1 次提交
    • E
      snapshots: Support topological visits · b647d219
      Eric Blake 提交于
      Wire up support for VIR_DOMAIN_SNAPSHOT_LIST_TOPOLOGICAL in the
      domain-agnostic support code.
      
      Clients of snapshot_conf using virDomainSnapshotForEachDescendant()
      are using a depth-first visit but with postfix visits of a given
      node. Changing this to a prefix visit of the given node instantly
      turns this into a topologically-ordered visit.  (A prefix
      breadth-first visit would also be topologically sorted, but that
      requires a queue while our recursion naturally has a stack).
      
      With that change, we now always have a topological sort for
      virDomainSnapshotListAllChildren() regardless of the new public API
      flag. Then with one more tweak, we can also get a topological rather
      than a faster random hash visit for virDomainListAllSnapshots(), by
      doing a descendent walk from our internal metaroot (there, we let the
      public API flag control behavior, because a topological sort DOES
      require more stack and slightly more time).
      
      Note that virDomainSnapshotForEach() still uses a random hash visit;
      we could change that signature to take a tri-state for random, prefix,
      or postfix visit if we ever had clients that cared about the
      distinctions, but for now, none of the drivers seem to care.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJán Tomko <jtomko@redhat.com>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      b647d219
  14. 08 3月, 2019 7 次提交
    • E
      snapshot: Add virDomainSnapshotObjListParse · 1b57269c
      Eric Blake 提交于
      Add a new function to make it possible to parse a list of snapshots
      at once.  This is a counterpart to an earlier patch making it
      possible to produce all snapshots in a single XML string, and
      intentionally parses the same top-level element <snapshots> with
      an optional attribute current='name'.
      
      Note that since we know we started with no relations at all, and
      since checking parent relationships per-snapshot is not viable as
      we don't control which order the snapshots appear in, that we are
      fine with doing a final pass to update all parent/child
      relationships among the definitions.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      1b57269c
    • E
      snapshot: Split out virDomainSnapshotRedefineValidate helper · 1e90fa89
      Eric Blake 提交于
      Pull out the portion of virDomainSnapshotRefinePrep() that deals
      with definition sanity into a separate helper routine that can
      be reused with bulk redefine, leaving behind only the code
      specific to loop checking and in-place updates that are only
      needed in single-definition handling.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      1e90fa89
    • E
      snapshot: Avoid latent use-after-free when cleaning snapshots · 44a9b872
      Eric Blake 提交于
      Right now, the only callers of qemuDomainSnapshotDiscardAllMetadata()
      are right before freeing the virDomainSnapshotObjList, so it did not
      matter if the list's metaroot (which points to all the defined root
      snapshots) is left inconsistent. But an upcoming patch will want to
      clear all snapshots if a bulk redefine fails partway through, in
      which case things must be reset.  Make this work by teaching the
      existing virDomainSnapshotUpdateRelations() to be safe regardless of
      the incoming state of the metaroot (since we don't want to leak that
      internal detail into qemu code), then fixing the qemu code to use
      it after deleting all snapshots. Additionally, the qemu code must
      reset vm->current_snapshot if the current snapshot was removed,
      regardless of whether the overall removal succeeded or failed later.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      44a9b872
    • E
      snapshot: Add virDomainSnapshotObjListFormat · 86c0ed6f
      Eric Blake 提交于
      Add a new function to output all of the domain's snapshots in one
      buffer.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      86c0ed6f
    • E
      snapshot: Refactor virDomainSnapshotDefFormat · cae6619a
      Eric Blake 提交于
      Split out an internal helper that produces format into a
      virBuffer, similar to what domain_conf.c does, and making
      the next patch easier to write.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      cae6619a
    • E
      snapshot: Give virDomainSnapshotDefFormat its own flags · c5029559
      Eric Blake 提交于
      virDomainSnapshotDefFormat currently takes two sets of knobs:
      an 'unsigned int flags' argument that can currently just be
      VIR_DOMAIN_DEF_FORMAT_SECURE, and an 'int internal' argument used as
      a bool to determine whether to output an additional element.  It
      then reuses the 'flags' knob to call into virDomainDefFormatInternal(),
      which takes a different set of flags. In fact, prior to commit 0ecd6851
      (1.2.12), the 'flags' argument actually took the public
      VIR_DOMAIN_XML_SECURE, which was even more confusing.  Let's borrow
      from the style of that earlier commit, by introducing a function
      for translating from the public flags (VIR_DOMAIN_SNAPSHOT_XML_SECURE
      was just recently introduced) into a new enum specific to snapshot
      formatting, and adjust all callers to use snapshot-specific enum
      values when formatting, and where the formatter now uses a new
      variable 'domainflags' to make it obvious when we are translating
      from snapshot flags back to domain flags.  We don't even have to
      use the conversion function for drivers that don't accept the
      public VIR_DOMAIN_SNAPSHOT_XML_SECURE flag.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      c5029559
    • E
      snapshot: Rework virDomainSnapshotState enum · f43eb680
      Eric Blake 提交于
      The existing virDomainSnapshotState is a superset of virDomainState,
      adding one more state (disk-snapshot) on top of valid domain states.
      But as written, the enum cannot be used for gcc validation that all
      enum values are covered in a strongly-typed switch condition, because
      the enum does not explicitly include the values it is adding to.
      
      Copy the style used in qemu_blockjob.h of creating new enum names
      for every inherited value, and update most clients to use the new
      enum names anywhere snapshot state is referenced. The exception is
      two switch statements in qemu code, which instead gain a fixme
      comment about odd type usage (which will be cleaned up in the next
      patch). The rest of the patch is fairly mechanical (I actually did
      it by temporarily s/state/xstate/ in snapshot_conf.h to let the
      compiler find which spots in the code used the field, did the
      obvious search and replace in those functions, then undid the rename).
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      f43eb680
  15. 27 2月, 2019 2 次提交
    • E
      snapshot: Permit redefine of offline external snapshot · dafef600
      Eric Blake 提交于
      Due to historical back-compat, bare 'virsh snapshot-create-as'
      favors internal snapshots (but can't be used on domains with raw
      storage), while 'virsh snapshot-create-as --disk-only' favors
      external snapshots.  What's more, snapshots created with
      --disk-only while the domain was running are marked as snapshot
      state 'disk-snapshot', while snapshots created while the domain
      was offline are marked as snapshot state 'shutdown' (a
      'disk-snapshot' image might not be quiescent, while a 'shutdown'
      snapshot always is).
      
      But this leads to some interesting problems: if we create a
      --disk-only snapshot of an offline guest, and then immediately try
      to 'virsh snapshot-create --redefine' using the resulting XML to
      overwrite the existing snapashot in place, things silently succeed,
      but 'virsh snapshot-create --redefine --disk-only' fails with an
      error message that the snapshot state is not 'disk-only'.  Worse,
      if we delete the snapshot metadata first and then try to recreate
      things, omitting --disk-only fails because the verification code
      wants to force the default of an internal snapshot (which doesn't
      work with raw disks), and using --disk-only still fails because the
      snapshot XML is not 'disk-only' - making it impossible to recreate
      the snapshot metadata (or to transfer it from one libvirtd host to
      another).  Ideally, the presence or absence of the --disk-only
      flag, and the presence or absence of an existing snapshot being
      overwritten, shouldn't matter; if the XML is valid for one
      situation, it should always be valid to redefine the metadata for
      that snapshot.
      
      Fix things by uniformly using virDomainSnapshotDefIsExternal()
      (caching the results up front, and eliminating other 'if' clauses
      now rendered redundant) when deciding whether the XML being
      requested for redefinition should permit external or force internal
      state capture (we got it right in only one out of three places in
      the function).
      
      See also https://bugzilla.redhat.com/1680304; this fixes the
      domain-agnostic problems mentioned there, but another patch is
      needed to fix further oddities with the qemu driver.  I did not
      check for sure when the problems were introduced (git blame puts
      some affected hunks as far back as 1.0.0), but it was definitely
      been broken even before when commit 670e86bf (1.1.4) factored
      redefine prep out of qemu code into the common snapshot_conf code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      dafef600
    • E
      snapshots: Avoid term 'checkpoint' for full system snapshot · d152c727
      Eric Blake 提交于
      Upcoming patches plan to introduce virDomainCheckpointPtr as a new
      object for use in incremental backups, along with documentation on
      how incremental backups differ from snapshots.  But first, we need
      to rename any existing mention of a 'system checkpoint' to instead
      be a 'full system snapshot', so that we aren't overloading
      the term checkpoint.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
      d152c727
  16. 22 2月, 2019 1 次提交
    • E
      snapshot: Saner use of uuid · c900474e
      Eric Blake 提交于
      Most of the code base is fairly consistent about using the name
      'uuidstr' when dealing with a formatted human-readable form, and
      'uuid' when dealing with the smaller raw bytes form. Fix
      snapshot_conf to comply, as well as reducing the scope of a human
      string to only the error message that needs it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c900474e
  17. 18 2月, 2019 2 次提交