yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-migration-update-index-field-when-delete-or-qsort-RD.patch

26ba25
From 10aadee745539521945b4d6482717011eeb15fc2 Mon Sep 17 00:00:00 2001
26ba25
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
26ba25
Date: Wed, 1 Aug 2018 13:55:17 +0100
26ba25
Subject: [PATCH 13/21] migration: update index field when delete or qsort
26ba25
 RDMALocalBlock
26ba25
26ba25
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
Message-id: <20180801135522.11658-14-dgilbert@redhat.com>
26ba25
Patchwork-id: 81574
26ba25
O-Subject: [qemu-kvm RHEL8/virt212 PATCH 13/18] migration: update index field when delete or qsort RDMALocalBlock
26ba25
Bugzilla: 1594384
26ba25
RH-Acked-by: Peter Xu <peterx@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Juan Quintela <quintela@redhat.com>
26ba25
26ba25
From: Lidong Chen <jemmy858585@gmail.com>
26ba25
26ba25
rdma_delete_block function deletes RDMALocalBlock base on index field,
26ba25
but not update the index field. So when next time invoke rdma_delete_block,
26ba25
it will not work correctly.
26ba25
26ba25
If start and cancel migration repeatedly, some RDMALocalBlock not invoke
26ba25
ibv_dereg_mr to decrease kernel mm_struct vmpin. When vmpin is large than
26ba25
max locked memory limitation, ibv_reg_mr will failed, and migration can not
26ba25
start successfully again.
26ba25
26ba25
Signed-off-by: Lidong Chen <lidongchen@tencent.com>
26ba25
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
26ba25
Message-Id: <1525618499-1560-1-git-send-email-lidongchen@tencent.com>
26ba25
Signed-off-by: Juan Quintela <quintela@redhat.com>
26ba25
26ba25
Signed-off-by: Lidong Chen <jemmy858585@gmail.com>
26ba25
(cherry picked from commit 71cd73061c014d04bc6b54936e675347ebc8d964)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 migration/rdma.c | 7 +++++++
26ba25
 1 file changed, 7 insertions(+)
26ba25
26ba25
diff --git a/migration/rdma.c b/migration/rdma.c
26ba25
index da474fc..7d233b0 100644
26ba25
--- a/migration/rdma.c
26ba25
+++ b/migration/rdma.c
26ba25
@@ -708,6 +708,9 @@ static int rdma_delete_block(RDMAContext *rdma, RDMALocalBlock *block)
26ba25
             memcpy(local->block + block->index, old + (block->index + 1),
26ba25
                 sizeof(RDMALocalBlock) *
26ba25
                     (local->nb_blocks - (block->index + 1)));
26ba25
+            for (x = block->index; x < local->nb_blocks - 1; x++) {
26ba25
+                local->block[x].index--;
26ba25
+            }
26ba25
         }
26ba25
     } else {
26ba25
         assert(block == local->block);
26ba25
@@ -3246,6 +3249,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque)
26ba25
             qsort(rdma->local_ram_blocks.block,
26ba25
                   rdma->local_ram_blocks.nb_blocks,
26ba25
                   sizeof(RDMALocalBlock), dest_ram_sort_func);
26ba25
+            for (i = 0; i < local->nb_blocks; i++) {
26ba25
+                local->block[i].index = i;
26ba25
+            }
26ba25
+
26ba25
             if (rdma->pin_all) {
26ba25
                 ret = qemu_rdma_reg_whole_ram_blocks(rdma);
26ba25
                 if (ret) {
26ba25
-- 
26ba25
1.8.3.1
26ba25