Re: [PATCH 17/35] qemu: Refactor qemuDomainGetInfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]