kvm: reuse memory region slots
kvm: reuse memory region slots

There is a low limit on the maximum memory slot number imposed by the
kernel. On x86_64, that limit is 509. In order to delay hitting that
limit, we attempt to use the lowest unused slot number. As memory
regions are removed from the VM, the slot for that region is stored in a
heap so that that slot number can quickly be reused next time a memory
region is added.

BUG=None
TEST=finish a game of gnome-mahjong using virtio-wayland

Change-Id: I786c2e2b8ff239c19b3c8a18bd0f6e8f8dc2acbf
Reviewed-on: https://chromium-review.googlesource.com/740102
Commit-Ready: Stephen Barber <7719587e4b5a49340661b214ec85602f3918d06f@chromium.org>
Tested-by: Stephen Barber <7719587e4b5a49340661b214ec85602f3918d06f@chromium.org>
Tested-by: Zach Reizner <3374927928a53d04457674c546bd4de57c2044ec@chromium.org>
Reviewed-by: Stephen Barber <7719587e4b5a49340661b214ec85602f3918d06f@chromium.org>
Reviewed-by: Dylan Reid <c791bfe44996c1eed9c7149a0c5f12a86d58eb85@chromium.org>

google/crosvm,google/crosvm,google/crosvm,google/crosvm