From bee444cb2782df23066042547b4b8d8305695b49 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: From: Paolo Bonzini Date: Tue, 24 Apr 2012 14:01:32 +0200 Subject: [PATCH 5/8] block: drive-reopen fixes RH-Author: Paolo Bonzini Message-id: <1335276095-25813-6-git-send-email-pbonzini@redhat.com> Patchwork-id: 39430 O-Subject: [RHEL 6.3 qemu-kvm PATCH 5/8] block: drive-reopen fixes Bugzilla: 813862 RH-Acked-by: Marcelo Tosatti RH-Acked-by: Kevin Wolf RH-Acked-by: Jeffrey Cody Bugzilla: 813862 - documentation fixes (Eric) - refuse to reopen unless the job completes successfully (Marcelo) RHEL-only. --- blockdev.c | 10 +++++++++- qapi-schema.json | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) Signed-off-by: Michal Novotny --- blockdev.c | 10 +++++++++- qapi-schema.json | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index ae8ee6c..466bef5 100644 --- a/blockdev.c +++ b/blockdev.c @@ -706,7 +706,15 @@ void qmp___com_redhat_drive_reopen(const char *device, const char *new_image_fil return; } if (bs->job) { - block_job_cancel_sync(bs->job); + int ret = block_job_cancel_sync(bs->job); + + /* Do not complete the switch if the job had an I/O error or + * was canceled (for mirroring, the target was not synchronized + * completely). + */ + if (ret != 0) { + error_set(errp, QERR_DEVICE_IN_USE, device); + } } if (bdrv_in_use(bs)) { error_set(errp, QERR_DEVICE_IN_USE, device); diff --git a/qapi-schema.json b/qapi-schema.json index 22f770c..d37ee94 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -131,7 +131,8 @@ # @new-image-file: the target of the new image. If the file doesn't exists the # command will fail. # -# @format: #optional the format of the new image, default is 'qcow2'. +# @format: #optional the format of the new image, default is to probe the +# image file # # @witness: A file descriptor name that was passed via getfd. QEMU will write # a single byte to this file descriptor before completing the command -- 1.7.7.6