From afa0f6c1c65a74563447607f0cd29db0e2992799 Mon Sep 17 00:00:00 2001 From: Prasad Joshi Date: Tue, 26 Apr 2011 11:59:18 +0100 Subject: [PATCH] kvm tools: check read permission before using the root partition of the host to boot VM The commit fbe8d0f (kvm tools: Use the root partition of the host to boot the guest machine) changed the default image for virtual machine to root partition of the host machine. The patch adds a check to ensure appropriate permission (a read permission) is available for kvm tool to use this partition. Signed-off-by: Prasad Joshi Signed-off-by: Pekka Enberg --- kvm-run.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kvm-run.c b/kvm-run.c index 13e7662..bb2b301 100644 --- a/kvm-run.c +++ b/kvm-run.c @@ -264,6 +264,10 @@ static int root_device(char *dev, long *part) /* verify the device path */ if (stat(dev, &st) < 0) return -1; + + if (access(dev, R_OK) < 0) + return -1; + return 0; }