|
|
43fe83 |
From 9b1952c45a8d014142c3c5d332a2a4c35da0cbd9 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <9b1952c45a8d014142c3c5d332a2a4c35da0cbd9.1381871412.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
|
|
|
43fe83 |
Date: Mon, 14 Oct 2013 16:45:25 +0100
|
|
|
43fe83 |
Subject: [PATCH] LXC: Check the existence of dir before resolving symlinks
|
|
|
43fe83 |
|
|
|
43fe83 |
For
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=927072
|
|
|
43fe83 |
|
|
|
43fe83 |
If a dir does not exist, raise an immediate error in logs
|
|
|
43fe83 |
rather than letting virFileResolveAllLinks fail, since this
|
|
|
43fe83 |
gives better error reporting to the user.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
|
|
|
43fe83 |
(cherry picked from commit 9a08e2cbc6933c068310c85354cff75e015f1de0)
|
|
|
43fe83 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
43fe83 |
---
|
|
|
43fe83 |
src/lxc/lxc_container.c | 8 ++++++++
|
|
|
43fe83 |
1 file changed, 8 insertions(+)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
|
|
|
43fe83 |
index 43178e2..f6375b7 100644
|
|
|
43fe83 |
--- a/src/lxc/lxc_container.c
|
|
|
43fe83 |
+++ b/src/lxc/lxc_container.c
|
|
|
43fe83 |
@@ -1668,6 +1668,7 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
|
|
|
43fe83 |
{
|
|
|
43fe83 |
char *newroot;
|
|
|
43fe83 |
size_t i;
|
|
|
43fe83 |
+ char ebuf[1024];
|
|
|
43fe83 |
|
|
|
43fe83 |
VIR_DEBUG("Resolving symlinks");
|
|
|
43fe83 |
|
|
|
43fe83 |
@@ -1675,6 +1676,13 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
|
|
|
43fe83 |
virDomainFSDefPtr fs = vmDef->fss[i];
|
|
|
43fe83 |
if (!fs->src)
|
|
|
43fe83 |
continue;
|
|
|
43fe83 |
+
|
|
|
43fe83 |
+ if (access(fs->src, F_OK)) {
|
|
|
43fe83 |
+ VIR_DEBUG("Failed to access '%s': %s", fs->src,
|
|
|
43fe83 |
+ virStrerror(errno, ebuf, sizeof(ebuf)));
|
|
|
43fe83 |
+ return -1;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
VIR_DEBUG("Resolving '%s'", fs->src);
|
|
|
43fe83 |
if (virFileResolveAllLinks(fs->src, &newroot) < 0) {
|
|
|
43fe83 |
VIR_DEBUG("Failed to resolve symlink at %s", fs->src);
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|