qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

migration/rdma: Use ram_block_discard_disable()

RDMA will pin all guest memory (as documented in docs/rdma.txt). We want
to disable RAM block discards - however, to keep it simple use
ram_block_discard_is_required() instead of inhibiting.

Note: It is not sufficient to limit disabling to pin_all. Even when only
conditionally pinning 1 MB chunks, as soon as one page within such a
chunk was discarded and one page not, the discarded pages will be pinned
as well.

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20200626072248.78761-9-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

David Hildenbrand and committed by
Michael S. Tsirkin
5f1f1902 fee3f3ba

+16 -2
+16 -2
migration/rdma.c
··· 29 29 #include "qemu/sockets.h" 30 30 #include "qemu/bitmap.h" 31 31 #include "qemu/coroutine.h" 32 + #include "exec/memory.h" 32 33 #include <sys/socket.h> 33 34 #include <netdb.h> 34 35 #include <arpa/inet.h> ··· 4017 4018 Error *local_err = NULL; 4018 4019 4019 4020 trace_rdma_start_incoming_migration(); 4020 - rdma = qemu_rdma_data_init(host_port, &local_err); 4021 4021 4022 + /* Avoid ram_block_discard_disable(), cannot change during migration. */ 4023 + if (ram_block_discard_is_required()) { 4024 + error_setg(errp, "RDMA: cannot disable RAM discard"); 4025 + return; 4026 + } 4027 + 4028 + rdma = qemu_rdma_data_init(host_port, &local_err); 4022 4029 if (rdma == NULL) { 4023 4030 goto err; 4024 4031 } ··· 4067 4074 const char *host_port, Error **errp) 4068 4075 { 4069 4076 MigrationState *s = opaque; 4070 - RDMAContext *rdma = qemu_rdma_data_init(host_port, errp); 4071 4077 RDMAContext *rdma_return_path = NULL; 4078 + RDMAContext *rdma; 4072 4079 int ret = 0; 4073 4080 4081 + /* Avoid ram_block_discard_disable(), cannot change during migration. */ 4082 + if (ram_block_discard_is_required()) { 4083 + error_setg(errp, "RDMA: cannot disable RAM discard"); 4084 + return; 4085 + } 4086 + 4087 + rdma = qemu_rdma_data_init(host_port, errp); 4074 4088 if (rdma == NULL) { 4075 4089 goto err; 4076 4090 }