From patchwork Fri Oct 12 23:48:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jag Raman X-Patchwork-Id: 10639375 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 42B65112B for ; Fri, 12 Oct 2018 23:50:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A4AB2B911 for ; Fri, 12 Oct 2018 23:50:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 089612B978; Fri, 12 Oct 2018 23:50:36 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64BC62B911 for ; Fri, 12 Oct 2018 23:50:35 +0000 (UTC) Received: from localhost ([::1]:43085 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7CU-0000yE-4V for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Oct 2018 19:50:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7Ax-0008C8-PK for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gB7Aq-0006UR-6i for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:48:57 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44370) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gB7Ao-0006SY-39 for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:48:52 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9CNiX9l146857 for ; Fri, 12 Oct 2018 23:48:48 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 : in-reply-to : references; s=corp-2018-07-02; bh=oDiuDVQAYJiZW9NgSobcgXaJZV0ThWTQvNMCxPBkwqI=; b=ZQRnzyeeOjbX8gdO8NmhIDpBp/5DUZHbPuRUmJCl2cE9NVe2Q6bLzJPG9esNXrKj+im8 nw14ANjbYtPAgwJHixeyOF4fxFREz5kbgtF48U2dUm87udYXRD5KN487vBWn20qbMKsa fxN9+25ZhF89dhgicKwn/o61oQc92lNMGq7EqIvfhGMwHxZa+S4kzZ/bFTRpY7XnK1B1 4ZXcQEBOMg/Mqw0qd7DNqCyFJ7f7BN11kpVZTUCUZig72AQp+ptNdAA+QdTw7eiqtWZl UB2Tom/px4NbTWVK2THKeGST1qNe4EQMxj37uxAeFOLY6JsAJ36tOZwHpg4NszsVNWRM dQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mxn0qnjq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Oct 2018 23:48:48 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9CNmlJn018531 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Oct 2018 23:48:47 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9CNmlgv023388 for ; Fri, 12 Oct 2018 23:48:47 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Oct 2018 23:48:47 +0000 From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2018 19:48:33 -0400 Message-Id: <11dd17274b257d93b2ccf94ce5d0c64081556920.1539387238.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=5900 definitions=9044 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 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-1807170000 definitions=main-1810120235 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v1 6/8] multi-process QEMU: 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, jag.raman@oracle.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 Initialize remote process main loop and add the message handling logic. Handle SYNC_SYSMEM message by updating its "system_memory" container using shared file descriptors received from QEMU. Signed-off-by: Jagannathan Raman --- hw/scsi/qemu-scsi-dev.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/hw/scsi/qemu-scsi-dev.c b/hw/scsi/qemu-scsi-dev.c index 21aba91..ede0c4b 100644 --- a/hw/scsi/qemu-scsi-dev.c +++ b/hw/scsi/qemu-scsi-dev.c @@ -23,22 +23,93 @@ */ #include +#include +#include #include "qemu/osdep.h" #include "qemu/module.h" #include "remote/pcihost.h" #include "remote/machine.h" #include "hw/boards.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" static RemMachineState *machine; +static ProxyLinkState *proxy_link; + +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)) { + 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; +} int main(int argc, char *argv[]) { + Error *err = NULL; + module_call_init(MODULE_INIT_QOM); machine = REMOTE_MACHINE(object_new(TYPE_REMOTE_MACHINE)); current_machine = MACHINE(machine); + if (qemu_init_main_loop(&err)) { + error_report_err(err); + return -EBUSY; + } + + qemu_init_cpu_loop(); + + page_size_init(); + + 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); + + start_handler(proxy_link); + return 0; }