From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 9 Dec 2015 15:04:57 +0100 Subject: [PATCH] PVE: backup: modify job api Introduce a pause_count parameter to start a backup in paused mode. This way backups of multiple drives can be started up sequentially via the completion callback while having been started at the same point in time. Signed-off-by: Thomas Lamprecht --- block/backup.c | 2 ++ block/replication.c | 2 +- blockdev.c | 4 ++-- include/block/block_int.h | 1 + job.c | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/block/backup.c b/block/backup.c index b26c22c4b8..812783d3cb 100644 --- a/block/backup.c +++ b/block/backup.c @@ -550,6 +550,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BlockdevOnError on_target_error, int creation_flags, BlockCompletionFunc *cb, void *opaque, + int pause_count, JobTxn *txn, Error **errp) { int64_t len; @@ -668,6 +669,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, block_job_add_bdrv(&job->common, "target", target, 0, BLK_PERM_ALL, &error_abort); job->len = len; + job->common.job.pause_count += pause_count; return &job->common; diff --git a/block/replication.c b/block/replication.c index 23b2993d74..e70a6cf2bd 100644 --- a/block/replication.c +++ b/block/replication.c @@ -546,7 +546,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, 0, MIRROR_SYNC_MODE_NONE, NULL, false, BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL, - backup_job_completed, bs, NULL, &local_err); + backup_job_completed, bs, 0, NULL, &local_err); if (local_err) { error_propagate(errp, local_err); backup_job_cleanup(bs); diff --git a/blockdev.c b/blockdev.c index 4d141e9a1f..a7c97b1585 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3574,7 +3574,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, JobTxn *txn, job = backup_job_create(backup->job_id, bs, target_bs, backup->speed, backup->sync, bmap, backup->compress, backup->on_source_error, backup->on_target_error, - job_flags, NULL, NULL, txn, &local_err); + job_flags, NULL, NULL, 0, txn, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); goto unref; @@ -3679,7 +3679,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn, job = backup_job_create(backup->job_id, bs, target_bs, backup->speed, backup->sync, bmap, backup->compress, backup->on_source_error, backup->on_target_error, - job_flags, NULL, NULL, txn, &local_err); + job_flags, NULL, NULL, 0, txn, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); } diff --git a/include/block/block_int.h b/include/block/block_int.h index 3aa1e832a8..9f4fbad5a6 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -1169,6 +1169,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, BlockdevOnError on_target_error, int creation_flags, BlockCompletionFunc *cb, void *opaque, + int pause_count, JobTxn *txn, Error **errp); void hmp_drive_add_node(Monitor *mon, const char *optstr); diff --git a/job.c b/job.c index 28dd48f8a5..7a21e83780 100644 --- a/job.c +++ b/job.c @@ -898,7 +898,7 @@ void job_start(Job *job) job->co = qemu_coroutine_create(job_co_entry, job); job->pause_count--; job->busy = true; - job->paused = false; + job->paused = job->pause_count > 0; job_state_transition(job, JOB_STATUS_RUNNING); aio_co_enter(job->aio_context, job->co); }