From patchwork Thu Mar 7 07:21:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 10842279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09C7714DE for ; Thu, 7 Mar 2019 07:28:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCED528D98 for ; Thu, 7 Mar 2019 07:28:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA6F828C16; Thu, 7 Mar 2019 07:28:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4F94926253 for ; Thu, 7 Mar 2019 07:28:58 +0000 (UTC) Received: from localhost ([127.0.0.1]:46639 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1nSb-0006xS-GU for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 02:28:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1nLb-0001x9-ME for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:21:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1nLa-0004wx-T4 for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:21:43 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:55304) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1nLa-0004wh-KQ for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:21:42 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x277JL0q037943; Thu, 7 Mar 2019 07:21:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=1H9635U3ZeUQish7hUVDvcDGuquGhkpFSgr83dGpylM=; b=j5bNAHaXCTpCJwi+wSOGyZN3TrcIyQ/qICB7Jv6hNoTynIY1jdhHtcNI3bVK6A5l81ff vv0XeUA9KR1130X+cqaITRnnPRcuCOnlsUDtXvySE6cykRVu80RJi8iOHS/bP7+BRJKV zVSSAFv1Y5mhgNvOzfmh0hapwr6cvcbFx4UbR9Y46+XoSzjFiM1wBfrSesDLCOTiqU3L eNVL7jA9BO8TqLEwC9906JIMPJK6tcC9S4FUiqT5F9gtsTs60xmUxSiNUhB4ieK58zsk VBNA64dIQtZAVCTCXboFCfwwZBwTUdum9lZ9pNa05HwBi4llIzO3H2Mtn24SYUss2+gx Nw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2qyjfrr5bj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Mar 2019 07:21:35 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x277LZJ0004412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Mar 2019 07:21:35 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x277LYSH011298; Thu, 7 Mar 2019 07:21:34 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Mar 2019 23:21:34 -0800 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2019 23:21:32 -0800 Message-Id: <20190307072132.8630-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9187 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 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-1810050000 definitions=main-1903070053 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [multiprocess RFC PATCH 12/37] multi-process: remote process initialization X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: elena.ufimtseva@oracle.com, john.g.johnson@oracle.com, sstabellini@kernel.org, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Adds the handler to process message from QEMU, Initialize remote process main loop, handles SYNC_SYSMEM message by updating its "system_memory" container using shared file descriptors received from QEMU. Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman --- remote/remote-main.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index d5304fb..b15e299 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -23,6 +23,8 @@ */ #include +#include +#include #include "qemu/osdep.h" #include "qemu/module.h" @@ -31,12 +33,108 @@ #include "hw/boards.h" #include "hw/qdev-core.h" #include "qemu/main-loop.h" +#include "remote/memory.h" +#include "io/proxy-link.h" +#include "qapi/error.h" +#include "qemu/main-loop.h" +#include "sysemu/cpus.h" +#include "qemu-common.h" +#include "hw/pci/pci.h" +#include "qemu/thread.h" +#include "qemu/main-loop.h" +#include "qemu/config-file.h" +#include "sysemu/sysemu.h" +#include "block/block.h" + +static ProxyLinkState *proxy_link; +PCIDevice *remote_pci_dev; + +static void process_msg(GIOCondition cond) +{ + ProcMsg *msg = NULL; + Error *err = NULL; + + if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { + error_setg(&err, "socket closed, cond is %d", cond); + goto finalize_loop; + } + + msg = g_malloc0(sizeof(ProcMsg)); + + if (proxy_proc_recv(proxy_link, msg) < 0) { + error_setg(&err, "Failed to receive message"); + goto finalize_loop; + } + + switch (msg->cmd) { + case INIT: + break; + case CONF_WRITE: + break; + case CONF_READ: + break; + default: + error_setg(&err, "Unknown command"); + goto finalize_loop; + } + + g_free(msg); + + return; + +finalize_loop: + error_report_err(err); + g_free(msg); + proxy_link_finalize(proxy_link); + proxy_link = NULL; +} + +static void *remote_main_loop(void *data) +{ + while (1) { + qemu_mutex_lock_iothread(); + main_loop_wait(false); + qemu_mutex_unlock_iothread(); + } + + return NULL; +} int main(int argc, char *argv[]) { + Error *err = NULL; + QemuThread main_loop_thread; + module_call_init(MODULE_INIT_QOM); + bdrv_init_with_whitelist(); + + if (qemu_init_main_loop(&err)) { + error_report_err(err); + return -EBUSY; + } + + qemu_init_cpu_loop(); + + page_size_init(); + current_machine = MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACHINE))); + proxy_link = proxy_link_create(); + if (!proxy_link) { + printf("Could not create proxy link\n"); + return -1; + } + + proxy_link_set_sock(proxy_link, STDIN_FILENO); + proxy_link_set_callback(proxy_link, process_msg); + + qemu_thread_create(&main_loop_thread, "remote-main-loop", remote_main_loop, + NULL, QEMU_THREAD_DETACHED); + + start_handler(proxy_link); + + qemu_thread_cancel(&main_loop_thread); + return 0; }