[libvirt] [PATCH] bhyve: implement domainGetCPUStats

Ján Tomko jtomko at redhat.com
Wed Apr 30 12:51:18 UTC 2014


On 04/30/2014 12:03 PM, Daniel P. Berrange wrote:
> On Tue, Apr 29, 2014 at 08:54:26PM +0400, Roman Bogorodskiy wrote:
>>
>> Looks like FreeBSD does not support such kind of per-cpu reporting for
>> host cpus. Just to make sure I didn't miss something, I asked that
>> question of the FreeBSD virtualization maillist and looks like I'm right
>> about that [1].
>>
>> Would it better to abandon this feature for now and wait when it'd be
>> supported (I'm not sure if/when it's going to happen), or just leave the
>> code that reports only the stats for all cpus?
> 
> I think it is better to leave it unsupported, so apps can see the
> VIR_ERR_NO_SUPPORT error and not mistakenly interpret incorrect data.
> 

The apps should check how many stat parameters are supported for a given pCPU
by calling virDomainGetCPUStats with nparams=0 and/or check the actual number
of stats returned.

Could we return valid results for total CPU stats (start_cpu = -1) and just
not return any for all other start_cpu values?

From the API documentation [1]:

 * Typical use sequence is below.
 *
 * getting total stats: set start_cpu as -1, ncpus 1
 * virDomainGetCPUStats(dom, NULL, 0, -1, 1, 0) => nparams
 * params = calloc(nparams, sizeof(virTypedParameter))
 * virDomainGetCPUStats(dom, params, nparams, -1, 1, 0) => total stats.
 *
 * getting per-cpu stats:
 * virDomainGetCPUStats(dom, NULL, 0, 0, 0, 0) => ncpus
 * virDomainGetCPUStats(dom, NULL, 0, 0, 1, 0) => nparams
 * params = calloc(ncpus * nparams, sizeof(virTypedParameter))
 * virDomainGetCPUStats(dom, params, nparams, 0, ncpus, 0) => per-cpu stats

Jan

[1] http://libvirt.org/html/libvirt-libvirt.html#virDomainGetCPUStats

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140430/fbbcfc05/attachment-0001.sig>


More information about the libvir-list mailing list