On Fri, Jul 17, 2026 at 04:31:32PM +0200, Maciej S. Szmigiero wrote:
> Inside the VFIO code such sync point for VFIO devices could/should indeed
> be created, but then it's not available for these other (non-VFIO) devices
> for the purpose of avoiding the regression from the previous paragraph.
>
> However, replacing the order priority/adjustment mechanism from patch 1
> with the "pre" and "post" handlers I described above would avoid having
> that regression (and help fix the vhost-net case too).
I'm not sure I fully get the pre/post handlers idea, I think it sounds
working, but in all cases I want to decouple it with patch 1: I don't think
it requires patch 1, am I right?
Now if we want to avoid this "theoretical regression" and solve both things
together.. I think we may need to refactor the notifiers mechanism.
Firstly, I hope we're on the same page that essentially prepare_cb() is the
priority mechanism here, we only have HIGH and NORMAL priority, where cb()
is the NORMAL priority.
We also need to persist depth concept per-notifier, I think we should start
by renaming VMChangeStateEntry.priority to depth, add a comment explaining
it (on different order of invokations on VM start/shutdown).
But then, I don't think we need anything as complex as pre/post hooks with
hashes. I think you're right then we need SYNC point which can be
essentially a priority notifier that is in the middle of HIGH and NORMAL.
Hence, I want to see if below should be the easiest:
- Rename VMChangeStateEntry.priority to depth
- Normalize prepare_cb() into VM_CHANGE_NOTIFY_PRI_HIGH, making cb() to
be NORMAL, OTOH. With this, prepare_cb() needs to be registered
separately with qemu_add_vm_change_state_handler_prio_full(). The
function now should drop prepare_cb() but instead take a real
"priority" value of VM_CHANGE_NOTIFY_PRI_*.
- Introduce VM_CHANGE_NOTIFY_PRI_SYNC, in the middle of PREPARE / NORMAL.
- VFIO can now register its 3rd notifier against SYNC.
All rest devices will need to shift part of its logic into PRI_HIGH to
either quiesce DMA or enable the backend to accept DMA (when on dest QEMU).
None of them will need SYNC only if they'll also switch to an async thread
model.
Thanks,
--
Peter Xu