From patchwork Wed Apr 8 18:33:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11480641 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 503DF81 for ; Wed, 8 Apr 2020 18:40:21 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23D1C2072F for ; Wed, 8 Apr 2020 18:40:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=web.de header.i=@web.de header.b="B1+Ng5ux" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23D1C2072F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=web.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:39552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMFcZ-0008Jr-3H for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Apr 2020 14:40:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58060) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jMFWh-0006eu-BL for qemu-devel@nongnu.org; Wed, 08 Apr 2020 14:34:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jMFWg-0004Yk-Ee for qemu-devel@nongnu.org; Wed, 08 Apr 2020 14:34:15 -0400 Received: from mout.web.de ([212.227.17.11]:46761) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jMFWg-0004XN-1J for qemu-devel@nongnu.org; Wed, 08 Apr 2020 14:34:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1586370835; bh=Ok7tKtjZZkKFvWc5NnUyDQ4Xr69cRQd1e1Rf/HuBLN4=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=B1+Ng5uxSFUmv9TQKe59ZQw7wMAeif7QVySz8Qk5lgdi/OuzsMQ39iUV8dUkXfMlS qN2TebgTZcHTMXOPa57u/lib5CFj8ojcUOJneKzSOLGRG/cpYgI2ZKkcu65H/dTKJm au3pl3oLW3b127PJMaL6f8F6V1gqWpI2zhiSeKJc= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([88.130.61.62]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MPHKO-1jQdEZ10wC-004VBS; Wed, 08 Apr 2020 20:33:55 +0200 Date: Wed, 8 Apr 2020 20:33:53 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH 2/3] chardev/char.c: Use qemu_co_sleep_ns if in coroutine Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:k1fw5k77W1NyeRTs3Wjdh2c+m6balKpYGf7d4/4vCZqFPea4tjl BVfTjA1Ncywgbt9jQcPTrx9yc2Ao5r85wGiirMnGgm2Ngvgp+b3J59IrUXdRELkWYlbwzeY IZsNmuECb3fybvWOu7Y7q5X8DYq3za/fYO0cYfTxsLgmUmrE/6UnDCRZP+JH4fzx0Bbxmm6 84mFVf8IDwPT1SWI7OEJg== X-UI-Out-Filterresults: notjunk:1;V03:K0:BT95PjSaaH4=:z8+hTZBDLXdQXzvWczBjN9 YLLVsE5cQDTIWeRviWWwKIAUReIh+nj2FK/H6Y7nQOQDvnLVdPyzJBlr6gSg1dgCb25Srm5ub ESSles58iTVkMNY/uaXNa7Q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v2X3nuFvH 8Hh8KkTlufSupu6CZ7oyxUm83xJ0XOlSu+xRu4q3fZmx5EaMTKupaKJFXdMssX7vpCp07kKpd fV7HbzSUjwQZPPGmJ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.11 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen , Jason Wang , Paolo Bonzini , Li Zhijian , =?utf-8?q?Marc-Andr=C3=A9?= Lureau Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" This will be needed in the next patch. Signed-off-by: Lukas Straub Reviewed-by: Marc-André Lureau Reviewed-by: Zhang Chen --- chardev/char.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chardev/char.c b/chardev/char.c index 04075389bf..51ad0dc6b3 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -38,6 +38,7 @@ #include "qemu/module.h" #include "qemu/option.h" #include "qemu/id.h" +#include "qemu/coroutine.h" #include "chardev/char-mux.h" @@ -119,7 +120,11 @@ static int qemu_chr_write_buffer(Chardev *s, retry: res = cc->chr_write(s, buf + *offset, len - *offset); if (res < 0 && errno == EAGAIN && write_all) { - g_usleep(100); + if (qemu_in_coroutine()) { + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 100000); + } else { + g_usleep(100); + } goto retry; }