[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V6 10/24] hostmem-shm: preserve for cpr
From: |
Steve Sistare |
Subject: |
[PATCH V6 10/24] hostmem-shm: preserve for cpr |
Date: |
Tue, 14 Jan 2025 09:23:40 -0800 |
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>
---
backends/hostmem-shm.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/backends/hostmem-shm.c b/backends/hostmem-shm.c
index fabee41..f67ad27 100644
--- a/backends/hostmem-shm.c
+++ b/backends/hostmem-shm.c
@@ -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;
--
1.8.3.1
- [PATCH V6 01/24] backends/hostmem-shm: factor out allocation of "anonymous shared memory with an fd", (continued)
- [PATCH V6 01/24] backends/hostmem-shm: factor out allocation of "anonymous shared memory with an fd", Steve Sistare, 2025/01/14
- [PATCH V6 05/24] memory: add RAM_PRIVATE, Steve Sistare, 2025/01/14
- [PATCH V6 03/24] physmem: qemu_ram_alloc_from_fd extensions, Steve Sistare, 2025/01/14
- [PATCH V6 02/24] physmem: fix qemu_ram_alloc_from_fd size calculation, Steve Sistare, 2025/01/14
- [PATCH V6 04/24] physmem: fd-based shared memory, Steve Sistare, 2025/01/14
- [PATCH V6 07/24] migration: cpr-state, Steve Sistare, 2025/01/14
- [PATCH V6 06/24] machine: aux-ram-share option, Steve Sistare, 2025/01/14
- [PATCH V6 09/24] hostmem-memfd: preserve for cpr, Steve Sistare, 2025/01/14
- [PATCH V6 08/24] physmem: preserve ram blocks for cpr, Steve Sistare, 2025/01/14
- [PATCH V6 10/24] hostmem-shm: preserve for cpr,
Steve Sistare <=
- [PATCH V6 18/24] tests/qtest: optimize migrate_set_ports, Steve Sistare, 2025/01/14
- [PATCH V6 12/24] migration: incoming channel, Steve Sistare, 2025/01/14
- [PATCH V6 20/24] migration-test: defer connection, Steve Sistare, 2025/01/14
- [PATCH V6 24/24] migration: cpr-transfer documentation, Steve Sistare, 2025/01/14
- [PATCH V6 11/24] migration: enhance migrate_uri_parse, Steve Sistare, 2025/01/14
- [PATCH V6 22/24] tests/qtest: assert qmp connected, Steve Sistare, 2025/01/14
- [PATCH V6 16/24] migration: cpr-transfer mode, Steve Sistare, 2025/01/14
- [PATCH V6 13/24] migration: SCM_RIGHTS for QEMUFile, Steve Sistare, 2025/01/14
- [PATCH V6 17/24] migration-test: memory_backend, Steve Sistare, 2025/01/14