[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V4 19/25] hostmem-memfd: cpr support
From: |
Steve Sistare |
Subject: |
[PATCH V4 19/25] hostmem-memfd: cpr support |
Date: |
Tue, 6 Jul 2021 09:45:50 -0700 |
Preserve memory-backend-memfd memory objects during cpr.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
backends/hostmem-memfd.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index 69b0ae3..3503c89 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -15,6 +15,7 @@
#include "sysemu/sysemu.h"
#include "qom/object_interfaces.h"
#include "qemu/memfd.h"
+#include "qemu/env.h"
#include "qemu/module.h"
#include "qapi/error.h"
#include "qom/object.h"
@@ -36,23 +37,25 @@ static void
memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
{
HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(backend);
- char *name;
- int fd;
+ char *name = host_memory_backend_get_name(backend);
+ int fd = getenv_fd(name);
if (!backend->size) {
error_setg(errp, "can't create backend with size 0");
return;
}
- 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,
- errp);
- if (fd == -1) {
- return;
+ if (fd < 0) {
+ 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,
+ errp);
+ if (fd == -1) {
+ return;
+ }
+ setenv_fd(name, fd);
}
- name = host_memory_backend_get_name(backend);
memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
name, backend->size,
backend->share, fd, 0, errp);
--
1.8.3.1
- [PATCH V4 07/25] machine: memfd-alloc option, (continued)
- [PATCH V4 07/25] machine: memfd-alloc option, Steve Sistare, 2021/07/06
- [PATCH V4 08/25] vl: add helper to request re-exec, Steve Sistare, 2021/07/06
- [PATCH V4 09/25] string to strList, Steve Sistare, 2021/07/06
- [PATCH V4 10/25] util: env var helpers, Steve Sistare, 2021/07/06
- [PATCH V4 12/25] cpr: QMP interfaces for restart, Steve Sistare, 2021/07/06
- [PATCH V4 11/25] cpr: restart mode, Steve Sistare, 2021/07/06
- [PATCH V4 13/25] cpr: HMP interfaces for restart, Steve Sistare, 2021/07/06
- [PATCH V4 14/25] pci: export functions for cpr, Steve Sistare, 2021/07/06
- [PATCH V4 15/25] vfio-pci: refactor for cpr, Steve Sistare, 2021/07/06
- [PATCH V4 17/25] vfio-pci: cpr part 2, Steve Sistare, 2021/07/06
- [PATCH V4 19/25] hostmem-memfd: cpr support,
Steve Sistare <=
- [PATCH V4 18/25] vhost: reset vhost devices upon cprsave, Steve Sistare, 2021/07/06
- [PATCH V4 21/25] chardev: cpr for simple devices, Steve Sistare, 2021/07/06
- [PATCH V4 20/25] chardev: cpr framework, Steve Sistare, 2021/07/06
- [PATCH V4 22/25] chardev: cpr for pty, Steve Sistare, 2021/07/06
- [PATCH V4 23/25] chardev: cpr for sockets, Steve Sistare, 2021/07/06
- [PATCH V4 25/25] simplify savevm, Steve Sistare, 2021/07/06
- [PATCH V4 24/25] cpr: only-cpr-capable option, Steve Sistare, 2021/07/06
- [PATCH V4 04/25] cpr: HMP interfaces for reboot, Steve Sistare, 2021/07/06
- [PATCH V4 16/25] vfio-pci: cpr part 1, Steve Sistare, 2021/07/06