From: Eduardo Habkost <ehabkost@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
David Hildenbrand <david@redhat.com>
Subject: [Qemu-devel] [PULL 07/12] pc-dimm: move actual plug/unplug of a memory region to MemoryDevice
Date: Mon, 7 May 2018 14:03:10 -0300 [thread overview]
Message-ID: <20180507170315.11497-8-ehabkost@redhat.com> (raw)
In-Reply-To: <20180507170315.11497-1-ehabkost@redhat.com>
From: David Hildenbrand <david@redhat.com>
Registering the memory region for migration has do be done by the owner.
There could be cases, where we don't want to migrate the memory.
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180423165126.15441-8-david@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
include/hw/mem/memory-device.h | 3 +++
hw/mem/memory-device.c | 18 ++++++++++++++++++
hw/mem/pc-dimm.c | 5 ++---
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index 3427c7d424..2853b084b5 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -44,5 +44,8 @@ uint64_t get_plugged_memory_size(void);
uint64_t memory_device_get_free_addr(MachineState *ms, const uint64_t *hint,
uint64_t align, uint64_t size,
Error **errp);
+void memory_device_plug_region(MachineState *ms, MemoryRegion *mr,
+ uint64_t addr);
+void memory_device_unplug_region(MachineState *ms, MemoryRegion *mr);
#endif
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index 8535ddcb14..3e04f3954e 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -243,6 +243,24 @@ uint64_t get_plugged_memory_size(void)
return size;
}
+void memory_device_plug_region(MachineState *ms, MemoryRegion *mr,
+ uint64_t addr)
+{
+ /* we expect a previous call to memory_device_get_free_addr() */
+ g_assert(ms->device_memory);
+
+ memory_region_add_subregion(&ms->device_memory->mr,
+ addr - ms->device_memory->base, mr);
+}
+
+void memory_device_unplug_region(MachineState *ms, MemoryRegion *mr)
+{
+ /* we expect a previous call to memory_device_get_free_addr() */
+ g_assert(ms->device_memory);
+
+ memory_region_del_subregion(&ms->device_memory->mr, mr);
+}
+
static const TypeInfo memory_device_info = {
.name = TYPE_MEMORY_DEVICE,
.parent = TYPE_INTERFACE,
diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 8aa2d36ce9..0119c68e01 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -36,7 +36,6 @@ void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine,
uint64_t align, Error **errp)
{
int slot;
- MemoryHotplugState *hpms = machine->device_memory;
PCDIMMDevice *dimm = PC_DIMM(dev);
PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm);
MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
@@ -83,7 +82,7 @@ void pc_dimm_memory_plug(DeviceState *dev, MachineState *machine,
}
trace_mhp_pc_dimm_assigned_slot(slot);
- memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr);
+ memory_device_plug_region(machine, mr, addr);
vmstate_register_ram(vmstate_mr, dev);
out:
@@ -97,7 +96,7 @@ void pc_dimm_memory_unplug(DeviceState *dev, MachineState *machine)
MemoryRegion *vmstate_mr = ddc->get_vmstate_memory_region(dimm);
MemoryRegion *mr = ddc->get_memory_region(dimm, &error_abort);
- memory_region_del_subregion(&machine->device_memory->mr, mr);
+ memory_device_unplug_region(machine, mr);
vmstate_unregister_ram(vmstate_mr, dev);
}
--
2.14.3
next prev parent reply other threads:[~2018-05-07 17:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-07 17:03 [Qemu-devel] [PULL 00/12] Machine queue, 2018-05-07 Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 01/12] pc-dimm: factor out MemoryDevice interface Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 02/12] machine: make MemoryHotplugState accessible via the machine Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 03/12] pc-dimm: no need to pass the memory region Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 04/12] pc-dimm: pass in the machine and to the MemoryHotplugState Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 05/12] pc-dimm: factor out address search into MemoryDevice code Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 06/12] pc-dimm: factor out capacity and slot checks into MemoryDevice Eduardo Habkost
2018-05-07 17:03 ` Eduardo Habkost [this message]
2018-05-07 17:03 ` [Qemu-devel] [PULL 08/12] machine: rename MemoryHotplugState to DeviceMemoryState Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 09/12] pc: rename "hotplug memory" terminology to "device memory" Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 10/12] spapr: " Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 11/12] vl: allow 'maxmem' without 'slot' Eduardo Habkost
2018-05-07 17:03 ` [Qemu-devel] [PULL 12/12] scripts/device-crash-test: Removed fixed CAN entries Eduardo Habkost
2018-05-08 15:15 ` [Qemu-devel] [PULL 00/12] Machine queue, 2018-05-07 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180507170315.11497-8-ehabkost@redhat.com \
--to=ehabkost@redhat.com \
--cc=david@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).