mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
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: Gao feng <gaofeng@cn.fujitsu.com>
(cherry picked from commit c0d8c7c885
)
Adapted to lack of VIR_STRDUP
This commit is contained in:
parent
419ea63029
commit
3bdb7f883e
@ -1557,6 +1557,32 @@ cleanup:
|
||||
}
|
||||
|
||||
|
||||
int lxcContainerSetupHostdevCapsMakePath(const char *dev)
|
||||
{
|
||||
int ret = -1;
|
||||
char *dir, *tmp;
|
||||
|
||||
if (!(dir = strdup(dev)))
|
||||
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,
|
||||
virDomainHostdevDefPtr def ATTRIBUTE_UNUSED,
|
||||
const char *dstprefix ATTRIBUTE_UNUSED,
|
||||
|
@ -63,6 +63,8 @@ int lxcContainerStart(virDomainDefPtr def,
|
||||
|
||||
int lxcContainerAvailable(int features);
|
||||
|
||||
int lxcContainerSetupHostdevCapsMakePath(const char *dev);
|
||||
|
||||
virArch lxcContainerGetAlt32bitArch(virArch arch);
|
||||
|
||||
#endif /* LXC_CONTAINER_H */
|
||||
|
Loading…
Reference in New Issue
Block a user