From patchwork Tue Jan 19 20:28:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jag Raman X-Patchwork-Id: 12030799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94AC8C433DB for ; Tue, 19 Jan 2021 20:58:29 +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 E2DCD22CE3 for ; Tue, 19 Jan 2021 20:58:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2DCD22CE3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1y55-0007fa-KS for qemu-devel@archiver.kernel.org; Tue, 19 Jan 2021 15:58:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1xf9-0003a9-2b for qemu-devel@nongnu.org; Tue, 19 Jan 2021 15:31:39 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:60784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1xf5-0000fg-2h for qemu-devel@nongnu.org; Tue, 19 Jan 2021 15:31:38 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10JKNUs9002789; Tue, 19 Jan 2021 20:31:28 GMT 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 : content-type : mime-version; s=corp-2020-01-29; bh=fcOYsIut7P+7V3lCOwx9r74mhX1CARiekYFi7+KIyC8=; b=sTfDBjLkgWDZp8V+lif4M6JwD0wpGdEJ3se50XPuH31zeKuHy3SI36TGhPGLyTKjwRfw OpMQkOhg+QKPeam1+r0hBfg4lGgnZ+9EfeboUqk7KsFpGY1mVPFn9ED783T6pvv66F5C 3mLVmjyhVIGeVuLXWWwZnR3Q584lVglf0Byh23ITK8xSDwrnG4wygLOH9Xy6HMQPDUjk BNTJJ/SUSPdcRCLhBIih0uKPmxigLkKSTBRUWv38ocg7vkruejqKsdTuaZZbG1ov3Pqg nFiXUz3rDEjeQGtd53NrNotWtuaYh7csH7M/bROIE5cQ8DIAHqi1UYjyfsVGzT1IyB0r 1w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 363xyhtb3t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jan 2021 20:31:28 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10JKPc7P128314; Tue, 19 Jan 2021 20:29:28 GMT Received: from nam02-cy1-obe.outbound.protection.outlook.com (mail-cys01nam02lp2054.outbound.protection.outlook.com [104.47.37.54]) by userp3030.oracle.com with ESMTP id 3661njtast-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jan 2021 20:29:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H42Y8RRUNogi3SPZs9hSvNXcUg0JLVb3YylZAUAsbVoidCCVWUhXpA9DGjG2ZHjIbcf/kyM4pKUpAh00aevMsLEZ6pW6v86MHpa2nkiKpzHkSIj6+j1cuQ3Lt6mahxYYu23/hpTbvO679G/su2jlcFUCGNo6EGMWvnThraLszeRImbtjzvuzu9qWEEIZa5K9ivCywQoiazWRFMnLi+FS1Tvf8SsijWa/Ay8OkzCV+JHEjo1LdZJbzat4XogNnsmDJKf0LxMuE28/dUNv1ij3sf/Bk9p2kiYWJLF9EftxuBvl4caDCJA483QbUqxUSigwpz0pOqYX8KXPIikcA4KJ8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fcOYsIut7P+7V3lCOwx9r74mhX1CARiekYFi7+KIyC8=; b=lIEBG8b8wTkaql6LdOxY/MLRIj+3tLxmUD0Sw2X8QgVCnUx1BsqI4aGzbXRDIMPnHRmUIKepcFABELa5UcFyG3xTVbdVNNDQ72o9a7Iu2CqjFe0CwqC92e9dUfDtFlSJz2xk4Z0Lh60XprI75VNjd7cnEuhsFkfV/OxBilpTzc+yLxFuccQWVn6/dpaJfj3k4JNG7JPcOaRA8pSbslLjD+oq33Up2yJeFPfWfAgES76yHe26/KVikt3+A4y9Pf+GQC8PYSqMETzbQzzniovgYex1yVFE3C1S9PLLz3nhnIprP6J6RxB+ohSic1nnEsXfoyZaeD/r8NeCDkjZidUxKA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fcOYsIut7P+7V3lCOwx9r74mhX1CARiekYFi7+KIyC8=; b=xj0me+IjqNKW3NJu2ozs/a7CpVP5zwNmgrzhzpjs2GaboO+PMsNQkhZ3YkmICRCP8Eiuhq00VOoCuhw8IBnlFEqmzRPg7gRjOwaY+OSn0fLefte18mhGs/Bu5XSugKtqKUwAOlrNDDtxyGdhaWiok09VMK7j9vAS4vHuHBnMcvE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB2744.namprd10.prod.outlook.com (2603:10b6:a02:ae::18) by BYAPR10MB3349.namprd10.prod.outlook.com (2603:10b6:a03:155::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.9; Tue, 19 Jan 2021 20:29:25 +0000 Received: from BYAPR10MB2744.namprd10.prod.outlook.com ([fe80::5cf0:3e26:c005:341b]) by BYAPR10MB2744.namprd10.prod.outlook.com ([fe80::5cf0:3e26:c005:341b%7]) with mapi id 15.20.3763.014; Tue, 19 Jan 2021 20:29:25 +0000 From: Jagannathan Raman To: qemu-devel@nongnu.org Subject: [PATCH v20 14/20] multi-process: add proxy communication functions Date: Tue, 19 Jan 2021 15:28:31 -0500 Message-Id: <9ee013428a49194a17f16952ad579f7e057b531c.1611081587.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-Originating-IP: [209.17.40.38] X-ClientProxiedBy: DM6PR01CA0007.prod.exchangelabs.com (2603:10b6:5:296::12) To BYAPR10MB2744.namprd10.prod.outlook.com (2603:10b6:a02:ae::18) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from jaraman-bur-1.us.oracle.com (209.17.40.38) by DM6PR01CA0007.prod.exchangelabs.com (2603:10b6:5:296::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 19 Jan 2021 20:29:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d1f22f5-eab7-43c4-c584-08d8bcb8e977 X-MS-TrafficTypeDiagnostic: BYAPR10MB3349: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ay5/3Tr5CmZ5ZGjUu0EgtNsybckk1pClp6qQm0/2XE/j1LGWmJjjOdTK06XZxZL0qrC/Gd6uFohn2EQfaLbrvdPa17URqlbPbbWqUY81KML4ooptRXnr6SN5JlU4oZKTIinTbCqDh58OihNFlVFmkB109UcJQxv7tfI9U86YFKaPDgr+V6+lmwd2QWp4awRlp3WaHTCzyIThNkf7rvdODpmn5wzFDkGAJrC6M93c6oJ5ippV6alcxgM4Wnmr1eBSdUpIezMzA4OazsVBBRgf44Qjl1HKfhRBVgo395wjcDsXYc4c3OxwaLd4wxNxnG1dG022P+SFxHLVfdHRm75J1KhDkTpRFBsfoLEfMb+Eh7Hcw+CQ/IyF20U/4CGlsqw/hqTPMO7Lev6bLczOGeXBjQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2744.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(366004)(136003)(346002)(376002)(7696005)(52116002)(2906002)(6486002)(5660300002)(7416002)(36756003)(66476007)(66556008)(478600001)(6916009)(956004)(2616005)(4326008)(66946007)(26005)(186003)(16526019)(8676002)(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-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d1f22f5-eab7-43c4-c584-08d8bcb8e977 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2744.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2021 20:29:25.2248 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /v0jf8dQ308Uo/ymnb0LISJNNTVOUAYQiT0h4Bs362cjof4K+UDTwCPa1kovoDUrl0ompj4Pp8oCohvpXUbyuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3349 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101190113 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 spamscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101190113 Received-SPF: pass client-ip=156.151.31.86; envelope-from=jag.raman@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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, swapnil.ingle@nutanix.com, 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, felipe@nutanix.com, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, alex.williamson@redhat.com, stefanha@redhat.com, thanos.makatos@nutanix.com, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Elena Ufimtseva Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Reviewed-by: Stefan Hajnoczi --- include/hw/remote/mpqemu-link.h | 4 ++++ hw/remote/mpqemu-link.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/hw/remote/mpqemu-link.h b/include/hw/remote/mpqemu-link.h index 6ee5bc5..1b35d40 100644 --- a/include/hw/remote/mpqemu-link.h +++ b/include/hw/remote/mpqemu-link.h @@ -15,6 +15,8 @@ #include "qemu/thread.h" #include "io/channel.h" #include "exec/hwaddr.h" +#include "io/channel-socket.h" +#include "hw/remote/proxy.h" #define REMOTE_MAX_FDS 8 @@ -68,6 +70,8 @@ typedef struct { bool mpqemu_msg_send(MPQemuMsg *msg, QIOChannel *ioc, Error **errp); bool mpqemu_msg_recv(MPQemuMsg *msg, QIOChannel *ioc, Error **errp); +uint64_t mpqemu_msg_send_and_await_reply(MPQemuMsg *msg, PCIProxyDev *pdev, + Error **errp); bool mpqemu_msg_valid(MPQemuMsg *msg); #endif diff --git a/hw/remote/mpqemu-link.c b/hw/remote/mpqemu-link.c index 4b25649..88d1f9b 100644 --- a/hw/remote/mpqemu-link.c +++ b/hw/remote/mpqemu-link.c @@ -182,6 +182,40 @@ fail: return ret; } +/* + * Send msg and wait for a reply with command code RET_MSG. + * Returns the message received of size u64 or UINT64_MAX + * on error. + * Called from VCPU thread in non-coroutine context. + * Used by the Proxy object to communicate to remote processes. + */ +uint64_t mpqemu_msg_send_and_await_reply(MPQemuMsg *msg, PCIProxyDev *pdev, + Error **errp) +{ + ERRP_GUARD(); + MPQemuMsg msg_reply = {0}; + uint64_t ret = UINT64_MAX; + + assert(!qemu_in_coroutine()); + + QEMU_LOCK_GUARD(&pdev->io_mutex); + if (!mpqemu_msg_send(msg, pdev->ioc, errp)) { + return ret; + } + + if (!mpqemu_msg_recv(&msg_reply, pdev->ioc, errp)) { + return ret; + } + + if (!mpqemu_msg_valid(&msg_reply)) { + error_setg(errp, "ERROR: Invalid reply received for command %d", + msg->cmd); + return ret; + } + + return msg_reply.data.u64; +} + bool mpqemu_msg_valid(MPQemuMsg *msg) { if (msg->cmd >= MPQEMU_CMD_MAX && msg->cmd < 0) {