libvirt/daemon
Eric Blake 462dc569de rpc: allow truncated return for virDomainGetCPUStats
The RPC code assumed that the array returned by the driver would be
fully populated; that is, ncpus on entry resulted in ncpus * return
value on exit.  However, while we don't support holes in the middle
of ncpus, we do want to permit the case of ncpus on entry being
longer than the array returned by the driver (that is, it should be
safe for the caller to pass ncpus=128 on entry, and the driver will
stop populating the array when it hits max_id).

Additionally, a successful return implies that the caller will then
use virTypedParamArrayClear on the entire array; for this to not
free uninitialized memory, the driver must ensure that all skipped
entries are explicitly zeroed (the RPC driver did this, but not
the qemu driver).

There are now three cases:
server 0.9.10 and client 0.9.10 or newer: No impact - there were no
hypervisor drivers that supported cpu stats

server 0.9.11 or newer and client 0.9.10: if the client calls with
ncpus beyond the max, then the rpc call will fail on the client side
and disconnect the client, but the server is no worse for the wear

server 0.9.11 or newer and client 0.9.11: the server can return a
truncated array and the client will do just fine

I reproduced the problem by using a host with 2 CPUs, and doing:
virsh cpu-stats $dom --start 1 --count 2

* daemon/remote.c (remoteDispatchDomainGetCPUStats): Allow driver
to omit tail of array.
* src/remote/remote_driver.c (remoteDomainGetCPUStats):
Accommodate driver that omits tail of array.
* src/libvirt.c (virDomainGetCPUStats): Document this.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Clear all
unpopulated entries.
2012-03-07 07:14:11 -07:00
..
libvirtd.aug Implement keepalive protocol in libvirt daemon 2011-11-24 11:44:08 +01:00
libvirtd.c build: use correct type for pid and similar types 2012-03-02 06:57:43 -07:00
libvirtd.conf maint: typo fixes 2011-12-01 16:08:34 -07:00
libvirtd.h API: make declaration of _LAST enum values conditional 2012-01-20 16:05:51 -07:00
libvirtd.init.in daemon: Remove deprecated HAL from init script dependencies 2012-03-02 16:32:37 +01:00
libvirtd.logrotate.in Add logrotate support for libvirtd.log 2011-03-04 22:43:55 +08:00
libvirtd.lxc.logrotate.in Change logrotate to be per-hypervisor logs 2010-03-10 11:27:02 +01:00
libvirtd.pod.in docs: removed outdated reference to virt-mem 2010-11-23 01:11:10 +11:00
libvirtd.policy-0 Allow polkit auth for VNC and SSH users 2012-02-07 11:59:35 -05:00
libvirtd.policy-1 Allow polkit auth for VNC and SSH users 2012-02-07 11:59:35 -05:00
libvirtd.qemu.logrotate.in Change logrotate to be per-hypervisor logs 2010-03-10 11:27:02 +01:00
libvirtd.sasl Rename qemud/ directory to daemon/ 2009-09-21 14:41:42 +01:00
libvirtd.service.in daemon: Allow overriding NOFILES ulimit for the daemon as well 2012-02-01 16:04:30 +01:00
libvirtd.sysconf daemon: Allow overriding NOFILES ulimit for the daemon as well 2012-02-01 16:04:30 +01:00
libvirtd.sysctl init: raise default system aio limits 2011-10-05 14:49:35 -06:00
libvirtd.uml.logrotate.in Change logrotate to be per-hypervisor logs 2010-03-10 11:27:02 +01:00
libvirtd.upstart daemon: Allow overriding NOFILES ulimit for the daemon as well 2012-02-01 16:04:30 +01:00
Makefile.am Workaround python header file insanity 2012-02-24 16:43:27 +00:00
remote.c rpc: allow truncated return for virDomainGetCPUStats 2012-03-07 07:14:11 -07:00
remote.h Remove unused virNetServerProgramErrorHander typedef 2011-07-13 11:47:01 +01:00
stream.c maint: fix improper use of 'an' 2011-12-03 17:11:56 -07:00
stream.h Ensure client streams are closed when marking a client for close 2011-08-16 14:38:11 -07:00
test_libvirtd.aug Allow certificate sanity checking to be disabled 2011-07-22 15:18:32 +01:00
THREADS.txt maint: use consistent file name for threading notes 2011-05-31 13:54:45 -06:00