tools/dm_restrict: Ask QEMU to chroot
authorGeorge Dunlap <george.dunlap@citrix.com>
Tue, 6 Nov 2018 15:41:23 +0000 (15:41 +0000)
committerGeorge Dunlap <george.dunlap@citrix.com>
Tue, 6 Nov 2018 15:41:23 +0000 (15:41 +0000)
commit7414750be1fed21687a0a28f67cc2397ebb0d0ba
tree038fa97b1a3ae26926b9952d4bacaa74a79b2a94
parent2c224f4c518113c6f38d583b5b3b1da0fc92d022
tools/dm_restrict: Ask QEMU to chroot

When dm_restrict is enabled, ask QEMU to chroot into an empty directory.

* Create $XEN_RUN_DIR/qemu-root-<domid> (deleting the old one if it's there)
* Pass the -chroot option to QEMU

Rather than running `rm -rf` on the directory before creating it
(since there is no library function to do this), simply rmdir the
directory, relying on the fact that the previous QEMU instance, if
properly restricted, shouldn't have been able to write anything
anyway.

Suggested-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
Changes since v4:
- Minor change to comment
- Update stale directory name in commit message

Changes since v2:
- Style fixes
- Testing moved to a different patch

CC: Ian Jackson <ian.jackson@citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Anthony Perard <anthony.perard@citrix.com>
docs/designs/qemu-deprivilege.md
tools/libxl/libxl_dm.c