virtio-mem: Implement RamDiscardManager interface
commit2044969f0b27fa67f2b69bc710eaef45998cb6fb
authorDavid Hildenbrand <david@redhat.com>
Tue, 13 Apr 2021 09:55:23 +0000 (13 11:55 +0200)
committerEduardo Habkost <ehabkost@redhat.com>
Thu, 8 Jul 2021 19:54:45 +0000 (8 15:54 -0400)
tree5649d2f1d2338675082c09b41f4cd1a151d043bc
parent3aca6380fdf566e518640de0d90ea6fa74b41825
virtio-mem: Implement RamDiscardManager interface

Let's properly notify when (un)plugging blocks, after discarding memory
and before allowing the guest to consume memory. Handle errors from
notifiers gracefully (e.g., no remaining VFIO mappings) when plugging,
rolling back the change and telling the guest that the VM is busy.

One special case to take care of is replaying all notifications after
restoring the vmstate. The device starts out with all memory discarded,
so after loading the vmstate, we have to notify about all plugged
blocks.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Alex Williamson <alex.williamson@redhat.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>
Cc: Auger Eric <eric.auger@redhat.com>
Cc: Wei Yang <richard.weiyang@linux.alibaba.com>
Cc: teawater <teawaterz@linux.alibaba.com>
Cc: Marek Kedzierski <mkedzier@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20210413095531.25603-6-david@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
hw/virtio/virtio-mem.c
include/hw/virtio/virtio-mem.h