@@ -16,32 +16,34 @@
#include "qapi/error.h"
#include "sysemu/hostmem.h"
#include "hw/i386/hostmem-epc.h"
+#include "migration/cpr-state.h"
static void
sgx_epc_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
{
uint32_t ram_flags;
- char *name;
- int fd;
+ g_autofree char *name = object_get_canonical_path(OBJECT(backend));
+ int fd = cpr_find_fd(name, 0);
if (!backend->size) {
error_setg(errp, "can't create backend with size 0");
return;
}
- fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
if (fd < 0) {
- error_setg_errno(errp, errno,
- "failed to open /dev/sgx_vepc to alloc SGX EPC");
- return;
+ fd = qemu_open_old("/dev/sgx_vepc", O_RDWR);
+ if (fd < 0) {
+ error_setg_errno(errp, errno,
+ "failed to open /dev/sgx_vepc to alloc SGX EPC");
+ return;
+ }
+ cpr_save_fd(name, 0, fd);
}
- name = object_get_canonical_path(OBJECT(backend));
ram_flags = (backend->share ? RAM_SHARED : 0) | RAM_PROTECTED;
memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
name, backend->size, ram_flags,
fd, 0, errp);
- g_free(name);
}
static void sgx_epc_backend_instance_init(Object *obj)
Preserve memory-backend-epc memory objects during cpr. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- backends/hostmem-epc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)