From nobody Sun Feb 8 23:33:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1571915977; cv=none; d=zoho.com; s=zohoarc; b=LRPIP/yKI1/GAcHh6jmJBGEdL2Cv0Wm2WTNL5vJKIlrDwmodwqtAFaBmUcN3xpz/IWGvaKjM3i31sPRy+Son11exP67BIYVLlCCj7I6IPFimP7we7CxKZVTVfu3WVbF+tmim5Vk7eXuEZC36XBSc2SrmvY9QxMt8n9+oltFWOhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571915977; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=btour2UNUU7CDnNRKI6AE+S8OUCK/eeLSqRjU36nKl8=; b=hUSF1ECSP0+fz+Jp98Tainx47qcCnJhdw/pBe/qv9hTNsbp6uY0uPQCovylnbUdQptVWrLiwhlSWLMfCT/ZC95qHrSZdIIKQu/TWCvv62qzeLf66aiIdUiV+CBD9b0T6bTOSrc5xA8k/0OevGUezn/6Z9iil0vSOO7Sd1MPBGPM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571915977571806.421720940298; Thu, 24 Oct 2019 04:19:37 -0700 (PDT) Received: from localhost ([::1]:36854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNZcj-00042W-Eb for importer@patchew.org; Thu, 24 Oct 2019 05:41:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44315) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNZAG-0001Te-KQ for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:12:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNZAF-0005C7-C6 for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:12:16 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46804) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNZAF-0005BT-4M for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:12:15 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9O94Pfb116363; Thu, 24 Oct 2019 09:12:09 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2vqswtte5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 09:12:09 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9O982R1093173; Thu, 24 Oct 2019 09:10:08 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2vtm244fsx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 09:10:07 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x9O9A7Bh001853; Thu, 24 Oct 2019 09:10:07 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Oct 2019 02:10:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=corp-2019-08-05; bh=btour2UNUU7CDnNRKI6AE+S8OUCK/eeLSqRjU36nKl8=; b=dzKhPrwb9dtZda7tj96620UuOifJO9LUzWJp0slqY9T0HDXZC6XMmsGZeKpbNchLMvx7 RqEcLaO0hKhNlJFQnpqekOY4n1JFJYNe+ryrBtZAywTSMz/0l1oPj41swqtQG4yUjc2E xaNg0kxzdeNUKvBfWFHQzgbhyDPpw+g2Ayocp9vaYlkI+Jt0KaWYE50KWZnOkJclMWM4 RyVGZSSP17kuP/yhi4arNR9ZFgNH9V6dz/tCfJRokKNINqj0qBXKE67YUiSG4NXN4kZ9 tkho7Zq8x47ehjSalohik3QXRXxjoyyS280YjObttGS38YM5UWPo39rZeFljcqGBV4a8 vg== From: Jagannathan Raman To: qemu-devel@nongnu.org Subject: [RFC v4 PATCH 08/49] multi-process: add functions to synchronize proxy and remote endpoints Date: Thu, 24 Oct 2019 05:08:49 -0400 Message-Id: <823727c8cf4bbc563cecebd6a231bea77d81adeb.1571905346.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240089 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910240089 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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: elena.ufimtseva@oracle.com, fam@euphon.net, john.g.johnson@oracle.com, kraxel@redhat.com, jag.raman@oracle.com, quintela@redhat.com, mst@redhat.com, armbru@redhat.com, kanth.ghatraju@oracle.com, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.com, rth@twiddle.net, kwolf@redhat.com, berrange@redhat.com, mreitz@redhat.com, ross.lagerwall@citrix.com, marcandre.lureau@gmail.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In some cases, for example MMIO read, QEMU has to wait for the remote to complete a command before proceeding. An eventfd based mechanism is added to synchronize QEMU & remote process. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- v1 -> v2: - Added timeout to synchronization functions include/io/mpqemu-link.h | 9 +++++++++ io/mpqemu-link.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index 345c67e..dee2dd3 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -30,7 +30,9 @@ =20 #include #include +#include #include +#include =20 #include "qom/object.h" #include "qemu/thread.h" @@ -147,4 +149,11 @@ void mpqemu_destroy_channel(MPQemuChannel *chan); void mpqemu_link_set_callback(MPQemuLinkState *s, mpqemu_link_callback cal= lback); void mpqemu_start_coms(MPQemuLinkState *s); =20 +#define GET_REMOTE_WAIT eventfd(0, 0) +#define PUT_REMOTE_WAIT(wait) close(wait) +#define PROXY_LINK_WAIT_DONE 1 + +uint64_t wait_for_remote(int efd); +void notify_proxy(int fd, uint64_t val); + #endif diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index b39f4d0..696aeb1 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -231,6 +231,46 @@ int mpqemu_msg_recv(MPQemuLinkState *s, MPQemuMsg *msg= , MPQemuChannel *chan) return rc; } =20 +uint64_t wait_for_remote(int efd) +{ + struct pollfd pfd =3D { .fd =3D efd, .events =3D POLLIN }; + uint64_t val; + int ret; + + ret =3D poll(&pfd, 1, 1000); + + switch (ret) { + case 0: + qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: Timed out\= n"); + /* TODO: Kick-off error recovery */ + return ULLONG_MAX; + case -1: + qemu_log_mask(LOG_REMOTE_DEBUG, "Poll error wait_for_remote: %s\n", + strerror(errno)); + return ULLONG_MAX; + default: + if (read(efd, &val, sizeof(val)) =3D=3D -1) { + qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: %s\n", + strerror(errno)); + return ULLONG_MAX; + } + } + + val =3D (val =3D=3D ULLONG_MAX) ? val : (val - 1); + + return val; +} + +void notify_proxy(int efd, uint64_t val) +{ + val =3D (val =3D=3D ULLONG_MAX) ? val : (val + 1); + + if (write(efd, &val, sizeof(val)) =3D=3D -1) { + qemu_log_mask(LOG_REMOTE_DEBUG, "Error notify_proxy: %s\n", + strerror(errno)); + } +} + static gboolean mpqemu_link_handler_prepare(GSource *gsrc, gint *timeout) { g_assert(timeout); --=20 1.8.3.1