> > > This is my understanding of the protocol as well, when the device is > > > running, pending_bytes might drop to zero if no internal state has > > > changed and may be non-zero on the next iteration due to device > > > activity. When the device is not running, pending_bytes reporting zero > > > indicates the device is done, there is no further state to transmit. > > > Does that meet your need/expectation? > > > > > (1) on one side, as in vfio_save_pending(), > > vfio_save_pending() > > { > > ... > > ret = vfio_update_pending(vbasedev); > > ... > > *res_precopy_only += migration->pending_bytes; > > ... > > } > > the pending_bytes tells migration thread how much data is still hold in > > device side. > > the device data includes > > device internal data + running device dirty data + device state. > > > > so the pending_bytes should include device state as well, right? > > if so, the pending_bytes should never reach 0 if there's any device > > state to be sent after device is stopped. > > I hadn't expected the pending-bytes to include a fixed offset for device > state (If you mean a few registers etc) - I'd expect pending to drop > possibly to zero; the heuristic as to when to switch from iteration to > stop, is based on the total pending across all iterated devices; so it's > got to be allowed to drop otherwise you'll never transition to stop. > ok. got it. > > (2) on the other side, > > along side we updated the pending_bytes in vfio_save_pending() and > > enter into the vfio_save_iterate(), if we repeatedly update > > pending_bytes in vfio_save_iterate(), it would enter into a scenario > > like > > > > initially pending_bytes=500M. > > vfio_save_iterate() --> > > round 1: transmitted 500M. > > round 2: update pending bytes, pending_bytes=50M (50M dirty data). > > round 3: update pending bytes, pending_bytes=50M. > > ... > > round N: update pending bytes, pending_bytes=50M. > > > > If there're two vfio devices, the vfio_save_iterate() for the second device > > may never get chance to be called because there's always pending_bytes > > produced by the first device, even the size if small. > > And between RAM and the vfio devices? yes, is that right? Thanks Yan