virtio: tolerate importing queues with adjusted size#1117
Merged
Conversation
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..
3ea068e to
e2ff18e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_sizeregister, 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..