diff --git a/tools/ioemu/block-raw.c b/tools/ioemu/block-raw.c index 41c8abb413..9b01211bbf 100644 --- a/tools/ioemu/block-raw.c +++ b/tools/ioemu/block-raw.c @@ -166,7 +166,7 @@ typedef struct RawAIOCB { struct RawAIOCB *next; } RawAIOCB; -static int aio_sig_num = SIGUSR2; +const int aio_sig_num = SIGUSR2; static RawAIOCB *first_aio; /* AIO issued */ static int aio_initialized = 0; diff --git a/tools/ioemu/vl.c b/tools/ioemu/vl.c index 696791f13c..02c3bb21a2 100644 --- a/tools/ioemu/vl.c +++ b/tools/ioemu/vl.c @@ -7059,6 +7059,18 @@ int main(int argc, char **argv) #endif char qemu_dm_logfilename[128]; + + /* Ensure that SIGUSR2 is blocked by default when a new thread is created, + then only the threads that use the signal unblock it -- this fixes a + race condition in Qcow support where the AIO signal is misdelivered. */ + { + extern const int aio_sig_num; + sigset_t set; + + sigemptyset(&set); + sigaddset(&set, aio_sig_num); + sigprocmask(SIG_BLOCK, &set, NULL); + } LIST_INIT (&vm_change_state_head); #ifndef _WIN32