From patchwork Sun Jul 1 19:48:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 168458 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 138CB2C01CA for ; Mon, 2 Jul 2012 05:48:38 +1000 (EST) Received: from localhost ([::1]:57367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SlQ8J-00049i-S4 for incoming@patchwork.ozlabs.org; Sun, 01 Jul 2012 15:48:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59061) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SlQ8A-00049c-2L for qemu-devel@nongnu.org; Sun, 01 Jul 2012 15:48:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SlQ85-0000vi-NE for qemu-devel@nongnu.org; Sun, 01 Jul 2012 15:48:25 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:52898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SlQ85-0000vU-H4 for qemu-devel@nongnu.org; Sun, 01 Jul 2012 15:48:21 -0400 Received: by dadn2 with SMTP id n2so7235928dad.4 for ; Sun, 01 Jul 2012 12:48:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=OTIzbWNXYND7N3PA8+uWa74il9Od6KFsRq6Euro/ve8=; b=aXzRFNPTteD7KRmaXBhTMHcpFECKoyYO2BfvvKfnPsnzHD4znuxvIP3RGN7r4L7k20 Ohl5h4T/7CPwnC5IWldIiXoI21F2njf5VWdH2RZfi4rznN59jQIDrbapygw9h3haj3ze xf2din2Xi/NrGp0rHYWgiDOhc/2Lh1exeBiXxKIKSVEjhlBHm7wxk0DTJHEvD8GwyX1P 10gOCmWEMJ07iZogP96cCtuYOI2bph8wk5z11YE9INPHuDz2XNtDXA7HOh06YZ5HDBdV U5n+X/uZpOA9CYN9GYHOWXXWSrFfC1nutSmFOmikcSD5ryJa7AnhmcnGyNoXdaBNBLAe 5IEQ== Received: by 10.68.129.198 with SMTP id ny6mr24100762pbb.22.1341172098939; Sun, 01 Jul 2012 12:48:18 -0700 (PDT) Received: from [192.168.1.1] (60-242-102-4.tpgi.com.au. [60.242.102.4]) by mx.google.com with ESMTPS id gk3sm9615116pbc.69.2012.07.01.12.48.16 (version=SSLv3 cipher=OTHER); Sun, 01 Jul 2012 12:48:18 -0700 (PDT) Message-ID: <4FF0A980.4070903@ozlabs.ru> Date: Mon, 02 Jul 2012 05:48:16 +1000 From: Alexey Kardashevskiy User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: qemu-devel@nongnu.org References: <4FF02F2C.30006@ozlabs.ru> <4FF05173.6090801@redhat.com> <4FF05369.20405@ozlabs.ru> <4FF062BC.4090200@ozlabs.ru> <4FF066AF.40606@redhat.com> In-Reply-To: <4FF066AF.40606@redhat.com> X-Gm-Message-State: ALoCoQn2g3ObZQz4N+ZgI176DTZQ0I/OFu8bzaTRHDZ/AmesI6AHvXQWwUS3r6/fKcw9ARSnUDf8 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: Paolo Bonzini , Alex Williamson , mst@redhat.com, David Gibson Subject: [Qemu-devel] [PATCH] eventfd: making it rhread 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 not when select() is waiting. However sometime we need to update the handlers list from another thread. For that the main loop's select() needs to be restarted with the updated list. The patch adds the qemu_notify_event() call to interrupt select() and make wrapping code to 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; }