1. 16 4月, 2012 3 次提交
    • M
      qemuProcessStart: Switch to flags instead of bunch booleans · 63ddc65d
      Michal Privoznik 提交于
      Currently, we have 3 boolean arguments we have to pass
      to qemuProcessStart(). As libvirt grows it is harder and harder
      to remember them and their position. Therefore we should
      switch to flags instead.
      63ddc65d
    • O
      qemu: Avoid the memory allocation and freeing · 6fbd5737
      Osier Yang 提交于
      6fbd5737
    • O
      numad: Convert node list to cpumap before setting affinity · ccf80e36
      Osier Yang 提交于
      Instead of returning a CPUs list, numad returns NUMA node
      list instead, this patch is to convert the node list to
      cpumap before affinity setting. Otherwise, the domain
      processes will be pinned only to CPU[$numa_cell_num],
      which will cause significiant performance losses.
      
      Also because numad will balance the affinity dynamically,
      reflecting the cpuset from numad back doesn't make much
      sense then, and it may just could produce confusion for
      the users. Thus the better way is not to reflect it back
      to XML. And in this case, it's better to ignore the cpuset
      when parsing XML.
      
      The codes to update the cpuset is removed in this patch
      incidentally, and there will be a follow up patch to ignore
      the manually specified "cpuset" if "placement" is "auto",
      and document will be updated too.
      ccf80e36
  2. 13 4月, 2012 2 次提交
  3. 12 4月, 2012 5 次提交
    • M
      qemuOpenFile: Don't force chown on NFS · b1256816
      Michal Privoznik 提交于
      If dynamic_ownership is off and we are creating a file on NFS
      we force chown. This will fail as chown/chmod are not supported
      on NFS. However, with no dynamic_ownership we are not required
      to do any chown.
      b1256816
    • E
      blockjob: allow for fast-finishing job · a9d3495e
      Eric Blake 提交于
      In my testing, I was able to provoke an odd block pull failure:
      
      $ virsh blockpull dom vda --bandwidth 10000
      error: Requested operation is not valid: No active operation on device: drive-virtio-disk0
      
      merely by using gdb to artifically wait to do the block job set speed
      until after the pull had already finished.  But in reality, that should
      be a success, since the pull finished before we had a chance to set
      speed.  Furthermore, using a double job lock is not only annoying, but
      a bug in itself - if you do parallel virDomainBlockRebase, and hit
      the race window just right, the first call grabs the VM job to start
      a fast block job, then the second call grabs the VM job to start
      a long-running job with unspecified speed, then the first call finally
      regrabs the VM job and sets the speed, which ends up running the
      second job under the speed from the first call.  By consolidating
      things into a single job, we avoid opening that race, as well as reduce
      the time between starting the job and changing the speed, for less
      likelihood of the speed change happening after block job completion
      in the first place.
      
      * src/qemu/qemu_monitor.h (BLOCK_JOB_CMD): Add new mode.
      * src/qemu/qemu_driver.c (qemuDomainBlockRebase): Move secondary
      job call...
      (qemuDomainBlockJobImpl): ...here, for fewer locks.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Change
      return value on new internal mode.
      a9d3495e
    • E
      blockjob: wire up qemu async virDomainBlockJobAbort · a91ce852
      Eric Blake 提交于
      Without the VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag, libvirt will internally
      poll using qemu's "query-block-jobs" API and will not return until the
      operation has been completed.  API users are advised that this operation
      is unbounded and further interaction with the domain during this period
      may block.  Future patches may refactor things to allow other queries in
      parallel with this polling.  For older qemu, we synthesize the cancellation
      event, since qemu won't generate it.
      
      The choice of polling duration copies from the code in qemu_migration.c.
      Signed-off-by: NAdam Litke <agl@us.ibm.com>
      Cc: Stefan Hajnoczi <stefanha@gmail.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      a91ce852
    • E
      blockjob: optimize JSON event handler lookup · ecb39e9d
      Eric Blake 提交于
      Probably in the noise, but this will let us scale more efficiently
      as we learn to recognize even more qemu events.
      
      * src/qemu/qemu_monitor_json.c (eventHandlers): Sort.
      (qemuMonitorEventCompare): New helper function.
      (qemuMonitorJSONIOProcessEvent): Optimize event lookup.
      ecb39e9d
    • E
      blockjob: add qemu capabilities related to block pull jobs · 2b085f5b
      Eric Blake 提交于
      RHEL 6.2 was released with an early version of block jobs, which only
      worked on the qed file format, where the commands were spelled with
      underscore (contrary to QMP style), and where 'block_job_cancel' was
      synchronous and did not trigger an event.
      
      The upcoming qemu 1.1 release has fixed these short-comings [1][2]:
      the commands now work on multiple file types, are spelled with dash,
      and 'block-job-cancel' is asynchronous and emits an event upon conclusion.
      
      [1]qemu commit 370521a1d6f5537ea7271c119f3fbb7b0fa57063
      [2]https://lists.gnu.org/archive/html/qemu-devel/2012-04/msg01248.html
      
      This patch recognizes the new spellings, and fixes virDomainBlockRebase
      to give a graceful error when talking to a too-old qemu on a partial
      rebase attempt.  Fixes for the new semantics will come later.  This
      patch also removes a bogus ATTRIBUTE_NONNULL mistakenly added in
      commit 10ec36e2.
      
      * src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC)
      (QEMU_CAPS_BLOCKJOB_ASYNC): New bits.
      * src/qemu/qemu_capabilities.c (qemuCaps): Name them.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONCheckCommands): Set
      them.
      (qemuMonitorJSONBlockJob): Manage both command names.
      (qemuMonitorJSONDiskSnapshot): Minor formatting fix.
      * src/qemu/qemu_monitor.h (qemuMonitorBlockJob): Alter signature.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockJob): Likewise.
      * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Pass through
      capability bit.
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Update callers.
      2b085f5b
  4. 11 4月, 2012 4 次提交
    • P
      qemu: Fix deadlock when qemuDomainOpenConsole cleans up a connection · 3d3de46a
      Peter Krempa 提交于
      The new safe console handling introduced a possibility to deadlock the
      qemu driver when a new console connection forcibly disconnects a
      previous console stream that belongs to an already closed connection.
      
      The virStreamFree function calls subsequently a the virReleaseConnect
      function that tries to lock the driver while discarding the connection,
      but the driver was already locked in qemuDomainOpenConsole.
      
      Backtrace of the deadlocked thread:
      0  0x00007f66e5aa7f14 in __lll_lock_wait () from /lib64/libpthread.so.0
      1  0x00007f66e5aa3411 in _L_lock_500 () from /lib64/libpthread.so.0
      2  0x00007f66e5aa322a in pthread_mutex_lock () from/lib64/libpthread.so.0
      3  0x0000000000462bbd in qemudClose ()
      4  0x00007f66e6e178eb in virReleaseConnect () from/usr/lib64/libvirt.so.0
      5  0x00007f66e6e19c8c in virUnrefStream () from /usr/lib64/libvirt.so.0
      6  0x00007f66e6e3d1de in virStreamFree () from /usr/lib64/libvirt.so.0
      7  0x00007f66e6e09a5d in virConsoleHashEntryFree () from/usr/lib64/libvirt.so.0
      8  0x00007f66e6db7282 in virHashRemoveEntry () from/usr/lib64/libvirt.so.0
      9  0x00007f66e6e09c4e in virConsoleOpen () from /usr/lib64/libvirt.so.0
      10 0x00000000004526e9 in qemuDomainOpenConsole ()
      11 0x00007f66e6e421f1 in virDomainOpenConsole () from/usr/lib64/libvirt.so.0
      12 0x00000000004361e4 in remoteDispatchDomainOpenConsoleHelper ()
      13 0x00007f66e6e80375 in virNetServerProgramDispatch () from/usr/lib64/libvirt.so.0
      14 0x00007f66e6e7ae11 in virNetServerHandleJob () from/usr/lib64/libvirt.so.0
      15 0x00007f66e6da897d in virThreadPoolWorker () from/usr/lib64/libvirt.so.0
      16 0x00007f66e6da7ff6 in virThreadHelper () from/usr/lib64/libvirt.so.0
      17 0x00007f66e5aa0c5c in start_thread () from /lib64/libpthread.so.0
      18 0x00007f66e57e7fcd in clone () from /lib64/libc.so.6
      
      * src/qemu/qemu_driver.c: qemuDomainOpenConsole()
              -- unlock the qemu driver right after acquiring the domain
              object
      3d3de46a
    • J
      qemu: Warn on possibly incorrect usage of EnterMonitor* · 6eede368
      Jiri Denemark 提交于
      qemuDomainObjEnterMonitor{,WithDriver} should not be called from async
      jobs, only EnterMonitorAsync variant is allowed.
      6eede368
    • J
      qemu: Track job owner for better debugging · 08ec1d78
      Jiri Denemark 提交于
      In case an API fails with "cannot acquire state change lock", searching
      for the API that possibly forgot to end its job is not always easy.
      Let's keep track of the job owner and print it out for easier
      identification.
      08ec1d78
    • J
      qemu: Avoid excessive calls to qemuDomainObjSaveJob() · 31796e2c
      Jiri Denemark 提交于
      As reported by Daniel Berrangé, we have a huge performance regression
      for virDomainGetInfo() due to the change which makes virDomainEndJob()
      save the XML status file every time it is called. Previous to that
      change, 2000 calls to virDomainGetInfo() took ~2.5 seconds. After that
      change, 2000 calls to virDomainGetInfo() take 2 *minutes* 45 secs.
      
      We made the change to be able to recover from libvirtd restart in the
      middle of a job. However, only destroy and async jobs are taken care of.
      Thus it makes more sense to only save domain state XML when these jobs
      are started/stopped.
      31796e2c
  5. 10 4月, 2012 1 次提交
    • D
      Wire up <loader> to set the QEMU BIOS path · ddf2dfa1
      Daniel P. Berrange 提交于
      * src/qemu/qemu_command.c: Wire up -bios with <loader>
      * tests/qemuxml2argvdata/qemuxml2argv-bios.args,
        tests/qemuxml2argvdata/qemuxml2argv-bios.xml: Expand
        existing BIOS test case to cover <loader>
      ddf2dfa1
  6. 06 4月, 2012 2 次提交
    • E
      snapshot: fix memory leak on error · 14135609
      Eric Blake 提交于
      Leak introduced in commit 0436d328.  If we allocate an actions array,
      but fail early enough to never consume it with the qemu monitor
      transaction call, we leaked memory.
      
      But our semantics of making the transaction command free the caller's
      memory is awkward; avoiding the memory leak requires making every
      intermediate function in the call chain check for error.  It is much
      easier to fix things so that the function that allocates also frees,
      while the call chain leaves the caller's data intact.  To do that,
      I had to hack our JSON data structure to make it easy to protect a
      portion of an arbitrary JSON tree from being freed.
      
      * src/util/json.h (virJSONType): Name the enum.
      (_virJSONValue): New field.
      * src/util/json.c (virJSONValueFree): Use it to protect a portion
      of an array.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONTransaction): Avoid
      freeing caller's data.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive):
      Free actions array on failure.
      14135609
    • M
      qemu_ga: Don't overwrite errors on FSThaw · 650da0e9
      Michal Privoznik 提交于
      We can tell qemuDomainSnapshotFSThaw if we want it to report errors or
      not. However, if we don't want to and an error has been already set by
      previous qemuReportError() we must keep copy of that error not just a
      pointer to it. Otherwise, it get overwritten if FSThaw reports an error.
      650da0e9
  7. 04 4月, 2012 3 次提交
  8. 03 4月, 2012 1 次提交
    • J
      qemu: Start nested job in qemuDomainCheckEjectableMedia · 66cab01a
      Jiri Denemark 提交于
      Originally, qemuDomainCheckEjectableMedia was entering monitor with qemu
      driver lock. Commit 2067e31b, which I
      made to fix that, revealed another issue we had (but didn't notice it
      since the driver was locked): we didn't set nested job when
      qemuDomainCheckEjectableMedia is called during migration. Thus the
      original fix I made was wrong.
      66cab01a
  9. 02 4月, 2012 1 次提交
    • P
      Support clock=variable relative to localtime · b8bf79aa
      Philipp Hahn 提交于
      Since Xen 3.1 the clock=variable semantic is supported. In addition to
      qemu/kvm Xen also knows about a variant where the offset is relative to
      'localtime' instead of 'utc'.
      
      Extends the libvirt structure with a flag 'basis' to specify, if the
      offset is relative to 'localtime' or 'utc'.
      
      Extends the libvirt structure with a flag 'reset' to force the reset
      behaviour of 'localtime' and 'utc'; this is needed for backward
      compatibility with previous versions of libvirt, since they report
      incorrect XML.
      
      Adapt the only user 'qemu' to the new name.
      Extend the RelaxNG schema accordingly.
      Document the new 'basis' attribute in the HTML documentation.
      Adapt test for the new attribute.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      b8bf79aa
  10. 31 3月, 2012 5 次提交
    • E
      qemu: reflect any memory rounding back to xml · 095b0bc4
      Eric Blake 提交于
      If we round up a user's memory request, we should update the XML
      to reflect the actual value in use by the VM, rather than giving
      an artificially small value back to the user.
      
      * src/qemu/qemu_command.c (qemuBuildNumaArgStr)
      (qemuBuildCommandLine): Reflect rounding back to XML.
      095b0bc4
    • H
      qemu: support live change of the bridge used by a guest network device · 2711ac87
      Hendrik Schwartke 提交于
      This patch was created to resolve this upstream bug:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=784767
      
      and is at least a partial solution to this RHEL RFE:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=805071
      
      Previously the only attribute of a network device that could be
      modified by virUpdateDeviceFlags() ("virsh update-device") was the
      link state; attempts to change any other attribute would log an error
      and fail.
      
      This patch adds recognition of a change in bridge device name, and
      supports reconnecting the guest's interface to the new device.
      Standard audit logs for detaching and attaching a network device are
      also generated. Although the current auditing function doesn't log the
      bridge being attached to, this will later be changed in a separate
      patch.
      2711ac87
    • L
      qemu: eliminate nested switch, simplify code · ecde1591
      Laine Stump 提交于
      qemuBuildHostNetStr had a switch-within-a-switch where both were
      looking at the same variable. This was apparently to take advantage of
      code common to three different cases (while also taking care of some
      code that was different). However, there were only 2 lines common to
      all, one of those can be eliminated by merging it into the
      virAsprintfs that are in each case. On top of that, all the extra
      empty cases cause Coverity complaints (because they are unreachable),
      but absence of the empty cases causes a compile error due to
      "enumeration value not handled in switch".
      
      The solution is to just make each toplevel case independent, folding
      in the common code to each.
      ecde1591
    • L
      qemu: set default name for SPICE agent channel when generating command · 3269ee65
      Laine Stump 提交于
      commit b0e2bb33 set a default value for the SPICE agent channel by
      inserting it during parsing of the channel XML. That method of setting
      a default is problematic because it makes a format/parse roundtrip
      unclean, and experience with setting other values as a side effect of
      parsing has led to headaches (e.g. automatically setting a MAC address
      in the parser when one isn't specified in the input XML).
      
      This patch does not revert commit b0e2bb33 (it will be reverted in a
      separate patch) but adds the alternate implementation of simply
      inserting the default value in the appropriate place on the qemu
      commandline when no value is provided.
      3269ee65
    • M
      qemu_agent: Issue guest-sync prior to every command · 075c8518
      Michal Privoznik 提交于
      If we issue guest command and GA is not running, the issuing thread
      will block endlessly. We can check for GA presence by issuing
      guest-sync with unique ID (timestamp). We don't want to issue real
      command as even if GA is not running, once it is started, it process
      all commands written to GA socket.
      075c8518
  11. 30 3月, 2012 2 次提交
    • D
      Consistent style for usage of sizeof operator · ec8cae93
      Daniel P. Berrange 提交于
      The code is splattered with a mix of
      
        sizeof foo
        sizeof (foo)
        sizeof(foo)
      
      Standardize on sizeof(foo) and add a syntax check rule to
      enforce it
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      ec8cae93
    • W
      fix a deadlock when qemu cannot start · ff68d6ee
      Wen Congyang 提交于
      When qemu cannot start, we may call qemuProcessStop() twice.
      We have check whether the vm is running at the beginning of
      qemuProcessStop() to avoid libvirt deadlock. We call
      qemuProcessStop() with driver and vm locked. It seems that
      we can avoid libvirt deadlock. But unfortunately we may
      unlock driver and vm in the function qemuProcessKill() while
      vm->def->id is not -1. So qemuProcessStop() will be run twice,
      and monitor will be freed unexpectedly. So we should set
      vm->def->id to -1 at the beginning of qemuProcessStop().
      ff68d6ee
  12. 29 3月, 2012 1 次提交
    • C
      qemu: Make migration fail when port profile association fails on the dst host · a02500d0
      Christian Benvenuti 提交于
      In the current V3 migration protocol, Libvirt does not
      check the result of the function
      
        qemuMigrationVPAssociatePortProfiles
      
      This means that it is possible for a migration to complete
      successfully even when the VM loses network connectivity on
      the destination host.
      
      With this change libvirt aborts the migration
      (during the "finish" step) when the above function fails, that
      is to say when at least one of the port profile associations fails.
      
      Signed-off by: Christian Benvenuti <benve@cisco.com>
      a02500d0
  13. 27 3月, 2012 6 次提交
    • E
      snapshot: don't pass NULL to QMP command creation · a14eda31
      Eric Blake 提交于
      Commit d42a2ffc caused a regression in creating a disk-only snapshot
      of a qcow2 disk; by passing the wrong variable to the monitor call,
      libvirt ended up creating JSON that looked like "format":null instead
      of the intended "format":"qcow2".
      
      To make it easier to diagnose this in the future, make JSON creation
      error out if "s:arg" is paired with NULL (it is still possible to
      use "n:arg" in the rare cases where qemu will accept a null).
      
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotCreateSingleDiskActive): Pass correct value.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONMakeCommandRaw):
      Improve error message.
      a14eda31
    • D
      qemu,util: on restart of libvirt restart vepa callbacks · bd6b0a05
      D. Herrendoerfer 提交于
      When libvirtd is restarted, also restart the netlink event
      message callbacks for existing VEPA connections and send
      a message to lldpad for these existing links, so it learns
      the new libvirtd pid.
      Signed-off-by: ND. Herrendoerfer <d.herrendoerfer@herrendoerfer.name>
      bd6b0a05
    • J
      qemu: Avoid entering monitor with locked driver · 2067e31b
      Jiri Denemark 提交于
      This avoids possible deadlock of the qemu driver in case a domain is
      begin migrated (in Begin phase) and unrelated connection to qemu driver
      is closed at the right time.
      
      I checked all callers of qemuDomainCheckEjectableMedia() and they are
      calling this function with qemu driver locked.
      2067e31b
    • L
      build: fix "missing initializer" error in qemu_process.c · ecb4d92d
      Laine Stump 提交于
      Found when attempting to build on Fedora 17 alpha with:
      
         ./autogen.sh --system --enable-compile-warnings=error
      
      (this same build command works without problem on Fedora 16). Since
      the consumer of the qemuProcessReconnectData doesn't assume that the
      other fields of the struct are initialized (although it uses them
      internally), the simpler solution is to just switch to C99-style
      struct initialization (which doesn't require specification of all
      fields).
      ecb4d92d
    • L
      build: avoid frame size error when building without -O2 · cf57d345
      Laine Stump 提交于
      libvirt always adds -Werror-frame-larger-than=4096 to the flags when
      it builds. When building on Fedora 17, two functions with multiple
      1024 buffers declared inside if {} blocks would generate frame size
      errors; apparently the version of gcc on Fedora 16 will merge these
      multiple buffers into a single buffer even when optimization is off,
      but Fedora 17 won't.
      
      The fix is to declare a single 1024 buffer at the top of the two
      offending functions, and reuse the single buffer throughout the
      functions.
      cf57d345
    • M
      Cleanup for a return statement in source files · 9943276f
      Martin Kletzander 提交于
      Return statements with parameter enclosed in parentheses were modified
      and parentheses were removed. The whole change was scripted, here is how:
      
      List of files was obtained using this command:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$'
      
      Found files were modified with this command:
      sed -i -e                                                                 \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      
      Then checked for nonsense.
      
      The whole command looks like this:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e                            \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      9943276f
  14. 24 3月, 2012 4 次提交
    • O
      spec: Add missed dependancy for numad · beb76e37
      Osier Yang 提交于
      numad is available since Fedora 17 and RHEL6.X. And it's not supported
      on s390[x] and ARM.
      beb76e37
    • E
      snapshot: improve qemu handling of reused snapshot targets · d42a2ffc
      Eric Blake 提交于
      The oVirt developers have stated that the real reasons they want
      to have qemu reuse existing volumes when creating a snapshot are:
      1. the management framework is set up so that creation has to be
      done from a central node for proper resource tracking, and having
      libvirt and/or qemu create things violates the framework, and
      2. qemu defaults to creating snapshots with an absolute path to
      the backing file, but oVirt wants to manage a backing chain that
      uses just relative names, to allow for easier migration of a chain
      across storage locations.
      
      When 0.9.10 added VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT (commit
      4e9953a4), it only addressed point 1, but libvirt was still using
      O_TRUNC which violates point 2.  Meanwhile, the new qemu
      'transaction' monitor command includes a new optional mode argument
      that will force qemu to reuse the metadata of the file it just
      opened (with the burden on the caller to have valid metadata there
      in the first place).  So, this tweaks the meaning of the flag to
      cover both points as intended for use by oVirt.  It is not strictly
      backward-compatible to 0.9.10 behavior, but it can be argued that
      the O_TRUNC of 0.9.10 was a bug.
      
      Note that this flag is all-or-nothing, and only selects between
      'existing' and the default 'absolute-paths'.  A more flexible
      approach that would allow per-disk selections, as well as adding
      support for the 'no-backing-file' mode, would be possible by
      extending the <domainsnapshot> xml to have a per-disk mode, but
      until we have a management application expressing a need for that
      additional complexity, it is not worth doing.
      
      * src/libvirt.c (virDomainSnapshotCreateXML): Tweak documentation.
      * src/qemu/qemu_monitor.h (qemuMonitorDiskSnapshot): Add
      parameters.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskSnapshot):
      Likewise.
      * src/qemu/qemu_monitor.c (qemuMonitorDiskSnapshot): Pass them
      through.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskSnapshot): Use
      new monitor command arguments.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive)
      (qemuDomainSnapshotCreateSingleDiskActive): Adjust callers.
      (qemuDomainSnapshotDiskPrepare): Allow qed, modify rules on reuse.
      d42a2ffc
    • E
      snapshot: wire up qemu transaction command · 0436d328
      Eric Blake 提交于
      The hardest part about adding transactions is not using the new
      monitor command, but undoing the partial changes we made prior
      to a failed transaction.
      
      * src/qemu/qemu_driver.c (qemuDomainSnapshotCreateDiskActive): Use
      transaction when available.
      (qemuDomainSnapshotUndoSingleDiskActive): New function.
      (qemuDomainSnapshotCreateSingleDiskActive): Pass through actions.
      (qemuDomainSnapshotCreateXML): Adjust caller.
      0436d328
    • E
      snapshot: add support for qemu transaction command · 64d5e815
      Eric Blake 提交于
      QEmu 1.1 is adding a 'transaction' command to the JSON monitor.
      Each element of a transaction corresponds to a top-level command,
      with the additional guarantee that the transaction flushes all
      pending I/O, then guarantees that all actions will be successful
      as a group or that failure will roll back the state to what it
      was before the monitor command.  The difference between a
      top-level command:
      
      { "execute": "blockdev-snapshot-sync", "arguments":
        { "device": "virtio0", ... } }
      
      and a transaction:
      
      { "execute": "transaction", "arguments":
        { "actions": [
          { "type": "blockdev-snapshot-sync", "data":
            { "device": "virtio0", ... } } ] } }
      
      is just a couple of changed key names and nesting the shorter
      command inside a JSON array to the longer command.  This patch
      just adds the framework; the next patch will actually use a
      transaction.
      
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONMakeCommand): Move
      guts...
      (qemuMonitorJSONMakeCommandRaw): ...into new helper.  Add support
      for array element.
      (qemuMonitorJSONTransaction): New command.
      (qemuMonitorJSONDiskSnapshot): Support use in a transaction.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskSnapshot): Add
      argument.
      (qemuMonitorJSONTransaction): New declaration.
      * src/qemu/qemu_monitor.h (qemuMonitorTransaction): Likewise.
      (qemuMonitorDiskSnapshot): Add argument.
      * src/qemu/qemu_monitor.c (qemuMonitorTransaction): New wrapper.
      (qemuMonitorDiskSnapshot): Pass argument on.
      * src/qemu/qemu_driver.c
      (qemuDomainSnapshotCreateSingleDiskActive): Update caller.
      64d5e815