From nobody Thu Nov 6 06:17:51 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1539388284514715.0834893702227; Fri, 12 Oct 2018 16:51:24 -0700 (PDT) Received: from localhost ([::1]:43087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7DA-0000zn-AJ for importer@patchew.org; Fri, 12 Oct 2018 19:51:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gB7Ax-0008C5-P5 for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:49:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gB7Aq-0006Ue-7c for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:48:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47372) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gB7Ao-0006Rg-2Z for qemu-devel@nongnu.org; Fri, 12 Oct 2018 19:48:52 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9CNj5JO088748 for ; Fri, 12 Oct 2018 23:48:47 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnprndsq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Oct 2018 23:48:47 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9CNmkWt009571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 12 Oct 2018 23:48:46 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9CNmk6Q008253 for ; Fri, 12 Oct 2018 23:48:46 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:46 +0000 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=30h0ylkHQCN/HgpExrF3BN7rAyMHeNAodBaK6l4TIHY=; b=m6tXanK9KiaYlueM8bHsdOgvHpr7iQ3yhsC7a+U/1lROJRSstWle/1bQRogH5hb4ID4v w24G/ZhmEKyggs+GcNeLqDLZYkb9T5FhtUC46L4h13S1hMHibg1uSFqOoMCYRzchXstX 0XZFD/G9aitGnf/GcPKy67RVnrIf0WygPLwV/jy2g/77nF9eLQNBRrxoJ9r+idDZfjYh ExImMkdz8E2Sut96powATbtYjDsEE2HAX2+JSTD4Bzd5/hH8+gRH3bgXa7o6cUkECDky YtRvK1JN8eQv0381SvecD96VwhfKEO3uSvOYBMCac26QPTtnF39ALixkgNankQVo3t1B vw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2018 19:48:31 -0400 Message-Id: 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=1 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: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v1 4/8] multi-process QEMU: setup a machine for remote device process 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" - remote-machine object sets up various subsystems of the remote device process. - PCI host bridge is instantiated - RAM, IO & PCI memory regions are initialized Signed-off-by: Jagannathan Raman --- exec.c | 3 +- hw/scsi/qemu-scsi-dev.c | 9 +++++ include/exec/address-spaces.h | 2 ++ include/remote/machine.h | 43 ++++++++++++++++++++++++ remote/Makefile.objs | 1 + remote/machine.c | 78 +++++++++++++++++++++++++++++++++++++++= ++++ 6 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 include/remote/machine.h create mode 100644 remote/machine.c diff --git a/exec.c b/exec.c index d0821e6..7dafc0b 100644 --- a/exec.c +++ b/exec.c @@ -192,7 +192,6 @@ typedef struct subpage_t { #define PHYS_SECTION_WATCH 3 =20 static void io_mem_init(void); -static void memory_map_init(void); static void tcg_commit(MemoryListener *listener); =20 static MemoryRegion io_mem_watch; @@ -3070,7 +3069,7 @@ static void tcg_commit(MemoryListener *listener) tlb_flush(cpuas->cpu); } =20 -static void memory_map_init(void) +void memory_map_init(void) { system_memory =3D g_malloc(sizeof(*system_memory)); =20 diff --git a/hw/scsi/qemu-scsi-dev.c b/hw/scsi/qemu-scsi-dev.c index 3cb8698..21aba91 100644 --- a/hw/scsi/qemu-scsi-dev.c +++ b/hw/scsi/qemu-scsi-dev.c @@ -26,10 +26,19 @@ =20 #include "qemu/osdep.h" #include "qemu/module.h" +#include "remote/pcihost.h" +#include "remote/machine.h" +#include "hw/boards.h" + +static RemMachineState *machine; =20 int main(int argc, char *argv[]) { module_call_init(MODULE_INIT_QOM); =20 + machine =3D REMOTE_MACHINE(object_new(TYPE_REMOTE_MACHINE)); + + current_machine =3D MACHINE(machine); + return 0; } diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h index db8bfa9..56a877b 100644 --- a/include/exec/address-spaces.h +++ b/include/exec/address-spaces.h @@ -33,6 +33,8 @@ MemoryRegion *get_system_memory(void); */ MemoryRegion *get_system_io(void); =20 +void memory_map_init(void); + extern AddressSpace address_space_memory; extern AddressSpace address_space_io; =20 diff --git a/include/remote/machine.h b/include/remote/machine.h new file mode 100644 index 0000000..92f9793 --- /dev/null +++ b/include/remote/machine.h @@ -0,0 +1,43 @@ +/* + * Remote machine configuration + * + * Copyright 2018, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef REMOTE_MACHINE_H +#define REMOTE_MACHINE_H + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "hw/boards.h" +#include "remote/pcihost.h" + +typedef struct RemMachineState { + MachineState parent_obj; + + RemPCIHost *host; +} RemMachineState; + +#define TYPE_REMOTE_MACHINE "remote-machine" +#define REMOTE_MACHINE(obj) \ + OBJECT_CHECK(RemMachineState, (obj), TYPE_REMOTE_MACHINE) + +#endif diff --git a/remote/Makefile.objs b/remote/Makefile.objs index 3072f95..e90ae20 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1 +1,2 @@ remote-obj-y +=3D pcihost.o +remote-obj-y +=3D machine.o diff --git a/remote/machine.c b/remote/machine.c new file mode 100644 index 0000000..9aea0ba --- /dev/null +++ b/remote/machine.c @@ -0,0 +1,78 @@ +/* + * Machine for remote device + * + * Copyright 2018, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include +#include + +#include "qemu/osdep.h" +#include "remote/pcihost.h" +#include "remote/machine.h" +#include "exec/address-spaces.h" +#include "exec/memory.h" +#include "exec/ioport.h" +#include "exec/ramlist.h" +#include "qemu/thread.h" +#include "qom/object.h" +#include "qemu/module.h" + +static void remote_machine_init(Object *obj) +{ + RemMachineState *s =3D REMOTE_MACHINE(obj); + RemPCIHost *rem_host; + MemoryRegion *system_memory, *system_io, *pci_memory; + + qemu_mutex_init(&ram_list.mutex); + + memory_map_init(); + + system_memory =3D get_system_memory(); + system_io =3D get_system_io(); + + pci_memory =3D g_new(MemoryRegion, 1); + memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); + + rem_host =3D REMOTE_HOST_DEVICE(qdev_create(NULL, TYPE_REMOTE_HOST_DEV= ICE)); + + rem_host->mr_pci_mem =3D pci_memory; + rem_host->mr_sys_mem =3D system_memory; + rem_host->mr_sys_io =3D system_io; + + s->host =3D rem_host; + + qdev_init_nofail(DEVICE(rem_host)); +} + +static const TypeInfo remote_machine =3D { + .name =3D TYPE_REMOTE_MACHINE, + .parent =3D TYPE_MACHINE, + .instance_size =3D sizeof(RemMachineState), + .instance_init =3D remote_machine_init, +}; + +static void remote_machine_register_types(void) +{ + type_register_static(&remote_machine); +} + +type_init(remote_machine_register_types); --=20 1.8.3.1