forked from quic/qemu
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multi-process: setup memory manager for remote device
SyncSysMemMsg message format is defined. It is used to send file descriptors of the RAM regions to remote device. RAM on the remote device is configured with a set of file descriptors. Old RAM regions are deleted and new regions, each with an fd, is added to the RAM. Signed-off-by: Jagannathan Raman <[email protected]> Signed-off-by: John G Johnson <[email protected]> Signed-off-by: Elena Ufimtseva <[email protected]> Reviewed-by: Stefan Hajnoczi <[email protected]> Message-id: 7d2d1831d812e85f681e7a8ab99e032cf4704689.1611938319.git.jag.raman@oracle.com Signed-off-by: Stefan Hajnoczi <[email protected]>
- Loading branch information
1 parent
c7d80c7
commit ed5d001
Showing
6 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Memory manager for remote device | ||
* | ||
* Copyright © 2018, 2021 Oracle and/or its affiliates. | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
* See the COPYING file in the top-level directory. | ||
* | ||
*/ | ||
|
||
#include "qemu/osdep.h" | ||
#include "qemu-common.h" | ||
|
||
#include "hw/remote/memory.h" | ||
#include "exec/address-spaces.h" | ||
#include "exec/ram_addr.h" | ||
#include "qapi/error.h" | ||
|
||
static void remote_sysmem_reset(void) | ||
{ | ||
MemoryRegion *sysmem, *subregion, *next; | ||
|
||
sysmem = get_system_memory(); | ||
|
||
QTAILQ_FOREACH_SAFE(subregion, &sysmem->subregions, subregions_link, next) { | ||
if (subregion->ram) { | ||
memory_region_del_subregion(sysmem, subregion); | ||
object_unparent(OBJECT(subregion)); | ||
} | ||
} | ||
} | ||
|
||
void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp) | ||
{ | ||
ERRP_GUARD(); | ||
SyncSysmemMsg *sysmem_info = &msg->data.sync_sysmem; | ||
MemoryRegion *sysmem, *subregion; | ||
static unsigned int suffix; | ||
int region; | ||
|
||
sysmem = get_system_memory(); | ||
|
||
remote_sysmem_reset(); | ||
|
||
for (region = 0; region < msg->num_fds; region++) { | ||
g_autofree char *name; | ||
subregion = g_new(MemoryRegion, 1); | ||
name = g_strdup_printf("remote-mem-%u", suffix++); | ||
memory_region_init_ram_from_fd(subregion, NULL, | ||
name, sysmem_info->sizes[region], | ||
true, msg->fds[region], | ||
sysmem_info->offsets[region], | ||
errp); | ||
|
||
if (*errp) { | ||
g_free(subregion); | ||
remote_sysmem_reset(); | ||
return; | ||
} | ||
|
||
memory_region_add_subregion(sysmem, sysmem_info->gpas[region], | ||
subregion); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Memory manager for remote device | ||
* | ||
* Copyright © 2018, 2021 Oracle and/or its affiliates. | ||
* | ||
* This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
* See the COPYING file in the top-level directory. | ||
* | ||
*/ | ||
|
||
#ifndef REMOTE_MEMORY_H | ||
#define REMOTE_MEMORY_H | ||
|
||
#include "exec/hwaddr.h" | ||
#include "hw/remote/mpqemu-link.h" | ||
|
||
void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters