mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-26 15:14:42 +00:00
qemu_driver: add virCgroupMounted
When we mount any cgroup without "-o devices", we will fail to start vms: error: Failed to start domain vm1 error: Unable to deny all devices for vm1: No such file or directory When we mount any cgroup without "-o cpu", we will fail to get schedinfo: Scheduler : posix error: unable to get cpu shares tunable: No such file or directory We should only use the cgroup controllers which are mounted on host. So I add virCgroupMounted() for qemuCgroupControllerActive() Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
This commit is contained in:
parent
4c2b3e1d29
commit
41b2cee2a8
@ -72,6 +72,7 @@ virCgroupGetMemoryHardLimit;
|
|||||||
virCgroupGetMemorySoftLimit;
|
virCgroupGetMemorySoftLimit;
|
||||||
virCgroupGetMemoryUsage;
|
virCgroupGetMemoryUsage;
|
||||||
virCgroupGetSwapHardLimit;
|
virCgroupGetSwapHardLimit;
|
||||||
|
virCgroupMounted;
|
||||||
virCgroupRemove;
|
virCgroupRemove;
|
||||||
virCgroupSetCpuShares;
|
virCgroupSetCpuShares;
|
||||||
virCgroupSetFreezerState;
|
virCgroupSetFreezerState;
|
||||||
|
@ -730,6 +730,8 @@ static int qemuCgroupControllerActive(struct qemud_driver *driver,
|
|||||||
{
|
{
|
||||||
if (driver->cgroup == NULL)
|
if (driver->cgroup == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
if (!virCgroupMounted(driver->cgroup, controller))
|
||||||
|
return 0;
|
||||||
if (driver->cgroupControllers & (1 << controller))
|
if (driver->cgroupControllers & (1 << controller))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -71,6 +71,19 @@ void virCgroupFree(virCgroupPtr *group)
|
|||||||
VIR_FREE(*group);
|
VIR_FREE(*group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virCgroupMounted: query whether a cgroup subsystem is mounted or not
|
||||||
|
*
|
||||||
|
* @cgroup: The group structure to be queried
|
||||||
|
* @controller: cgroup subsystem id
|
||||||
|
*
|
||||||
|
* Returns true if a cgroup is subsystem is mounted.
|
||||||
|
*/
|
||||||
|
bool virCgroupMounted(virCgroupPtr cgroup, int controller)
|
||||||
|
{
|
||||||
|
return cgroup->controllers[controller].mountPoint != NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
|
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
|
||||||
/*
|
/*
|
||||||
* Process /proc/mounts figuring out what controllers are
|
* Process /proc/mounts figuring out what controllers are
|
||||||
|
@ -83,5 +83,6 @@ int virCgroupGetFreezerState(virCgroupPtr group, char **state);
|
|||||||
int virCgroupRemove(virCgroupPtr group);
|
int virCgroupRemove(virCgroupPtr group);
|
||||||
|
|
||||||
void virCgroupFree(virCgroupPtr *group);
|
void virCgroupFree(virCgroupPtr *group);
|
||||||
|
bool virCgroupMounted(virCgroupPtr cgroup, int controller);
|
||||||
|
|
||||||
#endif /* CGROUP_H */
|
#endif /* CGROUP_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user