From e435cb49b117103ed89054fd0c48f9ed30cb5d98 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <5e4659718c6d6ee9ab11b269d929a292a71b3ab0.1334770230.git.minovotn@redhat.com> References: <5e4659718c6d6ee9ab11b269d929a292a71b3ab0.1334770230.git.minovotn@redhat.com> From: Paolo Bonzini Date: Fri, 13 Apr 2012 16:27:21 +0200 Subject: [PATCH 13/18] block: cancel job on drive-reopen RH-Author: Paolo Bonzini Message-id: <1334334446-31987-12-git-send-email-pbonzini@redhat.com> Patchwork-id: 39221 O-Subject: [RHEL 6.3 qemu-kvm PATCH 11/16] block: cancel job on drive-reopen Bugzilla: 806432 RH-Acked-by: Kevin Wolf RH-Acked-by: Laszlo Ersek RH-Acked-by: Jeffrey Cody Bugzilla: 806432 Upstream status: submitted as part of the mirroring forward-port When used to switch storage after mirroring, drive-reopen must atomically cancel the mirroring job and open the target. Do this before calling bdrv_in_use. This has a nice side effect: if block_job_cancel_sync fails to complete the job due to a bug, reopening will fail instead of proceeding with corrupted data! --- blockdev.c | 3 +++ 1 file changed, 3 insertions(+) Signed-off-by: Michal Novotny --- blockdev.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/blockdev.c b/blockdev.c index 56acb63..a29416e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -693,6 +693,9 @@ void qmp___com_redhat_drive_reopen(const char *device, const char *new_image_fil error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } + if (bs->job) { + block_job_cancel_sync(bs->job); + } if (bdrv_in_use(bs)) { error_set(errp, QERR_DEVICE_IN_USE, device); return; -- 1.7.7.6