mirror of https://gitee.com/openkylin/libvirt.git
qemu: update qemuCgroupControllerActive signature
Clang warned about a dead assignment. In the process, I noticed that we are only using the function for a bool value. I audited all other callers in qemu_{migration,cgroup,driver,hotplug), and all were making the call in a bool context. Also, do bounds checking on the argument. * src/qemu/qemu_cgroup.c (qemuSetupCgroup): Delete dead assignment. (qemuCgroupControllerActive): Change return type to bool. * src/qemu/qemu_cgroup.h (qemuCgroupControllerActive): Likewise.
This commit is contained in:
parent
44aa49aefe
commit
29e131dec2
|
@ -43,16 +43,18 @@ static const char *const defaultDeviceACL[] = {
|
||||||
#define DEVICE_PTY_MAJOR 136
|
#define DEVICE_PTY_MAJOR 136
|
||||||
#define DEVICE_SND_MAJOR 116
|
#define DEVICE_SND_MAJOR 116
|
||||||
|
|
||||||
int qemuCgroupControllerActive(struct qemud_driver *driver,
|
bool qemuCgroupControllerActive(struct qemud_driver *driver,
|
||||||
int controller)
|
int controller)
|
||||||
{
|
{
|
||||||
if (driver->cgroup == NULL)
|
if (driver->cgroup == NULL)
|
||||||
return 0;
|
return false;
|
||||||
if (!virCgroupMounted(driver->cgroup, controller))
|
if (!virCgroupMounted(driver->cgroup, controller))
|
||||||
return 0;
|
return false;
|
||||||
|
if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST)
|
||||||
|
return false;
|
||||||
if (driver->cgroupControllers & (1 << controller))
|
if (driver->cgroupControllers & (1 << controller))
|
||||||
return 1;
|
return true;
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -312,7 +314,7 @@ int qemuSetupCgroup(struct qemud_driver *driver,
|
||||||
if (vm->def->mem.hard_limit != 0 ||
|
if (vm->def->mem.hard_limit != 0 ||
|
||||||
vm->def->mem.soft_limit != 0 ||
|
vm->def->mem.soft_limit != 0 ||
|
||||||
vm->def->mem.swap_hard_limit != 0) {
|
vm->def->mem.swap_hard_limit != 0) {
|
||||||
if ((rc = qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_MEMORY))) {
|
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_MEMORY)) {
|
||||||
if (vm->def->mem.hard_limit != 0) {
|
if (vm->def->mem.hard_limit != 0) {
|
||||||
rc = virCgroupSetMemoryHardLimit(cgroup, vm->def->mem.hard_limit);
|
rc = virCgroupSetMemoryHardLimit(cgroup, vm->def->mem.hard_limit);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
|
|
|
@ -34,8 +34,8 @@ struct _qemuCgroupData {
|
||||||
};
|
};
|
||||||
typedef struct _qemuCgroupData qemuCgroupData;
|
typedef struct _qemuCgroupData qemuCgroupData;
|
||||||
|
|
||||||
int qemuCgroupControllerActive(struct qemud_driver *driver,
|
bool qemuCgroupControllerActive(struct qemud_driver *driver,
|
||||||
int controller);
|
int controller);
|
||||||
int qemuSetupDiskCgroup(struct qemud_driver *driver,
|
int qemuSetupDiskCgroup(struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virCgroupPtr cgroup,
|
virCgroupPtr cgroup,
|
||||||
|
|
Loading…
Reference in New Issue