qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize
@ 2020-01-17  7:55 pannengyuan
  2020-01-17  7:55 ` [PATCH 1/2] virtio-scsi: delete vqs in unrealize to avoid memleaks pannengyuan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: pannengyuan @ 2020-01-17  7:55 UTC (permalink / raw)
  To: mst, pbonzini, fam; +Cc: Pan Nengyuan, qemu-devel, zhang.zhanghailiang

From: Pan Nengyuan <pannengyuan@huawei.com>

This serie patch fix memleaks when detaching virtio-scsi device. 
1. use old virtio_del_queue to fix memleaks, it's easier for stable branches to merge.
   As the discussion in https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02903.html

2. replace virtio_del_queue to virtio_delete_queue to make it more clear.

Pan Nengyuan (2):
  virtio-scsi: delete vqs in unrealize to avoid memleaks
  virtio-scsi: convert to new virtio_delete_queue

 hw/scsi/virtio-scsi.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.21.0.windows.1




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

* [PATCH 1/2] virtio-scsi: delete vqs in unrealize to avoid memleaks
  2020-01-17  7:55 [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize pannengyuan
@ 2020-01-17  7:55 ` pannengyuan
  2020-01-17  7:55 ` [PATCH 2/2] virtio-scsi: convert to new virtio_delete_queue pannengyuan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pannengyuan @ 2020-01-17  7:55 UTC (permalink / raw)
  To: mst, pbonzini, fam
  Cc: Euler Robot, Pan Nengyuan, qemu-devel, zhang.zhanghailiang

From: Pan Nengyuan <pannengyuan@huawei.com>

This patch fix memleaks when attaching/detaching virtio-scsi device, the
memory leak stack is as follow:

Direct leak of 21504 byte(s) in 3 object(s) allocated from:
  #0 0x7f491f2f2970 (/lib64/libasan.so.5+0xef970)  ??:?
  #1 0x7f491e94649d (/lib64/libglib-2.0.so.0+0x5249d)  ??:?
  #2 0x564d0f3919fa (./x86_64-softmmu/qemu-system-x86_64+0x2c3e9fa)  /mnt/sdb/qemu/hw/virtio/virtio.c:2333
  #3 0x564d0f2eca55 (./x86_64-softmmu/qemu-system-x86_64+0x2b99a55)  /mnt/sdb/qemu/hw/scsi/virtio-scsi.c:912
  #4 0x564d0f2ece7b (./x86_64-softmmu/qemu-system-x86_64+0x2b99e7b)  /mnt/sdb/qemu/hw/scsi/virtio-scsi.c:924
  #5 0x564d0f39ee47 (./x86_64-softmmu/qemu-system-x86_64+0x2c4be47)  /mnt/sdb/qemu/hw/virtio/virtio.c:3531
  #6 0x564d0f980224 (./x86_64-softmmu/qemu-system-x86_64+0x322d224)  /mnt/sdb/qemu/hw/core/qdev.c:865

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
 hw/scsi/virtio-scsi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 4bc73a370e..858b3aaccb 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -943,7 +943,13 @@ void virtio_scsi_common_unrealize(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
+    int i;
 
+    virtio_del_queue(vdev, 0);
+    virtio_del_queue(vdev, 1);
+    for (i = 0; i < vs->conf.num_queues; i++) {
+        virtio_del_queue(vdev, i + 2);
+    }
     g_free(vs->cmd_vqs);
     virtio_cleanup(vdev);
 }
-- 
2.21.0.windows.1




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

* [PATCH 2/2] virtio-scsi: convert to new virtio_delete_queue
  2020-01-17  7:55 [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize pannengyuan
  2020-01-17  7:55 ` [PATCH 1/2] virtio-scsi: delete vqs in unrealize to avoid memleaks pannengyuan
