virtio-balloon: use actual number of stats for stats queue buffers
authorLadi Prosek <lprosek@redhat.com>
Tue, 28 Mar 2017 16:46:58 +0000 (18:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Dec 2017 13:23:42 +0000 (14:23 +0100)
commitc6f9090929dca3fd1208e636f60860f4a7e421a2
tree9d718f26ce35052878a0423bb5ed6cc3fb24b1a4
parent808ed3bd9d42823e00ab2d3dc4c9899437fa3c8a
virtio-balloon: use actual number of stats for stats queue buffers

[ Upstream commit 9646b26e85896ef0256e66649f7937f774dc18a6 ]

The virtio balloon driver contained a not-so-obvious invariant that
update_balloon_stats has to update exactly VIRTIO_BALLOON_S_NR counters
in order to send valid stats to the host. This commit fixes it by having
update_balloon_stats return the actual number of counters, and its
callers use it when pushing buffers to the stats virtqueue.

Note that it is still out of spec to change the number of counters
at run-time. "Driver MUST supply the same subset of statistics in all
buffers submitted to the statsq."

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/virtio/virtio_balloon.c