From patchwork Fri Jan 29 16:46:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jag Raman X-Patchwork-Id: 12056111 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 854CCC433DB for ; Fri, 29 Jan 2021 17:12:53 +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 1D49464DE9 for ; Fri, 29 Jan 2021 17:12:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D49464DE9 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]:53992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5XKG-0004Ao-7O for qemu-devel@archiver.kernel.org; Fri, 29 Jan 2021 12:12:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5WxP-0007y7-3J for qemu-devel@nongnu.org; Fri, 29 Jan 2021 11:49:15 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:60918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5WxH-0006LW-AF for qemu-devel@nongnu.org; Fri, 29 Jan 2021 11:49:13 -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 10TGO0kR130096; Fri, 29 Jan 2021 16:48:57 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 : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=eUVxYFvu1Tu2Npba8+MmCoAp4tqpZfuy6yUJjiKwyRg=; b=qKHJgcWX2oi4f3ePFbOHz6X9HiaqU85TLCdixfBBSO7ADeE2Q4S8AinmQylV8kfIbTUm htUaEUOB4FI3YX2Up1RjVcCcVHDL+aSp4rAcbeoEydRUq9zFzr8k2n3KhCryg5rlU0pj ACX6enzOeAxlDeNSLqbduEuSbfwW4l/Oi8//RRrJUhoNkzuIcu+KLO320aaMRJbyTEEG 3+jhQ529j9R+B6lf0E2WOJ7RTmSs3XwOzU7alocoV9OdtnA7JDJ2ufooKE4qlASnyTQ+ 4kbVchm6QgC2DVACYWQQJmr1mi1R47Pa/ADDTQ0Ql4AsJFxa9phqFSxIT+FGF71lK6I0 tw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 368b7ra9rp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 16:48:56 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10TGOhnM083811; Fri, 29 Jan 2021 16:46:56 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2043.outbound.protection.outlook.com [104.47.74.43]) by aserp3020.oracle.com with ESMTP id 36ceug42fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 16:46:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JPtdHow3hi7yZ7shLinq057Q68Q9R+TfTCMTvOMNUzwheViKWHqyvCpzt+13T4F9Eco29uvPZ++jHU4qRe/THTxUr9aqzCxzw5QJhqurVjCc6he+IsDx9T77pgIPSRa6MrNPVRi9xhWRwN6FBMuS2Oi+nU6Cozn2V9atmn1O8icdLZN5beaFh5BKeAWVFoQvwb23s/R1G6ZcMd0wO4BK+cs1s3Shog4HjJh5BmpOJ+ErJCYoXIPaYy76+gpRkcSYirL0pyixChLZZ2kYNyzibWeHWEZtFuaNzRJWkTpvLm3x8vfQZQafbUbZCrv8MUcU5GbcIEeSLYNUq+j1bzkpPQ== 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=eUVxYFvu1Tu2Npba8+MmCoAp4tqpZfuy6yUJjiKwyRg=; b=eYcC2IMedpeD/KB10mHkObZf5y8c0WsdP5zWOMtulJETu6Vdyw1GQb6CdIzvfGp9K4kh8gRe3p+ENW2kJXu11D9wAiDqQHFvSF7uqOt87SD+/Ktchxq7GvEb+1Pk2RhgTPLIpPXw6FTLVThq6Id9bqIR+0+xYXrKW4MDKqxR8nQLyLf7jfHeLbJKIK4R3IjtjCysnp7v4//MWFkPZY3O0/kR/0AyCpVkWc2Sg1MTII28ZfR3Cy6KO3KAhYI1K2kp8scEq2fmMAHrfvtD0rrfes1h3voQUeOQZpr+ghoYG3kCYMrsXXvzx+NuqeAjRCOpgiqDIdmhXKJCCSmf8oNvSQ== 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=eUVxYFvu1Tu2Npba8+MmCoAp4tqpZfuy6yUJjiKwyRg=; b=LVLjGdA0osLru6iVZaifsfFeBSfvB/uVAbuOGf96u+KJOVVA59sQSWKSt0k25yFJ6/FgXcYy0NNSzhu0jaO+KHv+FpmKUdWWmg029oijpUZnd52/J9E3XNUcbkGx6rjbUEiDn0DvqzdkgtbLxcQqIiIKX5RV1LhlMvNGRYq6knw= 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 SJ0PR10MB4671.namprd10.prod.outlook.com (2603:10b6:a03:2d5::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.19; Fri, 29 Jan 2021 16:46:53 +0000 Received: from BYAPR10MB2744.namprd10.prod.outlook.com ([fe80::74a8:e88d:b89e:bf2d]) by BYAPR10MB2744.namprd10.prod.outlook.com ([fe80::74a8:e88d:b89e:bf2d%4]) with mapi id 15.20.3805.020; Fri, 29 Jan 2021 16:46:53 +0000 From: Jagannathan Raman To: qemu-devel@nongnu.org Subject: [PATCH v21 10/20] multi-process: Initialize message handler in remote device Date: Fri, 29 Jan 2021 11:46:11 -0500 Message-Id: <99d38d8b93753a6409ac2340e858858cda59ab1b.1611938319.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-Originating-IP: [209.17.40.45] X-ClientProxiedBy: BYAPR05CA0053.namprd05.prod.outlook.com (2603:10b6:a03:74::30) 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.45) by BYAPR05CA0053.namprd05.prod.outlook.com (2603:10b6:a03:74::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.8 via Frontend Transport; Fri, 29 Jan 2021 16:46:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f004ff10-2eaf-45a0-1d70-08d8c4757b4a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4671: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cqkr8QTwj1DTLf3AwMR+7RJ/e1dZDpaYxz5R5qXpCKczlf0ITskyoL6uAk3434YNusA3v2jJs8ANIsyRhm1mlCNXjTejmDqVN4V3HzdSdTxfALPI5DIFzZIsCeemfpAK9HYwG5ILChPH0mWlhr7U0iR0G2yn6x6caaAF03pZIuydEI9ykeC9+oR9OezbZRQMkTtOoiaOfMYciz5Bpp5znYDXySYMMQXlLaqxsGZUv6+06v7WjLjIwfuYoD+vsm82FP6z7FtVH33QCPCDCAs1JCI0SMXgv4eWEzkKlLJ54myytKfSgQFMvn6KKCQAB1HBL8cQsqnbhkE0KZSVGWiri/O7q+XylIHDUvUeA6wbAkx76U0974vvAFg6zPpQJxOudl9GE1+j5fut22QtEdrwnPz0ltpjxhKr7oL6P305bT/k98xE6W0Gx8+FLRhj9PFTtrHz9Quu+5YSsH5aO9fRVF4dqMQk8Hawt3iYA4kwhJ4ASIkBTpOKWTzMat9dJJd24LhkHeyWNJgyzm2TyHBYEQ== 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:(136003)(366004)(376002)(39860400002)(396003)(346002)(956004)(2616005)(4326008)(8676002)(6666004)(66556008)(478600001)(86362001)(36756003)(7416002)(107886003)(316002)(6916009)(2906002)(66476007)(16526019)(66946007)(15650500001)(7696005)(52116002)(6486002)(186003)(8936002)(5660300002)(83380400001)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?cBkkD4x6iWQX9bk2PWSKkxMcK9GdEL?= =?utf-8?q?LpOUBBJBBGBqvRMAZtmH54vct0zbknxOWCOqenjoYktd4LattHnbucklkQAgkPZrp?= =?utf-8?q?DhIMavI9o/BbCITsMkogaDkDzKzvbPi/OdJ9QIJh8VvxdNU5af5susrSuBjCOZKM/?= =?utf-8?q?znJ+4xhntM9XRkB2HzElrffB0ILy6RiVlQap6cF9anq6Wxu6agNKGRDZBXy2I87Zu?= =?utf-8?q?l7hzX1lsWVhlN9sD1AcIzKAS7tqISvk4jH7GGlPqVZjXD9IH+vUgdl4XnsO6GSxPu?= =?utf-8?q?002guOaDYM8wFqbXXGanL/XahNiOhMCUzuvHuX0Px+/MQ/ahHMfiCJdnrRHIlKBHk?= =?utf-8?q?uOgQUoUYs1N0t5JtP+Xj9nM7Qk5TKbRbH4f0ityKmIhacwUUl9syZX0SA8fcK9KcT?= =?utf-8?q?go6rbYpc+WzYqEwRYqRuX1CBkmnxBVS9jPle6xGCZOMo2EpESmk0/DLKzCV+FUTra?= =?utf-8?q?LSA0G/lK/OBAG4g2Kx8AwS0C8pEbAcw5f8f5NGSCzWL1QtmNA7h9Jxi//e0GhFhaW?= =?utf-8?q?mxxFOvvmCpGx7f8MwS/LYN6oF9A41liq2hNRcxq5HQ4kLmZr65MEZrcN/b8p1IDdO?= =?utf-8?q?V/6fk6Ivw/IC3mdHgkgfgwNxVCZFUjJOqNTCFatqQjxnX5PVMJvokXZ9wXHnZuDKf?= =?utf-8?q?KWp4oAc4DsNJ+xuSzBiCyzN5jN+SjC8/fZk3yNm4fIT5Pl2yPcQ16PVI8KrLoOyym?= =?utf-8?q?epd7NNevE06EfZqQ+55UVthc0FEqq/+9Qmo5PLkuDs+oqnkDzlxOecP3d1wiQvbWZ?= =?utf-8?q?BbJhUzrtqLslFB3Vj8OWjr1mS/0YzKqLQzvKj95TtFwjIg3qBIMGUARQqMWon4Jhx?= =?utf-8?q?/QxAqt4053I3hDOu3FQiq4SeqMkekeBDBQ0G1yw2jztRQna1Z/OGrB4eZP8zq2Cxb?= =?utf-8?q?mfsKfboQ3f1SV+W2txcVYdx7WGV3TIA/BwekQptDzJaE8A7CkKrIFN0DThr4eKaXV?= =?utf-8?q?FZ8foH2e6kH4wXHLzBrEVNpRmhYNjCMY0zK616bOUmV3HkEpguSoVFNd1RSgwQVGM?= =?utf-8?q?IfFZP9i0oeTVjjrLys?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f004ff10-2eaf-45a0-1d70-08d8c4757b4a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2744.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 16:46:53.3516 (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: Vbzd1yWnkk+y2LDSINMF34xzo9U6GyyojhWsr7k8H9GL8K54u/qANd2lvuKyi5IWBu8S/J6fCNqqSOQgA1yvaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4671 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9878 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101290081 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9878 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 mlxscore=0 clxscore=1015 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101290081 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" Initializes the message handler function in the remote process. It is called whenever there's an event pending on QIOChannel that registers this function. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Stefan Hajnoczi --- include/hw/remote/machine.h | 9 +++++++ hw/remote/message.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + hw/remote/meson.build | 1 + 4 files changed, 68 insertions(+) create mode 100644 hw/remote/message.c diff --git a/include/hw/remote/machine.h b/include/hw/remote/machine.h index bdfbca4..b92b2ce 100644 --- a/include/hw/remote/machine.h +++ b/include/hw/remote/machine.h @@ -14,6 +14,7 @@ #include "qom/object.h" #include "hw/boards.h" #include "hw/pci-host/remote.h" +#include "io/channel.h" struct RemoteMachineState { MachineState parent_obj; @@ -21,7 +22,15 @@ struct RemoteMachineState { RemotePCIHost *host; }; +/* Used to pass to co-routine device and ioc. */ +typedef struct RemoteCommDev { + PCIDevice *dev; + QIOChannel *ioc; +} RemoteCommDev; + #define TYPE_REMOTE_MACHINE "x-remote-machine" OBJECT_DECLARE_SIMPLE_TYPE(RemoteMachineState, REMOTE_MACHINE) +void coroutine_fn mpqemu_remote_msg_loop_co(void *data); + #endif diff --git a/hw/remote/message.c b/hw/remote/message.c new file mode 100644 index 0000000..36e2d4f --- /dev/null +++ b/hw/remote/message.c @@ -0,0 +1,57 @@ +/* + * Copyright © 2020, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL-v2, version 2 or later. + * + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "hw/remote/machine.h" +#include "io/channel.h" +#include "hw/remote/mpqemu-link.h" +#include "qapi/error.h" +#include "sysemu/runstate.h" + +void coroutine_fn mpqemu_remote_msg_loop_co(void *data) +{ + g_autofree RemoteCommDev *com = (RemoteCommDev *)data; + PCIDevice *pci_dev = NULL; + Error *local_err = NULL; + + assert(com->ioc); + + pci_dev = com->dev; + for (; !local_err;) { + MPQemuMsg msg = {0}; + + if (!mpqemu_msg_recv(&msg, com->ioc, &local_err)) { + break; + } + + if (!mpqemu_msg_valid(&msg)) { + error_setg(&local_err, "Received invalid message from proxy" + "in remote process pid="FMT_pid"", + getpid()); + break; + } + + switch (msg.cmd) { + default: + error_setg(&local_err, + "Unknown command (%d) received for device %s" + " (pid="FMT_pid")", + msg.cmd, DEVICE(pci_dev)->id, getpid()); + } + } + + if (local_err) { + error_report_err(local_err); + qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); + } else { + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } +} diff --git a/MAINTAINERS b/MAINTAINERS index ceabcfb..619d743 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3194,6 +3194,7 @@ F: hw/remote/machine.c F: include/hw/remote/machine.h F: hw/remote/mpqemu-link.c F: include/hw/remote/mpqemu-link.h +F: hw/remote/message.c Build and test automation ------------------------- diff --git a/hw/remote/meson.build b/hw/remote/meson.build index a2b2fc0..9f5c57f 100644 --- a/hw/remote/meson.build +++ b/hw/remote/meson.build @@ -2,5 +2,6 @@ remote_ss = ss.source_set() remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('machine.c')) remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('mpqemu-link.c')) +remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('message.c')) softmmu_ss.add_all(when: 'CONFIG_MULTIPROCESS', if_true: remote_ss)