From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbXtK-0006DK-QD for qemu-devel@nongnu.org; Mon, 04 Jun 2012 10:04:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SbXtE-0004Sv-Ky for qemu-devel@nongnu.org; Mon, 04 Jun 2012 10:04:18 -0400 Received: from cpe-174-097-227-101.nc.res.rr.com ([174.97.227.101]:35257 helo=localhost.localdomain) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SbXtD-0004ST-MN for qemu-devel@nongnu.org; Mon, 04 Jun 2012 10:04:12 -0400 From: Corey Bryant Date: Mon, 4 Jun 2012 09:10:07 -0400 Message-Id: <1338815410-24890-1-git-send-email-coreyb@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 0/3] file descriptor passing using getfd over QMP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, aliguori@us.ibm.com, Corey Bryant , eblake@redhat.com, stefanha@linux.vnet.ibm.com 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 created in a recent fd passing prototype. It also reuses the test driver that Stefan Hajnoczi 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