From patchwork Tue Jan 19 20:28:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jag Raman X-Patchwork-Id: 12030785 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 F2B69C433DB for ; Tue, 19 Jan 2021 20:51:41 +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 5D92822D08 for ; Tue, 19 Jan 2021 20:51:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D92822D08 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]:38136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1xyW-0008Kf-9T for qemu-devel@archiver.kernel.org; Tue, 19 Jan 2021 15:51:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1xet-0003Va-Gl for qemu-devel@nongnu.org; Tue, 19 Jan 2021 15:31:23 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:57810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1xer-0000dF-3d for qemu-devel@nongnu.org; Tue, 19 Jan 2021 15:31:23 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10JKODTi131286; Tue, 19 Jan 2021 20:31:15 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=KRxZkeXCGOGB5WtxKQKW3/m4SU9GrTHotzpmkhTwWDM=; b=SVzgdcWeylJdSTkwQzNKwa6+/iA/1bYRqR34rwSHQTZC/UXKxUGm8EMrNA2y7NScGIs0 X22B3CRJ2m8bAj20TlZgEyFC7U9PYbfsW15s2zvJbrXUYvOEewdRdfz4FIZ8voyzwSU+ hyZHK7ApHYLVubS6KOA1oC+tOip5HZtH25LmpAwlGYI58FA3cXVUdSk5of+I0xAaSbZd Ggef317nDKl25Vgktw315j1mFMucw6iQjJkkhNHU68y88Icz3OuYk9mJAnyk9MCLJ+XP sGwSitufEotgvOJ9josZFcMcQacXBaZ/aK78oen2Ie8csX3lI3Zvo24wf4lOlhYQe0KD 9A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 363r3ktxwr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jan 2021 20:31:15 +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 10JKPkEY176110; Tue, 19 Jan 2021 20:29:15 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2054.outbound.protection.outlook.com [104.47.36.54]) by aserp3020.oracle.com with ESMTP id 3661er94nc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Jan 2021 20:29:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iS1gT1/qRXWWWaV6OopRTVkh6p7hyHjuQQyStlg8o/9ED9V89p/0gmiBHMv+NWD2yMVlLcRf9jxtfCupFhSdSl0O+4XzV9sN0vey/JKUAXkFUg+gJG6+1o9mpYIUKgg6ylSYGrlXNxtwQ3sutvCHEpQLHFLJ8skV+zv0AJ/bV5vdIxvYJOcUM1Afire+oWhNKvduYT6xKdeLJuozK4XRNjsom73n5mfriyX+eNxhdbUS3v/1AMv4hiaZDDjF4nlevGyYuD0t1tfjpoGHIHbxihkQHDH+9boil6/rDRufrHywOsMg3RUt+AFDh189hYF5qgXYaUxmlUOIKN70jiBAwQ== 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=KRxZkeXCGOGB5WtxKQKW3/m4SU9GrTHotzpmkhTwWDM=; b=BKqGyL9/syz928DnQaHI2SGJmlRaYZeUnOzB6hExEfAQ3tiU038ZGXbzV8NNtYHR61Jf1O1a6OyewKzKgPAk3lMgpvANdBIImtb9CSF3yo0DqINDlgWUlo++4AdNm1aU1+fpV4R3nj8AK+YaOYAMPQrGofaYMV8vsgNZKbRGluHg5Qu0VCFWST5RQrXOvn0DsvLaSBuq+1iLtZz4IGWCY+kJplY7hFiHAwpt2Xw8PwcLNj8muPmVXzvB9j5cz8d14X3kre9i2sGE4zrmwfd4kBzBrXhQqN6RXvUFfECpz8ZeQrFWGyP6H70rvEgRaIRfWfqD/jlMa/EcmlYPKtAcpw== 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=KRxZkeXCGOGB5WtxKQKW3/m4SU9GrTHotzpmkhTwWDM=; b=qbnz6f3NOQwO5xP3HHZlZhtBIro+nOd1bUyOd1AqeYC83op00Qh4MROptsWQfnsn0yRbuXde2+B6eMgUykL/3zGIUHqgEj+CgZI0BLJplCNGEAx6LpeQ5hDdpwOKmkgwEke5MKnhH0JVMEhwHu6cfyuguvkbM8y2loAvmXuDV4o= 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 BYAPR10MB3351.namprd10.prod.outlook.com (2603:10b6:a03:14d::16) 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:13 +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:13 +0000 From: Jagannathan Raman To: qemu-devel@nongnu.org Subject: [PATCH v20 10/20] multi-process: Initialize message handler in remote device Date: Tue, 19 Jan 2021 15:28:27 -0500 Message-Id: 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:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95899e30-52e2-4e3e-6718-08d8bcb8e250 X-MS-TrafficTypeDiagnostic: BYAPR10MB3351: 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: ILlko1oB8K6LNsSQhjaei5hiWRr6m7dbDMtMh89ZnAWkoCrZ7prDFm8Z0Y0s0xzG3Chw2YXbW7sVjtdtYOdqPiFOXv84xbXdFtFoLZ8Y92uut7j0fzYEEJ1/uV2fLQiFnXlt7jV87NBiIzCtwqa/bs2JfvEWCX8h18mf5DrIj6DrNra07GvjdDIQ17w+fQFbcEIPLmjbhyIe+Y7lnNAuyQjf7g7sfukxWOZu0WiLRAcxWtJVni2QfNopGo2Et8p7A+StxLGCVO83nGRPpSJ8Ecrz7K/KWW5gesn/5mK94vokEFXgwOPn07LzINY5YA9x3MQlJmTzhTBX4BovKhLdAytx+Zh6oPHL++cNB6/qCIRQctpLzUUcws8COL4kz49AWYJ0avmSDWRI0byb2u8e3LWE4PnMuyrreSbgHAGKVpbze4Lk/KEOOD2DLJEZw3Yuph2cQuRvbC9VJZHdzQu9JoAFm4miESFXJ7LP6c3G9Bm2DrtTC+AxpZIY4SZNfv0lZNmy9CA3njx2xryjwsyVzA== 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:(396003)(39860400002)(366004)(136003)(376002)(346002)(86362001)(2906002)(6666004)(15650500001)(6916009)(36756003)(4326008)(8676002)(52116002)(66476007)(66556008)(316002)(8936002)(66946007)(6486002)(107886003)(956004)(5660300002)(478600001)(7696005)(16526019)(26005)(186003)(7416002)(2616005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?q?FSjsknd3JtmsrcW1el/7BqpVLN8n2l?= =?utf-8?q?tvtZ6faC5H+ze6BGUa8f8Amz3YMR++0fU7gBo/GN3lxtvPoGh2Pxjer2BlwufuYiP?= =?utf-8?q?/Bozbv8gEu3mLisA+60In0JH5sW4rN/HT80DrtysC/i8vp7WJiOHD34m2bpkyi848?= =?utf-8?q?RIWM8j8QX5+g3Ewdw5BF9eQVNzdwy3exQjUrFWRuqw+lhjpaKXuyl1mbHatBYXSel?= =?utf-8?q?VOPQUtYHtLiMddTq2hVEFqvi1r+nJcAqGDLpsTwueZlvKSr+8PYVA4ssWF/6afjMs?= =?utf-8?q?RuZ+ED/GgrgzNijoWACpbFRLIDWZShhQFa9q+ECzvQqXlLiR87S/3/pikCYMhbxQ2?= =?utf-8?q?g7VHbdzzRTewpg5Z128oi/TDJJD4pM3RGF7x7dqd6gsrekH6Obe1PBHEwFuaTPxJA?= =?utf-8?q?dxja8J61t3E9d1IZTKKA0Snc4ncwMjDsTTL1Y4CqX90ugo+Bje8eIrzYsKPxfFuqj?= =?utf-8?q?xRkGAKHcFS9tueT2tk1BcQ/mHP8P15v/VDcoDXAVb7kHlmk4YSmoWplHj84z/G/vh?= =?utf-8?q?NcxOpFPghuzcz/F5ReE7l/+sL0RAf/JieL5SDhjKmBCbkzPICgRwHfP5bkYA468ji?= =?utf-8?q?FDj7K35sMRqorsMtDD6zv8yvYJGI4QorauSzRVCWZBEYBtFgJ37bwIb58l0kB5/d9?= =?utf-8?q?gj7wGMjTa4AD4WVrVBxLGQazkdab0ftCLFS9vDo1i/imAJ8fNQEm5tBDubXy6vHBq?= =?utf-8?q?kS9w23ijmCS+13/606JEErPYIU9FiuNYqzV7UsYMw9DyFf8AKxGdJP7ji/Xe9LrW1?= =?utf-8?q?rNuL1C8l0JSciOns5laI8yN5Ou5Y35Yxo8hYHmLNceJ31YUd2BtGnYaazbXaTF6To?= =?utf-8?q?QfiapackxxQFMAHiUbm74O0IYdVAP+6T07eibfl7szn0/5MpZYKVTUZ5eBCEgsb7Q?= =?utf-8?q?vm2pSpUcO7VWPDHAE1zdOWMpoMZsSN5YiWNAH1DybBmpTfMNbn2UDdOe/4PSFac?= =?utf-8?q?=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95899e30-52e2-4e3e-6718-08d8bcb8e250 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:13.3637 (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: wOeEqWnSeVD4V5b+YUDDynKe/7PCZ8Z3+2B5x1fqsoD4fIL8s8kbuS/8xM6xEJ0YyumKtp+T03BOTvcbW/TESQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3351 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 bulkscore=0 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 mlxlogscore=999 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 phishscore=0 suspectscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101190113 Received-SPF: pass client-ip=141.146.126.78; envelope-from=jag.raman@oracle.com; helo=aserp2120.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 ae3172a..205b188 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3195,6 +3195,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)