qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: <pannengyuan@huawei.com>
To: <mst@redhat.com>, <kwolf@redhat.com>, <mreitz@redhat.com>
Cc: Pan Nengyuan <pannengyuan@huawei.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org,
	zhang.zhanghailiang@huawei.com
Subject: [PATCH 2/2] vhost-use-blk: convert to new virtio_delete_queue
Date: Thu, 13 Feb 2020 09:28:07 +0800	[thread overview]
Message-ID: <20200213012807.45552-3-pannengyuan@huawei.com> (raw)
In-Reply-To: <20200213012807.45552-1-pannengyuan@huawei.com>

From: Pan Nengyuan <pannengyuan@huawei.com>

use the new virtio_delete_queue function to cleanup.

Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
---
 hw/block/vhost-user-blk.c          | 11 +++++++----
 include/hw/virtio/vhost-user-blk.h |  1 +
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
index 2eba8b9db0..ed6a5cc03b 100644
--- a/hw/block/vhost-user-blk.c
+++ b/hw/block/vhost-user-blk.c
@@ -420,9 +420,10 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
     virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK,
                 sizeof(struct virtio_blk_config));
 
+    s->virtqs = g_new0(VirtQueue *, s->num_queues);
     for (i = 0; i < s->num_queues; i++) {
-        virtio_add_queue(vdev, s->queue_size,
-                         vhost_user_blk_handle_output);
+        s->virtqs[i] = virtio_add_queue(vdev, s->queue_size,
+                                        vhost_user_blk_handle_output);
     }
 
     s->inflight = g_new0(struct vhost_inflight, 1);
@@ -461,8 +462,9 @@ virtio_err:
     g_free(s->vqs);
     g_free(s->inflight);
     for (i = 0; i < s->num_queues; i++) {
-        virtio_del_queue(vdev, i);
+        virtio_delete_queue(s->virtqs[i]);
     }
+    g_free(s->virtqs);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&s->vhost_user);
 }
@@ -482,8 +484,9 @@ static void vhost_user_blk_device_unrealize(DeviceState *dev, Error **errp)
     g_free(s->inflight);
 
     for (i = 0; i < s->num_queues; i++) {
-        virtio_del_queue(vdev, i);
+        virtio_delete_queue(s->virtqs[i]);
     }
+    g_free(s->virtqs);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&s->vhost_user);
 }
diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-user-blk.h
index 108bfadeeb..f68911f6f0 100644
--- a/include/hw/virtio/vhost-user-blk.h
+++ b/include/hw/virtio/vhost-user-blk.h
@@ -37,6 +37,7 @@ typedef struct VHostUserBlk {
     struct vhost_inflight *inflight;
     VhostUserState vhost_user;
     struct vhost_virtqueue *vqs;
+    VirtQueue **virtqs;
     guint watch;
     bool connected;
 } VHostUserBlk;
-- 
2.21.0.windows.1




  parent reply	other threads:[~2020-02-13  1:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13  1:28 [PATCH 0/2] delete virtio queues in vhost-user-blk-unrealize pannengyuan
2020-02-13  1:28 ` [PATCH 1/2] vhost-user-blk: delete virtioqueues in unrealize to fix memleaks pannengyuan
2020-02-21 11:32   ` Stefan Hajnoczi
2020-02-13  1:28 ` pannengyuan [this message]
2020-02-21 11:31   ` [PATCH 2/2] vhost-use-blk: convert to new virtio_delete_queue Stefan Hajnoczi
2020-02-22  7:56     ` Pan Nengyuan
2020-02-25 13:31   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200213012807.45552-3-pannengyuan@huawei.com \
    --to=pannengyuan@huawei.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zhang.zhanghailiang@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).