From patchwork Tue Apr 14 02:53:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: WANG Chao X-Patchwork-Id: 461043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9FA4E1400A0 for ; Tue, 14 Apr 2015 16:20:06 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=gmail.com header.i=@gmail.com header.b=fsdRA90/; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost ([::1]:54510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YhuCY-00067O-Vs for incoming@patchwork.ozlabs.org; Tue, 14 Apr 2015 02:20:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yhqyo-0002T5-NO for qemu-devel@nongnu.org; Mon, 13 Apr 2015 22:53:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yhqyj-0006I7-Nq for qemu-devel@nongnu.org; Mon, 13 Apr 2015 22:53:38 -0400 Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:32819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yhqyj-0006Hb-GH for qemu-devel@nongnu.org; Mon, 13 Apr 2015 22:53:33 -0400 Received: by pdbnk13 with SMTP id nk13so128200573pdb.0 for ; Mon, 13 Apr 2015 19:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=EyvrmmIHl96OPKfl6YQIQrwV0wv6lwYuNAzS3T1Vytw=; b=fsdRA90/Z6wrlSYj1zkQzZUGKZAU3gSIeDCPJyxmIhE/bMf9bGw1A4rrJKOgMhESzr c34Bkp3Ir7K1FCmBCgT8sI5/EellVmgqRfZrwFO6mV0jbnUsp5aMFjVyw3HXAzl2KEAK T33m+x6dBK+pbHfgB/tDeMP/loXhgQOb3KyYw5uQmnQ6JOTGC8f6XzUiGCFo79+DpaJI ovyPLdFHxlQ045W5ZdrLX/b/zP+XoY5QOe/kOwFZIfa4zZLKEN8wj/4wKYRN8xfuyCm4 Ka6pqYFnIBbp+egun4DDoJWJlwjvxUkyjncR710+DOF+utqKyxPCGbOnhs53kc0MXEnf jq0g== X-Received: by 10.70.91.37 with SMTP id cb5mr32080002pdb.151.1428980011381; Mon, 13 Apr 2015 19:53:31 -0700 (PDT) Received: from localhost (li676-142.members.linode.com. [106.186.123.142]) by mx.google.com with ESMTPSA id i9sm8628119pdj.27.2015.04.13.19.53.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 19:53:30 -0700 (PDT) From: WANG Chao To: Michael Roth Date: Tue, 14 Apr 2015 10:53:07 +0800 Message-Id: <1428979987-21883-1-git-send-email-wcwxyz@gmail.com> X-Mailer: git-send-email 2.3.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::229 X-Mailman-Approved-At: Tue, 14 Apr 2015 02:19:30 -0400 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] qga: use unbuffered glib IO 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 Glib's internal buffering implementation is opaque. It seems to grow up when receiving large chunk of data (eg. by guest-file-write). When that buffer become large, the glib main loop will stop notifying callback for small incoming chunk (eg. by guest-file-close) but wait until buffer is filled up again. In this situation, qemu-ga will simply looks like hang/dead from the client side of view. By disabling the buffer, qemu-ga will deal with each incoming chunk with no delay. So the client side will no longer face the situation where an issued command doesn't come back with a response. Signed-off-by: WANG Chao --- qga/channel-posix.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/qga/channel-posix.c b/qga/channel-posix.c index 8aad4fe..a2ca161 100644 --- a/qga/channel-posix.c +++ b/qga/channel-posix.c @@ -116,6 +116,7 @@ static int ga_channel_client_add(GAChannel *c, int fd) client_channel = g_io_channel_unix_new(fd); g_assert(client_channel); g_io_channel_set_encoding(client_channel, NULL, &err); + g_io_channel_set_buffered(client_channel, false); if (err != NULL) { g_warning("error setting channel encoding to binary"); g_error_free(err); @@ -230,14 +231,6 @@ GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size) size -= written; } - if (status == G_IO_STATUS_NORMAL) { - status = g_io_channel_flush(c->client_channel, &err); - if (err != NULL) { - g_warning("error flushing channel: %s", err->message); - return G_IO_STATUS_ERROR; - } - } - return status; }