From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zhgoe-0008Bk-Ql for qemu-devel@nongnu.org; Thu, 01 Oct 2015 12:34:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zhgob-0005AK-3W for qemu-devel@nongnu.org; Thu, 01 Oct 2015 12:34:44 -0400 From: John Snow Date: Thu, 1 Oct 2015 12:34:31 -0400 Message-Id: <1443717273-5280-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1443717273-5280-1-git-send-email-jsnow@redhat.com> References: <1443717273-5280-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] block: prohibit migration during BlockJobs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, John Snow Unless we can prove this to be safe for specific cases, the default should be to prohibit migration during BlockJobs. In conjunction with "migration: disallow_migrate_add_blocker during migration", this should be sufficient to disallow the blockjob from starting in the event of an in-progress migration. Signed-off-by: John Snow --- blockjob.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/blockjob.c b/blockjob.c index 62bb906..b5849b3 100644 --- a/blockjob.c +++ b/blockjob.c @@ -35,12 +35,14 @@ #include "qmp-commands.h" #include "qemu/timer.h" #include "qapi-event.h" +#include "migration/migration.h" void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, int64_t speed, BlockCompletionFunc *cb, void *opaque, Error **errp) { BlockJob *job; + int ret; if (bs->job) { error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs)); @@ -71,6 +73,14 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, return NULL; } } + + /* Re-use the op-blocker as a migration blocker */ + ret = migrate_add_blocker(job->blocker, errp); + if (ret < 0) { + block_job_release(bs); + return NULL; + } + return job; } @@ -80,6 +90,7 @@ void block_job_release(BlockDriverState *bs) bs->job = NULL; bdrv_op_unblock_all(bs, job->blocker); + migrate_del_blocker(job->blocker); error_free(job->blocker); g_free(job); } -- 2.4.3