[libvirt] [PATCH 17/35] qemu: Refactor qemuDomainGetInfo
Ján Tomko
jtomko at redhat.com
Wed Jun 3 13:31:32 UTC 2015
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150603/50492e54/attachment-0001.sig>
More information about the libvir-list
mailing list