On 6/9/2026 7:52 PM, Igor Mammedov wrote:
On Fri, 5 Jun 2026 18:46:08 +0800 fanhuang <[email protected]> wrote:+ if (host_memory_backend_is_mapped(spm->hostmem)) { + error_setg(errp, "memory backend '%s' is already in use", + object_get_canonical_path_component(OBJECT(spm->hostmem))); + return; + }this belongs to sp_mem realize
Right — it only needs spm->hostmem, no MachineState. Will move the is_mapped check (and the set_mapped(true)) into sp_mem_realize(), with a matching set_mapped(false) in unrealize, mirroring pc-dimm.
+ if (ms->numa_state && spm->node >= ms->numa_state->num_nodes) { + error_setg(errp, + "'node' property value %" PRIu32 + " exceeds the number of NUMA nodes (%d)", + spm->node, ms->numa_state->num_nodes); + return; + }I think this the right place for this, despite what other mems do. Perhaps it is worth to consolidate/cleanup 1st. I'd put it in memory_device_pre_plug(): if has_node_prop: .....
Agreed on keeping the check in pre_plug. I looked into the consolidation: pc-dimm and virtio-mem each carry their own node validation in realize() today, with slightly different wording (and pc-dimm has an extra "machine doesn't support NUMA" branch that virtio-mem folds into its main check). A generic version in memory_device_pre_plug() (gated on the device exposing a "node" property) would have to subsume both and settle on one error path -- a framework change spanning pc-dimm and virtio-mem, separate in scope from adding sp-mem. So for the next respin the node check stays local to pc_sp_mem_pre_plug(); I'll follow up with the consolidation as a dedicated cleanup once sp-mem lands.
+ memory_device_pre_plug(MEMORY_DEVICE(dev), ms, errp); +} + +static void pc_sp_mem_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + SpMemDevice *spm = SP_MEM(dev); + MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(MEMORY_DEVICE(dev)); + uint64_t addr, size; + + host_memory_backend_set_mapped(spm->hostmem, true);dup? see above.
Yes — removed from plug once the check/set move to realize. Best regards, FangSheng Huang (Jerry)
