memimport: Support memfd blocks

To transfer memfd-backed blocks without passing their fd every time,
thus minimizing overhead and avoiding fd leaks, a command is sent
with the memfd fd as ancil data very early on.

This command has an ID that uniquely identifies the memfd region.
Further memfd block references are then exclusively done using this
ID.

This commit implements the details of such 'permanent' mappings on
the receiving end, using memimport segments.

Suggested-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>
This commit is contained in:
Ahmed S. Darwish 2016-03-13 01:07:27 +02:00 committed by David Henningsson
parent 73e86b1cb1
commit f8714af56b
6 changed files with 113 additions and 23 deletions

View file

@ -417,15 +417,10 @@ fail:
}
/* Caller owns passed @memfd_fd and must close it down when appropriate. */
static int NEW_API_pa_shm_attach(pa_shm *m, pa_mem_type_t type, unsigned id, int memfd_fd, bool writable) {
int pa_shm_attach(pa_shm *m, pa_mem_type_t type, unsigned id, int memfd_fd, bool writable) {
return shm_attach(m, type, id, memfd_fd, writable, false);
}
/* Compatibility version until the new API is used in external sources */
int pa_shm_attach(pa_shm *m, unsigned id, bool writable) {
return NEW_API_pa_shm_attach(m, PA_MEM_TYPE_SHARED_POSIX, id, -1, writable);
}
int pa_shm_cleanup(void) {
#ifdef HAVE_SHM_OPEN