From patchwork Wed Aug 1 04:05:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 174367 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 C49062C00AD for ; Wed, 1 Aug 2012 14:05:57 +1000 (EST) Received: from localhost ([::1]:43173 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwQC3-0001mo-Qm for incoming@patchwork.ozlabs.org; Wed, 01 Aug 2012 00:05:55 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwQBx-0001mh-OU for qemu-devel@nongnu.org; Wed, 01 Aug 2012 00:05:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwQBv-00076x-OS for qemu-devel@nongnu.org; Wed, 01 Aug 2012 00:05:49 -0400 Received: from ozlabs.org ([203.10.76.45]:46631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwQBv-00076l-C4 for qemu-devel@nongnu.org; Wed, 01 Aug 2012 00:05:47 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 5A7E02C00AD; Wed, 1 Aug 2012 14:05:45 +1000 (EST) From: David Gibson To: anthony@codemonkey.ws, qemu-devel@nongnu.org Date: Wed, 1 Aug 2012 14:05:36 +1000 Message-Id: <1343793936-28000-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 , pbonzini@redhat.com 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 --- iohandler.c | 1 + 1 file changed, 1 insertion(+) 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; }