From patchwork Sun Apr 26 19:25:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 11510981 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 6925615AB for ; Sun, 26 Apr 2020 19:47:56 +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 22D38206BF for ; Sun, 26 Apr 2020 19:47:56 +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="OF9jbFvc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22D38206BF 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]:44126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSnFq-0006SU-Ew for patchwork-qemu-devel@patchwork.kernel.org; Sun, 26 Apr 2020 15:47:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47700) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSmud-0001Ce-9R for qemu-devel@nongnu.org; Sun, 26 Apr 2020 15:25:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSmuc-0005kf-QG for qemu-devel@nongnu.org; Sun, 26 Apr 2020 15:25:59 -0400 Received: from mout.web.de ([212.227.15.4]:55933) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jSmuc-0005h4-7d for qemu-devel@nongnu.org; Sun, 26 Apr 2020 15:25:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1587929144; bh=SxlQe2CwqaYOqz1vCvbqvBcqvHod26E6TNFCs9tSaPk=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject:In-Reply-To:References; b=OF9jbFvc4e23YG2KLX13/j8t1ExuQPQ3kC+4Fnq0bUtvBDyxLd+CT8i4KGwbwEaTC D6Io6/bylklu7p5y6hXLNioI3LlrslPWAyGTdqoWo7zcfa34t7YyTYdHkfSPPAH2mR Ty2coWoDT49oDIY0a43Q6A6gSO5mMQDDikTVjxq0= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([89.247.255.95]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MeBEk-1jqOrW1Pna-00PuwV; Sun, 26 Apr 2020 21:25:44 +0200 Date: Sun, 26 Apr 2020 21:25:42 +0200 From: Lukas Straub To: qemu-devel Subject: [PATCH v2 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:2g0REWAPIPYjxMb5/6MrQGa6gM7ymM0942qnJLo/vDtcq9ytUOf JZIY4Pu4IGkbb2C8CQzatm8pyRGfHVN1RctNP/lXH8qlAy0jfxsD45NSY8xe7wnFjCfwwKX /vKE9jx05JOeHKjv6CCzrs68XEsO8N8Z5UekYICXk73TLHoLm/XmSKHELSaj+A87BRxW7Ye ESphm3Ud7zopK+0jZaN6Q== X-UI-Out-Filterresults: notjunk:1;V03:K0:TIi3+7IszWQ=:b43BOh/4dXD+72dOzSJtbo BTsnTbVYbsdbyIApiBvg4wMGhtLc4nktV/8bZER5Ifh9/Mahhg6Pb3V4Hg3PGOuRyKYo3jpSr G1iFF371ncDL9r90f4un+i4Ra8suIN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ojltp kTxNV5Q4a7PC2/lCVOgo4IXg645d5owcWGC9tFvU0cpI0kWq01SacdWjVpYs+ysM7HPb7yTT+ qa8LO2vE9yn0PWYFd Received-SPF: pass client-ip=212.227.15.4; envelope-from=lukasstraub2@web.de; helo=mout.web.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/26 15:25:56 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.4 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; }