On 9/20/19 1:11 PM, Kevin Wolf wrote: > Emitting a QMP event when blkdebug injects an error makes sense to me. > > I wouldn't use it for this case, though, because this would become racy. > It could happen that the guest writes to the image, which sends a QMP > event, and then reads before the external program has removed the error.
My POC had a single lock protecting it's shared state. I'm kind of surprised no one jumped on that because it's a big point of lock contention. One could argue that the state data and associated lock(s) should be on each device which leads me to the next point. I think with careful locking and sequencing we could address this race condition so that the error was removed before the write completed. In fact it would need to work that way to allow the external test code the ability to perturb the data before it's written if that's what the test wanted to do. -Tony