[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V7 09/24] hostmem-memfd: preserve for cpr
From: |
Steve Sistare |
Subject: |
[PATCH V7 09/24] hostmem-memfd: preserve for cpr |
Date: |
Wed, 15 Jan 2025 11:00:35 -0800 |
Preserve memory-backend-memfd memory objects during cpr-transfer.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
---
backends/hostmem-memfd.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index 1672da9..85daa14 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -17,6 +17,7 @@
#include "qemu/module.h"
#include "qapi/error.h"
#include "qom/object.h"
+#include "migration/cpr.h"
OBJECT_DECLARE_SIMPLE_TYPE(HostMemoryBackendMemfd, MEMORY_BACKEND_MEMFD)
@@ -33,15 +34,19 @@ static bool
memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
{
HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(backend);
- g_autofree char *name = NULL;
+ g_autofree char *name = host_memory_backend_get_name(backend);
+ int fd = cpr_find_fd(name, 0);
uint32_t ram_flags;
- int fd;
if (!backend->size) {
error_setg(errp, "can't create backend with size 0");
return false;
}
+ if (fd >= 0) {
+ goto have_fd;
+ }
+
fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size,
m->hugetlb, m->hugetlbsize, m->seal ?
F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL : 0,
@@ -49,9 +54,10 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error
**errp)
if (fd == -1) {
return false;
}
+ cpr_save_fd(name, 0, fd);
+have_fd:
backend->aligned = true;
- name = host_memory_backend_get_name(backend);
ram_flags = backend->share ? RAM_SHARED : RAM_PRIVATE;
ram_flags |= backend->reserve ? 0 : RAM_NORESERVE;
ram_flags |= backend->guest_memfd ? RAM_GUEST_MEMFD : 0;
--
1.8.3.1
- [PATCH V7 00/24] Live update: cpr-transfer, Steve Sistare, 2025/01/15
- [PATCH V7 01/24] backends/hostmem-shm: factor out allocation of "anonymous shared memory with an fd", Steve Sistare, 2025/01/15
- [PATCH V7 08/24] physmem: preserve ram blocks for cpr, Steve Sistare, 2025/01/15
- [PATCH V7 03/24] physmem: qemu_ram_alloc_from_fd extensions, Steve Sistare, 2025/01/15
- [PATCH V7 04/24] physmem: fd-based shared memory, Steve Sistare, 2025/01/15
- [PATCH V7 02/24] physmem: fix qemu_ram_alloc_from_fd size calculation, Steve Sistare, 2025/01/15
- [PATCH V7 05/24] memory: add RAM_PRIVATE, Steve Sistare, 2025/01/15
- [PATCH V7 07/24] migration: cpr-state, Steve Sistare, 2025/01/15
- [PATCH V7 09/24] hostmem-memfd: preserve for cpr,
Steve Sistare <=
- [PATCH V7 06/24] machine: aux-ram-share option, Steve Sistare, 2025/01/15
- [PATCH V7 11/24] migration: enhance migrate_uri_parse, Steve Sistare, 2025/01/15
- [PATCH V7 12/24] migration: incoming channel, Steve Sistare, 2025/01/15
- [PATCH V7 14/24] migration: VMSTATE_FD, Steve Sistare, 2025/01/15
- [PATCH V7 13/24] migration: SCM_RIGHTS for QEMUFile, Steve Sistare, 2025/01/15
- [PATCH V7 17/24] migration-test: memory_backend, Steve Sistare, 2025/01/15
- [PATCH V7 15/24] migration: cpr-transfer save and load, Steve Sistare, 2025/01/15
- [PATCH V7 10/24] hostmem-shm: preserve for cpr, Steve Sistare, 2025/01/15
- [PATCH V7 16/24] migration: cpr-transfer mode, Steve Sistare, 2025/01/15
- [PATCH V7 22/24] tests/qtest: assert qmp connected, Steve Sistare, 2025/01/15