Skip to content

virtio: tolerate importing queues with adjusted size#1117

Merged
iximeow merged 1 commit into
masterfrom
ixi/virtio-queue-size-migrate
Apr 20, 2026
Merged

virtio: tolerate importing queues with adjusted size#1117
iximeow merged 1 commit into
masterfrom
ixi/virtio-queue-size-migrate

Conversation

@iximeow
Copy link
Copy Markdown
Member

@iximeow iximeow commented Apr 16, 2026

Legacy VirtIO devices did not have a mechanism to negotiate queue size, so we very strictly requred imported virtqueues to have the same size as the freshly-created queues for that device. If they didn't match, the old device state is simply not importable.

In transitional and modern VirtIO interfaces, there is a writable queue_size register, and we faithfully allow guests to configure queue sizes; the initial sizes are the maximums we support for a VirtIO device, and guests can pick a smaller number if they're so inclined.

My test virtio-nic driver set a relatively low but fixed queue size out of laziness (this made laying out memory a little more straightforward). Trying to migrate a device that driver has configured fails because queue import is overly-strict.

This bug seems pretty unlikely to hit in practice, because afaict guest OSes will just go with the maximum queue sizes we offer, but we should tolerate it.

I'm trying to reproduce a bug I see in Linux but I don't fully understand, and tripped across this along the way. The search continues..

Legacy VirtIO devices did not have a mechanism to negotiate queue size,
so we very strictly requred imported virtqueues to have the same size as
the freshly-created queues for that device. If they didn't match, the
old device state is simply not importable.

In transitional and modern VirtIO interfaces, there is a writable
`queue_size` register, and we faithfully allow guests to configure queue
sizes; the initial sizes are the maximums we support for a VirtIO
device, and guests can pick a smaller number if they're so inclined.

My test virtio-nic driver set a relatively low but fixed queue size out
of laziness (this made laying out memory a little more straightforward).
Trying to migrate a device that driver has configured fails because
queue import is overly-strict.

This bug seems pretty unlikely to hit in practice, because afaict guest
OSes will just go with the maximum queue sizes we offer, but we should
tolerate it.

I'm trying to reproduce a bug I see in Linux but I don't fully
understand, and tripped across this along the way. The search
continues..
@iximeow iximeow force-pushed the ixi/virtio-queue-size-migrate branch from 3ea068e to e2ff18e Compare April 20, 2026 22:29
@iximeow iximeow merged commit aa17344 into master Apr 20, 2026
14 checks passed
@iximeow iximeow deleted the ixi/virtio-queue-size-migrate branch April 20, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant