From patchwork Wed Jul 18 12:52:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 171663 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 E00922C0350 for ; Wed, 18 Jul 2012 22:52:32 +1000 (EST) Received: from localhost ([::1]:51928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTjz-0002ap-2d for incoming@patchwork.ozlabs.org; Wed, 18 Jul 2012 08:52:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55813) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTjp-0002aX-Hy for qemu-devel@nongnu.org; Wed, 18 Jul 2012 08:52:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrTjg-00061u-3C for qemu-devel@nongnu.org; Wed, 18 Jul 2012 08:52:21 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:45710) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrTjf-00061q-VL for qemu-devel@nongnu.org; Wed, 18 Jul 2012 08:52:12 -0400 Received: by yenl1 with SMTP id l1so1582885yen.4 for ; Wed, 18 Jul 2012 05:52:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Yhlh9WM/w2vgdOvGyqbDi2XhTb+9jzrNA6EOd1L4Bkw=; b=KbWtVNY1oby++b1ljo/sOLNaBa0Ko0cQmXynujuEW53Q3hQ8RfKZV//XyTn2+ZoTHR zAiCC2BAAzKH5uVW3mBvF10j98R0lDjf43kUfMSaDU7u+fNHV/XPKDzbtd1rKd6ojqbX FWcNgOvnsowycEcMzyAn2VzVJr2RbYSyhVVv0O9QD0n6v6na3K3U6yDVy16dbNoqIP+k DmDBT11NgjIuneYMBp4nCjwnnz+Zoxgwe/mzidKOoUJAisJu39Znqka4xMlAMbiA+sF/ oXiicQwCBqRlYCFGsRSVolDFV/dBu6d25852BRdEM28hLXzcFiphlC4fahAUDNTP24fh 3STw== Received: by 10.68.227.198 with SMTP id sc6mr7101846pbc.138.1342615931002; Wed, 18 Jul 2012 05:52:11 -0700 (PDT) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPS id qd2sm12344218pbb.29.2012.07.18.05.52.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jul 2012 05:52:10 -0700 (PDT) From: Alexey Kardashevskiy To: "Michael S . Tsirkin" Date: Wed, 18 Jul 2012 22:52:04 +1000 Message-Id: <1342615924-20925-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1342613333-20239-1-git-send-email-aik@ozlabs.ru> References: <1342613333-20239-1-git-send-email-aik@ozlabs.ru> X-Gm-Message-State: ALoCoQk8g8LDTnzvLiy5ETcumm+x4kW+jM51nvKUnGC0CIhXKkmqQrTVZ7ZKfFcQ6x7oilBSr8ys X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.213.173 Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org 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 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 closes/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; }