From: Cam Macdonell <cam@cs.ualberta.ca>
To: qemu-devel@nongnu.org
Cc: Cam Macdonell <cam@cs.ualberta.ca>, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCH 2/2] Unregister shared memory on unplug.
Date: Tue, 30 Nov 2010 14:03:59 -0700 [thread overview]
Message-ID: <1291151039-10966-3-git-send-email-cam@cs.ualberta.ca> (raw)
In-Reply-To: <1291151039-10966-1-git-send-email-cam@cs.ualberta.ca>
This allows 'peer' ivshmem guests to detach from shared memory before migration
and re-attach after migration is complete.
Signed-off-by: Cam Macdonell <cam@cs.ualberta.ca>
---
hw/ivshmem.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/ivshmem.c b/hw/ivshmem.c
index 06dce70..9254fad 100644
--- a/hw/ivshmem.c
+++ b/hw/ivshmem.c
@@ -68,6 +68,7 @@ typedef struct IVShmemState {
int nb_peers; /* how many guests we have space for */
int max_peer; /* maximum numbered peer */
+ void *shm_ptr;
int vm_id;
uint32_t vectors;
uint32_t features;
@@ -365,14 +366,13 @@ static int check_shm_size(IVShmemState *s, int fd) {
* create the BAR and map the memory immediately */
static void create_shared_memory_BAR(IVShmemState *s, int fd) {
- void * ptr;
-
s->shm_fd = fd;
- ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ s->shm_ptr = mmap(0, s->ivshmem_size, PROT_READ|PROT_WRITE,
+ MAP_SHARED, fd, 0);
s->ivshmem_offset = qemu_ram_alloc_from_ptr(&s->dev.qdev, "ivshmem.bar2",
- s->ivshmem_size, ptr);
+ s->ivshmem_size, s->shm_ptr);
/* region for shared memory */
pci_register_bar(&s->dev, 2, s->ivshmem_size,
@@ -797,6 +797,10 @@ static int pci_ivshmem_uninit(PCIDevice *dev)
{
IVShmemState *s = DO_UPCAST(IVShmemState, dev, dev);
+ cpu_register_physical_memory(s->shm_pci_addr, s->ivshmem_size,
+ IO_MEM_UNASSIGNED);
+ qemu_ram_free_from_ptr(s->ivshmem_offset);
+ munmap(s->shm_ptr, s->ivshmem_size);
cpu_unregister_io_memory(s->ivshmem_mmio_io_addr);
unregister_savevm(&dev->qdev, "ivshmem", s);
--
1.7.0.4
prev parent reply other threads:[~2010-12-01 3:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-30 21:03 [Qemu-devel] [PATCH 0/2] fixups for ivshmem unplug/migration Cam Macdonell
2010-11-30 21:03 ` [Qemu-devel] [PATCH 1/2] add qemu_ram_free_from_ptr Cam Macdonell
2010-11-30 21:03 ` Cam Macdonell [this message]
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=1291151039-10966-3-git-send-email-cam@cs.ualberta.ca \
--to=cam@cs.ualberta.ca \
--cc=kvm@vger.kernel.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).