1. 22 3月, 2019 2 次提交
    • 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
  2. 16 3月, 2019 3 次提交
  3. 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
  4. 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
  5. 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
  6. 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
  7. 18 2月, 2019 2 次提交
  8. 04 2月, 2019 1 次提交
  9. 14 12月, 2018 1 次提交
    • D
      Remove all Author(s): lines from source file headers · 60046283
      Daniel P. Berrangé 提交于
      In many files there are header comments that contain an Author:
      statement, supposedly reflecting who originally wrote the code.
      In a large collaborative project like libvirt, any non-trivial
      file will have been modified by a large number of different
      contributors. IOW, the Author: comments are quickly out of date,
      omitting people who have made significant contribitions.
      
      In some places Author: lines have been added despite the person
      merely being responsible for creating the file by moving existing
      code out of another file. IOW, the Author: lines give an incorrect
      record of authorship.
      
      With this all in mind, the comments are useless as a means to identify
      who to talk to about code in a particular file. Contributors will always
      be better off using 'git log' and 'git blame' if they need to  find the
      author of a particular bit of code.
      
      This commit thus deletes all Author: comments from the source and adds
      a rule to prevent them reappearing.
      
      The Copyright headers are similarly misleading and inaccurate, however,
      we cannot delete these as they have legal meaning, despite being largely
      inaccurate. In addition only the copyright holder is permitted to change
      their respective copyright statement.
      Reviewed-by: NErik Skultety <eskultet@redhat.com>
      Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
      60046283
  10. 06 12月, 2018 1 次提交
  11. 26 7月, 2018 1 次提交
  12. 25 6月, 2018 1 次提交
  13. 20 4月, 2018 1 次提交
    • J
      conf: Add error checking to virDomainSnapshotDiskDefFormat · c028c719
      John Ferlan 提交于
      Commit id '43f2ccdc' called virDomainDiskSourceDefFormatInternal
      rather than formatting the the disk source inline. However, it
      did not handle the case where the helper failed. Over time the
      helper has been renamed to virDomainDiskSourceFormat. Similar to
      other consumers, if virDomainDiskSourceFormat fails, then the
      formatting could be off, so it's better to fail than to continue
      on with some possibly bad data. Alter the function and the caller
      to check status and jump to error in that case.
      
      Found by Coverity
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      c028c719
  14. 14 12月, 2017 1 次提交
    • P
      conf: Add infrastructure for disk source private data XML · aed3d038
      Peter Krempa 提交于
      VM drivers may need to store additional private data to the status XML
      so that it can be restored after libvirtd restart. Since not everything
      is needed add a callback infrastructure, where VM drivers can add only
      stuff they need.
      
      Note that the private data is formatted as a <privateData> sub-element
      of the <disk> or <backingStore> <source> sub-element. This is done since
      storing it out of band (in the VM private data) would require a complex
      matching process to allow to put the data into correct place.
      aed3d038
  15. 28 9月, 2017 1 次提交
    • A
      util: Add TLS attributes to virStorageSource · f1705485
      Ashish Mittal 提交于
      Add an optional virTristateBool haveTLS to virStorageSource to
      manage whether a storage source will be using TLS.
      
      Sample XML for a VxHS disk:
      
      <disk type='network' device='disk'>
        <driver name='qemu' type='raw' cache='none'/>
        <source protocol='vxhs' name='eb90327c-8302-4725-9e1b-4e85ed4dc251' tls='yes'>
          <host name='192.168.0.1' port='9999'/>
        </source>
        <target dev='vda' bus='virtio'/>
      </disk>
      
      Additionally add a tlsFromConfig boolean to control whether the TLS
      setting was due to domain configuration or qemu.conf global setting
      in order to decide whether to Format the haveTLS setting for either
      a live or saved domain configuration file.
      
      Update the qemuxml2xmltest in order to add a test to show the proper
      parsing.
      
      Also update the docs to describe the tls attribute.
      Signed-off-by: NAshish Mittal <Ashish.Mittal@veritas.com>
      Signed-off-by: NJohn Ferlan <jferlan@redhat.com>
      f1705485
  16. 21 9月, 2017 1 次提交
  17. 14 8月, 2017 1 次提交
  18. 07 6月, 2017 3 次提交
  19. 05 6月, 2017 1 次提交
  20. 17 12月, 2016 1 次提交
  21. 26 9月, 2016 1 次提交
  22. 07 6月, 2016 1 次提交
    • P
      conf: Add infrastructure for adding configuration validation · b394af16
      Peter Krempa 提交于
      Until now we weren't able to add checks that would reject configuration
      once accepted by the parser. This patch adds a new callback and
      infrastructure to add such checks. In this patch all the places where
      rejecting a now-invalid configuration wouldn't be a good idea are marked
      with a new parser flag.
      b394af16
  23. 17 2月, 2016 1 次提交
    • E
      util: Add a return value to void hash iterators · cc48d3a1
      Erik Skultety 提交于
      Our existing virHashForEach method iterates through all items disregarding the
      fact, that some of the iterators might have actually failed. Errors are usually
      dispatched through an error element in opaque data which then causes the
      original caller of virHashForEach to return -1. In that case, virHashForEach
      could return as soon as one of the iterators fail. This patch changes the
      iterator return type and adjusts all of its instances accordingly, so the
      actual refactor of virHashForEach method can be dealt with later.
      Signed-off-by: NErik Skultety <eskultet@redhat.com>
      cc48d3a1
  24. 11 2月, 2016 4 次提交