1. 11 10月, 2012 1 次提交
    • J
      Add MIGRATABLE flag for virDomainGetXMLDesc · 28f8dfdc
      Jiri Denemark 提交于
      Using VIR_DOMAIN_XML_MIGRATABLE flag, one can request domain's XML
      configuration that is suitable for migration or save/restore. Such XML
      may contain extra run-time stuff internal to libvirt and some default
      configuration may be removed for better compatibility of the XML with
      older libvirt releases.
      
      This flag may serve as an easy way to get the XML that can be passed
      (after desired modifications) to APIs that accept custom XMLs, such as
      virDomainMigrate{,ToURI}2 or virDomainSaveFlags.
      28f8dfdc
  2. 26 9月, 2012 1 次提交
  3. 21 9月, 2012 1 次提交
  4. 19 9月, 2012 1 次提交
    • L
      network: fix incorrect VIR_NETWORK_UPDATE_COMMAND_* values · 01ab6599
      Laine Stump 提交于
      These enums originally were put into the flags for virNetworkUpdate,
      and when they were moved into their own enum, the numbers weren't
      appropriately changed, causing the commands to start with value 2
      instead of 1. This causes problems for things like ENUM_IMPL, which
      wants a string for every value in the requested range, including those
      not used in the enum.
      01ab6599
  5. 18 9月, 2012 2 次提交
    • L
      network: define new API virNetworkUpdate · 574b9bc6
      Laine Stump 提交于
      This patch adds a new public API virNetworkUpdate that will permit
      updating an existing network configuration without requiring that the
      network be destroyed/restarted for the changes to take effect.
      574b9bc6
    • E
      blockjob: add virDomainBlockCommit · ef1e024d
      Eric Blake 提交于
      A block commit moves data in the opposite direction of block pull.
      Block pull reduces the chain length by dropping backing files after
      data has been pulled into the top overlay, and is always safe; block
      commit reduces the chain length by dropping overlays after data has
      been committed into the backing file, and any files that depended
      on base but not on top are invalidated at any point where they have
      unallocated data that is now pointing to changed contents in base.
      Both directions are useful, however: a qcow2 layer that is more than
      50% allocated will typically be faster with a pull operation, while
      a qcow2 layer with less than 50% allocation will be faster as a
      commit operation.  Committing across multiple layers can be more
      efficient than repeatedly committing one layer at a time, but
      requires extra support from the hypervisor.
      
      This API matches Jeff Cody's proposed qemu command 'block-commit':
      https://lists.gnu.org/archive/html/qemu-devel/2012-09/msg02226.html
      
      Jeff's command is still in the works for qemu 1.3, and may gain
      further enhancements, such as the ability to control on-error
      handling (it will be comparable to the error handling Paolo is
      adding to 'drive-mirror', so a similar solution will be needed
      when I finally propose virDomainBlockCopy with more functionality
      than the basics supported by virDomainBlockRebase).  However, even
      without qemu support, this API will be useful for _offline_ block
      commits, by wrapping qemu-img calls and turning them into a block
      job, so this API is worth committing now.
      
      For some examples of how this will be implemented, all starting
      with the chain: base <- snap1 <- snap2 <- active
      
      + These are equivalent:
       virDomainBlockCommit(dom, disk, NULL, NULL, 0, 0)
       virDomainBlockCommit(dom, disk, NULL, "active", 0, 0)
       virDomainBlockCommit(dom, disk, "base", NULL, 0, 0)
       virDomainBlockCommit(dom, disk, "base", "active", 0, 0)
      but cannot be implemented for online qemu with round 1 of
      Jeff's patches; and for offline images, it would require
      three back-to-back qemu-img invocations unless qemu-img
      is patched to allow more efficient multi-layer commits;
      the end result would be 'base' as the active disk with
      contents from all three other files, where 'snap1' and
      'snap2' are invalid right away, and 'active' is invalid
      once any further changes to 'base' are made.
      
      + These are equivalent:
       virDomainBlockCommit(dom, disk, "snap2", NULL, 0, 0)
       virDomainBlockCommit(dom, disk, NULL, NULL, 0, _SHALLOW)
      they cannot be implemented for online qemu, but for offline,
      it is a matter of 'qemu-img commit active', so that 'snap2'
      is now the active disk with contents formerly in 'active'.
      
      + Similarly:
       virDomainBlockCommit(dom, disk, "snap2", NULL, 0, _DELETE)
      for an offline domain will merge 'active' into 'snap2', then
      delete 'active' to avoid leaving a potentially invalid file
      around.
      
      + This version:
       virDomainBlockCommit(dom, disk, NULL, "snap2", 0, _SHALLOW)
      can be implemented online with 'block-commit' passing a base of
      snap1 and a top of snap2; and can be implemented offline by
      'qemu-img commit snap2' followed by 'qemu-img rebase -u
      -b snap1 active'
      
      * include/libvirt/libvirt.h.in (virDomainBlockCommit): New API.
      * src/libvirt.c (virDomainBlockCommit): Implement it.
      * src/libvirt_public.syms (LIBVIRT_0.10.2): Export it.
      * src/driver.h (virDrvDomainBlockCommit): New driver callback.
      * docs/apibuild.py (CParser.parseSignature): Add exception.
      ef1e024d
  6. 17 9月, 2012 4 次提交
    • O
      node_memory: Define the APIs to get/set memory parameters · 12ad7435
      Osier Yang 提交于
      * include/libvirt/libvirt.h.in: (Add macros for the param fields,
        declare the APIs).
      * src/driver.h: (New methods for the driver struct)
      * src/libvirt.c: (Implement the public APIs)
      * src/libvirt_public.syms: (Export the public symbols)
      12ad7435
    • O
      list: Define new API virConnectListAllSecrets · 7a236982
      Osier Yang 提交于
      This is to list the secret objects. Supports to filter the secrets
      by its storage location, and whether it's private or not.
      
      include/libvirt/libvirt.h.in: Declare enum virConnectListAllSecretFlags
                                    and virConnectListAllSecrets.
      python/generator.py: Skip auto-generating
      src/driver.h: (virDrvConnectListAllSecrets)
      src/libvirt.c: Implement the public API
      src/libvirt_public.syms: Export the symbol to public
      7a236982
    • O
      list: Define new API virConnectListAllNWFilters · 6498f76e
      Osier Yang 提交于
      This is to list the network filter objects. No flags are supported
      
      include/libvirt/libvirt.h.in: Declare enum virConnectListAllNWFilterFlags
                                    and virConnectListAllNWFilters.
      python/generator.py: Skip auto-generating
      src/driver.h: (virDrvConnectListAllNWFilters)
      src/libvirt.c: Implement the public API
      src/libvirt_public.syms: Export the symbol to public
      6498f76e
    • O
      list: Define new API virConnectListAllNodeDevices · c6a3be5d
      Osier Yang 提交于
      This is to list the node device objects, supports to filter the results
      by capability types.
      
      include/libvirt/libvirt.h.in: Declare enum virConnectListAllNodeDeviceFlags
                                    and virConnectListAllNodeDevices.
      python/generator.py: Skip auto-generating
      src/driver.h: (virDrvConnectListAllNodeDevices)
      src/libvirt.c: Implement the public API
      src/libvirt_public.syms: Export the symbol to public
      c6a3be5d
  7. 12 9月, 2012 1 次提交
    • O
      list: Define new API virConnectListAllInterfaces · f4af202f
      Osier Yang 提交于
      This is to list the interface objects, supported filtering flags
      are: active|inactive.
      
      include/libvirt/libvirt.h.in: Declare enum virConnectListAllInterfaceFlags
                                    and virConnectListAllInterfaces.
      python/generator.py: Skip auto-generating
      src/driver.h: (virDrvConnectListAllInterfaces)
      src/libvirt.c: Implement the public API
      src/libvirt_public.syms: Export the symbol to public
      f4af202f
  8. 11 9月, 2012 1 次提交
    • O
      list: Define new API virConnectListAllNetworks · 89a1df9b
      Osier Yang 提交于
      This is to list the network objects, supported filtering flags
      are: active|inactive, persistent|transient, autostart|no-autostart.
      
      include/libvirt/libvirt.h.in: Declare enum virConnectListAllNetworkFlags
                                    and virConnectListAllNetworks.
      python/generator.py: Skip auto-generating
      src/driver.h: (virDrvConnectListAllNetworks)
      src/libvirt.c: Implement the public API
      src/libvirt_public.syms: Export the symbol to public
      89a1df9b
  9. 10 9月, 2012 1 次提交
    • O
      list: Define new API virStoragePoolListAllVolumes · a42eac60
      Osier Yang 提交于
      Simply returns the storage volume objects. No supported filter
      flags.
      
      include/libvirt/libvirt.h.in: Declare the API
      python/generator.py: Skip the function for generating. virStoragePool.py
                           will be added in later patch.
      src/driver.h: virDrvStoragePoolListVolumesFlags
      src/libvirt.c: Implementation for the API.
      src/libvirt_public.syms: Export the symbol to public
      a42eac60
  10. 07 9月, 2012 1 次提交
  11. 06 9月, 2012 1 次提交
    • O
      list: Define new API virStorageListAllStoragePools · 075c754a
      Osier Yang 提交于
      This introduces a new API to list the storage pool objects,
      4 groups of flags are provided to filter the returned pools:
      
        * Active or not
      
        * Autostarting or not
      
        * Persistent or not
      
        * And the pool type.
      
      include/libvirt/libvirt.h.in: New enum virConnectListAllStoragePoolFlags;
                                    Declare the API.
      python/generator.py: Skip the generating
      src/driver.h: (virDrvConnectListAllStoragePools)
      src/libvirt.c: Implementation for the API.
      src/libvirt_public.syms: Export the symbol.
      075c754a
  12. 22 8月, 2012 2 次提交
  13. 21 8月, 2012 1 次提交
  14. 17 8月, 2012 1 次提交
  15. 30 7月, 2012 1 次提交
  16. 27 7月, 2012 2 次提交
    • P
      lib: Revert removing of Summary and Description fields in headers · d6e94bdd
      Peter Krempa 提交于
      Those fields are used by the apibuild script to create documentation.
      This commit partialy reverts a4bcefbc.
      d6e94bdd
    • O
      maint: Use consistent copyright. · a4bcefbc
      Osier Yang 提交于
      This is a follow up patch of commit f9ce7dad, it modifies all
      the files which declare the copyright like "See COPYING.LIB for
      the License of this software" to use the detailed/consistent one.
      
      And deserts the outdated comments like:
      
       * libvirt-qemu.h:
       * Summary: qemu specific interfaces
       * Description: Provides the interfaces of the libvirt library to handle
       *              qemu specific methods
       *
       * Copy:  Copyright (C) 2010, 2012 Red Hat, Inc.
      
      Uses the more compact style like:
      
       * libvirt-qemu.h: Interfaces specific for QEMU/KVM driver
       *
       * Copyright (C) 2010, 2012 Red Hat, Inc.
      a4bcefbc
  17. 21 7月, 2012 1 次提交
    • G
      Add virDomainGetHostname · a91067fa
      Guido Günther 提交于
      to query a guests's hostname. Containers like LXC and OpenVZ allow to
      set a hostname different from the hosts name and QEMU's guest agent
      could provide similar functionality.
      a91067fa
  18. 14 7月, 2012 1 次提交
    • D
      Define public API for receiving guest memory balloon events · 7ed6d7dd
      Daniel P. Berrange 提交于
      When the guest changes its memory balloon applications may want
      to know what the new value is, without having to periodically
      poll on XML / domain info. Introduce a "balloon change" event
      to let apps see this
      
      * include/libvirt/libvirt.h.in: Define the
        virConnectDomainEventBalloonChangeCallback callback
        and VIR_DOMAIN_EVENT_ID_BALLOON_CHANGE constant
      * python/libvirt-override-virConnect.py,
        python/libvirt-override.c: Wire up helpers for new event
      * daemon/remote.c: Helper for serializing balloon event
      * examples/domain-events/events-c/event-test.c,
        examples/domain-events/events-python/event-test.py: Add
        example of balloon event usage
      * src/conf/domain_event.c, src/conf/domain_event.h: Handling
        of balloon events
      * src/remote/remote_driver.c: Add handler of balloon events
      * src/remote/remote_protocol.x: Define wire protocol for
        balloon events
      * src/remote_protocol-structs: Likewise.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      7ed6d7dd
  19. 25 6月, 2012 1 次提交
    • M
      storage: Introduce --inactive for pool-dumpxml · 8d27005b
      Michal Privoznik 提交于
      Storage is one of the last domains in libvirt where we don't fully
      utilize inactive and live XML. Okay, it might be because we don't
      have support for that. So implement such support. However, we need
      to fallback when talking to old daemon which doesn't support this
      new flag called VIR_STORAGE_XML_INACTIVE.
      8d27005b
  20. 20 6月, 2012 2 次提交
    • E
      list: add virDomainListAllSnapshots API · 37bb0447
      Eric Blake 提交于
      There was an inherent race between virDomainSnapshotNum() and
      virDomainSnapshotListNames(), where an additional snapshot could
      be created in the meantime, or where a snapshot could be deleted
      before converting the name back to a virDomainSnapshotPtr.  It
      was also an awkward name: the function operates on domains, not
      domain snapshots.  virDomainSnapshotListChildrenNames() suffered
      from the same inherent race, although its naming was nicer.
      
      This patch makes things nicer by grabbing a snapshot list
      atomically, in the format most useful to the user.
      
      * include/libvirt/libvirt.h.in (virDomainListAllSnapshots)
      (virDomainSnapshotListAllChildren): New declarations.
      * src/libvirt.c (virDomainSnapshotListNames)
      (virDomainSnapshotListChildrenNames): Add cross-references.
      (virDomainListAllSnapshots, virDomainSnapshotListAllChildren):
      New functions.
      * src/libvirt_public.syms (LIBVIRT_0.9.13): Export them.
      * src/driver.h (virDrvDomainListAllSnapshots)
      (virDrvDomainSnapshotListAllChildren): New callbacks.
      * python/generator.py (skip_function): Prepare for later
      hand-written versions.
      37bb0447
    • E
      snapshot: add additional filters when getting lists · 5873f2e2
      Eric Blake 提交于
      It turns out that one-bit filtering makes it hard to select the inverse
      set, so it is easier to provide filtering groups.  For back-compat,
      omitting all bits within a group means the group is not used for
      filtering, and by definition of a group (each snapshot matches exactly
      one bit within the group, and the set of bits in the group covers all
      snapshots), selecting all bits also makes the group useless.
      
      Unfortunately, virDomainSnapshotListChildren defined the bit
      VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS as an expansion rather than a
      filter, so we cannot make it part of a filter group, so that bit
      (and its counterpart VIR_DOMAIN_SNAPSHOT_LIST_ROOTS for
      virDomainSnapshotList) remains a single control bit.
      
      * include/libvirt/libvirt.h.in (virDomainSnapshotListFlags): Add a
      couple more flags.
      * src/libvirt.c (virDomainSnapshotNum)
      (virDomainSnapshotNumChildren): Document them.
      (virDomainSnapshotListNames, virDomainSnapshotListChildrenNames):
      Likewise, and add thread-safety caveats.
      * src/conf/virdomainlist.h (VIR_DOMAIN_SNAPSHOT_FILTERS_*): New
      convenience macros.
      * src/conf/domain_conf.c (virDomainSnapshotObjListCopyNames)
      (virDomainSnapshotObjListCount): Support the new flags.
      5873f2e2
  21. 19 6月, 2012 1 次提交
    • P
      lib: Add public api to enable atomic listing of guest · 747f64ee
      Peter Krempa 提交于
      This patch adds a new public api that lists domains. The new approach is
      different from those used before. There are key points to this:
      
      1) The list is acquired atomically and contains both active and inactive
      domains (guests). This eliminates the need to call two different list
      APIs, where the state might change in between the calls.
      
      2) The returned list consists of virDomainPtrs instead of names or ID's
      that have to be converted to virDomainPtrs anyways using separate calls
      for each one of them. This is more convenient and saves hypervisor calls.
      
      3) The returned list is auto-allocated. This saves a lot of hassle for
      the users.
      
      4) Built in support for filtering. The API call supports various
      filtering flags that modify the output list according to user needs.
      
      Available filter groups:
          Domain status:
          VIR_CONNECT_LIST_DOMAINS_ACTIVE, VIR_CONNECT_LIST_DOMAINS_INACTIVE
      
          Domain persistence:
          VIR_CONNECT_LIST_DOMAINS_PERSISTENT,
          VIR_CONNECT_LIST_DOMAINS_TRANSIENT
      
          Domain state:
          VIR_CONNECT_LIST_DOMAINS_RUNNING, VIR_CONNECT_LIST_DOMAINS_PAUSED,
          VIR_CONNECT_LIST_DOMAINS_SHUTOFF, VIR_CONNECT_LIST_DOMAINS_OTHER
      
          Existence of managed save image:
          VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE,
          VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE
      
          Auto-start option:
          VIR_CONNECT_LIST_DOMAINS_AUTOSTART,
          VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART
      
          Existence of snapshot:
          VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT,
          VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT
      
      5) The python binding returns a list of domain objects that is very neat
      to work with.
      
      The only problem with this approach is no support from code generators
      so both RPC code and python bindings had to be written manually.
      
      *include/libvirt/libvirt.h.in: - add API prototype
                                     - clean up whitespace mistakes nearby
      *python/generator.py: - inhibit generation of the bindings for the new
                              api
      *src/driver.h: - add driver prototype
                     - clean up some whitespace mistakes nearby
      *src/libvirt.c: - add public implementation
      *src/libvirt_public.syms: - export the new symbol
      747f64ee
  22. 15 6月, 2012 1 次提交
  23. 12 6月, 2012 1 次提交
    • E
      snapshot: new query APIs · 2e13b9ab
      Eric Blake 提交于
      Right now, starting from just a virDomainSnapshotPtr, and wanting to
      know if it is the current snapshot for its respective domain, you have
      to use virDomainSnapshotGetDomain(), then virDomainSnapshotCurrent(),
      then compare the two names returned by virDomainSnapshotGetName().
      It is a bit easier if we can directly query this information from the
      snapshot itself.
      
      Right now, it is possible to filter a snapshot listing based on
      whether snapshots have metadata that would prevent domain deletion,
      but the only way to learn if an individual snapshot has metadata is
      to see if that snapshot appears in the list returned by a listing.
      Additionally, I hope to expand the qemu driver in a future patch to
      use qemu-img to reconstruct snapshot XML corresponding to internal
      qcow2 snapshot names not otherwise tracked by libvirt (in part, so
      that libvirt can guarantee that new snapshots are not created with
      a name that would silently corrupt the existing portion of the qcow2
      file); if I ever get that in, then it would no longer be an all-or-none
      decision on whether snapshots have metadata, and becomes all the more
      important to be able to directly determine that information from a
      particular snapshot.
      
      Other query functions (such as virDomainIsActive) do not have a flags
      argument, but since virDomainHasCurrentSnapshot takes a flags argument,
      I figured it was safer to provide a flags argument here as well.
      
      * include/libvirt/libvirt.h.in (virDomainSnapshotIsCurrent)
      (virDomainSnapshotHasMetadata): New declarations.
      * src/libvirt.c (virDomainSnapshotIsCurrent)
      (virDomainSnapshotHasMetadata): New functions.
      * src/libvirt_public.syms (LIBVIRT_0.9.13): Export them.
      * src/driver.h (virDrvDomainSnapshotIsCurrent)
      (virDrvDomainSnapshotHasMetadata): New driver callbacks.
      2e13b9ab
  24. 09 6月, 2012 1 次提交
    • E
      snapshot: add virDomainSnapshotRef API · 9d08debe
      Eric Blake 提交于
      virDomainSnapshotPtr has a refcount member, but no one was able
      to use it.  Furthermore, all of our other vir*Ptr objects have
      a *Ref method to match their *Free method.  Thankfully, this is
      client-side only, so we can use this new function regardless of
      how old the server side is!  (I have future patches to virsh
      that want to use it.)
      
      * include/libvirt/libvirt.h.in (virDomainSnapshotRef): Declare.
      * src/libvirt.c (virDomainSnapshotRef): Implement it.
      * src/libvirt_public.syms (LIBVIRT_0.9.13): Export it.
      9d08debe
  25. 22 5月, 2012 1 次提交
    • W
      storage backend: Add RBD (RADOS Block Device) support · 74951ead
      Wido den Hollander 提交于
      This patch adds support for a new storage backend with RBD support.
      
      RBD is the RADOS Block Device and is part of the Ceph distributed storage
      system.
      
      It comes in two flavours: Qemu-RBD and Kernel RBD, this storage backend only
      supports Qemu-RBD, thus limiting the use of this storage driver to Qemu only.
      
      To function this backend relies on librbd and librados being present on the
      local system.
      
      The backend also supports Cephx authentication for safe authentication with
      the Ceph cluster.
      
      For storing credentials it uses the built-in secret mechanism of libvirt.
      Signed-off-by: NWido den Hollander <wido@widodh.nl>
      74951ead
  26. 18 5月, 2012 1 次提交
    • H
      Add a new param 'vcpu_time' to virDomainGetCPUStats · d29a7aaa
      Hu Tao 提交于
      Currently virDomainGetCPUStats gets total cpu usage, which consists
      of:
      
        1. vcpu usage: the physical cpu time consumed by virtual cpu(s) of
           domain
        2. hypervisor: `total cpu usage' - `vcpu usage'
      
      The param 'vcpu_time' is for getting vcpu usages.
      d29a7aaa
  27. 23 4月, 2012 1 次提交
    • E
      blockjob: add new API flags · 36484692
      Eric Blake 提交于
      This patch introduces a new block job, useful for live storage
      migration using pre-copy streaming.  Justification for including
      this under virDomainBlockRebase rather than adding a new command
      includes: 1) there are now two possible block jobs in qemu, with
      virDomainBlockRebase starting either type of command, and
      virDomainBlockJobInfo and virDomainBlockJobAbort working to end
      either type; 2) reusing this command allows distros to backport
      this feature to the libvirt 0.9.10 API without a .so bump.
      
      Note that a future patch may add a more powerful interface named
      virDomainBlockJobCopy, dedicated to just the block copy job, in
      order to expose even more options (such as setting an arbitrary
      format type for the destination without having to probe it from a
      pre-existing destination file); adding a new command for targetting
      just block copy would be similar to how we already have
      virDomainBlockPull for targetting just the block pull job.
      
      Using a live VM with the backing chain:
        base <- snap1 <- snap2
      as the starting point, we have:
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY)
      creates /path/to/copy with the same format as snap2, with no backing
      file, so entire chain is copied and flattened
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      creates /path/to/copy as a raw file, so entire chain is copied and
      flattened
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_SHALLOW)
      creates /path/to/copy with the same format as snap2, but with snap1 as
      a backing file, so only snap2 is copied.
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
      reuse existing /path/to/copy (must have empty contents, and format is
      probed[*] from the metadata), and copy the full chain
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
          VIR_DOMAIN_BLOCK_REBASE_SHALLOW)
      reuse existing /path/to/copy (contents must be identical to snap1,
      and format is probed[*] from the metadata), and copy only the contents
      of snap2
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
          VIR_DOMAIN_BLOCK_REBASE_SHALLOW|VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      reuse existing /path/to/copy (must be raw volume with contents
      identical to snap1), and copy only the contents of snap2
      
      Less useful combinations:
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_SHALLOW|
          VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      fail if source is not raw, otherwise create /path/to/copy as raw and
      the single file is copied (no chain involved)
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
          VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      makes little sense: the destination must be raw but have no contents,
      meaning that it is an empty file, so there is nothing to reuse
      
      The other three flags are rejected without VIR_DOMAIN_BLOCK_COPY.
      
      [*] Note that probing an existing file for its format can be a security
      risk _if_ there is a possibility that the existing file is 'raw', in
      which case the guest can manipulate the file to appear like some other
      format.  But, by virtue of the VIR_DOMAIN_BLOCK_REBASE_COPY_RAW flag,
      it is possible to avoid probing of raw files, at which point, probing
      of any remaining file type is no longer a security risk.
      
      It would be nice if we could issue an event when pivoting from phase 1
      to phase 2, but qemu hasn't implemented that, and we would have to poll
      in order to synthesize it ourselves.  Meanwhile, qemu will give us a
      distinct job info and completion event when we either cancel or pivot
      to end the job.  Pivoting is accomplished via the new:
      
      virDomainBlockJobAbort(dom, disk, VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT)
      
      Management applications can pre-create the copy with a relative
      backing file name, and use the VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT
      flag to have qemu reuse the metadata; if the management application
      also copies the backing files to a new location, this can be used
      to perform live storage migration of an entire backing chain.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_BLOCK_JOB_TYPE_COPY):
      New block job type.
      (virDomainBlockJobAbortFlags, virDomainBlockRebaseFlags): New enums.
      * src/libvirt.c (virDomainBlockRebase): Document the new flags,
      and implement general restrictions on flag combinations.
      (virDomainBlockJobAbort): Document the new flag.
      (virDomainSaveFlags, virDomainSnapshotCreateXML)
      (virDomainRevertToSnapshot, virDomainDetachDeviceFlags): Document
      restrictions.
      * include/libvirt/virterror.h (VIR_ERR_BLOCK_COPY_ACTIVE): New
      error.
      * src/util/virterror.c (virErrorMsg): Define it.
      36484692
  28. 12 4月, 2012 1 次提交
    • A
      blockjob: add API for async virDomainBlockJobAbort · a696f8b7
      Adam Litke 提交于
      Block job cancellation can take a while.  Now that upstream qemu 1.1
      has asynchronous block cancellation, we want to expose that to the user.
      Therefore, the following updates are made to the virDomainBlockJob API:
      
      A new block job event type VIR_DOMAIN_BLOCK_JOB_CANCELED is managed by
      libvirt.  Regardless of the flags used with virDomainBlockJobAbort, this
      event will be raised: 1. when using synchronous block_job_cancel (the
      event will be synthesized by libvirt), and 2. whenever it is received
      from qemu (via asynchronous block-job-cancel).  Note that the event
      may be detected by libvirt even before the virDomainBlockJobAbort
      completes (always true when it is synthesized, but also possible if
      cancellation was fast).
      
      A new extension flag VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC is added to the
      virDomainBlockJobAbort API.  When enabled, this function will allow
      (but not require) asynchronous operation (ie, it returns as soon as
      possible, which might be before the job has actually been canceled).
      When the API is used in this mode, it is the responsibility of the
      caller to wait for a VIR_DOMAIN_BLOCK_JOB_CANCELED event or poll via
      the virDomainGetBlockJobInfo API to check the cancellation status.
      
      This patch also exposes the new flag through virsh, and makes virsh
      slightly easier to use (--async implies --abort, and lack of any options
      implies --info), although it leaves the qemu implementation for later
      patches.
      Signed-off-by: NAdam Litke <agl@us.ibm.com>
      Cc: Stefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a696f8b7
  29. 24 3月, 2012 2 次提交
    • E
      snapshot: add atomic create flag · 4d5533ca
      Eric Blake 提交于
      Right now, it is appallingly easy to cause qemu disk snapshots
      to alter a domain then fail; for example, by requesting a two-disk
      snapshot where the second disk name resides on read-only storage.
      In this failure scenario, libvirt reports failure, but modifies
      the live domain XML in-place to record that the first disk snapshot
      was taken; and places a difficult burden on the management app
      to grab the XML and reparse it to see which disks, if any, were
      altered by the partial snapshot.
      
      This patch adds a new flag where implementations can request that
      the hypervisor make snapshots atomically; either no changes to
      XML occur, or all disks were altered as a group.  If you request
      the flag, you either get outright failure up front, or you take
      advantage of hypervisor abilities to make an atomic snapshot. Of
      course, drivers should prefer the atomic means even without the
      flag explicitly requested.
      
      There's no way to make snapshots 100% bulletproof - even if the
      hypervisor does it perfectly atomic, we could run out of memory
      during the followup tasks of updating our in-memory XML, and report
      a failure.  However, these sorts of catastrophic failures are rare
      and unlikely, and it is still nicer to know that either all
      snapshots happened or none of them, as that is an easier state to
      recover from.
      
      * include/libvirt/libvirt.h.in
      (VIR_DOMAIN_SNAPSHOT_CREATE_ATOMIC): New flag.
      * src/libvirt.c (virDomainSnapshotCreateXML): Document it.
      * tools/virsh.c (cmdSnapshotCreate, cmdSnapshotCreateAs): Expose it.
      * tools/virsh.pod (snapshot-create, snapshot-create-as): Document
      it.
      4d5533ca
    • E
      build: fix incorrect enum declaration · 9b6860f5
      Eric Blake 提交于
      Recent changes have caused build failures on systems where pdwtags works:
      commit a26a1969 mistakenly exported a public variable
      commits a26a1969, 57ddcc23, 487c0633 all had copy-paste bugs in
      hand-updating the golden API rather than rerunning pdwtags
      
      * include/libvirt/libvirt.h.in (virDomainEventTrayChangeReason):
      Make this a typedef, not external storage.
      * src/remote_protocol-structs (remote_procedure): Fix spelling.
      9b6860f5
  30. 23 3月, 2012 3 次提交
    • O
      qemu: Update domain status to running while wakeup event is emitted · 7c5a0c94
      Osier Yang 提交于
      This introduces a new running reason VIR_DOMAIN_RUNNING_WAKEUP,
      and new suspend event type VIR_DOMAIN_EVENT_STARTED_WAKEUP.
      
      While a wakeup event is emitted, the domain which entered into
      VIR_DOMAIN_PMSUSPENDED will be transferred to "running"
      with reason VIR_DOMAIN_RUNNING_WAKEUP, and a new domain lifecycle
      event emitted with type VIR_DOMAIN_EVENT_STARTED_WAKEUP.
      7c5a0c94
    • O
      New domain state pmsuspended · 54d9026a
      Osier Yang 提交于
      This introduces a new domain state pmsuspended to represent
      the domain which has been suspended by guest power management,
      e.g. (entered itno s3 state). Because a "running" state could
      be confused in this case, one will see the guest is paused
      actually while playing. And state "paused" is for the domain
      which was paused by virDomainSuspend.
      54d9026a
    • O
      Add support for the suspend event · 487c0633
      Osier Yang 提交于
      This patch introduces a new event type for the QMP event
      SUSPEND:
      
          VIR_DOMAIN_EVENT_ID_PMSUSPEND
      
      The event doesn't take any data, but considering there might
      be reason for wakeup in future, the callback definition is:
      
      typedef void
      (*virConnectDomainEventSuspendCallback)(virConnectPtr conn,
                                              virDomainPtr dom,
                                              int reason,
                                              void *opaque);
      
      "reason" is unused currently, always passes "0".
      487c0633