From patchwork Sun Apr 26 21:18:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11511007 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 B6F2D15AB for ; Sun, 26 Apr 2020 21:26:04 +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 8CAFF206BF for ; Sun, 26 Apr 2020 21:26:04 +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="jQlV5Efb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8CAFF206BF 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]:46494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSomp-0007Qk-7u for patchwork-qemu-devel@patchwork.kernel.org; Sun, 26 Apr 2020 17:26:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33780) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSog5-0004Dp-Tj for qemu-devel@nongnu.org; Sun, 26 Apr 2020 17:19:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSog5-0005kg-HL for qemu-devel@nongnu.org; Sun, 26 Apr 2020 17:19:05 -0400 Received: from mout.web.de ([217.72.192.78]:38289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jSog4-0005fS-W9 for qemu-devel@nongnu.org; Sun, 26 Apr 2020 17:19:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1587935930; bh=NSu8R6ZArrzXlpc/YQzMnC4LGGAot9bFFDtDweoB8DM=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=jQlV5Efb5XeABlgz3+G/xMcRlmb0rWJRxrJrdIZqrJbuovN4ZHZpBAcqlRdFmVO85 Dptlyc0A+XjZkQre1yYzXxWwXhqNiHaEudEntWUiAhTOI5yQiyKJJ010l+WSHCn+jn NfQx0AVTSh4IHCa828zIl8ZAQLk3twcn6a56kU/I= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([94.134.180.69]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MbQOe-1jjFd81LGO-00IkEX; Sun, 26 Apr 2020 23:18:50 +0200 Date: Sun, 26 Apr 2020 23:18:47 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v3 2/6] 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:TWcJqsNDhHaXFF3bGcMiCZL6a7b89w6jWKkxntDSDR57yfyTP9Q /Jx0UBWCRj1Tg7/JSi7QNTwnjl5dkwGGLVAdP/WicIYKZSaS9zoIxiMpgaUGaSksa57rrXt tQAXwjqgu2zE8g4sKWB32X5I2rkFSnZZRyjhat9Pu66udi3Ugu2JW6rtOzDWHeCQgcIPhN2 O00mY14bOAGyT5O78haCg== X-UI-Out-Filterresults: notjunk:1;V03:K0:P1M7rcbPO9I=:OYWJasBOQgAyquCnJPVacW iN1ivLI3uDlipIr+O3y70hPsb63to3h7AKYWibPH7u4Mt1P2Phj/vGCNUCGJVQG/zYJh+2Ndm XLssiD0RQCtMwAjrRNXBhs9Uj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Gz2haI3Y3tbSVECGvTiMm8sMjNBo+6OAfeob5B6h+MOGwud1utD1CmpxbArO1QUebLghDNhk1 rYPN8xqE/j2Odai8/ Received-SPF: pass client-ip=217.72.192.78; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/26 15:25:57 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.78 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 e77564060d..5c8014199f 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; }