pc-dimm: factor out capacity and slot checks into MemoryDevice

Move the checks into memory_device_get_free_addr(). This will check
before doing any calculations if we have KVM/vhost slots left and if
the total region size would be exceeded.

Of course, while at it, make it independent of pc-dimm code.

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180423165126.15441-7-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
David Hildenbrand 2018-04-23 18:51:21 +02:00 committed by Eduardo Habkost
parent bb0831bdf4
commit 1b6d6af21b
3 changed files with 51 additions and 61 deletions

View file

@ -78,7 +78,6 @@ typedef struct PCDIMMDeviceClass {
int pc_dimm_get_free_slot(const int *hint, int max_slots, Error **errp);
uint64_t pc_existing_dimms_capacity(Error **errp);
void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine,
uint64_t align, Error **errp);
void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine);