diff mbox series

[PROTOTYPE,5/6] virtio-mem: Require only RAM_BLOCK_DISCARD_T_COORDINATED discards

Message ID 20200924160423.106747-6-david@redhat.com
State New
Headers show
Series virtio-mem: vfio support | expand

Commit Message

David Hildenbrand Sept. 24, 2020, 4:04 p.m. UTC
We implement the SparseRamHandler interface and properly communicate
changes by notifying listeners - especially in all scenarios
- when memory becomes usable by the guest
- when memory becomes unusable by the guest (and we discard memory)

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Wei Yang <richardw.yang@linux.intel.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Pankaj Gupta <pankaj.gupta.linux@gmail.com>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 hw/virtio/virtio-mem.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index e23969eaed..efeff7c64c 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -531,7 +531,7 @@  static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
         return;
     }
 
-    if (ram_block_discard_require(true)) {
+    if (ram_block_discard_type_require(RAM_BLOCK_DISCARD_T_COORDINATED, true)) {
         error_setg(errp, "Discarding RAM is disabled");
         return;
     }
@@ -539,7 +539,7 @@  static void virtio_mem_device_realize(DeviceState *dev, Error **errp)
     ret = ram_block_discard_range(rb, 0, qemu_ram_get_used_length(rb));
     if (ret) {
         error_setg_errno(errp, -ret, "Unexpected error discarding RAM");
-        ram_block_discard_require(false);
+        ram_block_discard_type_require(RAM_BLOCK_DISCARD_T_COORDINATED, false);
         return;
     }
 
@@ -579,7 +579,7 @@  static void virtio_mem_device_unrealize(DeviceState *dev)
     virtio_del_queue(vdev, 0);
     virtio_cleanup(vdev);
     g_free(vmem->bitmap);
-    ram_block_discard_require(false);
+    ram_block_discard_type_require(RAM_BLOCK_DISCARD_T_COORDINATED, false);
 }
 
 static int virtio_mem_restore_unplugged(VirtIOMEM *vmem)