From: "Daniel P. Berrange" <berrange(a)redhat.com>
A couple of places in LXC setup for filesystems did not do
a "goto cleanup" after reporting errors. While fixing this,
also add in many more debug statements to aid troubleshooting
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_container.c | 23 ++++++++++++++++++-----
src/lxc/lxc_controller.c | 6 ++++++
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 595c0f2..389c336 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -551,6 +551,8 @@ static int lxcContainerPrepareRoot(virDomainDefPtr def,
char *dst;
char *tmp;
+ VIR_DEBUG("Prepare root %d", root->type);
+
if (root->type == VIR_DOMAIN_FS_TYPE_MOUNT)
return 0;
@@ -1230,7 +1232,8 @@ static int lxcContainerMountFSBlockHelper(virDomainFSDefPtr fs,
goto cleanup;
if (format) {
- VIR_DEBUG("Mount %s with detected format %s", src, format);
+ VIR_DEBUG("Mount '%s' on '%s' with detected format
'%s'",
+ src, fs->dst, format);
if (mount(src, fs->dst, format, fsflags, NULL) < 0) {
virReportSystemError(errno,
_("Failed to mount device %s to %s as %s"),
@@ -1339,12 +1342,12 @@ static int lxcContainerMountFS(virDomainFSDefPtr fs,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected filesystem type %s"),
virDomainFSTypeToString(fs->type));
- break;
+ return -1;
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Cannot mount filesystem type %s"),
virDomainFSTypeToString(fs->type));
- break;
+ return -1;
}
return 0;
}
@@ -1885,18 +1888,26 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
char *newroot;
size_t i;
+ VIR_DEBUG("Resolving filesystem symlinks");
for (i = 0; i < vmDef->nfss; i++) {
+ VIR_DEBUG("Res %zu", i);
virDomainFSDefPtr fs = vmDef->fss[i];
- if (!fs->src)
+ if (!fs->src) {
+ VIR_DEBUG("Skip");
continue;
- if (virFileResolveAllLinks(fs->src, &newroot) < 0)
+ }
+ VIR_DEBUG("Resolving '%s'", fs->src);
+ if (virFileResolveAllLinks(fs->src, &newroot) < 0) {
+ VIR_DEBUG("Failed to resolve symlink at %s", fs->src);
return -1;
+ }
VIR_DEBUG("Resolved '%s' to %s", fs->src, newroot);
VIR_FREE(fs->src);
fs->src = newroot;
}
+ VIR_DEBUG("Resolved all filesystem symlinks");
return 0;
}
@@ -2020,9 +2031,11 @@ static int lxcContainerChild(void *data)
goto cleanup;
}
+ VIR_DEBUG("Resolve t");
if (lxcContainerResolveSymlinks(vmDef) < 0)
goto cleanup;
+ VIR_DEBUG("Setting up pivot");
if (lxcContainerSetupPivotRoot(vmDef, root,
argv->ttyPaths, argv->nttyPaths,
argv->securityDriver) < 0)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index ef35c05..831dff8 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -450,6 +450,8 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
size_t i;
int ret = -1;
+ VIR_DEBUG("Setting up loop devices for filesystems");
+
for (i = 0; i < ctrl->def->nfss; i++) {
virDomainFSDefPtr fs = ctrl->def->fss[i];
int fd;
@@ -492,9 +494,12 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr
ctrl)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("fs driver %s is not supported"),
virDomainFSDriverTypeTypeToString(fs->fsdriver));
+ goto cleanup;
}
}
+ VIR_DEBUG("Setting up loop devices for disks");
+
for (i = 0; i < ctrl->def->ndisks; i++) {
virDomainDiskDefPtr disk = ctrl->def->disks[i];
int fd;
@@ -548,6 +553,7 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk driver %s is not supported"),
disk->driverName);
+ goto cleanup;
}
}
--
1.8.3.1