All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking
@ 2015-02-23 22:58 Max Reitz
  2015-02-24  9:43 ` Markus Armbruster
  2015-02-25  6:22 ` Fam Zheng
  0 siblings, 2 replies; 5+ messages in thread
From: Max Reitz @ 2015-02-23 22:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Max Reitz, Anthony Liguori, Michael S. Tsirkin

s->blocker is really only used in hw/scsi/virtio-scsi.c; the only places
where it is used in hw/scsi/virtio-scsi-dataplane.c is when it is
allocated and when it is freed. That does not make a whole lot of sense
(and is actually wrong because this leads to s->blocker potentially
being NULL when blk_op_block_all() is called in virtio-scsi.c), so move
the allocation and destruction of s->blocker to blk_op_block_all() and
blk_op_unblock_all() in virtio-scsi.c, respectively.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
Try:

$ echo -e 'eject drv\nquit' | \
    x86_64-softmmu/qemu-system-x86_64 \
        -monitor stdio -machine accel=qtest -display none \
        -object iothread,id=thr -device virtio-scsi-pci,iothread=thr \
        -drive if=none,file=test.qcow2,format=qcow2,id=drv \
        -device scsi-cd,drive=drv

What it should do:

QEMU 2.2.50 monitor - type 'help' for more information
(qemu) eject drv
Device 'drv' is busy: block device is in use by data plane
(qemu) quit

What it should not do:

QEMU 2.2.50 monitor - type 'help' for more information
(qemu) eject drv
[1]    10102 done
       10103 segmentation fault (core dumped)
---
 hw/scsi/virtio-scsi-dataplane.c | 4 ----
 hw/scsi/virtio-scsi.c           | 6 +++++-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index 03a1e8c..9b775d4 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -211,8 +211,6 @@ void virtio_scsi_dataplane_start(VirtIOSCSI *s)
 
     s->dataplane_starting = true;
 
-    assert(!s->blocker);
-    error_setg(&s->blocker, "block device is in use by data plane");
     /* Set up guest notifier (irq) */
     rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
     if (rc != 0) {
@@ -279,8 +277,6 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
     if (!s->dataplane_started || s->dataplane_stopping) {
         return;
     }
-    error_free(s->blocker);
-    s->blocker = NULL;
     s->dataplane_stopping = true;
     assert(s->ctx == iothread_get_aio_context(vs->conf.iothread));
 
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 9e2c718..5469bad 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -766,6 +766,8 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
         if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
             return;
         }
+        assert(!s->blocker);
+        error_setg(&s->blocker, "block device is in use by data plane");
         blk_op_block_all(sd->conf.blk, s->blocker);
     }
 
@@ -789,8 +791,10 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                VIRTIO_SCSI_EVT_RESET_REMOVED);
     }
 
-    if (s->ctx) {
+    if (s->ctx && s->blocker) {
         blk_op_unblock_all(sd->conf.blk, s->blocker);
+        error_free(s->blocker);
+        s->blocker = NULL;
     }
     qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);
 }
-- 
2.1.0

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

