On 04/07/2016 18:31, Daniel P. Berrange wrote:
>> > Instead of using a atexit() handler, only run the chardev cleanup as
>> > initially proposed at the end of main(), where there are less chances
>> > (hic) of conflicts or other races.
> This doesn't really seem all that much safer. There's still plenty of
> chance that threads are running in the background at the end of the
> main() method, so plenty of scope for the qemu_chr_cleanup() call to
> cause threads to segv by destroying the chardevs they're using behind
> their back.

At this point you have stopped all CPUs and block devices.  There is not
much else that is going on in QEMU at all, at this point.  The solution
would be to stop those threads.

Paolo

> IIUC, the original intent here was that we call unlink() on the UNIX
> socket paths when QEMU exits.
> 
> Surely we can come up with a way to that, and only that, upon exit,
> without actually having to free the chardev memory with all the risks
> that entails.
> 
> eg, have a qemu_chr_close() method that closes & cleans up resources,
> separately from actually free'ing the Chardev struct with all the
> risk of crashing concurrent threads that entails.
> 

Reply via email to