提交 2e832b18 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 1a82e01c
...@@ -618,6 +618,8 @@ static int lxcContainerPrepareRoot(virDomainDefPtr def, ...@@ -618,6 +618,8 @@ static int lxcContainerPrepareRoot(virDomainDefPtr def,
char *dst; char *dst;
char *tmp; char *tmp;
VIR_DEBUG("Prepare root %d", root->type);
if (root->type == VIR_DOMAIN_FS_TYPE_MOUNT) if (root->type == VIR_DOMAIN_FS_TYPE_MOUNT)
return 0; return 0;
...@@ -1286,7 +1288,8 @@ static int lxcContainerMountFSBlockHelper(virDomainFSDefPtr fs, ...@@ -1286,7 +1288,8 @@ static int lxcContainerMountFSBlockHelper(virDomainFSDefPtr fs,
goto cleanup; goto cleanup;
if (format) { 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) { if (mount(src, fs->dst, format, fsflags, NULL) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Failed to mount device %s to %s as %s"), _("Failed to mount device %s to %s as %s"),
...@@ -1391,12 +1394,12 @@ static int lxcContainerMountFS(virDomainFSDefPtr fs, ...@@ -1391,12 +1394,12 @@ static int lxcContainerMountFS(virDomainFSDefPtr fs,
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected filesystem type %s"), _("Unexpected filesystem type %s"),
virDomainFSTypeToString(fs->type)); virDomainFSTypeToString(fs->type));
break; return -1;
default: default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Cannot mount filesystem type %s"), _("Cannot mount filesystem type %s"),
virDomainFSTypeToString(fs->type)); virDomainFSTypeToString(fs->type));
break; return -1;
} }
return 0; return 0;
} }
...@@ -1570,8 +1573,9 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef) ...@@ -1570,8 +1573,9 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
virDomainFSDefPtr fs = vmDef->fss[i]; virDomainFSDefPtr fs = vmDef->fss[i];
if (!fs->src) if (!fs->src)
continue; continue;
VIR_DEBUG("Resolving '%s'", fs->src);
if (virFileResolveAllLinks(fs->src, &newroot) < 0) { 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; return -1;
} }
...@@ -1580,6 +1584,7 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef) ...@@ -1580,6 +1584,7 @@ static int lxcContainerResolveSymlinks(virDomainDefPtr vmDef)
VIR_FREE(fs->src); VIR_FREE(fs->src);
fs->src = newroot; fs->src = newroot;
} }
VIR_DEBUG("Resolved all filesystem symlinks");
return 0; return 0;
} }
...@@ -1708,6 +1713,7 @@ static int lxcContainerChild(void *data) ...@@ -1708,6 +1713,7 @@ static int lxcContainerChild(void *data)
if (lxcContainerResolveSymlinks(vmDef) < 0) if (lxcContainerResolveSymlinks(vmDef) < 0)
goto cleanup; goto cleanup;
VIR_DEBUG("Setting up pivot");
if (lxcContainerSetupPivotRoot(vmDef, root, if (lxcContainerSetupPivotRoot(vmDef, root,
argv->ttyPaths, argv->nttyPaths, argv->ttyPaths, argv->nttyPaths,
argv->securityDriver) < 0) argv->securityDriver) < 0)
......
...@@ -453,6 +453,8 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) ...@@ -453,6 +453,8 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
size_t i; size_t i;
int ret = -1; int ret = -1;
VIR_DEBUG("Setting up loop devices for filesystems");
for (i = 0; i < ctrl->def->nfss; i++) { for (i = 0; i < ctrl->def->nfss; i++) {
virDomainFSDefPtr fs = ctrl->def->fss[i]; virDomainFSDefPtr fs = ctrl->def->fss[i];
int fd; int fd;
...@@ -486,9 +488,12 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) ...@@ -486,9 +488,12 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("fs driver %s is not supported"), _("fs driver %s is not supported"),
virDomainFSDriverTypeTypeToString(fs->fsdriver)); virDomainFSDriverTypeTypeToString(fs->fsdriver));
goto cleanup;
} }
} }
VIR_DEBUG("Setting up loop devices for disks");
for (i = 0; i < ctrl->def->ndisks; i++) { for (i = 0; i < ctrl->def->ndisks; i++) {
virDomainDiskDefPtr disk = ctrl->def->disks[i]; virDomainDiskDefPtr disk = ctrl->def->disks[i];
int fd; int fd;
...@@ -541,6 +546,7 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl) ...@@ -541,6 +546,7 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("disk driver %s is not supported"), _("disk driver %s is not supported"),
disk->driverName); disk->driverName);
goto cleanup;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册