All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror
@ 2018-02-07 16:29 Paolo Bonzini
  2018-02-08  1:17 ` Fam Zheng
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Paolo Bonzini @ 2018-02-07 16:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-block, jsnow

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 <pbonzini@redhat.com>
---
 blockdev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/blockdev.c b/blockdev.c
index 8e977eef11..c7e2e0a00e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -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);
 
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror
  2018-02-07 16:29 [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror Paolo Bonzini
@ 2018-02-08  1:17 ` Fam Zheng
  2018-02-08 10:10 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Fam Zheng @ 2018-02-08  1:17 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, jsnow, qemu-block

On Wed, 02/07 17:29, Paolo Bonzini wrote:
> 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 <pbonzini@redhat.com>
> ---
>  blockdev.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 8e977eef11..c7e2e0a00e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -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);
>  
> -- 
> 2.14.3
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
  2018-02-07 16:29 [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror Paolo Bonzini
  2018-02-08  1:17 ` Fam Zheng
@ 2018-02-08 10:10 ` Alberto Garcia
  2018-02-08 10:38   ` Paolo Bonzini
  2018-02-08 12:41 ` Alberto Garcia
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Alberto Garcia @ 2018-02-08 10:10 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-block

On Wed 07 Feb 2018 05:29:20 PM CET, Paolo Bonzini wrote:
> 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 <pbonzini@redhat.com>
> ---
>  blockdev.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/blockdev.c b/blockdev.c
> index 8e977eef11..c7e2e0a00e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
  2018-02-08 10:10 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
@ 2018-02-08 10:38   ` Paolo Bonzini
  0 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2018-02-08 10:38 UTC (permalink / raw)
  To: Alberto Garcia, qemu-devel; +Cc: qemu-block

On 08/02/2018 11:10, Alberto Garcia wrote:
> On Wed 07 Feb 2018 05:29:20 PM CET, Paolo Bonzini wrote:
>> 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 <pbonzini@redhat.com>
>> ---
>>  blockdev.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>>
>> diff --git a/blockdev.c b/blockdev.c
>> index 8e977eef11..c7e2e0a00e 100644
>> --- a/blockdev.c
>> +++ b/blockdev.c
>> @@ -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?

In include/block/block_int.h, they are not in the "Protected by
AioContext lock" section.

Paolo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
  2018-02-07 16:29 [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror Paolo Bonzini
  2018-02-08  1:17 ` Fam Zheng
  2018-02-08 10:10 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
@ 2018-02-08 12:41 ` Alberto Garcia
  2018-02-09 15:36 ` Kevin Wolf
  2018-02-09 23:07 ` [Qemu-devel] " John Snow
  4 siblings, 0 replies; 11+ messages in thread
From: Alberto Garcia @ 2018-02-08 12:41 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-block

On Wed 07 Feb 2018 05:29:20 PM CET, Paolo Bonzini wrote:
> 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 <pbonzini@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
  2018-02-07 16:29 [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror Paolo Bonzini
                   ` (2 preceding siblings ...)
  2018-02-08 12:41 ` Alberto Garcia
@ 2018-02-09 15:36 ` Kevin Wolf
  2018-02-09 23:07 ` [Qemu-devel] " John Snow
  4 siblings, 0 replies; 11+ messages in thread
From: Kevin Wolf @ 2018-02-09 15:36 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, qemu-block

Am 07.02.2018 um 17:29 hat Paolo Bonzini geschrieben:
> 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 <pbonzini@redhat.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror
  2018-02-07 16:29 [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror Paolo Bonzini
                   ` (3 preceding siblings ...)
  2018-02-09 15:36 ` Kevin Wolf
@ 2018-02-09 23:07 ` John Snow
  2018-02-12  9:58   ` Paolo Bonzini
  4 siblings, 1 reply; 11+ messages in thread
From: John Snow @ 2018-02-09 23:07 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: qemu-block



On 02/07/2018 11:29 AM, Paolo Bonzini wrote:
> 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 <pbonzini@redhat.com>
> ---
>  blockdev.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 8e977eef11..c7e2e0a00e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -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);
>  
> 

What's the implication of the temporarily-extant target node that it
needs to be avoided so strictly?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror
  2018-02-09 23:07 ` [Qemu-devel] " John Snow
@ 2018-02-12  9:58   ` Paolo Bonzini
  2018-02-12 10:02     ` Daniel P. Berrangé
  0 siblings, 1 reply; 11+ messages in thread
From: Paolo Bonzini @ 2018-02-12  9:58 UTC (permalink / raw)
  To: John Snow, qemu-devel; +Cc: qemu-block

On 10/02/2018 00:07, John Snow wrote:
>> +    /* 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?
> 

Creating a file on disk, that no one will ever remvoe. :)

Paolo

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror
  2018-02-12  9:58   ` Paolo Bonzini
@ 2018-02-12 10:02     ` Daniel P. Berrangé
  2018-02-12 12:42       ` [Qemu-devel] [Qemu-block] " Kevin Wolf
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel P. Berrangé @ 2018-02-12 10:02 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: John Snow, qemu-devel, qemu-block

On Mon, Feb 12, 2018 at 10:58:31AM +0100, Paolo Bonzini wrote:
> On 10/02/2018 00:07, John Snow wrote:
> >> +    /* 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?
> > 
> 
> 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
-- 
|: 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 :|

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
  2018-02-12 10:02     ` Daniel P. Berrangé
@ 2018-02-12 12:42       ` Kevin Wolf
  2018-02-12 12:49         ` Daniel P. Berrangé
  0 siblings, 1 reply; 11+ messages in thread
From: Kevin Wolf @ 2018-02-12 12:42 UTC (permalink / raw)
  To: Daniel P. Berrangé; +Cc: Paolo Bonzini, qemu-devel, qemu-block

Am 12.02.2018 um 11:02 hat Daniel P. Berrangé geschrieben:
> On Mon, Feb 12, 2018 at 10:58:31AM +0100, Paolo Bonzini wrote:
> > On 10/02/2018 00:07, John Snow wrote:
> > >> +    /* 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?
> > > 
> > 
> > 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] block: early check for blockers on drive-mirror
  2018-02-12 12:42       ` [Qemu-devel] [Qemu-block] " Kevin Wolf
@ 2018-02-12 12:49         ` Daniel P. Berrangé
  0 siblings, 0 replies; 11+ messages in thread
From: Daniel P. Berrangé @ 2018-02-12 12:49 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Paolo Bonzini, qemu-devel, qemu-block

On Mon, Feb 12, 2018 at 01:42:11PM +0100, Kevin Wolf wrote:
> Am 12.02.2018 um 11:02 hat Daniel P. Berrangé geschrieben:
> > On Mon, Feb 12, 2018 at 10:58:31AM +0100, Paolo Bonzini wrote:
> > > On 10/02/2018 00:07, John Snow wrote:
> > > >> +    /* 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?
> > > > 
> > > 
> > > 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...)

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
-- 
|: 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 :|

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-02-12 12:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-07 16:29 [Qemu-devel] [PATCH] block: early check for blockers on drive-mirror Paolo Bonzini
2018-02-08  1:17 ` Fam Zheng
2018-02-08 10:10 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2018-02-08 10:38   ` Paolo Bonzini
2018-02-08 12:41 ` Alberto Garcia
2018-02-09 15:36 ` Kevin Wolf
2018-02-09 23:07 ` [Qemu-devel] " John Snow
2018-02-12  9:58   ` Paolo Bonzini
2018-02-12 10:02     ` Daniel P. Berrangé
2018-02-12 12:42       ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2018-02-12 12:49         ` Daniel P. Berrangé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.