Skip to content

Commit 4055826

Browse files
akihikodakiMichael Tokarev
authored andcommitted
virtio: Call set_features during reset
virtio-net expects set_features() will be called when the feature set used by the guest changes to update the number of virtqueues but it is not called during reset, which will clear all features, leaving the queues added for VIRTIO_NET_F_MQ or VIRTIO_NET_F_RSS. Not only these extra queues are visible to the guest, they will cause segmentation fault during migration. Call set_features() during reset to remove those queues for virtio-net as we call set_status(). It will also prevent similar bugs for virtio-net and other devices in the future. Fixes: f9d6dbf ("virtio-net: remove virtio queues if the guest doesn't support multiqueue") Buglink: https://issues.redhat.com/browse/RHEL-73842 Cc: [email protected] Signed-off-by: Akihiko Odaki <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> (cherry picked from commit 0caed25) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 8efe159 commit 4055826

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

hw/virtio/virtio.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,8 @@ void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index)
23162316
}
23172317
}
23182318

2319+
static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val);
2320+
23192321
void virtio_reset(void *opaque)
23202322
{
23212323
VirtIODevice *vdev = opaque;
@@ -2346,7 +2348,7 @@ void virtio_reset(void *opaque)
23462348
vdev->start_on_kick = false;
23472349
vdev->started = false;
23482350
vdev->broken = false;
2349-
vdev->guest_features = 0;
2351+
virtio_set_features_nocheck(vdev, 0);
23502352
vdev->queue_sel = 0;
23512353
vdev->status = 0;
23522354
vdev->disabled = false;

0 commit comments

Comments
 (0)