@ 2020-01-17  7:55 ` pannengyuan
  2020-01-20 14:35 ` [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize Stefan Hajnoczi
  2020-01-21 16:23 ` Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: pannengyuan @ 2020-01-17  7:55 UTC (permalink / raw)
  To: mst, pbonzini, fam; +Cc: Pan Nengyuan, qemu-devel, zhang.zhanghailiang

From: Pan Nengyuan <pannengyuan@huawei.com>

Use virtio_delete_queue to make it more clear.

Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
 hw/scsi/virtio-scsi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 858b3aaccb..d3af42ef92 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -945,10 +945,10 @@ void virtio_scsi_common_unrealize(DeviceState *dev)
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
     int i;
 
-    virtio_del_queue(vdev, 0);
-    virtio_del_queue(vdev, 1);
+    virtio_delete_queue(vs->ctrl_vq);
+    virtio_delete_queue(vs->event_vq);
     for (i = 0; i < vs->conf.num_queues; i++) {
-        virtio_del_queue(vdev, i + 2);
+        virtio_delete_queue(vs->cmd_vqs[i]);
     }
     g_free(vs->cmd_vqs);
     virtio_cleanup(vdev);
-- 
2.21.0.windows.1




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

* Re: [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize
  2020-01-17  7:55 [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize pannengyuan
  2020-01-17  7:55 ` [PATCH 1/2] virtio-scsi: delete vqs in unrealize to avoid memleaks pannengyuan
  2020-01-17  7:55 ` [PATCH 2/2] virtio-scsi: convert to new virtio_delete_queue pannengyuan
@ 2020-01-20 14:35 ` Stefan Hajnoczi
  2020-01-21 16:23 ` Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2020-01-20 14:35 UTC (permalink / raw)
  To: pannengyuan; +Cc: fam, pbonzini, zhang.zhanghailiang, qemu-devel, mst

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

On Fri, Jan 17, 2020 at 03:55:45PM +0800, pannengyuan@huawei.com wrote:
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> This serie patch fix memleaks when detaching virtio-scsi device. 
> 1. use old virtio_del_queue to fix memleaks, it's easier for stable branches to merge.
>    As the discussion in https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02903.html
> 
> 2. replace virtio_del_queue to virtio_delete_queue to make it more clear.
> 
> Pan Nengyuan (2):
>   virtio-scsi: delete vqs in unrealize to avoid memleaks
>   virtio-scsi: convert to new virtio_delete_queue
> 
>  hw/scsi/virtio-scsi.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> -- 
> 2.21.0.windows.1
> 
> 
> 

The patches could be squashed by the maintainer, but the code changes
are fine:

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize
  2020-01-17  7:55 [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize pannengyuan
                   ` (2 preceding siblings ...)
  2020-01-20 14:35 ` [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize Stefan Hajnoczi
@ 2020-01-21 16:23 ` Paolo Bonzini
  3 siblings, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2020-01-21 16:23 UTC (permalink / raw)
  To: pannengyuan, mst, fam; +Cc: qemu-devel, zhang.zhanghailiang

On 17/01/20 08:55, pannengyuan@huawei.com wrote:
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> This serie patch fix memleaks when detaching virtio-scsi device. 
> 1. use old virtio_del_queue to fix memleaks, it's easier for stable branches to merge.
>    As the discussion in https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02903.html
> 
> 2. replace virtio_del_queue to virtio_delete_queue to make it more clear.
> 
> Pan Nengyuan (2):
>   virtio-scsi: delete vqs in unrealize to avoid memleaks
>   virtio-scsi: convert to new virtio_delete_queue
> 
>  hw/scsi/virtio-scsi.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 

Queued, thanks.

Paolo



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

end of thread, other threads:[~2020-01-21 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17  7:55 [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize pannengyuan
2020-01-17  7:55 ` [PATCH 1/2] virtio-scsi: delete vqs in unrealize to avoid memleaks pannengyuan
2020-01-17  7:55 ` [PATCH 2/2] virtio-scsi: convert to new virtio_delete_queue pannengyuan
2020-01-20 14:35 ` [PATCH 0/2] delete virtio queues in virtio_scsi_unrealize Stefan Hajnoczi
2020-01-21 16:23 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).