From patchwork Tue Jul 7 08:43:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wen Congyang X-Patchwork-Id: 492103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7F35014012C for ; Tue, 7 Jul 2015 18:48:13 +1000 (AEST) Received: from localhost ([::1]:55818 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCOXz-0003Mf-Nb for incoming@patchwork.ozlabs.org; Tue, 07 Jul 2015 04:48:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCORf-0000Mu-PJ for qemu-devel@nongnu.org; Tue, 07 Jul 2015 04:41:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCORc-00030i-Hz for qemu-devel@nongnu.org; Tue, 07 Jul 2015 04:41:39 -0400 Received: from [59.151.112.132] (port=62005 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCORb-0001Wo-Na; Tue, 07 Jul 2015 04:41:36 -0400 X-IronPort-AV: E=Sophos;i="5.13,665,1427731200"; d="scan'208";a="98163939" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 07 Jul 2015 16:43:35 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t678bxM6010451; Tue, 7 Jul 2015 16:37:59 +0800 Received: from G08FNSTD140052.g08.fujitsu.local (10.167.226.52) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Tue, 7 Jul 2015 16:39:41 +0800 From: Wen Congyang To: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Stefan Hajnoczi Date: Tue, 7 Jul 2015 16:43:07 +0800 Message-ID: <1436258596-1253-10-git-send-email-wency@cn.fujitsu.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1436258596-1253-1-git-send-email-wency@cn.fujitsu.com> References: <1436258596-1253-1-git-send-email-wency@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.52] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Kevin Wolf , qemu block , Jeff Cody , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , "Michael R. Hines" , Gonglei , Yang Hongyang , zhanghailiang Subject: [Qemu-devel] [PATCH COLO-BLOCK v8 09/18] Backup: clear all bitmap when doing block checkpoint X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Wen Congyang Signed-off-by: zhanghailiang Signed-off-by: Gonglei Cc: Jeff Cody --- block/backup.c | 13 +++++++++++++ blockjob.c | 10 ++++++++++ include/block/blockjob.h | 12 ++++++++++++ 3 files changed, 35 insertions(+) diff --git a/block/backup.c b/block/backup.c index d3c7d9f..ebb8a88 100644 --- a/block/backup.c +++ b/block/backup.c @@ -211,11 +211,24 @@ static void backup_iostatus_reset(BlockJob *job) bdrv_iostatus_reset(s->target); } +static void backup_do_checkpoint(BlockJob *job, Error **errp) +{ + BackupBlockJob *backup_job = container_of(job, BackupBlockJob, common); + + if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) { + error_setg(errp, "this feature or command is not currently supported"); + return; + } + + hbitmap_reset_all(backup_job->bitmap); +} + static const BlockJobDriver backup_job_driver = { .instance_size = sizeof(BackupBlockJob), .job_type = BLOCK_JOB_TYPE_BACKUP, .set_speed = backup_set_speed, .iostatus_reset = backup_iostatus_reset, + .do_checkpoint = backup_do_checkpoint, }; static BlockErrorAction backup_error_action(BackupBlockJob *job, diff --git a/blockjob.c b/blockjob.c index ec46fad..cb412d1 100644 --- a/blockjob.c +++ b/blockjob.c @@ -400,3 +400,13 @@ void block_job_defer_to_main_loop(BlockJob *job, qemu_bh_schedule(data->bh); } + +void block_job_do_checkpoint(BlockJob *job, Error **errp) +{ + if (!job->driver->do_checkpoint) { + error_setg(errp, "this feature or command is not currently supported"); + return; + } + + job->driver->do_checkpoint(job, errp); +} diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 57d8ef1..b832dc3 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -50,6 +50,9 @@ typedef struct BlockJobDriver { * manually. */ void (*complete)(BlockJob *job, Error **errp); + + /** Optional callback for job types that support checkpoint. */ + void (*do_checkpoint)(BlockJob *job, Error **errp); } BlockJobDriver; /** @@ -348,4 +351,13 @@ void block_job_defer_to_main_loop(BlockJob *job, BlockJobDeferToMainLoopFn *fn, void *opaque); +/** + * block_job_do_checkpoint: + * @job: The job. + * @errp: Error object. + * + * Do block checkpoint on the specified job. + */ +void block_job_do_checkpoint(BlockJob *job, Error **errp); + #endif