Description of problem: http://libvirt.org/html/libvirt-libvirt.html#virDomainBlockJobAbort The API virDomainBlockJobAbort should be sync default. But with VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT flag, the api is async, not sync. if (disk->mirror && mode == BLOCK_JOB_ABORT && (flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT)) { ret = qemuDomainBlockPivot(conn, driver, vm, device, disk); goto endjob; } After called qemuDomainBlockPivot, the code goto the endjob. That skip the block simulation code. Version-Release number of selected component (if applicable): Trunk code How reproducible: Steps to Reproduce: 1. virDomainBlockRebase with VIR_DOMAIN_BLOCK_REBASE_COPY flag 2. virDomainBlockJobAbort with VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT flag Actual results: virDomainBlockJobAbort is async Expected results: virDomainBlockJobAbort is sync Additional info:
From what I understand, the "block-job-complete" qmp command called by qemuDomainBlockPivot() is inherently synchronous and thus we don't need to simulate the blocking of the API.
From this test code http://git.qemu.org/?p=qemu.git;a=blob_plain;f=tests/qemu-iotests/041;hb=HEAD to see, the block-job-complete is async. Even if you are right 'block-job-complete' is sync, that also means VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag doesn't work.
Blech. qemu's block-job-complete is inherently async - it merely requests the end of a job and returns control immediately; but the job may take a while longer to actually end because of time spent flushing sectors to disk. Looks like I introduced the bug when adding blockcopy in commit eaba79d, and that I merely need to update where the goto jumps.
We've explicitly documented that the VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag can, but not must, return control before the job has actually ended. Ignoring the async flag is not a problem. But when the flag is not present, and we have promised sync behavior, then libvirt does need to wait for the event.
Upstream patch proposed: https://www.redhat.com/archives/libvir-list/2014-July/msg00664.html
Fixed for 1.2.7: commit 97c59b9c46f915c48cd5db96ada40f060553bcae Author: Eric Blake <eblake> Date: Mon Jul 14 10:13:18 2014 -0600 blockjob: wait for pivot to complete https://bugzilla.redhat.com/show_bug.cgi?id=1119173 documents that commit eaba79d was flawed in the implementation of the VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag when it comes to completing a blockcopy. Basically, the qemu pivot action is async (the QMP command returns immediately, but the user must wait for the BLOCK_JOB_COMPLETE event to know that all I/O related to the job has finally been flushed), but the libvirt command was documented as synchronous by default. As active block commit will also be using this code, it is worth fixing now. * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Don't skip wait loop after pivot. Signed-off-by: Eric Blake <eblake>