From patchwork Wed Aug 22 03:01:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 179223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C3F2D2C0091 for ; Wed, 22 Aug 2012 13:05:17 +1000 (EST) Received: from localhost ([::1]:57143 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T41Fr-0000BT-P2 for incoming@patchwork.ozlabs.org; Tue, 21 Aug 2012 23:05:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T41Fd-0000A1-G7 for qemu-devel@nongnu.org; Tue, 21 Aug 2012 23:05:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T41Fc-0005bR-D2 for qemu-devel@nongnu.org; Tue, 21 Aug 2012 23:05:01 -0400 Received: from ozlabs.org ([203.10.76.45]:50289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T41Fc-0005bI-1e for qemu-devel@nongnu.org; Tue, 21 Aug 2012 23:05:00 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 21E852C0090; Wed, 22 Aug 2012 13:04:57 +1000 (EST) From: David Gibson To: aliguori@us.ibm.com, qemu-devel@nongnu.org Date: Wed, 22 Aug 2012 13:01:34 +1000 Message-Id: <1345604494-24778-1-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 1.7.10.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: Alexey Kardashevskiy , David Gibson Subject: [Qemu-devel] [PATCH] eventfd: making it thread safe X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alexey Kardashevskiy QEMU uses IO handlers to run select() in the main loop. The handlers list is managed by qemu_set_fd_handler() helper which works fine when called from the main thread as it is called when select() is not waiting. However IO handlers list can be changed in the thread other than the main one doing os_host_main_loop_wait(), for example, as a result of a hypercall which changes PCI config space (VFIO on POWER is the case) and enables/disabled MSI/MSIX which creates eventfd handles. As the main loop should be waiting on the newly created eventfds, it has to be restarted. The patch adds the qemu_notify_event() call to interrupt select() to make main_loop() restart select() with the updated IO handlers list. Signed-off-by: Alexey Kardashevskiy Reviewed-by: Paolo Bonzini Signed-off-by: David Gibson --- iohandler.c | 1 + 1 file changed, 1 insertion(+) Anthony, this bugfix for eventfds has been sent before, but seems to have fallen through the cracks. Please apply. diff --git a/iohandler.c b/iohandler.c index 3c74de6..dea4355 100644 --- a/iohandler.c +++ b/iohandler.c @@ -77,6 +77,7 @@ int qemu_set_fd_handler2(int fd, ioh->fd_write = fd_write; ioh->opaque = opaque; ioh->deleted = 0; + qemu_notify_event(); } return 0; }