Commit 3c980cb8 authored by David Hildenbrand's avatar David Hildenbrand Committed by sanglipeng1
Browse files

virtio: reenable config if freezing device failed

stable inclusion
from stable-v5.10.215
commit 3b29694dde9be0a4876963e4ac181edc297670bc
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAJJ2D

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3b29694dde9be0a4876963e4ac181edc297670bc



--------------------------------

commit 310227f42882c52356b523e2f4e11690eebcd2ab upstream.

Currently, we don't reenable the config if freezing the device failed.

For example, virtio-mem currently doesn't support suspend+resume, and
trying to freeze the device will always fail. Afterwards, the device
will no longer respond to resize requests, because it won't get notified
about config changes.

Let's fix this by re-enabling the config if freezing fails.

Fixes: 22b7050a ("virtio: defer config changed notifications")
Cc: <stable@kernel.org>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
Message-Id: <20240213135425.795001-1-david@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng1 <sanglipeng1@jd.com>
parent ce2d971a
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -425,13 +425,19 @@ EXPORT_SYMBOL_GPL(unregister_virtio_device);
int virtio_device_freeze(struct virtio_device *dev)
{
	struct virtio_driver *drv = drv_to_virtio(dev->dev.driver);
	int ret;

	virtio_config_disable(dev);

	dev->failed = dev->config->get_status(dev) & VIRTIO_CONFIG_S_FAILED;

	if (drv && drv->freeze)
		return drv->freeze(dev);
	if (drv && drv->freeze) {
		ret = drv->freeze(dev);
		if (ret) {
			virtio_config_enable(dev);
			return ret;
		}
	}

	return 0;
}