mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
LXC: Check the existence of dir before resolving symlinks
If a dir does not exist, raise an immediate error in logs rather than letting virFileResolveAllLinks fail, since this gives better error reporting to the user. Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
parent
0e618c6aff
commit
9a08e2cbc6
@ -1696,6 +1696,7 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
|
|||||||
{
|
{
|
||||||
char *newroot;
|
char *newroot;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
char ebuf[1024];
|
||||||
|
|
||||||
VIR_DEBUG("Resolving symlinks");
|
VIR_DEBUG("Resolving symlinks");
|
||||||
|
|
||||||
@ -1703,6 +1704,13 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
|
|||||||
virDomainFSDefPtr fs = vmDef->fss[i];
|
virDomainFSDefPtr fs = vmDef->fss[i];
|
||||||
if (!fs->src)
|
if (!fs->src)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (access(fs->src, F_OK)) {
|
||||||
|
VIR_DEBUG("Failed to access '%s': %s", fs->src,
|
||||||
|
virStrerror(errno, ebuf, sizeof(ebuf)));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
VIR_DEBUG("Resolving '%s'", fs->src);
|
VIR_DEBUG("Resolving '%s'", fs->src);
|
||||||
if (virFileResolveAllLinks(fs->src, &newroot) < 0) {
|
if (virFileResolveAllLinks(fs->src, &newroot) < 0) {
|
||||||
VIR_DEBUG("Failed to resolve symlink at %s", fs->src);
|
VIR_DEBUG("Failed to resolve symlink at %s", fs->src);
|
||||||
|
Loading…
Reference in New Issue
Block a user