On Tue, May 07, 2024 at 10:47:13AM +0300, Avihai Horon wrote: > > While at it, another trivial comment is maybe it's nice to have a helper to > > both update the vfio migration state, plus emitting events when necessary. > > I think vfio_migration_set_state() does exactly that, no?
Ah yes, looks so. It's just that I saw some common patterns, like: ===8<=== @@ -126,11 +167,13 @@ static int vfio_migration_set_state(VFIODevice *vbasedev, } migration->device_state = recover_state; + vfio_migration_send_state_change_event(vbasedev); return ret; } migration->device_state = new_state; + vfio_migration_send_state_change_event(vbasedev); if (mig_state->data_fd != -1) { if (migration->data_fd != -1) { /* @@ -157,6 +200,7 @@ reset_device: } migration->device_state = VFIO_DEVICE_STATE_RUNNING; + vfio_migration_send_state_change_event(vbasedev); return ret; } ===8<=== So maybe some more internal helpers? It doesn't look like to cover all updates to device_state, but I really didn't read into it. Not a huge deal really, feel free to keep it as-is if maintainers are happy. Thanks, -- Peter Xu