machine: make MemoryHotplugState accessible via the machine

Let's allow to query the MemoryHotplugState directly from the machine.
If the pointer is NULL, the machine does not support memory devices. If
the pointer is !NULL, the machine supports memory devices and the
data structure contains information about the applicable physical
guest address space region.

This allows us to generically detect if a certain machine has support
for memory devices, and to generically manage it (find free address
range, plug/unplug a memory region).

We will rename "MemoryHotplugState" to something more meaningful
("DeviceMemory") after we completed factoring out the pc-dimm code into
MemoryDevice code.

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180423165126.15441-3-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
[ehabkost: rebased series, solved conflicts at spapr.c]
[ehabkost: squashed fix to use g_malloc0()]
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
This commit is contained in:
David Hildenbrand 2018-04-23 18:51:17 +02:00 committed by Eduardo Habkost
parent 2cc0e2e814
commit b0c14ec4ef
9 changed files with 60 additions and 50 deletions

View file

@ -213,6 +213,17 @@ struct MachineClass {
int64_t (*get_default_cpu_node_id)(const MachineState *ms, int idx);
};
/**
* MemoryHotplugState:
* @base: address in guest physical address space where the memory
* address space for memory devices starts
* @mr: address space container for memory devices
*/
typedef struct MemoryHotplugState {
hwaddr base;
MemoryRegion mr;
} MemoryHotplugState;
/**
* MachineState:
*/
@ -243,6 +254,7 @@ struct MachineState {
bool enforce_config_section;
bool enable_graphics;
char *memory_encryption;
MemoryHotplugState *device_memory;
ram_addr_t ram_size;
ram_addr_t maxram_size;

View file

@ -32,7 +32,6 @@ struct PCMachineState {
/* <public> */
/* State for other subsystems/APIs: */
MemoryHotplugState hotplug_memory;
Notifier machine_done;
/* Pointers to devices and objects: */

View file

@ -19,6 +19,7 @@
#include "exec/memory.h"
#include "sysemu/hostmem.h"
#include "hw/qdev.h"
#include "hw/boards.h"
#define TYPE_PC_DIMM "pc-dimm"
#define PC_DIMM(obj) \
@ -75,17 +76,6 @@ typedef struct PCDIMMDeviceClass {
MemoryRegion *(*get_vmstate_memory_region)(PCDIMMDevice *dimm);
} PCDIMMDeviceClass;
/**
* MemoryHotplugState:
* @base: address in guest physical address space where hotplug memory
* address space begins.
* @mr: hotplug memory address space container
*/
typedef struct MemoryHotplugState {
hwaddr base;
MemoryRegion mr;
} MemoryHotplugState;
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start,
uint64_t address_space_size,
uint64_t *hint, uint64_t align, uint64_t size,

View file

@ -162,7 +162,6 @@ struct sPAPRMachineState {
/*< public >*/
char *kvm_type;
MemoryHotplugState hotplug_memory;
const char *icp_type;