53e83913af
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
101 lines
4.2 KiB
Diff
101 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
|
|
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.
|
|
---
|
|
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 8630d32926..7f970842d7 100644
|
|
--- a/block/backup.c
|
|
+++ b/block/backup.c
|
|
@@ -613,6 +613,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;
|
|
@@ -746,6 +747,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 6349d6958e..84e07cc4d4 100644
|
|
--- a/block/replication.c
|
|
+++ b/block/replication.c
|
|
@@ -571,7 +571,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 dcf8c8d2ab..d5eb6b62ca 100644
|
|
--- a/blockdev.c
|
|
+++ b/blockdev.c
|
|
@@ -3568,7 +3568,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);
|
|
bdrv_unref(target_bs);
|
|
if (local_err != NULL) {
|
|
error_propagate(errp, local_err);
|
|
@@ -3660,7 +3660,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
|
|
job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
|
|
backup->sync, NULL, 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 903b9c1034..0b2516c3cf 100644
|
|
--- a/include/block/block_int.h
|
|
+++ b/include/block/block_int.h
|
|
@@ -1083,6 +1083,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 fa671b431a..72c50ee18e 100644
|
|
--- a/job.c
|
|
+++ b/job.c
|
|
@@ -557,7 +557,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);
|
|
}
|
|
--
|
|
2.11.0
|
|
|