
On Fri, May 29, 2015 at 03:33:38PM +0200, Peter Krempa wrote:
Since the returned structure uses "unsigned long" for memory sizes add a few overflow checks to notify the user in case we are not able to represent given values. --- src/qemu/qemu_driver.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-)
@@ -2625,30 +2628,34 @@ static int qemuDomainGetInfo(virDomainPtr dom, - info->maxMem = virDomainDefGetMemoryActual(vm->def); - if (virDomainObjIsActive(vm)) { - if (qemuDomainUpdateCurrentMemorySize(driver, vm) < 0) + if (VIR_ASSIGN_IS_OVERFLOW(info->memory, vm->def->mem.cur_balloon)) { + virReportError(VIR_ERR_OVERFLOW, "%s", + _("Current memory size too large")); goto cleanup; + }
- info->memory = vm->def->mem.cur_balloon; - } else { - info->memory = 0; + if (qemuGetProcessInfo(&(info->cpuTime), NULL, NULL, vm->pid, 0) < 0) { + virReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("cannot read cputime for domain")); + goto cleanup; + } }
- info->nrVirtCpu = vm->def->vcpus;
This line should stay. ACK with that change. Jan
ret = 0;
cleanup: