提交 c0d8c7c8 编写于 作者: G Gao feng 提交者: Daniel P. Berrange

LXC: hostdev: introduce lxcContainerSetupHostdevCapsMakePath

This helper function is used to create parent directory for
the hostdev which will be added to the container. If the
parent directory of this hostdev doesn't exist, the mknod of
the hostdev will fail. eg with /dev/net/tun
Signed-off-by: NGao feng <gaofeng@cn.fujitsu.com>
上级 9a0ac6d9
...@@ -1544,6 +1544,32 @@ cleanup: ...@@ -1544,6 +1544,32 @@ cleanup:
} }
int lxcContainerSetupHostdevCapsMakePath(const char *dev)
{
int ret = -1;
char *dir, *tmp;
if (VIR_STRDUP(dir, dev) < 0)
return -1;
if ((tmp = strrchr(dir, '/'))) {
*tmp = '\0';
if (virFileMakePath(dir) < 0) {
virReportSystemError(errno,
_("Failed to create directory for '%s' dev '%s'"),
dir, dev);
goto cleanup;
}
}
ret = 0;
cleanup:
VIR_FREE(dir);
return ret;
}
static int lxcContainerSetupHostdevCapsStorage(virDomainDefPtr vmDef ATTRIBUTE_UNUSED, static int lxcContainerSetupHostdevCapsStorage(virDomainDefPtr vmDef ATTRIBUTE_UNUSED,
virDomainHostdevDefPtr def ATTRIBUTE_UNUSED, virDomainHostdevDefPtr def ATTRIBUTE_UNUSED,
virSecurityManagerPtr securityDriver ATTRIBUTE_UNUSED) virSecurityManagerPtr securityDriver ATTRIBUTE_UNUSED)
......
...@@ -63,6 +63,8 @@ int lxcContainerStart(virDomainDefPtr def, ...@@ -63,6 +63,8 @@ int lxcContainerStart(virDomainDefPtr def,
int lxcContainerAvailable(int features); int lxcContainerAvailable(int features);
int lxcContainerSetupHostdevCapsMakePath(const char *dev);
virArch lxcContainerGetAlt32bitArch(virArch arch); virArch lxcContainerGetAlt32bitArch(virArch arch);
#endif /* LXC_CONTAINER_H */ #endif /* LXC_CONTAINER_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册