* Re: [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking
  2015-02-23 22:58 [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking Max Reitz
@ 2015-02-24  9:43 ` Markus Armbruster
  2015-02-24 14:03   ` Max Reitz
  2015-02-25  6:22 ` Fam Zheng
  1 sibling, 1 reply; 5+ messages in thread
From: Markus Armbruster @ 2015-02-24  9:43 UTC (permalink / raw)
  To: Max Reitz; +Cc: Paolo Bonzini, qemu-devel, Anthony Liguori, Michael S. Tsirkin

Max Reitz <mreitz@redhat.com> writes:

> s->blocker is really only used in hw/scsi/virtio-scsi.c; the only places
> where it is used in hw/scsi/virtio-scsi-dataplane.c is when it is
> allocated and when it is freed. That does not make a whole lot of sense
> (and is actually wrong because this leads to s->blocker potentially
> being NULL when blk_op_block_all() is called in virtio-scsi.c), so move
> the allocation and destruction of s->blocker to blk_op_block_all() and
> blk_op_unblock_all() in virtio-scsi.c, respectively.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> Try:
>
> $ echo -e 'eject drv\nquit' | \
>     x86_64-softmmu/qemu-system-x86_64 \
>         -monitor stdio -machine accel=qtest -display none \
>         -object iothread,id=thr -device virtio-scsi-pci,iothread=thr \
>         -drive if=none,file=test.qcow2,format=qcow2,id=drv \
>         -device scsi-cd,drive=drv
>
> What it should do:
>
> QEMU 2.2.50 monitor - type 'help' for more information
> (qemu) eject drv
> Device 'drv' is busy: block device is in use by data plane
> (qemu) quit
>
> What it should not do:
>
> QEMU 2.2.50 monitor - type 'help' for more information
> (qemu) eject drv
> [1]    10102 done
>        10103 segmentation fault (core dumped)

Why do you put your nice reproducer below the --- divider?  I rather
like bug fixing commits come with reproducers in the commit message.

[...]

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

* Re: [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking
  2015-02-24  9:43 ` Markus Armbruster
@ 2015-02-24 14:03   ` Max Reitz
  2015-02-24 16:24     ` Eric Blake
  0 siblings, 1 reply; 5+ messages in thread
From: Max Reitz @ 2015-02-24 14:03 UTC (permalink / raw)
  To: Markus Armbruster
  Cc: Paolo Bonzini, qemu-devel, Anthony Liguori, Michael S. Tsirkin

On 2015-02-24 at 04:43, Markus Armbruster wrote:
> Max Reitz <mreitz@redhat.com> writes:
>
>> s->blocker is really only used in hw/scsi/virtio-scsi.c; the only places
>> where it is used in hw/scsi/virtio-scsi-dataplane.c is when it is
>> allocated and when it is freed. That does not make a whole lot of sense
>> (and is actually wrong because this leads to s->blocker potentially
>> being NULL when blk_op_block_all() is called in virtio-scsi.c), so move
>> the allocation and destruction of s->blocker to blk_op_block_all() and
>> blk_op_unblock_all() in virtio-scsi.c, respectively.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>> Try:
>>
>> $ echo -e 'eject drv\nquit' | \
>>      x86_64-softmmu/qemu-system-x86_64 \
>>          -monitor stdio -machine accel=qtest -display none \
>>          -object iothread,id=thr -device virtio-scsi-pci,iothread=thr \
>>          -drive if=none,file=test.qcow2,format=qcow2,id=drv \
>>          -device scsi-cd,drive=drv
>>
>> What it should do:
>>
>> QEMU 2.2.50 monitor - type 'help' for more information
>> (qemu) eject drv
>> Device 'drv' is busy: block device is in use by data plane
>> (qemu) quit
>>
>> What it should not do:
>>
>> QEMU 2.2.50 monitor - type 'help' for more information
>> (qemu) eject drv
>> [1]    10102 done
>>         10103 segmentation fault (core dumped)
> Why do you put your nice reproducer below the --- divider?  I rather
> like bug fixing commits come with reproducers in the commit message.
>
> [...]

Because then I'm afraid that Eric complains because I used echo -e 
instead of printf.

Seriously speaking, I don't mind putting it into the commit message. 
I'll wait for reviews on the change itself, and then either send a v2 
with the reproducer included in the commit message or hope for a 
maintainer to fix it up himself (which I'd be totally fine with *hint 
hint*).

Max

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

* Re: [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking
  2015-02-24 14:03   ` Max Reitz
@ 2015-02-24 16:24     ` Eric Blake
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Blake @ 2015-02-24 16:24 UTC (permalink / raw)
  To: Max Reitz, Markus Armbruster
  Cc: Paolo Bonzini, qemu-devel, Anthony Liguori, Michael S. Tsirkin

[-- Attachment #1: Type: text/plain, Size: 1691 bytes --]

On 02/24/2015 07:03 AM, Max Reitz wrote:
> On 2015-02-24 at 04:43, Markus Armbruster wrote:
>> Max Reitz <mreitz@redhat.com> writes:
>>
>>> s->blocker is really only used in hw/scsi/virtio-scsi.c; the only places
>>> where it is used in hw/scsi/virtio-scsi-dataplane.c is when it is
>>> allocated and when it is freed. That does not make a whole lot of sense
>>> (and is actually wrong because this leads to s->blocker potentially
>>> being NULL when blk_op_block_all() is called in virtio-scsi.c), so move
>>> the allocation and destruction of s->blocker to blk_op_block_all() and
>>> blk_op_unblock_all() in virtio-scsi.c, respectively.
>>>
>> Why do you put your nice reproducer below the --- divider?  I rather
>> like bug fixing commits come with reproducers in the commit message.

As do I :)

>>
>> [...]
> 
> Because then I'm afraid that Eric complains because I used echo -e
> instead of printf.

I might point out the non-portability, but for a commit message, I'm
perfectly fine leaving a non-portable construct in place.  I'm only
going to ask for a respin if 'echo -e' is used in the patch body.

> 
> Seriously speaking, I don't mind putting it into the commit message.
> I'll wait for reviews on the change itself, and then either send a v2
> with the reproducer included in the commit message or hope for a
> maintainer to fix it up himself (which I'd be totally fine with *hint
> hint*).

Up to the maintainer on that front, but if it helps, then with the
amended commit message:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

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

* Re: [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking
  2015-02-23 22:58 [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking Max Reitz
  2015-02-24  9:43 ` Markus Armbruster
@ 2015-02-25  6:22 ` Fam Zheng
  1 sibling, 0 replies; 5+ messages in thread
From: Fam Zheng @ 2015-02-25  6:22 UTC (permalink / raw)
  To: Max Reitz; +Cc: Paolo Bonzini, qemu-devel, Anthony Liguori, Michael S. Tsirkin

On Mon, 02/23 17:58, Max Reitz wrote:
> s->blocker is really only used in hw/scsi/virtio-scsi.c; the only places
> where it is used in hw/scsi/virtio-scsi-dataplane.c is when it is
> allocated and when it is freed. That does not make a whole lot of sense
> (and is actually wrong because this leads to s->blocker potentially
> being NULL when blk_op_block_all() is called in virtio-scsi.c), so move
> the allocation and destruction of s->blocker to blk_op_block_all() and
> blk_op_unblock_all() in virtio-scsi.c, respectively.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> Try:
> 
> $ echo -e 'eject drv\nquit' | \
>     x86_64-softmmu/qemu-system-x86_64 \
>         -monitor stdio -machine accel=qtest -display none \
>         -object iothread,id=thr -device virtio-scsi-pci,iothread=thr \
>         -drive if=none,file=test.qcow2,format=qcow2,id=drv \
>         -device scsi-cd,drive=drv
> 
> What it should do:
> 
> QEMU 2.2.50 monitor - type 'help' for more information
> (qemu) eject drv
> Device 'drv' is busy: block device is in use by data plane
> (qemu) quit
> 
> What it should not do:
> 
> QEMU 2.2.50 monitor - type 'help' for more information
> (qemu) eject drv
> [1]    10102 done
>        10103 segmentation fault (core dumped)
> ---
>  hw/scsi/virtio-scsi-dataplane.c | 4 ----
>  hw/scsi/virtio-scsi.c           | 6 +++++-
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
> index 03a1e8c..9b775d4 100644
> --- a/hw/scsi/virtio-scsi-dataplane.c
> +++ b/hw/scsi/virtio-scsi-dataplane.c
> @@ -211,8 +211,6 @@ void virtio_scsi_dataplane_start(VirtIOSCSI *s)
>  
>      s->dataplane_starting = true;
>  
> -    assert(!s->blocker);
> -    error_setg(&s->blocker, "block device is in use by data plane");
>      /* Set up guest notifier (irq) */
>      rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
>      if (rc != 0) {
> @@ -279,8 +277,6 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
>      if (!s->dataplane_started || s->dataplane_stopping) {
>          return;
>      }
> -    error_free(s->blocker);
> -    s->blocker = NULL;
>      s->dataplane_stopping = true;
>      assert(s->ctx == iothread_get_aio_context(vs->conf.iothread));
>  
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index 9e2c718..5469bad 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -766,6 +766,8 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplug_dev, DeviceState *dev,
>          if (blk_op_is_blocked(sd->conf.blk, BLOCK_OP_TYPE_DATAPLANE, errp)) {
>              return;
>          }
> +        assert(!s->blocker);
> +        error_setg(&s->blocker, "block device is in use by data plane");
>          blk_op_block_all(sd->conf.blk, s->blocker);
>      }
>  
> @@ -789,8 +791,10 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                                 VIRTIO_SCSI_EVT_RESET_REMOVED);
>      }
>  
> -    if (s->ctx) {
> +    if (s->ctx && s->blocker) {
>          blk_op_unblock_all(sd->conf.blk, s->blocker);
> +        error_free(s->blocker);
> +        s->blocker = NULL;
>      }
>      qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);
>  }
> -- 
> 2.1.0
> 
> 

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

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

end of thread, other threads:[~2015-02-25  6:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-23 22:58 [Qemu-devel] [PATCH] virtio-scsi: Allocate op blocker reason before blocking Max Reitz
2015-02-24  9:43 ` Markus Armbruster
2015-02-24 14:03   ` Max Reitz
2015-02-24 16:24     ` Eric Blake
2015-02-25  6:22 ` Fam Zheng

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.