[libvirt] [PATCHv4 10/18] blockjob: return appropriate event and info
Jiri Denemark
jdenemar at redhat.com
Fri Apr 13 12:36:24 UTC 2012
On Mon, Apr 09, 2012 at 21:52:19 -0600, Eric Blake wrote:
> Handle the new type of block copy event and info. Of course,
> this patch does nothing until a later patch actually allows the
> creation/abort of a block copy job.
>
> * src/qemu/qemu_monitor_json.c (qemuMonitorJSONHandleBlockJobImpl)
> (qemuMonitorJSONGetBlockJobInfoOne): Translate new job type.
> * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Snoop a successful
> info query to save effort on a pivot request.
> ---
> src/qemu/qemu_driver.c | 6 ++++++
> src/qemu/qemu_monitor_json.c | 4 ++++
> 2 files changed, 10 insertions(+), 0 deletions(-)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index b0937eb..931e095 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -11687,6 +11687,12 @@ qemuDomainBlockJobImpl(virDomainPtr dom, const char *path, const char *base,
> if (ret < 0)
> goto endjob;
>
> + /* Snoop block copy operations, so future cancel operations can
> + * avoid checking if pivot is safe. */
> + if (mode == BLOCK_JOB_INFO && ret == 1 && vm->def->disks[idx]->mirror &&
> + info->cur == info->end && info->type == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY)
> + vm->def->disks[idx]->mirroring = true;
> +
> /* Qemu provides asynchronous block job cancellation, but without
> * the VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC flag libvirt guarantees a
> * synchronous operation. Provide this behavior by waiting here,
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 89f0eb8..8475dab 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -788,6 +788,8 @@ qemuMonitorJSONHandleBlockJobImpl(qemuMonitorPtr mon,
>
> if (STREQ(type_str, "stream"))
> type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL;
> + else if (STREQ(type_str, "mirror"))
> + type = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY;
>
> switch (event) {
> case VIR_DOMAIN_BLOCK_JOB_COMPLETED:
> @@ -3412,6 +3414,8 @@ static int qemuMonitorJSONGetBlockJobInfoOne(virJSONValuePtr entry,
> }
> if (STREQ(type, "stream"))
> info->type = VIR_DOMAIN_BLOCK_JOB_TYPE_PULL;
> + else if (STREQ(type, "mirror"))
> + info->type = VIR_DOMAIN_BLOCK_JOB_TYPE_COPY;
> else
> info->type = VIR_DOMAIN_BLOCK_JOB_TYPE_UNKNOWN;
OK
Jirka
More information about the libvir-list
mailing list