|
|
ddf19c |
From 959955217f745f1ee6cbea97314efe69f2d7dc08 Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
ddf19c |
Date: Fri, 7 Feb 2020 11:27:43 +0000
|
|
|
ddf19c |
Subject: [PATCH 10/18] blockdev: unify qmp_blockdev_backup and blockdev-backup
|
|
|
ddf19c |
transaction paths
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
ddf19c |
Message-id: <20200207112749.25073-4-slp@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 93756
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 3/9] blockdev: unify qmp_blockdev_backup and blockdev-backup transaction paths
|
|
|
ddf19c |
Bugzilla: 1745606 1746217 1773517 1779036 1782111 1782175 1783965
|
|
|
ddf19c |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Issuing a blockdev-backup from qmp_blockdev_backup takes a slightly
|
|
|
ddf19c |
different path than when it's issued from a transaction. In the code,
|
|
|
ddf19c |
this is manifested as some redundancy between do_blockdev_backup() and
|
|
|
ddf19c |
blockdev_backup_prepare().
|
|
|
ddf19c |
|
|
|
ddf19c |
This change unifies both paths, merging do_blockdev_backup() and
|
|
|
ddf19c |
blockdev_backup_prepare(), and changing qmp_blockdev_backup() to
|
|
|
ddf19c |
create a transaction instead of calling do_backup_common() direcly.
|
|
|
ddf19c |
|
|
|
ddf19c |
As a side-effect, now qmp_blockdev_backup() is executed inside a
|
|
|
ddf19c |
drained section, as it happens when creating a blockdev-backup
|
|
|
ddf19c |
transaction. This change is visible from the user's perspective, as
|
|
|
ddf19c |
the job gets paused and immediately resumed before starting the actual
|
|
|
ddf19c |
work.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
ddf19c |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 5b7bfe515ecbd584b40ff6e41d2fd8b37c7d5139)
|
|
|
ddf19c |
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
blockdev.c | 60 +++++++++++++-----------------------------------------------
|
|
|
ddf19c |
1 file changed, 13 insertions(+), 47 deletions(-)
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/blockdev.c b/blockdev.c
|
|
|
ddf19c |
index 5e85fc0..152a0f7 100644
|
|
|
ddf19c |
--- a/blockdev.c
|
|
|
ddf19c |
+++ b/blockdev.c
|
|
|
ddf19c |
@@ -1940,16 +1940,13 @@ typedef struct BlockdevBackupState {
|
|
|
ddf19c |
BlockJob *job;
|
|
|
ddf19c |
} BlockdevBackupState;
|
|
|
ddf19c |
|
|
|
ddf19c |
-static BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
|
|
|
ddf19c |
- Error **errp);
|
|
|
ddf19c |
-
|
|
|
ddf19c |
static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common);
|
|
|
ddf19c |
BlockdevBackup *backup;
|
|
|
ddf19c |
- BlockDriverState *bs, *target;
|
|
|
ddf19c |
+ BlockDriverState *bs;
|
|
|
ddf19c |
+ BlockDriverState *target_bs;
|
|
|
ddf19c |
AioContext *aio_context;
|
|
|
ddf19c |
- Error *local_err = NULL;
|
|
|
ddf19c |
|
|
|
ddf19c |
assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP);
|
|
|
ddf19c |
backup = common->action->u.blockdev_backup.data;
|
|
|
ddf19c |
@@ -1959,8 +1956,8 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
ddf19c |
return;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
- target = bdrv_lookup_bs(backup->target, backup->target, errp);
|
|
|
ddf19c |
- if (!target) {
|
|
|
ddf19c |
+ target_bs = bdrv_lookup_bs(backup->target, backup->target, errp);
|
|
|
ddf19c |
+ if (!target_bs) {
|
|
|
ddf19c |
return;
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
@@ -1971,13 +1968,10 @@ static void blockdev_backup_prepare(BlkActionState *common, Error **errp)
|
|
|
ddf19c |
/* Paired with .clean() */
|
|
|
ddf19c |
bdrv_drained_begin(state->bs);
|
|
|
ddf19c |
|
|
|
ddf19c |
- state->job = do_blockdev_backup(backup, common->block_job_txn, &local_err);
|
|
|
ddf19c |
- if (local_err) {
|
|
|
ddf19c |
- error_propagate(errp, local_err);
|
|
|
ddf19c |
- goto out;
|
|
|
ddf19c |
- }
|
|
|
ddf19c |
+ state->job = do_backup_common(qapi_BlockdevBackup_base(backup),
|
|
|
ddf19c |
+ bs, target_bs, aio_context,
|
|
|
ddf19c |
+ common->block_job_txn, errp);
|
|
|
ddf19c |
|
|
|
ddf19c |
-out:
|
|
|
ddf19c |
aio_context_release(aio_context);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
@@ -3695,41 +3689,13 @@ XDbgBlockGraph *qmp_x_debug_query_block_graph(Error **errp)
|
|
|
ddf19c |
return bdrv_get_xdbg_block_graph(errp);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
-BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
|
|
|
ddf19c |
- Error **errp)
|
|
|
ddf19c |
+void qmp_blockdev_backup(BlockdevBackup *backup, Error **errp)
|
|
|
ddf19c |
{
|
|
|
ddf19c |
- BlockDriverState *bs;
|
|
|
ddf19c |
- BlockDriverState *target_bs;
|
|
|
ddf19c |
- AioContext *aio_context;
|
|
|
ddf19c |
- BlockJob *job;
|
|
|
ddf19c |
-
|
|
|
ddf19c |
- bs = bdrv_lookup_bs(backup->device, backup->device, errp);
|
|
|
ddf19c |
- if (!bs) {
|
|
|
ddf19c |
- return NULL;
|
|
|
ddf19c |
- }
|
|
|
ddf19c |
-
|
|
|
ddf19c |
- target_bs = bdrv_lookup_bs(backup->target, backup->target, errp);
|
|
|
ddf19c |
- if (!target_bs) {
|
|
|
ddf19c |
- return NULL;
|
|
|
ddf19c |
- }
|
|
|
ddf19c |
-
|
|
|
ddf19c |
- aio_context = bdrv_get_aio_context(bs);
|
|
|
ddf19c |
- aio_context_acquire(aio_context);
|
|
|
ddf19c |
-
|
|
|
ddf19c |
- job = do_backup_common(qapi_BlockdevBackup_base(backup),
|
|
|
ddf19c |
- bs, target_bs, aio_context, txn, errp);
|
|
|
ddf19c |
-
|
|
|
ddf19c |
- aio_context_release(aio_context);
|
|
|
ddf19c |
- return job;
|
|
|
ddf19c |
-}
|
|
|
ddf19c |
-
|
|
|
ddf19c |
-void qmp_blockdev_backup(BlockdevBackup *arg, Error **errp)
|
|
|
ddf19c |
-{
|
|
|
ddf19c |
- BlockJob *job;
|
|
|
ddf19c |
- job = do_blockdev_backup(arg, NULL, errp);
|
|
|
ddf19c |
- if (job) {
|
|
|
ddf19c |
- job_start(&job->job);
|
|
|
ddf19c |
- }
|
|
|
ddf19c |
+ TransactionAction action = {
|
|
|
ddf19c |
+ .type = TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP,
|
|
|
ddf19c |
+ .u.blockdev_backup.data = backup,
|
|
|
ddf19c |
+ };
|
|
|
ddf19c |
+ blockdev_do_action(&action, errp);
|
|
|
ddf19c |
}
|
|
|
ddf19c |
|
|
|
ddf19c |
/* Parameter check and block job starting for drive mirroring.
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|