[Devel] [PATCH RHEL10 COMMIT] virtio_balloon: quiesce balloon work before device shutdown

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 29 21:15:19 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-211.16.1.12.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.16.1.12.7.vz10
------>
commit 56aa7617fd1f7fb53c49552ea5a1414d3bb9a2a7
Author: Denis V. Lunev <den at openvz.org>
Date:   Mon Jun 29 14:34:55 2026 +0200

    virtio_balloon: quiesce balloon work before device shutdown
    
    Commit 8bd2fa086a04 ("virtio: break and reset virtio devices on
    device_shutdown()") added a generic virtio bus .shutdown handler that
    breaks and resets every virtio device during device_shutdown(), i.e. on
    reboot and kexec.
    
    virtio_balloon provides no .shutdown of its own, so that generic path
    runs while the balloon's asynchronous work is still armed. Once the
    device has been broken, virtqueue_add_inbuf() in
    virtballoon_free_page_report() returns -EIO and trips its
    WARN_ON_ONCE(). On a kernel booted with panic_on_warn that turns an
    ordinary reboot, for example a kexec based upgrade, into a fatal panic
    in the middle of device_shutdown(), so the machine never reaches the
    new kernel.
    
    Relaxing that single WARN_ON_ONCE() would only hide the symptom: the
    inflate/deflate and OOM paths do not warn, they call
    wait_event(vb->acked, ...) and would instead block forever on a broken
    queue that can no longer complete. The device has to be quiesced, not
    just kept quiet.
    
    Add a .shutdown handler that quiesces the balloon via the shared
    virtballoon_quiesce() helper while the device is still alive, and only
    then breaks and resets it via virtio_device_shutdown(). Unlike
    virtballoon_remove() the balloon workqueue is not destroyed, as shutdown
    does not free the device and cancel_work_sync() together with stop_update
    already prevent any further work from being queued.
    
    Feature: fix ms/virtio_balloon
    https://virtuozzo.atlassian.net/browse/VSTOR-135654
    Fixes: 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shutdown()")
    Signed-off-by: Denis V. Lunev <den at openvz.org>
    
    Reviewed-by: David Hildenbrand <david at kernel.org>
---
 drivers/virtio/virtio_balloon.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index f16c8ed6737df..d6106ccecf71d 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -1217,6 +1217,12 @@ static void virtballoon_remove(struct virtio_device *vdev)
 	kfree(vb);
 }
 
+static void virtballoon_shutdown(struct virtio_device *vdev)
+{
+	virtballoon_quiesce(vdev->priv);
+	virtio_device_shutdown(vdev);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int virtballoon_freeze(struct virtio_device *vdev)
 {
@@ -1282,6 +1288,7 @@ static struct virtio_driver virtio_balloon_driver = {
 	.validate =	virtballoon_validate,
 	.probe =	virtballoon_probe,
 	.remove =	virtballoon_remove,
+	.shutdown =	virtballoon_shutdown,
 	.config_changed = virtballoon_changed,
 #ifdef CONFIG_PM_SLEEP
 	.freeze	=	virtballoon_freeze,


More information about the Devel mailing list