blockjob: support pivot operation on cancel
blockjob: support pivot operation on cancel

This is the bare minimum to end a copy job (of course, until a
later patch adds the ability to start a copy job, this patch
doesn't do much in isolation; I've just split the patches to
ease the review).

This patch intentionally avoids SELinux, lock manager, and audit
actions.  Also, if libvirtd restarts at the exact moment that a
'block-job-complete' is in flight, the proposed proper way to
detect the outcome of that would be with a persistent bitmap and
some additional query commands when libvirtd restarts.  This
patch is enough to test the common case of success when used
correctly, while saving the subtleties of proper cleanup for
worst-case errors for later.

When a mirror job is started, cancelling the job safely reverts back
to the source disk, regardless of whether the destination is in
phase 1 (streaming, in which case the destination is worthless) or
phase 2 (mirroring, in which case the destination is synced up to
the source at the time of the cancel).  Our existing code does just
fine in either phase, other than some bookkeeping cleanup; this
implements live block copy.

Ideas for future enhancements via new flags:

Depending on when persistent bitmap support is added, it may be
worth adding a VIR_DOMAIN_REBASE_COPY_ATOMIC flag that fails up
front if we detect an older qemu with risky pivot operation.

Interesting side note: while snapshot-create --disk-only creates a
copy of the disk at a point in time by moving the domain on to a
new file (the copy is the file now in the just-extended backing
chain), blockjob --abort of a copy job creates a copy of the disk
while keeping the domain on the original file.  There may be
potential improvements to the snapshot code to exploit block copy
over multiple disks all at one point in time.  And, if
'block-job-cancel' were made part of 'transaction', you could
copy multiple disks at the same point in time without pausing
the domain.  This also implies we may want to add a --quiesce flag
to virDomainBlockJobAbort, so that when breaking a mirror (whether
by cancel or pivot), the side of the mirror that we are abandoning
is at least in a stable state with regards to guest I/O.

* src/qemu/qemu_driver.c (qemuDomainBlockJobAbort): Accept new flag.
(qemuDomainBlockPivot): New helper function.
(qemuDomainBlockJobImpl): Implement it.

jardasgit/libvirt,rlaager/libvirt,cbosdo/libvirt,crobinso/libvirt,zhlcindy/libvirt-1.1.4-maintain,zippy2/libvirt,taget/libvirt,elmarco/libvirt,olafhering/libvirt,emaste/libvirt,olafhering/libvirt,cbosdo/libvirt,siboulet/libvirt-openvz,olafhering/libvirt,VenkatDatta/libvirt,siboulet/libvirt-openvz,jeckersb/libvirt,olafhering/libvirt,novel/fbsd-libvirt,zippy2/libvirt,siboulet/libvirt-openvz,taget/libvirt,trainstack/libvirt,emaste/libvirt,fabianfreyer/libvirt,libvirt/libvirt,jardasgit/libvirt,jeckersb/libvirt,rlaager/libvirt,zhlcindy/libvirt-1.1.4-maintain,trainstack/libvirt,iam-TJ/libvirt,andreabolognani/libvirt,emaste/libvirt,shugaoye/libvirt,trainstack/libvirt,andreabolognani/libvirt,siboulet/libvirt-openvz,iam-TJ/libvirt,novel/fbsd-libvirt,andreabolognani/libvirt,bjzhang/libvirt,novel/fbsd-libvirt,shugaoye/libvirt,crobinso/libvirt,bjzhang/libvirt,jfehlig/libvirt,datto/libvirt,elmarco/libvirt,zhlcindy/libvirt-1.1.4-maintain,fabianfreyer/libvirt,iam-TJ/libvirt,jfehlig/libvirt,VenkatDatta/libvirt,nertpinx/libvirt,shugaoye/libvirt,novel/fbsd-libvirt,iam-TJ/libvirt,jardasgit/libvirt,elmarco/libvirt,elmarco/libvirt,andreabolognani/libvirt,VenkatDatta/libvirt,cbosdo/libvirt,VenkatDatta/libvirt,crobinso/libvirt,iam-TJ/libvirt,taget/libvirt,libvirt/libvirt,agx/libvirt,VenkatDatta/libvirt,datto/libvirt,siboulet/libvirt-openvz,eskultety/libvirt,jardasgit/libvirt,novel/fbsd-libvirt,datto/libvirt,novel/fbsd-libvirt,jeckersb/libvirt,iam-TJ/libvirt,andreabolognani/libvirt,trainstack/libvirt,jeckersb/libvirt,rlaager/libvirt,shugaoye/libvirt,bjzhang/libvirt,eskultety/libvirt,cbosdo/libvirt,emaste/libvirt,jfehlig/libvirt,trainstack/libvirt,datto/libvirt,zhlcindy/libvirt-1.1.4-maintain,nertpinx/libvirt,agx/libvirt,fabianfreyer/libvirt,jfehlig/libvirt,jeckersb/libvirt,agx/libvirt,agx/libvirt,jardasgit/libvirt,bjzhang/libvirt,zippy2/libvirt,libvirt/libvirt,rlaager/libvirt,jeckersb/libvirt,agx/libvirt,novel/fbsd-libvirt,emaste/libvirt,zippy2/libvirt,trainstack/libvirt,rlaager/libvirt,nertpinx/libvirt,taget/libvirt,taget/libvirt,eskultety/libvirt,zhlcindy/libvirt-1.1.4-maintain,shugaoye/libvirt,fabianfreyer/libvirt,eskultety/libvirt,nertpinx/libvirt,emaste/libvirt,trainstack/libvirt,eskultety/libvirt,cbosdo/libvirt,novel/fbsd-libvirt,bjzhang/libvirt,emaste/libvirt,fabianfreyer/libvirt,crobinso/libvirt,novel/fbsd-libvirt,nertpinx/libvirt,datto/libvirt,jeckersb/libvirt,elmarco/libvirt,iam-TJ/libvirt,libvirt/libvirt