Skip to content

viona: do not lose used/avail indices#1135

Merged
iximeow merged 1 commit intomasterfrom
ixi/viona-set-used-avail-idx
May 6, 2026
Merged

viona: do not lose used/avail indices#1135
iximeow merged 1 commit intomasterfrom
ixi/viona-set-used-avail-idx

Conversation

@iximeow
Copy link
Copy Markdown
Member

@iximeow iximeow commented Apr 30, 2026

When we're going to get virtio-nic device running after initialization or import, part of queues_restart() involves synchronizing the state of viona rings with the Propolis-side state for corresponding virtqueues; we're about to hand off operation of those queues to viona after all. When we stop a virtio-nic device, queues_sync() synchronizes viona ring state back into Propolis via VNA_IOC_RING_GET_STATE, and when exported we correctly retain all queue state.

On import we had omitted to set vrs_avail_idx and vrs_used_idx. The guest-side state for the wring then is written on top of the previously-exported memory, clobbering correct state with the now reset-to-initial queue indices. Resuming the guest at this point is a bit fraught, as there's no reason to believe that the descriptors at such indices are valid. In the lucky case you may catch a Linux guest logging something like:

virtio_net virtio0: input.0:id 0 is not a head!

at which point it gives up on the very broken device.

... I could probably write a test for this, by setting vrs_qaddr_avail (and avail) to something and then migrating the device. there's no reason we need to actually send packets anywhere or rx interrupts etc...

anyhow, at this point ping from a host elsewhere on my network to the VM, and ping from the VM to an external host, both keep working across migration again. yay!!

@iximeow iximeow added networking Related to networking devices/backends. migration Issues related to live migration. labels Apr 30, 2026
Copy link
Copy Markdown
Contributor

@dancrossnyc dancrossnyc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sound you hear is me, banging my head against the table and groaning loudly.

@iximeow iximeow force-pushed the ixi/viona-import-usepairs branch from 05044d4 to fee6a9f Compare May 6, 2026 00:33
When we're going to get virtio-nic device running after initialization
or import, part of `queues_restart()` involves synchronizing the state
of viona rings with the Propolis-side state for corresponding
virtqueues; we're about to hand off operation of those queues to viona
after all. When we stop a virtio-nic device, `queues_sync()`
synchronizes viona ring state back into Propolis via
VNA_IOC_RING_GET_STATE, and when exported we correctly retain all queue
state.

On import we had omitted to set vrs_avail_idx and vrs_used_idx. The
guest-side state for the wring then is written on top of the
previously-exported memory, clobbering correct state with the now
reset-to-initial queue indices. Resuming the guest at this point is a
bit fraught, as there's no reason to believe that the descriptors at
such indices are valid. In the lucky case you may catch a Linux guest
logging something like:

> virtio_net virtio0: input.0:id 0 is not a head!

at which point it gives up on the very broken device.
Base automatically changed from ixi/viona-import-usepairs to master May 6, 2026 01:45
@iximeow iximeow force-pushed the ixi/viona-set-used-avail-idx branch from f8063e2 to bc07cd3 Compare May 6, 2026 01:46
@iximeow iximeow merged commit 3f6d599 into master May 6, 2026
14 checks passed
@iximeow iximeow deleted the ixi/viona-set-used-avail-idx branch May 6, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

migration Issues related to live migration. networking Related to networking devices/backends.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants