From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166180; cv=none; d=zohomail.com; s=zohoarc; b=JTv2en8U/381YH71QZ6B0JfZ6+BCX91EXdCxJHQT7eRWQdZHlA1DQ6qe9vt866HV0wgIUGftpXlUNlIrUcizpr0G8Eu6ET1dy50ZPeLVm3uWcuCrIoK/1jFb7gQRE5vgBiVsZmQbhG02ANoW7rRZ08pDB5Wpxtftft1X49gEfH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166180; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BFB0jbBLAAhWRdpEaUJINzAaXAPaQUAvTvTVo8clZIY=; b=H3JucUUZFrw9twP7MnrECKwvfqHzR9YKlrzds/XV8sxZJLy6AorHEma/gL8nV/wpHtMyR68b9MuGgbk9wTUSMmEW1K2EpyzxBjnPiLGAcMxcAHKaN6JiZDbgGe7pcQcKsJ1UHBLX6nIhPRSroOh3PhELLQQwbg8vACf3Ww7GELk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166180867331.96129109798824; Mon, 6 Apr 2020 02:43:00 -0700 (PDT) Received: from localhost ([::1]:57132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOHT-0003B4-I2 for importer@patchew.org; Mon, 06 Apr 2020 05:42:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44049) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGR-0001Q1-5B for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGP-000229-9x for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:54 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34458) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGN-00020Q-Kn for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:53 -0400 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 0369dxfb089554; Mon, 6 Apr 2020 09:41:36 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 306hnqwtvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:36 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cfuK092164; Mon, 6 Apr 2020 09:41:36 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 3073spk5c9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:35 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fXH8013456; Mon, 6 Apr 2020 09:41:33 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:32 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=BFB0jbBLAAhWRdpEaUJINzAaXAPaQUAvTvTVo8clZIY=; b=Ypabdv7YxxaSf2SQug28+QleX7R/wSWqPuiLhaV6cCuIUhKieVu6hSq4oZ8IYkSt+LxQ hAlRnclAB3wese32IC+i/p1zNLfqOCZtODM/jTq3tTlZqCqqOn+8ZrvXcW+3yYJVRfVU yaAl1oo5UpaLZOJKbZ5vQFunLH4sRqn61zPlXkiGOroZNALe5SlyYd55wWEPZE/sRuWb +6RPaTRlCQkpFpJDvMgzIzhPxtFu9RnjcDdPi7xgYgHo1U90u9sPvfPikmcXJkbupTpc x4D/FHMlttCatRa9rpa4oPzJGdfzvVITH0+nA8ilZXlnkcjTciGkUhzpig5NvV6KnfJv 2A== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 01/36] memory: alloc RAM from file at offset Date: Mon, 6 Apr 2020 02:40:51 -0700 Message-Id: <8eb137b1c387aad37e85eaa251a6da90c50306e2.1586165555.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=3 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=3 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Allow RAM MemoryRegion to be created from an offset in a file, instead of allocating at offset of 0 by default. This is needed to synchronize RAM between QEMU & remote process. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva Reviewed-by: Dr. David Alan Gilbert --- exec.c | 11 +++++++---- include/exec/ram_addr.h | 2 +- include/qemu/mmap-alloc.h | 3 ++- memory.c | 2 +- util/mmap-alloc.c | 7 ++++--- util/oslib-posix.c | 2 +- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/exec.c b/exec.c index de9d949902..d99bfef193 100644 --- a/exec.c +++ b/exec.c @@ -1801,6 +1801,7 @@ static void *file_ram_alloc(RAMBlock *block, ram_addr_t memory, int fd, bool truncate, + off_t offset, Error **errp) { void *area; @@ -1851,7 +1852,8 @@ static void *file_ram_alloc(RAMBlock *block, } =20 area =3D qemu_ram_mmap(fd, memory, block->mr->align, - block->flags & RAM_SHARED, block->flags & RAM_PME= M); + block->flags & RAM_SHARED, block->flags & RAM_PME= M, + offset); if (area =3D=3D MAP_FAILED) { error_setg_errno(errp, errno, "unable to map backing store for guest RAM"); @@ -2271,7 +2273,7 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp, bool shared) #ifdef CONFIG_POSIX RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, uint32_t ram_flags, int fd, - Error **errp) + off_t offset, Error **errp) { RAMBlock *new_block; Error *local_err =3D NULL; @@ -2316,7 +2318,8 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, Mem= oryRegion *mr, new_block->used_length =3D size; new_block->max_length =3D size; new_block->flags =3D ram_flags; - new_block->host =3D file_ram_alloc(new_block, size, fd, !file_size, er= rp); + new_block->host =3D file_ram_alloc(new_block, size, fd, !file_size, of= fset, + errp); if (!new_block->host) { g_free(new_block); return NULL; @@ -2346,7 +2349,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, M= emoryRegion *mr, return NULL; } =20 - block =3D qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, errp); + block =3D qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, 0, errp); if (!block) { if (created) { unlink(mem_path); diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 5e59a3d8d7..1b9f489ff0 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -121,7 +121,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, Mem= oryRegion *mr, Error **errp); RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, uint32_t ram_flags, int fd, - Error **errp); + off_t offset, Error **errp); =20 RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr, Error **errp); diff --git a/include/qemu/mmap-alloc.h b/include/qemu/mmap-alloc.h index e786266b92..4f579858bc 100644 --- a/include/qemu/mmap-alloc.h +++ b/include/qemu/mmap-alloc.h @@ -25,7 +25,8 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared, - bool is_pmem); + bool is_pmem, + off_t start); =20 void qemu_ram_munmap(int fd, void *ptr, size_t size); =20 diff --git a/memory.c b/memory.c index 601b749906..f5fec476b7 100644 --- a/memory.c +++ b/memory.c @@ -1596,7 +1596,7 @@ void memory_region_init_ram_from_fd(MemoryRegion *mr, mr->destructor =3D memory_region_destructor_ram; mr->ram_block =3D qemu_ram_alloc_from_fd(size, mr, share ? RAM_SHARED : 0, - fd, &err); + fd, 0, &err); mr->dirty_log_mask =3D tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; if (err) { mr->size =3D int128_zero(); diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 27dcccd8ec..a28f7025f0 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -86,7 +86,8 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared, - bool is_pmem) + bool is_pmem, + off_t start) { int flags; int map_sync_flags =3D 0; @@ -147,7 +148,7 @@ void *qemu_ram_mmap(int fd, offset =3D QEMU_ALIGN_UP((uintptr_t)guardptr, align) - (uintptr_t)guar= dptr; =20 ptr =3D mmap(guardptr + offset, size, PROT_READ | PROT_WRITE, - flags | map_sync_flags, fd, 0); + flags | map_sync_flags, fd, start); =20 if (ptr =3D=3D MAP_FAILED && map_sync_flags) { if (errno =3D=3D ENOTSUP) { @@ -172,7 +173,7 @@ void *qemu_ram_mmap(int fd, * we will remove these flags to handle compatibility. */ ptr =3D mmap(guardptr + offset, size, PROT_READ | PROT_WRITE, - flags, fd, 0); + flags, fd, start); } =20 if (ptr =3D=3D MAP_FAILED) { diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 4dd6d7d4b4..0671dc7964 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -209,7 +209,7 @@ void *qemu_memalign(size_t alignment, size_t size) void *qemu_anon_ram_alloc(size_t size, uint64_t *alignment, bool shared) { size_t align =3D QEMU_VMALLOC_ALIGN; - void *ptr =3D qemu_ram_mmap(-1, size, align, shared, false); + void *ptr =3D qemu_ram_mmap(-1, size, align, shared, false, 0); =20 if (ptr =3D=3D MAP_FAILED) { return NULL; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166957; cv=none; d=zohomail.com; s=zohoarc; b=X+Br8atByyNpsD9FYdgxdZ6lbPZCLBrqi2YuhdU5sIoa6fNcarQNpK88+Vh1uIq7A2vv9Tb/He06ZgBzWacDMjBFOrnBGgVFOE/qLpkpbjthd8GUuPzNKBDExu8Gfss8qM98zUKuqz3/rgzLRWHkX0SIk8egU8gSOxTUKlCw/z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166957; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vo9XVqRjUwLdxamis5vtm7R1B8Mjc6k73iBRSiBen4E=; b=ZiDbNwRgmyQWBPaokTjq10XKFp/tWTcqTBEOs+/C4WvqVi4+9midjnMXhIl+MlRu9CEzD1xSrmClMPYZgCFxqeIx+5wvXrjJLROtadHRTjuW4TuvSizRjxfieCQuWETTyr8WH0cgKSGfNcScNMXgGpYOn1vofFOcGr4FOvh8jBw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166957037715.697676018469; Mon, 6 Apr 2020 02:55:57 -0700 (PDT) Received: from localhost ([::1]:57584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOTz-00017Y-O3 for importer@patchew.org; Mon, 06 Apr 2020 05:55:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44899) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOIE-0005aZ-A7 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOIC-0003Z0-Qy for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:46 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOIC-0003Y4-If for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:44 -0400 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 0369dtf4089528; Mon, 6 Apr 2020 09:43:37 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 306hnqwu5g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:43:37 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369bLHC056293; Mon, 6 Apr 2020 09:41:37 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 3073qcnbwu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:37 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fZbY013461; Mon, 6 Apr 2020 09:41:35 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:34 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=vo9XVqRjUwLdxamis5vtm7R1B8Mjc6k73iBRSiBen4E=; b=xKN+2vBvhNqIovOWgZc830JzkIabzB6WoCHUoaeutPeHsL5IWqrnGFv+J9SlqAEuPyy1 1L33ZlWCiWL8xn6olSL8hx58vtq8II7uGGTl+T1X7/XjG05cRAmqFFVbdPZzcHrwfoar GrBHFETFrK3WVCD5EaJncMV0tv0ko4eSGmZSDECjs5zE7hBojj5AwfzFOmMYaOaN54OW YG+W5TlH+rIjqu4HkD1QWVH/7ppRDtAZpRxiBBmmK4jkrmZtINakRNeL4WrgupU0oeJq NiWETFcpjXycqYO9/9/yJsYfnjyrwHxWZg+CiRv966hVJJBdQuDKE0j12iLzDFKqkHwF 6A== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 02/36] multi-process: Refactor machine_init and exit notifiers Date: Mon, 6 Apr 2020 02:40:52 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Relocate machine_int and exit notifiers into common code Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- Makefile.objs | 1 + include/sysemu/sysemu.h | 2 ++ softmmu/vl.c | 40 ----------------------- stubs/machine-init-done.c | 12 +++++++ util/machine-notify.c | 67 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 82 insertions(+), 40 deletions(-) create mode 100644 util/machine-notify.c diff --git a/Makefile.objs b/Makefile.objs index a7c967633a..bfb9271862 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -79,6 +79,7 @@ qemu-seccomp.o-libs :=3D $(SECCOMP_LIBS) common-obj-$(CONFIG_FDT) +=3D device_tree.o =20 common-obj-y +=3D qapi/ +common-obj-y +=3D util/machine-notify.o =20 endif # CONFIG_SOFTMMU =20 diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index ef81302e1a..2438dd7bea 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -17,11 +17,13 @@ extern bool qemu_uuid_set; =20 void qemu_add_exit_notifier(Notifier *notify); void qemu_remove_exit_notifier(Notifier *notify); +void qemu_run_exit_notifiers(void); =20 extern bool machine_init_done; =20 void qemu_add_machine_init_done_notifier(Notifier *notify); void qemu_remove_machine_init_done_notifier(Notifier *notify); +void qemu_run_machine_init_done_notifiers(void); =20 extern int autostart; =20 diff --git a/softmmu/vl.c b/softmmu/vl.c index 814537bb42..380aefd56e 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -173,12 +173,6 @@ int icount_align_option; QemuUUID qemu_uuid; bool qemu_uuid_set; =20 -static NotifierList exit_notifiers =3D - NOTIFIER_LIST_INITIALIZER(exit_notifiers); - -static NotifierList machine_init_done_notifiers =3D - NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); - bool xen_allowed; uint32_t xen_domid; enum xen_mode xen_mode =3D XEN_EMULATE; @@ -2326,21 +2320,6 @@ static MachineClass *machine_parse(const char *name,= GSList *machines) return mc; } =20 -void qemu_add_exit_notifier(Notifier *notify) -{ - notifier_list_add(&exit_notifiers, notify); -} - -void qemu_remove_exit_notifier(Notifier *notify) -{ - notifier_remove(notify); -} - -static void qemu_run_exit_notifiers(void) -{ - notifier_list_notify(&exit_notifiers, NULL); -} - static const char *pid_file; static Notifier qemu_unlink_pidfile_notifier; =20 @@ -2353,25 +2332,6 @@ static void qemu_unlink_pidfile(Notifier *n, void *d= ata) =20 bool machine_init_done; =20 -void qemu_add_machine_init_done_notifier(Notifier *notify) -{ - notifier_list_add(&machine_init_done_notifiers, notify); - if (machine_init_done) { - notify->notify(notify, NULL); - } -} - -void qemu_remove_machine_init_done_notifier(Notifier *notify) -{ - notifier_remove(notify); -} - -static void qemu_run_machine_init_done_notifiers(void) -{ - machine_init_done =3D true; - notifier_list_notify(&machine_init_done_notifiers, NULL); -} - static const QEMUOption *lookup_opt(int argc, char **argv, const char **poptarg, int *poptind) { diff --git a/stubs/machine-init-done.c b/stubs/machine-init-done.c index cd8e81392d..fc8be8cead 100644 --- a/stubs/machine-init-done.c +++ b/stubs/machine-init-done.c @@ -3,6 +3,18 @@ =20 bool machine_init_done =3D true; =20 +static NotifierList machine_init_done_notifiers =3D + NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); + void qemu_add_machine_init_done_notifier(Notifier *notify) { } + +void qemu_remove_machine_init_done_notifier(Notifier *notify) +{ +} + +void qemu_run_machine_init_done_notifiers(void) +{ + notifier_list_notify(&machine_init_done_notifiers, NULL); +} diff --git a/util/machine-notify.c b/util/machine-notify.c new file mode 100644 index 0000000000..63fc59a5a6 --- /dev/null +++ b/util/machine-notify.c @@ -0,0 +1,67 @@ +/* + * Machine notifiers. + * + * Copyright (c) 2003-2008 Fabrice Bellard + * + * 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 "qemu/osdep.h" +#include "qemu/notify.h" +#include "sysemu/sysemu.h" + +static NotifierList machine_init_done_notifiers =3D + NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); + +static NotifierList exit_notifiers =3D + NOTIFIER_LIST_INITIALIZER(exit_notifiers); + +void qemu_add_machine_init_done_notifier(Notifier *notify) +{ + notifier_list_add(&machine_init_done_notifiers, notify); + if (machine_init_done) { + notify->notify(notify, NULL); + } +} + +void qemu_remove_machine_init_done_notifier(Notifier *notify) +{ + notifier_remove(notify); +} + +void qemu_run_machine_init_done_notifiers(void) +{ + machine_init_done =3D true; + notifier_list_notify(&machine_init_done_notifiers, NULL); +} + +void qemu_add_exit_notifier(Notifier *notify) +{ + notifier_list_add(&exit_notifiers, notify); +} + +void qemu_remove_exit_notifier(Notifier *notify) +{ + notifier_remove(notify); +} + +void qemu_run_exit_notifiers(void) +{ + notifier_list_notify(&exit_notifiers, NULL); +} --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166858; cv=none; d=zohomail.com; s=zohoarc; b=TYfQBH+8B5GpuGppYT76Nz0pmdZD0G2cXts2zGcwhcWtO5u4wpji84Goft+YQcRkfnH049WBzXoLm0RoQsVdeWtN+PjVZTptUwnvdvy/c9WKCQOv0ka39X058IXpu1hJpIRO0Df616nEUM5JcyaUD284pUKTjFvMN3dMBlzmuw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166858; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w4L9woYyKs+2bi6PufE8NQwrRdD1WvhFBFES4xpZX6A=; b=DDr3uKZuoWNWkPOiifFUOuLGuixEQpHC7jO0vmrmcR6p5xJlbQIs8CipJl42TLmPQ8STqDnsw0fBgMVTU+NH3fLY0tLGCtZ0dRzNLGhek18QSSNtwhKkgcxqHA/UAN78mcaK+W9akL0S+5OrYlhmX9YlB7U81+zKN9T2djuG5fg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166858985560.3315039636832; Mon, 6 Apr 2020 02:54:18 -0700 (PDT) Received: from localhost ([::1]:57536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOSP-0007HY-N5 for importer@patchew.org; Mon, 06 Apr 2020 05:54:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44916) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOIK-0005fl-AE for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOII-0003d0-OC for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:52 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46692) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOII-0003cH-Fq for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:50 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369gtkH028646; Mon, 6 Apr 2020 09:43:39 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 306jvmwrbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:43:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369bLJ5056323; Mon, 6 Apr 2020 09:41:38 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 3073qcnby8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:38 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369faQi006721; Mon, 6 Apr 2020 09:41:37 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:36 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=wWLay3pm8AxpvecMxv9+x86nn94U64jdP+vfUO8kaz8=; b=b9kAYaqNiWK/ekjYBp3vmvJ8Cyel5VjGwGgaT2Sk0TG4+wmL+GFk77b/gR7BLktNCec3 vFL/64AcR3D6kv+2Cza10mXJNk+9+rjyAKWzIR6kx+B7TpoxYpdhP/30Xw5NshKbje+d xnavkTdT7Eqmf5vb+YrV/6d/yBUF8tiaNB59Hq/i2V5a5OQwk+wZM+cpsGcF/4MyJ2r8 OoHQgnIAYXo4a/H/J/lXMLYGILpwNiEnyl0YfZSv9RFAMMOuawv/LOB/ELYNYKbyGiai xhI6Nsd8qeTA1+Y8uKkBgsqac27weq0jhgDxFmlDjKlWr92oeNPS+PFYGbAsscvF9eZx +A== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 03/36] command-line: refractor parser code Date: Mon, 6 Apr 2020 02:40:53 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id 0369gtkH028646 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Refactor command-line parser code so that it could be used by other processes as well. Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- MAINTAINERS | 2 + Makefile.objs | 2 + include/qemu-parse.h | 42 ++++++++++++++++++++ qemu-parse.c | 93 ++++++++++++++++++++++++++++++++++++++++++++ softmmu/vl.c | 84 +-------------------------------------- 5 files changed, 140 insertions(+), 83 deletions(-) create mode 100644 include/qemu-parse.h create mode 100644 qemu-parse.c diff --git a/MAINTAINERS b/MAINTAINERS index b5c86ec494..611d9a64b0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2003,6 +2003,8 @@ F: tests/test-keyval.c F: tests/test-qemu-opts.c F: util/keyval.c F: util/qemu-option.c +F: include/qemu-parse.h +F: qemu-parse.c =20 Coverity model M: Markus Armbruster diff --git a/Makefile.objs b/Makefile.objs index bfb9271862..f29c60c59d 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -78,6 +78,8 @@ qemu-seccomp.o-libs :=3D $(SECCOMP_LIBS) =20 common-obj-$(CONFIG_FDT) +=3D device_tree.o =20 +common-obj-y +=3D qemu-parse.o + common-obj-y +=3D qapi/ common-obj-y +=3D util/machine-notify.o =20 diff --git a/include/qemu-parse.h b/include/qemu-parse.h new file mode 100644 index 0000000000..156b238db6 --- /dev/null +++ b/include/qemu-parse.h @@ -0,0 +1,42 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef VL_H +#define VL_H + +#include "qemu/osdep.h" +#include "qemu-common.h" + +/***********************************************************/ +/* QEMU Block devices */ + +#define HD_OPTS "media=3Ddisk" +#define CDROM_OPTS "media=3Dcdrom" +#define FD_OPTS "" +#define PFLASH_OPTS "" +#define MTD_OPTS "" +#define SD_OPTS "" + +#define HAS_ARG 0x0001 + +typedef struct QEMUOption { + const char *name; + int flags; + int index; + uint32_t arch_mask; +} QEMUOption; + +const QEMUOption *lookup_opt(int argc, char **argv, const char **poptarg, + int *poptind); + +int drive_init_func(void *opaque, QemuOpts *opts, Error **errp); + +int device_init_func(void *opaque, QemuOpts *opts, Error **errp); + +#endif /* VL_H */ + diff --git a/qemu-parse.c b/qemu-parse.c new file mode 100644 index 0000000000..2535374fdd --- /dev/null +++ b/qemu-parse.c @@ -0,0 +1,93 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "sysemu/blockdev.h" +#include "sysemu/arch_init.h" +#include "qemu/option.h" +#include "qemu-options.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "monitor/qdev.h" +#include "qom/object.h" +#include "qemu-parse.h" + +/***********************************************************/ +/* QEMU Block devices */ + +static const QEMUOption qemu_options[] =3D { + { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, +#define QEMU_OPTIONS_GENERATE_OPTIONS +#include "qemu-options-wrapper.h" + { NULL }, +}; + +const QEMUOption *lookup_opt(int argc, char **argv, const char **poptarg, + int *poptind) +{ + const QEMUOption *popt; + int optind =3D *poptind; + char *r =3D argv[optind]; + const char *optarg; + + loc_set_cmdline(argv, optind, 1); + optind++; + /* Treat --foo the same as -foo. */ + if (r[1] =3D=3D '-') { + r++; + } + popt =3D qemu_options; + for (;;) { + if (!popt->name) { + error_report("invalid option"); + exit(1); + } + if (!strcmp(popt->name, r + 1)) { + break; + } + popt++; + } + if (popt->flags & HAS_ARG) { + if (optind >=3D argc) { + error_report("requires an argument"); + exit(1); + } + optarg =3D argv[optind++]; + loc_set_cmdline(argv, optind - 2, 2); + } else { + optarg =3D NULL; + } + + *poptarg =3D optarg; + *poptind =3D optind; + + return popt; +} + +int drive_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + BlockInterfaceType *block_default_type =3D opaque; + + return drive_new(opts, *block_default_type, errp) =3D=3D NULL; +} + +int device_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + + dev =3D qdev_device_add(opts, errp); + if (!dev && *errp) { + error_report_err(*errp); + return -1; + } else if (dev) { + object_unref(OBJECT(dev)); + } + return 0; +} diff --git a/softmmu/vl.c b/softmmu/vl.c index 380aefd56e..33568108b0 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -36,6 +36,7 @@ #include "sysemu/runstate.h" #include "sysemu/seccomp.h" #include "sysemu/tcg.h" +#include "qemu-parse.h" =20 #include "qemu/error-report.h" #include "qemu/sockets.h" @@ -970,20 +971,6 @@ static int cleanup_add_fd(void *opaque, QemuOpts *opts= , Error **errp) /***********************************************************/ /* QEMU Block devices */ =20 -#define HD_OPTS "media=3Ddisk" -#define CDROM_OPTS "media=3Dcdrom" -#define FD_OPTS "" -#define PFLASH_OPTS "" -#define MTD_OPTS "" -#define SD_OPTS "" - -static int drive_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - BlockInterfaceType *block_default_type =3D opaque; - - return drive_new(opts, *block_default_type, errp) =3D=3D NULL; -} - static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **err= p) { if (qemu_opt_get(opts, "snapshot") =3D=3D NULL) { @@ -1691,21 +1678,6 @@ static void help(int exitcode) exit(exitcode); } =20 -#define HAS_ARG 0x0001 - -typedef struct QEMUOption { - const char *name; - int flags; - int index; - uint32_t arch_mask; -} QEMUOption; - -static const QEMUOption qemu_options[] =3D { - { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL }, -#define QEMU_OPTIONS_GENERATE_OPTIONS -#include "qemu-options-wrapper.h" - { NULL }, -}; =20 typedef struct VGAInterfaceInfo { const char *opt_name; /* option name */ @@ -2067,20 +2039,6 @@ static int device_help_func(void *opaque, QemuOpts *= opts, Error **errp) return qdev_device_help(opts); } =20 -static int device_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - DeviceState *dev; - - dev =3D qdev_device_add(opts, errp); - if (!dev && *errp) { - error_report_err(*errp); - return -1; - } else if (dev) { - object_unref(OBJECT(dev)); - } - return 0; -} - static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp) { Error *local_err =3D NULL; @@ -2332,46 +2290,6 @@ static void qemu_unlink_pidfile(Notifier *n, void *d= ata) =20 bool machine_init_done; =20 -static const QEMUOption *lookup_opt(int argc, char **argv, - const char **poptarg, int *poptind) -{ - const QEMUOption *popt; - int optind =3D *poptind; - char *r =3D argv[optind]; - const char *optarg; - - loc_set_cmdline(argv, optind, 1); - optind++; - /* Treat --foo the same as -foo. */ - if (r[1] =3D=3D '-') - r++; - popt =3D qemu_options; - for(;;) { - if (!popt->name) { - error_report("invalid option"); - exit(1); - } - if (!strcmp(popt->name, r + 1)) - break; - popt++; - } - if (popt->flags & HAS_ARG) { - if (optind >=3D argc) { - error_report("requires an argument"); - exit(1); - } - optarg =3D argv[optind++]; - loc_set_cmdline(argv, optind - 2, 2); - } else { - optarg =3D NULL; - } - - *poptarg =3D optarg; - *poptind =3D optind; - - return popt; -} - static MachineClass *select_machine(void) { GSList *machines =3D object_class_get_list(TYPE_MACHINE, false); --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166177; cv=none; d=zohomail.com; s=zohoarc; b=N/I76D9vR8uSoC8iAJVkKHzaFNvuHqbUWf5AFf5S9GFz91lRmYGzSnZSCRC0oYJmJOvqxqjaUSlM36rrZKiyXgP+XCAbX+HD5OpNUY7Gj1Ukk285To6f2Umaja7htnkXlPHwJIqj0zCuXiylD4waWtua8Y3tpSHnMwjsQ0XzAs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166177; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zIeNg9GJ442gcJiKn8WcNNdmeKePXBPreKOVh7LX5jE=; b=W/0xtBoIni6/agxoLHq3ePBl1QGITBw+X+GBFZFMGQhPLgX8etOn+etU2QSQ8yPs23UxJnwyQ8sP7Ev1uQ9jgXk3f2sTUX241EfGbxha8W9apKQWArNfMbdzc89QOghALpxtkGfJEJ/WPIKvBT+o9WgvH/GpWW1Fo8aTUY5l9f4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166177387830.243829803322; Mon, 6 Apr 2020 02:42:57 -0700 (PDT) Received: from localhost ([::1]:57124 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOHP-00034a-MJ for importer@patchew.org; Mon, 06 Apr 2020 05:42:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44001) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGO-0001Pa-5J for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGL-0001zb-Qn for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:51 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGL-0001wz-FE for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:49 -0400 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 0369dovi089372; Mon, 6 Apr 2020 09:41:41 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 306hnqwtvt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:41 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cbxX006560; Mon, 6 Apr 2020 09:41:40 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 3073xvtt92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:40 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369fdg6006731; Mon, 6 Apr 2020 09:41:39 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:38 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=zIeNg9GJ442gcJiKn8WcNNdmeKePXBPreKOVh7LX5jE=; b=sqzGm/3DmLBQONhMzabQ1+zDUK7LaCgeNeTki2afJ4layHnUWgmkNSVwBbiR8At8My2g J+dSzCOZbhJ6Ptpz3WX/7OdJ5E0JGdvonVhd9exa+i/Y1FwN+xGGFtMxYJzLE+tJbjxR rZglctqEdN4pHj0hYuaJsfEMFGTanB+hQ+ABWANZ0t+SO5hLWHDdHE8J4wVDXYP1GEiy 6qNli99+NPt+Mb25q4VnjfpvsZEAlgE5iTg/9RHwAA6TG+RHLSyoz9Vn2WvGvU18D54i 7j6GldtdfJu8cFx7lRNrLoR50jeo1iSHjIu/MiAavsr58f3O71iKD1uX5xcfp8iyOg1z Uw== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 04/36] multi-process: Refactor chardev functions out of vl.c Date: Mon, 6 Apr 2020 02:40:54 -0700 Message-Id: <751edf3f6993127a439ed8f80b90fb52e8129d97.1586165555.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Some of the initialization helper functions w.r.t chardev in vl.c are also used by the remote process. Therefore, these functions are refactored into shared files that both QEMU & remote process could use. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Dr. David Alan Gilbert --- chardev/char.c | 14 ++++++++++++++ include/chardev/char.h | 2 ++ softmmu/vl.c | 14 -------------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index e77564060d..47dcf93da7 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -1196,3 +1196,17 @@ static void register_types(void) } =20 type_init(register_types); + +int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + Error *local_err =3D NULL; + + if (!qemu_chr_new_from_opts(opts, NULL, &local_err)) { + if (local_err) { + error_propagate(errp, local_err); + return -1; + } + exit(0); + } + return 0; +} diff --git a/include/chardev/char.h b/include/chardev/char.h index 00589a6025..0804e78f7a 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -290,4 +290,6 @@ GSource *qemu_chr_timeout_add_ms(Chardev *chr, guint ms, /* console.c */ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **er= rp); =20 +int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp); + #endif diff --git a/softmmu/vl.c b/softmmu/vl.c index 33568108b0..9517f0b167 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2039,20 +2039,6 @@ static int device_help_func(void *opaque, QemuOpts *= opts, Error **errp) return qdev_device_help(opts); } =20 -static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - Error *local_err =3D NULL; - - if (!qemu_chr_new_from_opts(opts, NULL, &local_err)) { - if (local_err) { - error_propagate(errp, local_err); - return -1; - } - exit(0); - } - return 0; -} - #ifdef CONFIG_VIRTFS static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp) { --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166289; cv=none; d=zohomail.com; s=zohoarc; b=IXK+Xo+kPRBw8yLnqIXfMohPicLTlcUn61Oa4rcwKlCUWGVqpAg27jp6ES56z52lImZW2doUbcM3h8SrFjNpSW3EP06H5fVZhgPkJmFAanIVwmKSgEnLGLLYIqS3nzbHnykX9fXpMDKb23MJtTwpqvX2pa3kVjakkFJyyJ74Ujc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166289; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c0j6bwfYWxJ8tWMCbFF9L/DxtHFtQGMxoI2UFJHCj6M=; b=cWl7nQRicooIStClxyxWTwzQFgMm95u5M+zU33LZXf26y3phbROtyQCac/dCQCTb/X2VdtA+QtSlECktS5+SjDTnWZNXuAOjFLH4HzdQdo5acXdzp5xgHkwOKsr72xcVXCidu2HKnX6DVqDMvnDfrUGxDZVkggYosqQfq+qSmm4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166289543942.9682234357009; Mon, 6 Apr 2020 02:44:49 -0700 (PDT) Received: from localhost ([::1]:57238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOJE-0006TE-D0 for importer@patchew.org; Mon, 06 Apr 2020 05:44:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44002) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGO-0001Pb-4K for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGL-0001zg-Qs for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:51 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45240) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGL-0001xQ-GD for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:49 -0400 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 0369djKw069599; Mon, 6 Apr 2020 09:41:43 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 306j6m5t9t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:43 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cU1I006266; Mon, 6 Apr 2020 09:41:42 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 3073xvttbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:42 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369fe6b031755; Mon, 6 Apr 2020 09:41:40 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:39 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=c0j6bwfYWxJ8tWMCbFF9L/DxtHFtQGMxoI2UFJHCj6M=; b=vNSYIydaMYvu4imO4V+i3s1FhFzfZq/HRA2Xkww+8qHuy2BcroyJ56a8oYxSMtK1FM2/ 50F+sBPgfmPgKbFlmFIQC/CHI8Gbce4DIGhcFa1pxuj2oUtV5p0av+dA5LH58LK22HY+ VOVGX15hc48TgeJZB3ctJVeSbPwdR7yojt0GPMZ3CoC+izkEHiHjFDDVYspf82lTKVL7 xv8EjZ5W5AA2V7tEkyIPmRzTP+5+GtXRW9EOVwV9Rgyu1whAUaBQ661K0RBrp713gLFq wH0wNHxSxZt1h3qhd9iHXjYw3Cgp2fBKFE9CnIpO3iD0fQuiNzbzwbiSzv/Kpotzsul8 mA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 05/36] multi-process: Refactor monitor functions out of vl.c Date: Mon, 6 Apr 2020 02:40:55 -0700 Message-Id: <42e0baf1cbf308ed01bcd72fcc5b829965855883.1586165555.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=1 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Some of the initialization helper functions w.r.t monitor in vl.c are also used by the remote process. Therefore, these functions are refactored into shared files that both QEMU & remote process could use. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Dr. David Alan Gilbert --- include/monitor/monitor.h | 3 +++ monitor/monitor.c | 37 +++++++++++++++++++++++++++++++++++++ softmmu/vl.c | 35 ----------------------------------- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h index 1018d754a6..3803e904f2 100644 --- a/include/monitor/monitor.h +++ b/include/monitor/monitor.h @@ -48,4 +48,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int dup_fd= ); void monitor_fdset_dup_fd_remove(int dup_fd); int64_t monitor_fdset_dup_fd_find(int dup_fd); =20 +int mon_init_func(void *opaque, QemuOpts *opts, Error **errp); +void monitor_parse(const char *optarg, const char *mode, bool pretty); + #endif /* MONITOR_H */ diff --git a/monitor/monitor.c b/monitor/monitor.c index 125494410a..88423b38b6 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -35,6 +35,8 @@ #include "sysemu/qtest.h" #include "sysemu/sysemu.h" #include "trace.h" +#include "qemu/cutils.h" +#include "qemu/config-file.h" =20 /* * To prevent flooding clients, events can be throttled. The @@ -611,6 +613,41 @@ void monitor_init_globals_core(void) NULL); } =20 +int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + return monitor_init_opts(opts, errp); +} + +void monitor_parse(const char *optarg, const char *mode, bool pretty) +{ + static int monitor_device_index; + QemuOpts *opts; + const char *p; + char label[32]; + + if (strstart(optarg, "chardev:", &p)) { + snprintf(label, sizeof(label), "%s", p); + } else { + snprintf(label, sizeof(label), "compat_monitor%d", + monitor_device_index); + opts =3D qemu_chr_parse_compat(label, optarg, true); + if (!opts) { + error_report("parse error: %s", optarg); + exit(1); + } + } + + opts =3D qemu_opts_create(qemu_find_opts("mon"), label, 1, &error_fata= l); + qemu_opt_set(opts, "mode", mode, &error_abort); + qemu_opt_set(opts, "chardev", label, &error_abort); + if (!strcmp(mode, "control")) { + qemu_opt_set_bool(opts, "pretty", pretty, &error_abort); + } else { + assert(pretty =3D=3D false); + } + monitor_device_index++; +} + int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp) { Chardev *chr; diff --git a/softmmu/vl.c b/softmmu/vl.c index 9517f0b167..f30b6994e8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2046,41 +2046,6 @@ static int fsdev_init_func(void *opaque, QemuOpts *o= pts, Error **errp) } #endif =20 -static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - return monitor_init_opts(opts, errp); -} - -static void monitor_parse(const char *optarg, const char *mode, bool prett= y) -{ - static int monitor_device_index =3D 0; - QemuOpts *opts; - const char *p; - char label[32]; - - if (strstart(optarg, "chardev:", &p)) { - snprintf(label, sizeof(label), "%s", p); - } else { - snprintf(label, sizeof(label), "compat_monitor%d", - monitor_device_index); - opts =3D qemu_chr_parse_compat(label, optarg, true); - if (!opts) { - error_report("parse error: %s", optarg); - exit(1); - } - } - - opts =3D qemu_opts_create(qemu_find_opts("mon"), label, 1, &error_fata= l); - qemu_opt_set(opts, "mode", mode, &error_abort); - qemu_opt_set(opts, "chardev", label, &error_abort); - if (!strcmp(mode, "control")) { - qemu_opt_set_bool(opts, "pretty", pretty, &error_abort); - } else { - assert(pretty =3D=3D false); - } - monitor_device_index++; -} - struct device_config { enum { DEV_USB, /* -usbdevice */ --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167182; cv=none; d=zohomail.com; s=zohoarc; b=jgIt6Y+GQMCjrHnfusdcUG4Xoze2WWm1ijeIn5cKhcmkKFBdkVKPDk8CjLP+dzzZDWA5xTtfhGigNjMyubWBFR7Nqz+e3rfo8vUB5AK0/UUrVOxvCfUy/Je2Ze0ZS+oj2GtRSLT2yr0N3UgLOsjKYS/VjSNKNKBOzGp7bIg63Ek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167182; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rhVR2dPIww6dDESuuvSXnMdKtTtRaFanuh6jModnbhE=; b=TlBJ/KSoG94RGHptgQmg1dAnoV1B0znXhcR1/lm5/5g9txwCG96qaiF3ncJovunMxI17StBgipeLhBztKAJQk6GmiD3Z9XuMgzP7YWlty7WhtZvefxLYdn3lg6IsC81eeyz2XHcFGYz730sopwdtF3faP9ieJc/i0RmOzhJ+Oss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167182428683.0774595364545; Mon, 6 Apr 2020 02:59:42 -0700 (PDT) Received: from localhost ([::1]:57678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOXd-00089Y-4b for importer@patchew.org; Mon, 06 Apr 2020 05:59:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44925) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOIL-0005gr-Gw for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOIJ-0003dN-B5 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:53 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47066) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOIJ-0003cU-25 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:51 -0400 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 0369heQ5073032; Mon, 6 Apr 2020 09:43:45 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 306j6m5tj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:43:45 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369bKlm056262; Mon, 6 Apr 2020 09:41:44 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 3073qcnc4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:44 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fgtO030556; Mon, 6 Apr 2020 09:41:42 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:41 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=rhVR2dPIww6dDESuuvSXnMdKtTtRaFanuh6jModnbhE=; b=xKMU61KFaNsb/ld8K2z5sIEoQnNesusECb7Ge0Jqqf5fj2aIf1yMDsoXUfW8VNi7uZ/S zABflOgRXYzZpH9ltBAQ6EWgu3Nob0nMO2DCIhm8nOwjjxxw9g6qfDs6vTJNrBhIdzRF lm2EYPDDp8FRhOUJsnNYDX0Fx201N5rNZGlu6Dh3fEw2NyVgfl7mAU3TSHM+UFM0bM9p McMeXjmcaFjgRnOtHMmFlyXgReFrvs8OKQoPO+xweOL/u3t9gFxMbfv7EvbtbB2NYmf/ hmcOqRPYnMxPMw8JtIOXGFZ8DHfR5f+1zVozAYaZ5GjtjmBPAztYI781H88Q5BJWy+6T mA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 06/36] monitor: destaticize HMP commands Date: Mon, 6 Apr 2020 02:40:56 -0700 Message-Id: <5b37943ea8f27258f29b1c8a5cd8a4905ae82739.1586165555.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=1 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Dr. David Alan Gilbert --- hmp-commands.hx | 4 +- monitor/misc.c | 76 +++++++++++++++++++------------------- monitor/monitor-internal.h | 38 +++++++++++++++++++ 3 files changed, 78 insertions(+), 40 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 7f0f3974ad..02cae25c24 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -11,7 +11,7 @@ HXCOMM HXCOMM can be used for comments, discarded from bo= th rST and C. .args_type =3D "name:S?", .params =3D "[cmd]", .help =3D "show the help", - .cmd =3D do_help_cmd, + .cmd =3D hmp_do_help_cmd, .flags =3D "p", }, =20 @@ -555,7 +555,7 @@ ERST .args_type =3D "fmt:/,val:l", .params =3D "/fmt expr", .help =3D "print expression value (use $reg for CPU register= access)", - .cmd =3D do_print, + .cmd =3D hmp_do_print, }, =20 SRST diff --git a/monitor/misc.c b/monitor/misc.c index 6c45fa490f..c0eee6f4ab 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -178,12 +178,12 @@ int hmp_compare_cmd(const char *name, const char *lis= t) return 0; } =20 -static void do_help_cmd(Monitor *mon, const QDict *qdict) +void hmp_do_help_cmd(Monitor *mon, const QDict *qdict) { help_cmd(mon, qdict_get_try_str(qdict, "name")); } =20 -static void hmp_trace_event(Monitor *mon, const QDict *qdict) +void hmp_trace_event(Monitor *mon, const QDict *qdict) { const char *tp_name =3D qdict_get_str(qdict, "name"); bool new_state =3D qdict_get_bool(qdict, "option"); @@ -227,7 +227,7 @@ static void hmp_trace_file(Monitor *mon, const QDict *q= dict) } #endif =20 -static void hmp_info_help(Monitor *mon, const QDict *qdict) +void hmp_info_help(Monitor *mon, const QDict *qdict) { help_cmd(mon, "info"); } @@ -315,7 +315,7 @@ int monitor_get_cpu_index(void) return cs ? cs->cpu_index : UNASSIGNED_CPU_INDEX; } =20 -static void hmp_info_registers(Monitor *mon, const QDict *qdict) +void hmp_info_registers(Monitor *mon, const QDict *qdict) { bool all_cpus =3D qdict_get_try_bool(qdict, "cpustate_all", false); CPUState *cs; @@ -338,7 +338,7 @@ static void hmp_info_registers(Monitor *mon, const QDic= t *qdict) } =20 #ifdef CONFIG_TCG -static void hmp_info_jit(Monitor *mon, const QDict *qdict) +void hmp_info_jit(Monitor *mon, const QDict *qdict) { if (!tcg_enabled()) { error_report("JIT information is only available with accel=3Dtcg"); @@ -349,13 +349,13 @@ static void hmp_info_jit(Monitor *mon, const QDict *q= dict) dump_drift_info(); } =20 -static void hmp_info_opcount(Monitor *mon, const QDict *qdict) +void hmp_info_opcount(Monitor *mon, const QDict *qdict) { dump_opcount_info(); } #endif =20 -static void hmp_info_sync_profile(Monitor *mon, const QDict *qdict) +void hmp_info_sync_profile(Monitor *mon, const QDict *qdict) { int64_t max =3D qdict_get_try_int(qdict, "max", 10); bool mean =3D qdict_get_try_bool(qdict, "mean", false); @@ -366,7 +366,7 @@ static void hmp_info_sync_profile(Monitor *mon, const Q= Dict *qdict) qsp_report(max, sort_by, coalesce); } =20 -static void hmp_info_history(Monitor *mon, const QDict *qdict) +void hmp_info_history(Monitor *mon, const QDict *qdict) { MonitorHMP *hmp_mon =3D container_of(mon, MonitorHMP, common); int i; @@ -386,7 +386,7 @@ static void hmp_info_history(Monitor *mon, const QDict = *qdict) } } =20 -static void hmp_info_cpustats(Monitor *mon, const QDict *qdict) +void hmp_info_cpustats(Monitor *mon, const QDict *qdict) { CPUState *cs =3D mon_get_cpu(); =20 @@ -397,7 +397,7 @@ static void hmp_info_cpustats(Monitor *mon, const QDict= *qdict) cpu_dump_statistics(cs, 0); } =20 -static void hmp_info_trace_events(Monitor *mon, const QDict *qdict) +void hmp_info_trace_events(Monitor *mon, const QDict *qdict) { const char *name =3D qdict_get_try_str(qdict, "name"); bool has_vcpu =3D qdict_haskey(qdict, "vcpu"); @@ -457,7 +457,7 @@ void qmp_client_migrate_info(const char *protocol, cons= t char *hostname, error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", "spice"); } =20 -static void hmp_logfile(Monitor *mon, const QDict *qdict) +void hmp_logfile(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; =20 @@ -467,7 +467,7 @@ static void hmp_logfile(Monitor *mon, const QDict *qdic= t) } } =20 -static void hmp_log(Monitor *mon, const QDict *qdict) +void hmp_log(Monitor *mon, const QDict *qdict) { int mask; const char *items =3D qdict_get_str(qdict, "items"); @@ -484,7 +484,7 @@ static void hmp_log(Monitor *mon, const QDict *qdict) qemu_set_log(mask); } =20 -static void hmp_singlestep(Monitor *mon, const QDict *qdict) +void hmp_singlestep(Monitor *mon, const QDict *qdict) { const char *option =3D qdict_get_try_str(qdict, "option"); if (!option || !strcmp(option, "on")) { @@ -496,7 +496,7 @@ static void hmp_singlestep(Monitor *mon, const QDict *q= dict) } } =20 -static void hmp_gdbserver(Monitor *mon, const QDict *qdict) +void hmp_gdbserver(Monitor *mon, const QDict *qdict) { const char *device =3D qdict_get_try_str(qdict, "device"); if (!device) @@ -512,7 +512,7 @@ static void hmp_gdbserver(Monitor *mon, const QDict *qd= ict) } } =20 -static void hmp_watchdog_action(Monitor *mon, const QDict *qdict) +void hmp_watchdog_action(Monitor *mon, const QDict *qdict) { const char *action =3D qdict_get_str(qdict, "action"); if (select_watchdog_action(action) =3D=3D -1) { @@ -654,7 +654,7 @@ static void memory_dump(Monitor *mon, int count, int fo= rmat, int wsize, } } =20 -static void hmp_memory_dump(Monitor *mon, const QDict *qdict) +void hmp_memory_dump(Monitor *mon, const QDict *qdict) { int count =3D qdict_get_int(qdict, "count"); int format =3D qdict_get_int(qdict, "format"); @@ -664,7 +664,7 @@ static void hmp_memory_dump(Monitor *mon, const QDict *= qdict) memory_dump(mon, count, format, size, addr, 0); } =20 -static void hmp_physical_memory_dump(Monitor *mon, const QDict *qdict) +void hmp_physical_memory_dump(Monitor *mon, const QDict *qdict) { int count =3D qdict_get_int(qdict, "count"); int format =3D qdict_get_int(qdict, "format"); @@ -694,7 +694,7 @@ static void *gpa2hva(MemoryRegion **p_mr, hwaddr addr, = Error **errp) return qemu_map_ram_ptr(mrs.mr->ram_block, mrs.offset_within_region); } =20 -static void hmp_gpa2hva(Monitor *mon, const QDict *qdict) +void hmp_gpa2hva(Monitor *mon, const QDict *qdict) { hwaddr addr =3D qdict_get_int(qdict, "addr"); Error *local_err =3D NULL; @@ -714,7 +714,7 @@ static void hmp_gpa2hva(Monitor *mon, const QDict *qdic= t) memory_region_unref(mr); } =20 -static void hmp_gva2gpa(Monitor *mon, const QDict *qdict) +void hmp_gva2gpa(Monitor *mon, const QDict *qdict) { target_ulong addr =3D qdict_get_int(qdict, "addr"); MemTxAttrs attrs; @@ -769,7 +769,7 @@ out: return ret; } =20 -static void hmp_gpa2hpa(Monitor *mon, const QDict *qdict) +void hmp_gpa2hpa(Monitor *mon, const QDict *qdict) { hwaddr addr =3D qdict_get_int(qdict, "addr"); Error *local_err =3D NULL; @@ -796,7 +796,7 @@ static void hmp_gpa2hpa(Monitor *mon, const QDict *qdic= t) } #endif =20 -static void do_print(Monitor *mon, const QDict *qdict) +void hmp_do_print(Monitor *mon, const QDict *qdict) { int format =3D qdict_get_int(qdict, "format"); hwaddr val =3D qdict_get_int(qdict, "val"); @@ -822,7 +822,7 @@ static void do_print(Monitor *mon, const QDict *qdict) monitor_printf(mon, "\n"); } =20 -static void hmp_sum(Monitor *mon, const QDict *qdict) +void hmp_sum(Monitor *mon, const QDict *qdict) { uint32_t addr; uint16_t sum; @@ -842,7 +842,7 @@ static void hmp_sum(Monitor *mon, const QDict *qdict) =20 static int mouse_button_state; =20 -static void hmp_mouse_move(Monitor *mon, const QDict *qdict) +void hmp_mouse_move(Monitor *mon, const QDict *qdict) { int dx, dy, dz, button; const char *dx_str =3D qdict_get_str(qdict, "dx_str"); @@ -866,7 +866,7 @@ static void hmp_mouse_move(Monitor *mon, const QDict *q= dict) qemu_input_event_sync(); } =20 -static void hmp_mouse_button(Monitor *mon, const QDict *qdict) +void hmp_mouse_button(Monitor *mon, const QDict *qdict) { static uint32_t bmap[INPUT_BUTTON__MAX] =3D { [INPUT_BUTTON_LEFT] =3D MOUSE_EVENT_LBUTTON, @@ -883,7 +883,7 @@ static void hmp_mouse_button(Monitor *mon, const QDict = *qdict) mouse_button_state =3D button_state; } =20 -static void hmp_ioport_read(Monitor *mon, const QDict *qdict) +void hmp_ioport_read(Monitor *mon, const QDict *qdict) { int size =3D qdict_get_int(qdict, "size"); int addr =3D qdict_get_int(qdict, "addr"); @@ -917,7 +917,7 @@ static void hmp_ioport_read(Monitor *mon, const QDict *= qdict) suffix, addr, size * 2, val); } =20 -static void hmp_ioport_write(Monitor *mon, const QDict *qdict) +void hmp_ioport_write(Monitor *mon, const QDict *qdict) { int size =3D qdict_get_int(qdict, "size"); int addr =3D qdict_get_int(qdict, "addr"); @@ -939,7 +939,7 @@ static void hmp_ioport_write(Monitor *mon, const QDict = *qdict) } } =20 -static void hmp_boot_set(Monitor *mon, const QDict *qdict) +void hmp_boot_set(Monitor *mon, const QDict *qdict) { Error *local_err =3D NULL; const char *bootdevice =3D qdict_get_str(qdict, "bootdevice"); @@ -952,7 +952,7 @@ static void hmp_boot_set(Monitor *mon, const QDict *qdi= ct) } } =20 -static void hmp_info_mtree(Monitor *mon, const QDict *qdict) +void hmp_info_mtree(Monitor *mon, const QDict *qdict) { bool flatview =3D qdict_get_try_bool(qdict, "flatview", false); bool dispatch_tree =3D qdict_get_try_bool(qdict, "dispatch_tree", fals= e); @@ -965,7 +965,7 @@ static void hmp_info_mtree(Monitor *mon, const QDict *q= dict) =20 int64_t dev_time; =20 -static void hmp_info_profile(Monitor *mon, const QDict *qdict) +void hmp_info_profile(Monitor *mon, const QDict *qdict) { static int64_t last_cpu_exec_time; int64_t cpu_exec_time; @@ -982,7 +982,7 @@ static void hmp_info_profile(Monitor *mon, const QDict = *qdict) dev_time =3D 0; } #else -static void hmp_info_profile(Monitor *mon, const QDict *qdict) +void hmp_info_profile(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "Internal profiler not compiled\n"); } @@ -991,7 +991,7 @@ static void hmp_info_profile(Monitor *mon, const QDict = *qdict) /* Capture support */ static QLIST_HEAD (capture_list_head, CaptureState) capture_head; =20 -static void hmp_info_capture(Monitor *mon, const QDict *qdict) +void hmp_info_capture(Monitor *mon, const QDict *qdict) { int i; CaptureState *s; @@ -1002,7 +1002,7 @@ static void hmp_info_capture(Monitor *mon, const QDic= t *qdict) } } =20 -static void hmp_stopcapture(Monitor *mon, const QDict *qdict) +void hmp_stopcapture(Monitor *mon, const QDict *qdict) { int i; int n =3D qdict_get_int(qdict, "n"); @@ -1018,7 +1018,7 @@ static void hmp_stopcapture(Monitor *mon, const QDict= *qdict) } } =20 -static void hmp_wavcapture(Monitor *mon, const QDict *qdict) +void hmp_wavcapture(Monitor *mon, const QDict *qdict) { const char *path =3D qdict_get_str(qdict, "path"); int freq =3D qdict_get_try_int(qdict, "freq", 44100); @@ -1071,7 +1071,7 @@ static void hmp_warn_acl(void) warn_acl =3D true; } =20 -static void hmp_acl_show(Monitor *mon, const QDict *qdict) +void hmp_acl_show(Monitor *mon, const QDict *qdict) { const char *aclname =3D qdict_get_str(qdict, "aclname"); QAuthZList *auth =3D find_auth(mon, aclname); @@ -1098,7 +1098,7 @@ static void hmp_acl_show(Monitor *mon, const QDict *q= dict) } } =20 -static void hmp_acl_reset(Monitor *mon, const QDict *qdict) +void hmp_acl_reset(Monitor *mon, const QDict *qdict) { const char *aclname =3D qdict_get_str(qdict, "aclname"); QAuthZList *auth =3D find_auth(mon, aclname); @@ -1115,7 +1115,7 @@ static void hmp_acl_reset(Monitor *mon, const QDict *= qdict) monitor_printf(mon, "acl: removed all rules\n"); } =20 -static void hmp_acl_policy(Monitor *mon, const QDict *qdict) +void hmp_acl_policy(Monitor *mon, const QDict *qdict) { const char *aclname =3D qdict_get_str(qdict, "aclname"); const char *policy =3D qdict_get_str(qdict, "policy"); @@ -1156,7 +1156,7 @@ static QAuthZListFormat hmp_acl_get_format(const char= *match) } } =20 -static void hmp_acl_add(Monitor *mon, const QDict *qdict) +void hmp_acl_add(Monitor *mon, const QDict *qdict) { const char *aclname =3D qdict_get_str(qdict, "aclname"); const char *match =3D qdict_get_str(qdict, "match"); @@ -1209,7 +1209,7 @@ static void hmp_acl_add(Monitor *mon, const QDict *qd= ict) } } =20 -static void hmp_acl_remove(Monitor *mon, const QDict *qdict) +void hmp_acl_remove(Monitor *mon, const QDict *qdict) { const char *aclname =3D qdict_get_str(qdict, "aclname"); const char *match =3D qdict_get_str(qdict, "match"); diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 8f60ccc70a..bc8c9fa16b 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -183,4 +183,42 @@ int hmp_compare_cmd(const char *name, const char *list= ); void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data, Error **errp); =20 +void hmp_do_help_cmd(Monitor *mon, const QDict *qdict); +void hmp_trace_event(Monitor *mon, const QDict *qdict); +void hmp_info_help(Monitor *mon, const QDict *qdict); +void hmp_info_registers(Monitor *mon, const QDict *qdict); +void hmp_info_jit(Monitor *mon, const QDict *qdict); +void hmp_info_opcount(Monitor *mon, const QDict *qdict); +void hmp_info_sync_profile(Monitor *mon, const QDict *qdict); +void hmp_info_history(Monitor *mon, const QDict *qdict); +void hmp_info_cpustats(Monitor *mon, const QDict *qdict); +void hmp_info_trace_events(Monitor *mon, const QDict *qdict); +void hmp_logfile(Monitor *mon, const QDict *qdict); +void hmp_log(Monitor *mon, const QDict *qdict); +void hmp_singlestep(Monitor *mon, const QDict *qdict); +void hmp_gdbserver(Monitor *mon, const QDict *qdict); +void hmp_watchdog_action(Monitor *mon, const QDict *qdict); +void hmp_memory_dump(Monitor *mon, const QDict *qdict); +void hmp_physical_memory_dump(Monitor *mon, const QDict *qdict); +void hmp_gpa2hva(Monitor *mon, const QDict *qdict); +void hmp_gva2gpa(Monitor *mon, const QDict *qdict); +void hmp_gpa2hpa(Monitor *mon, const QDict *qdict); +void hmp_do_print(Monitor *mon, const QDict *qdict); +void hmp_sum(Monitor *mon, const QDict *qdict); +void hmp_mouse_move(Monitor *mon, const QDict *qdict); +void hmp_mouse_button(Monitor *mon, const QDict *qdict); +void hmp_ioport_read(Monitor *mon, const QDict *qdict); +void hmp_ioport_write(Monitor *mon, const QDict *qdict); +void hmp_boot_set(Monitor *mon, const QDict *qdict); +void hmp_info_mtree(Monitor *mon, const QDict *qdict); +void hmp_info_profile(Monitor *mon, const QDict *qdict); +void hmp_info_capture(Monitor *mon, const QDict *qdict); +void hmp_stopcapture(Monitor *mon, const QDict *qdict); +void hmp_wavcapture(Monitor *mon, const QDict *qdict); +void hmp_acl_show(Monitor *mon, const QDict *qdict); +void hmp_acl_reset(Monitor *mon, const QDict *qdict); +void hmp_acl_policy(Monitor *mon, const QDict *qdict); +void hmp_acl_add(Monitor *mon, const QDict *qdict); +void hmp_acl_remove(Monitor *mon, const QDict *qdict); + #endif --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166427; cv=none; d=zohomail.com; s=zohoarc; b=IgZGUs3RNkkpBs+QVfh79Td0LK9iU188tEFWjHb1eglbjhN/btlhY1NVElC0LEbZhQ6JSs9Zbku2B7BpOHi48kPa6KwLkCzaK9lBq5ShuAGAdn82bG5UrdsCTO8g2Mp7YVCIHgEHyBp+V2drY5Ys6lp7Np3EvFXk+fxrUX30xyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166427; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zv0fyL99R1UsFGCTMrkgtdNF4qpuM5u8ypOXrcG1Vbo=; b=Zib3nAkbGGQdS+2u3HWYD+KL9ZBPkFsqAFhMRI3cQG3Qbk1bglM41njg6K+3GrABe262KXPCsHhiESrSRkqyNZ8Ge8PU5PsbPVmyqfPbkZURQZEE5bdguocJUlkA7ZE9gJt044KCZxWu73+xoX8Fq5ADCua0n2vjDNilZxEa1ik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166427568404.4399310467113; Mon, 6 Apr 2020 02:47:07 -0700 (PDT) Received: from localhost ([::1]:57340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOLS-0001nr-Ar for importer@patchew.org; Mon, 06 Apr 2020 05:47:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44102) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGW-0001TY-Rm for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGU-00026P-SS for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:00 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45154) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGT-00024R-2h for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:58 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cx6f025177; Mon, 6 Apr 2020 09:41:48 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 306jvmwr3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:48 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369ciqO092283; Mon, 6 Apr 2020 09:41:47 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 3073spk5p3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:47 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369fiP5006867; Mon, 6 Apr 2020 09:41:45 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:43 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=Zv0fyL99R1UsFGCTMrkgtdNF4qpuM5u8ypOXrcG1Vbo=; b=oxLjbSJEYhKIrgV5yHKg2UcQWbMePP4Ob1PkSIPZYEoASgsj7DDM+OC5aDsu4Xep8eQs PgV3uRgyqAb174Rbx9U6SI3k5koHZsSys7U06jnHCGgzIg+J3kkM1OxVoq6ztYvuZ60c DJeHnrA25y1g7l9ospBAg8/00dNarNQjxcuZkZFbsB5Q1UoUI+wfmFZl2AjC8Uq4hX0m vdg+47B9eCQ3HegCSjs+ykrJX4EUUhmVQ9cgPC155r4OdKSuRNjyYlmftaXQ2uvGMzjD lf/N+R0zk5B9gu3lKsTMcQpKACVuDd6bp52rFdWOcpTWQ68AtmpR2NnC+RiJ/A9ZpzTZ oQ== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 07/36] multi-process: add a command line option for debug file Date: Mon, 6 Apr 2020 02:40:57 -0700 Message-Id: <02b5b025dfe3d5753ab5bc5fccbcd6ac9d726077.1586165555.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Can be used with -d rdebug command options when starting qemu. Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Reviewed-by: Stefan Hajnoczi --- include/qemu/log.h | 1 + util/log.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/qemu/log.h b/include/qemu/log.h index f4724f7330..a039ddb61a 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -64,6 +64,7 @@ static inline bool qemu_log_separate(void) #define CPU_LOG_PLUGIN (1 << 18) /* LOG_STRACE is used for user-mode strace logging. */ #define LOG_STRACE (1 << 19) +#define LOG_REMOTE_DEBUG (1 << 20) =20 /* Lock output for a series of related logs. Since this is not needed * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we diff --git a/util/log.c b/util/log.c index 2da6cb31dc..1f90e70cdd 100644 --- a/util/log.c +++ b/util/log.c @@ -334,6 +334,8 @@ const QEMULogItem qemu_log_items[] =3D { #endif { LOG_STRACE, "strace", "log every user-mode syscall, its input, and its result" }, + { LOG_REMOTE_DEBUG, "rdebug", + "log remote debug" }, { 0, NULL, NULL }, }; =20 --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166293; cv=none; d=zohomail.com; s=zohoarc; b=CW6vSQFjkmnDPnV6vnFMC4YL2nx6qwp6pecUuc1T03VKDZnQWA4UG4h1V9UQ/+d6Q7rqcd1KuG9L59se2go1E41i6b40SRapE5EPLXgGfHHZocmQsEz1/QRC81fUIMjg3I2tDHRPTK/0chLuURdCzXTLc5lOwcKpb+kQC6wDKTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166293; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=sX/T02oeGexRf+emRO9VLnjkMC71nHIenHbZKIjsvEg=; b=ZH3hKnMy+iNrqQDU3S9UHkEhRPk/NgMC4dH0S69BXwFo1g5xgMeCv6knjbdux4oqp/o5JZENa73CXEjctXRK7QsYzpvxHiX4vyifVwOqOdwuHdxwZzZFma7qwHRnJgmomtB3gUei1LsY7Uof8YodkiRXE9oCt+8dtntDzxM9AtU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166293615974.1749587639887; Mon, 6 Apr 2020 02:44:53 -0700 (PDT) Received: from localhost ([::1]:57250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOJI-0006ct-8h for importer@patchew.org; Mon, 06 Apr 2020 05:44:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44068) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGT-0001Qm-28 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGR-00023t-6l for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:56 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGQ-00022T-RS for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:55 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369d1oB025216; Mon, 6 Apr 2020 09:41:48 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 306jvmwr3w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:47 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cmYi092363; Mon, 6 Apr 2020 09:41:47 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 3073spk5pd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:47 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fkOK030577; Mon, 6 Apr 2020 09:41:46 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:45 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=sX/T02oeGexRf+emRO9VLnjkMC71nHIenHbZKIjsvEg=; b=wJp5fvnLESFjT83p7c5GkUQcTOATE//NAf4HpmiWJDde7AcUz0Nt8or1xHkNT0PywOpA FeB3pI68Km1USgpdF89QxNWLOl463P2GIm3u39D1F8xn9bWMdmuaEGGi0J0Z+MHe7fLP sbiYhmVjrCot8k9b8YhucCp3RyXC/SAmhw3mOzATeAScW6gsR5yH5Fehl99Ubhgwy7sE f1HJWF2vODGXpQJKT0XWrf44NESb19/kidC+uH4PU7CeV9Us41UhPqzNSO6RbycDlYYD UtrUiKuWYFk5zz3PV8qPmZORXuGxqjbRW+aAL2hVF0E7AV6VvEDZhQ0esaGGB2kfGH1R eg== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 08/36] multi-process: Add stub functions to facilate build of multi-process Date: Mon, 6 Apr 2020 02:40:58 -0700 Message-Id: <3581740cf5a9eaca8c86bc28e75750be7e7b45e4.1586165555.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Add stub functions that are needed during compile time but not in runtime. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 3 ++ accel/stubs/kvm-stub.c | 5 +++ accel/stubs/tcg-stub.c | 98 ++++++++++++++++++++++++++++++++++++++++++ stubs/audio.c | 12 ++++++ stubs/monitor.c | 53 +++++++++++++++++++++++ stubs/net-stub.c | 31 +++++++++++++ stubs/replay.c | 14 ++++++ stubs/vl-stub.c | 79 ++++++++++++++++++++++++++++++++++ stubs/vmstate.c | 19 ++++++++ stubs/xen-mapcache.c | 22 ++++++++++ 10 files changed, 336 insertions(+) create mode 100644 stubs/audio.c create mode 100644 stubs/net-stub.c create mode 100644 stubs/vl-stub.c create mode 100644 stubs/xen-mapcache.c diff --git a/MAINTAINERS b/MAINTAINERS index 611d9a64b0..ff59f60fdc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -442,6 +442,7 @@ F: hw/pci-host/xen_igd_pt.c F: include/hw/block/dataplane/xen* F: include/hw/xen/ F: include/sysemu/xen-mapcache.h +F: stubs/xen-mapcache.c =20 Guest CPU Cores (HAXM) --------------------- @@ -1898,6 +1899,7 @@ F: include/hw/audio/ F: tests/qtest/ac97-test.c F: tests/qtest/es1370-test.c F: tests/qtest/intel-hda-test.c +F: stubs/audio.c =20 Block layer core M: Kevin Wolf @@ -2119,6 +2121,7 @@ F: include/net/ F: qemu-bridge-helper.c T: git https://github.com/jasowang/qemu.git net F: qapi/net.json +F: stubs/net-stub.c =20 Netmap network backend M: Luigi Rizzo diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 82f118d2df..baa6b38da4 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -31,6 +31,7 @@ bool kvm_allowed; bool kvm_readonly_mem_allowed; bool kvm_ioeventfd_any_length_allowed; bool kvm_msi_use_devid; +bool kvm_halt_in_kernel_allowed; =20 int kvm_destroy_vcpu(CPUState *cpu) { @@ -58,6 +59,10 @@ void kvm_cpu_synchronize_post_init(CPUState *cpu) { } =20 +void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu) +{ +} + int kvm_cpu_exec(CPUState *cpu) { abort(); diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c index 677191a69c..2e4e8741fb 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -11,14 +11,112 @@ */ =20 #include "qemu/osdep.h" +#include "qemu-common.h" #include "cpu.h" #include "tcg/tcg.h" #include "exec/exec-all.h" +#include "translate-all.h" +#include "exec/ram_addr.h" + +bool parallel_cpus; =20 void tb_flush(CPUState *cpu) { } =20 +#ifdef CONFIG_MPQEMU +void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr) +{ +} + +void tb_invalidate_phys_range(ram_addr_t start, ram_addr_t end) +{ +} + +void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t en= d) +{ +} + +void tb_invalidate_phys_page_fast(struct page_collection *pages, + tb_page_addr_t start, int len, + uintptr_t retaddr) +{ +} + +void tlb_init(CPUState *cpu) +{ +} + void tlb_set_dirty(CPUState *cpu, target_ulong vaddr) { } + +void tlb_flush(CPUState *cpu) +{ +} + +void tlb_flush_page(CPUState *cpu, target_ulong addr) +{ +} + +void tlb_reset_dirty(CPUState *cpu, ram_addr_t start1, ram_addr_t length) +{ +} + +void tcg_region_init(void) +{ +} + +void tcg_register_thread(void) +{ +} + +void tcg_flush_softmmu_tlb(CPUState *cs) +{ +} + +void cpu_loop_exit_noexc(CPUState *cpu) +{ + cpu->exception_index =3D -1; + cpu_loop_exit(cpu); +} + +void cpu_loop_exit(CPUState *cpu) +{ + cpu->can_do_io =3D 1; + siglongjmp(cpu->jmp_env, 1); +} + +void cpu_reloading_memory_map(void) +{ +} + +int cpu_exec(CPUState *cpu) +{ + return 0; +} + +void cpu_exec_step_atomic(CPUState *cpu) +{ +} + +bool cpu_restore_state(CPUState *cpu, uintptr_t host_pc, bool will_exit) +{ + return false; +} + +void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc) +{ + cpu_loop_exit(cpu); +} + +struct page_collection * +page_collection_lock(tb_page_addr_t start, tb_page_addr_t end) +{ + return NULL; +} + +void page_collection_unlock(struct page_collection *set) +{ +} +#endif diff --git a/stubs/audio.c b/stubs/audio.c new file mode 100644 index 0000000000..8ae3b0f568 --- /dev/null +++ b/stubs/audio.c @@ -0,0 +1,12 @@ +#include "qemu/osdep.h" +#include "audio/audio.h" + +AudioState *audio_state_by_name(const char *name) +{ + return NULL; +} + +const char *audio_get_id(QEMUSoundCard *card) +{ + return NULL; +} diff --git a/stubs/monitor.c b/stubs/monitor.c index 20786ac4ff..07b0bedaab 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -2,6 +2,28 @@ #include "qapi/error.h" #include "monitor/monitor.h" #include "../monitor/monitor-internal.h" +#include "qapi/qapi-types-misc.h" +#include "qapi/qapi-commands-misc.h" +#include "qapi/qapi-types-qom.h" +#include "qapi/qapi-commands-qdev.h" +#include "hw/qdev-core.h" +#include "sysemu/sysemu.h" +#include "sysemu/runstate.h" +#include "monitor/hmp.h" + +#pragma weak hmp_handle_error +#pragma weak cur_mon +#pragma weak monitor_vprintf +#pragma weak monitor_printf +#pragma weak monitor_cur_is_qmp +#pragma weak qmp_device_list_properties + +__thread Monitor *cur_mon; + +int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) +{ + abort(); +} =20 int monitor_get_fd(Monitor *mon, const char *name, Error **errp) { @@ -16,3 +38,34 @@ void monitor_init_hmp(Chardev *chr, bool use_readline, E= rror **errp) void monitor_fdsets_cleanup(void) { } + +int monitor_get_cpu_index(void) +{ + return -ENOSYS; +} +int monitor_printf(Monitor *mon, const char *fmt, ...) +{ + return -ENOSYS; +} + +bool monitor_cur_is_qmp(void) +{ + return false; +} + +ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, + Error **errp) +{ + return NULL; +} + +VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev, + VMChangeStateHandler = *cb, + void *opaque) +{ + return NULL; +} + +void hmp_handle_error(Monitor *mon, Error *err) +{ +} diff --git a/stubs/net-stub.c b/stubs/net-stub.c new file mode 100644 index 0000000000..cb2274ba40 --- /dev/null +++ b/stubs/net-stub.c @@ -0,0 +1,31 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "net/net.h" + +int qemu_find_net_clients_except(const char *id, NetClientState **ncs, + NetClientDriver type, int max) +{ + return -ENOSYS; +} + +NetClientState *net_hub_port_find(int hub_id) +{ + return NULL; +} + +int net_hub_id_for_client(NetClientState *nc, int *id) +{ + return -ENOSYS; +} + +int qemu_show_nic_models(const char *arg, const char *const *models) +{ + return -ENOSYS; +} + +int qemu_find_nic_model(NICInfo *nd, const char * const *models, + const char *default_model) +{ + return -ENOSYS; +} + diff --git a/stubs/replay.c b/stubs/replay.c index 5974ec1f50..2e3feee6a9 100644 --- a/stubs/replay.c +++ b/stubs/replay.c @@ -88,3 +88,17 @@ int replay_read_random(void *buf, size_t len) { return 0; } + +bool replay_has_checkpoint(void) +{ + return false; +} + +int replay_get_instructions(void) +{ + return 0; +} + +void replay_account_executed_instructions(void) +{ +} diff --git a/stubs/vl-stub.c b/stubs/vl-stub.c new file mode 100644 index 0000000000..fff72be201 --- /dev/null +++ b/stubs/vl-stub.c @@ -0,0 +1,79 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "qemu/uuid.h" +#include "sysemu/sysemu.h" +#include "exec/cpu-common.h" +#include "exec/gdbstub.h" +#include "sysemu/replay.h" +#include "disas/disas.h" +#include "sysemu/runstate.h" + +bool tcg_allowed; +bool xen_allowed; +bool boot_strict; +bool qemu_uuid_set; + +int mem_prealloc; +int smp_cpus; +int vga_interface_type =3D VGA_NONE; +int smp_cores =3D 1; +int smp_threads =3D 1; +int icount_align_option; +int boot_menu; + +unsigned int max_cpus; +const uint32_t arch_type; +const char *mem_path; +uint8_t qemu_extra_params_fw[2]; +uint8_t *boot_splash_filedata; +size_t boot_splash_filedata_size; +struct syminfo *syminfos; + +ram_addr_t ram_size; +MachineState *current_machine; +QemuUUID qemu_uuid; + +int runstate_is_running(void) +{ + return 0; +} + +void runstate_set(RunState new_state) +{ +} + +void vm_state_notify(int running, RunState state) +{ +} + +bool qemu_vmstop_requested(RunState *r) +{ + return false; +} + +void qemu_system_debug_request(void) +{ +} + +char *qemu_find_file(int type, const char *name) +{ + return NULL; +} + +void gdb_set_stop_cpu(CPUState *cpu) +{ +} + +void replay_enable_events(void) +{ +} + +void replay_disable_events(void) +{ +} + +#ifdef TARGET_I386 +void x86_cpu_list(void) +{ +} +#endif diff --git a/stubs/vmstate.c b/stubs/vmstate.c index cc4fe41dfc..c7c015ac58 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -1,7 +1,9 @@ #include "qemu/osdep.h" #include "migration/vmstate.h" +#include "migration/misc.h" =20 const VMStateDescription vmstate_dummy =3D {}; +const VMStateInfo vmstate_info_timer; =20 int vmstate_register_with_alias_id(VMStateIf *obj, uint32_t instance_id, @@ -23,3 +25,20 @@ bool vmstate_check_only_migratable(const VMStateDescript= ion *vmsd) { return true; } + +void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev) +{ +} + +void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev) +{ +} + +void vmstate_register_ram_global(MemoryRegion *mr) +{ +} + +bool migration_is_idle(void) +{ + return true; +} diff --git a/stubs/xen-mapcache.c b/stubs/xen-mapcache.c new file mode 100644 index 0000000000..af5c031727 --- /dev/null +++ b/stubs/xen-mapcache.c @@ -0,0 +1,22 @@ +#include "qemu/osdep.h" +#include "exec/hwaddr.h" +#include "exec/cpu-common.h" +#include "sysemu/xen-mapcache.h" + +#ifdef CONFIG_XEN + +void xen_invalidate_map_cache_entry(uint8_t *buffer) +{ +} + +uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, uint8_t lock, bool d= ma) +{ + return NULL; +} + +ram_addr_t xen_ram_addr_from_mapcache(void *ptr) +{ + return 0; +} + +#endif --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167068; cv=none; d=zohomail.com; s=zohoarc; b=S1WcewUSwL4e+RNfHmpqFnPaoE5sSy0iDeniOfnfQnm2gYaEOQeK2Q9MtjZEbi9wrIqrvHKPmjNIwuBjMrr7RcV2n3dhHBNmLzZMPSbnn7cRYP8k57OsBmMXikJpFiDVLXE6t6FI8VnafD0AizEByoa3Ow0+xo44mIoU2C7fnjI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167068; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FWBqwWKfJON+64uL8pkeFeHCcs+bEyi4l1FtgC6XwwY=; b=EQf9pV3C/vnfDADK3FtP3P3QrIZt+wKbCQ+Db/Ln2KFAFDv0fjo5skxyN0vkjwDLxgPexwZDfFeTwjPvoaut8wlDttIsJq4eGADnfj60WFwEU/zwYAmzK65VjSDYtcBUd4Y+CF2zxDo1+8v7sx6pmDUtqlqpy6UCIhPlBHMgHAU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167068564617.4073740247641; Mon, 6 Apr 2020 02:57:48 -0700 (PDT) Received: from localhost ([::1]:57634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOVn-0004VB-7l for importer@patchew.org; Mon, 06 Apr 2020 05:57:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44940) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOIQ-0005lu-0N for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOIO-0003hd-KY for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:57 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47186) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOIO-0003gH-CU for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:56 -0400 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 0369hfiE073043; Mon, 6 Apr 2020 09:43:50 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 306j6m5tjf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:43:50 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cgbJ092204; Mon, 6 Apr 2020 09:41:50 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 3073spk5rs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:50 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369flpI013481; Mon, 6 Apr 2020 09:41:48 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:47 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=FWBqwWKfJON+64uL8pkeFeHCcs+bEyi4l1FtgC6XwwY=; b=bNj9g0pSfANmDIT4RN06ZtvUm471Kox7u0adkaXOok1C6ayBtBLIeNtG1lu4ZP8UXAJ7 VupkEn74yVUtXvvfEBPYoB+73FMuw2o0/u9f0COXbrMiIzmwTA8IV871WNfCJUocFJVA QzV+qNneUM06XkNd9ON6ik9gbBloWZWUb0MZrV0Bj9xXQZz8cCdY9Zma4yWD8MOXrj+l g1uRFnKfuHnrMbqCcsRmmpmmH38cCnJ0uObJmXRXV5BxRV4B4mmBEjRNAHoOdvMGp2SH 0nxwEI5gkxPSApw4L/Qa7//UZRmn1GyfnvU3jf0TOs/gDi+4mLUHr3oknRMuJlmVkXBQ 3Q== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 09/36] multi-process: Add config option for multi-process QEMU Date: Mon, 6 Apr 2020 02:40:59 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=1 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Add a configuration option to separate multi-process code Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- configure | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configure b/configure index e225a1e3ff..3fbb66a5d5 100755 --- a/configure +++ b/configure @@ -509,6 +509,7 @@ libpmem=3D"" default_devices=3D"yes" plugins=3D"no" fuzzing=3D"no" +mpqemu=3D"no" =20 supported_cpu=3D"no" supported_os=3D"no" @@ -1601,6 +1602,10 @@ for opt do ;; --gdb=3D*) gdb_bin=3D"$optarg" ;; + --enable-mpqemu) mpqemu=3Dyes + ;; + --disable-mpqemu) mpqemu=3Dno + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1894,6 +1899,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: debug-mutex mutex debugging support libpmem libpmem support xkbcommon xkbcommon support + mpqemu multi-process QEMU support =20 NOTE: The object files are built at the place where configure is launched EOF @@ -6772,6 +6778,7 @@ echo "default devices $default_devices" echo "plugin support $plugins" echo "fuzzing support $fuzzing" echo "gdb $gdb_bin" +echo "multiprocess QEMU $mpqemu" =20 if test "$supported_cpu" =3D "no"; then echo @@ -7590,6 +7597,10 @@ if test "$libpmem" =3D "yes" ; then echo "CONFIG_LIBPMEM=3Dy" >> $config_host_mak fi =20 +if test "$mpqemu" =3D "yes" ; then + echo "CONFIG_MPQEMU=3Dy" >> $config_host_mak +fi + if test "$bochs" =3D "yes" ; then echo "CONFIG_BOCHS=3Dy" >> $config_host_mak fi --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166187; cv=none; d=zohomail.com; s=zohoarc; b=hJAKFwx3cjIwAOutDb+KEx2JoF4RArMcW2J8vUzU9Gr2l9p4m6bvWDibn0RcbAn1vk8d/g31xWIxfJGqWiZYoUoq2Qo81Tv4wrW1GpC4qettGQolq0AlSLp3kqVqgfqR9foGhjAMJH1fMlxpgPV10WvY7rRglyj2Wk5r8f2dzAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166187; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=T5ctyZ1GDAo0tBNvyhUgGBWgfW7ELpytJVlquvCr45g=; b=ZDoL8iAIXDqlFSLQDt444saovULf400zlB9LuxjhKJC8zWhGvMZ1pKkqBw1CVd/+MsnabMWHZG3LGWwlxTOXN7Y4deprdeBHjQglscNrtL+E3+GUltk2BJa3es63cwPcrCE6FvmsVYZ3kRCqQEt5rTE8aX8oH10xVfJBnhNAKBc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158616618704892.4439478779351; Mon, 6 Apr 2020 02:43:07 -0700 (PDT) Received: from localhost ([::1]:57150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOHZ-0003U1-Jq for importer@patchew.org; Mon, 06 Apr 2020 05:43:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44127) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGY-0001W8-Vn for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGW-00027y-Pv for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:02 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45160) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGU-00024t-Rf for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:41:59 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cw57025095; Mon, 6 Apr 2020 09:41:51 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 306jvmwr47-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:51 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cgbK092204; Mon, 6 Apr 2020 09:41:50 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 3073spk5sc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:50 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fnus030593; Mon, 6 Apr 2020 09:41:49 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:49 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=kIalzytJdDDfIc2BY1qxdqyet2Bto2Ynart6KyI/SrQ=; b=Qdpn1ugE6yQBWnCqapspOMbur7KZ3ZH1Zmu4MFo12dNxqP49/iD7QovnYLNbuUn5b6ox JslmbfupWxg12rfG+Y85BU10yrZz1jDqNN2k6mr3un4QaOBXUL1cBSpE2XQ2MqmM9ouy W5A7UuiJ7oQ9b2x2ipHwTC38eS+HEhGyCSdOUp6MxQLUmUv3aA1D+rCWOKxschWM3s5K 47Xgp3qftIfRD8MfiHZU+QHtVWH/GGXWd7/WnYQyms31bzMJN/dC/gHZPtBYA8QlSQvL W5/6V8iV3WrsUmBLYdAKR0wSbkByH9tBmyozM9fxB3pcbii3kVT1/Jr75ZI/Uva9KzNR bw== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 10/36] multi-process: build system for remote device process Date: Mon, 6 Apr 2020 02:41:00 -0700 Message-Id: <5d94fe42e8bcfcf4476117e1ce776f2397c81789.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id 0369cw57025095 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Modify Makefile to support the building of the remote device process. Implements main() function of remote device process. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 8 ++++++ Makefile | 2 ++ Makefile.objs | 27 ++++++++++++++++++ Makefile.target | 61 ++++++++++++++++++++++++++++++++++++++++- accel/Makefile.objs | 2 ++ backends/Makefile.objs | 2 ++ block/Makefile.objs | 2 ++ hw/Makefile.objs | 7 +++++ hw/block/Makefile.objs | 2 ++ hw/core/Makefile.objs | 18 ++++++++++++ hw/nvram/Makefile.objs | 2 ++ hw/pci/Makefile.objs | 4 +++ hw/scsi/Makefile.objs | 2 ++ migration/Makefile.objs | 2 ++ qom/Makefile.objs | 3 ++ remote/Makefile.objs | 1 + remote/remote-main.c | 23 ++++++++++++++++ stubs/replay.c | 4 +++ 18 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 remote/Makefile.objs create mode 100644 remote/remote-main.c diff --git a/MAINTAINERS b/MAINTAINERS index ff59f60fdc..ede5e32953 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2810,6 +2810,14 @@ S: Maintained F: hw/semihosting/ F: include/hw/semihosting/ =20 +Multi-process QEMU +M: Jagannathan Raman +M: Elena Ufimtseva +M: John G Johnson +S: Maintained +F: remote/Makefile.objs +F: remote/remote-main.c + Build and test automation ------------------------- Build and test automation diff --git a/Makefile b/Makefile index fc2808fb4b..12812a3dc7 100644 --- a/Makefile +++ b/Makefile @@ -474,6 +474,8 @@ dummy :=3D $(call unnest-vars,, \ qom-obj-y \ io-obj-y \ common-obj-y \ + remote-pci-obj-y \ + remote-lsi-obj-y \ common-obj-m \ trace-obj-y) =20 diff --git a/Makefile.objs b/Makefile.objs index f29c60c59d..f6654633b4 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -21,6 +21,33 @@ block-obj-$(CONFIG_REPLICATION) +=3D replication.o =20 block-obj-m =3D block/ =20 +######################################################### +# remote-pci-obj-y is common code used by remote devices + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D hw/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qom/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D backends/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D block/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D migration/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D accel/ + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D cpus-common.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D dma-helpers.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D blockdev.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qdev-monitor.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D bootdevice.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D iothread.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qemu-parse.o + +############################################################## +# remote-lsi-obj-y is code used to implement remote LSI device + +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D hw/ + +####################################################################### +# crypto-obj-y is code used by both qemu system emulation and qemu-img + crypto-obj-y =3D crypto/ =20 io-obj-y =3D io/ diff --git a/Makefile.target b/Makefile.target index 8ed1eba95b..70fa1eeca5 100644 --- a/Makefile.target +++ b/Makefile.target @@ -36,7 +36,17 @@ QEMU_PROG_BUILD =3D $(QEMU_PROG) endif endif =20 +ifdef CONFIG_MPQEMU +SCSI_DEV_PROG=3Dqemu-scsi-dev +SCSI_DEV_BUILD =3D $(SCSI_DEV_PROG) +endif + PROGS=3D$(QEMU_PROG) $(QEMU_PROGW) + +ifeq ($(TARGET_NAME)-$(CONFIG_MPQEMU)-$(CONFIG_USER_ONLY), x86_64-y-) +PROGS +=3D $(SCSI_DEV_PROG) +endif + STPFILES=3D =20 config-target.h: config-target.h-timestamp @@ -121,6 +131,20 @@ LIBS :=3D $(libs_cpu) $(LIBS) =20 obj-$(CONFIG_PLUGIN) +=3D plugins/ =20 +ifeq ($(TARGET_NAME)-$(CONFIG_MPQEMU)-$(CONFIG_USER_ONLY), x86_64-y-) +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/kvm-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/tcg-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/hax-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/whpx-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/vl-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/net-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/monitor.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/replay.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/xen-mapcache.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/audio.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/monitor.o +endif + ######################################################### # Linux user emulator target =20 @@ -179,6 +203,20 @@ endif # CONFIG_SOFTMMU dummy :=3D $(call unnest-vars,,obj-y) all-obj-y :=3D $(obj-y) =20 +dummy :=3D $(call unnest-vars,..,remote-pci-tgt-obj-y) +all-remote-pci-obj-y :=3D $(remote-pci-tgt-obj-y) + +ifeq ($(TARGET_NAME)-$(CONFIG_MPQEMU)-$(CONFIG_USER_ONLY), x86_64-y-) +all-remote-pci-obj-y +=3D memory.o +all-remote-pci-obj-y +=3D exec.o +all-remote-pci-obj-y +=3D exec-vary.o +all-remote-pci-obj-y +=3D ioport.o +all-remote-pci-obj-y +=3D cpus.o +endif + +remote-pci-obj-y :=3D +remote-lsi-obj-y :=3D + include $(SRC_PATH)/Makefile.objs dummy :=3D $(call unnest-vars,.., \ authz-obj-y \ @@ -189,7 +227,10 @@ dummy :=3D $(call unnest-vars,.., \ qom-obj-y \ io-obj-y \ common-obj-y \ - common-obj-m) + common-obj-m \ + remote-pci-obj-y \ + remote-lsi-obj-y) + all-obj-y +=3D $(common-obj-y) all-obj-y +=3D $(qom-obj-y) all-obj-$(CONFIG_SOFTMMU) +=3D $(authz-obj-y) @@ -197,8 +238,19 @@ all-obj-$(CONFIG_SOFTMMU) +=3D $(block-obj-y) $(charde= v-obj-y) all-obj-$(CONFIG_SOFTMMU) +=3D $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) +=3D $(io-obj-y) =20 +all-remote-pci-obj-y +=3D $(authz-obj-y) +all-remote-pci-obj-y +=3D $(block-obj-y) +all-remote-pci-obj-y +=3D $(crypto-obj-y) +all-remote-pci-obj-y +=3D $(io-obj-y) +all-remote-pci-obj-y +=3D $(chardev-obj-y) +all-remote-pci-obj-y +=3D $(remote-pci-obj-y) + + +all-remote-lsi-obj-y +=3D $(all-remote-pci-obj-y) $(remote-lsi-obj-y) + ifdef CONFIG_SOFTMMU $(QEMU_PROG_BUILD): config-devices.mak +$(SCSI_DEV_BUILD): config-devices.mak endif =20 COMMON_LDADDS =3D ../libqemuutil.a @@ -211,6 +263,13 @@ ifdef CONFIG_DARWIN $(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@") endif =20 +$(SCSI_DEV_BUILD): $(all-remote-lsi-obj-y) $(COMMON_LDADDS) + $(call LINK, $(filter-out %.mak, $^)) +ifdef CONFIG_DARWIN + $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@,"REZ= ","$(TARGET_DIR)$@") + $(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@") +endif + gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_= c.sh $@ $(TARGET_XML_FILES),"GEN","$(TARGET_DIR)$@") =20 diff --git a/accel/Makefile.objs b/accel/Makefile.objs index 17e5ac6061..e312dd4f01 100644 --- a/accel/Makefile.objs +++ b/accel/Makefile.objs @@ -3,3 +3,5 @@ obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) +=3D qte= st.o obj-$(CONFIG_KVM) +=3D kvm/ obj-$(CONFIG_TCG) +=3D tcg/ obj-y +=3D stubs/ + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D accel.o diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 28a847cd57..947cde39ac 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -21,3 +21,5 @@ common-obj-$(CONFIG_LINUX) +=3D hostmem-memfd.o common-obj-$(CONFIG_GIO) +=3D dbus-vmstate.o dbus-vmstate.o-cflags =3D $(GIO_CFLAGS) dbus-vmstate.o-libs =3D $(GIO_LIBS) + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D hostmem.o diff --git a/block/Makefile.objs b/block/Makefile.objs index 3635b6b4c1..3e7513967c 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -74,3 +74,5 @@ io_uring.o-cflags :=3D $(LINUX_IO_URING_CFLAGS) io_uring.o-libs :=3D $(LINUX_IO_URING_LIBS) parallels.o-cflags :=3D $(LIBXML2_CFLAGS) parallels.o-libs :=3D $(LIBXML2_LIBS) + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D stream.o diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 660e2b4373..af9235b6f2 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -44,3 +44,10 @@ endif =20 common-obj-y +=3D $(devices-dirs-y) obj-y +=3D $(devices-dirs-y) + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D core/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D block/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D pci/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D nvram/ + +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D scsi/ diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs index 4b4a2b338d..0b4644f472 100644 --- a/hw/block/Makefile.objs +++ b/hw/block/Makefile.objs @@ -16,3 +16,5 @@ obj-$(CONFIG_VIRTIO_BLK) +=3D virtio-blk.o obj-$(CONFIG_VHOST_USER_BLK) +=3D vhost-user-blk.o =20 obj-y +=3D dataplane/ + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D block.o cdrom.o hd-geometry.o diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index 6215e7c208..e3e80848c8 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -31,3 +31,21 @@ common-obj-$(CONFIG_OR_IRQ) +=3D or-irq.o common-obj-$(CONFIG_SPLIT_IRQ) +=3D split-irq.o common-obj-$(CONFIG_PLATFORM_BUS) +=3D platform-bus.o common-obj-$(CONFIG_GENERIC_LOADER) +=3D generic-loader.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qdev-properties.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qdev.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D bus.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D irq.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D hotplug.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D machine.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D fw-path-provider.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D reset.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D sysbus.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D loader.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D nmi.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qdev-properties-system.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qdev-fw.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D numa.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D cpu.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D vmstate-if.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D resettable.o diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs index f3ad921382..4d2d809106 100644 --- a/hw/nvram/Makefile.objs +++ b/hw/nvram/Makefile.objs @@ -6,3 +6,5 @@ common-obj-$(CONFIG_CHRP_NVRAM) +=3D chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) +=3D mac_nvram.o common-obj-$(CONFIG_NRF51_SOC) +=3D nrf51_nvm.o obj-$(CONFIG_PSERIES) +=3D spapr_nvram.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D fw_cfg.o diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs index c78f2fb24b..955be54472 100644 --- a/hw/pci/Makefile.objs +++ b/hw/pci/Makefile.objs @@ -12,3 +12,7 @@ common-obj-$(CONFIG_PCI_EXPRESS) +=3D pcie_port.o pcie_ho= st.o =20 common-obj-$(call lnot,$(CONFIG_PCI)) +=3D pci-stub.o common-obj-$(CONFIG_ALL) +=3D pci-stub.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D pci.o pci_bridge.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D msi.o msix.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D pcie.o diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs index 54b36ed8b1..ef97770922 100644 --- a/hw/scsi/Makefile.objs +++ b/hw/scsi/Makefile.objs @@ -13,3 +13,5 @@ obj-y +=3D virtio-scsi.o virtio-scsi-dataplane.o obj-$(CONFIG_VHOST_SCSI) +=3D vhost-scsi-common.o vhost-scsi.o obj-$(CONFIG_VHOST_USER_SCSI) +=3D vhost-scsi-common.o vhost-user-scsi.o endif + +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D scsi-generic.o scsi-bus.o lsi53c895a.= o scsi-disk.o emulation.o diff --git a/migration/Makefile.objs b/migration/Makefile.objs index 0fc619e380..ad33d77d0b 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -16,3 +16,5 @@ common-obj-$(CONFIG_RDMA) +=3D rdma.o common-obj-$(CONFIG_LIVE_BLOCK_MIGRATION) +=3D block.o =20 rdma.o-libs :=3D $(RDMA_LIBS) + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qemu-file.o vmstate.o qjson.o vmstate= -types.o diff --git a/qom/Makefile.objs b/qom/Makefile.objs index 1b45d104ba..7e9455db90 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -3,3 +3,6 @@ qom-obj-y +=3D object_interfaces.o =20 common-obj-$(CONFIG_SOFTMMU) +=3D qom-hmp-cmds.o qom-qmp-cmds.o storage-daemon-obj-y +=3D qom-qmp-cmds.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D object.o qom-qobject.o container.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D object_interfaces.o diff --git a/remote/Makefile.objs b/remote/Makefile.objs new file mode 100644 index 0000000000..a9b2256b2a --- /dev/null +++ b/remote/Makefile.objs @@ -0,0 +1 @@ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote-main.o diff --git a/remote/remote-main.c b/remote/remote-main.c new file mode 100644 index 0000000000..7c0764ad01 --- /dev/null +++ b/remote/remote-main.c @@ -0,0 +1,23 @@ +/* + * Remote device initialization + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include + +#include "qemu/module.h" + +int main(int argc, char *argv[]) +{ + module_call_init(MODULE_INIT_QOM); + + return 0; +} diff --git a/stubs/replay.c b/stubs/replay.c index 2e3feee6a9..9b53c0cb37 100644 --- a/stubs/replay.c +++ b/stubs/replay.c @@ -102,3 +102,7 @@ int replay_get_instructions(void) void replay_account_executed_instructions(void) { } + +void replay_add_blocker(Error *reason) +{ +} --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167328; cv=none; d=zohomail.com; s=zohoarc; b=B9iED9/Bop77bph81S0LzCZzd322oElmkDXdyHTy64yRFIuzd0w+WBkX/2Rw0nWzWFahmBbHwf7tqdJpz/P69hSkpYZAz7h/Xq8RR/LEDgx2sOItd/SpFYnocVqJJEzSn0nSKeYHFrvuzvIeTz9A6hLHvKYhJjA9PWqlHrTSGBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167328; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bMFeUW+PN4Fh62RHaFNoVJKqmfRyzEgWwQG3Iq3yf8U=; b=NJP5tZkERv4wtbByvuC+3FFSL34XcFqdEFVj/yrQhgPSltqCzgl2D39oaBYp5zPdpMWcPbhf8DyirEnIInHna5/jI8L2mxdr61tErDJAk5lTzJtqc2UsjSfldQWtHWUholJdON62+LvCkEK7+8uhCWZ/6NYoLV1zUkM3u2yWa6o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167328558600.2197540762145; Mon, 6 Apr 2020 03:02:08 -0700 (PDT) Received: from localhost ([::1]:57774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOZz-00046J-7h for importer@patchew.org; Mon, 06 Apr 2020 06:02:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44952) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOIS-0005uQ-IP for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOIQ-0003ix-EJ for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:00 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:46814) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOIQ-0003iD-53 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:58 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369grqm028621; Mon, 6 Apr 2020 09:43:52 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 306jvmwrc4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:43:52 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cgb9092222; Mon, 6 Apr 2020 09:41:51 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3073spk5tp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:51 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369foEq031799; Mon, 6 Apr 2020 09:41:51 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:50 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=poyiIix6Qk8vgRZdeHPTb6Q0vO16O4GTcIZpoY0+3tA=; b=RJFydkgBY+Ohr/VbT9SjM8/ZPTRgdbKhJPVAhWqOQ13xhZkXbDwQRCx3fWkbCcYkTPgr AI86t0X5uUuVCPld+y0a5soDm3y3gPcJ6Tqut9vNhq+ljQKM7IfLKSF0UWSdXp7hK8RG KMG6GW6mDMraJNkfGuGB/b+eWZ0x9GL7B8o+XXAMT4GGcqqCtboXGAh/LyfLhV8QALEB LFXDUdYn3KQJ7kYwFKhTS1zVQ+Ev/gtxD8A82JjVsfN/1p5PXKnGXFBo/57JiNrXTxYa YWDOYbY9WbzfZ2ujYrG3LfifivG9IBCjQuj1AAA4Zz/LcjxG/anXKb38ot398nWHQwy6 ZQ== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 11/36] multi-process: define mpqemu-link object Date: Mon, 6 Apr 2020 02:41:01 -0700 Message-Id: <44a31593aa51b50575c659db7906862572b70c13.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id 0369grqm028621 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Defines mpqemu-link object which forms the communication link between QEMU & emulation program. Adds functions to configure members of mpqemu-link object instance. Adds functions to send and receive messages over the communication channel. Adds GMainLoop to handle events received on the communication channel. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 2 + include/io/mpqemu-link.h | 127 ++++++++++++++++ io/Makefile.objs | 2 + io/mpqemu-link.c | 312 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 443 insertions(+) create mode 100644 include/io/mpqemu-link.h create mode 100644 io/mpqemu-link.c diff --git a/MAINTAINERS b/MAINTAINERS index ede5e32953..b895788ba7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2817,6 +2817,8 @@ M: John G Johnson S: Maintained F: remote/Makefile.objs F: remote/remote-main.c +F: include/io/mpqemu-link.h +F: io/mpqemu-link.c =20 Build and test automation ------------------------- diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h new file mode 100644 index 0000000000..af401e640c --- /dev/null +++ b/include/io/mpqemu-link.h @@ -0,0 +1,127 @@ +/* + * Communication channel between QEMU and remote device process + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef MPQEMU_LINK_H +#define MPQEMU_LINK_H + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "qom/object.h" +#include "qemu/thread.h" + +#define TYPE_MPQEMU_LINK "mpqemu-link" +#define MPQEMU_LINK(obj) \ + OBJECT_CHECK(MPQemuLinkState, (obj), TYPE_MPQEMU_LINK) + +#define REMOTE_MAX_FDS 8 + +#define MPQEMU_MSG_HDR_SIZE offsetof(MPQemuMsg, data1.u64) + +/** + * mpqemu_cmd_t: + * + * proc_cmd_t enum type to specify the command to be executed on the remote + * device. + */ +typedef enum { + INIT =3D 0, + MAX, +} mpqemu_cmd_t; + +/** + * MPQemuMsg: + * @cmd: The remote command + * @bytestream: Indicates if the data to be shared is structured (data1) + * or unstructured (data2) + * @size: Size of the data to be shared + * @data1: Structured data + * @fds: File descriptors to be shared with remote device + * @data2: Unstructured data + * + * MPQemuMsg Format of the message sent to the remote device from QEMU. + * + */ +typedef struct { + mpqemu_cmd_t cmd; + int bytestream; + size_t size; + + union { + uint64_t u64; + } data1; + + int fds[REMOTE_MAX_FDS]; + int num_fds; + + uint8_t *data2; +} MPQemuMsg; + +/** + * MPQemuChannel: + * @gsrc: GSource object to be used by loop + * @gpfd: GPollFD object containing the socket & events to monitor + * @sock: Socket to send/receive communication, same as the one in gpfd + * @send_lock: Mutex to synchronize access to the send stream + * @recv_lock: Mutex to synchronize access to the recv stream + * + * Defines the channel that make up the communication link + * between QEMU and remote process + */ + +typedef struct MPQemuChannel { + GSource gsrc; + GPollFD gpfd; + int sock; + QemuMutex send_lock; + QemuMutex recv_lock; +} MPQemuChannel; + +typedef struct MPQemuLinkState MPQemuLinkState; + +typedef void (*mpqemu_link_callback)(GIOCondition cond, MPQemuLinkState *l= ink, + MPQemuChannel *chan); + +/* + * MPQemuLinkState Instance info. of the communication + * link between QEMU and remote process. The Link could + * be made up of multiple channels. + * + * ctx GMainContext to be used for communication + * loop Main loop that would be used to poll for incoming data + * com Communication channel to transport control messages + * + */ + +struct MPQemuLinkState { + Object obj; + + GMainContext *ctx; + GMainLoop *loop; + + MPQemuChannel *com; + + mpqemu_link_callback callback; +}; + +MPQemuLinkState *mpqemu_link_create(void); +void mpqemu_link_finalize(MPQemuLinkState *s); + +void mpqemu_msg_send(MPQemuMsg *msg, MPQemuChannel *chan); +int mpqemu_msg_recv(MPQemuMsg *msg, MPQemuChannel *chan); + +void mpqemu_init_channel(MPQemuLinkState *s, MPQemuChannel **chan, int fd); +void mpqemu_destroy_channel(MPQemuChannel *chan); +void mpqemu_link_set_callback(MPQemuLinkState *s, + mpqemu_link_callback callback); +void mpqemu_start_coms(MPQemuLinkState *s, MPQemuChannel* chan); +bool mpqemu_msg_valid(MPQemuMsg *msg); + +#endif diff --git a/io/Makefile.objs b/io/Makefile.objs index 9a20fce4ed..5875ab0697 100644 --- a/io/Makefile.objs +++ b/io/Makefile.objs @@ -10,3 +10,5 @@ io-obj-y +=3D channel-util.o io-obj-y +=3D dns-resolver.o io-obj-y +=3D net-listener.o io-obj-y +=3D task.o + +io-obj-$(CONFIG_MPQEMU) +=3D mpqemu-link.o diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c new file mode 100644 index 0000000000..b7d3e53ae8 --- /dev/null +++ b/io/mpqemu-link.c @@ -0,0 +1,312 @@ +/* + * Communication channel between QEMU and remote device process + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "qemu/module.h" +#include "io/mpqemu-link.h" +#include "qemu/log.h" +#include "qemu/lockable.h" + +GSourceFuncs gsrc_funcs; + +static void mpqemu_link_inst_init(Object *obj) +{ + MPQemuLinkState *s =3D MPQEMU_LINK(obj); + + s->ctx =3D g_main_context_default(); + s->loop =3D g_main_loop_new(s->ctx, FALSE); +} + +static const TypeInfo mpqemu_link_info =3D { + .name =3D TYPE_MPQEMU_LINK, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(MPQemuLinkState), + .instance_init =3D mpqemu_link_inst_init, +}; + +static void mpqemu_link_register_types(void) +{ + type_register_static(&mpqemu_link_info); +} + +type_init(mpqemu_link_register_types) + +MPQemuLinkState *mpqemu_link_create(void) +{ + MPQemuLinkState *link =3D MPQEMU_LINK(object_new(TYPE_MPQEMU_LINK)); + + link->com =3D NULL; + + return link; +} + +void mpqemu_link_finalize(MPQemuLinkState *s) +{ + g_main_loop_unref(s->loop); + g_main_context_unref(s->ctx); + g_main_loop_quit(s->loop); + + mpqemu_destroy_channel(s->com); + + object_unref(OBJECT(s)); +} + +void mpqemu_msg_send(MPQemuMsg *msg, MPQemuChannel *chan) +{ + int rc; + uint8_t *data; + union { + char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))]; + struct cmsghdr align; + } u; + struct msghdr hdr; + struct cmsghdr *chdr; + int sock =3D chan->sock; + QemuMutex *lock =3D &chan->send_lock; + + struct iovec iov =3D { + .iov_base =3D (char *) msg, + .iov_len =3D MPQEMU_MSG_HDR_SIZE, + }; + + memset(&hdr, 0, sizeof(hdr)); + memset(&u, 0, sizeof(u)); + + hdr.msg_iov =3D &iov; + hdr.msg_iovlen =3D 1; + + if (msg->num_fds > REMOTE_MAX_FDS) { + qemu_log_mask(LOG_REMOTE_DEBUG, "%s: Max FDs exceeded\n", __func__= ); + return; + } + + if (msg->num_fds > 0) { + size_t fdsize =3D msg->num_fds * sizeof(int); + + hdr.msg_control =3D &u; + hdr.msg_controllen =3D sizeof(u); + + chdr =3D CMSG_FIRSTHDR(&hdr); + chdr->cmsg_len =3D CMSG_LEN(fdsize); + chdr->cmsg_level =3D SOL_SOCKET; + chdr->cmsg_type =3D SCM_RIGHTS; + memcpy(CMSG_DATA(chdr), msg->fds, fdsize); + hdr.msg_controllen =3D CMSG_SPACE(fdsize); + } + + WITH_QEMU_LOCK_GUARD(lock) { + do { + rc =3D sendmsg(sock, &hdr, 0); + } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); + + if (rc < 0) { + qemu_log_mask(LOG_REMOTE_DEBUG, "%s - sendmsg rc is %d, errno = is %d," + " sock %d\n", __func__, rc, errno, sock); + return; + } + + if (msg->bytestream) { + data =3D msg->data2; + } else { + data =3D (uint8_t *)msg + MPQEMU_MSG_HDR_SIZE; + } + + do { + rc =3D write(sock, data, msg->size); + } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); + } +} + + +int mpqemu_msg_recv(MPQemuMsg *msg, MPQemuChannel *chan) +{ + int rc; + uint8_t *data; + union { + char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))]; + struct cmsghdr align; + } u; + struct msghdr hdr; + struct cmsghdr *chdr; + size_t fdsize; + int sock =3D chan->sock; + QemuMutex *lock =3D &chan->recv_lock; + + struct iovec iov =3D { + .iov_base =3D (char *) msg, + .iov_len =3D MPQEMU_MSG_HDR_SIZE, + }; + + memset(&hdr, 0, sizeof(hdr)); + memset(&u, 0, sizeof(u)); + + hdr.msg_iov =3D &iov; + hdr.msg_iovlen =3D 1; + hdr.msg_control =3D &u; + hdr.msg_controllen =3D sizeof(u); + + WITH_QEMU_LOCK_GUARD(lock) { + do { + rc =3D recvmsg(sock, &hdr, 0); + } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); + + if (rc < 0) { + qemu_log_mask(LOG_REMOTE_DEBUG, "%s - recvmsg rc is %d, errno = is %d," + " sock %d\n", __func__, rc, errno, sock); + return rc; + } + + msg->num_fds =3D 0; + for (chdr =3D CMSG_FIRSTHDR(&hdr); chdr !=3D NULL; + chdr =3D CMSG_NXTHDR(&hdr, chdr)) { + if ((chdr->cmsg_level =3D=3D SOL_SOCKET) && + (chdr->cmsg_type =3D=3D SCM_RIGHTS)) { + fdsize =3D chdr->cmsg_len - CMSG_LEN(0); + msg->num_fds =3D fdsize / sizeof(int); + if (msg->num_fds > REMOTE_MAX_FDS) { + qemu_log_mask(LOG_REMOTE_DEBUG, + "%s: Max FDs exceeded\n", __func__); + return -ERANGE; + } + + memcpy(msg->fds, CMSG_DATA(chdr), fdsize); + break; + } + } + + if (msg->bytestream) { + if (!msg->size) { + qemu_mutex_unlock(lock); + return -EINVAL; + } + + msg->data2 =3D calloc(1, msg->size); + data =3D msg->data2; + } else { + data =3D (uint8_t *)&msg->data1; + } + + if (msg->size) { + do { + rc =3D read(sock, data, msg->size); + } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)= ); + } + } + return rc; +} + +static gboolean mpqemu_link_handler_prepare(GSource *gsrc, gint *timeout) +{ + g_assert(timeout); + + *timeout =3D -1; + + return FALSE; +} + +static gboolean mpqemu_link_handler_check(GSource *gsrc) +{ + MPQemuChannel *chan =3D (MPQemuChannel *)gsrc; + + return chan->gpfd.events & chan->gpfd.revents; +} + +static gboolean mpqemu_link_handler_dispatch(GSource *gsrc, GSourceFunc fu= nc, + gpointer data) +{ + MPQemuLinkState *s =3D (MPQemuLinkState *)data; + MPQemuChannel *chan =3D (MPQemuChannel *)gsrc; + + s->callback(chan->gpfd.revents, s, chan); + + if ((chan->gpfd.revents & G_IO_HUP) || (chan->gpfd.revents & G_IO_ERR)= ) { + return G_SOURCE_REMOVE; + } + + return G_SOURCE_CONTINUE; +} + +void mpqemu_link_set_callback(MPQemuLinkState *s, mpqemu_link_callback cal= lback) +{ + s->callback =3D callback; +} + +void mpqemu_init_channel(MPQemuLinkState *s, MPQemuChannel **chan, int fd) +{ + MPQemuChannel *src; + + gsrc_funcs =3D (GSourceFuncs){ + .prepare =3D mpqemu_link_handler_prepare, + .check =3D mpqemu_link_handler_check, + .dispatch =3D mpqemu_link_handler_dispatch, + .finalize =3D NULL, + }; + + src =3D (MPQemuChannel *)g_source_new(&gsrc_funcs, sizeof(MPQemuChanne= l)); + + src->sock =3D fd; + qemu_mutex_init(&src->send_lock); + qemu_mutex_init(&src->recv_lock); + + g_source_set_callback(&src->gsrc, NULL, (gpointer)s, NULL); + src->gpfd.fd =3D fd; + src->gpfd.events =3D G_IO_IN | G_IO_HUP | G_IO_ERR; + g_source_add_poll(&src->gsrc, &src->gpfd); + + *chan =3D src; +} + +void mpqemu_destroy_channel(MPQemuChannel *chan) +{ + g_source_unref(&chan->gsrc); + close(chan->sock); + qemu_mutex_destroy(&chan->send_lock); + qemu_mutex_destroy(&chan->recv_lock); +} + +void mpqemu_start_coms(MPQemuLinkState *s, MPQemuChannel* chan) +{ + g_assert(g_source_attach(&chan->gsrc, s->ctx)); + + g_main_loop_run(s->loop); +} + +bool mpqemu_msg_valid(MPQemuMsg *msg) +{ + if (msg->cmd >=3D MAX) { + return false; + } + + if (msg->bytestream) { + if (!msg->data2) { + return false; + } + } else { + if (msg->data2) { + return false; + } + } + + /* Verify FDs. */ + if (msg->num_fds >=3D REMOTE_MAX_FDS) { + return false; + } + if (msg->num_fds > 0) { + for (int i =3D 0; i < msg->num_fds; i++) { + if (fcntl(msg->fds[i], F_GETFL) =3D=3D -1) { + return false; + } + } + } + + return true; +} --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166534; cv=none; d=zohomail.com; s=zohoarc; b=BalvJY1j78IXhF5bWh0Z1DicXo4Y+Oinr3Ja+ypdgyY5YUnlPkmG+3fCZYT9jCHN2DxBG216Y+DSgLE9O5z3FcEL9fqEzmIajadZ/oI+e16dirtICJfS3aE6UwU+rTSlSmc2Lcp8mxyKzea1ZqG4CMYaAydeK5u27KMZs6iVAbQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=959nCTrI56f4p3sVT1WQASzy2cespo3AN8EG4QncjXU=; b=T1sPjMtlqjpD1Qx3LYqngGAX29p2W5PdajAYJOCMg682d3JYRCOsFhaSer6bCPB1bRBwPa6EuYYFECVgOP90MkpvRRsBrvgz7vo8GWGGDIB5DFNRQxrCVdFhkGnDw2CFcdByh2VVZ7LGUs6k4XQrtdIelLA75i00rVwww/H+tSI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166534277265.95306979690724; Mon, 6 Apr 2020 02:48:54 -0700 (PDT) Received: from localhost ([::1]:57378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLONA-000541-Pk for importer@patchew.org; Mon, 06 Apr 2020 05:48:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44144) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGa-0001Zl-PD for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGY-00029a-MQ for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:04 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45384) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGW-00027P-Ri for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:02 -0400 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 0369dkIJ069626; Mon, 6 Apr 2020 09:41:54 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 306j6m5tap-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369bK3t056244; Mon, 6 Apr 2020 09:41:53 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 3073qcncdp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:53 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369fqHY031805; Mon, 6 Apr 2020 09:41:52 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:52 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=959nCTrI56f4p3sVT1WQASzy2cespo3AN8EG4QncjXU=; b=VADl1ikVn74ixkeS9eIzbQihBhiD+jW7LfMAHaxYXktjMuQOcCNtrtK8d5ieSvUceLNS KZbrqOB5TKiqWoY0TzrRBKTBr/YtOi8Aye64fvvCPsVXeGZsa5RicOsDR2NfMElqXtkD EHhut2MdjkciFVCpoyLJbyIq1GngBTJwD4ZWpCvWrX4mBkkI1VNpzTlnfhnRcvZZW6ep L7nY9F1k78SCVh3x67ptHz/Pl1XTOSUd1qUclVdVrsHh3Y+t6qlt4Y3FBEtwYhoNftXS 9ouchganuVpNGkI0RxrkIO2XvaMg+Ssc7IB/wEcSSbbS/T7rpml+fRo1biLiGyfjryPC BQ== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 12/36] multi-process: add functions to synchronize proxy and remote endpoints Date: Mon, 6 Apr 2020 02:41:02 -0700 Message-Id: <013cbc654f4f22a60659e580e98bd45925614866.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=1 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman In some cases, for example MMIO read, QEMU has to wait for the remote to complete a command before proceeding. An eventfd based mechanism is added to synchronize QEMU & remote process. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- include/io/mpqemu-link.h | 7 +++++++ io/mpqemu-link.c | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index af401e640c..ef95599bca 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -124,4 +124,11 @@ void mpqemu_link_set_callback(MPQemuLinkState *s, void mpqemu_start_coms(MPQemuLinkState *s, MPQemuChannel* chan); bool mpqemu_msg_valid(MPQemuMsg *msg); =20 +#define GET_REMOTE_WAIT eventfd(0, EFD_CLOEXEC) +#define PUT_REMOTE_WAIT(wait) close(wait) +#define PROXY_LINK_WAIT_DONE 1 + +uint64_t wait_for_remote(int efd); +void notify_proxy(int fd, uint64_t val); + #endif diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index b7d3e53ae8..fa9b3a66b1 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -10,6 +10,7 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include =20 #include "qemu/module.h" #include "io/mpqemu-link.h" @@ -204,6 +205,46 @@ int mpqemu_msg_recv(MPQemuMsg *msg, MPQemuChannel *cha= n) return rc; } =20 +uint64_t wait_for_remote(int efd) +{ + struct pollfd pfd =3D { .fd =3D efd, .events =3D POLLIN }; + uint64_t val; + int ret; + + ret =3D poll(&pfd, 1, 1000); + + switch (ret) { + case 0: + qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: Timed out\= n"); + /* TODO: Kick-off error recovery */ + return ULLONG_MAX; + case -1: + qemu_log_mask(LOG_REMOTE_DEBUG, "Poll error wait_for_remote: %s\n", + strerror(errno)); + return ULLONG_MAX; + default: + if (read(efd, &val, sizeof(val)) =3D=3D -1) { + qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: %s\n", + strerror(errno)); + return ULLONG_MAX; + } + } + + val =3D (val =3D=3D ULLONG_MAX) ? val : (val - 1); + + return val; +} + +void notify_proxy(int efd, uint64_t val) +{ + val =3D (val =3D=3D ULLONG_MAX) ? val : (val + 1); + + if (write(efd, &val, sizeof(val)) =3D=3D -1) { + qemu_log_mask(LOG_REMOTE_DEBUG, "Error notify_proxy: %s\n", + strerror(errno)); + } +} + static gboolean mpqemu_link_handler_prepare(GSource *gsrc, gint *timeout) { g_assert(timeout); --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166868; cv=none; d=zohomail.com; s=zohoarc; b=LamPvLFayN0XUiQaEAXT/36/1WAQII3+lKdVhfDUlMKBUXDJ5dNNpN0S/RlBH4NiD8gHyTMh9pTY5hF2mLlI7uyupuN8foiZUeEIKAxMmNQagaFIPDMknpUKAFXutV4oFB9ho6LBbgZhDH2AZ5vrblNAzyUxXt2TJoA70dQC0R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166868; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AuuwH2bGZSTUDLjKhJIxmaIgB+kwsCV6G+kSslfrizs=; b=J19C19Hsz1cgFFwJdqLgLzA68MWJyUQJ7WFOTd+PDpA76yFRQJ1fkwLAHYAgaiBH/28vGSB4ssAiy/jETLrd549comT2+a3S0V7ZAkAQN9aAlmf81Or7f8Kyp7LSDAF06XAsi02JuZdr7xNXIeV/O5hB4OcmvFuowPZFPUVr/VQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166868284842.7173878606022; Mon, 6 Apr 2020 02:54:28 -0700 (PDT) Received: from localhost ([::1]:57540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOSZ-0007QV-1V for importer@patchew.org; Mon, 06 Apr 2020 05:54:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44251) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGp-0002Du-1X for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGn-0002LG-Ib for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGn-0002KS-9S for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:17 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cxUg025130; Mon, 6 Apr 2020 09:41:55 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 306jvmwr4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:55 +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 0369fO4F066128; Mon, 6 Apr 2020 09:41:54 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 307419xgj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:54 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fs5g030645; Mon, 6 Apr 2020 09:41:54 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:53 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=JmO6yBKztpXd9CZJ1RsWz9TkifxZcxC2nMOhMvI7YwA=; b=NHo51UX+mO/1jI3kGiWTgBmEqir71R7ED/muGyL/8NBT6yqnUYRE8KBaK4uZyFUxaTTx ks6z09hmR8yVVgoRuNdmAUv4XWPVZCUisO69fdKlh8SzTr79DB21djnBqxbKSKrSuSnH VihlJP3LmHK7/xgG72gRxdKeHB7/tQPhvDr9jhWdiDkpFcNHRoPqjKWIqvDeTZ/rtMKU 6dm8VNc9KUsIozErfcVggBQfmNXeO7Y/fEqmaYmO8TiLMgW8a+0Sh2TEWfw7JJb8ckSG CbkZk15wfMSJ4Hm3HsLoIOwPkAoGH651kghQ4JJHvUzyb7r1tNTyp7bxBa0KHwLXycqf Ww== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 13/36] multi-process: setup PCI host bridge for remote device Date: Mon, 6 Apr 2020 02:41:03 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id 0369cxUg025130 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman PCI host bridge is setup for the remote device process. It is implemented using remote-pcihost object. It is an extension of the PCI host bridge setup by QEMU. Remote-pcihost configures a PCI bus which could be used by the remote PCI device to latch on to. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 2 ++ hw/pci/Makefile.objs | 2 +- include/remote/pcihost.h | 45 ++++++++++++++++++++++++++++ remote/Makefile.objs | 1 + remote/pcihost.c | 64 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 include/remote/pcihost.h create mode 100644 remote/pcihost.c diff --git a/MAINTAINERS b/MAINTAINERS index b895788ba7..95c7ac77bd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2819,6 +2819,8 @@ F: remote/Makefile.objs F: remote/remote-main.c F: include/io/mpqemu-link.h F: io/mpqemu-link.c +F: include/remote/pcihost.h +F: remote/pcihost.c =20 Build and test automation ------------------------- diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs index 955be54472..90693a7695 100644 --- a/hw/pci/Makefile.objs +++ b/hw/pci/Makefile.objs @@ -13,6 +13,6 @@ common-obj-$(CONFIG_PCI_EXPRESS) +=3D pcie_port.o pcie_ho= st.o common-obj-$(call lnot,$(CONFIG_PCI)) +=3D pci-stub.o common-obj-$(CONFIG_ALL) +=3D pci-stub.o =20 -remote-pci-obj-$(CONFIG_MPQEMU) +=3D pci.o pci_bridge.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D pci.o pci_bridge.o pci_host.o pcie_ho= st.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D msi.o msix.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D pcie.o diff --git a/include/remote/pcihost.h b/include/remote/pcihost.h new file mode 100644 index 0000000000..7aca9ccaf1 --- /dev/null +++ b/include/remote/pcihost.h @@ -0,0 +1,45 @@ +/* + * PCI Host for remote device + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef REMOTE_PCIHOST_H +#define REMOTE_PCIHOST_H + +#include +#include + +#include "exec/memory.h" +#include "hw/pci/pcie_host.h" + +#define TYPE_REMOTE_HOST_DEVICE "remote-pcihost" +#define REMOTE_HOST_DEVICE(obj) \ + OBJECT_CHECK(RemPCIHost, (obj), TYPE_REMOTE_HOST_DEVICE) + +typedef struct RemPCIHost { + /*< private >*/ + PCIExpressHost parent_obj; + /*< public >*/ + + /* + * Memory Controller Hub (MCH) may not be necessary for the emulation + * program. The two important reasons for implementing a PCI host in t= he + * emulation program are: + * - Provide a PCI bus for IO devices + * - Enable translation of guest PA to the PCI bar regions + * + * For both the above mentioned purposes, it doesn't look like we would + * need the MCH + */ + + MemoryRegion *mr_pci_mem; + MemoryRegion *mr_sys_mem; + MemoryRegion *mr_sys_io; +} RemPCIHost; + +#endif diff --git a/remote/Makefile.objs b/remote/Makefile.objs index a9b2256b2a..2757f5a265 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1 +1,2 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote-main.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D pcihost.o diff --git a/remote/pcihost.c b/remote/pcihost.c new file mode 100644 index 0000000000..dbe081903e --- /dev/null +++ b/remote/pcihost.c @@ -0,0 +1,64 @@ +/* + * Remote PCI host device + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include +#include + +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_host.h" +#include "hw/pci/pcie_host.h" +#include "hw/qdev-properties.h" +#include "remote/pcihost.h" +#include "exec/memory.h" + +static const char *remote_host_root_bus_path(PCIHostState *host_bridge, + PCIBus *rootbus) +{ + return "0000:00"; +} + +static void remote_host_realize(DeviceState *dev, Error **errp) +{ + char *busname =3D g_strdup_printf("remote-pci-%ld", (unsigned long)get= pid()); + PCIHostState *pci =3D PCI_HOST_BRIDGE(dev); + RemPCIHost *s =3D REMOTE_HOST_DEVICE(dev); + + pci->bus =3D pci_root_bus_new(DEVICE(s), busname, + s->mr_pci_mem, s->mr_sys_io, + 0, TYPE_PCIE_BUS); +} + +static void remote_host_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIHostBridgeClass *hc =3D PCI_HOST_BRIDGE_CLASS(klass); + + hc->root_bus_path =3D remote_host_root_bus_path; + dc->realize =3D remote_host_realize; + + dc->user_creatable =3D false; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->fw_name =3D "pci"; +} + +static const TypeInfo remote_host_info =3D { + .name =3D TYPE_REMOTE_HOST_DEVICE, + .parent =3D TYPE_PCIE_HOST_BRIDGE, + .instance_size =3D sizeof(RemPCIHost), + .class_init =3D remote_host_class_init, +}; + +static void remote_machine_register(void) +{ + type_register_static(&remote_host_info); +} + +type_init(remote_machine_register) --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166305; cv=none; d=zohomail.com; s=zohoarc; b=ZxHP4i2XT3Gw/vlqm0v1GMAg4MhRiLjm1FCmuBUUDWAVg96VzZFSnKjsT3zH9P4egSFQt+29MpDship1gGPRyDWCwIQx/0rQNMktLiyYCm5BPuWEe7aFdsvOX/UscqoMutdkc3eTFgolcSTm9ICk1+VmLTLTXvtYZvRRMppp+i4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166305; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oL9pdaRecpPYGPEWLWbm8t1YkYPgrLJJa59ADE5WaOE=; b=APsf2KxvVM9PbGi9RObfa99EBqjRbCg3lxHCd97FJWfK88V8uBFvEBkkhaX6+ZWuRRzrbyL1qDpHSA9nUsq7uIr5zyTw0AGohRFM/tKrCI1kHYHmIHKzJwS283zBMezJwP+Vyz8Cnb3h9NdcsneWtU6Bgr06HjTmbg9WB3rmeiw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166305277571.5562619931393; Mon, 6 Apr 2020 02:45:05 -0700 (PDT) Received: from localhost ([::1]:57256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOJT-0006ue-Um for importer@patchew.org; Mon, 06 Apr 2020 05:45:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44191) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGh-0001s8-7O for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGf-0002EE-LB for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:11 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45322) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGf-0002D3-Cb for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:09 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369d0OR025179; Mon, 6 Apr 2020 09:41:58 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 306jvmwr4m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:57 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cfE2092163; Mon, 6 Apr 2020 09:41:57 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 3073spk5xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:57 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369ftxW030651; Mon, 6 Apr 2020 09:41:55 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:55 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=ryAEnQCWEwuN6zdfMf72ZhZnYh5nhoAZMWkb6smGonw=; b=ISvN+VlA6F/Y3DJe1iA1vQaK5mwvXQVykyW3THggOfkgbntYGR6Jr5sQp9GCcQ3j98B6 3n+XugaL5uJFA4qDjhwF3T5yztsYKA/e0lqeSsOSMnmXksbKtQWM9bHFANyNX+A/0Q83 kj3kS4spN5ZkFmRPUO/az0Wri3pzBlOx0JYaRPteHcLbzHZId/UPLyMv3jhp3NbKF1zE K6ZhtOunEGPTU+CWB6yRnoZgKkkmPAI+UXSPktL+CqEqBAQRIcPYJsFb2V991ZBVBwSQ N2cF9LpsMQhAqRGT7vl4o2CjVgB9lCVOJ8EcE0LEQaSTngwtOkJBS3Q9U0kFI8SDB0H5 vw== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 14/36] multi-process: setup a machine object for remote device process Date: Mon, 6 Apr 2020 02:41:04 -0700 Message-Id: <17fc1bb4e32a3d088a4ad72e9173e942f4cbe5b6.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id 0369d0OR025179 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman remote-machine object sets up various subsystems of the remote device process. Instantiate PCI host bridge object and initialize RAM, IO & PCI memory regions. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 2 + Makefile.objs | 1 + exec.c | 3 +- include/exec/address-spaces.h | 2 + include/remote/machine.h | 30 +++++++++++++ remote/Makefile.objs | 1 + remote/machine.c | 84 +++++++++++++++++++++++++++++++++++ remote/remote-main.c | 7 +++ util/Makefile.objs | 2 + 9 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 include/remote/machine.h create mode 100644 remote/machine.c diff --git a/MAINTAINERS b/MAINTAINERS index 95c7ac77bd..970cdfc2ef 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2821,6 +2821,8 @@ F: include/io/mpqemu-link.h F: io/mpqemu-link.c F: include/remote/pcihost.h F: remote/pcihost.c +F: include/remote/machine.h +F: remote/machine.c =20 Build and test automation ------------------------- diff --git a/Makefile.objs b/Makefile.objs index f6654633b4..ff3f06b146 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -31,6 +31,7 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D block/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D migration/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D accel/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D util/ =20 remote-pci-obj-$(CONFIG_MPQEMU) +=3D cpus-common.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D dma-helpers.o diff --git a/exec.c b/exec.c index d99bfef193..3bdad9d058 100644 --- a/exec.c +++ b/exec.c @@ -161,7 +161,6 @@ typedef struct subpage_t { #define PHYS_SECTION_UNASSIGNED 0 =20 static void io_mem_init(void); -static void memory_map_init(void); static void tcg_log_global_after_sync(MemoryListener *listener); static void tcg_commit(MemoryListener *listener); =20 @@ -2951,7 +2950,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/include/exec/address-spaces.h b/include/exec/address-spaces.h index db8bfa9a92..56a877b7ba 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 0000000000..7e9bdbe28e --- /dev/null +++ b/include/remote/machine.h @@ -0,0 +1,30 @@ +/* + * Remote machine configuration + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef REMOTE_MACHINE_H +#define REMOTE_MACHINE_H + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "hw/boards.h" +#include "remote/pcihost.h" +#include "qemu/notify.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 2757f5a265..13d4c48988 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1,2 +1,3 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote-main.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D pcihost.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D machine.o diff --git a/remote/machine.c b/remote/machine.c new file mode 100644 index 0000000000..97e4f194ea --- /dev/null +++ b/remote/machine.c @@ -0,0 +1,84 @@ +/* + * Machine for remote device + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#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 "qemu/thread.h" +#include "qom/object.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "qemu/main-loop.h" +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "qemu/notify.h" + +static void remote_machine_init(Object *obj) +{ + RemMachineState *s =3D REMOTE_MACHINE(obj); + RemPCIHost *rem_host; + MemoryRegion *system_memory, *system_io, *pci_memory; + + Error *error_abort =3D NULL; + + object_property_add_child(object_get_root(), "machine", obj, &error_ab= ort); + if (error_abort) { + error_report_err(error_abort); + } + + 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; + + object_property_add_child(OBJECT(s), "remote-device", OBJECT(rem_host), + &error_abort); + if (error_abort) { + error_report_err(error_abort); + return; + } + + qemu_mutex_lock_iothread(); + memory_region_add_subregion_overlap(system_memory, 0x0, pci_memory, -1= ); + qemu_mutex_unlock_iothread(); + + 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); diff --git a/remote/remote-main.c b/remote/remote-main.c index 7c0764ad01..ecf30e0cba 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -14,10 +14,17 @@ #include =20 #include "qemu/module.h" +#include "remote/pcihost.h" +#include "remote/machine.h" +#include "hw/boards.h" +#include "hw/qdev-core.h" +#include "qemu/main-loop.h" =20 int main(int argc, char *argv[]) { module_call_init(MODULE_INIT_QOM); =20 + current_machine =3D MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACH= INE))); + return 0; } diff --git a/util/Makefile.objs b/util/Makefile.objs index 6718a38b61..3c0e3a57c0 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -63,3 +63,5 @@ util-obj-y +=3D guest-random.o util-obj-$(CONFIG_GIO) +=3D dbus.o dbus.o-cflags =3D $(GIO_CFLAGS) dbus.o-libs =3D $(GIO_LIBS) + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D notify.o --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166479; cv=none; d=zohomail.com; s=zohoarc; b=Z52njwnQAcQ6yh7hqxiYUNRJ6jnmacTm7dz0shvhyV8g318M+fUTls6uV7YdIazTtbqikO2OdCJ7QHObu8HnozFzQ5csyIP/W43lpq0xGDJjq7JIJlssCfjl5za99GMjCVzsDS8r/RPq9CrM8LYnIrIflm7Wl76HjD9EDkwom/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166479; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ocxw30CD77itaXwWYc8usvbQ51B1ehp6L27/1r5Fr0A=; b=h/a0rq5htYohF2z97VKO8jdbHrvvpkUxJVEnm/0sxFbkW2NtHQV5GwEeI6ZwthegwK4JLk262INzkz8XFga7W28B4Ds4yYyVoX84pyeLH1mRXjlVS52TDuL2fn1Hflo3gn9Rq6QMbY8w5ffuddHci/PrcYRf3Ixlze8Pu2fxozY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166479337897.8001447381558; Mon, 6 Apr 2020 02:47:59 -0700 (PDT) Received: from localhost ([::1]:57350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOMH-0003ID-UQ for importer@patchew.org; Mon, 06 Apr 2020 05:47:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44158) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGc-0001fe-JB for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGa-0002Ar-Ux for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:06 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGa-0002AM-Mj for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:04 -0400 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 0369dppg089410; Mon, 6 Apr 2020 09:41:59 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 306hnqwtwu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:59 +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 0369fN4b066099; Mon, 6 Apr 2020 09:41:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 307419xgr4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:41:58 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fv3G030654; Mon, 6 Apr 2020 09:41:57 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:57 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=LvBkFU1eOYEKjiZWPiX4Hx8WWcTA1vJJzDeFSp2zBG4=; b=PXpnq2eebIt1BRbLTNUHB89PwdPJG00/NosrHaDs8djiSopmZ7IR+yapL1mDdM4lSsRO /S2RE7Tt79ROj0LjjHmBPzoR5Las7icWH83isL/uhIODkXyYeQ8AZazrjoZMsu7nzfZG G4jkKTsaQ8PFc9Ql5CLSADkAZ98UW1xz4szcBnmOECe1dBkgSg6ggSVFBwZ72QYFLg+j HK/rdWwHgZybE8us/OgHZj2QsvsyK7mw+MYIIdArFWWR8NRtug/7yXdjSxzFNqLfhXxR D27008l9pzKX7doEmp/RlWVCElqw/75MsoLNN3S9aZAQHQJbsZlltuwq5eKOl5jaWV4v sQ== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 15/36] multi-process: setup memory manager for remote device Date: Mon, 6 Apr 2020 02:41:05 -0700 Message-Id: <7b1614ac098dd88b32dd06a2d7e17f7d1b85492c.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=4 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2130.oracle.com id 0369dppg089410 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman sync_sysmem_msg_t message format is defined. It is used to send file descriptors of the RAM regions to remote device. RAM on the remote device is configured with a set of file descriptors. Old RAM regions are deleted and new regions, each with an fd, is added to the RAM. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 2 ++ Makefile.target | 2 ++ exec.c | 17 +++++++++++ include/exec/ram_addr.h | 2 ++ include/io/mpqemu-link.h | 12 ++++++++ include/remote/memory.h | 20 +++++++++++++ io/mpqemu-link.c | 13 +++++++++ remote/memory.c | 63 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 131 insertions(+) create mode 100644 include/remote/memory.h create mode 100644 remote/memory.c diff --git a/MAINTAINERS b/MAINTAINERS index 970cdfc2ef..7b46ec2e71 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2823,6 +2823,8 @@ F: include/remote/pcihost.h F: remote/pcihost.c F: include/remote/machine.h F: remote/machine.c +F: include/remote/memory.h +F: remote/memory.c =20 Build and test automation ------------------------- diff --git a/Makefile.target b/Makefile.target index 70fa1eeca5..500fa07fda 100644 --- a/Makefile.target +++ b/Makefile.target @@ -143,6 +143,8 @@ remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/replay.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/xen-mapcache.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/audio.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/monitor.o + +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D remote/memory.o endif =20 ######################################################### diff --git a/exec.c b/exec.c index 3bdad9d058..523e77dd09 100644 --- a/exec.c +++ b/exec.c @@ -2359,6 +2359,23 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, = MemoryRegion *mr, =20 return block; } + +void qemu_ram_init_from_fd(MemoryRegion *mr, int fd, uint64_t size, + ram_addr_t offset, Error **errp) +{ + char *name =3D g_strdup_printf("%d", fd); + + memory_region_init(mr, NULL, name, size); + mr->ram =3D true; + mr->terminates =3D true; + mr->destructor =3D NULL; + mr->align =3D 0; + mr->ram_block =3D qemu_ram_alloc_from_fd(size, mr, RAM_SHARED, fd, off= set, + errp); + mr->dirty_log_mask =3D tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; + + g_free(name); +} #endif =20 static diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 1b9f489ff0..d9d7314f51 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -122,6 +122,8 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, Mem= oryRegion *mr, RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, uint32_t ram_flags, int fd, off_t offset, Error **errp); +void qemu_ram_init_from_fd(MemoryRegion *mr, int fd, uint64_t size, + ram_addr_t offset, Error **errp); =20 RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host, MemoryRegion *mr, Error **errp); diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index ef95599bca..d46cb81058 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -16,6 +16,8 @@ =20 #include "qom/object.h" #include "qemu/thread.h" +#include "exec/cpu-common.h" +#include "exec/hwaddr.h" =20 #define TYPE_MPQEMU_LINK "mpqemu-link" #define MPQEMU_LINK(obj) \ @@ -27,15 +29,23 @@ =20 /** * mpqemu_cmd_t: + * SYNC_SYSMEM Shares QEMU's RAM with remote device's RAM * * proc_cmd_t enum type to specify the command to be executed on the remote * device. */ typedef enum { INIT =3D 0, + SYNC_SYSMEM, MAX, } mpqemu_cmd_t; =20 +typedef struct { + hwaddr gpas[REMOTE_MAX_FDS]; + uint64_t sizes[REMOTE_MAX_FDS]; + ram_addr_t offsets[REMOTE_MAX_FDS]; +} sync_sysmem_msg_t; + /** * MPQemuMsg: * @cmd: The remote command @@ -49,6 +59,7 @@ typedef enum { * MPQemuMsg Format of the message sent to the remote device from QEMU. * */ + typedef struct { mpqemu_cmd_t cmd; int bytestream; @@ -56,6 +67,7 @@ typedef struct { =20 union { uint64_t u64; + sync_sysmem_msg_t sync_sysmem; } data1; =20 int fds[REMOTE_MAX_FDS]; diff --git a/include/remote/memory.h b/include/remote/memory.h new file mode 100644 index 0000000000..e2e479bb6f --- /dev/null +++ b/include/remote/memory.h @@ -0,0 +1,20 @@ +/* + * Memory manager for remote device + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef REMOTE_MEMORY_H +#define REMOTE_MEMORY_H + +#include "qemu/osdep.h" +#include "exec/hwaddr.h" +#include "io/mpqemu-link.h" + +void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp); + +#endif diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index fa9b3a66b1..330a6deffe 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -348,6 +348,19 @@ bool mpqemu_msg_valid(MPQemuMsg *msg) } } } + /* Verify message specific fields. */ + switch (msg->cmd) { + case SYNC_SYSMEM: + if (msg->num_fds =3D=3D 0 || msg->bytestream !=3D 0) { + return false; + } + if (msg->size !=3D sizeof(msg->data1)) { + return false; + } + break; + default: + break; + } =20 return true; } diff --git a/remote/memory.c b/remote/memory.c new file mode 100644 index 0000000000..2c8b7bb42f --- /dev/null +++ b/remote/memory.c @@ -0,0 +1,63 @@ +/* + * Memory manager for remote device + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include +#include + +#include "qemu/osdep.h" +#include "qemu/queue.h" +#include "qemu-common.h" +#include "remote/memory.h" +#include "exec/memory.h" +#include "exec/address-spaces.h" +#include "cpu.h" +#include "exec/ram_addr.h" +#include "io/mpqemu-link.h" +#include "qemu/main-loop.h" +#include "qapi/error.h" + +void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp) +{ + sync_sysmem_msg_t *sysmem_info =3D &msg->data1.sync_sysmem; + MemoryRegion *sysmem, *subregion, *next; + Error *local_err =3D NULL; + int region; + + sysmem =3D get_system_memory(); + + qemu_mutex_lock_iothread(); + + memory_region_transaction_begin(); + + QTAILQ_FOREACH_SAFE(subregion, &sysmem->subregions, subregions_link, n= ext) { + if (subregion->ram) { + memory_region_del_subregion(sysmem, subregion); + qemu_ram_free(subregion->ram_block); + } + } + + for (region =3D 0; region < msg->num_fds; region++) { + subregion =3D g_new(MemoryRegion, 1); + qemu_ram_init_from_fd(subregion, msg->fds[region], + sysmem_info->sizes[region], + sysmem_info->offsets[region], &local_err); + if (local_err) { + error_propagate(errp, local_err); + break; + } + + memory_region_add_subregion(sysmem, sysmem_info->gpas[region], + subregion); + } + + memory_region_transaction_commit(); + + qemu_mutex_unlock_iothread(); +} --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166539; cv=none; d=zohomail.com; s=zohoarc; b=csbGlmP1eu+ovx5fHbKPn2K3Pwbl+9ZIPX9IRh24MukzOZVrGORq2/ValA5t1dP63QUZHGfyr6wiepzQurVkCn2YCaxLoRgmu1/PoR/S7VBWyYhA+WJOn/ofsVSG0bTyE4X/QGSTPungbvzu4NM6SfJ+O6ZAInrtqZ37/MXZR78= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166539; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ovXmJb751tMmY62g+3cNjputDMZHGQwW/4lf2VA6e2I=; b=I42kex+HxDUsbn4cuWOPG3rkkXvSLHmSX9OTrzcSXYj4dZZqfR0J2FbYjRa+JvnZA1xiDHaEnn3+E7PnGPxb8OQh3k6Ic3OpRXAeMTsAfQ/gDcLZ8UgHFIB7ZC0vqKG7hLTCZgVRvUPq+qzpFJUtU268+iHJeSW3xuKeHXzAHbY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166539506433.3546303522893; Mon, 6 Apr 2020 02:48:59 -0700 (PDT) Received: from localhost ([::1]:57387 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLONG-0005EJ-0B for importer@patchew.org; Mon, 06 Apr 2020 05:48:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44204) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGi-0001w3-Fh for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGh-0002Fb-9O for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45358) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGg-0002El-W7 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:11 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369dA07025336; Mon, 6 Apr 2020 09:42:01 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 306jvmwr4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:00 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cUFY006236; Mon, 6 Apr 2020 09:42:00 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 3073xvtug9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:00 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369fwaK013611; Mon, 6 Apr 2020 09:41:59 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:41:58 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=ovXmJb751tMmY62g+3cNjputDMZHGQwW/4lf2VA6e2I=; b=ddhA0ToLKA9UXp3zMlgmntRIpO4LccokP4JXYSwTs2XbOP8YLu+Iv8zZxi5orCuNlfMl CRnNgK+SgDmR4abqlD9xNkjkRCSuMDyjpaX45Fjycsiw55+8Falqg/dS7pQ/+bCe0WSe X+pxoqh+pXEesWQsz59pEVCqCeFhfne60dkuvGnEr1sX7wqf+u7p7PmN7cCEaYJ1eMDX OnDW2U6ucyuNmQp3L8Z5gFVcws+607fWPgGq6uamHfQGOBJMo5816rREbnJGvARnBxtl ZDKghnt8vBdiM95tGGs11yOflDbpE5DexGzjxCdm4qb39HcEKKuZjEKefZjDiGQF1DUU rA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 16/36] multi-process: remote process initialization Date: Mon, 6 Apr 2020 02:41:06 -0700 Message-Id: <73241ca8e613a00d89f86d214bf586cad658a616.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=3 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 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 | 87 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index ecf30e0cba..51595f3141 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -12,6 +12,7 @@ #include "qemu-common.h" =20 #include +#include =20 #include "qemu/module.h" #include "remote/pcihost.h" @@ -19,12 +20,98 @@ #include "hw/boards.h" #include "hw/qdev-core.h" #include "qemu/main-loop.h" +#include "remote/memory.h" +#include "io/mpqemu-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" +#include "exec/ramlist.h" + +static MPQemuLinkState *mpqemu_link; + +static void process_msg(GIOCondition cond, MPQemuLinkState *link, + MPQemuChannel *chan) +{ + MPQemuMsg *msg =3D NULL; + Error *err =3D NULL; + + if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { + goto finalize_loop; + } + + msg =3D g_malloc0(sizeof(MPQemuMsg)); + + if (mpqemu_msg_recv(msg, chan) < 0) { + error_setg(&err, "Failed to receive message"); + goto finalize_loop; + } + + switch (msg->cmd) { + case INIT: + break; + default: + error_setg(&err, "Unknown command"); + goto finalize_loop; + } + + g_free(msg->data2); + g_free(msg); + + return; + +finalize_loop: + if (err) { + error_report_err(err); + } + g_free(msg); + mpqemu_link_finalize(mpqemu_link); + mpqemu_link =3D NULL; +} =20 int main(int argc, char *argv[]) { + Error *err =3D NULL; + module_call_init(MODULE_INIT_QOM); =20 + bdrv_init_with_whitelist(); + + if (qemu_init_main_loop(&err)) { + error_report_err(err); + return -EBUSY; + } + + qemu_init_cpu_loop(); + + page_size_init(); + + qemu_mutex_init(&ram_list.mutex); + current_machine =3D MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACH= INE))); =20 + mpqemu_link =3D mpqemu_link_create(); + if (!mpqemu_link) { + printf("Could not create MPQemu link\n"); + return -1; + } + + mpqemu_init_channel(mpqemu_link, &mpqemu_link->com, STDIN_FILENO); + + mpqemu_link_set_callback(mpqemu_link, process_msg); + + qdev_machine_creation_done(); + qemu_mutex_lock_iothread(); + qemu_run_machine_init_done_notifiers(); + qemu_mutex_unlock_iothread(); + + mpqemu_start_coms(mpqemu_link, mpqemu_link->com); + return 0; } --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166582; cv=none; d=zohomail.com; s=zohoarc; b=foR20r5OvwbtSm2Eqh4DKdFsq7p+8qKhmPwyLq1pjl7NVgBO2Uw++47QcuBUmJK0eQ0LsMzrXAiZvuFQ+ToBBpj/DRL8/drlCCk/H8LErUzaIb7Iff8mxEm2bEiP/O4qd8V1Fkt+TkTImmFILm3OdLg7hmI5NdlUjxhe4st8gFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166582; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xT1jzoEkW70yIdgluQ/8FNMIA4EeQ1p50dRX1tMQB58=; b=WtUOPrQGujBD5EhXniyCLeXmTSgSsHddLZR1NdoF8yofraDkfhfVYQTq2g6sWv1dZupJtqmhbj31uoCSyvO2NvPxlvkOiCyq87U7ifDWiCf8WQhvSuKQ2wMdm8mDS7uPZQ1vqQKyrYQrsNH73zgkHLCKhkCtTgq4IFV0E9LIFs8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166582809357.49940763153586; Mon, 6 Apr 2020 02:49:42 -0700 (PDT) Received: from localhost ([::1]:57406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLONx-00070p-B0 for importer@patchew.org; Mon, 06 Apr 2020 05:49:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44176) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGf-0001mz-FW for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGe-0002D7-6e for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:09 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:34746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGd-0002CI-U8 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:08 -0400 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 0369dobT089398; Mon, 6 Apr 2020 09:42:02 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 306hnqwtx4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:01 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cghc092199; Mon, 6 Apr 2020 09:42:01 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3073spk64f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:01 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369g0P6031832; Mon, 6 Apr 2020 09:42:00 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:00 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=E2poaPXRq0thx+nOqFvdQBZjmW7W6xIxA/hOatXPaB4=; b=vYigjTGiwcZ2D3+QqSsvm1lUuTI4e3gVIRcQ01ymWHRN3eJROF/lXC67BTdVaDPFhndZ PpxXzzWvLL6uQS35JyObMiIl5HIebg8bHZAQ1astlZDPMFkQwCNyb6bZRV0O6Tub0zHZ NIJgMYBc5obN0VWXtRIPzlnwL4/OdkJzUnSYF/mCYqHhx2QfWEYuRqFcME33xlZZ8fTl W4Ruh8BJFBrutQTD+J1rJMTVnKPeO3mLxydU7gEY+oJ0iaTChyeFLtGMK4qk4HQFBWQH ifbcbnEevlbwFhjl2PruXcHTW7tRuKnY/l1/Infiao0McKtd02qjx06HwVVhzBuuhnVl 0g== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 17/36] multi-process: introduce proxy object Date: Mon, 6 Apr 2020 02:41:07 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2130.oracle.com id 0369dobT089398 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Defines a PCI Device proxy object as a parent of TYPE_PCI_DEVICE. PCI Proxy Object registers as a PCI device with QEMU and forwards all PCI accesses to the remote process using the communication channel. Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- MAINTAINERS | 3 ++ hw/Makefile.objs | 2 ++ hw/proxy/Makefile.objs | 1 + hw/proxy/qemu-proxy.c | 56 +++++++++++++++++++++++++++++++++++ include/hw/proxy/qemu-proxy.h | 46 ++++++++++++++++++++++++++++ include/io/mpqemu-link.h | 1 + 6 files changed, 109 insertions(+) create mode 100644 hw/proxy/Makefile.objs create mode 100644 hw/proxy/qemu-proxy.c create mode 100644 include/hw/proxy/qemu-proxy.h diff --git a/MAINTAINERS b/MAINTAINERS index 7b46ec2e71..e2ac5b08a4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2825,6 +2825,9 @@ F: include/remote/machine.h F: remote/machine.c F: include/remote/memory.h F: remote/memory.c +F: hw/proxy/Makefile.objs +F: hw/proxy/qemu-proxy.c +F: include/hw/proxy/qemu-proxy.h =20 Build and test automation ------------------------- diff --git a/hw/Makefile.objs b/hw/Makefile.objs index af9235b6f2..7b489b12a5 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -45,6 +45,8 @@ endif common-obj-y +=3D $(devices-dirs-y) obj-y +=3D $(devices-dirs-y) =20 +common-obj-$(CONFIG_MPQEMU) +=3D proxy/ + remote-pci-obj-$(CONFIG_MPQEMU) +=3D core/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D block/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D pci/ diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs new file mode 100644 index 0000000000..eb81624cf8 --- /dev/null +++ b/hw/proxy/Makefile.objs @@ -0,0 +1 @@ +common-obj-$(CONFIG_MPQEMU) +=3D qemu-proxy.o diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c new file mode 100644 index 0000000000..bf6c4117ef --- /dev/null +++ b/hw/proxy/qemu-proxy.c @@ -0,0 +1,56 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "qapi/error.h" +#include "io/mpqemu-link.h" +#include "hw/proxy/qemu-proxy.h" +#include "hw/pci/pci.h" + +static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) +{ + PCIProxyDev *dev =3D PCI_PROXY_DEV(device); + PCIProxyDevClass *k =3D PCI_PROXY_DEV_GET_CLASS(dev); + Error *local_err =3D NULL; + + if (k->realize) { + k->realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } + } +} + +static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) +{ + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + k->realize =3D pci_proxy_dev_realize; +} + +static const TypeInfo pci_proxy_dev_type_info =3D { + .name =3D TYPE_PCI_PROXY_DEV, + .parent =3D TYPE_PCI_DEVICE, + .instance_size =3D sizeof(PCIProxyDev), + .class_size =3D sizeof(PCIProxyDevClass), + .class_init =3D pci_proxy_dev_class_init, + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; + +static void pci_proxy_dev_register_types(void) +{ + type_register_static(&pci_proxy_dev_type_info); +} + +type_init(pci_proxy_dev_register_types) + diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h new file mode 100644 index 0000000000..d7eaf26f29 --- /dev/null +++ b/include/hw/proxy/qemu-proxy.h @@ -0,0 +1,46 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef QEMU_PROXY_H +#define QEMU_PROXY_H + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "io/mpqemu-link.h" +#include "hw/pci/pci.h" + +#define TYPE_PCI_PROXY_DEV "pci-proxy-dev" + +#define PCI_PROXY_DEV(obj) \ + OBJECT_CHECK(PCIProxyDev, (obj), TYPE_PCI_PROXY_DEV) + +#define PCI_PROXY_DEV_CLASS(klass) \ + OBJECT_CLASS_CHECK(PCIProxyDevClass, (klass), TYPE_PCI_PROXY_D= EV) + +#define PCI_PROXY_DEV_GET_CLASS(obj) \ + OBJECT_GET_CLASS(PCIProxyDevClass, (obj), TYPE_PCI_PROXY_DEV) + +typedef struct PCIProxyDev { + PCIDevice parent_dev; + + MPQemuLinkState *mpqemu_link; + + int socket; + +} PCIProxyDev; + +typedef struct PCIProxyDevClass { + PCIDeviceClass parent_class; + + void (*realize)(PCIProxyDev *dev, Error **errp); + + char *command; +} PCIProxyDevClass; + +#endif /* QEMU_PROXY_H */ diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index d46cb81058..73cc59b874 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include "qemu-common.h" =20 +#include "sys/eventfd.h" #include "qom/object.h" #include "qemu/thread.h" #include "exec/cpu-common.h" --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166754; cv=none; d=zohomail.com; s=zohoarc; b=C6wL0i0LhYZF+7BZtQCdx2pyKyGeNcTOD0/9/GOsqX9v1+s39nCMJPHuEHVYp+p5LCilokk1lHjsW+xLWFKbn2DTUUnrkOayyu6xrhqyIuy5xdX5tRXRTlwgjL2/x0chOwxc597NiijsMbkBjQ3oKr/dmvnCGRJO41eqsgwnbqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166754; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b3tR5kc/fZFEBgfsLLZnsuzzLDNVQvVsWREjDfZMZ4I=; b=gooTEg67orIz+XV/lwBTucUVaiLGQHOQocuqCn7TV5upsJIzgQbz8aJmj1ttEgGs3P33p8U+ePIloAbu6uMg4zlnQmrMRB3sguwAr43fsXEBokAf8rH1lT+voypncbkrjdNWlrqCJhggc2fi18N469ooamxB4vYM2BCO2kwSaos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158616675409744.16678977823244; Mon, 6 Apr 2020 02:52:34 -0700 (PDT) Received: from localhost ([::1]:57496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOQi-0003qf-Nr for importer@patchew.org; Mon, 06 Apr 2020 05:52:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44235) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGo-0002BU-59 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGm-0002Ka-Pc for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:18 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45438) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGm-0002Jh-Fw for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:16 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cw59025095; Mon, 6 Apr 2020 09:42:03 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 306jvmwr55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:03 +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 0369fNth066091; Mon, 6 Apr 2020 09:42:02 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 307419xgyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:02 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369g2lx030676; Mon, 6 Apr 2020 09:42:02 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:01 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=b3tR5kc/fZFEBgfsLLZnsuzzLDNVQvVsWREjDfZMZ4I=; b=rH5IqK5K5Pn1Kk+dl0juay/pKJYx6jgizwSxUx4ZIGowRh78zHOb54bXBvNrhnPdGBjZ geSy6wQBbGugBjkUCoGt8DootuZAMT0RWvYe7o6MF2dyEUziblRwb/qK8WWVjXBVgkVI qOr5mCPhBOe/weeVaEJqPS2no0aq8XELSJN8WVq1+q+10Dc+xo6zDHs5EwBfegAHA1g9 tkBV13Rl6k2IWEhhEH+x5pcVq4jkJQX7jjgTFasMxv/8gCgvKOMroZ4VEVgtDLSMfF5Z dP1TeuZKTspm3dYooPZOZTedl8OLhlU8HTi9ZwEz1EfBRSm7TDTI6VtY/esvCw/ND0iP BA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 18/36] multi-process: Initialize Proxy Object's communication channel Date: Mon, 6 Apr 2020 02:41:08 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Add "socket" object property which initializes the communication channel Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- hw/proxy/qemu-proxy.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index bf6c4117ef..40bf56fd37 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -14,6 +14,25 @@ #include "hw/proxy/qemu-proxy.h" #include "hw/pci/pci.h" =20 +static void proxy_set_socket(Object *obj, const char *str, Error **errp) +{ + PCIProxyDev *pdev =3D PCI_PROXY_DEV(obj); + + pdev->socket =3D atoi(str); + + mpqemu_init_channel(pdev->mpqemu_link, &pdev->mpqemu_link->com, + pdev->socket); +} + +static void proxy_init(Object *obj) +{ + PCIProxyDev *pdev =3D PCI_PROXY_DEV(obj); + + pdev->mpqemu_link =3D mpqemu_link_create(); + + object_property_add_str(obj, "socket", NULL, proxy_set_socket, NULL); +} + static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) { PCIProxyDev *dev =3D PCI_PROXY_DEV(device); @@ -41,6 +60,7 @@ static const TypeInfo pci_proxy_dev_type_info =3D { .instance_size =3D sizeof(PCIProxyDev), .class_size =3D sizeof(PCIProxyDevClass), .class_init =3D pci_proxy_dev_class_init, + .instance_init =3D proxy_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { }, --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166706; cv=none; d=zohomail.com; s=zohoarc; b=VWKWFwbFELR3anQiiH+LgvAQvlYpp9CS9KPx+5AMR2Nzh9rgzCTk1n0knEQywGFc+WG7YtvMD+gtmKpvhyaVAzw3IIEE2mKAePzGNolZeObWx9KO4oJFU5s5YJHExxxJqRaWhorpvIMJGlBuN11rnSOL/545Ssgau3iYI57j6Ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166706; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RM+C3xEy7RjPnPzF/4GEN8h76sUo5WL9hA6KDYrbvm0=; b=P64KIaJ41wabk/Twm2LaL17tQoHkTsnFCta6LI32S7KWuNwFyoOyv79sF6DGME3qVn7g8VXdQ7g0OMn4enFhLw5d8drZj1LiZEhy4hGx0uxmHcvs6CBL7tPIZEaLI3SGwmycbrMoTa8nUta34ZzPz3GBwCAdZ1f9iRL2F7NbwUU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158616670666092.69985994004674; Mon, 6 Apr 2020 02:51:46 -0700 (PDT) Received: from localhost ([::1]:57462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOPx-00022D-Et for importer@patchew.org; Mon, 06 Apr 2020 05:51:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44266) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGp-0002G6-Q1 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGo-0002M1-HS for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45482) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGo-0002Ky-8k for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:18 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cxbN025132; Mon, 6 Apr 2020 09:42:06 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 306jvmwr5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:06 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cgIY092169; Mon, 6 Apr 2020 09:42:06 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 3073spk68m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:05 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369g3vr006937; Mon, 6 Apr 2020 09:42:03 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:03 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=RM+C3xEy7RjPnPzF/4GEN8h76sUo5WL9hA6KDYrbvm0=; b=pvmIbv9L0AszPYD2bRI9BXaH2opZmFnPv5/2NR2LR3I6z5KEb9knkZaoNjitZ/JzQuz+ OUXoZQhrLlpJJmKPCwUrkpHK3vYojDqX1x1SeVhE+HJWCevel9IILoYT6eI2KxvA9u+P WISninIavJBf5TQESoV7YpdoUmHTjjWIEEhN24R2fd4aij86bkrh+JREPFs7EXQEtgWO FjyRQLi9q3LWdM8TNhIBEZfBQbeVlZBb+Ak6IhgI00NMDclDX45RoI4tFPWSSagoaDak hMbsrcHz2SyX7/oT28ChcujgJYD2+9lgi70x2QwCQIz2IEft76CCMw/MjpJNzICti0u+ fA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 19/36] multi-process: Connect Proxy Object with device in the remote process Date: Mon, 6 Apr 2020 02:41:09 -0700 Message-Id: <0b56423127fe29ddd74ce1162038d028f9ba7fe3.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=3 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=3 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Send a message to the remote process to connect PCI device with the corresponding Proxy object in QEMU Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- hw/proxy/qemu-proxy.c | 34 +++++++++++++++++++++++++++++++ include/io/mpqemu-link.h | 5 +++++ io/mpqemu-link.c | 3 +++ remote/remote-main.c | 43 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 40bf56fd37..9b5e429a88 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -17,11 +17,45 @@ static void proxy_set_socket(Object *obj, const char *str, Error **errp) { PCIProxyDev *pdev =3D PCI_PROXY_DEV(obj); + DeviceState *dev =3D DEVICE(obj); + MPQemuMsg msg =3D { 0 }; + int wait, fd[2]; =20 pdev->socket =3D atoi(str); =20 mpqemu_init_channel(pdev->mpqemu_link, &pdev->mpqemu_link->com, pdev->socket); + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { + error_setg(errp, "Failed to create socket for device channel"); + return; + } + + wait =3D GET_REMOTE_WAIT; + + msg.cmd =3D CONNECT_DEV; + msg.bytestream =3D 1; + msg.data2 =3D (uint8_t *)g_strdup(dev->id); + msg.size =3D sizeof(msg.data2); + msg.num_fds =3D 2; + msg.fds[0] =3D wait; + msg.fds[1] =3D fd[1]; + + mpqemu_msg_send(&msg, pdev->mpqemu_link->com); + + if (wait_for_remote(wait)) { + error_setg(errp, "Failed to connect device to the remote"); + close(fd[0]); + } else { + mpqemu_init_channel(pdev->mpqemu_link, &pdev->mpqemu_link->dev, + fd[0]); + } + + PUT_REMOTE_WAIT(wait); + + close(fd[1]); + + g_free(msg.data2); } =20 static void proxy_init(Object *obj) diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index 73cc59b874..ebae9afc45 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -38,6 +38,7 @@ typedef enum { INIT =3D 0, SYNC_SYSMEM, + CONNECT_DEV, MAX, } mpqemu_cmd_t; =20 @@ -120,8 +121,12 @@ struct MPQemuLinkState { GMainLoop *loop; =20 MPQemuChannel *com; + MPQemuChannel *dev; =20 mpqemu_link_callback callback; + + void *opaque; + QemuThread thread; }; =20 MPQemuLinkState *mpqemu_link_create(void); diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index 330a6deffe..b395869a22 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -46,6 +46,9 @@ MPQemuLinkState *mpqemu_link_create(void) MPQemuLinkState *link =3D MPQEMU_LINK(object_new(TYPE_MPQEMU_LINK)); =20 link->com =3D NULL; + link->dev =3D NULL; + + link->opaque =3D NULL; =20 return link; } diff --git a/remote/remote-main.c b/remote/remote-main.c index 51595f3141..22319cb5ea 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -34,8 +34,48 @@ #include "block/block.h" #include "exec/ramlist.h" =20 +static void process_msg(GIOCondition cond, MPQemuLinkState *link, + MPQemuChannel *chan); + static MPQemuLinkState *mpqemu_link; =20 +#define LINK_TO_DEV(link) ((PCIDevice *)link->opaque) + +static gpointer dev_thread(gpointer data) +{ + MPQemuLinkState *link =3D data; + + mpqemu_start_coms(link, link->dev); + + return NULL; +} + +static void process_connect_dev_msg(MPQemuMsg *msg) +{ + char *devid =3D (char *)msg->data2; + MPQemuLinkState *link =3D NULL; + DeviceState *dev =3D NULL; + int wait =3D msg->fds[0]; + int ret =3D 0; + + dev =3D qdev_find_recursive(sysbus_get_default(), devid); + if (!dev) { + ret =3D 0xff; + goto exit; + } + + link =3D mpqemu_link_create(); + link->opaque =3D (void *)PCI_DEVICE(dev); + + mpqemu_init_channel(link, &link->dev, msg->fds[1]); + mpqemu_link_set_callback(link, process_msg); + qemu_thread_create(&link->thread, "dev_thread", dev_thread, link, + QEMU_THREAD_JOINABLE); + +exit: + notify_proxy(wait, ret); +} + static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan) { @@ -56,6 +96,9 @@ static void process_msg(GIOCondition cond, MPQemuLinkStat= e *link, switch (msg->cmd) { case INIT: break; + case CONNECT_DEV: + process_connect_dev_msg(msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166988; cv=none; d=zohomail.com; s=zohoarc; b=QiOG8ilc5KixPRJozfWmq5Rfz4WAX4h6SnRdbl+diZBzvjjG8rJ8h7i94i/a4RGjGVz4L9he+UMZEU69EElIRf3teDgF5BuI2JtjusuKS3ImpuNRWAiaVQXB2UPcBymszCksJZlbn0Hv793o7Fn6HJ3PG+0mP5CsjVW+nLk6wIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166988; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bx0c6Hybu8iBv8fzwLbjyVA2WnIXvJlvCCBNV6FRf0M=; b=CvC/T2J4ipyCRoM2SfDfzdNgOxPr63GtQ6Lbk1Op57bKeS9hpaxvT0dBVRlvqBG9aavvFJFzzBnp1/slkmelYb/iGm2ewOQgnlwf7BG0zhd7CWT/t6LKlvOV1m3SOA7kxUo+1ULKx/AbROQQ8zNWhdOU5SXX3b9mR3At9/KXLWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166988820680.185508329575; Mon, 6 Apr 2020 02:56:28 -0700 (PDT) Received: from localhost ([::1]:57598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOUV-0002Tr-Jh for importer@patchew.org; Mon, 06 Apr 2020 05:56:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44298) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGv-0002WW-C1 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGu-0002PZ-1o for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:25 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35004) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGt-0002Or-Pq for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:23 -0400 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 0369dotd089403; Mon, 6 Apr 2020 09:42:07 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 306hnqwtxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:07 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cVKr006344; Mon, 6 Apr 2020 09:42:07 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 3073xvtuv2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:07 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369g5uN006940; Mon, 6 Apr 2020 09:42:05 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:04 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=bx0c6Hybu8iBv8fzwLbjyVA2WnIXvJlvCCBNV6FRf0M=; b=peV0U3MabJE4ngS3qBpnou4FPYS0r7UcUz+S80iXgVhAEab9Swi4oG21U1DpzIoMl/+F ue85EMPV0fXJH6wfyx7eUpQtiIbF4akKOLRkHd2QniG83apnKXprCo3kuaRm2NetaTvs kXkFe5MyCPi7C78IGwygThlbvJzZELZvd/RYiQeppe3NaaMYA2aOlTDCvUlJD6CxJo65 n6ZyKbQTCyCylXgiwVojwQJLOS/O5pQAKjeWOW5fopRToS4KOM+1rAnqIy92knuwbH73 zqgsJeq+GucFl3sl0zRbIKxeCCTdEg73iIRaKBRhy/uELNJgKWrwI9agDD3KnAdGSTVn dg== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 20/36] multi-process: Forward PCI config space acceses to the remote process Date: Mon, 6 Apr 2020 02:41:10 -0700 Message-Id: <7a75d79057f2c412230ea1dbac4debe3a7d8eba8.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva The Proxy Object sends the PCI config space accesses as messages to the remote process over the communication channel Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- hw/proxy/qemu-proxy.c | 61 ++++++++++++++++++++++++++++++++++++++++ include/io/mpqemu-link.h | 8 ++++++ io/mpqemu-link.c | 6 ++++ remote/remote-main.c | 32 +++++++++++++++++++++ 4 files changed, 107 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 9b5e429a88..87cf39c672 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -14,6 +14,65 @@ #include "hw/proxy/qemu-proxy.h" #include "hw/pci/pci.h" =20 +static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, = int l, + unsigned int op) +{ + MPQemuMsg msg; + struct conf_data_msg conf_data; + int wait; + + memset(&msg, 0, sizeof(MPQemuMsg)); + conf_data.addr =3D addr; + conf_data.val =3D (op =3D=3D PCI_CONFIG_WRITE) ? *val : 0; + conf_data.l =3D l; + + msg.data2 =3D (uint8_t *)&conf_data; + if (!msg.data2) { + return -ENOMEM; + } + + msg.size =3D sizeof(conf_data); + msg.cmd =3D op; + msg.bytestream =3D 1; + + if (op =3D=3D PCI_CONFIG_WRITE) { + msg.num_fds =3D 0; + } else { + /* TODO: Dont create fd each time for send. */ + wait =3D GET_REMOTE_WAIT; + msg.num_fds =3D 1; + msg.fds[0] =3D wait; + } + + mpqemu_msg_send(&msg, dev->mpqemu_link->dev); + + if (op =3D=3D PCI_CONFIG_READ) { + *val =3D (uint32_t)wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + } + + return 0; +} + +static uint32_t pci_proxy_read_config(PCIDevice *d, uint32_t addr, int len) +{ + uint32_t val; + + (void)pci_default_read_config(d, addr, len); + + config_op_send(PCI_PROXY_DEV(d), addr, &val, len, PCI_CONFIG_READ); + + return val; +} + +static void pci_proxy_write_config(PCIDevice *d, uint32_t addr, uint32_t v= al, + int l) +{ + pci_default_write_config(d, addr, val, l); + + config_op_send(PCI_PROXY_DEV(d), addr, &val, l, PCI_CONFIG_WRITE); +} + static void proxy_set_socket(Object *obj, const char *str, Error **errp) { PCIProxyDev *pdev =3D PCI_PROXY_DEV(obj); @@ -86,6 +145,8 @@ static void pci_proxy_dev_class_init(ObjectClass *klass,= void *data) PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D pci_proxy_dev_realize; + k->config_read =3D pci_proxy_read_config; + k->config_write =3D pci_proxy_write_config; } =20 static const TypeInfo pci_proxy_dev_type_info =3D { diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index ebae9afc45..7228a1915e 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -39,9 +39,17 @@ typedef enum { INIT =3D 0, SYNC_SYSMEM, CONNECT_DEV, + PCI_CONFIG_WRITE, + PCI_CONFIG_READ, MAX, } mpqemu_cmd_t; =20 +struct conf_data_msg { + uint32_t addr; + uint32_t val; + int l; +}; + typedef struct { hwaddr gpas[REMOTE_MAX_FDS]; uint64_t sizes[REMOTE_MAX_FDS]; diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index b395869a22..643c0588ce 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -361,6 +361,12 @@ bool mpqemu_msg_valid(MPQemuMsg *msg) return false; } break; + case PCI_CONFIG_WRITE: + case PCI_CONFIG_READ: + if (msg->size !=3D sizeof(struct conf_data_msg)) { + return false; + } + break; default: break; } diff --git a/remote/remote-main.c b/remote/remote-main.c index 22319cb5ea..b5ed31f63b 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -41,6 +41,32 @@ static MPQemuLinkState *mpqemu_link; =20 #define LINK_TO_DEV(link) ((PCIDevice *)link->opaque) =20 +static void process_config_write(PCIDevice *dev, MPQemuMsg *msg) +{ + struct conf_data_msg *conf =3D (struct conf_data_msg *)msg->data2; + + qemu_mutex_lock_iothread(); + pci_default_write_config(dev, conf->addr, conf->val, conf->l); + qemu_mutex_unlock_iothread(); +} + +static void process_config_read(PCIDevice *dev, MPQemuMsg *msg) +{ + struct conf_data_msg *conf =3D (struct conf_data_msg *)msg->data2; + uint32_t val; + int wait; + + wait =3D msg->fds[0]; + + qemu_mutex_lock_iothread(); + val =3D pci_default_read_config(dev, conf->addr, conf->l); + qemu_mutex_unlock_iothread(); + + notify_proxy(wait, val); + + PUT_REMOTE_WAIT(wait); +} + static gpointer dev_thread(gpointer data) { MPQemuLinkState *link =3D data; @@ -99,6 +125,12 @@ static void process_msg(GIOCondition cond, MPQemuLinkSt= ate *link, case CONNECT_DEV: process_connect_dev_msg(msg); break; + case PCI_CONFIG_WRITE: + process_config_write(LINK_TO_DEV(link), msg); + break; + case PCI_CONFIG_READ: + process_config_read(LINK_TO_DEV(link), msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166635; cv=none; d=zohomail.com; s=zohoarc; b=efQ2qa+yjx5DYq+CRogy6wF8eewrpUAM6ExIE5TSmji5XQa1WekJjQpOeMl8aV407XNQltSiCgZCDSXK2deDqg2qsf2LY0t7Ja3y/o03WKKF1y4YfwKQUgl4wDX+EY0ZZQvPmpYSHqi0xU62gQyk1K57iKFOilmQESn6VNE38o4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166635; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4mO2dJF75SlZTMUcGzJgBWOZymNp9EgvlBVCh8v7ZU8=; b=Ujjpz4tD8iL6W9Nn7+SUqKuox5PTKcbYremyI0EXP/T4saJbL9F3fcI7apVkHzqIryo/kky5S4XT39m0H687hb6o5P+99pdZ4Q1LwQrGtXhVAcGbQ+3LS4L0IwiOj2lY+iCr5Z1Aa7dmubvaDH9W+29PmD0tSweaElVGbThN6/I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166635842716.0008248865443; Mon, 6 Apr 2020 02:50:35 -0700 (PDT) Received: from localhost ([::1]:57434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOOo-0000JI-Gt for importer@patchew.org; Mon, 06 Apr 2020 05:50:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44220) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGm-00026E-80 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGk-0002Iw-Lw for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:16 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45598) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGk-0002H4-DN for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:14 -0400 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 0369dnfo069764; Mon, 6 Apr 2020 09:42:08 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 306j6m5tbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:08 +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 0369fNjo066109; Mon, 6 Apr 2020 09:42:07 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 307419xh6j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:07 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369g6Em031919; Mon, 6 Apr 2020 09:42:06 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:06 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=4mO2dJF75SlZTMUcGzJgBWOZymNp9EgvlBVCh8v7ZU8=; b=m4oMxuUxSrbuaiVpyRW4oI7eWq3K3JPPnje5Mw/p8lM/oD3qzORqK9d1akk5WaK7t5dM 4aBkYKN6gzMSAGZidXDv/KtudfdlRApW3hx1aSMnrNAJNQ2u/7h5lj9Lylukk8fcB2W0 CVNMRjympEplXFT+ZsyTDNXh6BAvxToqXWbhBKUeYxIR/crdjeOG7NKl+2lJ2R9J1R8b W8bgkqSAeXENdtLdYeTP/yZNMVuhXi081zDX7mYQae1WAN4UNwVFrfK/CJ/KcJM1bgun tCdmiw6mQbktkbJpuDZVrZRHEl9ITuY/+BUiUK0GxMhN/eTNSJbbMYCqBkRh4DWZ4L7r iQ== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 21/36] multi-process: PCI BAR read/write handling for proxy & remote endpoints Date: Mon, 6 Apr 2020 02:41:11 -0700 Message-Id: <848b7213d9c1de43f5f5c8518a4f5bcd46faec7e.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=1 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Proxy device object implements handler for PCI BAR writes and reads. The handler uses BAR_WRITE/BAR_READ message to communicate to the remote process with the BAR address and value to be written/read. The remote process implements handler for BAR_WRITE/BAR_READ message. Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson --- hw/proxy/qemu-proxy.c | 64 ++++++++++++++++++++++++++++++ include/hw/proxy/qemu-proxy.h | 20 +++++++++- include/io/mpqemu-link.h | 12 ++++++ io/mpqemu-link.c | 6 +++ remote/remote-main.c | 73 +++++++++++++++++++++++++++++++++++ 5 files changed, 173 insertions(+), 2 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 87cf39c672..7fd0a312a5 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -169,3 +169,67 @@ static void pci_proxy_dev_register_types(void) =20 type_init(pci_proxy_dev_register_types) =20 +static void send_bar_access_msg(PCIProxyDev *dev, MemoryRegion *mr, + bool write, hwaddr addr, uint64_t *val, + unsigned size, bool memory) +{ + MPQemuLinkState *mpqemu_link =3D dev->mpqemu_link; + MPQemuMsg msg; + int wait; + + memset(&msg, 0, sizeof(MPQemuMsg)); + + msg.bytestream =3D 0; + msg.size =3D sizeof(msg.data1); + msg.data1.bar_access.addr =3D mr->addr + addr; + msg.data1.bar_access.size =3D size; + msg.data1.bar_access.memory =3D memory; + + if (write) { + msg.cmd =3D BAR_WRITE; + msg.data1.bar_access.val =3D *val; + } else { + wait =3D GET_REMOTE_WAIT; + + msg.cmd =3D BAR_READ; + msg.num_fds =3D 1; + msg.fds[0] =3D wait; + } + + mpqemu_msg_send(&msg, mpqemu_link->dev); + + if (!write) { + *val =3D wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + } +} + +void proxy_default_bar_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + ProxyMemoryRegion *pmr =3D opaque; + + send_bar_access_msg(pmr->dev, &pmr->mr, true, addr, &val, size, + pmr->memory); +} + +uint64_t proxy_default_bar_read(void *opaque, hwaddr addr, unsigned size) +{ + ProxyMemoryRegion *pmr =3D opaque; + uint64_t val; + + send_bar_access_msg(pmr->dev, &pmr->mr, false, addr, &val, size, + pmr->memory); + + return val; +} + +const MemoryRegionOps proxy_default_ops =3D { + .read =3D proxy_default_bar_read, + .write =3D proxy_default_bar_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index d7eaf26f29..9e4127eccb 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -26,14 +26,25 @@ #define PCI_PROXY_DEV_GET_CLASS(obj) \ OBJECT_GET_CLASS(PCIProxyDevClass, (obj), TYPE_PCI_PROXY_DEV) =20 -typedef struct PCIProxyDev { +typedef struct PCIProxyDev PCIProxyDev; + +typedef struct ProxyMemoryRegion { + PCIProxyDev *dev; + MemoryRegion mr; + bool memory; + bool present; + uint8_t type; +} ProxyMemoryRegion; + +struct PCIProxyDev { PCIDevice parent_dev; =20 MPQemuLinkState *mpqemu_link; =20 int socket; =20 -} PCIProxyDev; + ProxyMemoryRegion region[PCI_NUM_REGIONS]; +}; =20 typedef struct PCIProxyDevClass { PCIDeviceClass parent_class; @@ -43,4 +54,9 @@ typedef struct PCIProxyDevClass { char *command; } PCIProxyDevClass; =20 +void proxy_default_bar_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size); + +uint64_t proxy_default_bar_read(void *opaque, hwaddr addr, unsigned size); + #endif /* QEMU_PROXY_H */ diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index 7228a1915e..41cf092f9e 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -31,6 +31,8 @@ /** * mpqemu_cmd_t: * SYNC_SYSMEM Shares QEMU's RAM with remote device's RAM + * BAR_WRITE Writes to PCI BAR region + * BAR_READ Reads from PCI BAR region * * proc_cmd_t enum type to specify the command to be executed on the remote * device. @@ -41,6 +43,8 @@ typedef enum { CONNECT_DEV, PCI_CONFIG_WRITE, PCI_CONFIG_READ, + BAR_WRITE, + BAR_READ, MAX, } mpqemu_cmd_t; =20 @@ -56,6 +60,13 @@ typedef struct { ram_addr_t offsets[REMOTE_MAX_FDS]; } sync_sysmem_msg_t; =20 +typedef struct { + hwaddr addr; + uint64_t val; + unsigned size; + bool memory; +} bar_access_msg_t; + /** * MPQemuMsg: * @cmd: The remote command @@ -78,6 +89,7 @@ typedef struct { union { uint64_t u64; sync_sysmem_msg_t sync_sysmem; + bar_access_msg_t bar_access; } data1; =20 int fds[REMOTE_MAX_FDS]; diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index 643c0588ce..2b67ef6410 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -367,6 +367,12 @@ bool mpqemu_msg_valid(MPQemuMsg *msg) return false; } break; + case BAR_WRITE: + case BAR_READ: + if (msg->size !=3D sizeof(msg->data1)) { + return false; + } + break; default: break; } diff --git a/remote/remote-main.c b/remote/remote-main.c index b5ed31f63b..4f512aa5a8 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -33,6 +33,7 @@ #include "sysemu/sysemu.h" #include "block/block.h" #include "exec/ramlist.h" +#include "exec/memattrs.h" =20 static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan); @@ -102,6 +103,66 @@ exit: notify_proxy(wait, ret); } =20 +/* TODO: confirm memtx attrs. */ +static void process_bar_write(MPQemuMsg *msg, Error **errp) +{ + bar_access_msg_t *bar_access =3D &msg->data1.bar_access; + AddressSpace *as =3D + bar_access->memory ? &address_space_memory : &address_space_io; + MemTxResult res; + + res =3D address_space_rw(as, bar_access->addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *)&bar_access->val, bar_access->size, = true); + + if (res !=3D MEMTX_OK) { + error_setg(errp, "Could not perform address space write operation," + " inaccessible address: %lx.", bar_access->addr); + } +} + +static void process_bar_read(MPQemuMsg *msg, Error **errp) +{ + bar_access_msg_t *bar_access =3D &msg->data1.bar_access; + AddressSpace *as; + int wait =3D msg->fds[0]; + MemTxResult res; + uint64_t val =3D 0; + + as =3D bar_access->memory ? &address_space_memory : &address_space_io; + + assert(bar_access->size <=3D sizeof(uint64_t)); + + res =3D address_space_rw(as, bar_access->addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *)&val, bar_access->size, false); + + if (res !=3D MEMTX_OK) { + error_setg(errp, "Could not perform address space read operation," + " inaccessible address: %lx.", bar_access->addr); + val =3D (uint64_t)-1; + goto fail; + } + + switch (bar_access->size) { + case 4: + val =3D *((uint32_t *)&val); + break; + case 2: + val =3D *((uint16_t *)&val); + break; + case 1: + val =3D *((uint8_t *)&val); + break; + default: + error_setg(errp, "Invalid PCI BAR read size"); + return; + } + +fail: + notify_proxy(wait, val); + + PUT_REMOTE_WAIT(wait); +} + static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan) { @@ -131,6 +192,18 @@ static void process_msg(GIOCondition cond, MPQemuLinkS= tate *link, case PCI_CONFIG_READ: process_config_read(LINK_TO_DEV(link), msg); break; + case BAR_WRITE: + process_bar_write(msg, &err); + if (err) { + goto finalize_loop; + } + break; + case BAR_READ: + process_bar_read(msg, &err); + if (err) { + goto finalize_loop; + } + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166794; cv=none; d=zohomail.com; s=zohoarc; b=hINwdK0da8qvTdy2ovYPJL+QjUZ8Ae/IAa/9RJJP83l0x+GX+8YwEgKmeeS4XnfAFqMptTVqxekjJlXMcQfPs+HWBlkpvrK4W+0p43avBaT52bZbD6B1iOX/cbCL1WYrTiLaQaEa6LfKvYQ/r4gs/T27xWfXFU1mvnKkb7X6UDU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166794; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DwkuDa/ud7IhOzCQWjk3FC5aj90KOqsHk9Zb81Smx60=; b=WlaDdHvjpUCPURf6bdFgBt0Ll2KoaCXOv88rXLJTF8kR3XkQF6Rmct8LjADluPl5NCC1FboLgt1xF4dsaj6EpPtqUBpUuZ96OxMg9BcerJUCXz6BQhbiIUsSKeIYzGT3VvoXbC39PJhf3sdVQO68xIBldWMf36v99QKMoegxUK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166794874333.1050334340123; Mon, 6 Apr 2020 02:53:14 -0700 (PDT) Received: from localhost ([::1]:57512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLORN-0005Qf-B3 for importer@patchew.org; Mon, 06 Apr 2020 05:53:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44271) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGq-0002Gs-35 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGo-0002LU-5K for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45480) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGn-0002Kv-Rn for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:18 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cxbO025132; Mon, 6 Apr 2020 09:42:12 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 306jvmwr5x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:12 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cjB6092316; Mon, 6 Apr 2020 09:42:11 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 3073spk6cr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:11 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369g8Jt013703; Mon, 6 Apr 2020 09:42:08 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:08 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=FSSEMZbZRp9M2EFIdlYF63J5crNdAd2cSzpn8GgSEFw=; b=qtGXMYqBN8pNq0+uZhMqwu3BeceOPe3Ogif28PNuXdNzxZUZgRerw0xZmMgHO5MD3Yzs vCpIMYlv5qh4SRjRb4R8GFdlp4J59lON8QVVsAnf30o9yzRPNd/1CptEb2Xz1TpTePDO yOWZMZF2/FBckzfTkyPOoDShhCSqHF6nj3L7GZb07dg8N8V/CcmD+Z4F/RGR+NFI06SC P9geAWu7xGHzSa19CxwGqXCkyPMEUGS0rKW7E4zG8kzUoeO/QzBAEvdXriBWCF/WXKvZ Swk2cz/ilf4YjguHayrO3L/gwMH7mcrk36/67Uwsfwdn1MZhg8/LcVD/wiWhcfyIUkGw 0A== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 22/36] multi-process: Synchronize remote memory Date: Mon, 6 Apr 2020 02:41:12 -0700 Message-Id: <4d80a92957c091e3d9c8f18ccc13a1bc278c5aeb.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=4 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=4 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id 0369cxbO025132 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Add memory-listener object which is used to keep the view of the RAM in sync between QEMU and remote process. A MemoryListener is registered for system-memory AddressSpace. The listener sends SYNC_SYSMEM message to the remote process when memory listener commits the changes to memory, the remote process receives the message and processes it in the handler for SYNC_SYSMEM message. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 2 + Makefile.target | 3 + hw/proxy/memory-sync.c | 212 +++++++++++++++++++++++++++++++++ hw/proxy/qemu-proxy.c | 6 + include/hw/proxy/memory-sync.h | 37 ++++++ include/hw/proxy/qemu-proxy.h | 6 + remote/remote-main.c | 11 ++ 7 files changed, 277 insertions(+) create mode 100644 hw/proxy/memory-sync.c create mode 100644 include/hw/proxy/memory-sync.h diff --git a/MAINTAINERS b/MAINTAINERS index e2ac5b08a4..58aea19d34 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2828,6 +2828,8 @@ F: remote/memory.c F: hw/proxy/Makefile.objs F: hw/proxy/qemu-proxy.c F: include/hw/proxy/qemu-proxy.h +F: include/hw/proxy/memory-sync.h +F: hw/proxy/memory-sync.c =20 Build and test automation ------------------------- diff --git a/Makefile.target b/Makefile.target index 500fa07fda..c64d860895 100644 --- a/Makefile.target +++ b/Makefile.target @@ -127,6 +127,9 @@ obj-$(CONFIG_TCG) +=3D fpu/softfloat.o obj-y +=3D target/$(TARGET_BASE_ARCH)/ obj-y +=3D disas.o obj-$(call notempty,$(TARGET_XML_FILES)) +=3D gdbstub-xml.o +ifeq ($(TARGET_NAME)-$(CONFIG_MPQEMU)-$(CONFIG_USER_ONLY), x86_64-y-) +obj-$(CONFIG_MPQEMU) +=3D hw/proxy/memory-sync.o +endif LIBS :=3D $(libs_cpu) $(LIBS) =20 obj-$(CONFIG_PLUGIN) +=3D plugins/ diff --git a/hw/proxy/memory-sync.c b/hw/proxy/memory-sync.c new file mode 100644 index 0000000000..3edbb19efe --- /dev/null +++ b/hw/proxy/memory-sync.c @@ -0,0 +1,212 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include +#include +#include + +#include "qemu/osdep.h" +#include "qemu/compiler.h" +#include "qemu/int128.h" +#include "qemu/range.h" +#include "exec/memory.h" +#include "exec/cpu-common.h" +#include "cpu.h" +#include "exec/ram_addr.h" +#include "exec/address-spaces.h" +#include "io/mpqemu-link.h" +#include "hw/proxy/memory-sync.h" + +static const TypeInfo remote_mem_sync_type_info =3D { + .name =3D TYPE_MEMORY_LISTENER, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(RemoteMemSync), +}; + +static void remote_mem_sync_register_types(void) +{ + type_register_static(&remote_mem_sync_type_info); +} + +type_init(remote_mem_sync_register_types) + +static void proxy_ml_begin(MemoryListener *listener) +{ + RemoteMemSync *sync =3D container_of(listener, RemoteMemSync, listener= ); + int mrs; + + for (mrs =3D 0; mrs < sync->n_mr_sections; mrs++) { + memory_region_unref(sync->mr_sections[mrs].mr); + } + + g_free(sync->mr_sections); + sync->mr_sections =3D NULL; + sync->n_mr_sections =3D 0; +} + +static int get_fd_from_hostaddr(uint64_t host, ram_addr_t *offset) +{ + MemoryRegion *mr; + ram_addr_t off; + + mr =3D memory_region_from_host((void *)(uintptr_t)host, &off); + + if (offset) { + *offset =3D off; + } + + return memory_region_get_fd(mr); +} + +static bool proxy_mrs_can_merge(uint64_t host, uint64_t prev_host, size_t = size) +{ + bool merge; + int fd1, fd2; + + fd1 =3D get_fd_from_hostaddr(host, NULL); + + fd2 =3D get_fd_from_hostaddr(prev_host, NULL); + + merge =3D (fd1 =3D=3D fd2); + + merge &=3D ((prev_host + size) =3D=3D host); + + return merge; +} + +static void proxy_ml_region_addnop(MemoryListener *listener, + MemoryRegionSection *section) +{ + RemoteMemSync *sync =3D container_of(listener, RemoteMemSync, listener= ); + bool need_add =3D true; + uint64_t mrs_size, mrs_gpa, mrs_page; + uintptr_t mrs_host; + RAMBlock *mrs_rb; + MemoryRegionSection *prev_sec; + + if (!(memory_region_is_ram(section->mr) && + !memory_region_is_rom(section->mr))) { + return; + } + + mrs_rb =3D section->mr->ram_block; + mrs_page =3D (uint64_t)qemu_ram_pagesize(mrs_rb); + mrs_size =3D int128_get64(section->size); + mrs_gpa =3D section->offset_within_address_space; + mrs_host =3D (uintptr_t)memory_region_get_ram_ptr(section->mr) + + section->offset_within_region; + + if (get_fd_from_hostaddr(mrs_host, NULL) <=3D 0) { + return; + } + + mrs_host =3D mrs_host & ~(mrs_page - 1); + mrs_gpa =3D mrs_gpa & ~(mrs_page - 1); + mrs_size =3D ROUND_UP(mrs_size, mrs_page); + + if (sync->n_mr_sections) { + prev_sec =3D sync->mr_sections + (sync->n_mr_sections - 1); + uint64_t prev_gpa_start =3D prev_sec->offset_within_address_space; + uint64_t prev_size =3D int128_get64(prev_sec->size); + uint64_t prev_gpa_end =3D range_get_last(prev_gpa_start, prev_si= ze); + uint64_t prev_host_start =3D + (uintptr_t)memory_region_get_ram_ptr(prev_sec->mr) + + prev_sec->offset_within_region; + uint64_t prev_host_end =3D range_get_last(prev_host_start, prev_si= ze); + + if (mrs_gpa <=3D (prev_gpa_end + 1)) { + if (mrs_gpa < prev_gpa_start) { + assert(0); + } + + if ((section->mr =3D=3D prev_sec->mr) && + proxy_mrs_can_merge(mrs_host, prev_host_start, + (mrs_gpa - prev_gpa_start))) { + uint64_t max_end =3D MAX(prev_host_end, mrs_host + mrs_siz= e); + need_add =3D false; + prev_sec->offset_within_address_space =3D + MIN(prev_gpa_start, mrs_gpa); + prev_sec->offset_within_region =3D + MIN(prev_host_start, mrs_host) - + (uintptr_t)memory_region_get_ram_ptr(prev_sec->mr); + prev_sec->size =3D int128_make64(max_end - MIN(prev_host_s= tart, + mrs_host)); + } + } + } + + if (need_add) { + ++sync->n_mr_sections; + sync->mr_sections =3D g_renew(MemoryRegionSection, sync->mr_sectio= ns, + sync->n_mr_sections); + sync->mr_sections[sync->n_mr_sections - 1] =3D *section; + sync->mr_sections[sync->n_mr_sections - 1].fv =3D NULL; + memory_region_ref(section->mr); + } +} + +static void proxy_ml_commit(MemoryListener *listener) +{ + RemoteMemSync *sync =3D container_of(listener, RemoteMemSync, listener= ); + MPQemuMsg msg; + MemoryRegionSection section; + ram_addr_t offset; + uintptr_t host_addr; + int region; + + memset(&msg, 0, sizeof(MPQemuMsg)); + + msg.cmd =3D SYNC_SYSMEM; + msg.bytestream =3D 0; + msg.num_fds =3D sync->n_mr_sections; + msg.size =3D sizeof(msg.data1); + assert(msg.num_fds <=3D REMOTE_MAX_FDS); + + for (region =3D 0; region < sync->n_mr_sections; region++) { + section =3D sync->mr_sections[region]; + msg.data1.sync_sysmem.gpas[region] =3D + section.offset_within_address_space; + msg.data1.sync_sysmem.sizes[region] =3D int128_get64(section.size); + host_addr =3D (uintptr_t)memory_region_get_ram_ptr(section.mr) + + section.offset_within_region; + msg.fds[region] =3D get_fd_from_hostaddr(host_addr, &offset); + msg.data1.sync_sysmem.offsets[region] =3D offset; + } + mpqemu_msg_send(&msg, sync->mpqemu_link->com); +} + +void deconfigure_memory_sync(RemoteMemSync *sync) +{ + memory_listener_unregister(&sync->listener); +} + +/* + * TODO: Memory Sync need not be instantianted once per every proxy device. + * All remote devices are going to get the exact same updates at the + * same time. It therefore makes sense to have a broadcast model. + * + * Broadcast model would involve running the MemorySync object in a + * thread. MemorySync would contain a list of mpqemu-link objects + * that need notification. proxy_ml_commit() could send the same + * message to all the links at the same time. + */ +void configure_memory_sync(RemoteMemSync *sync, MPQemuLinkState *mpqemu_li= nk) +{ + sync->n_mr_sections =3D 0; + sync->mr_sections =3D NULL; + + sync->mpqemu_link =3D mpqemu_link; + + sync->listener.begin =3D proxy_ml_begin; + sync->listener.commit =3D proxy_ml_commit; + sync->listener.region_add =3D proxy_ml_region_addnop; + sync->listener.region_nop =3D proxy_ml_region_addnop; + sync->listener.priority =3D 10; + + memory_listener_register(&sync->listener, &address_space_memory); +} diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 7fd0a312a5..2ac4c1528a 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -13,6 +13,8 @@ #include "io/mpqemu-link.h" #include "hw/proxy/qemu-proxy.h" #include "hw/pci/pci.h" +#include "hw/proxy/memory-sync.h" +#include "qom/object.h" =20 static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, = int l, unsigned int op) @@ -138,6 +140,10 @@ static void pci_proxy_dev_realize(PCIDevice *device, E= rror **errp) error_propagate(errp, local_err); } } + + dev->sync =3D REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); + + configure_memory_sync(dev->sync, dev->mpqemu_link); } =20 static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/proxy/memory-sync.h b/include/hw/proxy/memory-sync.h new file mode 100644 index 0000000000..d8329c9b52 --- /dev/null +++ b/include/hw/proxy/memory-sync.h @@ -0,0 +1,37 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef MEMORY_SYNC_H +#define MEMORY_SYNC_H + +#include + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "exec/memory.h" +#include "io/mpqemu-link.h" + +#define TYPE_MEMORY_LISTENER "memory-listener" +#define REMOTE_MEM_SYNC(obj) \ + OBJECT_CHECK(RemoteMemSync, (obj), TYPE_MEMORY_LISTENER) + +typedef struct RemoteMemSync { + Object obj; + + MemoryListener listener; + + int n_mr_sections; + MemoryRegionSection *mr_sections; + + MPQemuLinkState *mpqemu_link; +} RemoteMemSync; + +void configure_memory_sync(RemoteMemSync *sync, MPQemuLinkState *mpqemu_li= nk); +void deconfigure_memory_sync(RemoteMemSync *sync); + +#endif diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 9e4127eccb..6d14876ba9 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -14,6 +14,7 @@ =20 #include "io/mpqemu-link.h" #include "hw/pci/pci.h" +#include "hw/proxy/memory-sync.h" =20 #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" =20 @@ -39,8 +40,13 @@ typedef struct ProxyMemoryRegion { struct PCIProxyDev { PCIDevice parent_dev; =20 + int n_mr_sections; + MemoryRegionSection *mr_sections; + MPQemuLinkState *mpqemu_link; =20 + RemoteMemSync *sync; + int socket; =20 ProxyMemoryRegion region[PCI_NUM_REGIONS]; diff --git a/remote/remote-main.c b/remote/remote-main.c index 4f512aa5a8..ed51499ace 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -34,6 +34,7 @@ #include "block/block.h" #include "exec/ramlist.h" #include "exec/memattrs.h" +#include "exec/address-spaces.h" =20 static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan); @@ -204,6 +205,16 @@ static void process_msg(GIOCondition cond, MPQemuLinkS= tate *link, goto finalize_loop; } break; + case SYNC_SYSMEM: + /* + * TODO: ensure no active DMA is happening when + * sysmem is being updated + */ + remote_sysmem_reconfig(msg, &err); + if (err) { + goto finalize_loop; + } + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166552; cv=none; d=zohomail.com; s=zohoarc; b=KvlWrtYCQF1PsV+ghDmORgLne5Vvg1h03wAvSvcpp8sGDTMRPoI0gOhORixrE3JHrgn1jnvnU1CE/lrwZYNd36vtJAz0OkKo99XZrUsSlEtd4bpXXRaEKeRZ0GKvJocUeowptKNG27DajkEqClSbITLl3tJUffp3xxcjQ+4oJ4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166552; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UwUyWKAq4j5KA9SFqORTZTHHMytlbz1RacX8c1CDaUw=; b=khSvVrOno593DDFacCSZK8nc/CNcT/wPe7oLe3jzKU89uDwtvMepeC8iXU0vKzCl0GYn5zryEhkdIYf5InC6qe4KXboUcURPz0prZLa2Zz6SbaDTJzPjrxvvmACy6W6pNq3xJTWpDm5Llpos5ki293DvMiR3Voe8/x924BZLjKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158616655212178.51713163768; Mon, 6 Apr 2020 02:49:12 -0700 (PDT) Received: from localhost ([::1]:57390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLONS-0005i1-QS for importer@patchew.org; Mon, 06 Apr 2020 05:49:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44494) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOH4-0002re-3M for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOH1-0002Ww-PL for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:33 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45668) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOH1-0002Vx-GG for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:31 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cx2F025174; Mon, 6 Apr 2020 09:42:25 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 306jvmwr6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:25 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369gOA0021524; Mon, 6 Apr 2020 09:42:25 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 3073xvtv4b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:24 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gA2r031990; Mon, 6 Apr 2020 09:42:10 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:10 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=dICwLVQfKmt9b9RTNoFPq4+Isx6rM+vknoP5dCCEHs8=; b=0EHN6+uib9r1dZQJ8OnkbaQFDABwHiW875vaR2g//y3RTrcen565zEhsapYkbjqEqAy7 KmcTWXMvWjW2lCaPUDAjeLwnxf99y97fJI1oVTzFMsDLytwkEZOrvOHfRFqXyZH/5A8u vO5CLYTVIDxxjqentbgJBWLFVJxlSh+dtlURtuQl6+GtauH2DDlM+l8b3IE1N9eqc7oc aVq7oW1i3rMClLJ0uH5XUxdkUD6dSHIQMzqVzU8ZxMribQv47Crh4WcIfeneOh5TAGJS J5X21OqHWwAsDCtgAh4WqAIQpEr7HOGQZYCgqfhPwXjxbC2oXmlsdFukhkDP0AJOTRbS pg== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 23/36] multi-process: create IOHUB object to handle irq Date: Mon, 6 Apr 2020 02:41:13 -0700 Message-Id: <5b3640774a0ad6413afc04cf2b72416766b886bf.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 mlxlogscore=999 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id 0369cx2F025174 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman IOHUB object is added to manage PCI IRQs. It uses KVM_IRQFD ioctl to create irqfd to injecting PCI interrupts to the guest. IOHUB object forwards the irqfd to the remote process. Remote process uses this fd to directly send interrupts to the guest, bypassing QEMU. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- MAINTAINERS | 2 + Makefile.target | 1 + hw/Makefile.objs | 2 - hw/proxy/Makefile.objs | 1 - hw/proxy/qemu-proxy.c | 52 ++++++++++++ include/hw/pci/pci_ids.h | 3 + include/hw/proxy/qemu-proxy.h | 8 ++ include/io/mpqemu-link.h | 8 ++ include/remote/iohub.h | 50 ++++++++++++ include/remote/machine.h | 2 + io/mpqemu-link.c | 1 + remote/Makefile.objs | 1 + remote/iohub.c | 148 ++++++++++++++++++++++++++++++++++ remote/machine.c | 15 ++++ remote/remote-main.c | 4 + 15 files changed, 295 insertions(+), 3 deletions(-) delete mode 100644 hw/proxy/Makefile.objs create mode 100644 include/remote/iohub.h create mode 100644 remote/iohub.c diff --git a/MAINTAINERS b/MAINTAINERS index 58aea19d34..21fbf9a0f0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2830,6 +2830,8 @@ F: hw/proxy/qemu-proxy.c F: include/hw/proxy/qemu-proxy.h F: include/hw/proxy/memory-sync.h F: hw/proxy/memory-sync.c +F: include/remote/iohub.h +F: remote/iohub.c =20 Build and test automation ------------------------- diff --git a/Makefile.target b/Makefile.target index c64d860895..b956ab24f6 100644 --- a/Makefile.target +++ b/Makefile.target @@ -129,6 +129,7 @@ obj-y +=3D disas.o obj-$(call notempty,$(TARGET_XML_FILES)) +=3D gdbstub-xml.o ifeq ($(TARGET_NAME)-$(CONFIG_MPQEMU)-$(CONFIG_USER_ONLY), x86_64-y-) obj-$(CONFIG_MPQEMU) +=3D hw/proxy/memory-sync.o +obj-$(CONFIG_MPQEMU) +=3D hw/proxy/qemu-proxy.o endif LIBS :=3D $(libs_cpu) $(LIBS) =20 diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 7b489b12a5..af9235b6f2 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -45,8 +45,6 @@ endif common-obj-y +=3D $(devices-dirs-y) obj-y +=3D $(devices-dirs-y) =20 -common-obj-$(CONFIG_MPQEMU) +=3D proxy/ - remote-pci-obj-$(CONFIG_MPQEMU) +=3D core/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D block/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D pci/ diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs deleted file mode 100644 index eb81624cf8..0000000000 --- a/hw/proxy/Makefile.objs +++ /dev/null @@ -1 +0,0 @@ -common-obj-$(CONFIG_MPQEMU) +=3D qemu-proxy.o diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 2ac4c1528a..a78694736b 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -15,6 +15,9 @@ #include "hw/pci/pci.h" #include "hw/proxy/memory-sync.h" #include "qom/object.h" +#include "qemu/event_notifier.h" +#include "sysemu/kvm.h" +#include "util/event_notifier-posix.c" =20 static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, = int l, unsigned int op) @@ -75,6 +78,53 @@ static void pci_proxy_write_config(PCIDevice *d, uint32_= t addr, uint32_t val, config_op_send(PCI_PROXY_DEV(d), addr, &val, l, PCI_CONFIG_WRITE); } =20 +static void proxy_intx_update(PCIDevice *pci_dev) +{ + PCIProxyDev *dev =3D PCI_PROXY_DEV(pci_dev); + PCIINTxRoute route; + int pin =3D pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1; + + if (dev->irqfd.fd) { + dev->irqfd.flags =3D KVM_IRQFD_FLAG_DEASSIGN; + (void) kvm_vm_ioctl(kvm_state, KVM_IRQFD, &dev->irqfd); + memset(&dev->irqfd, 0, sizeof(struct kvm_irqfd)); + } + + route =3D pci_device_route_intx_to_irq(pci_dev, pin); + + dev->irqfd.fd =3D event_notifier_get_fd(&dev->intr); + dev->irqfd.resamplefd =3D event_notifier_get_fd(&dev->resample); + dev->irqfd.gsi =3D route.irq; + dev->irqfd.flags |=3D KVM_IRQFD_FLAG_RESAMPLE; + (void) kvm_vm_ioctl(kvm_state, KVM_IRQFD, &dev->irqfd); +} + +static void setup_irqfd(PCIProxyDev *dev) +{ + PCIDevice *pci_dev =3D PCI_DEVICE(dev); + MPQemuMsg msg; + + event_notifier_init(&dev->intr, 0); + event_notifier_init(&dev->resample, 0); + + memset(&msg, 0, sizeof(MPQemuMsg)); + msg.cmd =3D SET_IRQFD; + msg.num_fds =3D 2; + msg.fds[0] =3D event_notifier_get_fd(&dev->intr); + msg.fds[1] =3D event_notifier_get_fd(&dev->resample); + msg.data1.set_irqfd.intx =3D + pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1; + msg.size =3D sizeof(msg.data1); + + mpqemu_msg_send(&msg, dev->mpqemu_link->dev); + + memset(&dev->irqfd, 0, sizeof(struct kvm_irqfd)); + + proxy_intx_update(pci_dev); + + pci_device_set_intx_routing_notifier(pci_dev, proxy_intx_update); +} + static void proxy_set_socket(Object *obj, const char *str, Error **errp) { PCIProxyDev *pdev =3D PCI_PROXY_DEV(obj); @@ -144,6 +194,8 @@ static void pci_proxy_dev_realize(PCIDevice *device, Er= ror **errp) dev->sync =3D REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); =20 configure_memory_sync(dev->sync, dev->mpqemu_link); + + setup_irqfd(dev); } =20 static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h index 11f8ab7149..bd0c17dc78 100644 --- a/include/hw/pci/pci_ids.h +++ b/include/hw/pci/pci_ids.h @@ -192,6 +192,9 @@ #define PCI_DEVICE_ID_SUN_SIMBA 0x5000 #define PCI_DEVICE_ID_SUN_SABRE 0xa000 =20 +#define PCI_VENDOR_ID_ORACLE 0x108e +#define PCI_DEVICE_ID_REMOTE_IOHUB 0xb000 + #define PCI_VENDOR_ID_CMD 0x1095 #define PCI_DEVICE_ID_CMD_646 0x0646 =20 diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 6d14876ba9..0d8ec6d686 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -12,9 +12,12 @@ #include "qemu/osdep.h" #include "qemu-common.h" =20 +#include + #include "io/mpqemu-link.h" #include "hw/pci/pci.h" #include "hw/proxy/memory-sync.h" +#include "qemu/event_notifier.h" =20 #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" =20 @@ -47,6 +50,11 @@ struct PCIProxyDev { =20 RemoteMemSync *sync; =20 + struct kvm_irqfd irqfd; + + EventNotifier intr; + EventNotifier resample; + int socket; =20 ProxyMemoryRegion region[PCI_NUM_REGIONS]; diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index 41cf092f9e..14e4be2bd0 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -33,6 +33,8 @@ * SYNC_SYSMEM Shares QEMU's RAM with remote device's RAM * BAR_WRITE Writes to PCI BAR region * BAR_READ Reads from PCI BAR region + * SET_IRQFD Sets the IRQFD to be used to raise interrupts directly + * from remote device * * proc_cmd_t enum type to specify the command to be executed on the remote * device. @@ -45,6 +47,7 @@ typedef enum { PCI_CONFIG_READ, BAR_WRITE, BAR_READ, + SET_IRQFD, MAX, } mpqemu_cmd_t; =20 @@ -81,6 +84,10 @@ typedef struct { * */ =20 +typedef struct { + int intx; +} set_irqfd_msg_t; + typedef struct { mpqemu_cmd_t cmd; int bytestream; @@ -90,6 +97,7 @@ typedef struct { uint64_t u64; sync_sysmem_msg_t sync_sysmem; bar_access_msg_t bar_access; + set_irqfd_msg_t set_irqfd; } data1; =20 int fds[REMOTE_MAX_FDS]; diff --git a/include/remote/iohub.h b/include/remote/iohub.h new file mode 100644 index 0000000000..7a488a8c38 --- /dev/null +++ b/include/remote/iohub.h @@ -0,0 +1,50 @@ +/* + * IO Hub for remote device + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef REMOTE_IOHUB_H +#define REMOTE_IOHUB_H + +#include + +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "qemu/event_notifier.h" +#include "qemu/thread-posix.h" +#include "io/mpqemu-link.h" + +#define REMOTE_IOHUB_NB_PIRQS 8 + +#define REMOTE_IOHUB_DEV 31 +#define REMOTE_IOHUB_FUNC 0 + +#define TYPE_REMOTE_IOHUB_DEVICE "remote-iohub" +#define REMOTE_IOHUB_DEVICE(obj) \ + OBJECT_CHECK(RemoteIOHubState, (obj), TYPE_REMOTE_IOHUB_DEVICE) + +typedef struct ResampleToken { + void *iohub; + int pirq; +} ResampleToken; + +typedef struct RemoteIOHubState { + PCIDevice d; + uint8_t irq_num[PCI_SLOT_MAX][PCI_NUM_PINS]; + EventNotifier irqfds[REMOTE_IOHUB_NB_PIRQS]; + EventNotifier resamplefds[REMOTE_IOHUB_NB_PIRQS]; + unsigned int irq_level[REMOTE_IOHUB_NB_PIRQS]; + ResampleToken token[REMOTE_IOHUB_NB_PIRQS]; + QemuMutex irq_level_lock[REMOTE_IOHUB_NB_PIRQS]; +} RemoteIOHubState; + +int remote_iohub_map_irq(PCIDevice *pci_dev, int intx); +void remote_iohub_set_irq(void *opaque, int pirq, int level); +void process_set_irqfd_msg(PCIDevice *pci_dev, MPQemuMsg *msg); + +#endif diff --git a/include/remote/machine.h b/include/remote/machine.h index 7e9bdbe28e..300394a546 100644 --- a/include/remote/machine.h +++ b/include/remote/machine.h @@ -16,11 +16,13 @@ #include "hw/boards.h" #include "remote/pcihost.h" #include "qemu/notify.h" +#include "remote/iohub.h" =20 typedef struct RemMachineState { MachineState parent_obj; =20 RemPCIHost *host; + RemoteIOHubState *iohub; } RemMachineState; =20 #define TYPE_REMOTE_MACHINE "remote-machine" diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index 2b67ef6410..4a998b3568 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -369,6 +369,7 @@ bool mpqemu_msg_valid(MPQemuMsg *msg) break; case BAR_WRITE: case BAR_READ: + case SET_IRQFD: if (msg->size !=3D sizeof(msg->data1)) { return false; } diff --git a/remote/Makefile.objs b/remote/Makefile.objs index 13d4c48988..cbb3065b69 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1,3 +1,4 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote-main.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D pcihost.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D machine.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D iohub.o diff --git a/remote/iohub.c b/remote/iohub.c new file mode 100644 index 0000000000..a991a4e112 --- /dev/null +++ b/remote/iohub.c @@ -0,0 +1,148 @@ +/* + * Remote IO Hub + * + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include + +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_ids.h" +#include "hw/pci/pci_bus.h" +#include "remote/iohub.h" +#include "qemu/thread.h" +#include "hw/boards.h" +#include "remote/machine.h" +#include "qemu/main-loop.h" + +static void remote_iohub_initfn(Object *obj) +{ + RemoteIOHubState *iohub =3D REMOTE_IOHUB_DEVICE(obj); + int slot, intx, pirq; + + memset(&iohub->irqfds, 0, sizeof(iohub->irqfds)); + memset(&iohub->resamplefds, 0, sizeof(iohub->resamplefds)); + + for (slot =3D 0; slot < PCI_SLOT_MAX; slot++) { + for (intx =3D 0; intx < PCI_NUM_PINS; intx++) { + iohub->irq_num[slot][intx] =3D (slot + intx) % 4 + 4; + } + } + + for (pirq =3D 0; pirq < REMOTE_IOHUB_NB_PIRQS; pirq++) { + qemu_mutex_init(&iohub->irq_level_lock[pirq]); + iohub->irq_level[pirq] =3D 0; + } +} + +static void remote_iohub_class_init(ObjectClass *klass, void *data) +{ + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + k->vendor_id =3D PCI_VENDOR_ID_ORACLE; + k->device_id =3D PCI_DEVICE_ID_REMOTE_IOHUB; +} + +static const TypeInfo remote_iohub_info =3D { + .name =3D TYPE_REMOTE_IOHUB_DEVICE, + .parent =3D TYPE_PCI_DEVICE, + .instance_size =3D sizeof(RemoteIOHubState), + .instance_init =3D remote_iohub_initfn, + .class_init =3D remote_iohub_class_init, + .interfaces =3D (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { } + } +}; + +static void remote_iohub_register(void) +{ + type_register_static(&remote_iohub_info); +} + +type_init(remote_iohub_register); + +int remote_iohub_map_irq(PCIDevice *pci_dev, int intx) +{ + BusState *bus =3D qdev_get_parent_bus(&pci_dev->qdev); + PCIBus *pci_bus =3D PCI_BUS(bus); + PCIDevice *pci_iohub =3D + pci_bus->devices[PCI_DEVFN(REMOTE_IOHUB_DEV, REMOTE_IOHUB_FUNC)]; + RemoteIOHubState *iohub =3D REMOTE_IOHUB_DEVICE(pci_iohub); + + return iohub->irq_num[PCI_SLOT(pci_dev->devfn)][intx]; +} + +/* + * TODO: Using lock to set the interrupt level could become a + * performance bottleneck. Check if atomic arithmetic + * is possible. + */ +void remote_iohub_set_irq(void *opaque, int pirq, int level) +{ + RemoteIOHubState *iohub =3D opaque; + + assert(pirq >=3D 0); + assert(pirq < REMOTE_IOHUB_NB_PIRQS); + + qemu_mutex_lock(&iohub->irq_level_lock[pirq]); + + if (level) { + if (++iohub->irq_level[pirq] =3D=3D 1) { + event_notifier_set(&iohub->irqfds[pirq]); + } + } else if (iohub->irq_level[pirq] > 0) { + iohub->irq_level[pirq]--; + } + + qemu_mutex_unlock(&iohub->irq_level_lock[pirq]); +} + +static void intr_resample_handler(void *opaque) +{ + ResampleToken *token =3D opaque; + RemoteIOHubState *iohub =3D token->iohub; + int pirq, s; + + pirq =3D token->pirq; + + s =3D event_notifier_test_and_clear(&iohub->resamplefds[pirq]); + + assert(s >=3D 0); + + qemu_mutex_lock(&iohub->irq_level_lock[pirq]); + + if (iohub->irq_level[pirq]) { + event_notifier_set(&iohub->irqfds[pirq]); + } + + qemu_mutex_unlock(&iohub->irq_level_lock[pirq]); +} + +void process_set_irqfd_msg(PCIDevice *pci_dev, MPQemuMsg *msg) +{ + RemMachineState *machine =3D REMOTE_MACHINE(current_machine); + RemoteIOHubState *iohub =3D machine->iohub; + int pirq =3D remote_iohub_map_irq(pci_dev, msg->data1.set_irqfd.intx); + + assert(msg->num_fds =3D=3D 2); + + if (event_notifier_get_fd(&iohub->irqfds[pirq]) !=3D -1) { + event_notifier_cleanup(&iohub->irqfds[pirq]); + event_notifier_cleanup(&iohub->resamplefds[pirq]); + memset(&iohub->token[pirq], 0, sizeof(ResampleToken)); + } + + event_notifier_init_fd(&iohub->irqfds[pirq], msg->fds[0]); + event_notifier_init_fd(&iohub->resamplefds[pirq], msg->fds[1]); + + iohub->token[pirq].iohub =3D iohub; + iohub->token[pirq].pirq =3D pirq; + + qemu_set_fd_handler(msg->fds[1], intr_resample_handler, NULL, + &iohub->token[pirq]); +} diff --git a/remote/machine.c b/remote/machine.c index 97e4f194ea..d529f68660 100644 --- a/remote/machine.c +++ b/remote/machine.c @@ -25,12 +25,16 @@ #include "qemu-common.h" #include "sysemu/sysemu.h" #include "qemu/notify.h" +#include "hw/pci/pci_host.h" +#include "remote/iohub.h" =20 static void remote_machine_init(Object *obj) { RemMachineState *s =3D REMOTE_MACHINE(obj); RemPCIHost *rem_host; MemoryRegion *system_memory, *system_io, *pci_memory; + PCIHostState *pci_host; + PCIDevice *pci_dev; =20 Error *error_abort =3D NULL; =20 @@ -67,6 +71,17 @@ static void remote_machine_init(Object *obj) qemu_mutex_unlock_iothread(); =20 qdev_init_nofail(DEVICE(rem_host)); + + pci_host =3D PCI_HOST_BRIDGE(rem_host); + pci_dev =3D pci_create_simple_multifunction(pci_host->bus, + PCI_DEVFN(REMOTE_IOHUB_DEV, + REMOTE_IOHUB_FUNC), + true, TYPE_REMOTE_IOHUB_DEVI= CE); + + s->iohub =3D REMOTE_IOHUB_DEVICE(pci_dev); + + pci_bus_irqs(pci_host->bus, remote_iohub_set_irq, remote_iohub_map_irq, + s->iohub, REMOTE_IOHUB_NB_PIRQS); } =20 static const TypeInfo remote_machine =3D { diff --git a/remote/remote-main.c b/remote/remote-main.c index ed51499ace..697fb992a1 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -35,6 +35,7 @@ #include "exec/ramlist.h" #include "exec/memattrs.h" #include "exec/address-spaces.h" +#include "remote/iohub.h" =20 static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan); @@ -215,6 +216,9 @@ static void process_msg(GIOCondition cond, MPQemuLinkSt= ate *link, goto finalize_loop; } break; + case SET_IRQFD: + process_set_irqfd_msg(LINK_TO_DEV(link), msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167164; cv=none; d=zohomail.com; s=zohoarc; b=LL7tMUmfZHATXxAA3nTuYLsOBoQDDzsjDi7acPfgPXQA93nb30tlWD1tVs+s6A+/HK7woi8sAafiB8tuqs9b0AVdR06YwAjEy2BO71CJrqdIOYHQBLVUlcEVoX5qWTyEsAocRX2QsnS94oEiF8ppPIxpGT6ORjaTBX+x+u88o4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167164; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1PhzKLozBMPHH7oqxxC9Ov6cuOiC3lWW+T0/mLX01j8=; b=cDCgaPYEEmp0O4cXWYcLm17cSEJ/XJEos3FSdsrNoC0qCl7XsLrbTYzBAE300RkyrqnVBLqM+BE34sVxm9DVrQpSpff3W5z+BMEZwNAL/pQWrqe69D1sve7YyaDbw4Z3W/FXKJDZmRcKyrD1H1ZMbPjez/SvBQrocpLXptX0hf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167164193485.55139501540236; Mon, 6 Apr 2020 02:59:24 -0700 (PDT) Received: from localhost ([::1]:57674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOXK-0007Xt-Sq for importer@patchew.org; Mon, 06 Apr 2020 05:59:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44987) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOIw-0006XS-Km for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOIv-00042b-2M for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:30 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36838) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOIu-00041l-Pm for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:29 -0400 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 0369hpLH093026; Mon, 6 Apr 2020 09:44:14 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 306hnqwu7r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:44:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369ciqa092283; Mon, 6 Apr 2020 09:42:13 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3073spk6ey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:13 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gC6K032002; Mon, 6 Apr 2020 09:42:12 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:12 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=1PhzKLozBMPHH7oqxxC9Ov6cuOiC3lWW+T0/mLX01j8=; b=jQkhXT1MOpd41igH4GxelcfLH4QTc+TTA7Su3HtOjmm3FpWWIJQfJckqI1yTGWp6J/lZ S2X6A7gP+Y5utnK4chznX9nnPRghjOgUvRnJ7+PH4T1l7z3zELN3s6nP/nruJ1Ospfop lbVcfMspJW7V/8cbqXxnXn9/MycjSkV1PlLjYXMq528e5JyjdWGNmUXArqUC9VP+bNI5 KAU/X08dnN8BEi0wFnkd8rNV6gGB6Y9y8jz9i3VStLhgYQcAJ4Hp228mfjimxTlUP37h rMxWxsBXl3hyCTYMrA9TMoP9xvWoD4ovAp9SsAprkobLhvg60eItEvrcBwgEKQgjx65Z YA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 24/36] multi-process: Retrieve PCI info from remote process Date: Mon, 6 Apr 2020 02:41:14 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=3 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=3 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Retrieve PCI configuration info about the remote device and configure the Proxy PCI object based on the returned information Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- hw/proxy/qemu-proxy.c | 84 ++++++++++++++++++++++++++++++++++++++++ include/io/mpqemu-link.h | 10 +++++ remote/remote-main.c | 21 ++++++++++ 3 files changed, 115 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index a78694736b..730e28483e 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -19,6 +19,8 @@ #include "sysemu/kvm.h" #include "util/event_notifier-posix.c" =20 +static void probe_pci_info(PCIDevice *dev); + static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, = int l, unsigned int op) { @@ -182,8 +184,12 @@ static void pci_proxy_dev_realize(PCIDevice *device, E= rror **errp) { PCIProxyDev *dev =3D PCI_PROXY_DEV(device); PCIProxyDevClass *k =3D PCI_PROXY_DEV_GET_CLASS(dev); + uint8_t *pci_conf =3D device->config; Error *local_err =3D NULL; =20 + pci_conf[PCI_LATENCY_TIMER] =3D 0xff; + pci_conf[PCI_INTERRUPT_PIN] =3D 0x01; + if (k->realize) { k->realize(dev, &local_err); if (local_err) { @@ -196,6 +202,8 @@ static void pci_proxy_dev_realize(PCIDevice *device, Er= ror **errp) configure_memory_sync(dev->sync, dev->mpqemu_link); =20 setup_irqfd(dev); + + probe_pci_info(PCI_DEVICE(dev)); } =20 static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) @@ -291,3 +299,79 @@ const MemoryRegionOps proxy_default_ops =3D { .max_access_size =3D 1, }, }; + +static void probe_pci_info(PCIDevice *dev) +{ + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(dev); + DeviceClass *dc =3D DEVICE_CLASS(pc); + PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); + MPQemuLinkState *mpqemu_link =3D pdev->mpqemu_link; + MPQemuMsg msg, ret; + uint32_t orig_val, new_val, class; + uint8_t type; + int i, size; + char *name; + + memset(&msg, 0, sizeof(MPQemuMsg)); + msg.bytestream =3D 0; + msg.size =3D 0; + msg.cmd =3D GET_PCI_INFO; + mpqemu_msg_send(&msg, mpqemu_link->dev); + + mpqemu_msg_recv(&ret, mpqemu_link->dev); + + pc->vendor_id =3D ret.data1.ret_pci_info.vendor_id; + pc->device_id =3D ret.data1.ret_pci_info.device_id; + pc->class_id =3D ret.data1.ret_pci_info.class_id; + pc->subsystem_id =3D ret.data1.ret_pci_info.subsystem_id; + + config_op_send(pdev, 11, &class, 1, PCI_CONFIG_READ); + switch (class) { + case PCI_BASE_CLASS_BRIDGE: + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + break; + case PCI_BASE_CLASS_STORAGE: + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); + break; + case PCI_BASE_CLASS_NETWORK: + set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); + break; + case PCI_BASE_CLASS_INPUT: + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + break; + case PCI_BASE_CLASS_DISPLAY: + set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); + break; + case PCI_BASE_CLASS_PROCESSOR: + set_bit(DEVICE_CATEGORY_CPU, dc->categories); + break; + default: + set_bit(DEVICE_CATEGORY_MISC, dc->categories); + break; + } + + for (i =3D 0; i < 6; i++) { + config_op_send(pdev, 0x10 + (4 * i), &orig_val, 4, PCI_CONFIG_READ= ); + new_val =3D 0xffffffff; + config_op_send(pdev, 0x10 + (4 * i), &new_val, 4, PCI_CONFIG_WRITE= ); + config_op_send(pdev, 0x10 + (4 * i), &new_val, 4, PCI_CONFIG_READ); + size =3D (~(new_val & 0xFFFFFFF0)) + 1; + config_op_send(pdev, 0x10 + (4 * i), &orig_val, 4, PCI_CONFIG_WRIT= E); + type =3D (new_val & 0x1) ? + PCI_BASE_ADDRESS_SPACE_IO : PCI_BASE_ADDRESS_SPACE_MEMO= RY; + + if (size) { + pdev->region[i].dev =3D pdev; + pdev->region[i].present =3D true; + if (type =3D=3D PCI_BASE_ADDRESS_SPACE_MEMORY) { + pdev->region[i].memory =3D true; + } + name =3D g_strdup_printf("bar-region-%d", i); + memory_region_init_io(&pdev->region[i].mr, OBJECT(pdev), + &proxy_default_ops, &pdev->region[i], + name, size); + pci_register_bar(dev, i, type, &pdev->region[i].mr); + g_free(name); + } + } +} diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index 14e4be2bd0..102c736705 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -48,6 +48,8 @@ typedef enum { BAR_WRITE, BAR_READ, SET_IRQFD, + GET_PCI_INFO, + RET_PCI_INFO, MAX, } mpqemu_cmd_t; =20 @@ -70,6 +72,13 @@ typedef struct { bool memory; } bar_access_msg_t; =20 +typedef struct { + uint16_t vendor_id; + uint16_t device_id; + uint16_t class_id; + uint16_t subsystem_id; +} ret_pci_info_msg_t; + /** * MPQemuMsg: * @cmd: The remote command @@ -98,6 +107,7 @@ typedef struct { sync_sysmem_msg_t sync_sysmem; bar_access_msg_t bar_access; set_irqfd_msg_t set_irqfd; + ret_pci_info_msg_t ret_pci_info; } data1; =20 int fds[REMOTE_MAX_FDS]; diff --git a/remote/remote-main.c b/remote/remote-main.c index 697fb992a1..d249eba9e8 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -165,6 +165,24 @@ fail: PUT_REMOTE_WAIT(wait); } =20 +static void process_get_pci_info_msg(MPQemuLinkState *link, MPQemuMsg *msg) +{ + PCIDevice *pci_dev =3D LINK_TO_DEV(link); + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(pci_dev); + MPQemuMsg ret =3D { 0 }; + + ret.cmd =3D RET_PCI_INFO; + + ret.data1.ret_pci_info.vendor_id =3D pc->vendor_id; + ret.data1.ret_pci_info.device_id =3D pc->device_id; + ret.data1.ret_pci_info.class_id =3D pc->class_id; + ret.data1.ret_pci_info.subsystem_id =3D pc->subsystem_id; + + ret.size =3D sizeof(ret.data1); + + mpqemu_msg_send(&ret, link->dev); +} + static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan) { @@ -219,6 +237,9 @@ static void process_msg(GIOCondition cond, MPQemuLinkSt= ate *link, case SET_IRQFD: process_set_irqfd_msg(LINK_TO_DEV(link), msg); break; + case GET_PCI_INFO: + process_get_pci_info_msg(link, msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167108; cv=none; d=zohomail.com; s=zohoarc; b=QSaYyVdp4wpqe3BYeZTrwsW7cPBj676JhYTlzDagsGXJq5VgODxc5vAuizlFtK+bYIYm99HjM6U3VYiKOY6rOfSkzvVv1b6XOXRxxJ5+LXG4entFgI7vgjJolB96lwEQ/PjgMKpbjEeKn1d67UjiAUgr+ctd8yZm7v3g0XVkdUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167108; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mg2o+E+zRN6NZYHSVJt2/lIDIZG5d4FQVlpm0ayOgWA=; b=HC0aeaYBSRRascDyGzzLE48s0zwUnustg4/s4h1fHTI9Uzkgn+qG7k1DX73/gfLCvrJVLCxqynirWHdoBy9HhVkMRy0RnmAkl37QdluVMbEzg+/KGI83ZFKmEaqXytsuaxmhNwsZ+DUB2j0ytt7DZwHgxXYlD+z9cjnmVnPaqEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167108740717.5735101081681; Mon, 6 Apr 2020 02:58:28 -0700 (PDT) Received: from localhost ([::1]:57644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOWR-0005vL-Gm for importer@patchew.org; Mon, 06 Apr 2020 05:58:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44322) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGx-0002ce-SL for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGw-0002RT-Oi for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:27 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35068) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGw-0002Qk-Ed for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:26 -0400 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 0369dqgg089453; Mon, 6 Apr 2020 09:42:15 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 306hnqwty2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:15 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369cg8u092172; Mon, 6 Apr 2020 09:42:14 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3073spk6g4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:14 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gEOW032013; Mon, 6 Apr 2020 09:42:14 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:13 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=Mg2o+E+zRN6NZYHSVJt2/lIDIZG5d4FQVlpm0ayOgWA=; b=ow5tmlXr8DuIznr5rFkWTG37y5rWj19eqvzwS8608rRlY3F+PXPuVITAXQj08ds61CIk zrOPAz6iABy3vDJ2y/580eyziQHsX0nTqboof04LgekHk6WQkQJA4HQyuyornNLT7xDo mu/23LuTh+byFDRSl3Y3kzcl1HlN53fsSzKg4jR41Cdjlflyr0kBfjqdSAiXJ4v0fIHc Ze3XMmYah4JfS3vQ5Etdpjq22ifjBGJR77SgTVaWo8ILW3H6OhEDzzaAUgthkoqdHLGl RUDJkim5qdJtB7XH5jhB6v6a6i7n9kV7MbfUlwWLoCpyVY815SwH8AbyAeW1jO1rsCxd lQ== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 25/36] multi-process: Introduce build flags to separate remote process code Date: Mon, 6 Apr 2020 02:41:15 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Introduce SCSI_PROCESS & REMOTE_PROCESS build flags to separate code that applies only to remote processes. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- Makefile.target | 4 ++++ rules.mak | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.target b/Makefile.target index b956ab24f6..adc76886f8 100644 --- a/Makefile.target +++ b/Makefile.target @@ -269,6 +269,10 @@ ifdef CONFIG_DARWIN $(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@") endif =20 +ifdef CONFIG_MPQEMU +$(SCSI_DEV_BUILD): REMOTE_FLAGS =3D -DREMOTE_PROCESS -DSCSI_PROCESS +endif + $(SCSI_DEV_BUILD): $(all-remote-lsi-obj-y) $(COMMON_LDADDS) $(call LINK, $(filter-out %.mak, $^)) ifdef CONFIG_DARWIN diff --git a/rules.mak b/rules.mak index 694865b63e..257f07e322 100644 --- a/rules.mak +++ b/rules.mak @@ -67,7 +67,7 @@ expand-objs =3D $(strip $(sort $(filter %.o,$1)) \ =20 %.o: %.c $(call quiet-command,$(CC) $(QEMU_LOCAL_INCLUDES) $(QEMU_INCLUDES) \ - $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) \ + $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) $($@-cflags) $(REMOTE_FLA= GS) \ -c -o $@ $<,"CC","$(TARGET_DIR)$@") %.o: %.rc $(call quiet-command,$(WINDRES) -I. -o $@ $<,"RC","$(TARGET_DIR)$@") --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166973; cv=none; d=zohomail.com; s=zohoarc; b=cl20W1XSskeSE3afnSQmN58lPkk6YEeZ34ReDXMvDTu/yoGDBlrx9Nrdq4i8O6CarVPc07CXPnmF8rKCphZfm0FKsQbcD8Qg0PVS82OlboA6d1tgZVvzkvXSnFA27HKBUExC3eIhr54Rm0XaUr2UCBoD0OO2tPpIZQjjdB+Ha2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166973; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e3YMqVnzzDydJ97eKXSYXZ6KhOOl8PAAGMGenFRxUxY=; b=D6Cx58hwy5XYb1DoVt0mHziiHdel8QH/B45xJOcxvAbNFAds2d8JWLSvKBSgm1JN+FPMsuVdJFucYgqCplT01AvQnlaI7oItXgVgYPWEbVaZKKRwj+G+RvzfEmSXTv/of7A/g4qXWOuPCKwmbDKx647F/spPc1ISDjTVSjemR1A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166973119882.4177387059641; Mon, 6 Apr 2020 02:56:13 -0700 (PDT) Received: from localhost ([::1]:57588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOUF-0001p4-Sy for importer@patchew.org; Mon, 06 Apr 2020 05:56:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44290) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGu-0002Te-Cu for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGs-0002On-S0 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:24 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45710) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGs-0002O1-IY for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:22 -0400 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 0369eShA070136; Mon, 6 Apr 2020 09:42:16 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 306j6m5tc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:16 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369ch94092251; Mon, 6 Apr 2020 09:42:16 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3073spk6gt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:16 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gFqj032026; Mon, 6 Apr 2020 09:42:15 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:15 -0700 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 : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=9VdQsRUWq0Hfr/+CgqCStzC0T+lowcu05EYYWMkJqP8=; b=IoW6sL5pbl8IYWar/gf5+TUaWxhUldFbkxnI20I9ixbeIHUPsx5/Oz0dAXWKoUS7TDXV 1Y5qAzR2KRipvZZFUuIlV9XMiDbDUp8cnyShv28aSoneCW2b9DFW6J/ELqmHru03Hvbt IFzIPqMMN/WHsxFEUq+9m7AAA6hR2iYzWu9LRm84p9O0pmEPvfxcJvxEQmFhK3cyIM7b 65CoNRVtwcMRixyD3RAkxMyrAm1FzX/Q3Gc4rCDD3YFuTb9uz6D5LHpAuP3N+ubKZXt9 ADtsJ4iDmeTQJnB2ymOxflkHp77Rp2c1NOzLoHUeD1gu+EwYCCRWitrqHr1ACYbyvCdV Cg== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 26/36] multi-process: add parse_cmdline in remote process Date: Mon, 6 Apr 2020 02:41:16 -0700 Message-Id: <620dba4d6247004dadb2202a58d0d6e2765e417e.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=1 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by aserp2120.oracle.com id 0369eShA070136 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- MAINTAINERS | 2 ++ remote/Makefile.objs | 1 + remote/remote-main.c | 20 +++++++++++- remote/remote-opts.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ remote/remote-opts.h | 15 +++++++++ 5 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 remote/remote-opts.c create mode 100644 remote/remote-opts.h diff --git a/MAINTAINERS b/MAINTAINERS index 21fbf9a0f0..2a0fd65f7a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2832,6 +2832,8 @@ F: include/hw/proxy/memory-sync.h F: hw/proxy/memory-sync.c F: include/remote/iohub.h F: remote/iohub.c +F: remote/remote-opts.h +F: remote/remote-opts.c =20 Build and test automation ------------------------- diff --git a/remote/Makefile.objs b/remote/Makefile.objs index cbb3065b69..f8d58d09e6 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1,4 +1,5 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote-main.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote-opts.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D pcihost.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D machine.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D iohub.o diff --git a/remote/remote-main.c b/remote/remote-main.c index d249eba9e8..a0892c05b6 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -24,6 +24,7 @@ #include "io/mpqemu-link.h" #include "qapi/error.h" #include "qemu/main-loop.h" +#include "qemu/cutils.h" #include "sysemu/cpus.h" #include "qemu-common.h" #include "hw/pci/pci.h" @@ -36,6 +37,7 @@ #include "exec/memattrs.h" #include "exec/address-spaces.h" #include "remote/iohub.h" +#include "remote-opts.h" =20 static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan); @@ -262,6 +264,7 @@ finalize_loop: int main(int argc, char *argv[]) { Error *err =3D NULL; + int fd =3D -1; =20 module_call_init(MODULE_INIT_QOM); =20 @@ -280,13 +283,28 @@ int main(int argc, char *argv[]) =20 current_machine =3D MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACH= INE))); =20 + qemu_add_opts(&qemu_device_opts); + qemu_add_opts(&qemu_drive_opts); + qemu_add_drive_opts(&qemu_legacy_drive_opts); + qemu_add_drive_opts(&qemu_common_drive_opts); + qemu_add_drive_opts(&qemu_drive_opts); + qemu_add_drive_opts(&bdrv_runtime_opts); + mpqemu_link =3D mpqemu_link_create(); if (!mpqemu_link) { printf("Could not create MPQemu link\n"); return -1; } =20 - mpqemu_init_channel(mpqemu_link, &mpqemu_link->com, STDIN_FILENO); + fd =3D qemu_parse_fd(argv[1]); + if (fd =3D=3D -1) { + printf("Failed to parse fd for remote process.\n"); + return -EINVAL; + } + + parse_cmdline(argc - 2, argv + 2, NULL); + + mpqemu_init_channel(mpqemu_link, &mpqemu_link->com, fd); =20 mpqemu_link_set_callback(mpqemu_link, process_msg); =20 diff --git a/remote/remote-opts.c b/remote/remote-opts.c new file mode 100644 index 0000000000..cb7837bf13 --- /dev/null +++ b/remote/remote-opts.c @@ -0,0 +1,75 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "hw/boards.h" +#include "sysemu/blockdev.h" +#include "qapi/error.h" +#include "qemu-options.h" +#include "qemu-parse.h" +#include "remote-opts.h" + +/* + * In remote process, we parse only subset of options. The code + * taken from vl.c to re-use in remote command line parser. + */ +void parse_cmdline(int argc, char **argv, char **envp) +{ + int optind; + const char *optarg; + MachineClass *mc; + + /* from vl.c */ + optind =3D 0; + + /* second pass of option parsing */ + + for (;;) { + if (optind >=3D argc) { + break; + } + if (argv[optind][0] !=3D '-') { + loc_set_cmdline(argv, optind, 1); + drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS); + } else { + const QEMUOption *popt; + + popt =3D lookup_opt(argc, argv, &optarg, &optind); + #ifndef REMOTE_PROCESS + if (!(popt->arch_mask & arch_type)) { + error_report("Option not supported for this target," + " %x arch_mask, %x arch_type", + popt->arch_mask, arch_type); + exit(1); + } + #endif + switch (popt->index) { + case QEMU_OPTION_drive: + if (drive_def(optarg) =3D=3D NULL) { + fprintf(stderr, "Could not init drive\n"); + exit(1); + } + break; + default: + break; + } + } + } + mc =3D MACHINE_GET_CLASS(current_machine); + + mc->block_default_type =3D IF_IDE; + if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, + &mc->block_default_type, &error_fatal)) { + /* We printed help */ + exit(0); + } + + return; +} diff --git a/remote/remote-opts.h b/remote/remote-opts.h new file mode 100644 index 0000000000..263d428060 --- /dev/null +++ b/remote/remote-opts.h @@ -0,0 +1,15 @@ +/* + * Copyright =C2=A9 2018, 2020 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef REMOTE_OPTS_H +#define REMOTE_OPTS_H + +void parse_cmdline(int argc, char **argv, char **envp); + +#endif + --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167426; cv=none; d=zohomail.com; s=zohoarc; b=PbiXOsA+2dZQRrDkCWRi83fFbQJ+IMKFcfB7YtiSCAqWHFwceS8EPDZq+0BgOAZUcCUlYCevF+Zlf2cM1mVR4qS2jZXZluICbSSdmzX1zh9bufFyzzQk27JMW6cB43/ety1vwyOef92ZlmxHVA6AAy07PVyIkiALdq9PqxMjE0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167426; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Mp0pIOa7jmLQH3zhd/vSln1/RYrdggQWV5RgSTlLgKM=; b=RcficPrDZjtPqNgHWd+QczFH+OiwVEWY16WTyPIvXIiZhDs9OhRGu3hIq1VLYTYQIXb7aVQQx/OHPY/R7dwHG5Xpv5XtgIQQHhRhWBYj7rPO3QCv4woJXCH/Wt63drFhRJ3amvKnNQr8xssqW7pzZKiVwWaw4nLdhB4ekhrXTJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167426806962.9296513620357; Mon, 6 Apr 2020 03:03:46 -0700 (PDT) Received: from localhost ([::1]:57812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLObZ-0006M7-EQ for importer@patchew.org; Mon, 06 Apr 2020 06:03:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45037) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOJA-00070w-8q for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOJ8-0004Dy-7n for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:44 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47298) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOJ7-0004CL-Vq for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:42 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369gvI3028669; Mon, 6 Apr 2020 09:44:20 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 306jvmwrdv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:44:20 +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 0369fN8r066116; Mon, 6 Apr 2020 09:42:19 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 307419xhnc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:19 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369gHIX013753; Mon, 6 Apr 2020 09:42:17 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:17 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=Mp0pIOa7jmLQH3zhd/vSln1/RYrdggQWV5RgSTlLgKM=; b=px0BepA7t/PuoGKVeDEcN56Xr3om1YtwNAZHM6lCw/nlXvyZYXeycUnahzf1XzuLsaHC eUz0oy/AAjuRVgaJpUht83lEZ+pzRR8qdH0XDD8pfnLxPsMVPAwWHCHOJTTnaeTvELrP A2eUHCXgXHY7OnFC5iXPLT+60p3OFdXrRkQ099AIZtIWaziNvwRvyFDChqYVhL8oY/79 N90IW9yGxkICPAXFnpFK4Pg3KXVeT5Y1IccM9wUmmd8xEJ9fQOEJFC3TdCVHXHrzW31Y OuvjwUOCBg5RG02Dj4KMsyuSYpJnWOz99hxep/prp4GJJ/dYID3w6aWg3CA6/ig6spyb ew== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 27/36] multi-process: add support to parse device option Date: Mon, 6 Apr 2020 02:41:17 -0700 Message-Id: <3bcef025cd4ea036d5834add99b44f72076f1076.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Enable remote process to parse device command line option Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- remote/remote-opts.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/remote/remote-opts.c b/remote/remote-opts.c index cb7837bf13..f077221c71 100644 --- a/remote/remote-opts.c +++ b/remote/remote-opts.c @@ -57,6 +57,13 @@ void parse_cmdline(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_device: + if (!qemu_opts_parse_noisily(qemu_find_opts("device"), + optarg, true)) { + error_report("Unable to process device command"); + exit(1); + } + break; default: break; } @@ -71,5 +78,8 @@ void parse_cmdline(int argc, char **argv, char **envp) exit(0); } =20 + qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, + &error_fatal); + return; } --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167198; cv=none; d=zohomail.com; s=zohoarc; b=kELAfeYWRl+qrXOO21St8FNnrLUlnKgga9kEiZ19pQy0QOiEMPAXCQ9MkhrkoVIVZOFPIu8RTGl7BQKW9VkAtHH9BBWKBar+JX2P1iwL7MOtYS4o+9HOdDRGyEBcceZrjHXTgKoflQ6EMcKwaZlkUuYHxqujNyvG5imixbxJAQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167198; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Sw6vucOkSSS3zuorTyAuM8T7i6NrbGQ0PafIY8KIoTE=; b=DqZDZfICd5VFo9QxKVDdszRvSzJm8h6bij6ITz+vsY1o8fZBZp66Wb0az26bdhAU6fv4z+LFT1Wq0F9hhDe9hMaku3ojrApi0I/FInwfvg7svIOKfhQfsD6ND+mFU3E3uZ9e3bqjfHR1thcANqBYfZ8nnzAwBtLCyLXKmqUsPKo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167198326952.5488619412348; Mon, 6 Apr 2020 02:59:58 -0700 (PDT) Received: from localhost ([::1]:57682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOXs-00009R-0v for importer@patchew.org; Mon, 06 Apr 2020 05:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44369) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOGz-0002f6-3d for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGx-0002Ry-L8 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:29 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGx-0002RP-Cw for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:27 -0400 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 0369e7Hk089733; Mon, 6 Apr 2020 09:42:22 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 306hnqwtya-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:21 +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 0369fNBP066100; Mon, 6 Apr 2020 09:42:21 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 307419xhq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:21 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369gIMe013759; Mon, 6 Apr 2020 09:42:19 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:18 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=Sw6vucOkSSS3zuorTyAuM8T7i6NrbGQ0PafIY8KIoTE=; b=NqN7yCX7Bk+9vwpHGpJI3iJzWqauUOIXX8hzfkkM/5EnIrWShxsvN1iix3YrP2+Fcuax 9XuVALgO+N/3H+cRrRueAXyYDZGNZZK/IkO5FfAdWXMcRAFYXj+BSDAYMePzC00HwhJ6 sVlZyCc0967DUlXfgS+a6QuyYIvYNo/5aPyqEdySR6h320RxpRQ0MWCmEgd8dK+95KaN 7YWrHkEY44F8X0WdcFB5104Z8GP2XRfDSwvAygFyoobrLnbW9sbmST2vlvbuRyqGw8Sm le8izJzva4VRYSkUTTWIvXji6EtSlf3tUAoSNC1/rJryWtV3EnYCdhba62Ng7EMcO3hS 9g== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 28/36] multi-process: send heartbeat messages to remote Date: Mon, 6 Apr 2020 02:41:18 -0700 Message-Id: <5b04d390bd21b04c384bb05f577b089cb81b03c3.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=3 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva In order to detect remote processes which are hung, the proxy periodically sends heartbeat messages to confirm if the remote process is alive Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- hw/proxy/qemu-proxy.c | 86 +++++++++++++++++++++++++++++++++++ include/hw/proxy/qemu-proxy.h | 3 ++ include/io/mpqemu-link.h | 1 + io/mpqemu-link.c | 5 ++ 4 files changed, 95 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 730e28483e..162014353f 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -21,6 +21,78 @@ =20 static void probe_pci_info(PCIDevice *dev); =20 +static void childsig_handler(int sig, siginfo_t *siginfo, void *ctx) +{ + /* TODO: Add proper handler. */ + printf("Child (pid %d) is dead? Signal is %d, Exit code is %d.\n", + siginfo->si_pid, siginfo->si_signo, siginfo->si_code); +} + +static void hb_msg(PCIProxyDev *dev) +{ + DeviceState *ds =3D DEVICE(dev); + MPQemuMsg msg =3D { 0 }; + uint64_t ret; + + if (event_notifier_get_fd(&dev->en_ping) =3D=3D -1) { + return; + } + + memset(&msg, 0, sizeof(MPQemuMsg)); + + msg.num_fds =3D 1; + msg.cmd =3D PROXY_PING; + msg.bytestream =3D 0; + msg.size =3D 0; + msg.fds[0] =3D event_notifier_get_fd(&dev->en_ping); + + mpqemu_msg_send(&msg, dev->mpqemu_link->com); + + ret =3D wait_for_remote(msg.fds[0]); + + if (ret) { + printf("Lost contact with remote device %s\n", ds->id); + /* TODO: Initiate error recovery */ + } +} + +#define NOP_INTERVAL 1000 + +static void remote_ping(void *opaque) +{ + PCIProxyDev *dev =3D opaque; + + hb_msg(dev); + + timer_mod(dev->hb_timer, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NOP_INTERVAL); +} + +static void start_hb_timer(PCIProxyDev *dev) +{ + dev->hb_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, + remote_ping, + dev); + + timer_mod(dev->hb_timer, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NOP_INTERVAL); +} + +static void stop_hb_timer(PCIProxyDev *dev) +{ + timer_del(dev->hb_timer); + timer_free(dev->hb_timer); +} + +static void set_sigchld_handler(void) +{ + struct sigaction sa_sigterm; + memset(&sa_sigterm, 0, sizeof(sa_sigterm)); + sa_sigterm.sa_sigaction =3D childsig_handler; + sa_sigterm.sa_flags =3D SA_SIGINFO | SA_NOCLDWAIT | SA_NOCLDSTOP; + sigaction(SIGCHLD, &sa_sigterm, NULL); +} + static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, = int l, unsigned int op) { @@ -204,6 +276,19 @@ static void pci_proxy_dev_realize(PCIDevice *device, E= rror **errp) setup_irqfd(dev); =20 probe_pci_info(PCI_DEVICE(dev)); + + set_sigchld_handler(); + + event_notifier_init(&dev->en_ping, 0); + + start_hb_timer(dev); +} + +static void pci_proxy_dev_exit(PCIDevice *pdev) +{ + PCIProxyDev *dev =3D PCI_PROXY_DEV(pdev); + + stop_hb_timer(dev); } =20 static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) @@ -211,6 +296,7 @@ static void pci_proxy_dev_class_init(ObjectClass *klass= , void *data) PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); =20 k->realize =3D pci_proxy_dev_realize; + k->exit =3D pci_proxy_dev_exit; k->config_read =3D pci_proxy_read_config; k->config_write =3D pci_proxy_write_config; } diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 0d8ec6d686..26f0a41110 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -55,6 +55,9 @@ struct PCIProxyDev { EventNotifier intr; EventNotifier resample; =20 + EventNotifier en_ping; + QEMUTimer *hb_timer; + int socket; =20 ProxyMemoryRegion region[PCI_NUM_REGIONS]; diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index 102c736705..45ea1fcafa 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -50,6 +50,7 @@ typedef enum { SET_IRQFD, GET_PCI_INFO, RET_PCI_INFO, + PROXY_PING, MAX, } mpqemu_cmd_t; =20 diff --git a/io/mpqemu-link.c b/io/mpqemu-link.c index 4a998b3568..ff8a7da4a4 100644 --- a/io/mpqemu-link.c +++ b/io/mpqemu-link.c @@ -374,6 +374,11 @@ bool mpqemu_msg_valid(MPQemuMsg *msg) return false; } break; + case PROXY_PING: + if (msg->size !=3D 0) { + return false; + } + break; default: break; } --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166441; cv=none; d=zohomail.com; s=zohoarc; b=CmrsMzbR/uyMr420Vh0ajMmgmU9vyu0jUKbxZei3h9ASBc/XBHJ9jA4CPxmBL0bVM/FbDGif6Vz8jUPNfiCYU2xJK8gPM+bMqvh96YZHFHmlyCcwSinPJCiZ1nS9mHfg+QMFgmBCyrBNH20veFjNL8Pmg1b1GmI1fMAmuqGeGxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166441; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SdDE3JKBu7f4i+tB+6lCAKGPdBJ7kMP18msjXH0Or7k=; b=jVTJmxMs4l2spDEKz497WMFRxSFnAWjpybX1Oi79KyTLsLLucNfD49Zj6v5SpB2NO5SyjLRNjkwargoY2i56K6by7NWnj8+SYlMQ3wdA+XoG6I60qaP4+1xqecMQS8aWqPwp9K7NzcbqBPFfV1BKpQJGQGDVu5kfAhcle96+mgU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166441794702.3032420823998; Mon, 6 Apr 2020 02:47:21 -0700 (PDT) Received: from localhost ([::1]:57344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOLg-00023c-AP for importer@patchew.org; Mon, 06 Apr 2020 05:47:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44414) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOH0-0002ga-5L for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOGz-0002Ti-1R for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:30 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35146) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOGy-0002Sg-P5 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:28 -0400 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 0369dxff089554; Mon, 6 Apr 2020 09:42:23 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 306hnqwtyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:23 +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 0369fOL6066148; Mon, 6 Apr 2020 09:42:22 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 307419xhrf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:22 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gKFG007155; Mon, 6 Apr 2020 09:42:20 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:20 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=SdDE3JKBu7f4i+tB+6lCAKGPdBJ7kMP18msjXH0Or7k=; b=XVYltTD+TzgXXShTn94OsyqWOPB9bP7AtAsa8KsyvKAYvoNKAN1TzNgvxTuRMK9q4yYh MScKQD86c6Oy+cHV6EfPvSkNZu7+AtwFtUaJREXO42CAIq643tp5DxTL8VrycZQTOjSS /1Yp5TOLA/+JTRpMRlmjztPkEbfuYVBm3sNyja7xx0yc3qgcUx75AXKvK0VsFSAOjDwv hdJJoHy3Ns5vDzpjLnj9S9npPiSvtuyFhcYY6r/boQsrlyonKUSeqGqD+CngL8FKCgCB MbleAwE6+UP0RAcLUMPYTMOymJmNVtcv481Qymi/RfNAQRfmqlIS3lGLw6hwT/pWQIbR ug== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 29/36] multi-process: handle heartbeat messages in remote process Date: Mon, 6 Apr 2020 02:41:19 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva If the remote process is alive, it responds to proxy's heartbeat messages Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- remote/remote-main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index a0892c05b6..18184b3f4b 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -190,6 +190,7 @@ static void process_msg(GIOCondition cond, MPQemuLinkSt= ate *link, { MPQemuMsg *msg =3D NULL; Error *err =3D NULL; + int wait; =20 if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { goto finalize_loop; @@ -242,6 +243,10 @@ static void process_msg(GIOCondition cond, MPQemuLinkS= tate *link, case GET_PCI_INFO: process_get_pci_info_msg(link, msg); break; + case PROXY_PING: + wait =3D msg->fds[0]; + notify_proxy(wait, 0); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167274; cv=none; d=zohomail.com; s=zohoarc; b=Vjhh/443Cg5EAI9LkzsVS+fEHg1br00v2C/PdljFDLE63I2w9PbVI6Qv3SWcd5sdASxoGZGL1WHsIjsJLbCaRtnYAHpgxi6xrKaZkd6Vi4psISELLS6HsHSOcJCvGuwANdiF8rA5bGmeE5zTcz651YXILi4ZyaxvDRF9S474Ijo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167274; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jbQyi+l5kcRmEtgZvNOXkZwgs6yQkKCSn5xC7Wm2LPw=; b=R2t2N1Z3TRD4gMXmKXBYP8UM04Zmpxi6AY+LAeM1r3ZDu+vSyGcKZOjKIY0K/AeKDolApVpo+4Xq+/XudsQ9+lZWeNC4mk7OO9Ojf4Ft46fYYV/zoI8ckuC3rxUZyBU8aAdFZykcE6ha0lRWMvOlAhljpp0huBNrJOgs0hnNDgI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167274660719.5270842900405; Mon, 6 Apr 2020 03:01:14 -0700 (PDT) Received: from localhost ([::1]:57736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOZ7-0002KJ-EP for importer@patchew.org; Mon, 06 Apr 2020 06:01:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45072) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOJC-00077h-JM for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOJB-0004Ft-7G for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:46 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOJA-0004Ey-UO for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:45 -0400 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 0369i3Q5093135; Mon, 6 Apr 2020 09:44:24 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 306hnqwu8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:44:23 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369chFP092235; Mon, 6 Apr 2020 09:42:23 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3073spk6ke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:22 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gLXR032052; Mon, 6 Apr 2020 09:42:22 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:21 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=jbQyi+l5kcRmEtgZvNOXkZwgs6yQkKCSn5xC7Wm2LPw=; b=uis10KAtowgcUHfYe78p2M1bXPWBY5z4zQhmOUgwuSfUv4xIFGQabHVjQkOn5bH05A5S TMzWwt7FluntTjYyuuJMHPtqGOiaEUaCG1yCqq8PP7UNN5tNqIsf55HtMVUbdjxYl+mK tXUbi2utUUbfethi685q9/aKilQvwiJGkuO7xHYeRRcbk1lTurCezWThfk0wPVwfEv2W WZ2YZQ2gv5oM6h96VA341RzD8Itavp0qiqOAyxhjYEa/QQLiQwu/6cWe4e7kDMAY76oH WN31OKG4bqbzzSvQgpmO/iqk37AZZ3aUJkwvCyzg2dRTd90Hz2qvGA+JWUUqEZDxxuZ8 8A== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 30/36] multi-process: perform device reset in the remote process Date: Mon, 6 Apr 2020 02:41:20 -0700 Message-Id: <472b75b4180021fdf2d4de540de0b94e34ffe964.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Perform device reset in the remote process when QEMU performs device reset. This is required to reset the internal state (like registers, etc...) of emulated devices Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- hw/proxy/qemu-proxy.c | 25 +++++++++++++++++++++++++ include/io/mpqemu-link.h | 1 + remote/remote-main.c | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 162014353f..cffc227acd 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -291,14 +291,39 @@ static void pci_proxy_dev_exit(PCIDevice *pdev) stop_hb_timer(dev); } =20 +static void proxy_device_reset(DeviceState *dev) +{ + PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); + MPQemuMsg msg; + int wait =3D -1; + + memset(&msg, 0, sizeof(MPQemuMsg)); + + msg.bytestream =3D 0; + msg.size =3D sizeof(msg.data1); + msg.cmd =3D DEVICE_RESET; + + wait =3D GET_REMOTE_WAIT; + msg.num_fds =3D 1; + msg.fds[0] =3D wait; + + mpqemu_msg_send(&msg, pdev->mpqemu_link->com); + + (void)wait_for_remote(wait); + + PUT_REMOTE_WAIT(wait); +} + static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); =20 k->realize =3D pci_proxy_dev_realize; k->exit =3D pci_proxy_dev_exit; k->config_read =3D pci_proxy_read_config; k->config_write =3D pci_proxy_write_config; + dc->reset =3D proxy_device_reset; } =20 static const TypeInfo pci_proxy_dev_type_info =3D { diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index 45ea1fcafa..22fb234744 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -51,6 +51,7 @@ typedef enum { GET_PCI_INFO, RET_PCI_INFO, PROXY_PING, + DEVICE_RESET, MAX, } mpqemu_cmd_t; =20 diff --git a/remote/remote-main.c b/remote/remote-main.c index 18184b3f4b..6e198de35f 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -38,6 +38,7 @@ #include "exec/address-spaces.h" #include "remote/iohub.h" #include "remote-opts.h" +#include "sysemu/reset.h" =20 static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan); @@ -185,6 +186,15 @@ static void process_get_pci_info_msg(MPQemuLinkState *= link, MPQemuMsg *msg) mpqemu_msg_send(&ret, link->dev); } =20 +static void process_device_reset_msg(MPQemuMsg *msg) +{ + qemu_devices_reset(); + + if (msg->num_fds =3D=3D 1) { + notify_proxy(msg->fds[0], 0); + } +} + static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan) { @@ -247,6 +257,9 @@ static void process_msg(GIOCondition cond, MPQemuLinkSt= ate *link, wait =3D msg->fds[0]; notify_proxy(wait, 0); break; + case DEVICE_RESET: + process_device_reset_msg(msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167087; cv=none; d=zohomail.com; s=zohoarc; b=hY6LFYuE8MjmdGgeUwj7K4PrX4cLa2gUCOn0WV3KECQ3j1d5/nA65CrVixoAj/dNB3Bp5q8VSSFihTdwijthW5unhgjZ8ly95GTE1p+gryQfbDErgQk/P90QEFPxrrHKh3KzpnhHLVkPYgbqPc6gAAFis8GsOzswZ/p4n4+Ptyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167087; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ErnlVmUky9MlIpNpwlwVvahKl4XDiFrMn9QLMadETbs=; b=kMSQee9pnZTPadCZZsCBmMgZnfyINv6S5Cfza+ZfMrLo4D2t805mN2NUsLw/1xttlucd4HpFk+wEUOiAoLjKphyQ1tcf/K7Rv92yqcfedGt5cmPj52CjMeiw1v2Slfo9V+JbxzuUIqzG2bWXBEvJCOFxcDnR+WTEJARbQi1syVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167087245948.6801141257454; Mon, 6 Apr 2020 02:58:07 -0700 (PDT) Received: from localhost ([::1]:57638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOW5-0005Ew-Fa for importer@patchew.org; Mon, 06 Apr 2020 05:58:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44467) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOH2-0002nd-J8 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOH0-0002W4-Ry for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:32 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35162) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOH0-0002V0-JW for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:30 -0400 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 0369eCZN089766; Mon, 6 Apr 2020 09:42:25 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 306hnqwtyq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:25 +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 0369fN8t066116; Mon, 6 Apr 2020 09:42:24 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 307419xhu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:24 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gNjb032122; Mon, 6 Apr 2020 09:42:23 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:23 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=ErnlVmUky9MlIpNpwlwVvahKl4XDiFrMn9QLMadETbs=; b=OoO09WPdq9+YDwNXcg9gRhD/iA5VoIB4O5nOdIp+0DCXI+tz+Aa0x1U0UHRRjALSNP1q KXZz1lX0RW0H/j6VIc6j9bNexUnVT7C49z/kEdqGKpT2E5IkV7s6lLsVc4W5SYvl+UeA CBOgaLB7CMAnscJIQ6q9Ls8deb7DhOeDmvshRQP1AukB1PcMmd/o028KmCkVY8QKnn35 X6LvAVzSE2/5ALT3QR2fmnaCFnMlRdpVOBwT/t6P4TBNPpgUwS/iA7N3nGYiBlwpA4iy MoPGUPZJkA37k3S3PgpC5Dv0/yPJj2BH0Xbdg3wBnOWRJC7vwj/sBArabvdyrvY6ZxTV jA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 31/36] multi-process/mon: choose HMP commands based on target Date: Mon, 6 Apr 2020 02:41:21 -0700 Message-Id: <5baeb9209242fc32e43f25513fab9ab082a52c0a.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Add "targets" field to HMP command definition to select the targets which would be supported by each command Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- hmp-commands-info.hx | 10 ++++++++++ hmp-commands.hx | 20 ++++++++++++++++++++ scripts/hxtool | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 1 deletion(-) mode change 100644 =3D> 100755 scripts/hxtool diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index ca5198438d..1fbca7a18d 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -23,6 +23,7 @@ ERST .params =3D "", .help =3D "show the version of QEMU", .cmd =3D hmp_info_version, + .targets =3D "scsi", .flags =3D "p", }, =20 @@ -50,6 +51,7 @@ ERST .params =3D "", .help =3D "show the character devices", .cmd =3D hmp_info_chardev, + .targets =3D "scsi", .flags =3D "p", }, =20 @@ -65,6 +67,7 @@ ERST .help =3D "show info of one block device or all block device= s " "(-n: show named nodes; -v: show details)", .cmd =3D hmp_info_block, + .targets =3D "scsi", }, =20 SRST @@ -78,6 +81,7 @@ ERST .params =3D "", .help =3D "show block device statistics", .cmd =3D hmp_info_blockstats, + .targets =3D "scsi", }, =20 SRST @@ -91,6 +95,7 @@ ERST .params =3D "", .help =3D "show progress of ongoing block device operations", .cmd =3D hmp_info_block_jobs, + .targets =3D "scsi", }, =20 SRST @@ -161,6 +166,7 @@ ERST .params =3D "", .help =3D "show the command line history", .cmd =3D hmp_info_history, + .targets =3D "scsi", .flags =3D "p", }, =20 @@ -214,6 +220,7 @@ ERST .params =3D "", .help =3D "show PCI info", .cmd =3D hmp_info_pci, + .targets =3D "scsi", }, =20 SRST @@ -598,6 +605,7 @@ ERST .params =3D "", .help =3D "show device tree", .cmd =3D hmp_info_qtree, + .targets =3D "scsi", }, =20 SRST @@ -611,6 +619,7 @@ ERST .params =3D "", .help =3D "show qdev device model list", .cmd =3D hmp_info_qdm, + .targets =3D "scsi", }, =20 SRST @@ -624,6 +633,7 @@ ERST .params =3D "[path]", .help =3D "show QOM composition tree", .cmd =3D hmp_info_qom_tree, + .targets =3D "scsi", .flags =3D "p", }, =20 diff --git a/hmp-commands.hx b/hmp-commands.hx index 02cae25c24..1b60676d7c 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -45,6 +45,7 @@ ERST .params =3D "", .help =3D "quit the emulator", .cmd =3D hmp_quit, + .targets =3D "scsi", }, =20 SRST @@ -76,6 +77,7 @@ ERST .params =3D "device size", .help =3D "resize a block image", .cmd =3D hmp_block_resize, + .targets =3D "scsi", }, =20 SRST @@ -92,6 +94,7 @@ ERST .params =3D "device [speed [base]]", .help =3D "copy data from a backing file into a block device= ", .cmd =3D hmp_block_stream, + .targets =3D "scsi", }, =20 SRST @@ -105,6 +108,7 @@ ERST .params =3D "device speed", .help =3D "set maximum speed for a background block operatio= n", .cmd =3D hmp_block_job_set_speed, + .targets =3D "scsi", }, =20 SRST @@ -120,6 +124,7 @@ ERST "\n\t\t\t if you want to abort the operation immedia= tely" "\n\t\t\t instead of keep running until data is in s= ync)", .cmd =3D hmp_block_job_cancel, + .targets =3D "scsi", }, =20 SRST @@ -133,6 +138,7 @@ ERST .params =3D "device", .help =3D "stop an active background block operation", .cmd =3D hmp_block_job_complete, + .targets =3D "scsi", }, =20 SRST @@ -147,6 +153,7 @@ ERST .params =3D "device", .help =3D "pause an active background block operation", .cmd =3D hmp_block_job_pause, + .targets =3D "scsi", }, =20 SRST @@ -160,6 +167,7 @@ ERST .params =3D "device", .help =3D "resume a paused background block operation", .cmd =3D hmp_block_job_resume, + .targets =3D "scsi", }, =20 SRST @@ -173,6 +181,7 @@ ERST .params =3D "[-f] device", .help =3D "eject a removable medium (use -f to force it)", .cmd =3D hmp_eject, + .targets =3D "scsi", }, =20 SRST @@ -186,6 +195,7 @@ ERST .params =3D "device", .help =3D "remove host block device", .cmd =3D hmp_drive_del, + .targets =3D "scsi", }, =20 SRST @@ -204,6 +214,7 @@ ERST .params =3D "device filename [format [read-only-mode]]", .help =3D "change a removable medium, optional format", .cmd =3D hmp_change, + .targets =3D "scsi", }, =20 SRST @@ -671,6 +682,7 @@ ERST .help =3D "add device, like -device on the command line", .cmd =3D hmp_device_add, .command_completion =3D device_add_completion, + .targets =3D "scsi", }, =20 SRST @@ -685,6 +697,7 @@ ERST .help =3D "remove device", .cmd =3D hmp_device_del, .command_completion =3D device_del_completion, + .targets =3D "scsi", }, =20 SRST @@ -1264,6 +1277,7 @@ ERST "The -c flag requests QEMU to compress backup data\n= \t\t\t" "(if the target format supports it).\n\t\t\t", .cmd =3D hmp_drive_backup, + .targets =3D "scsi", }, SRST ``drive_backup`` @@ -1280,6 +1294,7 @@ ERST "[,readonly=3Don|off][,copy-on-read=3Don|off]", .help =3D "add drive to PCI storage controller", .cmd =3D hmp_drive_add, + .targets =3D "scsi", }, =20 SRST @@ -1697,6 +1712,7 @@ ERST .help =3D "add chardev", .cmd =3D hmp_chardev_add, .command_completion =3D chardev_add_completion, + .targets =3D "scsi", }, =20 SRST @@ -1710,6 +1726,7 @@ ERST .params =3D "id args", .help =3D "change chardev", .cmd =3D hmp_chardev_change, + .targets =3D "scsi", }, =20 SRST @@ -1725,6 +1742,7 @@ ERST .help =3D "remove chardev", .cmd =3D hmp_chardev_remove, .command_completion =3D chardev_remove_completion, + .targets =3D "scsi", }, =20 SRST @@ -1739,6 +1757,7 @@ ERST .help =3D "send a break on chardev", .cmd =3D hmp_chardev_send_break, .command_completion =3D chardev_remove_completion, + .targets =3D "scsi", }, =20 SRST @@ -1810,6 +1829,7 @@ ERST .params =3D "[subcommand]", .help =3D "show various information about the system state", .cmd =3D hmp_info_help, + .targets =3D "scsi", .sub_table =3D hmp_info_cmds, .flags =3D "p", }, diff --git a/scripts/hxtool b/scripts/hxtool old mode 100644 new mode 100755 index 7b1452f3cf..80c6845db1 --- a/scripts/hxtool +++ b/scripts/hxtool @@ -10,7 +10,39 @@ hxtoh() SRST*|ERST*) flag=3D$(($flag^1)) ;; *) - test $flag -eq 1 && printf "%s\n" "$str" + # Skip line that has ".targets" as it is for multi-process tar= gets based hmp + # commands generation. + echo $str | grep -q '.targets' + if [ $? -eq 0 ]; then + continue + else + test $flag -eq 1 && printf "%s\n" "$str" + fi + ;; + esac + done +} + +hxtoh_tgt() +{ + section=3D"" + flag=3D1 + use_section=3D0 + while read -r str; do + # Print section if it has ".targets" and the second argument passe= d to the + # script, such as "scsi". + echo "$str" | grep -q -E ".targets.*$1" + if [ $? -eq 0 ]; then + use_section=3D1 + continue + fi + case $str in + HXCOMM*) + ;; + SRST*|ERST*) flag=3D$(($flag^1)); test $use_section -eq 1 && p= rintf '%s' "$section"; section=3D""; use_section=3D0 + ;; + *) + test $flag -eq 1 && section=3D"${section} ${str} ${IFS}" ;; esac done @@ -18,6 +50,7 @@ hxtoh() =20 case "$1" in "-h") hxtoh ;; +"-tgt") hxtoh_tgt $2 ;; *) exit 1 ;; esac =20 --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166672; cv=none; d=zohomail.com; s=zohoarc; b=FZBegxW045GANH7pYWLJQP6oAHTefsYx5/FkJybmPgbeMUQ6iVcK2VISI+nxHG8WYnTmUkKtWB2P54Mn/RcPU2pR4FgnpFxnBgTb69sEIzOhRIXDDJ46dTKglAEyFCZNhc22BtjJvGWOHdb5ILA0VJZaZLUs2kE4sujAt0Xores= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166672; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X9dbkBhM2qohXC9LR568CBMoVxX6ITNshH4LwP3N5oc=; b=cyCthOTX8ncah+lNVBiK5JamJYMGKq9rJOjh3J3CakDEvWyGatMw3jiS31tARnQLvIZgwLSBMuCDqQJ6iHMUXO6Gf/ydcShHZ7ASz04vggNAgiGbM0fV5XadePgksg/ejrcm/rDgDDZLWuPCsp01v6ArebOi4/CBOPGM5ra+iDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166672701583.7996714322445; Mon, 6 Apr 2020 02:51:12 -0700 (PDT) Received: from localhost ([::1]:57454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOPP-00010H-A7 for importer@patchew.org; Mon, 06 Apr 2020 05:51:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44569) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOHH-0003Pz-7L for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOHE-0002fT-Gn for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:47 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:46036) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOHE-0002ew-7P for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:44 -0400 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 0369drH1069795; Mon, 6 Apr 2020 09:42:38 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 306j6m5tde-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:38 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369gaPc107294; Mon, 6 Apr 2020 09:42:38 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 3073spk6p6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:37 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gPFL007193; Mon, 6 Apr 2020 09:42:25 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:24 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=X9dbkBhM2qohXC9LR568CBMoVxX6ITNshH4LwP3N5oc=; b=Kl3lRohoUaxhy3vH4JxZuAXydrV0pfysG/ie8Sp0brIHr4XiKYgSE7+1hTZV4VB6GmNd AjvbUBBVWdJxM9bo5r4fFkpwM9ENjtIDeaAN10GgLx9KFLTQaCV/DuE5E4/v1Yf7AP7N ktNKCX3e6w/weSb6S63HdWg84feQ2Wm1w3SXCSamU8CrPEDjHaEzQ/zXQLTR+QEi16He MM5Pzv4DW64VqQhX4B6SnMylEdXJ7XZOz5Fhgftz/Jtp4+Py9wBCgw0dHiWsCPB+oZCI Bfnytj5O7dTRtytbI7aRjZze3H0eAGJTIcL4aGY9HTC1TCCRIJPF9BTCld+xoG2PS8W+ +w== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 32/36] multi-process/mon: stub functions to enable QMP module for remote process Date: Mon, 6 Apr 2020 02:41:22 -0700 Message-Id: <2cd34390a079c63fad4ece60d7b63bdfff64c534.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva QMP module doesn't need some functions to run independently on the remote processes. However, these functions are necessary for compilation. Therefore, these functions are stub'ed out. The stub functions raise an assert if QEMU is built in debug mode (--enable-debug). Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- MAINTAINERS | 4 + accel/stubs/tcg-stub.c | 10 +++ configure | 4 + include/qemu-common.h | 8 ++ stubs/gdbstub.c | 23 ++++++ stubs/migration.c | 162 +++++++++++++++++++++++++++++++++++++++++ stubs/monitor.c | 31 ++++++++ stubs/net-stub.c | 69 ++++++++++++++++++ stubs/qapi-misc.c | 41 +++++++++++ stubs/qapi-target.c | 56 ++++++++++++++ stubs/ui-stub.c | 130 +++++++++++++++++++++++++++++++++ stubs/vl-stub.c | 92 +++++++++++++++++++++++ 12 files changed, 630 insertions(+) create mode 100644 stubs/migration.c create mode 100644 stubs/qapi-misc.c create mode 100644 stubs/qapi-target.c create mode 100644 stubs/ui-stub.c diff --git a/MAINTAINERS b/MAINTAINERS index 2a0fd65f7a..eb5ce6ea73 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1967,6 +1967,8 @@ F: blockdev-hmp-cmds.c F: block/qapi.c F: qapi/block*.json F: qapi/transaction.json +F: stubs/qapi-misc.c +F: stubs/qapi-target.c T: git https://repo.or.cz/qemu/armbru.git block-next =20 Dirty Bitmaps @@ -2081,6 +2083,7 @@ F: ui/ F: include/ui/ F: qapi/ui.json F: util/drm.c +F: stubs/ui-stub.c =20 Cocoa graphics M: Peter Maydell @@ -2112,6 +2115,7 @@ F: include/monitor/hmp-target.h F: tests/qtest/test-hmp.c F: include/qemu/qemu-print.h F: util/qemu-print.c +F: stubs/migration.c =20 Network device backends M: Jason Wang diff --git a/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c index 2e4e8741fb..cdbceb5fff 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -119,4 +119,14 @@ page_collection_lock(tb_page_addr_t start, tb_page_add= r_t end) void page_collection_unlock(struct page_collection *set) { } + +void dump_exec_info(void) +{ + qemu_debug_assert(0); +} + +void dump_opcount_info(void) +{ + qemu_debug_assert(0); +} #endif diff --git a/configure b/configure index 3fbb66a5d5..582487c26c 100755 --- a/configure +++ b/configure @@ -7601,6 +7601,10 @@ if test "$mpqemu" =3D "yes" ; then echo "CONFIG_MPQEMU=3Dy" >> $config_host_mak fi =20 +if test "$debug" =3D "yes" ; then + echo "CONFIG_DEBUG=3Dy" >> $config_host_mak +fi + if test "$bochs" =3D "yes" ; then echo "CONFIG_BOCHS=3Dy" >> $config_host_mak fi diff --git a/include/qemu-common.h b/include/qemu-common.h index d0142f29ac..b76e309d98 100644 --- a/include/qemu-common.h +++ b/include/qemu-common.h @@ -10,6 +10,8 @@ #ifndef QEMU_COMMON_H #define QEMU_COMMON_H =20 +#include + #define TFR(expr) do { if ((expr) !=3D -1) break; } while (errno =3D=3D EI= NTR) =20 /* Copyright string for -version arguments, About dialogs, etc */ @@ -135,4 +137,10 @@ void page_size_init(void); * returned. */ bool dump_in_progress(void); =20 +#ifdef CONFIG_DEBUG +#define qemu_debug_assert(x) assert(x) +#else +#define qemu_debug_assert(x) +#endif + #endif diff --git a/stubs/gdbstub.c b/stubs/gdbstub.c index 2b7aee50d3..1e65b54755 100644 --- a/stubs/gdbstub.c +++ b/stubs/gdbstub.c @@ -1,6 +1,29 @@ #include "qemu/osdep.h" +#include "qemu-common.h" #include "exec/gdbstub.h" /* xml_builtin */ =20 +#pragma weak gdbserver_start + const char *const xml_builtin[][2] =3D { { NULL, NULL } }; + +#ifdef CONFIG_USER_ONLY + +int gdbserver_start(int port) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +#else + +int gdbserver_start(const char *device) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +#endif diff --git a/stubs/migration.c b/stubs/migration.c new file mode 100644 index 0000000000..28ccf80f21 --- /dev/null +++ b/stubs/migration.c @@ -0,0 +1,162 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "migration/misc.h" +#include "migration/snapshot.h" +#include "qapi/qapi-types-migration.h" +#include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-types-net.h" + +MigrationInfo *qmp_query_migrate(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_migrate_set_capabilities(MigrationCapabilityStatusList *params, + Error **errp) +{ + qemu_debug_assert(0); +} + +MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) +{ + qemu_debug_assert(0); +} + +MigrationParameters *qmp_query_migrate_parameters(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_migrate_start_postcopy(Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_cancel(Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_continue(MigrationStatus state, Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_set_downtime(double value, Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_set_speed(int64_t value, Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_set_cache_size(int64_t value, Error **errp) +{ + qemu_debug_assert(0); +} + +int64_t qmp_query_migrate_cache_size(Error **errp) +{ + qemu_debug_assert(0); + + return 0; +} + +void qmp_migrate(const char *uri, bool has_blk, bool blk, + bool has_inc, bool inc, bool has_detach, bool detach, + bool has_resume, bool resume, Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_incoming(const char *uri, Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_recover(const char *uri, Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_migrate_pause(Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_x_colo_lost_heartbeat(Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_xen_save_devices_state(const char *filename, bool has_live, bool = live, + Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_xen_set_replication(bool enable, bool primary, + bool has_failover, bool failover, + Error **errp) +{ + qemu_debug_assert(0); +} + +ReplicationStatus *qmp_query_xen_replication_status(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_xen_colo_do_checkpoint(Error **errp) +{ + qemu_debug_assert(0); +} + +COLOStatus *qmp_query_colo_status(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void migration_global_dump(Monitor *mon) +{ + qemu_debug_assert(0); +} + +int load_snapshot(const char *name, Error **errp) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +int save_snapshot(const char *name, Error **errp) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +AnnounceParameters *migrate_announce_params(void) +{ + qemu_debug_assert(0); + + return NULL; +} diff --git a/stubs/monitor.c b/stubs/monitor.c index 07b0bedaab..959460834b 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -1,4 +1,5 @@ #include "qemu/osdep.h" +#include "qemu-common.h" #include "qapi/error.h" #include "monitor/monitor.h" #include "../monitor/monitor-internal.h" @@ -10,6 +11,24 @@ #include "sysemu/sysemu.h" #include "sysemu/runstate.h" #include "monitor/hmp.h" +#include "monitor/qdev.h" +#include "sysemu/blockdev.h" +#include "sysemu/sysemu.h" + +#include "qapi/qapi-types-block-core.h" +#include "qapi/qapi-commands-block-core.h" + +#pragma weak cur_mon +#pragma weak monitor_vprintf +#pragma weak monitor_get_fd +#pragma weak monitor_init +#pragma weak qapi_event_emit +#pragma weak monitor_get_cpu_index +#pragma weak monitor_printf +#pragma weak monitor_cur_is_qmp +#pragma weak qmp_device_list_properties +#pragma weak monitor_init_qmp +#pragma weak monitor_init_hmp =20 #pragma weak hmp_handle_error #pragma weak cur_mon @@ -22,40 +41,52 @@ __thread Monitor *cur_mon; =20 int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { + qemu_debug_assert(0); abort(); } =20 int monitor_get_fd(Monitor *mon, const char *name, Error **errp) { + qemu_debug_assert(0); error_setg(errp, "only QEMU supports file descriptor passing"); return -1; } =20 void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp) { + qemu_debug_assert(0); } =20 void monitor_fdsets_cleanup(void) { + qemu_debug_assert(0); } =20 int monitor_get_cpu_index(void) { + qemu_debug_assert(0); + return -ENOSYS; } int monitor_printf(Monitor *mon, const char *fmt, ...) { + qemu_debug_assert(0); + return -ENOSYS; } =20 bool monitor_cur_is_qmp(void) { + qemu_debug_assert(0); + return false; } =20 ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, Error **errp) { + qemu_debug_assert(0); + return NULL; } =20 diff --git a/stubs/net-stub.c b/stubs/net-stub.c index cb2274ba40..6660e83527 100644 --- a/stubs/net-stub.c +++ b/stubs/net-stub.c @@ -2,6 +2,9 @@ #include "qemu-common.h" #include "net/net.h" =20 +#include "qapi/qapi-commands-net.h" +#include "qapi/qapi-commands-rocker.h" + int qemu_find_net_clients_except(const char *id, NetClientState **ncs, NetClientDriver type, int max) { @@ -29,3 +32,69 @@ int qemu_find_nic_model(NICInfo *nd, const char * const = *models, return -ENOSYS; } =20 +void qmp_set_link(const char *name, bool up, Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_netdev_del(const char *id, Error **errp) +{ + qemu_debug_assert(0); +} + +RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name, + Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_announce_self(AnnounceParameters *params, Error **errp) +{ + qemu_debug_assert(0); +} + +RockerSwitch *qmp_query_rocker(const char *name, Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +RockerPortList *qmp_query_rocker_ports(const char *name, Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name, + bool has_tbl_id, + uint32_t tbl_id, + Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name, + bool has_type, + uint8_t type, + Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_netdev_add(Netdev *arg, Error **errp) +{ + qemu_debug_assert(0); +} + +void netdev_add(QemuOpts *opts, Error **errp) +{ + qemu_debug_assert(0); +} diff --git a/stubs/qapi-misc.c b/stubs/qapi-misc.c new file mode 100644 index 0000000000..3eeedd997a --- /dev/null +++ b/stubs/qapi-misc.c @@ -0,0 +1,41 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "qapi/qapi-commands-misc.h" +#include "./qapi/qapi-types-dump.h" +#include "qapi/qapi-commands-dump.h" + +void qmp_dump_guest_memory(bool paging, const char *file, + bool has_detach, bool detach, + bool has_begin, int64_t begin, bool has_length, + int64_t length, bool has_format, + DumpGuestMemoryFormat format, Error **errp) +{ + qemu_debug_assert(0); +} + +DumpQueryResult *qmp_query_dump(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **= errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_xen_load_devices_state(const char *filename, Error **errp) +{ + qemu_debug_assert(0); +} + +bool dump_in_progress(void) +{ + qemu_debug_assert(0); + + return FALSE; +} diff --git a/stubs/qapi-target.c b/stubs/qapi-target.c new file mode 100644 index 0000000000..7a16164dde --- /dev/null +++ b/stubs/qapi-target.c @@ -0,0 +1,56 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "qapi/qapi-types-misc-target.h" +#include "qapi/qapi-commands-misc-target.h" +#include "qapi/qapi-types-machine-target.h" +#include "qapi/qapi-commands-machine-target.h" + +#if defined(TARGET_I386) +void qmp_rtc_reset_reinjection(Error **errp) +{ + qemu_debug_assert(0); +} + +SevInfo *qmp_query_sev(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +SevCapability *qmp_query_sev_capabilities(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} +#endif + +#if defined(TARGET_S390X) || defined(TARGET_I386) || defined(TARGET_ARM) +CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, + CpuModelInfo *model, + Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} +#endif + +#if defined(TARGET_PPC) || defined(TARGET_ARM) || defined(TARGET_I386) || \ + defined(TARGET_S390X) || defined(TARGET_MIPS) +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} +#endif diff --git a/stubs/ui-stub.c b/stubs/ui-stub.c new file mode 100644 index 0000000000..a5a63ead50 --- /dev/null +++ b/stubs/ui-stub.c @@ -0,0 +1,130 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "ui/console.h" +#include "ui/input.h" +#include "ui/qemu-spice.h" + +#include "qapi/qapi-types-ui.h" +#include "qapi/qapi-commands-ui.h" + +void qmp_screendump(const char *filename, bool has_device, const char *dev= ice, + bool has_head, int64_t head, Error **errp) +{ + qemu_debug_assert(0); +} + +VncInfo *qmp_query_vnc(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +VncInfo2List *qmp_query_vnc_servers(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +MouseInfoList *qmp_query_mice(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_tim= e, + Error **errp) +{ + qemu_debug_assert(0); +} + +void qmp_input_send_event(bool has_device, const char *device, + bool has_head, int64_t head, + InputEventList *events, Error **errp) +{ + qemu_debug_assert(0); +} + +void vnc_display_open(const char *id, Error **errp) +{ + qemu_debug_assert(0); +} + +void vnc_display_add_client(const char *id, int csock, bool skipauth) +{ + qemu_debug_assert(0); +} + +void qemu_input_queue_rel(QemuConsole *src, InputAxis axis, int value) +{ + qemu_debug_assert(0); +} + +void qemu_input_queue_btn(QemuConsole *src, InputButton btn, bool down) +{ + qemu_debug_assert(0); +} + +void qemu_input_event_sync(void) +{ + qemu_debug_assert(0); +} + +void qemu_input_update_buttons(QemuConsole *src, uint32_t *button_map, + uint32_t button_old, uint32_t button_new) +{ + qemu_debug_assert(0); +} + +#ifdef CONFIG_SPICE + +int using_spice; + +SpiceInfo *qmp_query_spice(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, + const char *subject) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +int qemu_spice_display_add_client(int csock, int skipauth, int tls) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +int qemu_spice_set_passwd(const char *passwd, bool fail_if_conn, + bool disconnect_if_conn) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +int qemu_spice_set_pw_expire(time_t expires) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} + +#endif + +int index_from_key(const char *key, size_t key_length) +{ + qemu_debug_assert(0); + + return -ENOSYS; +} diff --git a/stubs/vl-stub.c b/stubs/vl-stub.c index fff72be201..606f078274 100644 --- a/stubs/vl-stub.c +++ b/stubs/vl-stub.c @@ -8,6 +8,12 @@ #include "disas/disas.h" #include "sysemu/runstate.h" =20 +#include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-run-state.h" +#include "sysemu/watchdog.h" +#include "disas/disas.h" +#include "audio/audio.h" + bool tcg_allowed; bool xen_allowed; bool boot_strict; @@ -21,6 +27,8 @@ int smp_threads =3D 1; int icount_align_option; int boot_menu; =20 +#pragma weak arch_type + unsigned int max_cpus; const uint32_t arch_type; const char *mem_path; @@ -33,6 +41,11 @@ ram_addr_t ram_size; MachineState *current_machine; QemuUUID qemu_uuid; =20 +int singlestep; +const char *qemu_name; +int no_shutdown; +int autostart; + int runstate_is_running(void) { return 0; @@ -77,3 +90,82 @@ void x86_cpu_list(void) { } #endif + +void qemu_system_shutdown_request(ShutdownCause reason) +{ + qemu_debug_assert(0); +} + +void qemu_system_reset_request(ShutdownCause reason) +{ + qemu_debug_assert(0); +} + +void qemu_system_powerdown_request(void) +{ + qemu_debug_assert(0); +} + +void qemu_exit_preconfig_request(void) +{ + qemu_debug_assert(0); +} + +bool runstate_needs_reset(void) +{ + qemu_debug_assert(0); + + return FALSE; +} + +bool qemu_wakeup_suspend_enabled(void) +{ + qemu_debug_assert(0); + + return FALSE; +} + +void qemu_system_wakeup_request(WakeupReason reason, Error **errp) +{ + qemu_debug_assert(0); +} + +DisplayOptions *qmp_query_display_options(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +StatusInfo *qmp_query_status(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +void qmp_watchdog_set_action(WatchdogAction action, Error **errp) +{ + qemu_debug_assert(0); +} + +int select_watchdog_action(const char *p) +{ + qemu_debug_assert(0); + + return -1; +} + +void monitor_disas(Monitor *mon, CPUState *cpu, + target_ulong pc, int nb_insn, int is_physical) +{ + qemu_debug_assert(0); +} + +int wav_start_capture(AudioState *state, CaptureState *s, const char *path, + int freq, int bits, int nchannels) +{ + qemu_debug_assert(0); + + return -1; +} --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166633; cv=none; d=zohomail.com; s=zohoarc; b=TpkKgHxI8ljElUrg7ZQMH9A46JhGRtmXWq21HUxLylnqwUhKenzPtpEJxUj2EMfBweZIwTJdQL3X/lJs21E9b1k4tfV1R6n5c5f0uVILG96RaFI+XXUDJx5BiyLzglJWG5vq901bEh8F5dswBfOZPpfBOLU6AQ1LJijY92PVk64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166633; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V34vqiNMw97o1dTPzX27wWZMFaoDykDwdyaDjPR3ekE=; b=f8itPwA88RmuGQqL2WeYmioU54ZerHoEusgTCr9w/su367eir1to4YPYUPfZoOedmfy5vmlV7SFhNhFifa60WtjCZFtDPOSPdITU7629LqfgHzIj37L80Mu7ndKoBSyb4x+t/rl9XSBk2Y+1tCgvQGKAXK7GHwxRg0EB1NJ0Ah0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166633673946.738135291446; Mon, 6 Apr 2020 02:50:33 -0700 (PDT) Received: from localhost ([::1]:57430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOOm-0000Di-Bd for importer@patchew.org; Mon, 06 Apr 2020 05:50:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44510) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOH6-0002wq-TE for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOH5-0002Zb-5o for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:45722) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOH4-0002Yy-Ts for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:35 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369dSE4025474; Mon, 6 Apr 2020 09:42:29 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 306jvmwr73-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:28 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369bM7G056443; Mon, 6 Apr 2020 09:42:28 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 3073qcndad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:28 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369gQvt013893; Mon, 6 Apr 2020 09:42:27 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:26 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=V34vqiNMw97o1dTPzX27wWZMFaoDykDwdyaDjPR3ekE=; b=y6ldnnIAg+1sJaif4fvWln7q6dsx5pGfJLSddNi59G9LDonBi/7VXAkSRRootTtpySM0 RgbLroGQIZJbKF4tJ4GdoFpgEz2iC50QiBZaTNnmefQwpNZDSP+JrgeFLDVo0mYQh0tx 8XXAgb8xa9tL4JSDan9TWi5OoCKzDDmliZOyK0i/uw1oetrW6JZOYTv8Ad0Xaz4HPjVK fjIyEgNS1QyyoABcvkBYTyqVMSU5whpbSLrupBnGk4iiXHN6CYNg0VFFQyZ+nLT0tzqP Ugrj3BSLCJLPsW5JNGrx4xGrtcgtqyFBXnJrnqBVeoE3GYb3I8l2pQiRJcbiCb+bDgy+ tA== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 33/36] multi-process/mon: enable QMP module support in the remote process Date: Mon, 6 Apr 2020 02:41:23 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=1 mlxlogscore=999 mlxscore=0 bulkscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Build system changes to enable QMP module in the remote process Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- Makefile.objs | 10 ++++++++++ Makefile.target | 35 +++++++++++++++++++++++++++++++++-- block/Makefile.objs | 3 +++ block/monitor/Makefile.objs | 2 ++ hmp-commands.hx | 1 + hw/core/Makefile.objs | 1 + monitor/Makefile.objs | 4 ++++ monitor/misc.c | 8 ++++++++ qapi/Makefile.objs | 2 ++ qom/Makefile.objs | 1 + stubs/monitor.c | 1 + ui/Makefile.objs | 2 ++ 12 files changed, 68 insertions(+), 2 deletions(-) diff --git a/Makefile.objs b/Makefile.objs index ff3f06b146..cdb55b2f82 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -32,6 +32,7 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D migration/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D remote/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D accel/ remote-pci-obj-$(CONFIG_MPQEMU) +=3D util/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D monitor/ =20 remote-pci-obj-$(CONFIG_MPQEMU) +=3D cpus-common.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D dma-helpers.o @@ -45,6 +46,10 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D qemu-parse.o # remote-lsi-obj-y is code used to implement remote LSI device =20 remote-lsi-obj-$(CONFIG_MPQEMU) +=3D hw/ +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D ui/ +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D block/ + +#remote-lsi-obj-$(CONFIG_MPQEMU) +=3D device-hotplug.o =20 ####################################################################### # crypto-obj-y is code used by both qemu system emulation and qemu-img @@ -113,6 +118,11 @@ common-obj-y +=3D util/machine-notify.o =20 endif # CONFIG_SOFTMMU =20 +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qapi/ +remote-pci-obj-$(CONFIG_MPQEMU) +=3D blockdev-nbd.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D job-qmp.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D balloon.o + ####################################################################### # Target-independent parts used in system and user emulation common-obj-y +=3D cpus-common.o diff --git a/Makefile.target b/Makefile.target index adc76886f8..1e9e102df8 100644 --- a/Makefile.target +++ b/Makefile.target @@ -142,13 +142,32 @@ remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/= hax-stub.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/whpx-stub.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/vl-stub.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/net-stub.o -remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/monitor.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/replay.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/xen-mapcache.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/audio.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/monitor.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/migration.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/ui-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/gdbstub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/qapi-target.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D stubs/qapi-misc.o =20 remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D remote/memory.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D arch_init.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D monitor/misc.o + +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-introspect.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-commands-block-core.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-commands-block.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-commands-misc.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-commands.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-commands-machine-target= .o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-commands-misc-target.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-visit-machine-target.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-visit-misc-target.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-types-machine-target.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-types-misc-target.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D qapi/qapi-init-commands.o endif =20 ######################################################### @@ -204,6 +223,10 @@ endif generated-files-y +=3D hmp-commands.h hmp-commands-info.h generated-files-y +=3D config-devices.h =20 +ifdef CONFIG_MPQEMU +generated-files-y +=3D hmp-scsi-commands.h hmp-scsi-commands-info.h +endif + endif # CONFIG_SOFTMMU =20 dummy :=3D $(call unnest-vars,,obj-y) @@ -289,10 +312,18 @@ hmp-commands.h: $(SRC_PATH)/hmp-commands.hx $(SRC_PAT= H)/scripts/hxtool hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/= hxtool $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$(= TARGET_DIR)$@") =20 +ifdef CONFIG_MPQEMU +hmp-scsi-commands.h: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool + $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -tgt scsi < $< > $@) + +hmp-scsi-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scr= ipts/hxtool + $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -tgt scsi < $< > $@) +endif + clean: clean-target rm -f *.a *~ $(PROGS) rm -f $(shell find . -name '*.[od]') - rm -f hmp-commands.h gdbstub-xml.c + rm -f hmp-commands.h gdbstub-xml.c hmp-scsi-commands.h hmp-scsi-commands-= info.h rm -f trace/generated-helpers.c trace/generated-helpers.c-timestamp ifdef CONFIG_TRACE_SYSTEMTAP rm -f *.stp diff --git a/block/Makefile.objs b/block/Makefile.objs index 3e7513967c..734548d48f 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -76,3 +76,6 @@ parallels.o-cflags :=3D $(LIBXML2_CFLAGS) parallels.o-libs :=3D $(LIBXML2_LIBS) =20 remote-pci-obj-$(CONFIG_MPQEMU) +=3D stream.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qapi-sysemu.o + +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D monitor/ diff --git a/block/monitor/Makefile.objs b/block/monitor/Makefile.objs index 0a74f9a8b5..a0c898711f 100644 --- a/block/monitor/Makefile.objs +++ b/block/monitor/Makefile.objs @@ -1 +1,3 @@ common-obj-y +=3D block-hmp-cmds.o + +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D block-hmp-cmds.o diff --git a/hmp-commands.hx b/hmp-commands.hx index 1b60676d7c..54d01a055f 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -12,6 +12,7 @@ HXCOMM HXCOMM can be used for comments, discarded from bo= th rST and C. .params =3D "[cmd]", .help =3D "show the help", .cmd =3D hmp_do_help_cmd, + .targets =3D "scsi", .flags =3D "p", }, =20 diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index e3e80848c8..251b77bc4c 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -49,3 +49,4 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D numa.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D cpu.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D vmstate-if.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D resettable.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D machine-qmp-cmds.o diff --git a/monitor/Makefile.objs b/monitor/Makefile.objs index a8533c9dd7..b6949be297 100644 --- a/monitor/Makefile.objs +++ b/monitor/Makefile.objs @@ -4,3 +4,7 @@ common-obj-y +=3D qmp-cmds.o qmp-cmds-control.o common-obj-y +=3D hmp-cmds.o =20 storage-daemon-obj-y +=3D monitor.o qmp.o qmp-cmds-control.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D monitor.o qmp.o hmp.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qmp-cmds.o qmp-cmds-control.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D hmp-cmds.o diff --git a/monitor/misc.c b/monitor/misc.c index c0eee6f4ab..edda4cce17 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -1679,13 +1679,21 @@ int monitor_fd_param(Monitor *mon, const char *fdna= me, Error **errp) =20 /* Please update hmp-commands.hx when adding or changing commands */ static HMPCommand hmp_info_cmds[] =3D { +#if defined(SCSI_PROCESS) +#include "hmp-scsi-commands-info.h" +#else #include "hmp-commands-info.h" +#endif { NULL, NULL, }, }; =20 /* hmp_cmds and hmp_info_cmds would be sorted at runtime */ HMPCommand hmp_cmds[] =3D { +#if defined(SCSI_PROCESS) +#include "hmp-scsi-commands.h" +#else #include "hmp-commands.h" +#endif { NULL, NULL, }, }; =20 diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index 4673ab7490..f7433d6a73 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -36,3 +36,5 @@ QAPI_MODULES_STORAGE_DAEMON =3D block-core char common co= ntrol crypto QAPI_MODULES_STORAGE_DAEMON +=3D introspect job qom sockets pragma transac= tion =20 storage-daemon-obj-y +=3D $(QAPI_MODULES_STORAGE_DAEMON:%=3Dqapi-commands-= %.o) + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D $(QAPI_COMMON_MODULES:%=3Dqapi-comman= ds-%.o) diff --git a/qom/Makefile.objs b/qom/Makefile.objs index 7e9455db90..546f9fbde6 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -6,3 +6,4 @@ storage-daemon-obj-y +=3D qom-qmp-cmds.o =20 remote-pci-obj-$(CONFIG_MPQEMU) +=3D object.o qom-qobject.o container.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D object_interfaces.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qom-qmp-cmds.o qom-hmp-cmds.o diff --git a/stubs/monitor.c b/stubs/monitor.c index 959460834b..1f8fa301f5 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -36,6 +36,7 @@ #pragma weak monitor_printf #pragma weak monitor_cur_is_qmp #pragma weak qmp_device_list_properties +#pragma weak monitor_fdsets_cleanup =20 __thread Monitor *cur_mon; =20 diff --git a/ui/Makefile.objs b/ui/Makefile.objs index e6da6ff047..c3ac572d6b 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -68,3 +68,5 @@ console-gl.o-libs +=3D $(OPENGL_LIBS) egl-helpers.o-libs +=3D $(OPENGL_LIBS) egl-context.o-libs +=3D $(OPENGL_LIBS) egl-headless.o-libs +=3D $(OPENGL_LIBS) + +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D vnc-stubs.o --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586167530; cv=none; d=zohomail.com; s=zohoarc; b=ncZfVqduUmx3nvpuhFHw0bImlbSSf/TUkJZNCtuf+rKO6rebdKvJu/GtZzxbDUKGG60K0JjeEtECfKy0zhnz0nGAmxwAcq43B8G8eWCdJxkp4suApacdeG/1orGRZRXALyS8WiWpC+hG9PXUgbWlGLn3xCP6Oz/2kGzPZQG+rzU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586167530; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6Q59cXboZOXx0HdsTyg1XD4d3qx1PvHh6xmcCZ0i1ps=; b=B4QKex5MPL2Ja4zZf3nMd88hR6k6sixapgDheIiYc8qlsSlI10EyLlg8d4X0EztmOyAFnXM73Whac/7sm3aqhSnvH6q7u5HADhgE676lu9LF4fcnrM6VdV3a3t9YcYOb3Ya4gsI3gXUFgAj82PFdUBnWHn38FBoZmP2roZH0ny8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586167530784621.0229465115572; Mon, 6 Apr 2020 03:05:30 -0700 (PDT) Received: from localhost ([::1]:57841 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOdF-0000hw-G1 for importer@patchew.org; Mon, 06 Apr 2020 06:05:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45055) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOJB-00074m-HF for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOJA-0004F8-Br for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:45 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47900) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOJA-0004EA-2l for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:44:44 -0400 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 0369hfiK073043; Mon, 6 Apr 2020 09:44:37 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 306j6m5tnt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:44:37 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369gaJ2107224; Mon, 6 Apr 2020 09:42:37 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 3073spk6qy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:36 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0369gSZD032140; Mon, 6 Apr 2020 09:42:28 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:28 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=6Q59cXboZOXx0HdsTyg1XD4d3qx1PvHh6xmcCZ0i1ps=; b=pZ1BIXuEi24jQS2C7eqlHjdXwQ2oCBmpA/la6NCa/aooGyFbm7BwW4RfTKvdzyuvOP4B pf5YZBxtAkm1ZWWkLB/qhaK3UV6OxAPjAfaoq2QaJU9LTqRuBcITrxUqeMzCRDQaxmFq mbhbtsT6zYIVtoMDpEOI+4sAzGdtaZHEyNBpOid8Qx8TFYO6gyxyFN9ppvI0YAFgb3j1 0wdVwfD2XlENIhqy7Rig4VWw76qMm9jDmzfNLI/0EYDoZYaR+U873wOjS/PMuKH9OQ0i GmE4rMf+HhjwaUfuiaEBQZfqKTP+S1E6AEycDDoPUfL3zGShNCu78IPb6PSiSsxG1wAV vw== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 34/36] multi-process/mon: Initialize QMP module for remote processes Date: Mon, 6 Apr 2020 02:41:24 -0700 Message-Id: <4c834a354e84bc5863b43fc24111422d450b79fa.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 malwarescore=0 suspectscore=1 adultscore=0 bulkscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 priorityscore=1501 suspectscore=1 lowpriorityscore=0 malwarescore=0 impostorscore=0 mlxscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- remote/remote-main.c | 13 +++++++++++++ remote/remote-opts.c | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index 6e198de35f..57f31616e0 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -39,6 +39,9 @@ #include "remote/iohub.h" #include "remote-opts.h" #include "sysemu/reset.h" +#include "qemu-parse.h" +#include "monitor/monitor.h" +#include "chardev/char.h" =20 static void process_msg(GIOCondition cond, MPQemuLinkState *link, MPQemuChannel *chan); @@ -286,6 +289,8 @@ int main(int argc, char *argv[]) =20 module_call_init(MODULE_INIT_QOM); =20 + monitor_init_globals(); + bdrv_init_with_whitelist(); =20 if (qemu_init_main_loop(&err)) { @@ -303,6 +308,8 @@ int main(int argc, char *argv[]) =20 qemu_add_opts(&qemu_device_opts); qemu_add_opts(&qemu_drive_opts); + qemu_add_opts(&qemu_chardev_opts); + qemu_add_opts(&qemu_mon_opts); qemu_add_drive_opts(&qemu_legacy_drive_opts); qemu_add_drive_opts(&qemu_common_drive_opts); qemu_add_drive_opts(&qemu_drive_opts); @@ -322,6 +329,12 @@ int main(int argc, char *argv[]) =20 parse_cmdline(argc - 2, argv + 2, NULL); =20 + qemu_opts_foreach(qemu_find_opts("chardev"), + chardev_init_func, NULL, &error_fatal); + + qemu_opts_foreach(qemu_find_opts("mon"), + mon_init_func, NULL, &error_fatal); + mpqemu_init_channel(mpqemu_link, &mpqemu_link->com, fd); =20 mpqemu_link_set_callback(mpqemu_link, process_msg); diff --git a/remote/remote-opts.c b/remote/remote-opts.c index f077221c71..ac3a9be6b8 100644 --- a/remote/remote-opts.c +++ b/remote/remote-opts.c @@ -15,6 +15,7 @@ #include "qemu-options.h" #include "qemu-parse.h" #include "remote-opts.h" +#include "monitor/monitor.h" =20 /* * In remote process, we parse only subset of options. The code @@ -64,6 +65,16 @@ void parse_cmdline(int argc, char **argv, char **envp) exit(1); } break; + case QEMU_OPTION_qmp: + monitor_parse(optarg, "control", false); + break; + case QEMU_OPTION_monitor: + if (!strncmp(optarg, "stdio", 5)) { + warn_report("STDIO not supported in remote process"); + } else if (strncmp(optarg, "none", 4)) { + monitor_parse(optarg, "readline", false); + } + break; default: break; } --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166802; cv=none; d=zohomail.com; s=zohoarc; b=dlAyN25N689NtkGQmT2sgJfuGsdDUU6XJcS+GQHqeyz19XQHuUyoXr1/zwVU3rG4gQpxC/mKKOBlDRYA+4GuZU3LFJxEFGefrEsfSeZcROUfRq2peX5jf+vZRuSogOgqGOClhI891WBZmisfdOCSH2CsexJERu7qfetH2auZLAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166802; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RQXcq9eBEi0i4j9+fGB9tNKSkYIyD8rqWv0FMKs9Mi0=; b=YMzH3Mdtww5yQE2Fi5Ckfhiwr1v+C1txzTV2Knowbdn3qctWOK0qxUX1CV6PXF5ogBbU9cr/GEGldkGp+i5RxLSS/h6HyUn2LH5oiqhmMWcOCe3lEVfGxls6kGHjVqNX3iwna3rKC9cVvoGisTQZXfoXsym7mYce2rdsD/qx0nY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166802949523.0433769043634; Mon, 6 Apr 2020 02:53:22 -0700 (PDT) Received: from localhost ([::1]:57528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLORV-0005lt-GZ for importer@patchew.org; Mon, 06 Apr 2020 05:53:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44762) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOHa-0004DF-86 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOHU-0002vj-Ec for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:06 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOHT-0002tk-W0 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:43:00 -0400 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 0369dobV089398; Mon, 6 Apr 2020 09:42:32 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 306hnqwu08-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:32 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0369bLlY056283; Mon, 6 Apr 2020 09:42:32 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 3073qcndbs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:31 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369gUZF030870; Mon, 6 Apr 2020 09:42:30 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:29 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=RQXcq9eBEi0i4j9+fGB9tNKSkYIyD8rqWv0FMKs9Mi0=; b=KRpMP119a6tB0ByDPHcnhVMEv+7r4XbFgLDahBC5UMZ9N/smrt4UGzEI/dycsW5NIGlM BTPdrYbbCW0JAj2IIqnKMiV+DTgY8JOrzvwkAQC9zS8r6eZhoOcq+y9Ugrclu5BIfzdI DDjDAAZLfeGdb8xSJEe2gDAPQvPtaqdGpvV12M76EikqM+VQ1czNzV8NLa+EqqPsF5Fh 2fPPiU2kndpv8xg9cm6zyU390xcRfyI42zmXgfGcPGxj8UxZi1UwrKc0jXXprLW6HEej AHU9SgD8A+ozojv6UFiAUiiQrxLqsD+pKKQZKLTIS74tzLok38gEPcUQpV82AKnGBijv bw== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 35/36] multi-process: add the concept description to docs/devel/qemu-multiprocess Date: Mon, 6 Apr 2020 02:41:25 -0700 Message-Id: <6710cfbdfc8e01326e9d8b134c7187f76b2e749b.1586165556.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=3 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=3 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: John G Johnson Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman --- MAINTAINERS | 1 + docs/devel/index.rst | 1 + docs/devel/multi-process.rst | 1102 ++++++++++++++++++++++++++++++++++ 3 files changed, 1104 insertions(+) create mode 100644 docs/devel/multi-process.rst diff --git a/MAINTAINERS b/MAINTAINERS index eb5ce6ea73..668c269eb6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2838,6 +2838,7 @@ F: include/remote/iohub.h F: remote/iohub.c F: remote/remote-opts.h F: remote/remote-opts.c +F: docs/devel/multi-process.rst =20 Build and test automation ------------------------- diff --git a/docs/devel/index.rst b/docs/devel/index.rst index b734ba4655..f80e5cddf3 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -26,3 +26,4 @@ Contents: bitops reset s390-dasd-ipl + multi-process diff --git a/docs/devel/multi-process.rst b/docs/devel/multi-process.rst new file mode 100644 index 0000000000..5a991e6b40 --- /dev/null +++ b/docs/devel/multi-process.rst @@ -0,0 +1,1102 @@ +Multi-process QEMU +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +QEMU is often used as the hypervisor for virtual machines running in the +Oracle cloud. Since one of the advantages of cloud computing is the +ability to run many VMs from different tenants in the same cloud +infrastructure, a guest that compromised its hypervisor could +potentially use the hypervisor's access privileges to access data it is +not authorized for. + +QEMU can be susceptible to security attacks because it is a large, +monolithic program that provides many features to the VMs it services. +Many of these features can be configured out of QEMU, but even a reduced +configuration QEMU has a large amount of code a guest can potentially +attack. Disaggregating QEMU reduces the attack surface by aiding to +limit each component in the system to only access the resources that +it needs to perform its job. + +QEMU services +------------- + +QEMU can be broadly described as providing three main services. One is a +VM control point, where VMs can be created, migrated, re-configured, and +destroyed. A second is to emulate the CPU instructions within the VM, +often accelerated by HW virtualization features such as Intel's VT +extensions. Finally, it provides IO services to the VM by emulating HW +IO devices, such as disk and network devices. + +A multi-process QEMU +~~~~~~~~~~~~~~~~~~~~ + +A multi-process QEMU involves separating QEMU services into separate +host processes. Each of these processes can be given only the privileges +it needs to provide its service, e.g., a disk service could be given +access only the the disk images it provides, and not be allowed to +access other files, or any network devices. An attacker who compromised +this service would not be able to use this exploit to access files or +devices beyond what the disk service was given access to. + +A QEMU control process would remain, but in multi-process mode, but will +have no direct interfaces to the VM. During VM execution, it would still +provide the user interface to hot-plug devices or live migrate the VM. + +A first step in creating a multi-process QEMU is to separate IO services +from the main QEMU program, which would continue to provide CPU +emulation. i.e., the control process would also be the CPU emulation +process. In a later phase, CPU emulation could be separated from the +control process. + +Disaggregating IO services +-------------------------- + +Disaggregating IO services is a good place to begin for a couple of reason= s. +One is the sheer number of IO devices QEMU can emulate provides a large +surface of interfaces which could potentially be exploited, and, indeed, +have been a source of exploits in the past. +Another is the modular nature of QEMU device emulation code provides +interface points where the QEMU functions that perform device emulation +can be separated from the QEMU functions that manage the emulation of +guest CPU instructions. + +QEMU device emulation +~~~~~~~~~~~~~~~~~~~~~ + +QEMU uses a object oriented SW architecture for device emulation code. +Configured objects are all compiled into the QEMU binary, then objects +are instantiated by name when used by the guest VM. For example, the +code to emulate a device named "foo" is always present in QEMU, but its +instantiation code is only run when the device is included in the target +VM. (e.g., via the QEMU command line as *-device foo*) + +The object model is hierarchical, so device emulation code names its +parent object (such as "pci-device" for a PCI device) and QEMU will +instantiate a parent object before calling the device's instantiation +code. + +Current separation models +~~~~~~~~~~~~~~~~~~~~~~~~~ + +In order to separate the device emulation code from the CPU emulation +code, the device object code must run in a different process. There are +a couple of existing QEMU features that can run emulation code +separately from the main QEMU process. These are examined below. + +vhost user model +^^^^^^^^^^^^^^^^ + +Virtio guest device drivers can be connected to vhost user applications +in order to perform their IO operations. This model uses special virtio +device drivers in the guest and vhost user device objects in QEMU, but +once the QEMU vhost user code has configured the vhost user application, +mission-mode IO is performed by the application. The vhost user +application is a daemon process that can be contacted via a known UNIX +domain socket. + +vhost socket +'''''''''''' + +As mentioned above, one of the tasks of the vhost device object within +QEMU is to contact the vhost application and send it configuration +information about this device instance. As part of the configuration +process, the application can also be sent other file descriptors over +the socket, which then can be used by the vhost user application in +various ways, some of which are described below. + +vhost MMIO store acceleration +''''''''''''''''''''''''''''' + +VMs are often run using HW virtualization features via the KVM kernel +driver. This driver allows QEMU to accelerate the emulation of guest CPU +instructions by running the guest in a virtual HW mode. When the guest +executes instructions that cannot be executed by virtual HW mode, +execution returns to the KVM driver so it can inform QEMU to emulate the +instructions in SW. + +One of the events that can cause a return to QEMU is when a guest device +driver accesses an IO location. QEMU then dispatches the memory +operation to the corresponding QEMU device object. In the case of a +vhost user device, the memory operation would need to be sent over a +socket to the vhost application. This path is accelerated by the QEMU +virtio code by setting up an eventfd file descriptor that the vhost +application can directly receive MMIO store notifications from the KVM +driver, instead of needing them to be sent to the QEMU process first. + +vhost interrupt acceleration +'''''''''''''''''''''''''''' + +Another optimization used by the vhost application is the ability to +directly inject interrupts into the VM via the KVM driver, again, +bypassing the need to send the interrupt back to the QEMU process first. +The QEMU virtio setup code configures the KVM driver with an eventfd +that triggers the device interrupt in the guest when the eventfd is +written. This irqfd file descriptor is then passed to the vhost user +application program. + +vhost access to guest memory +'''''''''''''''''''''''''''' + +The vhost application is also allowed to directly access guest memory, +instead of needing to send the data as messages to QEMU. This is also +done with file descriptors sent to the vhost user application by QEMU. +These descriptors can be passed to ``mmap()`` by the vhost application +to map the guest address space into the vhost application. + +IOMMUs introduce another level of complexity, since the address given to +the guest virtio device to DMA to or from is not a guest physical +address. This case is handled by having vhost code within QEMU register +as a listener for IOMMU mapping changes. The vhost application maintains +a cache of IOMMMU translations: sending translation requests back to +QEMU on cache misses, and in turn receiving flush requests from QEMU +when mappings are purged. + +applicability to device separation +'''''''''''''''''''''''''''''''''' + +Much of the vhost model can be re-used by separated device emulation. In +particular, the ideas of using a socket between QEMU and the device +emulation application, using a file descriptor to inject interrupts into +the VM via KVM, and allowing the application to ``mmap()`` the guest +should be re used. + +There are, however, some notable differences between how a vhost +application works and the needs of separated device emulation. The most +basic is that vhost uses custom virtio device drivers which always +trigger IO with MMIO stores. A separated device emulation model must +work with existing IO device models and guest device drivers. MMIO loads +break vhost store acceleration since they are synchronous - guest +progress cannot continue until the load has been emulated. By contrast, +stores are asynchronous, the guest can continue after the store event +has been sent to the vhost application. + +Another difference is that in the vhost user model, a single daemon can +support multiple QEMU instances. This is contrary to the security regime +desired, in which the emulation application should only be allowed to +access the files or devices the VM it's running on behalf of can access. +#### qemu-io model + +Qemu-io is a test harness used to test changes to the QEMU block backend +object code. (e.g., the code that implements disk images for disk driver +emulation) Qemu-io is not a device emulation application per se, but it +does compile the QEMU block objects into a separate binary from the main +QEMU one. This could be useful for disk device emulation, since its +emulation applications will need to include the QEMU block objects. + +New separation model based on proxy objects +------------------------------------------- + +A different model based on proxy objects in the QEMU program +communicating with remote emulation programs could provide separation +while minimizing the changes needed to the device emulation code. The +rest of this section is a discussion of how a proxy object model would +work. + +Remote emulation processes +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The remote emulation process will run the QEMU object hierarchy without +modification. The device emulation objects will be also be based on the +QEMU code, because for anything but the simplest device, it would not be +a tractable to re-implement both the object model and the many device +backends that QEMU has. + +The processes will communicate with the QEMU process over UNIX domain +sockets. The processes can be executed either as standalone processes, +or be executed by QEMU. In both cases, the host backends the emulation +processes will provide are specified on its command line, as they would +be for QEMU. For example: + +:: + + disk-proc -blockdev driver=3Dfile,node-name=3Dfile0,filename=3Ddisk-fi= le0 \ + -blockdev driver=3Dqcow2,node-name=3Ddrive0,file=3Dfile0 + +would indicate process *disk-proc* uses a qcow2 emulated disk named +*file0* as its backend. + +Emulation processes may emulate more than one guest controller. A common +configuration might be to put all controllers of the same device class +(e.g., disk, network, etc.) in a single process, so that all backends of +the same type can be managed by a single QMP monitor. + +communication with QEMU +^^^^^^^^^^^^^^^^^^^^^^^ + +Remote emulation processes will recognize a *-socket* argument that +specifies the path of a UNIX domain socket used to communicate with the +QEMU process. If no *-socket* argument is present, the process will use +file descriptor 0 to communicate with QEMU. For example, + +:: + + disk-proc -socket /tmp/disk0-sock + +will communicate with QEMU using the socket path */tmp/disk0-sock*. + +remote process QMP monitor +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Remote emulation processes can be monitored via QMP, similar to QEMU +itself. The QMP monitor socket is specified the same as for a QEMU +process: + +:: + + disk-proc -qmp unix:/tmp/disk-mon,server + +can be monitored over the UNIX socket path */tmp/disk-mon*. + +QEMU command line +~~~~~~~~~~~~~~~~~ + +The QEMU command line options will need to be modified to indicate which +items are emulated by a separate program, and which remain emulated by +QEMU itself. + +identifying remote emulation processes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Remote emulation processes will be identified to QEMU using a *-remote* +command line option. This option can either specify a command that QEMU +will execute, or can specify a UNIX domain socket that QEMU can use to +connect to an existing process. Both forms require a "id" option that +identifies the process to later *-device* options. The process version +is: + +:: + + -remote id=3Ddisk-proc,rid=3D0,exec=3D"disc-proc",command=3D"" + +And the socket version is: + +:: + + -remote id=3Ddisk-proc,rid=3D0,socket=3D"/tmp/disk0-sock" + +In the latter case, the remote process must be given the same socket on +its command line when it is executed: + +:: + + disk-proc -socket /tmp/disk0-sock + +identifying devices emulated remotely +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Devices that are to be emulated in a separate process will identify +the remote process with a "rid" option on their *-device* command +line specification. e.g., an LSI SCSI controller and disk can be +specified as: + +:: + + -device lsi53c895a,id=3Dscsi0 + -device scsi-hd,drive=3Ddrive0,bus=3Dscsi0.0,scsi-id=3D0 + +If these devices are emulated by remote process "disk-proc," as +described in the previous section, the QEMU command line would be: + +:: + + -device lsi53c895a,id=3Dscsi0,rid=3D0 + -device scsi-hd,drive=3Ddrive0,bus=3Dscsi0.0,scsi-id=3D0,rid=3D0 + +Some devices are implicitly created by the machine object. e.g., the q35 +machine object will create its PCI bus, and attach an ich9-ahci IDE +controller to it. In this case, options will need to be added to the +*-machine* command line. e.g., + +:: + + -machine pc-q35,ide-remote=3Ddisk-proc + +will use the remote process with an "id" of "disk-proc" to emulate the +IDE controller and its disks. + +The disks themselves still need to be specified with *-remote* option, +as in the example above. e.g., + +:: + + -device ide-hd,drive=3Ddrive0,bus=3Dide.0,unit=3D0,remote=3Ddisk-proc + +QEMU management of remote processes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Each *-remote* instance on the QEMU command line will create a remote +process proxy instance in QEMU. They will be held on a *QList* that can +be searched for by its "id" property. The remote process proxy will also +establish a communication channel between QEMU and the remote process. +This can be done in one of two methods: direction execution of the +process by QEMU with ``fork()`` and ``exec()`` system calls, or by +connecting to an existing process. + +direct execution +^^^^^^^^^^^^^^^^ + +When the remote process is directly executed, the remote process proxy +will setup a communication channel between itself and the emulation +process. This channel will be created using ``socketpair()`` and the +remote process side of the pair will be given to the process as file +descriptor 0. + +connecting to an existing process +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Some environments wish to deny QEMU the ability to execute ``fork()`` +and ``exec()`` In these case, emulation processes will be started before +QEMU, and a UNIX domain socket will be given to each emulation process +to communicate with QEMU over. After communication is established, the +socket will be unlinked from the file system space by the QEMU process. + +communication with emulation process +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +primary socket +'''''''''''''' + +Whether the process was executed by QEMU or externally, there will be a +primary socket for communication between QEMU and the remote process. +This channel will handle configuration commands from QEMU to the +process, either from the QEMU command line, or from QMP commands that +affect the devices being emulated by the process. This channel will only +allow one message to be pending at a time; if additional messages +arrive, they must wait for previous ones to be acknowledged from the +remote side. + +secondary sockets +''''''''''''''''' + +The primary socket can pass the file descriptors of secondary sockets +for operations that occur in parallel with commands on the primary +channel. These include MMIO operations generated by the guest, interrupt +notifications generated by the devices being emulated, or *vmstate* for +live migration. These secondary sockets will be created at the behest of +the device proxies that require them. A disk device proxy wouldn't need +any secondary sockets, but a disk controller device proxy may need both +an MMIO socket and an interrupt socket. + +emulation process attached via QMP command +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The command "device-add" QMP command facilitates device hot-plug that is +tp. This command's arguments will be the same as the *-remote* +command line when it's used to attach to a remote process. i.e., it will +need an "id" argument so that hot-plugged devices can later find it, and +a "socket" argument to identify the UNIX domain socket that will be used +to communicate with QEMU. + +QEMU device proxy objects +~~~~~~~~~~~~~~~~~~~~~~~~~ + +QEMU has an object model based on sub-classes inherited from the +"object" super-class. The sub-classes that are of interest here are the +"device" and "bus" sub-classes whose child sub-classes make up the +device tree of a QEMU emulated system. + +The proxy object model will use device proxy objects to replace the +device emulation code within the QEMU process. These objects will live +in the same place in the object and bus hierarchies as the objects they +replace. i.e., the proxy object for an LSI SCSI controller will be a +sub-class of the "pci-device" class, and will have the same PCI bus +parent and the same SCSI bus child objects as the LSI controller object +it replaces. + +After the QEMU command line has been parsed, the remote devices will be +instantiated in the same manner as local devices are. (i.e., +``qdev_device_add()``). In order to distinguish them from regular +*-device* device objects, their class name will be the name of the class +it replaces, with "-proxy" appended. e.g., the "lsi53c895a" proxy class +will be "lsi53c895a-proxy." + +device JSON description +^^^^^^^^^^^^^^^^^^^^^^^ + +The remote process needs a JSON representation of the command line +options used to create the object. This JSON representation is used to +create the corresponding object in the emulation process. e.g., for an +LSI SCSI controller invoked as: + +:: + + -device lsi53c895a,id=3Dscsi0,remote=3Dlsi-scsi + +the proxy object would create a + +:: + + { "driver" : "lsi53c895a", "id" : "scsi0" } + +JSON description. The "driver" option is assigned to the device name +when the command line is parsed, so the "-proxy" appended by the command +line parsing code is removed. The "remote" option isn't needed in the +JSON description since it only applies to the proxy object in the QEMU +process. + +device object whitelist +^^^^^^^^^^^^^^^^^^^^^^^ + +Some device objects may not need a proxy. These are devices with no +direct guest interfaces. (e.g., no MMIO, PIO, or interrupts). There will +be a whitelist of such devices, and any devices on this list will not be +instantiated in QEMU. Their JSON representation will still be sent to +the remote process, so the object can be created there. + +object initialization +^^^^^^^^^^^^^^^^^^^^^ + +QEMU object initialization occurs in two phases. The first +initialization happens once per object class. (i.e., there can be many +SCSI disks in an emulated system, but the "scsi-hd" class has its +``class_init()`` function called only once) The second phase happens +when each object's ``instance_init()`` function is called to initialize +each instance of the object. + +All device objects are sub-classes of the "device" class, so they also +have a ``realize()`` function that is called after ``instance_init()`` +is called and after the object's static properties have been +initialized. Many device objects don't even provide an instance\_init() +function, and do all their per-instance work in ``realize()``. + +class\_init +''''''''''' + +The ``class_init()`` method of a proxy object will, in general behave +similarly to the object it replaces, including setting any static +properties and methods needed by the proxy. + +instance\_init / realize +'''''''''''''''''''''''' + +The ``instance_init()`` and ``realize()`` functions would only need to +perform tasks related to being a proxy, such are registering its own +MMIO handlers, or creating a child bus that other proxy devices can be +attached to later. + +Other tasks will are device-specific. For example, PCI device objects +will initialize the PCI config space in order to make a valid PCI device +tree within the QEMU process. + +address space registration +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Most devices are driven by guest device driver accesses to IO addresses +or ports. The QEMU device emulation code uses QEMU's memory region +function calls (such as ``memory_region_init_io()``) to add callback +functions that QEMU will invoke when the guest accesses the device's +areas of the IO address space. When a guest driver does access the +device, the VM will exit HW virtualization mode and return to QEMU, +which will then lookup and execute the corresponding callback function. + +A proxy object would need to mirror the memory region calls the actual +device emulator would perform in its initialization code, but with its +own callbacks. When invoked by QEMU as a result of a guest IO operation, +they will forward the operation to the device emulation process. + +PCI config space +^^^^^^^^^^^^^^^^ + +PCI devices also have a configuration space that can be accessed by the +guest driver. Guest accesses to this space is not handled by the device +emulation object, but by its PCI parent object. Much of this space is +read-only, but certain registers (especially BAR and MSI-related ones) +need to be propagated to the emulation process. + +PCI parent proxy +'''''''''''''''' + +One way to propagate guest PCI config accesses is to create a +"pci-device-proxy" class that can serve as the parent of a PCI device +proxy object. This class's parent would be "pci-device" and it would +override the PCI parent's ``config_read()`` and ``config_write()`` +methods with ones that forward these operations to the emulation +program. + +interrupt receipt +^^^^^^^^^^^^^^^^^ + +A proxy for a device that generates interrupts will need to create a +socket to receive interrupt indications from the emulation process. An +incoming interrupt indication would then be sent up to its bus parent to +be injected into the guest. For example, a PCI device object may use +``pci_set_irq()``. + +live migration +^^^^^^^^^^^^^^ + +The proxy will register to save and restore any *vmstate* it needs over +a live migration event. The device proxy does not need to manage the +remote device's *vmstate*; that will be handled by the remote process +proxy (see below). + +QEMU remote device operation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Generic device operations, such as DMA, will be performed by the remote +process proxy by sending messages to the remote process. + +DMA operations +^^^^^^^^^^^^^^ + +DMA operations would be handled much like vhost applications do. One of +the initial messages sent to the emulation process is a guest memory +table. Each entry in this table consists of a file descriptor and size +that the emulation process can ``mmap()`` to directly access guest +memory, similar to ``vhost_user_set_mem_table()``. Note guest memory +must be backed by file descriptors, such as when QEMU is given the +*-mem-path* command line option. + +IOMMU operations +^^^^^^^^^^^^^^^^ + +When the emulated system includes an IOMMU, the remote process proxy in +QEMU will need to create a socket for IOMMU requests from the emulation +process. It will handle those requests with an +``address_space_get_iotlb_entry()`` call. In order to handle IOMMU +unmaps, the remote process proxy will also register as a listener on the +device's DMA address space. When an IOMMU memory region is created +within the DMA address space, an IOMMU notifier for unmaps will be added +to the memory region that will forward unmaps to the emulation process +over the IOMMU socket. + +device hot-plug via QMP +^^^^^^^^^^^^^^^^^^^^^^^ + +An QMP "device\_add" command can add a device emulated by a remote +process. It will also have "rid" option to the command, just as the +*-device* command line option does. The remote process may either be one +started at QEMU startup, or be one added by the "add-process" QMP +command described above. In either case, the remote process proxy will +forward the new device's JSON description to the corresponding emulation +process. + +live migration +^^^^^^^^^^^^^^ + +The remote process proxy will also register for live migration +notifications with ``vmstate_register()``. When called to save state, +the proxy will send the remote process a secondary socket file +descriptor to save the remote process's device *vmstate* over. The +incoming byte stream length and data will be saved as the proxy's +*vmstate*. When the proxy is resumed on its new host, this *vmstate* +will be extracted, and a secondary socket file descriptor will be sent +to the new remote process through which it receives the *vmstate* in +order to restore the devices there. + +device emulation in remote process +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The parts of QEMU that the emulation program will need include the +object model; the memory emulation objects; the device emulation objects +of the targeted device, and any dependent devices; and, the device's +backends. It will also need code to setup the machine environment, +handle requests from the QEMU process, and route machine-level requests +(such as interrupts or IOMMU mappings) back to the QEMU process. + +initialization +^^^^^^^^^^^^^^ + +The process initialization sequence will follow the same sequence +followed by QEMU. It will first initialize the backend objects, then +device emulation objects. The JSON descriptions sent by the QEMU process +will drive which objects need to be created. + +- address spaces + +Before the device objects are created, the initial address spaces and +memory regions must be configured with ``memory_map_init()``. This +creates a RAM memory region object (*system\_memory*) and an IO memory +region object (*system\_io*). + +- RAM + +RAM memory region creation will follow how ``pc_memory_init()`` creates +them, but must use ``memory_region_init_ram_from_fd()`` instead of +``memory_region_allocate_system_memory()``. The file descriptors needed +will be supplied by the guest memory table from above. Those RAM regions +would then be added to the *system\_memory* memory region with +``memory_region_add_subregion()``. + +- PCI + +IO initialization will be driven by the JSON descriptions sent from the +QEMU process. For a PCI device, a PCI bus will need to be created with +``pci_root_bus_new()``, and a PCI memory region will need to be created +and added to the *system\_memory* memory region with +``memory_region_add_subregion_overlap()``. The overlap version is +required for architectures where PCI memory overlaps with RAM memory. + +MMIO handling +^^^^^^^^^^^^^ + +The device emulation objects will use ``memory_region_init_io()`` to +install their MMIO handlers, and ``pci_register_bar()`` to associate +those handlers with a PCI BAR, as they do within QEMU currently. + +In order to use ``address_space_rw()`` in the emulation process to +handle MMIO requests from QEMU, the PCI physical addresses must be the +same in the QEMU process and the device emulation process. In order to +accomplish that, guest BAR programming must also be forwarded from QEMU +to the emulation process. + +interrupt injection +^^^^^^^^^^^^^^^^^^^ + +When device emulation wants to inject an interrupt into the VM, the +request climbs the device's bus object hierarchy until the point where a +bus object knows how to signal the interrupt to the guest. The details +depend on the type of interrupt being raised. + +- PCI pin interrupts + +On x86 systems, there is an emulated IOAPIC object attached to the root +PCI bus object, and the root PCI object forwards interrupt requests to +it. The IOAPIC object, in turn, calls the KVM driver to inject the +corresponding interrupt into the VM. The simplest way to handle this in +an emulation process would be to setup the root PCI bus driver (via +``pci_bus_irqs()``) to send a interrupt request back to the QEMU +process, and have the device proxy object reflect it up the PCI tree +there. + +- PCI MSI/X interrupts + +PCI MSI/X interrupts are implemented in HW as DMA writes to a +CPU-specific PCI address. In QEMU on x86, a KVM APIC object receives +these DMA writes, then calls into the KVM driver to inject the interrupt +into the VM. A simple emulation process implementation would be to send +the MSI DMA address from QEMU as a message at initialization, then +install an address space handler at that address which forwards the MSI +message back to QEMU. + +DMA operations +^^^^^^^^^^^^^^ + +When a emulation object wants to DMA into or out of guest memory, it +first must use dma\_memory\_map() to convert the DMA address to a local +virtual address. The emulation process memory region objects setup above +will be used to translate the DMA address to a local virtual address the +device emulation code can access. + +IOMMU +^^^^^ + +When an IOMMU is in use in QEMU, DMA translation uses IOMMU memory +regions to translate the DMA address to a guest physical address before +that physical address can be translated to a local virtual address. The +emulation process will need similar functionality. + +- IOTLB cache + +The emulation process will maintain a cache of recent IOMMU translations +(the IOTLB). When the translate() callback of an IOMMU memory region is +invoked, the IOTLB cache will be searched for an entry that will map the +DMA address to a guest PA. On a cache miss, a message will be sent back +to QEMU requesting the corresponding translation entry, which be both be +used to return a guest address and be added to the cache. + +- IOTLB purge + +The IOMMU emulation will also need to act on unmap requests from QEMU. +These happen when the guest IOMMU driver purges an entry from the +guest's translation table. + +live migration +^^^^^^^^^^^^^^ + +When a remote process receives a live migration indication from QEMU, it +will set up a channel using the received file descriptor with +``qio_channel_socket_new_fd()``. This channel will be used to create a +*QEMUfile* that can be passed to ``qemu_save_device_state()`` to send +the process's device state back to QEMU. This method will be reversed on +restore - the channel will be passed to ``qemu_loadvm_state()`` to +restore the device state. + +Accelerating device emulation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The messages that are required to be sent between QEMU and the emulation +process can add considerable latency to IO operations. The optimizations +described below attempt to ameliorate this effect by allowing the +emulation process to communicate directly with the kernel KVM driver. +The KVM file descriptors created would be passed to the emulation process +via initialization messages, much like the guest memory table is done. +#### MMIO acceleration + +Vhost user applications can receive guest virtio driver stores directly +from KVM. The issue with the eventfd mechanism used by vhost user is +that it does not pass any data with the event indication, so it cannot +handle guest loads or guest stores that carry store data. This concept +could, however, be expanded to cover more cases. + +The expanded idea would require a new type of KVM device: +*KVM\_DEV\_TYPE\_USER*. This device has two file descriptors: a master +descriptor that QEMU can use for configuration, and a slave descriptor +that the emulation process can use to receive MMIO notifications. QEMU +would create both descriptors using the KVM driver, and pass the slave +descriptor to the emulation process via an initialization message. + +data structures +^^^^^^^^^^^^^^^ + +- guest physical range + +The guest physical range structure describes the address range that a +device will respond to. It includes the base and length of the range, as +well as which bus the range resides on (e.g., on an x86machine, it can +specify whether the range refers to memory or IO addresses). + +A device can have multiple physical address ranges it responds to (e.g., +a PCI device can have multiple BARs), so the structure will also include +an enumerated identifier to specify which of the device's ranges is +being referred to. + ++--------+----------------------------+ +| Name | Description | ++=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| addr | range base address | ++--------+----------------------------+ +| len | range length | ++--------+----------------------------+ +| bus | addr type (memory or IO) | ++--------+----------------------------+ +| id | range ID (e.g., PCI BAR) | ++--------+----------------------------+ + +- MMIO request structure + +This structure describes an MMIO operation. It includes which guest +physical range the MMIO was within, the offset within that range, the +MMIO type (e.g., load or store), and its length and data. It also +includes a sequence number that can be used to reply to the MMIO, and +the CPU that issued the MMIO. + ++----------+------------------------+ +| Name | Description | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| rid | range MMIO is within | ++----------+------------------------+ +| offset | offset withing *rid* | ++----------+------------------------+ +| type | e.g., load or store | ++----------+------------------------+ +| len | MMIO length | ++----------+------------------------+ +| data | store data | ++----------+------------------------+ +| seq | sequence ID | ++----------+------------------------+ + +- MMIO request queues + +MMIO request queues are FIFO arrays of MMIO request structures. There +are two queues: pending queue is for MMIOs that haven't been read by the +emulation program, and the sent queue is for MMIOs that haven't been +acknowledged. The main use of the second queue is to validate MMIO +replies from the emulation program. + +- scoreboard + +Each CPU in the VM is emulated in QEMU by a separate thread, so multiple +MMIOs may be waiting to be consumed by an emulation program and multiple +threads may be waiting for MMIO replies. The scoreboard would contain a +wait queue and sequence number for the per-CPU threads, allowing them to +be individually woken when the MMIO reply is received from the emulation +program. It also tracks the number of posted MMIO stores to the device +that haven't been replied to, in order to satisfy the PCI constraint +that a load to a device will not complete until all previous stores to +that device have been completed. + +- device shadow memory + +Some MMIO loads do not have device side-effects. These MMIOs can be +completed without sending a MMIO request to the emulation program if the +emulation program shares a shadow image of the device's memory image +with the KVM driver. + +The emulation program will ask the KVM driver to allocate memory for the +shadow image, and will then use ``mmap()`` to directly access it. The +emulation program can control KVM access to the shadow image by sending +KVM an access map telling it which areas of the image have no +side-effects (and can be completed immediately), and which require a +MMIO request to the emulation program. The access map can also inform +the KVM drive which size accesses are allowed to the image. + +master descriptor +^^^^^^^^^^^^^^^^^ + +The master descriptor is used by QEMU to configure the new KVM device. +The descriptor would be returned by the KVM driver when QEMU issues a +*KVM\_CREATE\_DEVICE* ``ioctl()`` with a *KVM\_DEV\_TYPE\_USER* type. + +KVM\_DEV\_TYPE\_USER device ops + + +The *KVM\_DEV\_TYPE\_USER* operations vector will be registered by a +``kvm_register_device_ops()`` call when the KVM system in initialized by +``kvm_init()``. These device ops are called by the KVM driver when QEMU +executes certain ``ioctl()`` operations on its KVM file descriptor. They +include: + +- create + +This routine is called when QEMU issues a *KVM\_CREATE\_DEVICE* +``ioctl()`` on its per-VM file descriptor. It will allocate and +initialize a KVM user device specific data structure, and assign the +*kvm\_device* private field to it. + +- ioctl + +This routine is invoked when QEMU issues an ``ioctl()`` on the master +descriptor. The ``ioctl()`` commands supported are defined by the KVM +device type. *KVM\_DEV\_TYPE\_USER* ones will need several commands: + +*KVM\_DEV\_USER\_SLAVE\_FD* creates the slave file descriptor thatwill +be passed to the device emulation program. Only one slave can be created +by each master descriptor. The file operations performed by this +descriptor are described below. + +The *KVM\_DEV\_USER\_PA\_RANGE* command configures a guest physical +address range that the slave descriptor will receive MMIO notifications +for. The range is specified by a guest physical range structure +argument. For buses that assign addresses to devices dynamically, this +command can be executed while the guest is running, such as the case +when a guest changes a device's PCI BAR registers. + +*KVM\_DEV\_USER\_PA\_RANGE* will use ``kvm_io_bus_register_dev()`` to +register *kvm\_io\_device\_ops* callbacks to be invoked when the guest +performs a MMIO operation within the range. When a range is changed, +``kvm_io_bus_unregister_dev()`` is used to remove the previous +instantiation. + +*KVM\_DEV\_USER\_TIMEOUT* will configure a timeout value that specifies +how long KVM will wait for the emulation process to respond to a MMIO +indication. + +- destroy + +This routine is called when the VM instance is destroyed. It will need +to destroy the slave descriptor; and free any memory allocated by the +driver, as well as the *kvm\_device* structure itself. + +slave descriptor +^^^^^^^^^^^^^^^^ + +The slave descriptor will have its own file operations vector, which +responds to system calls on the descriptor performed by the device +emulation program. + +- read + +A read returns any pending MMIO requests from the KVM driver as MMIO +request structures. Multiple structures can be returned if there are +multiple MMIO operations pending. The MMIO requests are moved from the +pending queue to the sent queue, and if there are threads waiting for +space in the pending to add new MMIO operations, they will be woken +here. + +- write + +A write also consists of a set of MMIO requests. They are compared to +the MMIO requests in the sent queue. Matches are removed from the sent +queue, and any threads waiting for the reply are woken. If a store is +removed, then the number of posted stores in the per-CPU scoreboard is +decremented. When the number is zero, and a non side-effect load was +waiting for posted stores to complete, the load is continued. + +- ioctl + +There are several ioctl()s that can be performed on the slave +descriptor. + +A *KVM\_DEV\_USER\_SHADOW\_SIZE* ``ioctl()`` causes the KVM driver to +allocate memory for the shadow image. This memory can later be +``mmap()``\ ed by the emulation process to share the emulation's view of +device memory with the KVM driver. + +A *KVM\_DEV\_USER\_SHADOW\_CTRL* ``ioctl()`` controls access to the +shadow image. It will send the KVM driver a shadow control map, which +specifies which areas of the image can complete guest loads without +sending the load request to the emulation program. It will also specify +the size of load operations that are allowed. + +- poll + +An emulation program will use the ``poll()`` call with a *POLLIN* flag +to determine if there are MMIO requests waiting to be read. It will +return if the pending MMIO request queue is not empty. + +- mmap + +This call allows the emulation program to directly access the shadow +image allocated by the KVM driver. As device emulation updates device +memory, changes with no side-effects will be reflected in the shadow, +and the KVM driver can satisfy guest loads from the shadow image without +needing to wait for the emulation program. + +kvm\_io\_device ops +^^^^^^^^^^^^^^^^^^^ + +Each KVM per-CPU thread can handle MMIO operation on behalf of the guest +VM. KVM will use the MMIO's guest physical address to search for a +matching *kvm\_io\_device* to see if the MMIO can be handled by the KVM +driver instead of exiting back to QEMU. If a match is found, the +corresponding callback will be invoked. + +- read + +This callback is invoked when the guest performs a load to the device. +Loads with side-effects must be handled synchronously, with the KVM +driver putting the QEMU thread to sleep waiting for the emulation +process reply before re-starting the guest. Loads that do not have +side-effects may be optimized by satisfying them from the shadow image, +if there are no outstanding stores to the device by this CPU. PCI memory +ordering demands that a load cannot complete before all older stores to +the same device have been completed. + +- write + +Stores can be handled asynchronously unless the pending MMIO request +queue is full. In this case, the QEMU thread must sleep waiting for +space in the queue. Stores will increment the number of posted stores in +the per-CPU scoreboard, in order to implement the PCI ordering +constraint above. + +interrupt acceleration +^^^^^^^^^^^^^^^^^^^^^^ + +This performance optimization would work much like a vhost user +application does, where the QEMU process sets up *eventfds* that cause +the device's corresponding interrupt to be triggered by the KVM driver. +These irq file descriptors are sent to the emulation process at +initialization, and are used when the emulation code raises a device +interrupt. + +intx acceleration +''''''''''''''''' + +Traditional PCI pin interrupts are level based, so, in addition to an +irq file descriptor, a re-sampling file descriptor needs to be sent to +the emulation program. This second file descriptor allows multiple +devices sharing an irq to be notified when the interrupt has been +acknowledged by the guest, so they can re-trigger the interrupt if their +device has not de-asserted its interrupt. + +intx irq descriptor + + +The irq descriptors are created by the proxy object +``using event_notifier_init()`` to create the irq and re-sampling +*eventds*, and ``kvm_vm_ioctl(KVM_IRQFD)`` to bind them to an interrupt. +The interrupt route can be found with +``pci_device_route_intx_to_irq()``. + +intx routing changes + + +Intx routing can be changed when the guest programs the APIC the device +pin is connected to. The proxy object in QEMU will use +``pci_device_set_intx_routing_notifier()`` to be informed of any guest +changes to the route. This handler will broadly follow the VFIO +interrupt logic to change the route: de-assigning the existing irq +descriptor from its route, then assigning it the new route. (see +``vfio_intx_update()``) + +MSI/X acceleration +'''''''''''''''''' + +MSI/X interrupts are sent as DMA transactions to the host. The interrupt +data contains a vector that is programed by the guest, A device may have +multiple MSI interrupts associated with it, so multiple irq descriptors +may need to be sent to the emulation program. + +MSI/X irq descriptor + + +This case will also follow the VFIO example. For each MSI/X interrupt, +an *eventfd* is created, a virtual interrupt is allocated by +``kvm_irqchip_add_msi_route()``, and the virtual interrupt is bound to +the eventfd with ``kvm_irqchip_add_irqfd_notifier()``. + +MSI/X config space changes + + +The guest may dynamically update several MSI-related tables in the +device's PCI config space. These include per-MSI interrupt enables and +vector data. Additionally, MSIX tables exist in device memory space, not +config space. Much like the BAR case above, the proxy object must look +at guest config space programming to keep the MSI interrupt state +consistent between QEMU and the emulation program. + +-------------- + +Disaggregated CPU emulation +--------------------------- + +After IO services have been disaggregated, a second phase would be to +separate a process to handle CPU instruction emulation from the main +QEMU control function. There are no object separation points for this +code, so the first task would be to create one. + +Host access controls +-------------------- + +Separating QEMU relies on the host OS's access restriction mechanisms to +enforce that the differing processes can only access the objects they +are entitled to. There are a couple types of mechanisms usually provided +by general purpose OSs. + +Discretionary access control +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Discretionary access control allows each user to control who can access +their files. In Linux, this type of control is usually too coarse for +QEMU separation, since it only provides three separate access controls: +one for the same user ID, the second for users IDs with the same group +ID, and the third for all other user IDs. Each device instance would +need a separate user ID to provide access control, which is likely to be +unwieldy for dynamically created VMs. + +Mandatory access control +~~~~~~~~~~~~~~~~~~~~~~~~ + +Mandatory access control allows the OS to add an additional set of +controls on top of discretionary access for the OS to control. It also +adds other attributes to processes and files such as types, roles, and +categories, and can establish rules for how processes and files can +interact. + +Type enforcement +^^^^^^^^^^^^^^^^ + +Type enforcement assigns a *type* attribute to processes and files, and +allows rules to be written on what operations a process with a given +type can perform on a file with a given type. QEMU separation could take +advantage of type enforcement by running the emulation processes with +different types, both from the main QEMU process, and from the emulation +processes of different classes of devices. + +For example, guest disk images and disk emulation processes could have +types separate from the main QEMU process and non-disk emulation +processes, and the type rules could prevent processes other than disk +emulation ones from accessing guest disk images. Similarly, network +emulation processes can have a type separate from the main QEMU process +and non-network emulation process, and only that type can access the +host tun/tap device used to provide guest networking. + +Category enforcement +^^^^^^^^^^^^^^^^^^^^ + +Category enforcement assigns a set of numbers within a given range to +the process or file. The process is granted access to the file if the +process's set is a superset of the file's set. This enforcement can be +used to separate multiple instances of devices in the same class. + +For example, if there are multiple disk devices provides to a guest, +each device emulation process could be provisioned with a separate +category. The different device emulation processes would not be able to +access each other's backing disk images. + +Alternatively, categories could be used in lieu of the type enforcement +scheme described above. In this scenario, different categories would be +used to prevent device emulation processes in different classes from +accessing resources assigned to other classes. --=20 2.25.GIT From nobody Sun May 19 11:31:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1586166751; cv=none; d=zohomail.com; s=zohoarc; b=bgABe9wleuPkuM6MCQfae/A1aQmc7wUnIex90bvuWgWgBjR6V4IjpAuhk4GaxJIix7n9GbTHO8miulRWKO9W/pPYs7guiFlfKlXkV6tEhubNI5glOl5jfpy9F+QQbSokfN1xk4kL1esahgh6RWX9GfK0Ya6SGHnrXw/O++4if54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586166751; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZocP0cSRsfVsVQd13v1loLCOLD58vhqoOPrPurUZea8=; b=LGZuevRZA+SxLmd4bmdVs2uX8PKteJLBHEE4rdzq3g5ZnzcaiS81pSECW52OdzgJunoI18DQW2zQXAI+4sXoQulYGJ36WBGfmCxJjPA2KI6Vs0pVE0BOD2ivePPEVr4/rOTxYWNChKbsctfn+aVWU+4gUpiK9yT4NMrqQCn2R4w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586166751623416.5584203713081; Mon, 6 Apr 2020 02:52:31 -0700 (PDT) Received: from localhost ([::1]:57492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOQf-0003l7-SW for importer@patchew.org; Mon, 06 Apr 2020 05:52:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44560) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLOHG-0003OY-NJ for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLOHF-0002fx-02 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:46 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:35426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jLOHE-0002fG-Ne for qemu-devel@nongnu.org; Mon, 06 Apr 2020 05:42:44 -0400 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 0369dpr4089419; Mon, 6 Apr 2020 09:42:39 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 306hnqwu13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:39 +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 0369fOcd066204; Mon, 6 Apr 2020 09:42:38 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 307419xjct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 06 Apr 2020 09:42:38 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0369gZUS013926; Mon, 6 Apr 2020 09:42:35 GMT Received: from flaka.hsd1.ca.comcast.net (/67.180.143.163) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 06 Apr 2020 02:42:31 -0700 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 : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=ZocP0cSRsfVsVQd13v1loLCOLD58vhqoOPrPurUZea8=; b=UQNgX5m4gNp0FqT+IzHkFtyE93PSSnJDUgg5lMiOMLXTb2gaElXaYI+ziNjvaAp3C9lP l1nOrhfBVigBe7GGFcUv0KN4wzmiTCSAJVBOzo2FNBRg/TkRY1h8whlcuTbflAsYWlgr SSr27hRZ74x8YNrmh+rI891jSFC4G+sjUe9e5r+HuCrBWSYQcHETxqt0AYb8dbfImMqF odf6hl6HRgYS7bFStsMqrUJIiiQz+Wr0b5zgKxV7UpEVqpRbmiJpqzz1vipShUHjiijU U0WPzeKtB++DemJe9L3uK4xEFwmKtgJXkNXjKDhRMAalVmA0H+jI3sBhE7FwZj8KTT+a zQ== From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Subject: [PATCH v6 36/36] multi-process: add configure and usage information Date: Mon, 6 Apr 2020 02:41:26 -0700 Message-Id: X-Mailer: git-send-email 2.25.GIT In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060084 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9582 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 impostorscore=0 suspectscore=1 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004060083 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 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, liran.alon@oracle.com, stefanha@redhat.com, thanos.makatos@nutanix.com, rth@twiddle.net, 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- docs/multi-process.rst | 85 +++++++++++++++++++++++++ scripts/mpqemu-launcher-perf-mode.py | 93 ++++++++++++++++++++++++++++ scripts/mpqemu-launcher.py | 54 ++++++++++++++++ 3 files changed, 232 insertions(+) create mode 100644 docs/multi-process.rst create mode 100755 scripts/mpqemu-launcher-perf-mode.py create mode 100755 scripts/mpqemu-launcher.py diff --git a/docs/multi-process.rst b/docs/multi-process.rst new file mode 100644 index 0000000000..9d53667b4e --- /dev/null +++ b/docs/multi-process.rst @@ -0,0 +1,85 @@ +Multi-process QEMU +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +This document describes how to configure and use multi-process qemu. +For the design document refer to docs/devel/qemu-multiprocess. + +1) Configuration +---------------- + +To enable support for multi-process add --enable-mpqemu +to the list of options for the "configure" script. + + +2) Usage +-------- + +Multi-process QEMU requires an orchestrator to launch. Please refer to a +light-weight python based orchestrator for mpqemu in +scripts/mpqemu-launcher.py to lauch QEMU in multi-process mode. + +scripts/mpqemu-launcher-perf-mode.py launches in "perf" mode. In this mode, +the same QEMU process connects to multiple remote devices, each emulated in +a separate process. + +As of now, we only support the emulation of lsi53c895a in a separate proce= ss. + +Following is a description of command-line used to launch mpqemu. + +* Orchestrator: + + - The Orchestrator creates a unix socketpair + + - It launches the remote process and passes one of the + sockets to it via command-line. + + - It then launches QEMU and specifies the other socket as an option + to the Proxy device object + +* Remote Process: + + - The first command-line option in the remote process is one of the + sockets created by the Orchestrator + + - The remaining options are no different from how one launches QEMU with + devices. The only other requirement is each PCI device must have a + unique ID specified to it. This is needed to pair remote device with t= he + Proxy object. + + - Example command-line for the remote process is as follows: + + /usr/bin/qemu-scsu-dev 4 \ + -device lsi53c895a,id=3Dlsi0 = \ + -drive id=3Ddrive_image2,file=3D/build/ol7-nvme-test-1.qcow2 = \ + -device scsi-hd,id=3Ddrive2,drive=3Ddrive_image2,bus=3Dlsi0.0,scsi-i= d=3D0 + +* QEMU: + + - Since parts of the RAM are shared between QEMU & remote process, a + memory-backend-file is required to facilitate this, as follows: + + -object memory-backend-file,id=3Dmem,mem-path=3D/dev/shm/,size=3D4096M= ,share=3Don + + - A "pci-proxy-dev" device is created for each of the PCI devices emulat= ed + in the remote process. A "socket" sub-option specifies the other end of + unix channel created by orchestrator. The "id" sub-option must be spec= ified + and should be the same as the "id" specified for the remote PCI device + + - Example commandline for QEMU is as follows: + + -device pci-proxy-dev,id=3Dlsi0,socket=3D3 + +* Monitor / QMP: + + - The remote process supports QEMU monitor. It could be specified using = the + "-monitor" or "-qmp" command-line options + + - As an example, one could connect to the monitor by adding the following + to the command-line of the remote process + + -monitor unix:/home/qmp-sock,server,nowait + + - The user could connect to the monitor using the qmp script or using + "socat" as outlined below: + + socat /home/qmp-sock stdio diff --git a/scripts/mpqemu-launcher-perf-mode.py b/scripts/mpqemu-launcher= -perf-mode.py new file mode 100755 index 0000000000..a9be82faf5 --- /dev/null +++ b/scripts/mpqemu-launcher-perf-mode.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python3 + +import socket +import os +import subprocess +import time + +PROC_QEMU=3D'/usr/bin/qemu-system-x86_64' + +PROC_REMOTE=3D'/usr/bin/qemu-scsi-dev' + +proxy_1, remote_1 =3D socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) +proxy_2, remote_2 =3D socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) +proxy_3, remote_3 =3D socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) + +remote_cmd_1 =3D [ PROC_REMOTE, = \ + str(remote_1.fileno()), = \ + '-device', 'lsi53c895a,id=3Dlsi1', = \ + '-drive', 'id=3Ddrive_image1,' = \ + 'file=3D/build/ol7-nvme-test-1.qcow2', = \ + '-device', 'scsi-hd,id=3Ddrive1,drive=3Ddrive_image1,' = \ + 'bus=3Dlsi1.0,scsi-id=3D0', = \ + ] + +remote_cmd_2 =3D [ PROC_REMOTE, = \ + str(remote_2.fileno()), = \ + '-device', 'lsi53c895a,id=3Dlsi2', = \ + '-drive', 'id=3Ddrive_image2,' = \ + 'file=3D/build/ol7-nvme-test-2.qcow2', = \ + '-device', 'scsi-hd,id=3Ddrive2,drive=3Ddrive_image2,' = \ + 'bus=3Dlsi2.0,scsi-id=3D0' = \ + ] + +remote_cmd_3 =3D [ PROC_REMOTE, = \ + str(remote_3.fileno()), = \ + '-device', 'lsi53c895a,id=3Dlsi3', = \ + '-drive', 'id=3Ddrive_image3,' = \ + 'file=3D/build/ol7-nvme-test-3.qcow2', = \ + '-device', 'scsi-hd,id=3Ddrive3,drive=3Ddrive_image3,' = \ + 'bus=3Dlsi3.0,scsi-id=3D0' = \ + ] + +proxy_cmd =3D [ PROC_QEMU, = \ + '-name', 'OL7.4', = \ + '-machine', 'q35,accel=3Dkvm', = \ + '-smp', 'sockets=3D1,cores=3D1,threads=3D1', = \ + '-m', '2048', = \ + '-object', 'memory-backend-file,id=3Dsysmem-file,' = \ + 'mem-path=3D/dev/shm/test-mem,size=3D2G,share= =3Don', \ + '-numa', 'node,memdev=3Dsysmem-file', = \ + '-device', 'virtio-scsi-pci,id=3Dvirtio_scsi_pci0', = \ + '-drive', 'id=3Ddrive_image1,if=3Dnone,format=3Dqcow2,' = \ + 'file=3D/home/ol7-hdd-1.qcow2', = \ + '-device', 'scsi-hd,id=3Dimage1,drive=3Ddrive_image1,' = \ + 'bus=3Dvirtio_scsi_pci0.0', = \ + '-boot', 'd', = \ + '-vnc', ':0', = \ + '-device', 'pci-proxy-dev,id=3Dlsi1,' = \ + 'socket=3D'+str(proxy_1.fileno()), = \ + '-device', 'pci-proxy-dev,id=3Dlsi2,' = \ + 'socket=3D'+str(proxy_2.fileno()), = \ + '-device', 'pci-proxy-dev,id=3Dlsi3,' = \ + 'socket=3D'+str(proxy_3.fileno()) = \ + ] + + +pid =3D os.fork(); +if pid =3D=3D 0: + # In remote_1 + print('Launching Remote process 1'); + process =3D subprocess.Popen(remote_cmd_1, pass_fds=3D[remote_1.fileno= ()]) + os._exit(0) + + +pid =3D os.fork(); +if pid =3D=3D 0: + # In remote_2 + print('Launching Remote process 2'); + process =3D subprocess.Popen(remote_cmd_2, pass_fds=3D[remote_2.fileno= ()]) + os._exit(0) + + +pid =3D os.fork(); +if pid =3D=3D 0: + # In remote_3 + print('Launching Remote process 3'); + process =3D subprocess.Popen(remote_cmd_3, pass_fds=3D[remote_3.fileno= ()]) + os._exit(0) + + +print('Launching Proxy process'); +process =3D subprocess.Popen(proxy_cmd, pass_fds=3D[proxy_1.fileno(), = \ + proxy_2.fileno(), proxy_3.fileno()]) diff --git a/scripts/mpqemu-launcher.py b/scripts/mpqemu-launcher.py new file mode 100755 index 0000000000..28d6aa441f --- /dev/null +++ b/scripts/mpqemu-launcher.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +import socket +import os +import subprocess +import time + +PROC_QEMU=3D'/usr/bin/qemu-system-x86_64' + +PROC_REMOTE=3D'/usr/bin/qemu-scsi-dev' + +proxy, remote =3D socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) + +remote_cmd =3D [ PROC_REMOTE, = \ + str(remote.fileno()), = \ + '-device', 'lsi53c895a,id=3Dlsi1', = \ + '-drive', 'id=3Ddrive_image1,file=3D/build/ol7-nvme-test-1.= qcow2', \ + '-device', 'scsi-hd,id=3Ddrive1,drive=3Ddrive_image1,bus=3D= lsi1.0,' \ + 'scsi-id=3D0', = \ + '-device', 'lsi53c895a,id=3Dlsi2', = \ + '-drive', 'id=3Ddrive_image2,file=3D/build/ol7-nvme-test-2.= qcow2', \ + '-device', 'scsi-hd,id=3Ddrive2,drive=3Ddrive_image2,bus=3D= lsi2.0,' \ + 'scsi-id=3D0' = \ + ] + +proxy_cmd =3D [ PROC_QEMU, = \ + '-name', 'OL7.4', = \ + '-machine', 'q35,accel=3Dkvm', = \ + '-smp', 'sockets=3D1,cores=3D1,threads=3D1', = \ + '-m', '2048', = \ + '-object', 'memory-backend-file,id=3Dsysmem-file,' = \ + 'mem-path=3D/dev/shm/test-mem,size=3D2G,share= =3Don', \ + '-numa', 'node,memdev=3Dsysmem-file', = \ + '-device', 'virtio-scsi-pci,id=3Dvirtio_scsi_pci0', = \ + '-drive', 'id=3Ddrive_image1,if=3Dnone,format=3Dqcow2,' = \ + 'file=3D/home/ol7-hdd-1.qcow2', = \ + '-device', 'scsi-hd,id=3Dimage1,drive=3Ddrive_image1,' = \ + 'bus=3Dvirtio_scsi_pci0.0', = \ + '-boot', 'd', = \ + '-vnc', ':0', = \ + '-device', 'pci-proxy-dev,id=3Dlsi1,socket=3D'+str(proxy.fil= eno()), \ + '-device', 'pci-proxy-dev,id=3Dlsi2,socket=3D'+str(proxy.fil= eno()) \ + ] + + +pid =3D os.fork(); + +if pid: + # In Proxy + print('Launching QEMU with Proxy object'); + process =3D subprocess.Popen(proxy_cmd, pass_fds=3D[proxy.fileno()]) +else: + # In remote + print('Launching Remote process'); + process =3D subprocess.Popen(remote_cmd, pass_fds=3D[remote.fileno()]) --=20 2.25.GIT