block: early check for blockers on drive-mirror
PATCH 1/1 block: early check for blockers on drive-mirror
Even if an op blocker is present for BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this.
--- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+)
blockdev.c +5 -0
@@ -3565,6 +3565,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)return ; } +/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);
Signature · 1 line
2.14.3
Quoted 30 lines · Paolo Bonzini
Even if an op blocker is present for
BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this.Signed-off-by Paolo Bonzini <[email protected]>--- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+)blockdev.c +5
-0@@ -3565,6 +3565,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)return ; } +/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);Signature · 1 line
2.14.3
Quoted 15 lines · Paolo Bonzini
Even if an op blocker is present for
BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this.Signed-off-by Paolo Bonzini <[email protected]>--- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+)blockdev.c +0
-0
blockdev.c void qmp_drive_mirror(DriveMirror *arg, Error **errp) · line 3574
Quoted 10 lines
blockdev.c +5
-0@@ -3565,6 +3565,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)return ; } +/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);
Do we need to hold the AioContext in order to check for op blockers?
Berto
Quoted 19 lines · Alberto Garcia
Quoted 18 lines · Paolo Bonzini
Even if an op blocker is present for
BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this.Signed-off-by Paolo Bonzini <[email protected]>--- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+)blockdev.c +0
-0@@ -3565,6 +3565,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)return ; }
Quoted 9 lines
blockdev.c void qmp_drive_mirror(DriveMirror *arg, Error **errp) · line 3574
Quoted 7 lines
blockdev.c +5
-0+/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);Do we need to hold the AioContext in order to check for op blockers?
In include/block/block_int.h, they are not in the "Protected by AioContext lock" section.
Paolo
Quoted 6 lines · Paolo Bonzini
Even if an op blocker is present for
BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this.Signed-off-by Paolo Bonzini <[email protected]>
Berto
Kevin Wolf
AppliedAm 07.02.2018 um 17:29 hat Paolo Bonzini geschrieben:
Quoted 6 lines
Even if an op blocker is present for
BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this.Signed-off-by Paolo Bonzini <[email protected]>
Thanks, applied to the block branch.
Kevin
Quoted 17 lines · Paolo Bonzini
Even if an op blocker is present for
BLOCK_OP_TYPE_MIRROR_SOURCE, it is checked a bit late and the result is that the target is created even if drive-mirror subsequently fails. Add an early check to avoid this.Signed-off-by Paolo Bonzini <[email protected]>--- blockdev.c | 5 +++++ 1 file changed, 5 insertions(+)blockdev.c +0
-0@@ -3565,6 +3565,11 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp)return ;
blockdev.c void qmp_drive_mirror(DriveMirror *arg, Error **errp) · line 3575
Quoted 10 lines
blockdev.c +5
-0} +/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);
What's the implication of the temporarily-extant target node that it needs to be avoided so strictly?
Quoted 9 lines · John Snow
blockdev.c void qmp_drive_mirror(DriveMirror *arg, Error **errp) · line 3574
Quoted 9 lines
blockdev.c +5
-0+/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);
Quoted 3 lines
What's the implication of the temporarily-extant target node that it needs to be avoided so strictly?
Creating a file on disk, that no one will ever remvoe. :)
Paolo
Quoted 10 lines · Paolo Bonzini
Quoted 9 lines · John Snow
Quoted 9 lines
blockdev.c +5
-0+/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);
Quoted 5 lines
Quoted 3 lines
What's the implication of the temporarily-extant target node that it needs to be avoided so strictly?
Creating a file on disk, that no one will ever remvoe. :)
Fortunately libvirt's SELinux policy will probably prevent QEMU creating it in the first place :-)
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Am 12.02.2018 um 11:02 hat Daniel P. Berrangé geschrieben:
Quoted 11 lines · Paolo Bonzini
Quoted 10 lines · John Snow
Quoted 9 lines
Quoted 9 lines
blockdev.c +5
-0+/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
What's the implication of the temporarily-extant target node that it needs to be avoided so strictly?
Creating a file on disk, that no one will ever remvoe. :)
Fortunately libvirt's SELinux policy will probably prevent QEMU creating it in the first place :-)
Well, calling drive-mirror without allowing QEMU to create the target image would be a bit pointless, so I think we can assume that libvirt did set up the file permission so that QEMU can create it. (Unless mode=existing is used, but I understand that libvirt doesn't want to create images with qemu-img, so that doesn't seem to be the case...)
I don't know if libvirt takes care to remove a potentially already created file if the command then fails, but hopefully it does and the patch is not actually needed with libvirt.
Kevin
Quoted 18 lines · Kevin Wolf
Am 12.02.2018 um 11:02 hat Daniel P. Berrangé geschrieben:
Quoted 17 lines · Paolo Bonzini
Quoted 15 lines · John Snow
Quoted 9 lines
blockdev.c void qmp_drive_mirror(DriveMirror *arg, Error **errp) · line 3574
Quoted 9 lines
blockdev.c +5
-0+/* Early check to avoid creating target */ +if (bdrv_op_is_blocked (bs,BLOCK_OP_TYPE_MIRROR_SOURCE , errp)) { +return ; + } + aio_context =bdrv_get_aio_context (bs);aio_context_acquire (aio_context);Quoted 3 lines
What's the implication of the temporarily-extant target node that it needs to be avoided so strictly?
Creating a file on disk, that no one will ever remvoe. :)
Quoted 8 lines
Quoted 2 lines
Fortunately libvirt's SELinux policy will probably prevent QEMU creating it in the first place :-)
Well, calling drive-mirror without allowing QEMU to create the target image would be a bit pointless, so I think we can assume that libvirt did set up the file permission so that QEMU can create it. (Unless mode=existing is used, but I understand that libvirt doesn't want to create images with qemu-img, so that doesn't seem to be the case...)
We use either mode=existing or mode=absolute-paths depending on what the mgmt app asked for in the API call to libvirt. I'm still kind of suprised if mode=absolute-paths will work because we ought to be blocking the creation of the file AFAIK and we can't pre-label a file that doesn't exist yet.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|