mirror: prevent 'top' mode mirroring when no backing file specified on the destination
PATCH 1/1 mirror: prevent 'top' mode mirroring when no backing file specified on the destination
Mirroring using 'top' mode without backing file specified on the target can be success, but end with a disaster.
For example:
Migration can be success in this situation while the virtual machine on the destination
is no longer usable because of backing lost.
Remind the user earlier and return error in case of misoperation.
--- block/mirror.c | 6 ++++++ 1 file changed, 6 insertions(+)
block/mirror.c +6 -0
@@ -1038,6 +1038,12 @@ void mirror_start(const char *job_id, BlockDriverState *bs,error_setg (errp,"Sync mode 'incremental' not supported" );return ; } +if (mode ==MIRROR_SYNC_MODE_TOP && !backing_bs (target)) + { +error_setg (errp,"Target Backing required using Sync mode 'top'" ); +return ; + } + is_none_mode = mode ==MIRROR_SYNC_MODE_NONE ; base = mode ==MIRROR_SYNC_MODE_TOP ?backing_bs (bs) :NULL ; mirror_start_job(job_id, bs, BLOCK_JOB_DEFAULT, target, replaces,
Signature · 1 line
1.8.3.1
Quoted 7 lines · sochin jiang
Mirroring using 'top' mode without backing file specified on the target can be success, but end with a disaster.
For example:
Migration can be success in this situation while the virtual machine on the destination
is no longer usable because of backing lost.
I think this is a premature policy decision. Even though the user can abuse it to lose data, I think there is still enough technical reason for why a user might have a valid use case for doing this (perhaps for creating incremental backups, where the user plans on re-chaining data back together using 'qemu-img rebase -u'), so I don't think we should forbid it at the qemu level.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Well, that makes sense, I lose my consideration, thanks.
Sochin Jiang
Quoted 16 lines · Eric Blake
Quoted 7 lines · sochin jiang
Mirroring using 'top' mode without backing file specified on the target can be success, but end with a disaster.
For example:
Migration can be success in this situation while the virtual machine on the destination
is no longer usable because of backing lost.I think this is a premature policy decision. Even though the user can abuse it to lose data, I think there is still enough technical reason for why a user might have a valid use case for doing this (perhaps for creating incremental backups, where the user plans on re-chaining data back together using 'qemu-img rebase -u'), so I don't think we should forbid it at the qemu level.
Quoted 19 lines · sochin jiang
Mirroring using 'top' mode without backing file specified on the target can be success, but end with a disaster.
For example:
Migration can be success in this situation while the virtual machine on the destination
is no longer usable because of backing lost.Remind the user earlier and return error in case of misoperation.
Signed-off-by sochin jiang <[email protected]>--- block/mirror.c | 6 ++++++ 1 file changed, 6 insertions(+)block/mirror.c +0
-0
block/mirror.c void mirror_start(const char *job_id, BlockDriverState *bs, · line 1042
Quoted 5 lines
block/mirror.c +2
-0@@ -1038,6 +1038,12 @@ void mirror_start(const char *job_id, BlockDriverState *bs,error_setg (errp,"Sync mode 'incremental' not supported" );return ; } +if (mode ==MIRROR_SYNC_MODE_TOP && !backing_bs (target)) + {
Syntactic issue: The opening brace should be on the same line as the "if".
block/mirror.c void mirror_start(const char *job_id, BlockDriverState *bs, · line 1049
Quoted 7 lines
block/mirror.c +4
-0+error_setg (errp,"Target Backing required using Sync mode 'top'" ); +return ; + } + is_none_mode = mode ==MIRROR_SYNC_MODE_NONE ; base = mode ==MIRROR_SYNC_MODE_TOP ?backing_bs (bs) :NULL ; mirror_start_job(job_id, bs, BLOCK_JOB_DEFAULT, target, replaces,
General issue: For blockdev-mirror, I think this is a legitimate use case. As far as I'm aware, libvirt uses the mirror block job for all backups -- they do so by cancelling the block job after the BLOCK_JOB_READY event instead of letting it complete. So a user might want to mirror some drive somewhere else (in sync=top mode, with the new location not yet having assigned a backing file to it), then cancel the block job after BLOCK_JOB_READY and only assign the backing file at some later point.
An even greater issue is that qmp_drive_mirror() opens the target BDS with BDRV_O_NO_BACKING. Therefore, this will always error out with drive-mirror and sync=top (unless the source image does not have a backing file, in which case the sync=top will silently be converted to sync=full).
For drive-mirror, the target's backing chain will not be set up until mirror_complete().
Max
I got the idea, thanks, Max.
Sochin.Jiang
Quoted 56 lines · Max Reitz
Quoted 19 lines · sochin jiang
Mirroring using 'top' mode without backing file specified on the target can be success, but end with a disaster.
For example:
Migration can be success in this situation while the virtual machine on the destination
is no longer usable because of backing lost.Remind the user earlier and return error in case of misoperation.
Signed-off-by sochin jiang <[email protected]>--- block/mirror.c | 6 ++++++ 1 file changed, 6 insertions(+)block/mirror.c +0
-0block/mirror.c void mirror_start(const char *job_id, BlockDriverState *bs, · line 1042
Quoted 5 lines
block/mirror.c +2
-0@@ -1038,6 +1038,12 @@ void mirror_start(const char *job_id, BlockDriverState *bs,error_setg (errp,"Sync mode 'incremental' not supported" );return ; } +if (mode ==MIRROR_SYNC_MODE_TOP && !backing_bs (target)) + {Syntactic issue: The opening brace should be on the same line as the "if".
block/mirror.c void mirror_start(const char *job_id, BlockDriverState *bs, · line 1049
Quoted 7 lines
block/mirror.c +4
-0+error_setg (errp,"Target Backing required using Sync mode 'top'" ); +return ; + } + is_none_mode = mode ==MIRROR_SYNC_MODE_NONE ; base = mode ==MIRROR_SYNC_MODE_TOP ?backing_bs (bs) :NULL ; mirror_start_job(job_id, bs, BLOCK_JOB_DEFAULT, target, replaces,General issue: For blockdev-mirror, I think this is a legitimate use case. As far as I'm aware, libvirt uses the mirror block job for all backups -- they do so by cancelling the block job after the
BLOCK_JOB_READYevent instead of letting it complete. So a user might want to mirror some drive somewhere else (in sync=top mode, with the new location not yet having assigned a backing file to it), then cancel the block job afterBLOCK_JOB_READYand only assign the backing file at some later point.An even greater issue is that
qmp_drive_mirror()opens the target BDS withBDRV_O_NO_BACKING. Therefore, this will always error out with drive-mirror and sync=top (unless the source image does not have a backing file, in which case the sync=top will silently be converted to sync=full).For drive-mirror, the target's backing chain will not be set up until
mirror_complete().Max
Your series seems to have some coding style problems. See output below for more information:
Hi,
Your series seems to have some coding style problems. See output below for more information:
Subject: [Qemu-devel] [PATCH] mirror: prevent 'top' mode mirroring when no backing file specified on the destination
Message-id: [email protected]
Type: series
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
05e3f52 mirror: prevent 'top' mode mirroring when no backing file specified on the destination
=== OUTPUT BEGIN ===
Checking PATCH 1/1: mirror: prevent 'top' mode mirroring when no backing file specified on the destination...
ERROR: that open brace { should be on the previous line
#27: FILE: block/mirror.c:1041:
+ if (mode == MIRROR_SYNC_MODE_TOP && !backing_bs(target))
+ {
total: 1 errors, 0 warnings, 12 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]