}
-static int lxcContainerMountBasicFS(virDomainDefPtr def,
- bool pivotRoot,
- virSecurityManagerPtr securityDriver)
+static int lxcContainerMountBasicFS(bool pivotRoot,
+ char *sec_mount_options)
{
const struct {
const char *src;
* and don't want to DOS the entire OS RAM usage
*/
- char *mount_options = virSecurityManagerGetMountOptions(securityDriver, def);
ignore_value(virAsprintf(&opts,
- "mode=755,size=65536%s",(mount_options ? mount_options : "")));
- VIR_FREE(mount_options);
+ "mode=755,size=65536%s",(sec_mount_options ? sec_mount_options : "")));
if (!opts) {
virReportOOMError();
goto cleanup;
}
-static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs)
+static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs,
+ char *sec_mount_options)
{
int ret = -1;
char *data = NULL;
- if (virAsprintf(&data, "size=%lldk", fs->usage) < 0) {
+ if (virAsprintf(&data,
+ "size=%lldk%s", fs->usage, (sec_mount_options ? sec_mount_options : "")) < 0) {
virReportOOMError();
goto cleanup;
}
static int lxcContainerMountFS(virDomainFSDefPtr fs,
- const char *srcprefix)
+ const char *srcprefix,
+ char *sec_mount_options)
{
switch (fs->type) {
case VIR_DOMAIN_FS_TYPE_MOUNT:
return -1;
break;
case VIR_DOMAIN_FS_TYPE_RAM:
- if (lxcContainerMountFSTmpfs(fs) < 0)
+ if (lxcContainerMountFSTmpfs(fs, sec_mount_options) < 0)
return -1;
break;
case VIR_DOMAIN_FS_TYPE_BIND:
static int lxcContainerMountAllFS(virDomainDefPtr vmDef,
const char *dstprefix,
- bool skipRoot)
+ bool skipRoot,
+ char *sec_mount_options)
{
size_t i;
VIR_DEBUG("Mounting %s %d", dstprefix, skipRoot);
STREQ(vmDef->fss[i]->dst, "/"))
continue;
- if (lxcContainerMountFS(vmDef->fss[i], dstprefix) < 0)
+ if (lxcContainerMountFS(vmDef->fss[i], dstprefix, sec_mount_options) < 0)
return -1;
}
virDomainFSDefPtr root,
char **ttyPaths,
size_t nttyPaths,
- virSecurityManagerPtr securityDriver)
+ char *sec_mount_options)
{
struct lxcContainerCGroup *mounts = NULL;
size_t nmounts = 0;
goto cleanup;
/* Mounts the core /proc, /sys, etc filesystems */
- if (lxcContainerMountBasicFS(vmDef, true, securityDriver) < 0)
+ if (lxcContainerMountBasicFS(true, sec_mount_options) < 0)
goto cleanup;
/* Now we can re-mount the cgroups controllers in the
goto cleanup;
/* Sets up any non-root mounts from guest config */
- if (lxcContainerMountAllFS(vmDef, "/.oldroot", true) < 0)
+ if (lxcContainerMountAllFS(vmDef, "/.oldroot", true, sec_mount_options) < 0)
goto cleanup;
/* Gets rid of all remaining mounts from host OS, including /.oldroot itself */
but with extra stuff mapped in */
static int lxcContainerSetupExtraMounts(virDomainDefPtr vmDef,
virDomainFSDefPtr root,
- virSecurityManagerPtr securityDriver)
+ char *sec_mount_options)
{
int ret = -1;
struct lxcContainerCGroup *mounts = NULL;
}
VIR_DEBUG("Mounting config FS");
- if (lxcContainerMountAllFS(vmDef, "", false) < 0)
+ if (lxcContainerMountAllFS(vmDef, "", false, sec_mount_options) < 0)
return -1;
/* Before replacing /sys we need to identify any
goto cleanup;
/* Mounts the core /proc, /sys, etc filesystems */
- if (lxcContainerMountBasicFS(vmDef, false, securityDriver) < 0)
+ if (lxcContainerMountBasicFS(false, sec_mount_options) < 0)
goto cleanup;
/* Now we can re-mount the cgroups controllers in the
size_t nttyPaths,
virSecurityManagerPtr securityDriver)
{
+ int rc = -1;
+ char *sec_mount_options = NULL;
if (lxcContainerResolveSymlinks(vmDef) < 0)
return -1;
+ sec_mount_options = virSecurityManagerGetMountOptions(securityDriver, vmDef);
if (root && root->src)
- return lxcContainerSetupPivotRoot(vmDef, root, ttyPaths, nttyPaths, securityDriver);
+ rc = lxcContainerSetupPivotRoot(vmDef, root, ttyPaths, nttyPaths, sec_mount_options);
else
- return lxcContainerSetupExtraMounts(vmDef, root, securityDriver);
+ rc = lxcContainerSetupExtraMounts(vmDef, root, sec_mount_options);
+
+ VIR_FREE(sec_mount_options);
+ return rc;
}