Re: [libvirt] [PATCH] cpu usage in OpenVZ

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

 



On Thu, Jul 17, 2008 at 03:04:46PM +0400, Evgeniy Sokolov wrote:
> OpenVZ calculate statistics and allow to get them .
> Added function for getting cpu usage of container.

Modular some minor comments,  ACK for this patch.

> +    if (!openvzIsActiveVM(vm)) {
> +        info->cpuTime = 0;
> +    } else {
> +        if (openvzGetProcessInfo(&(info->cpuTime), dom->id) < 0) {
> +            openvzError(dom->conn, VIR_ERR_OPERATION_FAILED, ("cannot read cputime for domain"));

Need to have a leading '_'  in front of the string to be mark
for translation.

> +            return -1;
> +        }
> +    }
> +
>      /* TODO These need to be calculated differently for OpenVZ */
>      //info->cpuTime =
>      //info->maxMem = vm->def->maxmem;
> @@ -689,6 +700,48 @@ static int openvzListDefinedDomains(virC
>      return got;
>  }
>  
> +static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid) {
> +    int fd;
> +    char line[PATH_MAX] ;

Best to use something else as the size here - we're not reading
a path & we should try to eliminate uses of PATH_MAX in libvirt,
since  POSIX allows for it to be undefine, or stupidly huge. I
reckon 1024 would do the job for line length in this case.

> +    if (readvps != vpsid) /*not found*/
> +        return -1;
> +
> +    /* convert jiffies to nanoseconds */
> +    *cpuTime = 1000ull * 1000ull * 1000ull * (usertime + nicetime  + systime) / (unsigned long long)sysconf(_SC_CLK_TCK);

Can we break this expression across multiple lines to avoid going
soo far over 80 chars.

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]