[libvirt] [PATCH] bhyve: report cpuTime in bhyveDomainGetInfo

Roman Bogorodskiy bogorodskiy at gmail.com
Sun May 4 13:45:15 UTC 2014


  Ján Tomko wrote:

> On 05/01/2014 02:11 PM, Roman Bogorodskiy wrote:
> > Add a helper function virBhyveGetDomainTotalCpuStats() to
> > obtain process CPU time using kvm (kernel memory interface)
> > and use it to set cpuTime field of the virDomainInfo struct in
> > bhyveDomainGetInfo().
> > ---
> >  configure.ac              |  7 +++++++
> >  src/bhyve/bhyve_driver.c  |  9 +++++++++
> >  src/bhyve/bhyve_process.c | 40 ++++++++++++++++++++++++++++++++++++++++
> >  src/bhyve/bhyve_process.h |  3 +++
> >  4 files changed, 59 insertions(+)
> > 
> 
> > --- a/src/bhyve/bhyve_driver.c
> > +++ b/src/bhyve/bhyve_driver.c
> > @@ -268,6 +268,15 @@ bhyveDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
> >      if (virDomainGetInfoEnsureACL(domain->conn, vm->def) < 0)
> >          goto cleanup;
> >  
> > +    if (virDomainObjIsActive(vm)) {
> > +        if (virBhyveGetDomainTotalCpuStats(vm, &(info->cpuTime)) < 0) {
> > +            virReportError(VIR_ERR_OPERATION_FAILED,
> > +                           "%s", _("Cannot read cputime for domain"));
> 
> This will overwrite the error set by virBhyveGetDomainTotalCpuStats.

Just to make sure: you mean I need to just drop virReportError here and
just rely on error reporting by virBhyveGetDomainTotalCpuStats()?

> > +            goto cleanup;
> > +        }
> > +    } else
> > +        info->cpuTime = 0;
> 
> This 'else' block should have braces, since the 'if' block has them.
> 
> > +
> >      info->state = virDomainObjGetState(vm, NULL);
> >      info->maxMem = vm->def->mem.max_balloon;
> >      info->nrVirtCpu = vm->def->vcpus;
> 
> ACK with that fixed.
> 
> Jan
> 
> 

Thanks,

Roman Bogorodskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140504/be8b5d9f/attachment-0001.sig>


More information about the libvir-list mailing list