On Wed, Sep 02, 2015 at 04:51:11PM +0800, Wen Congyang wrote: > Signed-off-by: Wen Congyang <we...@cn.fujitsu.com> > Signed-off-by: zhanghailiang <zhang.zhanghaili...@huawei.com> > Signed-off-by: Gonglei <arei.gong...@huawei.com> > Cc: Jeff Cody <jc...@redhat.com> > --- > block/backup.c | 14 ++++++++++++++ > blockjob.c | 11 +++++++++++ > include/block/blockjob.h | 12 ++++++++++++ > 3 files changed, 37 insertions(+) > > diff --git a/block/backup.c b/block/backup.c > index b729c4b..59bdb79 100644 > --- a/block/backup.c > +++ b/block/backup.c > @@ -217,11 +217,25 @@ 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, "The backup job only supports block checkpoint in" > + " sync=none mode"); > + 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 62bb906..5528d92 100644 > --- a/blockjob.c > +++ b/blockjob.c > @@ -404,3 +404,14 @@ 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, "The job %s doesn't support block checkpoint", > + BlockJobType_lookup[job->driver->job_type]); > + return; > + } > + > + job->driver->do_checkpoint(job, errp); > +} > diff --git a/include/block/blockjob.h b/include/block/blockjob.h > index dd9d5e6..0b4f386 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; > > /** > @@ -356,4 +359,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 > -- > 2.4.3 > >
Reviewed-by: Jeff Cody <jc...@redhat.com>