virtio-mem: Prepare for device unplug support
commit92a8ee1b594244a82d4c955eab907034f8953f8b
authorDavid Hildenbrand <david@redhat.com>
Tue, 11 Jul 2023 15:34:44 +0000 (11 17:34 +0200)
committerDavid Hildenbrand <david@redhat.com>
Wed, 12 Jul 2023 07:27:31 +0000 (12 09:27 +0200)
tree5ddebb91d74600e3793832ada290e15d3d9a0ac8
parentaac44204bc6d2a062c2e1658fe6a02a67f55b9e6
virtio-mem: Prepare for device unplug support

In many cases, blindly unplugging a virtio-mem device is problematic. We
can only safely remove a device once:
* The guest is not expecting to be able to read unplugged memory
  (unplugged-inaccessible == on)
* The virtio-mem device does not have memory plugged (size == 0)
* The virtio-mem device does not have outstanding requests to the VM to
  plug memory (requested-size == 0)

So let's add a callback to the virtio-mem device class to check for that.
We'll wire-up virtio-mem-pci next.

Message-ID: <20230711153445.514112-7-david@redhat.com>
Tested-by: Mario Casquero <mcasquer@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David Hildenbrand <david@redhat.com>
hw/virtio/virtio-mem.c
include/hw/virtio/virtio-mem.h