libvirt's sVirt security driver provides SELinux MAC isolation for Qemu guest processes and their corresponding image files. In other words, sVirt uses SELinux to prevent a QEMU process from opening files that do not belong to it.
sVirt provides this support by labeling guests and resources with security labels that are stored in file system extended attributes. Some file systems, such as NFS, do not support the extended attribute security namespace, and therefore cannot support sVirt isolation. A solution to this problem is to provide fd passing support, where libvirt opens files and passes file descriptors to QEMU. This, along with SELinux policy to prevent QEMU from opening files, can provide image file isolation for NFS files. This patch series adds the getfd QMP monitor command, which allows an fd to be passed via SCM_RIGHTS, and returns the received file descriptor. Support is also added to the block layer to allow QEMU to dup() the fd when the filename is of the /dev/fd/X format. This is useful if MAC policy prevents QEMU from open()ing specific types of files. This solution will enable libvirt to open() an image file and push the file descriptor down to QEMU. When QEMU needs to "open" a file, it will first check if the filename is of the /dev/fd/X format and dup(X) if so. Otherwise it will continue and open() the file as it has in the past. This series reuses the file_open() function that Anthony Liguori <aligu...@us.ibm.com> created in a recent fd passing prototype. It also reuses the test driver that Stefan Hajnoczi <stefa...@linux.vnet.ibm.com> created for that prototype, but with several modifications. Corey Bryant (3): qmp/hmp: Add QMP getfd command that returns fd block: Add support to "open" /dev/fd/X filenames Sample server that opens image files for QEMU block.c | 15 +++ block/raw-posix.c | 20 ++-- block/raw-win32.c | 4 +- block/vdi.c | 5 +- block/vmdk.c | 21 ++-- block/vpc.c | 2 +- block/vvfat.c | 21 ++-- block_int.h | 13 +++ hmp-commands.hx | 2 +- monitor.c | 37 +++++- qapi-schema.json | 13 +++ qmp-commands.hx | 6 +- test-fd-passing.c | 321 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 439 insertions(+), 41 deletions(-) create mode 100644 test-fd-passing.c -- 1.7.10.2