ram_discard_listener_init(&vrdl->listener,
vfio_ram_discard_notify_populate,
- vfio_ram_discard_notify_discard, true);
+ vfio_ram_discard_notify_discard);
ram_discard_manager_register_listener(rdm, &vrdl->listener, section);
QLIST_INSERT_HEAD(&bcontainer->vrdl_list, vrdl, next);
return rdl->notify_populate(rdl, s);
}
-static int virtio_mem_notify_discard_cb(MemoryRegionSection *s, void *arg)
-{
- RamDiscardListener *rdl = arg;
-
- rdl->notify_discard(rdl, s);
- return 0;
-}
-
static void virtio_mem_notify_unplug(VirtIOMEM *vmem, uint64_t offset,
uint64_t size)
{
}
QLIST_FOREACH(rdl, &vmem->rdl_list, next) {
- if (rdl->double_discard_supported) {
- rdl->notify_discard(rdl, rdl->section);
- } else {
- virtio_mem_for_each_plugged_section(vmem, rdl->section, rdl,
- virtio_mem_notify_discard_cb);
- }
+ rdl->notify_discard(rdl, rdl->section);
}
}
g_assert(rdl->section->mr == &vmem->memdev->mr);
if (vmem->size) {
- if (rdl->double_discard_supported) {
- rdl->notify_discard(rdl, rdl->section);
- } else {
- virtio_mem_for_each_plugged_section(vmem, rdl->section, rdl,
- virtio_mem_notify_discard_cb);
- }
+ rdl->notify_discard(rdl, rdl->section);
}
memory_region_section_free_copy(rdl->section);
*/
NotifyRamDiscard notify_discard;
- /*
- * @double_discard_supported:
- *
- * The listener suppors getting @notify_discard notifications that span
- * already discarded parts.
- */
- bool double_discard_supported;
-
MemoryRegionSection *section;
QLIST_ENTRY(RamDiscardListener) next;
};
static inline void ram_discard_listener_init(RamDiscardListener *rdl,
NotifyRamPopulate populate_fn,
- NotifyRamDiscard discard_fn,
- bool double_discard_supported)
+ NotifyRamDiscard discard_fn)
{
rdl->notify_populate = populate_fn;
rdl->notify_discard = discard_fn;
- rdl->double_discard_supported = double_discard_supported;
}
/**
return rdl->notify_populate(rdl, section);
}
-static int
-ram_block_attributes_notify_discard_cb(MemoryRegionSection *section,
- void *arg)
-{
- RamDiscardListener *rdl = arg;
-
- rdl->notify_discard(rdl, section);
- return 0;
-}
-
static int
ram_block_attributes_for_each_populated_section(const RamBlockAttributes *attr,
MemoryRegionSection *section,
RamDiscardListener *rdl)
{
RamBlockAttributes *attr = RAM_BLOCK_ATTRIBUTES(rdm);
- int ret;
g_assert(rdl->section);
g_assert(rdl->section->mr == attr->ram_block->mr);
- if (rdl->double_discard_supported) {
- rdl->notify_discard(rdl, rdl->section);
- } else {
- ret = ram_block_attributes_for_each_populated_section(attr,
- rdl->section, rdl, ram_block_attributes_notify_discard_cb);
- if (ret) {
- error_report("%s: Failed to unregister RAM discard listener: %s",
- __func__, strerror(-ret));
- exit(1);
- }
- }
+ rdl->notify_discard(rdl, rdl->section);
memory_region_section_free_copy(rdl->section);
rdl->section = NULL;