mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
hostmem-shm: preserve for cpr
Preserve memory-backend-shm memory objects during cpr-transfer. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Peter Xu <peterx@redhat.com> Link: https://lore.kernel.org/r/1736967650-129648-11-git-send-email-steven.sistare@oracle.com Signed-off-by: Fabiano Rosas <farosas@suse.de>
This commit is contained in:
parent
28eaa5957d
commit
2ef121688f
1 changed files with 9 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
|||
#include "qemu/osdep.h"
|
||||
#include "system/hostmem.h"
|
||||
#include "qapi/error.h"
|
||||
#include "migration/cpr.h"
|
||||
|
||||
#define TYPE_MEMORY_BACKEND_SHM "memory-backend-shm"
|
||||
|
||||
|
@ -25,9 +26,9 @@ struct HostMemoryBackendShm {
|
|||
static bool
|
||||
shm_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
|
||||
{
|
||||
g_autofree char *backend_name = NULL;
|
||||
g_autofree char *backend_name = host_memory_backend_get_name(backend);
|
||||
uint32_t ram_flags;
|
||||
int fd;
|
||||
int fd = cpr_find_fd(backend_name, 0);
|
||||
|
||||
if (!backend->size) {
|
||||
error_setg(errp, "can't create shm backend with size 0");
|
||||
|
@ -39,13 +40,18 @@ shm_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (fd >= 0) {
|
||||
goto have_fd;
|
||||
}
|
||||
|
||||
fd = qemu_shm_alloc(backend->size, errp);
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
cpr_save_fd(backend_name, 0, fd);
|
||||
|
||||
have_fd:
|
||||
/* Let's do the same as memory-backend-ram,share=on would do. */
|
||||
backend_name = host_memory_backend_get_name(backend);
|
||||
ram_flags = RAM_SHARED;
|
||||
ram_flags |= backend->reserve ? 0 : RAM_NORESERVE;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue