The guest may not have the balloon driver initialised or may have it disabled. Report an error to the user in such a case when a request for ballooning arrives.
This also solves another issue where a previous request for ballooning failed (e.g., for the reason mentioned above), but the config was still updated, resulting in the ballooning value being applied to the guest after the guest loads the balloon module. This may not be the desirable thing to do at this later stage. Signed-off-by: Amit Shah <amit.s...@redhat.com> --- hw/virtio-balloon.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index a8ecb51..d692813 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -184,6 +184,9 @@ static int virtio_balloon_to_target(void *opaque, ram_addr_t target) { VirtIOBalloon *dev = opaque; + if (!(dev->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) { + return -ENODEV; + } if (target > ram_size) { target = ram_size; } -- 1.7.7.3