From 2e832b18d67591a6107757d1fd48fdd21e6d60cb Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 9 Jul 2013 14:24:10 +0100 Subject: [PATCH] LXC: Fix some error reporting in filesystem setup 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 --- src/lxc/lxc_container.c | 14 ++++++++++---- src/lxc/lxc_controller.c | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 004a6ff839..48a8f36e43 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -618,6 +618,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; @@ -1286,7 +1288,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"), @@ -1391,12 +1394,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; } @@ -1570,8 +1573,9 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef) virDomainFSDefPtr fs = vmDef->fss[i]; if (!fs->src) continue; + VIR_DEBUG("Resolving '%s'", fs->src); if (virFileResolveAllLinks(fs->src, &newroot) < 0) { - VIR_DEBUG("Fail to resolve link %s", fs->src); + VIR_DEBUG("Failed to resolve symlink at %s", fs->src); return -1; } @@ -1580,6 +1584,7 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef) VIR_FREE(fs->src); fs->src = newroot; } + VIR_DEBUG("Resolved all filesystem symlinks"); return 0; } @@ -1708,6 +1713,7 @@ static int lxcContainerChild(void *data) 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 9bb8331053..1d91422ce4 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -453,6 +453,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; @@ -486,9 +488,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; @@ -541,6 +546,7 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("disk driver %s is not supported"), disk->driverName); + goto cleanup; } } -- GitLab