[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[qemu-xen staging] vhost-user: fix duplicated notifier MR init



commit 695c25e167e217aab74f964afe9b93a8a52b4d41
Author:     Xueming Li <xuemingl@xxxxxxxxxx>
AuthorDate: Fri Oct 8 16:02:15 2021 +0800
Commit:     Michael Roth <michael.roth@xxxxxxx>
CommitDate: Tue Dec 14 08:57:02 2021 -0600

    vhost-user: fix duplicated notifier MR init
    
    In case of device resume after suspend, VQ notifier MR still valid.
    Duplicated registrations explode memory block list and slow down device
    resume.
    
    Fixes: 44866521bd6e ("vhost-user: support registering external host 
notifiers")
    Cc: tiwei.bie@xxxxxxxxx
    Cc: qemu-stable@xxxxxxxxxx
    Cc: Yuwei Zhang <zhangyuwei.9149@xxxxxxxxxxxxx>
    
    Signed-off-by: Xueming Li <xuemingl@xxxxxxxxxx>
    Message-Id: <20211008080215.590292-1-xuemingl@xxxxxxxxxx>
    Reviewed-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
    (cherry picked from commit a1ed9ef1de87c3e86ff68589604298ec90875a14)
    Signed-off-by: Michael Roth <michael.roth@xxxxxxx>
---
 hw/virtio/vhost-user.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index aec6cc1990..7b35c5d71d 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -1469,8 +1469,9 @@ static int 
vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *dev,
 
     name = g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]",
                            user, queue_idx);
-    memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
-                                      page_size, addr);
+    if (!n->mr.ram) /* Don't init again after suspend. */
+        memory_region_init_ram_device_ptr(&n->mr, OBJECT(vdev), name,
+                                          page_size, addr);
     g_free(name);
 
     if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) {
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.