From patchwork Wed Feb 10 23:09:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 45070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 70CD0B7CB6 for ; Thu, 11 Feb 2010 10:19:04 +1100 (EST) Received: from localhost ([127.0.0.1]:40261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfLoT-0002yU-Og for incoming@patchwork.ozlabs.org; Wed, 10 Feb 2010 18:17:41 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NfLge-0000IE-6J for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:36 -0500 Received: from [199.232.76.173] (port=47487 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NfLgc-0000HA-Bk for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:34 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NfLga-0002W9-GX for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:33 -0500 Received: from mail-fx0-f223.google.com ([209.85.220.223]:57329) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NfLgZ-0002VY-3f for qemu-devel@nongnu.org; Wed, 10 Feb 2010 18:09:32 -0500 Received: by fxm23 with SMTP id 23so592414fxm.2 for ; Wed, 10 Feb 2010 15:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=0BT+0x7WQVSI4+WPE1aMKdpmajipf71xE0a4KGD8tCA=; b=OX+nRk/U7mPDSMGM1hs61K5A8ov1+u1cGD2ZrXjh+xMkyAc+fppqFgsEgFlRrA8ied F1pJ1rFOBgXoiF10nTmwz22YjFLgGcW4OLZ6FwIVK7Sg91UJikEoXGZ7hv9toHQ3NUM1 TkjSTH21D6yLLbeJxdrIEZIwMM1V4oXzaaCi0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=mERJ+Z5yPqE9sTnB+rnsP5Iftrmq0FxhLqdPE/8Qq0GYZJW3NFyoo0pcKEo4mIMWXn m/ICoZKtbibhRlWcamTvJGm/m12iGgC92Xq9/R7EX+Az9kXAIZDXtZtXjEe22mbhkfzG VaLvnruEGmyIlunheoatE0DlNaeyDa8yDN68g= Received: by 10.223.17.92 with SMTP id r28mr452897faa.91.1265843368700; Wed, 10 Feb 2010 15:09:28 -0800 (PST) Received: from localhost.localdomain ([85.93.118.17]) by mx.google.com with ESMTPS id 18sm2839148fks.34.2010.02.10.15.09.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Feb 2010 15:09:28 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 11 Feb 2010 00:09:14 +0100 Message-Id: <1265843356-25765-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> References: <1265843356-25765-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 2/4] qemu-kvm: morph io_thread_wakeup into qemu.git's qemu_event_read X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Again, no need to loop if less than a full buffer is read, the next read would return EAGAIN. Signed-off-by: Paolo Bonzini --- qemu-kvm.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 669a784..50e1303 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -2049,19 +2049,13 @@ static void sigfd_handler(void *opaque) static void io_thread_wakeup(void *opaque) { int fd = (unsigned long) opaque; - char buffer[4096]; - - /* Drain the pipe/(eventfd) */ - while (1) { - ssize_t len; + ssize_t len; + char buffer[512]; + /* Drain the notify pipe. For eventfd, only 8 bytes will be read. */ + do { len = read(fd, buffer, sizeof(buffer)); - if (len == -1 && errno == EINTR) - continue; - - if (len <= 0) - break; - } + } while ((len == -1 && errno == EINTR) || len == sizeof(buffer)); } int kvm_main_loop(void)