From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545246; cv=none; d=zoho.com; s=zohoarc; b=mm4Wq4CiYfRUX/X/2qAZkyZX7DiCid8lI86hIegwm4I61jVQO4d1FCO2jMTVnuqw+yNmXdQralFBXD/mTTbkJQnWgD/g1JkMBSNZyyGoCfxoeeMpHcvDcjw6MHuwVqmNRCyTFaOEzDRi/fYboIjC2Z7x+avLxl5Bm0iQRtNFof8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545246; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+cmQtnJ2pLifyfm9PwUnhsvXEovk9HO1gEsy8i2T2fk=; b=jNqiFfMtOkrFKvyd4Pq8IJBFwD1JlVVwrMB3CcF6henQU59Gzb04ynCFUj40dGI+tk3iax3iSxJqjhiTyxZzUGc3oCvIzqqVQq3424Ug3xGyuDVHqnvpOEsb0lsvOZ6pFjTrXsONoXlW8P653yqE8U3Lb2c6fAjRD2lPrIRNEJQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545246290361.5717117549917; Tue, 3 Sep 2019 14:14:06 -0700 (PDT) Received: from localhost ([::1]:51592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G7o-0005Yw-Vo for importer@patchew.org; Tue, 03 Sep 2019 17:14:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53833) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaY-0008Ga-7Y for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaW-0000x6-Qs for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:42 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36250) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaW-0008Kc-Ix for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:40 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXrZc066205; Tue, 3 Sep 2019 20:38:26 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2usy4u82xe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:26 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcKQq188117; Tue, 3 Sep 2019 20:38:25 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2usu5117eh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:25 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KcP1P022759; Tue, 3 Sep 2019 20:38:25 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=+cmQtnJ2pLifyfm9PwUnhsvXEovk9HO1gEsy8i2T2fk=; b=GExoKsT1v6ngAcrg4Nyrw+tZDP6OtPoCO34yUeQdM3SSs+tfCkGVz54XPfs+K1QB+yD7 DnQa8aakWWsd6PflZ1raka033w1vPVnScJRScQj5Oj+gG7iGrNTHuWMMpYA3jayTiEb5 UdWFIh1j5GaaEM4CVs+tOkbmpG+EgSJ9LHYZipUH5H3RbMpMciLegW1ge/IxRMHMINOE 5vDLLpKvZL7LNqCur6NS9iYp/sPQ2LKtydOP8zBZ0uLO75SXVypnxE05fb3hzJSxTy18 MzDmBz1ObBZYZAUOZVs77XEmsIUy12Qmu6RulvcT9E8oFbcXXBZsUo/OeIPg0wRc65qG 9Q== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:27 -0400 Message-Id: <3bf3631115123d4a6a360b41ef0aaa47b40ff08d.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 01/45] multi-process: memory: alloc RAM from file at offset 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. This will be needed for the following patches. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- 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 3e78de3..b3f1aa9 100644 --- a/exec.c +++ b/exec.c @@ -1885,6 +1885,7 @@ static void *file_ram_alloc(RAMBlock *block, ram_addr_t memory, int fd, bool truncate, + off_t offset, Error **errp) { MachineState *ms =3D MACHINE(qdev_get_machine()); @@ -1936,7 +1937,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"); @@ -2325,7 +2327,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; @@ -2370,7 +2372,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; @@ -2400,7 +2403,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 b7b2e60..15837a1 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -164,7 +164,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 e786266..4f57985 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 5d8c9a9..debed5e 100644 --- a/memory.c +++ b/memory.c @@ -1622,7 +1622,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 f7f177d..4b727bd 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 fe0309c..f6a243f 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -204,7 +204,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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543274; cv=none; d=zoho.com; s=zohoarc; b=AHQLHScoZCQUIkbTp+WP9H/dRkmyOXbY+dCligGC0tMnopZ24TSkTyfHMC86vfeCfGAQ3tm1acwUjV3WuMOWaChJ0VdYgTFRsr95lF2VSM+LsuQ5h9v/5c3rnbeQHfUCtZjZsPPjg2EDov6HcoEXiOo3G1qSX8fpLV80ix6HEMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543274; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BmCXB0MhPfbpv+lvsEbmzbJ4q1qBl65OEA69sFifD6k=; b=c9d+9DN7yj+waJmt5KVPdvupBkzfgIhpBM8+/A3rfrag3rhwcF8PdNT1i1ohTz9YsOLyW2XST2LaYdxmQLpMjgCAF78gNvaOkaBejw4Vd54HmxE3RY9PQFWjyLmyyGTDYrPndsPkDUuazYvtNKegQQbVCleav3JWoVpAEZvhORY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 156754327482497.09074805180683; Tue, 3 Sep 2019 13:41:14 -0700 (PDT) Received: from localhost ([::1]:51092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fbt-0000Uw-4W for importer@patchew.org; Tue, 03 Sep 2019 16:41:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53078) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZa-00072b-9f for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZY-0008Qh-U2 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:41 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56528) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZY-0008KX-FW for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:40 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KYAwX053836; Tue, 3 Sep 2019 20:38:29 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2usy6n01wp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:29 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcAIN025408; Tue, 3 Sep 2019 20:38:29 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2us5ph9yk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:28 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KcQKU028537; Tue, 3 Sep 2019 20:38:27 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=BmCXB0MhPfbpv+lvsEbmzbJ4q1qBl65OEA69sFifD6k=; b=BiizWxPF22m2XtTInxooASMdRsUk7f2Gq9V5u1BKJ4nfxSeM5dBguoKkOIVUgpjc3kyH qldY1mvdS9XFSFY9nrl0LooOceUkiHxjMmCesvTKmStga0NG1p7R1CDe0vtNDTTFUN5k 2LJwOsA1wcCjah5M3RcghSnWLIdLJoAiahd1rZ7vZvQmKjaiA7XQzM1yvfD8EUPIIR99 jEq00rCb7ym9qnw2lpU/umyVKU22YlvnmbrzBCp42HFqe1CfYxfTayWkW6nRlUnFmrkG vS37PUcDS9XALnOs0wxS/wQPsqXY59jvLnYbQEMR4OYGtLcJcwsiySclsEhWoNYp9iik aA== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:28 -0400 Message-Id: <32b6764ce960a792b6f523d615ff160ef7d3d12e.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 02/45] multi-process: util: Add qemu_thread_cancel() to cancel running thread 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" qemu_thread_cancel() added to destroy a given running thread. This will be needed in the following patches. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- include/qemu/thread.h | 1 + util/qemu-thread-posix.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index 55d83a9..78791be 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -156,6 +156,7 @@ void qemu_thread_create(QemuThread *thread, const char = *name, void *(*start_routine)(void *), void *arg, int mode); void *qemu_thread_join(QemuThread *thread); +void qemu_thread_cancel(QemuThread *thread); void qemu_thread_get_self(QemuThread *thread); bool qemu_thread_is_self(QemuThread *thread); void qemu_thread_exit(void *retval); diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 1bf5e65..7c89071 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -573,3 +573,13 @@ void *qemu_thread_join(QemuThread *thread) } return ret; } + +void qemu_thread_cancel(QemuThread *thread) +{ + int err; + + err =3D pthread_cancel(thread->thread); + if (err) { + error_exit(err, __func__); + } +} --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545032; cv=none; d=zoho.com; s=zohoarc; b=fxzObAO4LsWsblAal9t80Pw0mmSBYQLfyqH49Axnv6ejoLY5vEwpyZkqUvFYJcpNayUluYDFA8gJ2nXiztrAg91AwB0dlaW0dI2E6bXdoTSEXaNWs4HMpQPCCGjRCwt0OQA4AzOfJG65pb2mA6SqYK9wYncpePkrHZedGbZVs6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545032; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=T3mfHAj9+HL3xKXNgTXtFXhOJtn0MsOFyDfMHjSkdBA=; b=NQq4EsqOUn4iy7PY63p6LrzFpd+hc3htv3MJvzTVwq/YZx1IA72BmP/cNHQkWfB+mJ/TiwZP4RHsS/Y4kcNzQyso03wHVypYr2A85yqyGbgG9EtelyvQW1igsmDQSgU3mtnH8rjZi3A0nRz4DjtgC5Gy/WDeCX2TCaeFLqKtA/c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545032460970.3485330736648; Tue, 3 Sep 2019 14:10:32 -0700 (PDT) Received: from localhost ([::1]:51540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G4M-0001tT-Ug for importer@patchew.org; Tue, 03 Sep 2019 17:10:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53819) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaX-0008Ff-Fe for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaW-0000vn-Az for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:41 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56556) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaW-0008Lu-39 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:40 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXfUl053263; Tue, 3 Sep 2019 20:38:30 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2usy6n01ws-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:30 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcH1Z094699; Tue, 3 Sep 2019 20:38:29 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2usu51u17c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:29 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcST7017254; Tue, 3 Sep 2019 20:38:28 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:27 -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 : in-reply-to : references; s=corp-2019-08-05; bh=T3mfHAj9+HL3xKXNgTXtFXhOJtn0MsOFyDfMHjSkdBA=; b=XRgP0ROpck6UAXjqTERRODdemzSq1oweuftKHOjSfzJO/2YZ2BfbzG7ZX9ow2iIVV3XZ +UEXyAHnSgkWpW+JOmg5EB8hzYMPSV+IRvfqXxbM5Gh6YHWz6eNmBxrv4on1jBvOobAE J2XBIuL0nXx6odmKduyKw01lJqRbI6jxfzfbV+vDnzDPcv7FXNxE2ZFGRNm6u8pIrmcN yZRDowpFRCgzP/WJmBM72TxnLlZmLVHI0vKYz2qvb4hngwoo8bpslqiTpx4/YT9SNXKh 9tVsZV1gGI50rb7I9HB4qMqx1fkrOzITNtJlaaylY7eSRrsvDi+Z5ZXuItizVLv9i58j Lg== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:29 -0400 Message-Id: <3dfc129055ff32b7b55bdcd7142baec1547bcd25.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 03/45] multi-process: add a command line option for debug file 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- 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 b097a6c..ca6f490 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -45,6 +45,7 @@ static inline bool qemu_log_separate(void) /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ #define CPU_LOG_TB_OP_IND (1 << 16) #define CPU_LOG_TB_FPU (1 << 17) +#define LOG_REMOTE_DEBUG (1 << 18) =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 1d1b33f..78e3e82 100644 --- a/util/log.c +++ b/util/log.c @@ -273,6 +273,8 @@ const QEMULogItem qemu_log_items[] =3D { { CPU_LOG_TB_NOCHAIN, "nochain", "do not chain compiled TBs so that \"exec\" and \"cpu\" show\n" "complete traces" }, + { LOG_REMOTE_DEBUG, "rdebug", + "log remote debug" }, { 0, NULL, NULL }, }; =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543272; cv=none; d=zoho.com; s=zohoarc; b=GScSgyX0eoU0Qp0kYi1/s38H4IAJzteDys3yGQYf/wRB+Ge8aWNK/st8J87E/3slsLhRE0LwziaXY9MnkG0YUoqerB31+hfJb5YO6whqxCWFA67PIlfcp4aRQpPl+tMzQa8onixXgs2fMnUHdriZQzbfXsYJTL9mQ3aSGKkNfFA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543272; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=XmCHv23AczqDtwapCDtN5qAjoOFV03ExMoAKO7FdPuM=; b=dAEL7tpKqCbtQ0ZuS6nr6t2VxzI+DSMMo65FqbWlp+WT/JRxOw4QKMusHpDoeY0MlT71wlJVLdDi9z3cOEL3c0mognSGwuGqYnNmBj7BBoSg7JmHDn1X3PAsGMDlM1MVmOZs4wakWuBzVndQwY5MhRru63aoP3ef9V7oP0N0eUs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 156754327292361.29186275821371; Tue, 3 Sep 2019 13:41:12 -0700 (PDT) Received: from localhost ([::1]:51104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fbz-0000f6-Ah for importer@patchew.org; Tue, 03 Sep 2019 16:41:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53110) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZb-00072e-4W for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZZ-0008R7-6y for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:43 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36320) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZY-0008Ps-SP for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:41 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXfrK066117; Tue, 3 Sep 2019 20:38:32 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2usy4u82xq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:32 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcJwJ188092; Tue, 3 Sep 2019 20:38:31 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2usu5117hk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:31 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcTB4017264; Tue, 3 Sep 2019 20:38:30 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=XmCHv23AczqDtwapCDtN5qAjoOFV03ExMoAKO7FdPuM=; b=aqWIu36VKSaBz0QRLMewu+6EewRNXjZKWs8/vlxlLsDAtYqMMHrlrclGC0/3BABYtEJq B5wmTojYJGkxd6kqcbOG/tUU+FYWk3U6WizxAOg2KFh2u79rSK6QVujZGOt6O0WXW167 bok2+BNDtBN6csvyGnxOlj5ff7Ufd4tH2r6lRMN8rS/3JvCfzlYj/GE3jsVt60NmiYg7 TR7wOOmyfAB2hfXrzeuehDzvAgxcE09S2z+ns23TgKZRafWJtp9Z/qHdKZgCeFSM7l3c SzaKLXlZalnaF8Rk40H2Zt4kqU6m+P0nVJMdL/NRZApJ5WM+7Y0RvOa8aVG0KagVkie3 0w== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:30 -0400 Message-Id: <29bbfa028904a603b708801897872fa250a6bbaa.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 04/45] multi-process: Add stub functions to facilate build of multi-process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- accel/stubs/kvm-stub.c | 5 +++ accel/stubs/tcg-stub.c | 85 +++++++++++++++++++++++++++++++++++++++++++= ++++ stubs/machine-init-done.c | 4 +++ stubs/monitor.c | 33 ++++++++++++++++++ stubs/net-stub.c | 31 +++++++++++++++++ stubs/replay.c | 14 ++++++++ stubs/vl-stub.c | 77 ++++++++++++++++++++++++++++++++++++++++++ stubs/vmstate.c | 20 +++++++++++ stubs/xen-mapcache.c | 22 ++++++++++++ 9 files changed, 291 insertions(+) create mode 100644 stubs/net-stub.c create mode 100644 stubs/vl-stub.c create mode 100644 stubs/xen-mapcache.c diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 6feb66e..f129dfb 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 76ae461..52722c7 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -16,11 +16,96 @@ #include "tcg/tcg.h" #include "exec/cpu-common.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 +void tb_check_watchpoint(CPUState *cpu) +{ +} + +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, + int is_cpu_write_access) +{ +} + +void tb_invalidate_phys_page_fast(struct page_collection *pages, + tb_page_addr_t start, int len) +{ +} + +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) +{ +} + +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) +{ +} diff --git a/stubs/machine-init-done.c b/stubs/machine-init-done.c index cd8e813..3deabc9 100644 --- a/stubs/machine-init-done.c +++ b/stubs/machine-init-done.c @@ -6,3 +6,7 @@ bool machine_init_done =3D true; void qemu_add_machine_init_done_notifier(Notifier *notify) { } + +void qemu_remove_machine_init_done_notifier(Notifier *notify) +{ +} diff --git a/stubs/monitor.c b/stubs/monitor.c index c3e9a2e..75dafce 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -2,6 +2,12 @@ #include "qapi/error.h" #include "qapi/qapi-emit-events.h" #include "monitor/monitor.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" =20 __thread Monitor *cur_mon; =20 @@ -27,3 +33,30 @@ void monitor_init_hmp(Chardev *chr, bool use_readline) void qapi_event_emit(QAPIEvent event, QDict *qdict) { } + +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; +} diff --git a/stubs/net-stub.c b/stubs/net-stub.c new file mode 100644 index 0000000..cb2274b --- /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 4ac6078..38fd1d3 100644 --- a/stubs/replay.c +++ b/stubs/replay.c @@ -80,3 +80,17 @@ void replay_mutex_lock(void) void replay_mutex_unlock(void) { } + +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 0000000..89db36c --- /dev/null +++ b/stubs/vl-stub.c @@ -0,0 +1,77 @@ +#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" + +bool tcg_allowed; +bool xen_allowed; +bool boot_strict; + +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 e1e89b8..a9824bc 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -1,8 +1,11 @@ #include "qemu/osdep.h" #include "migration/vmstate.h" +#include "migration/misc.h" =20 const VMStateDescription vmstate_dummy =3D {}; =20 +const VMStateInfo vmstate_info_timer; + int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, @@ -23,3 +26,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 0000000..af5c031 --- /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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543274; cv=none; d=zoho.com; s=zohoarc; b=UNo/+p2l0PcAw/Fr4z5onsg9ThdYKFnII4SVmXj2qCXYxTZbD2+1yI3db3E9TxlQkurAtCHz/ffNP5Kckk8v06uhgC0X4qsZd8gk5w72UkcWupmmB81T7Lw7PFbLU2SNBCuuEqZOXLY7Jqly+YFcekbf5Qax3P2QVHWPOpcWzyQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543274; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PzYg9OHooYsPSBqvu/Hk8iWabk8SxhmCqBxT68BFX94=; b=E8m4PF2s3A813tEgVFzc0HUU0k97BXkwG7uhXjEqEQMl37dYvFld4VbnRZ2DWoQ43K8KDWPx+46ZEZ0z0jfTVDFd5nI87YLS98IxyvLNLKsMeIp9tz5/fLc1+bcQ0VhbTUjFr3tD//f7Zn9zU2LL/0XTZB4jq+MgS5aHJGiJTNY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543274247244.66596289914685; Tue, 3 Sep 2019 13:41:14 -0700 (PDT) Received: from localhost ([::1]:51096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fbu-0000Wj-59 for importer@patchew.org; Tue, 03 Sep 2019 16:41:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53087) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZa-00072c-Ds for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZZ-0008Qx-4r for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:42 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZY-0008Pj-SH for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:41 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXqUN062430; Tue, 3 Sep 2019 20:38:34 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2usy66r2c8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:34 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc9sL025345; Tue, 3 Sep 2019 20:38:33 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2us5ph9ynn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:33 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcVao017295; Tue, 3 Sep 2019 20:38:31 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:30 -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 : in-reply-to : references; s=corp-2019-08-05; bh=PzYg9OHooYsPSBqvu/Hk8iWabk8SxhmCqBxT68BFX94=; b=SsM86V5OPBGEpaDpPK5QNWFTWutnGxUKZb/ULP5Q9cclxzns0crDNsBSk/DM7HDWQWuF C+G8gi1EIMX3JDA4LV8QiZmYqwBBOg2SX17NDsj7C5GZVdCfcw0YZ5i6YbPCIafxi0wE Oselg3TDjMAsY73m1fxbLUOynak7cyy6l/eKnzWhxhcPN2lpiXeyCfz4JY7ijdn4YYRu sASE+RbChLOnKnRf7+G3G7cIvYU0m1UtGBc+HrMBxLLKOoC0c2z9f9WQv479+0ur+AKn Z6pUdyoWAh0CWnzSrcH+z/uvOq/GbMXJl/gF27Iykc/djohjE4shBKu2M+h3sBzz5gvI og== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:31 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 05/45] multi-process: Add config option for multi-process QEMU 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 714e7fb..b467441 100755 --- a/configure +++ b/configure @@ -499,6 +499,7 @@ docker=3D"no" debug_mutex=3D"no" libpmem=3D"" default_devices=3D"yes" +mpqemu=3D"no" =20 # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64=3D"aarch64-linux-gnu-gcc" @@ -1543,6 +1544,10 @@ for opt do ;; --disable-libpmem) libpmem=3Dno ;; + --enable-mpqemu) mpqemu=3Dyes + ;; + --disable-mpqemu) mpqemu=3Dno + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1842,6 +1847,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: capstone capstone disassembler support debug-mutex mutex debugging support libpmem libpmem support + mpqemu multi-process QEMU support =20 NOTE: The object files are built at the place where configure is launched EOF @@ -6481,6 +6487,7 @@ echo "docker $docker" echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" +echo "multiprocess QEMU $mpqemu" =20 if test "$supported_cpu" =3D "no"; then echo @@ -7279,6 +7286,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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543834; cv=none; d=zoho.com; s=zohoarc; b=SS0ztAHpOFccdVE5n3qOxZwz0F8HeQr85AQ48yJeXc0JscDMPJDM6DeNV77+WkdEiMoeujQuKfhaRlO8x3mPzE3epCVTBWRMDv2ZjhYrAq7C3lK2b+lMyjUDH72XLIaecbhVT+J59ChzQQByLNbSijQSs0ckX8SMpQ/KvU+LXdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543834; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sufBEMJ4I4EcNCkTGCSCWMX+Mrfuf9C9/hUO5SD5W28=; b=WZw+rDvBm546l9wcevY2uDkpXyBrKkpyYuJTSNALCIilwHsALRRz02mjSq1pokjJ5OxU6Q4CFSnYA0tB4Q57WWgCqT/6ACmJj6bJTBU0MhruILikiuILi7AzIcrjKahCsrXSGRX3e+BtvxTdvoAtaH4W1Ixr0qBizAbEc16i3Ow= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 156754383408951.39318212415003; Tue, 3 Sep 2019 13:50:34 -0700 (PDT) Received: from localhost ([::1]:51240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fl2-0008Ql-IY for importer@patchew.org; Tue, 03 Sep 2019 16:50:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53152) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZd-00074t-Nw for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZb-0008U8-8m for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:45 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36368) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZa-0008Sy-W5 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:43 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXeWP066085; Tue, 3 Sep 2019 20:38:36 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2usy4u82xx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:35 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcAdW025439; Tue, 3 Sep 2019 20:38:35 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2us5ph9yy6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:34 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KcWH2022807; Tue, 3 Sep 2019 20:38:32 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=sufBEMJ4I4EcNCkTGCSCWMX+Mrfuf9C9/hUO5SD5W28=; b=IW8Vyj7UG7cpLQ9BQyF1z4OnnCJaFbj3HGJlmxcIrc1EdXBq8AkIg1PZDyc9MQM0acL6 8aTxTydLJb13jDAyGHPvQ/PIJoADdNhy4yVHPwpL++X05g5aXdy08KhN71Fv0BjSFRSl e3fmw8XIhpgqG2VpBF/TrlGt4X2fE7lf5pPx8QNB4hiUm+QThdBwSS4fkoMaQtPWV1Le pOJdTajZoqhGQ2ziTSvU4yBz4WEx2LQI9pj3WRD3Fdfp2nnZO+vDGG4d3pdJS5gwfvUW 774B+kEXO8OMxo0c/mz6TnlfLwUc7xj5lBs5oecjYFdqhYrjuQ5XETQNFpJJaWMvsyfo fA== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:32 -0400 Message-Id: <8c79ff5699c7b1e1948479fe86a448d5a255b6ce.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 06/45] multi-process: build system for remote device process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- Makefile | 2 ++ Makefile.objs | 22 +++++++++++++++++++++ Makefile.target | 51 +++++++++++++++++++++++++++++++++++++++++++++= ++-- backends/Makefile.objs | 2 ++ block/Makefile.objs | 2 ++ hw/Makefile.objs | 7 +++++++ hw/block/Makefile.objs | 2 ++ hw/core/Makefile.objs | 15 +++++++++++++++ hw/nvram/Makefile.objs | 2 ++ hw/pci/Makefile.objs | 4 ++++ hw/scsi/Makefile.objs | 2 ++ migration/Makefile.objs | 2 ++ qom/Makefile.objs | 4 ++++ remote/Makefile.objs | 1 + remote/remote-main.c | 35 +++++++++++++++++++++++++++++++++ stubs/replay.c | 4 ++++ 16 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 remote/Makefile.objs create mode 100644 remote/remote-main.c diff --git a/Makefile b/Makefile index 85862fb..3c9d946 100644 --- a/Makefile +++ b/Makefile @@ -427,6 +427,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 \ ui-obj-y \ ui-obj-m \ diff --git a/Makefile.objs b/Makefile.objs index 6a143dc..0668509 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -21,6 +21,28 @@ 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 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-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 =20 diff --git a/Makefile.target b/Makefile.target index 933b274..42fb642 100644 --- a/Makefile.target +++ b/Makefile.target @@ -36,7 +36,12 @@ QEMU_PROG_BUILD =3D $(QEMU_PROG) endif endif =20 -PROGS=3D$(QEMU_PROG) $(QEMU_PROGW) +ifdef CONFIG_MPQEMU +SCSI_DEV_PROG=3Dqemu-scsi-dev +SCSI_DEV_BUILD =3D $(SCSI_DEV_PROG) +endif + +PROGS=3D$(QEMU_PROG) $(QEMU_PROGW) $(SCSI_DEV_PROG) STPFILES=3D =20 # Makefile Tests @@ -122,6 +127,16 @@ obj-y +=3D disas.o obj-$(call notempty,$(TARGET_XML_FILES)) +=3D gdbstub-xml.o LIBS :=3D $(libs_cpu) $(LIBS) =20 +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 + ######################################################### # Linux user emulator target =20 @@ -178,6 +193,17 @@ 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) + +all-remote-pci-obj-y +=3D memory.o +all-remote-pci-obj-y +=3D exec.o +all-remote-pci-obj-y +=3D ioport.o +all-remote-pci-obj-y +=3D cpus.o + +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 +215,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) @@ -198,8 +227,19 @@ all-obj-$(CONFIG_USER_ONLY) +=3D $(crypto-user-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 @@ -212,6 +252,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/backends/Makefile.objs b/backends/Makefile.objs index 981e8e1..d04200a 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -17,3 +17,5 @@ endif common-obj-$(call land,$(CONFIG_VHOST_USER),$(CONFIG_VIRTIO)) +=3D vhost-u= ser.o =20 common-obj-$(CONFIG_LINUX) +=3D hostmem-memfd.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D hostmem.o diff --git a/block/Makefile.objs b/block/Makefile.objs index 35f3bca..2352fcc 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -63,3 +63,5 @@ qcow.o-libs :=3D -lz linux-aio.o-libs :=3D -laio 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 ece6cc3..4e28053 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -43,3 +43,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 f5f643f..7286fbd 100644 --- a/hw/block/Makefile.objs +++ b/hw/block/Makefile.objs @@ -15,3 +15,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 f8481d9..0229f4b 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -27,3 +27,18 @@ common-obj-$(CONFIG_SOFTMMU) +=3D null-machine.o obj-$(CONFIG_SOFTMMU) +=3D machine-qmp-cmds.o obj-$(CONFIG_SOFTMMU) +=3D numa.o common-obj-$(CONFIG_SOFTMMU) +=3D machine-hmp-cmds.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 diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs index 26f7b4c..9802a31 100644 --- a/hw/nvram/Makefile.objs +++ b/hw/nvram/Makefile.objs @@ -6,3 +6,5 @@ common-obj-y +=3D chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) +=3D mac_nvram.o obj-$(CONFIG_PSERIES) +=3D spapr_nvram.o obj-$(CONFIG_NRF51_SOC) +=3D nrf51_nvm.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D fw_cfg.o diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs index c78f2fb..955be54 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 54b36ed..ef97770 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 a4f3baf..016b6ab 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -13,3 +13,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 aae478f..05da824 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -3,3 +3,7 @@ qom-obj-y +=3D object_interfaces.o =20 common-obj-y =3D cpu.o common-obj-$(CONFIG_SOFTMMU) +=3D qom-hmp-cmds.o 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 +remote-pci-obj-$(CONFIG_MPQEMU) +=3D cpu.o diff --git a/remote/Makefile.objs b/remote/Makefile.objs new file mode 100644 index 0000000..a9b2256 --- /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 0000000..ffcf47f --- /dev/null +++ b/remote/remote-main.c @@ -0,0 +1,35 @@ +/* + * Remote device initialization + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include + +#include "qemu/osdep.h" +#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 38fd1d3..c52b621 100644 --- a/stubs/replay.c +++ b/stubs/replay.c @@ -94,3 +94,7 @@ int replay_get_instructions(void) void replay_account_executed_instructions(void) { } + +void replay_add_blocker(Error *reason) +{ +} --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543526; cv=none; d=zoho.com; s=zohoarc; b=LCfaCtwAaIXQpd8OkJBCFaLzccVLKd/R/oZdlVwlpiqEFB5lzb9KtTxWx9S8R3F6q5wba/fYUhx8b9mbwxncq4YGjvt5xKh5EXFPNyu7/VzodNYgDMYPoRLXph9BHunDDJ2vHQoyYc/aBQQO50wwS8cjjssIhnHppN5zFb/FgUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543526; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rIL8ld0p1Muqus2FHhkSfd2XH6KMqVn3unJf3ylmkjk=; b=jtsuVjP/ZSxA8RAjw8SNULVBrNhCVe7xdo7Ntrt/AJhmNa0HUwwastHKgaEJzH77DTzIvWTFTHoHkCFGBYc6aMUi7x2WJ9IJESEeJYWV8MqmBD/re4zxirDKyPX/MRLivM7b8vu8x47Gtp0xI8reoS6W+zCuER9aYyL9H7bmkto= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543526090624.999816100742; Tue, 3 Sep 2019 13:45:26 -0700 (PDT) Received: from localhost ([::1]:51166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fg3-0004Ik-QV for importer@patchew.org; Tue, 03 Sep 2019 16:45:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53176) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZf-00076r-9H for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZd-0008Vx-18 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:47 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56682) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZc-0008V5-P1 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:44 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXsN8053671; Tue, 3 Sep 2019 20:38:37 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2usy6n01xu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:37 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcAHc025510; Tue, 3 Sep 2019 20:38:37 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2us5pha00d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:37 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcYH1017392; Tue, 3 Sep 2019 20:38:34 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:33 -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 : in-reply-to : references; s=corp-2019-08-05; bh=rIL8ld0p1Muqus2FHhkSfd2XH6KMqVn3unJf3ylmkjk=; b=jnntvJFUlZ7OHO1whaaCossJSB2zJN1sj1tEqMeiVDDftc/1OQZPQb0o5wY5NRbBsVsj wn6eov1v4PYKUTfh+KX8O6C33VkD8XPVSfy77oTDyrydXKiHxyWXouTnucYluRTttbgh gAn2euu9isjUHUnb5kAgWSP20Z49icixsPD/MjdUaCMTS03kla4BfRJ+OjT/spYkTVq0 5e8FZt7VUtoAfY3HbmEBrQgvZQcGLc6UolpbdhLFXeqwQoDt6fQJAksWWZVFWLAI/xjG gdOb7Tc+eAH3bdpWU24LzDCkhU/T3VRNTYDxjmjSmTczLWLKiG9LAAqeKHfw2ZycBjnl +Q== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:33 -0400 Message-Id: <51220007b0f8a34cc72ff2847f5deb1f85c9c0e4.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 07/45] multi-process: define proxy-link object 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Defines proxy-link object which forms the communication link between QEMU & emulation program. Adds functions to configure members of proxy-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 --- v1 -> v2: - Use default context for main loop instead of a new context v2 -> v3: - Enabled multi-channel support in the communication link include/glib-compat.h | 4 + include/io/proxy-link.h | 147 ++++++++++++++++++++++++ io/Makefile.objs | 2 + io/proxy-link.c | 292 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 445 insertions(+) create mode 100644 include/io/proxy-link.h create mode 100644 io/proxy-link.c diff --git a/include/glib-compat.h b/include/glib-compat.h index 1291628..6189b9a 100644 --- a/include/glib-compat.h +++ b/include/glib-compat.h @@ -19,12 +19,16 @@ /* Ask for warnings for anything that was marked deprecated in * the defined version, or before. It is a candidate for rewrite. */ +#ifndef GLIB_VERSION_MIN_REQUIRED #define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_40 +#endif =20 /* Ask for warnings if code tries to use function that did not * exist in the defined version. These risk breaking builds */ +#ifndef GLIB_VERSION_MAX_ALLOWED #define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_40 +#endif =20 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h new file mode 100644 index 0000000..ee78cdd --- /dev/null +++ b/include/io/proxy-link.h @@ -0,0 +1,147 @@ +/* + * Communication channel between QEMU and remote device process + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef PROXY_LINK_H +#define PROXY_LINK_H + +#include +#include +#include +#include + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "qemu/thread.h" + +typedef struct ProxyLinkState ProxyLinkState; + +#define TYPE_PROXY_LINK "proxy-link" +#define PROXY_LINK(obj) \ + OBJECT_CHECK(ProxyLinkState, (obj), TYPE_PROXY_LINK) + +#define REMOTE_MAX_FDS 8 + +#define PROC_HDR_SIZE offsetof(ProcMsg, data1.u64) + +/* + * proc_cmd_t enum type to specify the command to be executed on the remote + * device + * + * Following commands are supported: + * CONF_READ PCI config. space read + * CONF_WRITE PCI config. space write + * + */ +typedef enum { + INIT =3D 0, + CONF_READ, + CONF_WRITE, + MAX, +} proc_cmd_t; + +/* + * ProcMsg Format of the message sent to the remote device from QEMU + * + * 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 + * + */ +typedef struct { + proc_cmd_t cmd; + int bytestream; + size_t size; + + union { + uint64_t u64; + } data1; + + int fds[REMOTE_MAX_FDS]; + int num_fds; + + uint8_t *data2; +} ProcMsg; + +struct conf_data_msg { + uint32_t addr; + uint32_t val; + int l; +}; + +/* + * ProcChannel defines the channel that make up the communication link + * between QEMU and remote process + * + * 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 + * lock Mutex to synchronize access to the channel + */ + +typedef struct ProcChannel { + GSource gsrc; + GPollFD gpfd; + int sock; + QemuMutex lock; +} ProcChannel; + +typedef void (*proxy_link_callback)(GIOCondition cond, ProcChannel *chan); + +/* + * ProxyLinkState 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 ProxyLinkState { + Object obj; + + GMainContext *ctx; + GMainLoop *loop; + + ProcChannel *com; + + proxy_link_callback callback; +}; + +ProxyLinkState *proxy_link_create(void); +void proxy_link_finalize(ProxyLinkState *s); + +void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan); +int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan); + +void proxy_link_init_channel(ProxyLinkState *s, ProcChannel **chan, int fd= ); +void proxy_link_destroy_channel(ProcChannel *chan); +void proxy_link_set_callback(ProxyLinkState *s, proxy_link_callback callba= ck); +void start_handler(ProxyLinkState *s); + +#endif diff --git a/io/Makefile.objs b/io/Makefile.objs index 9a20fce..ff88b46 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 proxy-link.o diff --git a/io/proxy-link.c b/io/proxy-link.c new file mode 100644 index 0000000..5eb9718 --- /dev/null +++ b/io/proxy-link.c @@ -0,0 +1,292 @@ +/* + * Communication channel between QEMU and remote device process + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qemu/module.h" +#include "io/proxy-link.h" +#include "qemu/log.h" + +GSourceFuncs gsrc_funcs; + +static void proxy_link_inst_init(Object *obj) +{ + ProxyLinkState *s =3D PROXY_LINK(obj); + + s->ctx =3D g_main_context_default(); + s->loop =3D g_main_loop_new(s->ctx, FALSE); +} + +static const TypeInfo proxy_link_info =3D { + .name =3D TYPE_PROXY_LINK, + .parent =3D TYPE_OBJECT, + .instance_size =3D sizeof(ProxyLinkState), + .instance_init =3D proxy_link_inst_init, +}; + +static void proxy_link_register_types(void) +{ + type_register_static(&proxy_link_info); +} + +type_init(proxy_link_register_types) + +ProxyLinkState *proxy_link_create(void) +{ + return PROXY_LINK(object_new(TYPE_PROXY_LINK)); +} + +void proxy_link_finalize(ProxyLinkState *s) +{ + g_main_loop_unref(s->loop); + g_main_context_unref(s->ctx); + g_main_loop_quit(s->loop); + + proxy_link_destroy_channel(s->com); + + object_unref(OBJECT(s)); +} + +void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg, ProcChannel *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->lock; + + struct iovec iov =3D { + .iov_base =3D (char *) msg, + .iov_len =3D PROC_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); + } + + qemu_mutex_lock(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); + qemu_mutex_unlock(lock); + return; + } + + if (msg->bytestream) { + data =3D msg->data2; + } else { + data =3D (uint8_t *)msg + PROC_HDR_SIZE; + } + + do { + rc =3D write(sock, data, msg->size); + } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); + + qemu_mutex_unlock(lock); +} + + +int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg, ProcChannel *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->lock; + + struct iovec iov =3D { + .iov_base =3D (char *) msg, + .iov_len =3D PROC_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); + + qemu_mutex_lock(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); + qemu_mutex_unlock(lock); + 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); + memcpy(msg->fds, CMSG_DATA(chdr), fdsize); + break; + } + } + + if (msg->size && msg->bytestream) { + 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)); + } + + qemu_mutex_unlock(lock); + + return rc; +} + +static gboolean proxy_link_handler_prepare(GSource *gsrc, gint *timeout) +{ + g_assert(timeout); + + *timeout =3D -1; + + return FALSE; +} + +static gboolean proxy_link_handler_check(GSource *gsrc) +{ + ProcChannel *chan =3D (ProcChannel *)gsrc; + + return chan->gpfd.events & chan->gpfd.revents; +} + +static gboolean proxy_link_handler_dispatch(GSource *gsrc, GSourceFunc fun= c, + gpointer data) +{ + ProxyLinkState *s =3D (ProxyLinkState *)data; + ProcChannel *chan =3D (ProcChannel *)gsrc; + + s->callback(chan->gpfd.revents, chan); + + if ((chan->gpfd.revents & G_IO_HUP) || (chan->gpfd.revents & G_IO_ERR)= ) { + return G_SOURCE_REMOVE; + } + + return G_SOURCE_CONTINUE; +} + +void proxy_link_set_callback(ProxyLinkState *s, proxy_link_callback callba= ck) +{ + s->callback =3D callback; +} + +void proxy_link_init_channel(ProxyLinkState *s, ProcChannel **chan, int fd) +{ + ProcChannel *src; + + gsrc_funcs =3D (GSourceFuncs){ + .prepare =3D proxy_link_handler_prepare, + .check =3D proxy_link_handler_check, + .dispatch =3D proxy_link_handler_dispatch, + .finalize =3D NULL, + }; + + src =3D (ProcChannel *)g_source_new(&gsrc_funcs, sizeof(ProcChannel)); + + src->sock =3D fd; + qemu_mutex_init(&src->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 proxy_link_destroy_channel(ProcChannel *chan) +{ + g_source_unref(&chan->gsrc); + close(chan->sock); + qemu_mutex_destroy(&chan->lock); +} + +void start_handler(ProxyLinkState *s) +{ + + g_assert(g_source_attach(&s->com->gsrc, s->ctx)); + + g_main_loop_run(s->loop); +} --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543277; cv=none; d=zoho.com; s=zohoarc; b=dRbZTHaq64u6B2wG1VABZ0YRG3gqd1HfAHpdi9ZAwskdYb+lir1E/PabwgctylF01D4Pjr/HOw7NyFOrBu2rjeAjvwonwmdX716HEDwR7vjqiaP5wMDk0CtjbC2mR6gmFLh7g0rLgl6ovDw0O5tqLzE05BzzWp3NHf0EVM0i2ik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543277; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RFnGd7mRDZoMBPLbemZy4/IawuAulvCvwnuP/3KMQdA=; b=hL0rn7QLwx1C7hjYiS+Wgce8V2moDrthrXsddh9hiuXUFDclSp8yotEemzogv2xRI9irwEBUq7rh13jAJWiKtin5LVj3X3+1pqiGsbV2eb5WNd5knYKrcCFxf8bSJuZLT4dCtrNS0IEwHqE2h0CwzmLyeBab8H2YAi42MQwHmuE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543277245315.03248724092555; Tue, 3 Sep 2019 13:41:17 -0700 (PDT) Received: from localhost ([::1]:51108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fc3-0000iZ-Pp for importer@patchew.org; Tue, 03 Sep 2019 16:41:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53147) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZd-00074K-Fl for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZc-0008Uv-3f for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:45 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36380) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZb-0008Tt-R0 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:44 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXeLt066086; Tue, 3 Sep 2019 20:38:37 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2usy4u82y3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:37 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcLOj188202; Tue, 3 Sep 2019 20:38:36 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2usu5117w9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:36 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcZT0012236; Tue, 3 Sep 2019 20:38:35 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:35 -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 : in-reply-to : references; s=corp-2019-08-05; bh=RFnGd7mRDZoMBPLbemZy4/IawuAulvCvwnuP/3KMQdA=; b=icwY7vQ20US2aAVnfQgaKIHVSAqY7SiXAlI8AIEQVOjtxTYUPXSij7mCaTbjNJwlqgZm o9J3ViqnGn5cNwoRj5UE5CeZjvjO70a3zG/GPKvi0Hl0JVG20H2WL+5oz6AT92Tu2Tl9 oIH3iI+xRh5O0RXA+3hie/zLm9b9BdMI7p6QgV08NdxEzSTTqrZncvWgJNrL5k8qZfA3 7FhXTgk7TUbAG6crSzSpJtKHnNk9C8J/5aLeQ6rCUO4PS8RhLs/xMaUmIgG6Wd1KMgkI 9wtvsV1NWG7YzoMvLIp/RjztjcrMS/5U27tmqyA9Rf/RNXra2VUnY0wPQvBQr7SxwOV7 zQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:34 -0400 Message-Id: <0f0117061fabf398c5d16811ef8787c0ba7d4b0e.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 08/45] multi-process: add functions to synchronize proxy and remote endpoints 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- v1 -> v2: - Added timeout to synchronization functions include/io/proxy-link.h | 8 ++++++++ io/proxy-link.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index ee78cdd..b76c574 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -28,7 +28,9 @@ #include #include #include +#include #include +#include =20 #include "qemu/osdep.h" #include "qom/object.h" @@ -133,11 +135,17 @@ struct ProxyLinkState { proxy_link_callback callback; }; =20 +#define GET_REMOTE_WAIT eventfd(0, 0) +#define PUT_REMOTE_WAIT(wait) close(wait) +#define PROXY_LINK_WAIT_DONE 1 + ProxyLinkState *proxy_link_create(void); void proxy_link_finalize(ProxyLinkState *s); =20 void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan); int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan); +uint64_t wait_for_remote(int efd); +void notify_proxy(int fd, uint64_t val); =20 void proxy_link_init_channel(ProxyLinkState *s, ProcChannel **chan, int fd= ); void proxy_link_destroy_channel(ProcChannel *chan); diff --git a/io/proxy-link.c b/io/proxy-link.c index 5eb9718..381a38e 100644 --- a/io/proxy-link.c +++ b/io/proxy-link.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include =20 #include "qemu/module.h" #include "io/proxy-link.h" @@ -216,6 +218,46 @@ int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg, P= rocChannel *chan) 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 proxy_link_handler_prepare(GSource *gsrc, gint *timeout) { g_assert(timeout); --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544193; cv=none; d=zoho.com; s=zohoarc; b=DooICDlP3YVztJ35iIjjdPtkbwFCLXSS/0twBKPA+XJc5aJRnVRtLgYR92BKlAC2WONtdg1mAPoRRFrN88rQJUJPp3oq9+cgGMU7Z3Y1hSaR2tlaIoJWgE0lTSMRziURZ+NNCrUM4v73Ipa6fYW5wHEeaE3VWvkhPm+VGFa5pSc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544193; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OlncDZQrMDnxGpyenFMZz0BfjFxWQY52FydwadgqByw=; b=JBp27HQHcKl07431dqSNhtUMMPCdyNMgOYDEwlJldow9ljlSSJDUcXx0QgxMvfR9pglyXrKTgjWlvyn7dD7acqKbJc5xFTIawF9TQcvNzAasPulXd1j4tv/DMq6H9GHeFzE0LmP6JherL3IJSxLnUiVzqzSJ5+hbfLg6zrDgXP8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 15675441931661013.3531267239481; Tue, 3 Sep 2019 13:56:33 -0700 (PDT) Received: from localhost ([::1]:51332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fqp-0007BH-BX for importer@patchew.org; Tue, 03 Sep 2019 16:56:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53304) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZr-0007OA-Tn for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZq-0000Kc-86 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:59 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZp-0000Jy-Vs for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:58 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXk6M062393; Tue, 3 Sep 2019 20:38:51 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2usy66r2eb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:51 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcY5t178165; Tue, 3 Sep 2019 20:38:51 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2us4wegq4k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:50 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KcbsF022822; Tue, 3 Sep 2019 20:38:37 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:37 -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 : in-reply-to : references; s=corp-2019-08-05; bh=OlncDZQrMDnxGpyenFMZz0BfjFxWQY52FydwadgqByw=; b=VZzme/pvT6nuWgcOKXsWuot8beU0fIqpO24PxiqeK10tilO1hWRUu9t48Ra0BMlhPLqS aDWZKdbQtsXrUu6e2kdEAqAfJvA1bAmIYafS+kmPeHQQikd8BdQ9/ncXUB/Uzi52PWRi +xhwtbK0A7lmQphHvHhIdvFTIUfvsunHdpoW1e6xXfanU4aEu8uySETcnjvvYrnc3GHX u4oYltLbSmHvxwcyDWL8gBdtaKOgTNoy8vjnRgcTBNDyJtQSFwWm3Wu9c+ILTYRWHwRg qvLmdAcHZQA1CkkyiX2zQABelg81ojXiSBqXFJlvHOvJq6z2LVw9c5GJkk+eJ1iuChVq fQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:35 -0400 Message-Id: <7df48f68a9e58683a19178c07b1d68fc76643825.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 09/45] multi-process: setup PCI host bridge for remote device 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- hw/pci/Makefile.objs | 2 +- include/remote/pcihost.h | 59 ++++++++++++++++++++++++++++++++++ remote/Makefile.objs | 1 + remote/pcihost.c | 84 ++++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 include/remote/pcihost.h create mode 100644 remote/pcihost.c diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs index 955be54..90693a7 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 0000000..b3c711d --- /dev/null +++ b/include/remote/pcihost.h @@ -0,0 +1,59 @@ +/* + * PCI Host for remote device + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef REMOTE_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 a9b2256..2757f5a 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 0000000..bcdd214 --- /dev/null +++ b/remote/pcihost.c @@ -0,0 +1,84 @@ +/* + * Remote PCI host device + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include + +#include "qemu/osdep.h" +#include "hw/pci/pci.h" +#include "hw/pci/pci_host.h" +#include "hw/pci/pcie_host.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) +{ + PCIHostState *pci =3D PCI_HOST_BRIDGE(dev); + RemPCIHost *s =3D REMOTE_HOST_DEVICE(dev); + + /* + * TODO: the name of the bus would be provided by QEMU. Use + * "pcie.0" for now. + */ + pci->bus =3D pci_root_bus_new(DEVICE(s), "pcie.0", + s->mr_pci_mem, s->mr_sys_io, + 0, TYPE_PCIE_BUS); +} + +static Property remote_host_props[] =3D { + DEFINE_PROP_END_OF_LIST(), +}; + +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->props =3D remote_host_props; + + 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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567546364; cv=none; d=zoho.com; s=zohoarc; b=fUgUHSNxVlir7gbyTiSjJRLZwLoOXgw50415lbJPbVmasogHh12l6bMMZfO4ecrfb5clVN4pYm1dsqIdUqpOdqRt6C02LglePZ8JnasdmcQzx8vCkZvWwrKBsTLIVh1gTA+mT1kui/PpgFAp1wGn1gCkbyy3knwel+P3vTak0zM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567546364; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ytFWpd4znREQzr25pofBI0txEoAvZMaz2ykEabl+Lo4=; b=VIS+qNKkQB5BTx9TR7qigmSAg4hj45dZnTnNqebgfvt0UAYIpLCrIWa88VYxERLbNfXyz4tTXzhsSTKgEsaipJKkfex1pvM2LdsEkRMReYNnYv5MyUSNV5D4ye+39oBbWiPavT57kqfDWUp6GEIH8VHUL7jqPXuRExcRlrcWYfU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567546364024537.3973875706463; Tue, 3 Sep 2019 14:32:44 -0700 (PDT) Received: from localhost ([::1]:51820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GPp-0005TN-Ue for importer@patchew.org; Tue, 03 Sep 2019 17:32:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54013) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fbd-0000y0-N5 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:40:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fbc-0001rD-0r for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:40:49 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:38636) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fbb-0001pj-NS for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:40:47 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdSYl070909; Tue, 3 Sep 2019 20:40:42 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2usy4u839d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:40:42 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcZaM178214; Tue, 3 Sep 2019 20:38:42 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2us4wegq56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:42 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcdKg012261; Tue, 3 Sep 2019 20:38:39 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=ytFWpd4znREQzr25pofBI0txEoAvZMaz2ykEabl+Lo4=; b=TxTQD4pp8tdJ0R7T0mO2Ikasvg/7ermRGrNEAKaYfgbcb5u9Ghqloq1i095nx2ph732V J0fLhlBpj6bzdGUnUFjDvEXd7jYPsn/8CukClzbh8mjP8MPXDpYMbEXDEMWzdKuKLcUF 6ickn90ezQPdwvWIjivepYCqkm7LoCTZcLsMdYOhJsml4+7KmhanNR0r3Eh7J08Bfhms YNsomf7zy9kTHOqXdNYjZHeH6vU/Pe1Rd49x7+NZdSQ50Hvn+7GQB9pF7SZHA9aRpjXY 8lLi7yX4/q0W21xbP1xbyOzCqN7RqoiEggeV67nkp1SlB631B/N2RNOayn2q0oXSYUzz 8g== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:36 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 10/45] multi-process: setup a machine object for remote device process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" remote-machine object sets up various subsystems of the remote device process. 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 --- exec.c | 3 +- include/exec/address-spaces.h | 2 + include/remote/machine.h | 46 ++++++++++++++++ remote/Makefile.objs | 1 + remote/machine.c | 118 ++++++++++++++++++++++++++++++++++++++= ++++ remote/remote-main.c | 7 +++ 6 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 include/remote/machine.h create mode 100644 remote/machine.c diff --git a/exec.c b/exec.c index b3f1aa9..04d9663 100644 --- a/exec.c +++ b/exec.c @@ -197,7 +197,6 @@ typedef struct subpage_t { #define PHYS_SECTION_WATCH 3 =20 static void io_mem_init(void); -static void memory_map_init(void); static void tcg_commit(MemoryListener *listener); =20 static MemoryRegion io_mem_watch; @@ -3165,7 +3164,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 db8bfa9..56a877b 100644 --- a/include/exec/address-spaces.h +++ b/include/exec/address-spaces.h @@ -33,6 +33,8 @@ MemoryRegion *get_system_memory(void); */ MemoryRegion *get_system_io(void); =20 +void memory_map_init(void); + extern AddressSpace address_space_memory; extern AddressSpace address_space_io; =20 diff --git a/include/remote/machine.h b/include/remote/machine.h new file mode 100644 index 0000000..a00732d --- /dev/null +++ b/include/remote/machine.h @@ -0,0 +1,46 @@ +/* + * Remote machine configuration + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef REMOTE_MACHINE_H +#define REMOTE_MACHINE_H + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "hw/boards.h" +#include "remote/pcihost.h" +#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) + +void qemu_run_machine_init_done_notifiers(void); + +#endif diff --git a/remote/Makefile.objs b/remote/Makefile.objs index 2757f5a..13d4c48 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 0000000..4ce197d --- /dev/null +++ b/remote/machine.c @@ -0,0 +1,118 @@ +/* + * Machine for remote device + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include +#include + +#include "qemu/osdep.h" +#include "remote/pcihost.h" +#include "remote/machine.h" +#include "exec/address-spaces.h" +#include "exec/memory.h" +#include "exec/ioport.h" +#include "exec/ramlist.h" +#include "qemu/thread.h" +#include "qom/object.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "qemu/main-loop.h" +#include "qemu-common.h" +#include "sysemu/sysemu.h" +#include "qemu/notify.h" + +static NotifierList machine_init_done_notifiers =3D + NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); + +bool machine_init_done; + +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); +} + +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; + + qemu_mutex_init(&ram_list.mutex); + + 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; + + 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 ffcf47f..97dd832 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -26,10 +26,17 @@ =20 #include "qemu/osdep.h" #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; } --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544008; cv=none; d=zoho.com; s=zohoarc; b=WEMaSCaHN6yAbY+MaTI4jTBD62xFm5Q+GpF2izeojStZFgTcgXEHWfjpuARj+vHicCCq98isOo08R390ecQeg/YfUVngKRJxqs5ocCKIJlHv4GCtl6sYiBpnPEH4dRgUcq6d+2dx3DEPAl3On1+r1+hVwZxwP/m7K0uIQODa95E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544008; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Nd3Vmf0eBGgm37ZZOWhDZ3W4qVXu7+GBPd6/ZZ9TVCk=; b=R3uEOMvuiq2ujWGb3hhsvIpVLhhSBTX7KttD34KSQB/uLP+bDABVqqEZc/xqQ79Xt9GdmrVnFieyrkYB4NvwE0bPmiPLVYsfdaW9hclIyLOyLgFyeukFxTD4sMzbsZ0c5BEsYVKR2g8nyQqgNoUzI4S/5zUgUaAh4PI361+2W50= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544008806267.18761732181724; Tue, 3 Sep 2019 13:53:28 -0700 (PDT) Received: from localhost ([::1]:51292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fnr-0003eF-5Z for importer@patchew.org; Tue, 03 Sep 2019 16:53:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53198) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZh-00079K-3G for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZf-00006n-HE for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:48 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59678) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZf-00005m-9F for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:47 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXi3u062312; Tue, 3 Sep 2019 20:38:42 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2usy66r2d8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:42 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcIq4094742; Tue, 3 Sep 2019 20:38:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2usu51u1p8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:41 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KceaC017430; Tue, 3 Sep 2019 20:38:40 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:40 -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 : in-reply-to : references; s=corp-2019-08-05; bh=Nd3Vmf0eBGgm37ZZOWhDZ3W4qVXu7+GBPd6/ZZ9TVCk=; b=QpaYtD6hhZ39f1DMXWzGK1L2IvvIOq0k3JE0IDLxQOvn+OvD3UoDeRW1BZYCUx+rwJvT ZmlxaP8D/6F+IpmE83cdrdHgbbSqgIDzZaqy9KeZGFvd19FPW+kGo1jyvBAJaZU+Vb4W N6BeQeMBUWGoTTFJ0Cm/tqpCexktCI3EbTDBUtz9UWIkA5tNAu/3tpgAKHSNHY+FKBSM BV6I1Dsxe2oQBc1m1jAEyCs5TVJgJIcCWtpHGCu6Y2Gdf84ayq5PdRjf7rIw0yE8NGEg e/rZXOKjncSUOPJFzPWe0E6x5R3u7YIPf0jGGXHBAMQ7cDV51ekbg+iovhVGnHAONAJy aQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:37 -0400 Message-Id: <122095a96dc62e41dc6ea333da7cb05509aa04a0.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 11/45] multi-process: setup memory manager for remote device 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- Makefile.target | 2 + include/io/proxy-link.h | 11 ++++++ include/remote/memory.h | 34 +++++++++++++++++ remote/memory.c | 99 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 146 insertions(+) create mode 100644 include/remote/memory.h create mode 100644 remote/memory.c diff --git a/Makefile.target b/Makefile.target index 42fb642..931ee80 100644 --- a/Makefile.target +++ b/Makefile.target @@ -137,6 +137,8 @@ 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 =20 +remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D remote/memory.o + ######################################################### # Linux user emulator target =20 diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index b76c574..159c787 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -35,6 +35,8 @@ #include "qemu/osdep.h" #include "qom/object.h" #include "qemu/thread.h" +#include "exec/cpu-common.h" +#include "exec/hwaddr.h" =20 typedef struct ProxyLinkState ProxyLinkState; =20 @@ -53,12 +55,14 @@ typedef struct ProxyLinkState ProxyLinkState; * Following commands are supported: * CONF_READ PCI config. space read * CONF_WRITE PCI config. space write + * SYNC_SYSMEM Shares QEMU's RAM with remote device's RAM * */ typedef enum { INIT =3D 0, CONF_READ, CONF_WRITE, + SYNC_SYSMEM, MAX, } proc_cmd_t; =20 @@ -75,12 +79,19 @@ typedef enum { * */ typedef struct { + hwaddr gpas[REMOTE_MAX_FDS]; + uint64_t sizes[REMOTE_MAX_FDS]; + ram_addr_t offsets[REMOTE_MAX_FDS]; +} sync_sysmem_msg_t; + +typedef struct { proc_cmd_t cmd; int bytestream; size_t size; =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 0000000..0ffbca0 --- /dev/null +++ b/include/remote/memory.h @@ -0,0 +1,34 @@ +/* + * Memory manager for remote device + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef REMOTE_MEMORY_H +#define REMOTE_MEMORY_H + +#include "qemu/osdep.h" +#include "exec/hwaddr.h" +#include "io/proxy-link.h" + +void remote_sysmem_reconfig(ProcMsg *msg, Error **errp); + +#endif diff --git a/remote/memory.c b/remote/memory.c new file mode 100644 index 0000000..6f87729 --- /dev/null +++ b/remote/memory.c @@ -0,0 +1,99 @@ +/* + * Memory manager for remote device + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include +#include + +#include "qemu/osdep.h" +#include "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/proxy-link.h" +#include "qemu/main-loop.h" +#include "qapi/error.h" + +static void remote_ram_destructor(MemoryRegion *mr) +{ + qemu_ram_free(mr->ram_block); +} + +static void remote_ram_init_from_fd(MemoryRegion *mr, int fd, uint64_t siz= e, + 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); +} + +void remote_sysmem_reconfig(ProcMsg *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); + remote_ram_destructor(subregion); + } + } + + for (region =3D 0; region < msg->num_fds; region++) { + subregion =3D g_new(MemoryRegion, 1); + remote_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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544201; cv=none; d=zoho.com; s=zohoarc; b=KWGlugmo04MjS3/jA8BFcze/Tu2UkMGwnKFuRP86+GNX+83lzSLI8I1RUa5EG80MmTIHqFoz6F3JWZr2LAtJI3rVK3JmircWa7TUAoac28JEHBWTDiaCa6L5vk0W/wr1Sw/DGdVmY824XAerZROHEfnmFSWuq0hWOIBFT8u7gKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544201; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GeV5ssJ4jjBW2Dn4aWTPWs+tYCKrZ+I98ssnh1cdZMo=; b=GMCdDvH5C7nlPT0EKNKpCZIDbIn/BSVdWedtpoNRJ2lU4cVvaGD5RGfdVzrLolKK8BxggC54Tj4vl+fW7ZA/UnQ4Fsm/QeZCH/YBEUHEU1CUMOMMY/F8JNhQrYTdhsIBalzJ2pV/8U1JNl2MNLkA2d6tvlLwjmbCmf2MlTOoMxY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544201978857.1547442768422; Tue, 3 Sep 2019 13:56:41 -0700 (PDT) Received: from localhost ([::1]:51340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fqw-0007K4-DQ for importer@patchew.org; Tue, 03 Sep 2019 16:56:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53218) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZk-0007DP-0G for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZi-0000Ad-MR for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:51 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36500) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZi-0000A0-EN for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:50 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXeWR066085; Tue, 3 Sep 2019 20:38:43 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2usy4u82yv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:43 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcInq094718; Tue, 3 Sep 2019 20:38:43 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2usu51u1pw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:43 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcgDQ017439; Tue, 3 Sep 2019 20:38:42 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=GeV5ssJ4jjBW2Dn4aWTPWs+tYCKrZ+I98ssnh1cdZMo=; b=F/FqvYnw+FGDr8+Cca2MonpSr/ymk7CrinQ4MNIEIwT7YYnEpyjRfnj8fwSuni1UOrGX ZnpMvM+totep2RepkP6MyeHe2n2vmoTyT4TbEjxmtBsfVXJr5bQIIO1EXzeLSL6Vv+Lc ynCF3KpjoJpUZEJS2Qbxg1MrXm+w1Z83FWjz2DTV/gR1Ww0OFh9nOsfPHbC1XtQYHbV9 H68uvS/+w6Kow8HbMg71TAOCSOechP5n1y9Oowplmu7JeZKrEcw6jAlcSDgUjk+SSi+A vtb4U+ODsTNePaU8HzxqsZKvaqA5iiQmqoeF9jxJixY8hYFmaYwMDg+0zwr2Svdukf8+ 2w== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:38 -0400 Message-Id: <7fd01deff75662e371e48c5eec677e79e9096967.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 12/45] multi-process: remote process initialization 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- v1 -> v2: - Separate thread for message processing is removed v2 -> v3: - Added multi-channel support in the remote end remote/remote-main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 81 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index 97dd832..72866ec 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -23,6 +23,8 @@ */ =20 #include +#include +#include =20 #include "qemu/osdep.h" #include "qemu/module.h" @@ -31,12 +33,91 @@ #include "hw/boards.h" #include "hw/qdev-core.h" #include "qemu/main-loop.h" +#include "remote/memory.h" +#include "io/proxy-link.h" +#include "qapi/error.h" +#include "qemu/main-loop.h" +#include "sysemu/cpus.h" +#include "qemu-common.h" +#include "hw/pci/pci.h" +#include "qemu/thread.h" +#include "qemu/main-loop.h" +#include "qemu/config-file.h" +#include "sysemu/sysemu.h" +#include "block/block.h" + +static ProxyLinkState *proxy_link; +PCIDevice *remote_pci_dev; + +static void process_msg(GIOCondition cond, ProcChannel *chan) +{ + ProcMsg *msg =3D NULL; + Error *err =3D NULL; + + if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { + error_setg(&err, "socket closed, cond is %d", cond); + goto finalize_loop; + } + + msg =3D g_malloc0(sizeof(ProcMsg)); + + if (proxy_proc_recv(proxy_link, msg, chan) < 0) { + error_setg(&err, "Failed to receive message"); + goto finalize_loop; + } + + switch (msg->cmd) { + case INIT: + break; + case CONF_WRITE: + break; + case CONF_READ: + break; + default: + error_setg(&err, "Unknown command"); + goto finalize_loop; + } + + g_free(msg); + + return; + +finalize_loop: + error_report_err(err); + g_free(msg); + proxy_link_finalize(proxy_link); + proxy_link =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(); + current_machine =3D MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACH= INE))); =20 + proxy_link =3D proxy_link_create(); + if (!proxy_link) { + printf("Could not create proxy link\n"); + return -1; + } + + proxy_link_init_channel(proxy_link, &proxy_link->com, STDIN_FILENO); + proxy_link_set_callback(proxy_link, process_msg); + + start_handler(proxy_link); + return 0; } --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543530; cv=none; d=zoho.com; s=zohoarc; b=ctD29Of6Gjsjs33JoiHH4ZA8HxUBV8uXzziHaESsSvsamUneAtGliNIydXf+7a1fjONC3+foB02VZ4q1JZX8yO+VZa85KFKzarWAKOtwYUjz5k1ZMet6KoOER96m7yB99VH/wKbqac0VSV9YlSGULtZwpTOYspLfPSA4+sovLCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543530; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=g7trl9l/lqPtxD+uWVpo+Oo5xZyKHP5RvCUDnClcG2E=; b=BRDIko9RRvJp1APuIpGlEUWa8BwioE3qo2ZcsGs8zNuZ/vHx2R0t5wO/jOvVhP6jg0Y2BO8XwvHShRhW8Fl7pcIsoAxv62dy3NDp1zZoRpfk96OXVi9zK5MuRzPnDyxBDFolM03kBomuxaXBnTBeIBr0LmJTEOSKUEsPUkf4F4w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543530678667.5070505664838; Tue, 3 Sep 2019 13:45:30 -0700 (PDT) Received: from localhost ([::1]:51170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fg9-0004Md-1w for importer@patchew.org; Tue, 03 Sep 2019 16:45:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53230) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZm-0007Gx-I5 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZk-0000Cu-Gt for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:54 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59758) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZk-0000BA-8o for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:52 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXih7062336; Tue, 3 Sep 2019 20:38:45 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2usy66r2dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:45 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcJZu094939; Tue, 3 Sep 2019 20:38:44 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2usu51u1qd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:44 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KchS3022927; Tue, 3 Sep 2019 20:38:43 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=g7trl9l/lqPtxD+uWVpo+Oo5xZyKHP5RvCUDnClcG2E=; b=ioCNBaL+OkIqMHV+erwdYXcDPIXyYbareHdhp1Nj4+UThi0POxwOFQk2p6nV26h43o4U WnW2tEIBiVDzvPFxt1/eP8RdUvV5IOySZV4Vg73qQpzIkTmy3NLQhsA5K3VJ8SuwLf0H Cf66RQyhC2074cBcNR2IrwlUOu5dtXTVB2CtEJ5qP7pa/hgbsJ2QU/tZEsI2osyXV5Qe r/GpEwRfqYayffo9GPlxUulVHkylpZ13UzawIoxwcNuDWpD0SC5FRXHv+69oeXElyC1h qCsO4mtPpfvJuP8PjEH4pNFmJFA7+aM7ceWqX4wcfM5aSBZhii7+dMvbHjP6Jdw3a+HV kA== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:39 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 13/45] multi-process: introduce proxy object 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 is responsible for registering PCI BARs,i MemoryRegionOps to handle access to the BARs and forwarding those to the remote device. PCI Proxy object intercepts config space reads and writes. In case of pci config write it forwards it to the remote device using communication channel set by proxy-link object. Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- hw/Makefile.objs | 2 + hw/proxy/Makefile.objs | 1 + hw/proxy/qemu-proxy.c | 247 ++++++++++++++++++++++++++++++++++++++= ++++ include/hw/proxy/qemu-proxy.h | 81 ++++++++++++++ remote/remote-main.c | 28 +++++ 5 files changed, 359 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/hw/Makefile.objs b/hw/Makefile.objs index 4e28053..e016100 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -44,6 +44,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 0000000..eb81624 --- /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 0000000..0ec7bb6 --- /dev/null +++ b/hw/proxy/qemu-proxy.c @@ -0,0 +1,247 @@ +/* + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "io/proxy-link.h" +#include "exec/memory.h" +#include "exec/cpu-common.h" +#include "exec/address-spaces.h" +#include "qemu/int128.h" +#include "qemu/range.h" +#include "hw/pci/pci.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qstring.h" +#include "sysemu/sysemu.h" +#include "hw/proxy/qemu-proxy.h" + +static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); + +int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp) +{ + char *args[3]; + pid_t rpid; + int fd[2] =3D {-1, -1}; + Error *local_error =3D NULL; + + if (pdev->managed) { + /* Child is forked by external program (such as libvirt). */ + return -1; + } + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { + error_setg(errp, "Unable to create unix socket."); + return -1; + } + /* TODO: Restrict the forked process' permissions and capabilities. */ + rpid =3D qemu_fork(&local_error); + + if (rpid =3D=3D -1) { + error_setg(errp, "Unable to spawn emulation program."); + close(fd[0]); + close(fd[1]); + return -1; + } + + if (rpid =3D=3D 0) { + close(fd[0]); + + args[0] =3D g_strdup(command); + args[1] =3D g_strdup_printf("%d", fd[1]); + args[2] =3D NULL; + execvp(args[0], (char *const *)args); + exit(1); + } + pdev->remote_pid =3D rpid; + pdev->rsocket =3D fd[0]; + + close(fd[1]); + + return 0; +} + +static int get_proxy_sock(PCIDevice *dev) +{ + PCIProxyDev *pdev; + + pdev =3D PCI_PROXY_DEV(dev); + + return pdev->rsocket; +} + +static void set_proxy_sock(PCIDevice *dev, int socket) +{ + PCIProxyDev *pdev; + + pdev =3D PCI_PROXY_DEV(dev); + + pdev->rsocket =3D socket; + pdev->managed =3D true; + +} + +static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, = int l, + unsigned int op) +{ + ProcMsg msg; + struct conf_data_msg conf_data; + int wait; + + memset(&msg, 0, sizeof(ProcMsg)); + conf_data.addr =3D addr; + conf_data.val =3D (op =3D=3D CONF_WRITE) ? *val : 0; + conf_data.l =3D l; + + msg.data2 =3D (uint8_t *)malloc(sizeof(conf_data)); + if (!msg.data2) { + return -ENOMEM; + } + + memcpy(msg.data2, (const uint8_t *)&conf_data, sizeof(conf_data)); + msg.size =3D sizeof(conf_data); + msg.cmd =3D op; + msg.bytestream =3D 1; + + if (op =3D=3D CONF_WRITE) { + msg.num_fds =3D 0; + } else { + wait =3D GET_REMOTE_WAIT; + msg.num_fds =3D 1; + msg.fds[0] =3D wait; + } + + proxy_proc_send(dev->proxy_link, &msg, dev->proxy_link->com); + + if (op =3D=3D CONF_READ) { + *val =3D (uint32_t)wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + } + + free(msg.data2); + + 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, CONF_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, CONF_WRITE); +} + +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; + k->config_read =3D pci_proxy_read_config; + k->config_write =3D pci_proxy_write_config; +} + +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), + .abstract =3D true, + .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) + +static void init_proxy(PCIDevice *dev, char *command, Error **errp) +{ + PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); + Error *local_error =3D NULL; + + if (!pdev->managed) { + if (command) { + remote_spawn(pdev, command, &local_error); + } else { + return; + } + } else { + pdev->remote_pid =3D atoi(pdev->rid); + if (pdev->remote_pid =3D=3D -1) { + error_setg(errp, "Remote PID is -1"); + return; + } + } + + pdev->proxy_link =3D proxy_link_create(); + + if (!pdev->proxy_link) { + error_setg(errp, "Failed to create proxy link"); + return; + } + + proxy_link_init_channel(pdev->proxy_link, &pdev->proxy_link->com, + pdev->socket); +} + +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); + } + } + + dev->set_proxy_sock =3D set_proxy_sock; + dev->get_proxy_sock =3D get_proxy_sock; + dev->init_proxy =3D init_proxy; +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h new file mode 100644 index 0000000..ee21818 --- /dev/null +++ b/include/hw/proxy/qemu-proxy.h @@ -0,0 +1,81 @@ +/* + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef QEMU_PROXY_H +#define QEMU_PROXY_H + +#include "io/proxy-link.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; + + int n_mr_sections; + MemoryRegionSection *mr_sections; + + ProxyLinkState *proxy_link; + + EventNotifier intr; + EventNotifier resample; + + pid_t remote_pid; + int rsocket; + int socket; + + char *rid; + + bool managed; + char *dev_id; + + QLIST_ENTRY(PCIProxyDev) next; + + void (*set_proxy_sock) (PCIDevice *dev, int socket); + int (*get_proxy_sock) (PCIDevice *dev); + + void (*set_remote_opts) (PCIDevice *dev, QDict *qdict, unsigned int cm= d); + void (*proxy_ready) (PCIDevice *dev); + void (*init_proxy) (PCIDevice *pdev, char *command, Error **errp); + +} PCIProxyDev; + +typedef struct PCIProxyDevClass { + PCIDeviceClass parent_class; + + void (*realize)(PCIProxyDev *dev, Error **errp); + + char *command; +} PCIProxyDevClass; + +int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp); + + +#endif /* QEMU_PROXY_H */ diff --git a/remote/remote-main.c b/remote/remote-main.c index 72866ec..93b2d36 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -49,6 +49,32 @@ static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; =20 +static void process_config_write(ProcMsg *msg) +{ + struct conf_data_msg *conf =3D (struct conf_data_msg *)msg->data2; + + qemu_mutex_lock_iothread(); + pci_default_write_config(remote_pci_dev, conf->addr, conf->val, conf->= l); + qemu_mutex_unlock_iothread(); +} + +static void process_config_read(ProcMsg *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(remote_pci_dev, conf->addr, conf->l); + qemu_mutex_unlock_iothread(); + + notify_proxy(wait, val); + + PUT_REMOTE_WAIT(wait); +} + static void process_msg(GIOCondition cond, ProcChannel *chan) { ProcMsg *msg =3D NULL; @@ -70,8 +96,10 @@ static void process_msg(GIOCondition cond, ProcChannel *= chan) case INIT: break; case CONF_WRITE: + process_config_write(msg); break; case CONF_READ: + process_config_read(msg); break; default: error_setg(&err, "Unknown command"); --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543829; cv=none; d=zoho.com; s=zohoarc; b=aZg2mzWvb0iXCOzsuSeFUg6j/eBu87k6mgtrfi+RQIt8/wFeXJJDM3BtR/b5NvtCOUW9fpWYjOVe3FGevjQu7goOQlXVMXyyz+XlMqGYgGg2U6OZYqcP3v4JCtjgR/eOEyiRLmz2T6phjbpR+5XRpC97qiZxQXBJcCsXb8R6KUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543829; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7zDGOIXoDOxm5PMB7Fr+f1SykrhndE2bHYknbic9f8o=; b=hyBRFJdmHcucv+0ZZrkWMZUxzYMBhdvdVQp4ED96EgU/ubZtgFIiadjX1i1pUrmnbl7VClG0MMXYQ8nkbaGIV/xstGcbC0MW8TWO5Zn+oFoCi7H8yXXZOCmTEmSA5EN6kApUvGIoVTmzXGSx/+B2GUvHpoesSsOkS1Jgw3WsN4E= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543829257929.9399834757697; Tue, 3 Sep 2019 13:50:29 -0700 (PDT) Received: from localhost ([::1]:51236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fkx-0008LD-6e for importer@patchew.org; Tue, 03 Sep 2019 16:50:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53251) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZo-0007Iy-38 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZm-0000I3-PU for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:55 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZm-0000HI-Ix for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:54 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXpvk053643; Tue, 3 Sep 2019 20:38:48 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2usy6n01ys-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:47 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcZ6j178259; Tue, 3 Sep 2019 20:38:47 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2us4wegqab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:46 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kcjxe012307; Tue, 3 Sep 2019 20:38:45 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:44 -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 : in-reply-to : references; s=corp-2019-08-05; bh=7zDGOIXoDOxm5PMB7Fr+f1SykrhndE2bHYknbic9f8o=; b=Rji2O74kPUr1gv2wAdaFaV9Uo7pEl6cIit35ruyk8sOT32yg6hc8xbX09a52XEmTRrKs FvcThNs68szBU2RLD8hIqg/I+YypO45oJJ+ZOkbJTJLaOlqCxxmnofq54g9dXXcqb2IR jU5tthB4KTHNCtQcH9YCTCtvmWMLSH7zkzd9DEs+Z2R1pZA8t8btAmAzyi/sh7ixZ5nm i44JG/fEYcJnlTjzVQydIO2SHD+ffD34Z2lHFIdFj6YSGQgcb4OZBA/lN6ACQzHOfqtZ NCjWEdepCv1Pyo60UpNSY7QEXMzK7OSztV0ae1Go412xI//bWBSqz5hNUHLXHHkclLGq IA== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:40 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 14/45] mutli-process: build remote command line args 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- New patch in v3 hw/proxy/qemu-proxy.c | 80 +++++++++++++++++++++++++++++++++------= ---- include/hw/proxy/qemu-proxy.h | 2 +- 2 files changed, 62 insertions(+), 20 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 0ec7bb6..e5fd4bb 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -45,47 +45,89 @@ =20 static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); =20 +static int add_argv(char *command_str, char **argv, int argc) +{ + int max_args =3D 64; + + if (argc < max_args - 1) { + argv[argc++] =3D command_str; + argv[argc] =3D 0; + } else { + return 0; + } + + return argc; +} + +static int make_argv(char *command_str, char **argv, int argc) +{ + int max_args =3D 64; + + char *p2 =3D strtok(command_str, " "); + while (p2 && argc < max_args - 1) { + argv[argc++] =3D p2; + p2 =3D strtok(0, " "); + } + argv[argc] =3D 0; + + return argc; +} + int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp) { - char *args[3]; pid_t rpid; int fd[2] =3D {-1, -1}; Error *local_error =3D NULL; + char *argv[64]; + int argc =3D 0, _argc; + char *sfd; + char *exec_dir; + int rc =3D -EINVAL; =20 if (pdev->managed) { /* Child is forked by external program (such as libvirt). */ - return -1; + return rc; } =20 if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { error_setg(errp, "Unable to create unix socket."); - return -1; + return rc; } + exec_dir =3D g_strdup_printf("%s/%s", qemu_get_exec_dir(), "qemu-scsi-= dev"); + argc =3D add_argv(exec_dir, argv, argc); + sfd =3D g_strdup_printf("%d", fd[1]); + argc =3D add_argv(sfd, argv, argc); + _argc =3D argc; + argc =3D make_argv((char *)command, argv, argc); + /* TODO: Restrict the forked process' permissions and capabilities. */ rpid =3D qemu_fork(&local_error); =20 if (rpid =3D=3D -1) { error_setg(errp, "Unable to spawn emulation program."); close(fd[0]); - close(fd[1]); - return -1; + goto fail; } =20 if (rpid =3D=3D 0) { close(fd[0]); - - args[0] =3D g_strdup(command); - args[1] =3D g_strdup_printf("%d", fd[1]); - args[2] =3D NULL; - execvp(args[0], (char *const *)args); + execvp(argv[0], (char *const *)argv); exit(1); } pdev->remote_pid =3D rpid; - pdev->rsocket =3D fd[0]; + pdev->rsocket =3D fd[1]; + pdev->socket =3D fd[0]; =20 + rc =3D 0; + +fail: close(fd[1]); =20 - return 0; + for (int i =3D 0; i < _argc; i++) { + g_free(argv[i]); + } + + return rc; } =20 static int get_proxy_sock(PCIDevice *dev) @@ -94,7 +136,7 @@ static int get_proxy_sock(PCIDevice *dev) =20 pdev =3D PCI_PROXY_DEV(dev); =20 - return pdev->rsocket; + return pdev->socket; } =20 static void set_proxy_sock(PCIDevice *dev, int socket) @@ -103,7 +145,7 @@ static void set_proxy_sock(PCIDevice *dev, int socket) =20 pdev =3D PCI_PROXY_DEV(dev); =20 - pdev->rsocket =3D socket; + pdev->socket =3D socket; pdev->managed =3D true; =20 } @@ -198,16 +240,16 @@ static void pci_proxy_dev_register_types(void) =20 type_init(pci_proxy_dev_register_types) =20 -static void init_proxy(PCIDevice *dev, char *command, Error **errp) +static void init_proxy(PCIDevice *dev, char *command, bool need_spawn, Err= or **errp) { PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); Error *local_error =3D NULL; =20 if (!pdev->managed) { - if (command) { - remote_spawn(pdev, command, &local_error); - } else { - return; + if (need_spawn) { + if (!remote_spawn(pdev, command, &local_error)) { + return; + } } } else { pdev->remote_pid =3D atoi(pdev->rid); diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index ee21818..3b37b65 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -63,7 +63,7 @@ typedef struct PCIProxyDev { =20 void (*set_remote_opts) (PCIDevice *dev, QDict *qdict, unsigned int cm= d); void (*proxy_ready) (PCIDevice *dev); - void (*init_proxy) (PCIDevice *pdev, char *command, Error **errp); + void (*init_proxy) (PCIDevice *dev, char *command, bool need_spawn, Er= ror **errp); =20 } PCIProxyDev; =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543533; cv=none; d=zoho.com; s=zohoarc; b=XoeQh0a/vVY5Up8N6Zy/jOtbJZbLJcquAt3Fi/Mj2zGj6E4TLMasWYheeLROU/6GaEH1tKaCCgJVS4nxLk3ghjqK9rCcKIECIpPsCxHnXSG5aVD7BCDxszXUVIwv5y53eYeJXN3AFGQVhsco6NRIIfrb/fKCaX5W3jJ9tFAiF/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543533; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5K/RtrZChD37454LN52XWbHOA/tbKWaTIL7EHZSXi34=; b=hamnZ4ZptnR9vRo2N09kJ+/SlVO/k+Z8kW8lvPdW4GSfVTrcRroDVNU4Jy918klxDuuJOIesvO4lnHoyl1g29bFLFSo7VFT4pyPvAPFOmIz0trVPSNPNXvYny+22rBBuIJqP/dKe2lJGrvgNibJzGvcMv8lxRz8abMTRBiN6ET8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543533056298.47611430533766; Tue, 3 Sep 2019 13:45:33 -0700 (PDT) Received: from localhost ([::1]:51178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FgB-0004Qw-4o for importer@patchew.org; Tue, 03 Sep 2019 16:45:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53244) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZn-0007IQ-Oc for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZm-0000Hr-Im for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:55 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59818) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZm-0000Fu-B3 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:54 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXsxh062445; Tue, 3 Sep 2019 20:38:49 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2usy66r2e1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:49 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc9ed025344; Tue, 3 Sep 2019 20:38:48 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2us5pha074-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:48 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kck5C017469; Tue, 3 Sep 2019 20:38:46 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:46 -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 : in-reply-to : references; s=corp-2019-08-05; bh=5K/RtrZChD37454LN52XWbHOA/tbKWaTIL7EHZSXi34=; b=GLLcD3fpuYmrHz94K4Fg7U6bzlHsfn0XWvy3dxmdNsJnW//lVptWbnAkrR40Y8iNtAJB VmwMzECbsYLeMmzouCPtqpUQkWRxpT8dHS2LQzaSHuZDOTdrkqO9Pn83/Rg/ZpWy2dqT 1CBphyibGakDJC1LAwWxojUbPYe21zFBrE35fApzGloP8KcKsnLr520HoqTKYZcSOToF uCQM2J5dtm1pUB4fbhTb/jgojrZYJ/F600ThTK3IK6Qnb0KPUblKcmdPlsrrvDPImOET UiFlrQTDp9cQVvf+Jt419EBy0qBj1ZYtHRaXu/xYf7MofTNyAdmtTgq0+5w5Re+uOGNs mw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:41 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 15/45] multi-process: add support of device id to communication channel 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- New patch in v3 include/io/proxy-link.h | 3 +++ io/proxy-link.c | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 159c787..0785394 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -88,6 +88,7 @@ typedef struct { proc_cmd_t cmd; int bytestream; size_t size; + size_t size_id; =20 union { uint64_t u64; @@ -98,6 +99,8 @@ typedef struct { int num_fds; =20 uint8_t *data2; + uint8_t *id; + } ProcMsg; =20 struct conf_data_msg { diff --git a/io/proxy-link.c b/io/proxy-link.c index 381a38e..6f60117 100644 --- a/io/proxy-link.c +++ b/io/proxy-link.c @@ -81,7 +81,7 @@ void proxy_link_finalize(ProxyLinkState *s) void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan) { int rc; - uint8_t *data; + uint8_t *data, *buf =3D NULL; union { char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))]; struct cmsghdr align; @@ -140,10 +140,19 @@ void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg,= ProcChannel *chan) data =3D (uint8_t *)msg + PROC_HDR_SIZE; } =20 + if (msg->size_id > 0) { + buf =3D calloc(1, msg->size + msg->size_id); + assert(buf); + memcpy(buf, data, msg->size); + memcpy(buf + msg->size, msg->id, msg->size_id); + data =3D buf; + } do { - rc =3D write(sock, data, msg->size); + rc =3D write(sock, data, msg->size + msg->size_id); } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); =20 + free(buf); + qemu_mutex_unlock(lock); } =20 @@ -151,7 +160,7 @@ void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg, P= rocChannel *chan) int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg, ProcChannel *chan) { int rc; - uint8_t *data; + uint8_t *data, *buf =3D NULL; union { char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))]; struct cmsghdr align; @@ -207,10 +216,28 @@ int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg, = ProcChannel *chan) data =3D (uint8_t *)&msg->data1; } =20 - if (msg->size) { + if (msg->size) { + if (msg->size_id > 0) { + buf =3D calloc(1, msg->size + msg->size_id); + data =3D buf; + } do { - rc =3D read(sock, data, msg->size); + rc =3D read(sock, data, msg->size + msg->size_id); } while (rc < 0 && (errno =3D=3D EINTR || errno =3D=3D EAGAIN)); + if (rc < 0) { + fprintf(stderr, "Read sock is an error!\n"); + return rc; + } + } + if (msg->size && msg->bytestream) { + memcpy(msg->data2, data, msg->size); + } else { + memcpy((uint8_t *)&msg->data1, data, msg->size); + } + + if (msg->size_id > 0) { + msg->id =3D calloc(1, msg->size_id); + memcpy(msg->id, data + msg->size, msg->size_id); } =20 qemu_mutex_unlock(lock); --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544435; cv=none; d=zoho.com; s=zohoarc; b=REVtCwgdRZuvIDnOBdEW3m79+6tDPZZmjgEvp3Hr3MppzkdV4eT2TEUvok0rblmmQju3ptYRcewnJet8Erh6Kk5CjrZZghZPo46507blQ3vPZ5BRvYTJYUytyVURzgyT7qgswNmNsfLs0M7Dg+Mxt0NEFozebpK6zjoZLFO+mKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544435; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hUkMbLInRYnGpWuGCRLtrqZcj9Se8FIP4xcY/vwdo2E=; b=oFWfzx84BnAi9+Z7+EALmvI99JfNSzbeML4cDbK7aHQZF0/h05/W3UJVzQpSyPmyY70y3g35TIsG1H0ME5ftQSILQouoGKe30oiKhjdlLC/0cYEuHK9tMqmnxSQ848VFHvVGcojk5LM4IRmUi0apnDstYv7I57oWORK0NRp5pxg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544435036493.3236369595111; Tue, 3 Sep 2019 14:00:35 -0700 (PDT) Received: from localhost ([::1]:51398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fuj-0002R4-5R for importer@patchew.org; Tue, 03 Sep 2019 17:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53273) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZp-0007Kx-Fb for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZn-0000JD-Uh for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZn-0000IZ-Mq for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:55 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXqVD062439; Tue, 3 Sep 2019 20:38:49 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2usy66r2e2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:49 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcLHf188207; Tue, 3 Sep 2019 20:38:48 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2usu51182h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:48 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kcm1L012337; Tue, 3 Sep 2019 20:38:48 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=hUkMbLInRYnGpWuGCRLtrqZcj9Se8FIP4xcY/vwdo2E=; b=VOld4uj2kL90H4rukUx6/D/Oy6HUSC1tXMo3w6hZCFZLKaXzE6irRXi30FWb5oscdoO6 JyjnrN9o6iRsytf8NV3znGqU4GB7X5sVCh/BWiTmxJnCzYxv3+wO5FkAFIYm80RotxU1 oAsoh5JSX3krxKoApDGilhZidYHllXpe4aUHqd693lOr7jgXhBqsi0pmn/TulW41XLuD geQe3VA/Pauh13xxoDf4IF/Dzzboqug3qvS1ZHMG2di0LlRvNMFRx2hFnbTwVoeG8ikJ cKtPIPi9gGG855zffpbCWC7iIofFCvfIA6JNpTfYKn7jMYmMaHmCz8j95iVFzfJVdR4r ig== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:42 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 16/45] multi-process: PCI BAR read/write handling for proxy & remote endpoints 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Proxy device object implements handler for PCI BAR writes and reads. The ha= ndler uses BAR_WRITE/BAR_READ message to communicate to the remote process with t= he 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 | 50 +++++++++++++++++++++++++++++ include/hw/proxy/qemu-proxy.h | 5 +++ include/io/proxy-link.h | 12 +++++++ remote/remote-main.c | 73 +++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 140 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index e5fd4bb..44668bf 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -287,3 +287,53 @@ static void pci_proxy_dev_realize(PCIDevice *device, E= rror **errp) dev->get_proxy_sock =3D get_proxy_sock; dev->init_proxy =3D init_proxy; } + +static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *= mr, + bool write, hwaddr addr, uint64_t *val, + unsigned size, bool memory) +{ + ProcMsg msg; + int wait; + + memset(&msg, 0, sizeof(ProcMsg)); + + 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; + } + + proxy_proc_send(proxy_link, &msg, proxy_link->com); + + if (!write) { + *val =3D wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + } +} + +void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr ad= dr, + uint64_t val, unsigned size, bool memory) +{ + send_bar_access_msg(dev->proxy_link, mr, true, addr, &val, size, memor= y); +} + +uint64_t proxy_default_bar_read(PCIProxyDev *dev, MemoryRegion *mr, hwaddr= addr, + unsigned size, bool memory) +{ + uint64_t val; + + send_bar_access_msg(dev->proxy_link, mr, false, addr, &val, size, memo= ry); + + return val; +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 3b37b65..a951570 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -77,5 +77,10 @@ typedef struct PCIProxyDevClass { =20 int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp); =20 +void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr ad= dr, + uint64_t val, unsigned size, bool memory); + +uint64_t proxy_default_bar_read(PCIProxyDev *dev, MemoryRegion *mr, hwaddr= addr, + unsigned size, bool memory); =20 #endif /* QEMU_PROXY_H */ diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 0785394..2c290b2 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -56,6 +56,8 @@ typedef struct ProxyLinkState ProxyLinkState; * CONF_READ PCI config. space read * CONF_WRITE PCI config. space write * 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 * */ typedef enum { @@ -63,6 +65,8 @@ typedef enum { CONF_READ, CONF_WRITE, SYNC_SYSMEM, + BAR_WRITE, + BAR_READ, MAX, } proc_cmd_t; =20 @@ -85,6 +89,13 @@ typedef struct { } sync_sysmem_msg_t; =20 typedef struct { + hwaddr addr; + uint64_t val; + unsigned size; + bool memory; +} bar_access_msg_t; + +typedef struct { proc_cmd_t cmd; int bytestream; size_t size; @@ -93,6 +104,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/remote/remote-main.c b/remote/remote-main.c index 93b2d36..43fe50a 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -45,6 +45,7 @@ #include "qemu/config-file.h" #include "sysemu/sysemu.h" #include "block/block.h" +#include "exec/memattrs.h" =20 static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -75,6 +76,66 @@ static void process_config_read(ProcMsg *msg) PUT_REMOTE_WAIT(wait); } =20 +/* TODO: confirm memtx attrs. */ +static void process_bar_write(ProcMsg *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(ProcMsg *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, ProcChannel *chan) { ProcMsg *msg =3D NULL; @@ -101,6 +162,18 @@ static void process_msg(GIOCondition cond, ProcChannel= *chan) case CONF_READ: process_config_read(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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544001; cv=none; d=zoho.com; s=zohoarc; b=Ba5EdEM8dRtrbmy7y8UV2Elhy46GISJJ7xLkGpp4OrPkg2yMVRxPwcW+r2OaLJtHPRjeyKVVtE3OT/G2pEhzK8wC9f6eLGM60+LVkdYovrk4XR55KDlYrLxv/dUwf0hU3bpHiaAruAFAjT6ISqQElpappU8zYyxpQJg8GSPkU/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544001; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PrJg6TSW3hB3SOAHdr8gQqvqSW+zQgyWsqtOk/RNj3g=; b=ZlqeAGd6np7Djjv1kVy7oIK7afcQPfShM/l7sIAnPwk/y5s77MJNXZuwiXe+FDpqfE9HUowd/HImQx9USM1AGD8eue9z1O9X2NJCzr7Vt6hVb6PAp5nNh45EOuiZ67KxUVSKGqIlh42RgY7FD1Zk1fDMv+XDCSf0HJk8t4OEvLM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544001063306.58360886026014; Tue, 3 Sep 2019 13:53:21 -0700 (PDT) Received: from localhost ([::1]:51282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fni-0003WG-To for importer@patchew.org; Tue, 03 Sep 2019 16:53:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53306) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZs-0007OR-07 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZq-0000LB-RW for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:59 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59924) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZq-0000KM-JI for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:58 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXqVE062439; Tue, 3 Sep 2019 20:38:51 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2usy66r2ed-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:51 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcZMI178242; Tue, 3 Sep 2019 20:38:51 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2us4wegqfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:51 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcnKI017496; Tue, 3 Sep 2019 20:38:50 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=PrJg6TSW3hB3SOAHdr8gQqvqSW+zQgyWsqtOk/RNj3g=; b=ctb1/SRi9aAcw0xMMuseE+yU9t16SipL9nGv7kE3Q1m3wzoFNqLKtnko2KJt/XFg3LRy hmSFyMgs3yJFiYPvbrLVARQwmwVU0NC2FrDsYHGcNFeeOYIOxYPc+7NaNQkraUtziHSB reWy9MLyhN+3aPMXOKs449RTfrG7RV2+yjDcNpc6FU6I42VoFyrj5Kqics93Cllfmmzn WvKAaga3yVYzFZLwX66lJlpCY6xV+dc3+l31Oa7aFMP5ysAMfFr39nw5o7GRKRzNsOyc aqviygzRdg7QZ/AOpqVMOeCk6BFJ0G3UZrR24UUxYBc+SnBp2C5aJyhsHztaID4XF02z iQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:43 -0400 Message-Id: <41b228aa6e1cd78146ac23d59f06060dcd4c7bfc.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 17/45] multi-process: modify BARs read/write to support dev_id 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 Reviewed-by: Liam Merwick --- New patch in v3 hw/proxy/qemu-proxy.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 44668bf..1021045 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -288,13 +288,16 @@ static void pci_proxy_dev_realize(PCIDevice *device, = Error **errp) dev->init_proxy =3D init_proxy; } =20 -static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *= mr, +static void send_bar_access_msg(PCIProxyDev *dev, MemoryRegion *mr, bool write, hwaddr addr, uint64_t *val, unsigned size, bool memory) { + ProxyLinkState *proxy_link; ProcMsg msg; int wait; =20 + proxy_link =3D dev->proxy_link; + memset(&msg, 0, sizeof(ProcMsg)); =20 msg.bytestream =3D 0; @@ -314,18 +317,31 @@ static void send_bar_access_msg(ProxyLinkState *proxy= _link, MemoryRegion *mr, msg.fds[0] =3D wait; } =20 + if (dev->dev_id) { + msg.size_id =3D strlen(dev->dev_id) + 1; + msg.id =3D calloc(1, msg.size_id); + memcpy(msg.id, dev->dev_id, msg.size_id); + } else { + msg.size_id =3D 0; + } + proxy_proc_send(proxy_link, &msg, proxy_link->com); =20 if (!write) { *val =3D wait_for_remote(wait); PUT_REMOTE_WAIT(wait); } + + if (msg.id) { + free(msg.id); + } + } =20 void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr ad= dr, uint64_t val, unsigned size, bool memory) { - send_bar_access_msg(dev->proxy_link, mr, true, addr, &val, size, memor= y); + send_bar_access_msg(dev, mr, true, addr, &val, size, memory); } =20 uint64_t proxy_default_bar_read(PCIProxyDev *dev, MemoryRegion *mr, hwaddr= addr, @@ -333,7 +349,7 @@ uint64_t proxy_default_bar_read(PCIProxyDev *dev, Memor= yRegion *mr, hwaddr addr, { uint64_t val; =20 - send_bar_access_msg(dev->proxy_link, mr, false, addr, &val, size, memo= ry); + send_bar_access_msg(dev, mr, false, addr, &val, size, memory); =20 return val; } --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544756; cv=none; d=zoho.com; s=zohoarc; b=DoNtqB7PjYy+I4MzbfWhPzyNXOkNBQ+a0eFP7dTxrzz+29zX3imOrekOUl2tP4ZvgMlRWJ+CmhK/48Z0P3Kny+UoTzUcbC/YRgNBmoAc6TLEtUIQ/J/IKCLgdgaL9g+C56JI01YBySPBxwflLV6KL0nWsGsVTUs9Xa6N4pKyNE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544756; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GUtOh6uWmy5bBzOxxzJ1uCCKmTjk2dTU82Y4WxCFH9g=; b=D7uUwKTYwBkGxwT0DjBA9NHJThCjuNTTvNqRb9seDt6lOr+0j207xozNvSO8ei5vV38S+ED6gG/3dFqKjMd/1eakRPYJmfmScSsmxt3wb5YVm1u1XUowwqloSUbBOkQgw3bHpwvyTyaxl1y2n38hNTkP1tPXyUKxHtei1YoVN0k= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544756289838.610468984379; Tue, 3 Sep 2019 14:05:56 -0700 (PDT) Received: from localhost ([::1]:51488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fzr-0006E3-Ag for importer@patchew.org; Tue, 03 Sep 2019 17:05:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53326) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZs-0007Pm-VM for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZr-0000My-Oj for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:00 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZr-0000L5-FZ for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:59 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXnAZ066152; Tue, 3 Sep 2019 20:38:53 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2usy4u830w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:53 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcMJf095268; Tue, 3 Sep 2019 20:38:52 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2usu51u1u6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:52 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kcpj9012358; Tue, 3 Sep 2019 20:38:51 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=GUtOh6uWmy5bBzOxxzJ1uCCKmTjk2dTU82Y4WxCFH9g=; b=N0z9o2PlxKEEX+lSRQaazjyIsUChKHzY4WuqMFBQBr3rmiwNqoza8SiCDrksLdkxK7T+ Nh3HunISNjzXo1dFTl7deGUgPMM4+tWUd/V/RkHDhGV8rKsKmFxjtuRnX42SQcTkISA2 Knydyu2Tavf9vP8YXx+a8h7KvuDEN9JTH1T0QH5xoup+drdb+F4sigwC8EGS7KXKtzxq D1EljkCVXY4KJ7Gyj1hkngwjqeTHcF4GqlBv6iGDLao4fxwGGpVdmLyccerCj8MSp+EF ijz5As/nMwuwNwCkRRMzrnf5RRrI1lii4wlUljYzJyScDNFafj7XwrEM3lQhDyQVFyTa MA== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:44 -0400 Message-Id: <74468c1d1d6d7ff7afb08d367edb6979ea5e3a31.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 18/45] multi-process: support dev id in config read/write 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- New patch in v3 hw/proxy/qemu-proxy.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 1021045..789f39a 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -151,12 +151,16 @@ static void set_proxy_sock(PCIDevice *dev, int socket) } =20 static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, = int l, - unsigned int op) + char *id, unsigned int op) { ProcMsg msg; struct conf_data_msg conf_data; int wait; =20 + if (!id) { + return -EINVAL; + } + memset(&msg, 0, sizeof(ProcMsg)); conf_data.addr =3D addr; conf_data.val =3D (op =3D=3D CONF_WRITE) ? *val : 0; @@ -171,6 +175,8 @@ static int config_op_send(PCIProxyDev *dev, uint32_t ad= dr, uint32_t *val, int l, msg.size =3D sizeof(conf_data); msg.cmd =3D op; msg.bytestream =3D 1; + msg.id =3D (uint8_t *)g_strdup(dev->dev_id); + msg.size_id =3D strlen(dev->dev_id) + 1; =20 if (op =3D=3D CONF_WRITE) { msg.num_fds =3D 0; @@ -188,6 +194,7 @@ static int config_op_send(PCIProxyDev *dev, uint32_t ad= dr, uint32_t *val, int l, } =20 free(msg.data2); + free(msg.id); =20 return 0; } @@ -198,7 +205,8 @@ static uint32_t pci_proxy_read_config(PCIDevice *d, uin= t32_t addr, int len) =20 (void)pci_default_read_config(d, addr, len); =20 - config_op_send(PCI_PROXY_DEV(d), addr, &val, len, CONF_READ); + config_op_send(PCI_PROXY_DEV(d), addr, &val, len, + PCI_PROXY_DEV(d)->dev_id, CONF_READ); =20 return val; } @@ -208,7 +216,8 @@ static void pci_proxy_write_config(PCIDevice *d, uint32= _t addr, uint32_t val, { pci_default_write_config(d, addr, val, l); =20 - config_op_send(PCI_PROXY_DEV(d), addr, &val, l, CONF_WRITE); + config_op_send(PCI_PROXY_DEV(d), addr, &val, l, + PCI_PROXY_DEV(d)->dev_id, CONF_WRITE); } =20 static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545013; cv=none; d=zoho.com; s=zohoarc; b=GKWQPl0xSfuiuU1uEVB/OdDNSKBXO+5rXUikbF85A5+9AZYQN2U75aFQ0SeKm1yl9457UbtoAuJH7Fmf3kRM66bgnZ/zi50o01PvOSp08iH/FKa/IDFXJjqxgdO/1IYUUKWJpz7cUPp6D5FcEpHNUUgiv1+wYFb6+OAd1lI15fE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545013; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4SShMEO4BMrcL4WeoxKpnzE+jvE1BAoblIgGAWyWpgU=; b=UXR5+a5OMRWqixemxdSCyyMKO84kMvRfbleCgH40lhuiUVYHqgODaja7hXBJbEVX+sDLoAjk342FtD77CCndZNEVnUf43SmFJBdYH6Xi2jiwm2DBNE6fbWlolYBZZJcTpuayDdODDwwer/P+mLHC3U/oiE4Wjpp5aeDERydjHq0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545013599254.2868869661071; Tue, 3 Sep 2019 14:10:13 -0700 (PDT) Received: from localhost ([::1]:51532 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G43-0001b9-MZ for importer@patchew.org; Tue, 03 Sep 2019 17:10:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53330) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZt-0007QQ-CV for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZr-0000Mf-Im for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:01 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36638) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZr-0000L0-Ao for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:38:59 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXem6066078; Tue, 3 Sep 2019 20:38:54 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2usy4u8310-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcIo1094718; Tue, 3 Sep 2019 20:38:53 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2usu51u1un-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:53 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcqnP012364; Tue, 3 Sep 2019 20:38:52 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=4SShMEO4BMrcL4WeoxKpnzE+jvE1BAoblIgGAWyWpgU=; b=Q2bmpfmqzLhmc7ikB/tfntICurNHcqsYgC4v6c+m2FuYW1rB5W/hkd2RB6FJ9ZEhzaz6 wwun/tG8ZUOuFlObsGxvgsDO2T7EN7Cs5B3iJSyQSG0R2bKPTPRuq3j0B/hqUBs8hpdk ZxsL+eghOhCAybgjd6/MZLJEUmPDTtFS+FKubje67IBFbMqxL/afeKqBNSdc6zVBhLcY 8GrptE3Z0w2XAbcKqlWxZt39ZP7WUiOHQOuo9fO6VvsYCsVDVo5ztxqxHvmCn5UVH13m VRdnn9t8qiUGdr9IJv4qTaNn9w1wnqeoyrVJx32zOlGB8zJpLyVDY6y01JA6erQcZfEE OQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:45 -0400 Message-Id: <4c59e3b3d38d1e269be889cc31859ea97c15b2ff.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 19/45] multi-process: Add LSI device proxy object 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Adds proxy-lsi53c895a object, as a derivative of the pci-proxy-dev object. This object is the proxy for the lsi53c895a object instantiated by the remote process. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- hw/proxy/Makefile.objs | 1 + hw/proxy/proxy-lsi53c895a.c | 162 ++++++++++++++++++++++++++++++++= ++++ include/hw/proxy/proxy-lsi53c895a.h | 42 ++++++++++ 3 files changed, 205 insertions(+) create mode 100644 hw/proxy/proxy-lsi53c895a.c create mode 100644 include/hw/proxy/proxy-lsi53c895a.h diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs index eb81624..f562f5a 100644 --- a/hw/proxy/Makefile.objs +++ b/hw/proxy/Makefile.objs @@ -1 +1,2 @@ common-obj-$(CONFIG_MPQEMU) +=3D qemu-proxy.o +common-obj-$(CONFIG_MPQEMU) +=3D proxy-lsi53c895a.o diff --git a/hw/proxy/proxy-lsi53c895a.c b/hw/proxy/proxy-lsi53c895a.c new file mode 100644 index 0000000..e8a8d36 --- /dev/null +++ b/hw/proxy/proxy-lsi53c895a.c @@ -0,0 +1,162 @@ +/* + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include + +#include "qemu/osdep.h" +#include "hw/qdev-core.h" +#include "qemu/bitops.h" +#include "hw/pci/pci.h" +#include "hw/proxy/qemu-proxy.h" +#include "hw/proxy/proxy-lsi53c895a.h" +#include "exec/memory.h" + +static uint64_t proxy_lsi_io_read(void *opaque, hwaddr addr, unsigned size) +{ + ProxyLSIState *s =3D opaque; + + return proxy_default_bar_read(PCI_PROXY_DEV(s), &s->io_io, addr, size, + false); +} + +static void proxy_lsi_io_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + ProxyLSIState *s =3D opaque; + + proxy_default_bar_write(PCI_PROXY_DEV(s), &s->io_io, addr, val, size, + false); +} + +static const MemoryRegionOps proxy_lsi_io_ops =3D { + .read =3D proxy_lsi_io_read, + .write =3D proxy_lsi_io_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + +static uint64_t proxy_lsi_ram_read(void *opaque, hwaddr addr, unsigned siz= e) +{ + ProxyLSIState *s =3D opaque; + + return proxy_default_bar_read(PCI_PROXY_DEV(s), &s->ram_io, addr, size, + true); +} + +static void proxy_lsi_ram_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + ProxyLSIState *s =3D opaque; + + proxy_default_bar_write(PCI_PROXY_DEV(s), &s->ram_io, addr, val, size, + true); +} + +static const MemoryRegionOps proxy_lsi_ram_ops =3D { + .read =3D proxy_lsi_ram_read, + .write =3D proxy_lsi_ram_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, +}; + +static uint64_t proxy_lsi_mmio_read(void *opaque, hwaddr addr, unsigned si= ze) +{ + ProxyLSIState *s =3D opaque; + + return proxy_default_bar_read(PCI_PROXY_DEV(s), &s->mmio_io, addr, siz= e, + true); +} + +static void proxy_lsi_mmio_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + ProxyLSIState *s =3D opaque; + + proxy_default_bar_write(PCI_PROXY_DEV(s), &s->mmio_io, addr, val, size, + true); +} + +static const MemoryRegionOps proxy_lsi_mmio_ops =3D { + .read =3D proxy_lsi_mmio_read, + .write =3D proxy_lsi_mmio_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + +static void proxy_lsi_realize(PCIProxyDev *dev, Error **errp) +{ + ProxyLSIState *s =3D LSI_PROXY_DEV(dev); + PCIDevice *pci_dev =3D PCI_DEVICE(dev); + uint8_t *pci_conf =3D pci_dev->config; + + pci_conf[PCI_LATENCY_TIMER] =3D 0xff; + pci_conf[PCI_INTERRUPT_PIN] =3D 0x01; + + memory_region_init_io(&s->mmio_io, OBJECT(s), &proxy_lsi_mmio_ops, s, + "proxy-lsi-mmio", 0x400); + memory_region_init_io(&s->ram_io, OBJECT(s), &proxy_lsi_ram_ops, s, + "proxy-lsi-ram", 0x2000); + memory_region_init_io(&s->io_io, OBJECT(s), &proxy_lsi_io_ops, s, + "proxy-lsi-io", 256); + + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_io); + pci_register_bar(pci_dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_i= o); + pci_register_bar(pci_dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io= ); +} + +static void proxy_lsi_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *pci_class =3D PCI_DEVICE_CLASS(klass); + PCIProxyDevClass *proxy_class =3D PCI_PROXY_DEV_CLASS(klass); + + proxy_class->realize =3D proxy_lsi_realize; + proxy_class->command =3D g_strdup("qemu-scsi-dev"); + + pci_class->vendor_id =3D PCI_VENDOR_ID_LSI_LOGIC; + pci_class->device_id =3D PCI_DEVICE_ID_LSI_53C895A; + pci_class->class_id =3D PCI_CLASS_STORAGE_SCSI; + pci_class->subsystem_id =3D 0x1000; + + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); + + dc->desc =3D "LSI Proxy Device"; +} + +static const TypeInfo lsi_proxy_dev_type_info =3D { + .name =3D TYPE_PROXY_LSI53C895A, + .parent =3D TYPE_PCI_PROXY_DEV, + .instance_size =3D sizeof(ProxyLSIState), + .class_init =3D proxy_lsi_class_init, +}; + +static void lsi_proxy_dev_register_types(void) +{ + type_register_static(&lsi_proxy_dev_type_info); +} + +type_init(lsi_proxy_dev_register_types) diff --git a/include/hw/proxy/proxy-lsi53c895a.h b/include/hw/proxy/proxy-l= si53c895a.h new file mode 100644 index 0000000..8afb8f3 --- /dev/null +++ b/include/hw/proxy/proxy-lsi53c895a.h @@ -0,0 +1,42 @@ +/* + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef LSI_PROXY_H +#define LSI_PROXY_H + +#include "hw/proxy/qemu-proxy.h" + +#define TYPE_PROXY_LSI53C895A "proxy-lsi53c895a" + +#define LSI_PROXY_DEV(obj) \ + OBJECT_CHECK(ProxyLSIState, (obj), TYPE_PROXY_LSI53C895A) + +typedef struct ProxyLSIState { + PCIProxyDev parent_dev; + + MemoryRegion mmio_io; + MemoryRegion ram_io; + MemoryRegion io_io; + +} ProxyLSIState; + +#endif --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544096; cv=none; d=zoho.com; s=zohoarc; b=WHQ1AsO2K86XrKgbpGghX/FC/QfZj3Og2wOvEe664N+iJqd0flMhK7GT+THEhkfBE9JMFxmDkpXdMTHuKByLmz00tu3TBzrWJ+EnhfxL2i8z0uGl46+nCwJy4w+VRjg0UtAeDcK+qfekRkJF/EK3E2cFkciPLkT4kO4awPb9X+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544096; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N8fcMVeZCfr+KZMIgLeOLBI1SDd2vaoWnXFbjaNitj4=; b=mr+A4j1WnwresuP9GFQiEIrZgo1Sc8rdTVyTf6Eh/q8Tj8So4CGdZpmNhzIjXCnevn/YMHoEpOZjQ6/U6pp4KmB6pIcsm+DsCMj9+2SNgEbPNso+mQ6JMrOMsUxfcGLIdVNCKcKMaI8n/EuYqfxedR6l18AKREWLrWEqkG0jK6w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544096219458.95978973941646; Tue, 3 Sep 2019 13:54:56 -0700 (PDT) Received: from localhost ([::1]:51312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FpG-0005Qi-BS for importer@patchew.org; Tue, 03 Sep 2019 16:54:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53486) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fa2-0007cb-0t for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZx-0000SD-Qz for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:09 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60078) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZx-0000Qe-ES for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:05 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXlhH062406; Tue, 3 Sep 2019 20:38:57 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2usy66r2f5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:57 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcJwb188092; Tue, 3 Sep 2019 20:38:56 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2usu511853-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:56 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KcsTX017531; Tue, 3 Sep 2019 20:38:54 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=N8fcMVeZCfr+KZMIgLeOLBI1SDd2vaoWnXFbjaNitj4=; b=ZC4asmQ+6gkS7lDRU24RWUDjwT/8hESKSyP6P5cxUBadMuOkK4EvIygEexoejy1ZGwId mwkCcm7/RJ8V67NWemszR+SL5CetJmkNE2qPSnSbJKwXnr0TJTNioEsOPrf7t3+I3npJ dfwGEaGNcjGQMpk7JdERLs0u7RFWUhuAcVLU7jlXDBm/DX0OtPSxkGNVPFAcSaaujySx 2ZkR4c7jpLB8y6pBvXNkbZflN9z1znqGwNplvl+8lFRUIbrcXbKpGHkXGi7WZMsB21Wv fc2ZUsP+so4mkqCGiKoeu+8JKioKxWn0/YCKkgVaackLy/REnXMR7KAs0UBdY7dcDtgg 5w== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:46 -0400 Message-Id: <9cae96e67e5464081f378d3efd3e0274ab92a8ca.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 20/45] multi-process: Synchronize remote memory 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- v2 -> v3: - Refactored code to obtain fd from host address, added get_fd_from_hostaddr(). - Discovered a bug which results in invalid FDs (-1) being sent over to the remote process. Fixed this by checking if the FD value is valid before sending over to remote. Makefile.target | 1 + hw/proxy/memory-sync.c | 226 +++++++++++++++++++++++++++++++++++++= ++++ hw/proxy/qemu-proxy.c | 5 + include/hw/proxy/memory-sync.h | 51 ++++++++++ include/hw/proxy/qemu-proxy.h | 2 + remote/remote-main.c | 11 ++ 6 files changed, 296 insertions(+) create mode 100644 hw/proxy/memory-sync.c create mode 100644 include/hw/proxy/memory-sync.h diff --git a/Makefile.target b/Makefile.target index 931ee80..3aa2ac8 100644 --- a/Makefile.target +++ b/Makefile.target @@ -125,6 +125,7 @@ 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 +obj-$(CONFIG_MPQEMU) +=3D hw/proxy/memory-sync.o LIBS :=3D $(libs_cpu) $(LIBS) =20 remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/kvm-stub.o diff --git a/hw/proxy/memory-sync.c b/hw/proxy/memory-sync.c new file mode 100644 index 0000000..5e57784 --- /dev/null +++ b/hw/proxy/memory-sync.c @@ -0,0 +1,226 @@ +/* + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include +#include +#include + +#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/proxy-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= ); + ProcMsg msg; + MemoryRegionSection section; + ram_addr_t offset; + uintptr_t host_addr; + int region; + + memset(&msg, 0, sizeof(ProcMsg)); + + 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; + } + proxy_proc_send(sync->proxy_link, &msg, sync->proxy_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 proxy_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, ProxyLinkState *proxy_link) +{ + sync->n_mr_sections =3D 0; + sync->mr_sections =3D NULL; + + sync->proxy_link =3D proxy_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 789f39a..158d8d7 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -42,6 +42,8 @@ #include "qapi/qmp/qstring.h" #include "sysemu/sysemu.h" #include "hw/proxy/qemu-proxy.h" +#include "hw/proxy/memory-sync.h" +#include "qom/object.h" =20 static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); =20 @@ -277,6 +279,8 @@ static void init_proxy(PCIDevice *dev, char *command, b= ool need_spawn, Error **e =20 proxy_link_init_channel(pdev->proxy_link, &pdev->proxy_link->com, pdev->socket); + + configure_memory_sync(pdev->sync, pdev->proxy_link); } =20 static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) @@ -295,6 +299,7 @@ static void pci_proxy_dev_realize(PCIDevice *device, Er= ror **errp) dev->set_proxy_sock =3D set_proxy_sock; dev->get_proxy_sock =3D get_proxy_sock; dev->init_proxy =3D init_proxy; + dev->sync =3D REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); } =20 static void send_bar_access_msg(PCIProxyDev *dev, MemoryRegion *mr, diff --git a/include/hw/proxy/memory-sync.h b/include/hw/proxy/memory-sync.h new file mode 100644 index 0000000..56d7268 --- /dev/null +++ b/include/hw/proxy/memory-sync.h @@ -0,0 +1,51 @@ +/* + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef MEMORY_SYNC_H +#define MEMORY_SYNC_H + +#include + +#include "qemu/osdep.h" +#include "qom/object.h" +#include "exec/memory.h" +#include "io/proxy-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; + + ProxyLinkState *proxy_link; +} RemoteMemSync; + +void configure_memory_sync(RemoteMemSync *sync, ProxyLinkState *proxy_link= ); +void deconfigure_memory_sync(RemoteMemSync *sync); + +#endif diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index a951570..cf8e006 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -24,6 +24,7 @@ #define QEMU_PROXY_H =20 #include "io/proxy-link.h" +#include "hw/proxy/memory-sync.h" =20 #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" =20 @@ -44,6 +45,7 @@ typedef struct PCIProxyDev { =20 ProxyLinkState *proxy_link; =20 + RemoteMemSync *sync; EventNotifier intr; EventNotifier resample; =20 diff --git a/remote/remote-main.c b/remote/remote-main.c index 43fe50a..bf2a77c 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -46,6 +46,7 @@ #include "sysemu/sysemu.h" #include "block/block.h" #include "exec/memattrs.h" +#include "exec/address-spaces.h" =20 static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -174,6 +175,16 @@ static void process_msg(GIOCondition cond, ProcChannel= *chan) 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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543855; cv=none; d=zoho.com; s=zohoarc; b=cIskkAYZGyK9//3FZyMcoKLdmM/Du9oI9RVshodgmtQgCScVPAwCnfHaYA9w7PLEJPjsnsKsnRCdaBU2yjH2Qz9GUhtwPngFv4Pzr7mppj/P8eX8g8e80M1iJMxK+tPQ9RnGaKS4Ejk47eTOlfctqOa693MREBUWO7Rg/e4A2mM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543855; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hLyMTkblEUSPt1ZVApwjHOCduPKjVD3wHdaigiVLbE0=; b=WC4fLz1V8Q8FxIVJ+kTq3+C97kS2cgYpBFTJ658i2zi3JIXOnAvW0FfyVOalk3Sxku5aJjKvxkwiAyfW/qHgTv2gQLfSUlpBpWFOO6jshwTCK1JfKL5s4vsY5qkZYp5tC3mx6iOdFhAXaac91JlmSK5e/r0Acv5LC2VrKwScYVo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543855666980.536137800118; Tue, 3 Sep 2019 13:50:55 -0700 (PDT) Received: from localhost ([::1]:51244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FlO-0000Ia-1y for importer@patchew.org; Tue, 03 Sep 2019 16:50:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53480) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fa1-0007cP-UM for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZx-0000RY-Et for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:09 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57024) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZx-0000QW-7B for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:05 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXpB6053654; Tue, 3 Sep 2019 20:38:57 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2usy6n020d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:57 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcAkt025388; Tue, 3 Sep 2019 20:38:56 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2us5pha0bf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:56 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KctiR023032; Tue, 3 Sep 2019 20:38:55 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=hLyMTkblEUSPt1ZVApwjHOCduPKjVD3wHdaigiVLbE0=; b=hwsjcZXJzz4eYkgBgq11ihbE4Mjy4SFW7cGm4aRxjFVJaJG93njq9KMnoNLRiqyuvNg+ 3nDmfc09NdR3jD/oeo/uoFKUXA49N5YcLCv4Zau0W//DfKpBkCJfXtwNhBO8Bt8MtyrQ OjTjuPPr2xj6JLq75zr6bkYVaT1J0zYAMoRs7b/j5TdiqHx6Se1zzXRSG51v8ku+eN3L KO/7sxAziB7yuauNZwW7db9wzPydpG13ckYDhTccX0o94T5sgrO0PYeV+9cHVm2e5Xyv N/0ZzXU9yr9jxSl/dzhWO7X/NrurkfvuQwCyDHBqeulN3cxXPa6JGik+qYzSLjOtCCRt Lg== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:47 -0400 Message-Id: <077c0cd5b70123a5105f1f0d143dbf306815b964.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 21/45] multi-process: create IOHUB object to handle irq 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- Makefile.target | 1 + hw/proxy/Makefile.objs | 1 - hw/proxy/qemu-proxy.c | 64 +++++++++++++++++ include/hw/pci/pci_ids.h | 3 + include/hw/proxy/qemu-proxy.h | 5 ++ include/io/proxy-link.h | 8 +++ include/remote/iohub.h | 63 +++++++++++++++++ include/remote/machine.h | 2 + remote/Makefile.objs | 1 + remote/iohub.c | 159 ++++++++++++++++++++++++++++++++++++++= ++++ remote/machine.c | 15 ++++ remote/remote-main.c | 4 ++ 12 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 include/remote/iohub.h create mode 100644 remote/iohub.c diff --git a/Makefile.target b/Makefile.target index 3aa2ac8..a0c00c6 100644 --- a/Makefile.target +++ b/Makefile.target @@ -126,6 +126,7 @@ obj-y +=3D target/$(TARGET_BASE_ARCH)/ obj-y +=3D disas.o obj-$(call notempty,$(TARGET_XML_FILES)) +=3D gdbstub-xml.o obj-$(CONFIG_MPQEMU) +=3D hw/proxy/memory-sync.o +obj-$(CONFIG_MPQEMU) +=3D hw/proxy/qemu-proxy.o LIBS :=3D $(libs_cpu) $(LIBS) =20 remote-pci-tgt-obj-$(CONFIG_MPQEMU) +=3D accel/stubs/kvm-stub.o diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs index f562f5a..ca89109 100644 --- a/hw/proxy/Makefile.objs +++ b/hw/proxy/Makefile.objs @@ -1,2 +1 @@ -common-obj-$(CONFIG_MPQEMU) +=3D qemu-proxy.o common-obj-$(CONFIG_MPQEMU) +=3D proxy-lsi53c895a.o diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 158d8d7..f92d29a 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -27,6 +27,9 @@ #include #include #include +#include +#include + #include "qemu/osdep.h" #include "qapi/error.h" #include "io/proxy-link.h" @@ -44,6 +47,9 @@ #include "hw/proxy/qemu-proxy.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 void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); =20 @@ -251,6 +257,63 @@ static void pci_proxy_dev_register_types(void) =20 type_init(pci_proxy_dev_register_types) =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); + ProcMsg msg; + + if (!dev->dev_id) { + fprintf(stderr, "Cannot setup IRQFD. No dev_id\n"); + return; + } + + event_notifier_init(&dev->intr, 0); + event_notifier_init(&dev->resample, 0); + + memset(&msg, 0, sizeof(ProcMsg)); + 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); + + if (dev->dev_id) { + msg.id =3D (uint8_t *)dev->dev_id; + msg.size_id =3D strlen((char *)dev->dev_id) + 1; + } + + proxy_proc_send(dev->proxy_link, &msg, dev->proxy_link->com); + + 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 init_proxy(PCIDevice *dev, char *command, bool need_spawn, Err= or **errp) { PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); @@ -281,6 +344,7 @@ static void init_proxy(PCIDevice *dev, char *command, b= ool need_spawn, Error **e pdev->socket); =20 configure_memory_sync(pdev->sync, pdev->proxy_link); + setup_irqfd(pdev); } =20 static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) diff --git a/include/hw/pci/pci_ids.h b/include/hw/pci/pci_ids.h index 0abe27a..9cc5e28 100644 --- a/include/hw/pci/pci_ids.h +++ b/include/hw/pci/pci_ids.h @@ -191,6 +191,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 cf8e006..e73835e 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -23,8 +23,11 @@ #ifndef QEMU_PROXY_H #define QEMU_PROXY_H =20 +#include + #include "io/proxy-link.h" #include "hw/proxy/memory-sync.h" +#include "qemu/event_notifier.h" =20 #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" =20 @@ -46,6 +49,8 @@ typedef struct PCIProxyDev { ProxyLinkState *proxy_link; =20 RemoteMemSync *sync; + struct kvm_irqfd irqfd; + EventNotifier intr; EventNotifier resample; =20 diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 2c290b2..e70bf50 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -58,6 +58,8 @@ typedef struct ProxyLinkState ProxyLinkState; * 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 * */ typedef enum { @@ -67,6 +69,7 @@ typedef enum { SYNC_SYSMEM, BAR_WRITE, BAR_READ, + SET_IRQFD, MAX, } proc_cmd_t; =20 @@ -96,6 +99,10 @@ typedef struct { } bar_access_msg_t; =20 typedef struct { + int intx; +} set_irqfd_msg_t; + +typedef struct { proc_cmd_t cmd; int bytestream; size_t size; @@ -105,6 +112,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 0000000..0a799d6 --- /dev/null +++ b/include/remote/iohub.h @@ -0,0 +1,63 @@ +/* + * IO Hub for remote device + * + * Copyright 2019, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef REMOTE_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/proxy-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 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]; + QemuMutex irq_level_lock[REMOTE_IOHUB_NB_PIRQS]; +} RemoteIOHubState; + +typedef struct ResampleToken { + RemoteIOHubState *iohub; + int pirq; +} ResampleToken; + +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, ProcMsg *msg); + +#endif diff --git a/include/remote/machine.h b/include/remote/machine.h index a00732d..0a16cc6 100644 --- a/include/remote/machine.h +++ b/include/remote/machine.h @@ -30,11 +30,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/remote/Makefile.objs b/remote/Makefile.objs index 13d4c48..cbb3065 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 0000000..c292269 --- /dev/null +++ b/remote/iohub.c @@ -0,0 +1,159 @@ +/* + * Remote IO Hub + * + * Copyright 2019, Oracle and/or its affiliates. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include + +#include "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; + uint64_t val; + int pirq, s; + + pirq =3D token->pirq; + + s =3D read(event_notifier_get_fd(&iohub->resamplefds[pirq]), &val, + sizeof(uint64_t)); + + 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, ProcMsg *msg) +{ + RemMachineState *machine =3D REMOTE_MACHINE(current_machine); + RemoteIOHubState *iohub =3D machine->iohub; + ResampleToken *token; + int pirq =3D remote_iohub_map_irq(pci_dev, msg->data1.set_irqfd.intx); + + assert(msg->num_fds =3D=3D 2); + + event_notifier_init_fd(&iohub->irqfds[pirq], msg->fds[0]); + event_notifier_init_fd(&iohub->resamplefds[pirq], msg->fds[1]); + + token =3D g_malloc0(sizeof(ResampleToken)); + token->iohub =3D iohub; + token->pirq =3D pirq; + + qemu_set_fd_handler(msg->fds[1], intr_resample_handler, NULL, token); +} diff --git a/remote/machine.c b/remote/machine.c index 4ce197d..5b03167 100644 --- a/remote/machine.c +++ b/remote/machine.c @@ -40,6 +40,8 @@ #include "qemu-common.h" #include "sysemu/sysemu.h" #include "qemu/notify.h" +#include "hw/pci/pci_host.h" +#include "remote/iohub.h" =20 static NotifierList machine_init_done_notifiers =3D NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); @@ -70,6 +72,8 @@ 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 @@ -101,6 +105,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 bf2a77c..8af284e 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -47,6 +47,7 @@ #include "block/block.h" #include "exec/memattrs.h" #include "exec/address-spaces.h" +#include "remote/iohub.h" =20 static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -185,6 +186,9 @@ static void process_msg(GIOCondition cond, ProcChannel = *chan) goto finalize_loop; } break; + case SET_IRQFD: + process_set_irqfd_msg(remote_pci_dev, msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567543907; cv=none; d=zoho.com; s=zohoarc; b=afPhYfymClNvlfEwz8Ey1710icXFFkFYyYubizBZdmbsGGsp7QjVpSjxSgeA196yfj8PkXp+ZH2ENDR4lq08BFJNq1OZnpZm1ItyQihRjvSrXBtso60pQEEOEhADSAH8umI045aNZdWskifcAtdXzHtCgXSydYjYLXztcyxF9Rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567543907; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=AAj/+tREyKBkCTDYSnVjDbyD9kk7j1Ya6lqslo/cMuU=; b=orVLBg0crE370xURurht5+3aVC1NAiMp23DkD9CSiVyJbjGkSR2MrXIvxydSSUUBZ6ICEuMjg5N0giTJ50SGZdqMxpyIqDgQYNMLplWeyDZvEEdrQWz+5brNEeSEqnYjuBKUvvYelTA+dUTWNuyWBR3IeNr7vV+d/TDyjO55DlQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567543907637857.7920314936048; Tue, 3 Sep 2019 13:51:47 -0700 (PDT) Received: from localhost ([::1]:51248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FmD-0001Vh-N4 for importer@patchew.org; Tue, 03 Sep 2019 16:51:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53409) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FZz-0007Ze-Vx for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FZx-0000Ry-L5 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:07 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FZx-0000Qh-Bo for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:05 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXfki053278; Tue, 3 Sep 2019 20:39:00 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2usy6n020x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:00 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcYYE178175; Tue, 3 Sep 2019 20:38:59 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2us4wegqqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:38:59 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kcw91012411; Tue, 3 Sep 2019 20:38:58 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38: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 : in-reply-to : references; s=corp-2019-08-05; bh=AAj/+tREyKBkCTDYSnVjDbyD9kk7j1Ya6lqslo/cMuU=; b=p7YM7yoenVaYfzuDc20JekfP3TYmK10PjrVC1dIRKuhAShd25Kw3wtHMObEF6R/MuU6g xQCezRjsbu8vb0nXzdRjj7Rs3oCZVSJARK9+gAd2NwW3A6jL4RbuNu4r1h3kaH5cDhbh QcOoGUe5FPdZGDsIIIaClKnz0iI+d7PVB3e77ZQ8MrP3Y95lCCag+rKZ3j2uNRJIPdGO VZK8dGtLNpEq/v8bdWQdVqbnYHjsO2fH3Uuwr1iOLg8KgtyJrB5qW/6DrNVl5tsCbJ2W QRJDyvHOaT1S5owkb1jyVAXPZo31ozgpYuD5LB9KU0wynw169BhhkiJ/xnFHdyWO70Yq VQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:48 -0400 Message-Id: <8d7ad61c3b4d43ec73a8fd9c56b3b652b5a7da72.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 22/45] multi-process: configure remote side devices 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Add functions to configure remote devices. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- hw/proxy/qemu-proxy.c | 43 +++++++++++++++++++++++++++++++++++++++= +++- include/hw/proxy/qemu-proxy.h | 2 ++ include/io/proxy-link.h | 4 ++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index f92d29a..dea6784 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -50,8 +50,47 @@ #include "qemu/event_notifier.h" #include "sysemu/kvm.h" #include "util/event_notifier-posix.c" +#include "hw/boards.h" +#include "include/qemu/log.h" =20 static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); +static void setup_irqfd(PCIProxyDev *dev); + +static void proxy_ready(PCIDevice *dev) +{ + PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); + + setup_irqfd(pdev); +} + +static void set_remote_opts(PCIDevice *dev, QDict *qdict, unsigned int cmd) +{ + QString *qstr; + ProcMsg msg; + const char *str; + PCIProxyDev *pdev; + + pdev =3D PCI_PROXY_DEV(dev); + + qstr =3D qobject_to_json(QOBJECT(qdict)); + str =3D qstring_get_str(qstr); + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.data2 =3D (uint8_t *)str; + msg.cmd =3D cmd; + msg.bytestream =3D 1; + msg.size =3D qstring_get_length(qstr) + 1; + msg.num_fds =3D 0; + if (pdev->dev_id) { + msg.id =3D (uint8_t *)pdev->dev_id; + msg.size_id =3D strlen((char *)pdev->dev_id) + 1; + } + + proxy_proc_send(pdev->proxy_link, &msg, pdev->proxy_link->com); + + return; +} =20 static int add_argv(char *command_str, char **argv, int argc) { @@ -344,7 +383,6 @@ static void init_proxy(PCIDevice *dev, char *command, b= ool need_spawn, Error **e pdev->socket); =20 configure_memory_sync(pdev->sync, pdev->proxy_link); - setup_irqfd(pdev); } =20 static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) @@ -364,6 +402,9 @@ static void pci_proxy_dev_realize(PCIDevice *device, Er= ror **errp) dev->get_proxy_sock =3D get_proxy_sock; dev->init_proxy =3D init_proxy; dev->sync =3D REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); + + dev->set_remote_opts =3D set_remote_opts; + dev->proxy_ready =3D proxy_ready; } =20 static void send_bar_access_msg(PCIProxyDev *dev, MemoryRegion *mr, diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index e73835e..4312f9e 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -28,6 +28,8 @@ #include "io/proxy-link.h" #include "hw/proxy/memory-sync.h" #include "qemu/event_notifier.h" +#include "hw/pci/pci.h" +#include "block/qdict.h" =20 #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" =20 diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index e70bf50..13fb312 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -70,6 +70,10 @@ typedef enum { BAR_WRITE, BAR_READ, SET_IRQFD, + DEV_OPTS, + DRIVE_OPTS, + DEVICE_ADD, + DEVICE_DEL, MAX, } proc_cmd_t; =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544436; cv=none; d=zoho.com; s=zohoarc; b=cqBwwmZKax0cLUTZAWu3hmY4HOWht5Rs9nBevaHuk8G6wt7By4blqQaM0WeJ+aewIqHT3w8SLQSnfyvql4l86TuRB2lsKrVKUxeXzUJjFnCKpMb7AkVAoUYHsMRF3VGjNLiKyh3hpvl9VIMBoyJZNUWt+tIHGj0bgBcr9ef0YIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544436; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Gz7N/piIslEYXG1oWtGqf1mRnr/vyekO1Re1YGs6iXU=; b=jScvvf4RcUXsgTXlrEbicAABOqNWzXfnipLedqq8EoOhwfyF5k/qyb6WJPfUlu1Z7yeT/IPS0EherzMj2TTyy8cmkaAMUmuccQiuvVYx0FWNBn/A6vikM+8FHFg6C5bIntUmswbY6eOq+uMJfBq6AgVEvQADfCVNr8XAw0Q0OQU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 156754443691833.519967565543084; Tue, 3 Sep 2019 14:00:36 -0700 (PDT) Received: from localhost ([::1]:51404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Ful-0002SP-IC for importer@patchew.org; Tue, 03 Sep 2019 17:00:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53517) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fa3-0007f3-Ua for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fa1-0000Vz-8e for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36782) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fa0-0000Ue-QN for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:09 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXeZs066077; Tue, 3 Sep 2019 20:39:03 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2usy4u831x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:03 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcKs4188118; Tue, 3 Sep 2019 20:39:02 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2usu5118a3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:02 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83Kd011028800; Tue, 3 Sep 2019 20:39:00 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:38:59 -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 : in-reply-to : references; s=corp-2019-08-05; bh=Gz7N/piIslEYXG1oWtGqf1mRnr/vyekO1Re1YGs6iXU=; b=Ki0LXxxX5uvH/tP4uRYAmbYh0KiQd15uTFky8ZgOxGV+gkhP50/cxe22H0UEoBxPM23A +QiD7I7blCMO5xaBZg0NLRD+i5PKvr8mvCJDOA+aU0DXVY1oXjmBBmhPhEmBGCfPx9tq Om5IsyadSQB3zVTNC+z7DWmfhzHu0iSkelcXi0swaycuF5yF28YsEEe7MRUfQFHaK4xJ TPiW+VgBtKOsqaHrNKGaTMmMrGZlTraxZdH0O6143h8Qmpyar3QEsBeYePNxtj+zbrIP jHATPpTw1HlW/GbqQZJlUiWPJ2b7FsOW/CN/dT5Pss6Kty1N3GFr8aW7wfiTmLsRVMcm Tw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:49 -0400 Message-Id: <1b3e4b481f9a66ca38ed94e574e7cf894cf982cc.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 23/45] multi-process: add qdev_proxy_add to create proxy devices 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva This is handled while parsing the command line options. The parsed options are being sent to remote process as the messgaes containing JSON strings. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- v1 -> v2: - parse socket and command suboptions of drive/device commands hw/proxy/qemu-proxy.c | 3 +- include/hw/proxy/qemu-proxy.h | 7 ++ include/monitor/qdev.h | 24 ++++ qdev-monitor.c | 254 ++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 287 insertions(+), 1 deletion(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index dea6784..61808c5 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -360,7 +360,8 @@ static void init_proxy(PCIDevice *dev, char *command, b= ool need_spawn, Error **e =20 if (!pdev->managed) { if (need_spawn) { - if (!remote_spawn(pdev, command, &local_error)) { + if (remote_spawn(pdev, command, &local_error)) { + fprintf(stderr, "remote spawn failed\n"); return; } } diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 4312f9e..fb408cf 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -86,6 +86,13 @@ typedef struct PCIProxyDevClass { =20 int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp); =20 +typedef struct PCIProxyDevList { + QLIST_HEAD(, PCIProxyDev) devices; +} proxy_dev_list_t; + +extern QemuMutex proxy_list_lock; +extern proxy_dev_list_t proxy_dev_list; + void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr ad= dr, uint64_t val, unsigned size, bool memory); =20 diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index 084799e..6b5020e 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -2,6 +2,7 @@ #define MONITOR_QDEV_H =20 #include "hw/qdev-core.h" +#include "hw/proxy/qemu-proxy.h" =20 /*** monitor commands ***/ =20 @@ -9,7 +10,30 @@ void hmp_info_qtree(Monitor *mon, const QDict *qdict); void hmp_info_qdm(Monitor *mon, const QDict *qdict); void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp); =20 +DeviceState *qdev_remote_add(QemuOpts *opts, bool device, Error **errp); +void qdev_proxy_fire(void); + int qdev_device_help(QemuOpts *opts); +DeviceState *qdev_proxy_add(const char *rid, const char *id, char *bus, + char *command, int rsocket, bool managed, + Error **errp); + +struct remote_process { + int rid; + int remote_pid; + unsigned int type; + int socket; + char *command; + QemuOpts *opts; + + QLIST_ENTRY(remote_process) next; +}; + +void remote_process_register(struct remote_process *p); + +struct remote_process *get_remote_process_type(unsigned int type); +struct remote_process *get_remote_process_rid(unsigned int rid); + DeviceState *qdev_device_add(QemuOpts *opts, Error **errp); void qdev_set_id(DeviceState *dev, const char *id); =20 diff --git a/qdev-monitor.c b/qdev-monitor.c index 58222c2..d6f7572 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -34,6 +34,17 @@ #include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "migration/misc.h" +#include "hw/boards.h" +#include "hw/proxy/qemu-proxy.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qstring.h" +#include "sysemu/sysemu.h" +#include "hw/proxy/proxy-lsi53c895a.h" +#include "include/qemu/cutils.h" +#include "include/qemu/log.h" +#include "qapi/qmp/qlist.h" +#include "hw/proxy/qemu-proxy.h" +#include "io/proxy-link.h" =20 /* * Aliases were a bad idea from the start. Let's keep them @@ -46,6 +57,8 @@ typedef struct QDevAlias uint32_t arch_mask; } QDevAlias; =20 +proxy_dev_list_t proxy_dev_list; +QemuMutex proxy_list_lock; /* Please keep this table sorted by typename. */ static const QDevAlias qdev_alias_table[] =3D { { "e1000", "e1000-82540em" }, @@ -561,6 +574,247 @@ void qdev_set_id(DeviceState *dev, const char *id) } } =20 +static QLIST_HEAD(, remote_process) remote_processes; + +void remote_process_register(struct remote_process *p) +{ + QLIST_INSERT_HEAD(&remote_processes, p, next); +} + +struct remote_process *get_remote_process_rid(unsigned int rid) +{ + struct remote_process *p; + + QLIST_FOREACH(p, &remote_processes, next) { + if (rid =3D=3D p->rid) { + return p; + } + } + return NULL; +} + +struct remote_process *get_remote_process_type(unsigned int type) +{ + struct remote_process *p; + + QLIST_FOREACH(p, &remote_processes, next) { + if (type =3D=3D p->type) { + return p; + } + } + return NULL; +} + +#if defined(CONFIG_MPQEMU) + +static PCIProxyDev *get_proxy_object_rid(const char *rid) +{ + PCIProxyDev *entry; + if (!proxy_list_lock.initialized) { + QLIST_INIT(&proxy_dev_list.devices); + qemu_mutex_init(&proxy_list_lock); + } + + qemu_mutex_lock(&proxy_list_lock); + QLIST_FOREACH(entry, &proxy_dev_list.devices, next) { + if (strncmp(entry->rid, rid, strlen(entry->rid)) =3D=3D 0) { + qemu_mutex_unlock(&proxy_list_lock); + return entry; + } + } + qemu_mutex_unlock(&proxy_list_lock); + + return NULL; +} + +#define MAX_RID_LENGTH 10 +void qdev_proxy_fire(void) +{ + PCIProxyDev *entry; + + QLIST_FOREACH(entry, &proxy_dev_list.devices, next) { + if (entry->proxy_ready) { + entry->proxy_ready(PCI_DEVICE(entry)); + } + } +} + +DeviceState *qdev_proxy_add(const char *rid, const char *id, char *bus, + char *command, int rsocket, bool managed, + Error **errp) +{ + DeviceState *ds; + PCIProxyDev *pdev, *old_pdev; + QemuOpts *proxy_opts; + const char *proxy_type; + Error *local_err =3D NULL; + QDict *qdict; + const char *str; + bool need_spawn =3D false; + bool remote_exists =3D false; + + if (strlen(rid) > MAX_RID_LENGTH) { + error_setg(errp, "rid %s is too long.", rid); + return NULL; + } + + old_pdev =3D get_proxy_object_rid(rid); + if (old_pdev) { + remote_exists =3D true; + if (old_pdev->dev_id) { + if (id) { + if (strncmp(id, old_pdev->dev_id, + strlen(old_pdev->dev_id)) =3D=3D 0) { + return DEVICE(old_pdev); + } + } else { + /* check if device belongs to this proxy, use bus */ + if (bus) { + if (strncmp(bus, old_pdev->dev_id, + strlen(old_pdev->dev_id)) =3D=3D 0) { + return DEVICE(old_pdev); + } + } + } + } + } + + proxy_opts =3D qemu_opts_create(&qemu_device_opts, NULL, 0, + errp); + + /* TODO: remove hardcoded type and add approptiate type identification= . */ + proxy_type =3D TYPE_PROXY_LSI53C895A; + + qemu_opts_set_id(proxy_opts, (char *)rid); + qemu_opt_set(proxy_opts, "driver", proxy_type, &local_err); + + qdict =3D qemu_opts_to_qdict(proxy_opts, NULL); + str =3D qstring_get_str(qobject_to_json(QOBJECT(qdict))); + + ds =3D qdev_device_add(proxy_opts, &local_err); + if (!ds) { + error_setg(errp, "Could not create proxy device" + " with opts %s.", str); + qemu_opts_del(proxy_opts); + return NULL; + } + qdev_set_id(ds, qemu_opts_id(proxy_opts)); + + pdev =3D PCI_PROXY_DEV(ds); + if (!pdev) { + error_setg(errp, "qdev_device_add failed."); + qemu_opts_del(proxy_opts); + return NULL; + } + pdev->rid =3D g_strdup(rid); + if (old_pdev) { + pdev->rsocket =3D old_pdev->rsocket; + pdev->socket =3D old_pdev->socket; + pdev->remote_pid =3D old_pdev->remote_pid; + } else { + pdev->rsocket =3D managed ? rsocket : -1; + pdev->socket =3D managed ? rsocket : -1; + + } + pdev->managed =3D managed; + + /* With no libvirt, we will need to spawn. For now, every time. */ + if (!remote_exists) { + need_spawn =3D true; + } + + pdev->init_proxy(PCI_DEVICE(ds), command, need_spawn, errp); + + qemu_mutex_lock(&proxy_list_lock); + QLIST_INSERT_HEAD(&proxy_dev_list.devices, pdev, next); + qemu_mutex_unlock(&proxy_list_lock); + + qemu_opts_del(proxy_opts); + return ds; +} + +DeviceState *qdev_remote_add(QemuOpts *opts, bool device, Error **errp) +{ + PCIProxyDev *pdev =3D NULL; + DeviceState *dev; + const char *rid, *rsocket =3D NULL, *command =3D NULL; + QDict *qdict_new; + const char *id =3D NULL; + const char *driver =3D NULL; + const char *bus =3D NULL; + + if (!proxy_list_lock.initialized) { + QLIST_INIT(&proxy_dev_list.devices); + qemu_mutex_init(&proxy_list_lock); + } + + rid =3D qemu_opt_get(opts, "rid"); + if (!rid) { + error_setg(errp, "rdevice option needs rid specified."); + return NULL; + } + if (device) { + driver =3D qemu_opt_get(opts, "driver"); + /* TODO: properly identify the device class. */ + if (strncmp(driver, "lsi", 3) =3D=3D 0) { + id =3D qemu_opts_id(opts); + if (!id) { + error_setg(errp, "qdev_remote_add option needs id specifie= d."); + return NULL; + } + } + } + + rsocket =3D qemu_opt_get(opts, "socket"); + if (rsocket) { + if (strlen(rsocket) > MAX_RID_LENGTH) { + error_setg(errp, "Socket number is incorrect."); + return NULL; + } + } + /* + * TODO: verify command with known commands and on remote end. + * How else can we verify the binary we launch without libvirtd suppor= t? + */ + command =3D qemu_opt_get(opts, "command"); + if (!rsocket && !command) { + error_setg(errp, "rdevice option needs socket or command specified= ."); + return NULL; + } + + bus =3D qemu_opt_get(opts, "bus"); + dev =3D qdev_proxy_add(rid, id, (char *)bus, (char *)command, + rsocket ? atoi(rsocket) : -1, + rsocket ? true : false, errp); + if (!dev) { + error_setg(errp, "qdev_proxy_add error."); + return NULL; + } + + qdict_new =3D qemu_opts_to_qdict(opts, NULL); + + if (!qdict_new) { + error_setg(errp, "Could not parse rdevice options."); + return NULL; + } + + pdev =3D PCI_PROXY_DEV(dev); + if (!pdev->set_remote_opts) { + /* TODO: destroy proxy? */ + error_setg(errp, "set_remote_opts failed."); + return NULL; + } else { + if (id && !pdev->dev_id) { + pdev->dev_id =3D g_strdup(id); + } + pdev->set_remote_opts(PCI_DEVICE(pdev), qdict_new, + device ? DEV_OPTS : DRIVE_OPTS); + } + + return dev; +} +#endif /*defined(CONFIG_MPQEMU)*/ + DeviceState *qdev_device_add(QemuOpts *opts, Error **errp) { DeviceClass *dc; --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544322; cv=none; d=zoho.com; s=zohoarc; b=n4C9wdyxGaYAB7dEGiKfBAb/SmHEW6R6Ky307uoGNqMdGaTnPuy2wQiPH+o3DuQLWN0BnCDCArqzLFUx3cEfZQPYAD7pqkhoILbTHdPm5MctiwKS6IqZWPOINaQeFvTbBwU9PQf6avWMj4cBS3NqwMOp8K+s3Eir7frpBXp29Dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544322; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Q22KB8TATm5qt9z400d/WBN//xpURZqDM87m/OOmhks=; b=AihCnbdCVGOeyD7JwnjrhbV2wW5/asJRPro6po0pUgw7VjmN8NmaYa+a/0GRqXP3HqBDRdsz0p+Kxw4tLMTzpD7w8sOv8YM8a5RSkVD8dlY/DdIhwmVT7ZhT9BZI/jYKH4reOhboGKNqUYmVmtHFgdRS/vI6BLgMuZ5DCYYChXs= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544322288699.3673736966621; Tue, 3 Sep 2019 13:58:42 -0700 (PDT) Received: from localhost ([::1]:51362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fsn-0000Ze-5w for importer@patchew.org; Tue, 03 Sep 2019 16:58:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53526) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fa4-0007fQ-6A for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fa2-0000X1-6W for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:11 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36802) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fa1-0000Vo-RQ for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:10 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXeGR066101; Tue, 3 Sep 2019 20:39:03 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2usy4u831y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:03 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcAIb025408; Tue, 3 Sep 2019 20:39:02 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2us5pha0f5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:02 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kd1RP012515; Tue, 3 Sep 2019 20:39:01 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=Q22KB8TATm5qt9z400d/WBN//xpURZqDM87m/OOmhks=; b=NCXpOLPxYeWEi9djZlaEpgfSf342GuP7MUzLODi1kWx4wl5qbext5HJLnqbRCkf2P0UQ esePhZOcw0LyxCc7B4g+JjLYZck2gWeNm7fg2DtY/HsCQGJabKqrxrFzEHZ3dS1gB9GQ RHGqH5W4XEWRv6oHvVyZq6q1J3nRT+ln8VAuRIr/eeRiNcGbx5uqPazzUAm/I30erbBG 5HUvSzYE5onWZTIxrQv+isgRvuxX5h5aAGC/U2zNvKCHWDyCtKLFB/p+8IQTHB005CaI ujxDKk9sJXuWcdRpRucroU0Kg8q5tgVATotuCccPkzwm6s5wGWfsvYbo2cvCijYs7T9k Aw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:50 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 24/45] multi-process: remote: add setup_devices and setup_drive msg processing 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Receive by remote side the configuration messages and build the device object from JSON device descriptions. Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- v1 -> v2: - for new command line suboptions with libvirtd support, clean the options before creating drives/devices - use default pci bus/address for now include/hw/qdev-core.h | 2 + qdev-monitor.c | 2 +- remote/remote-main.c | 231 +++++++++++++++++++++++++++++++++++++++++++++= ++++ 3 files changed, 234 insertions(+), 1 deletion(-) diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 136df77..2f81894 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -360,6 +360,8 @@ BusState *qdev_get_parent_bus(DeviceState *dev); =20 DeviceState *qdev_find_recursive(BusState *bus, const char *id); =20 +DeviceState *find_device_state(const char *id, Error **errp); + /* Returns 0 to walk children, > 0 to skip walk, < 0 to terminate walk. */ typedef int (qbus_walkerfn)(BusState *bus, void *opaque); typedef int (qdev_walkerfn)(DeviceState *dev, void *opaque); diff --git a/qdev-monitor.c b/qdev-monitor.c index d6f7572..69e467e 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -1017,7 +1017,7 @@ void qmp_device_add(QDict *qdict, QObject **ret_data,= Error **errp) object_unref(OBJECT(dev)); } =20 -static DeviceState *find_device_state(const char *id, Error **errp) +DeviceState *find_device_state(const char *id, Error **errp) { Object *obj; =20 diff --git a/remote/remote-main.c b/remote/remote-main.c index 8af284e..3e92a83 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -48,6 +48,21 @@ #include "exec/memattrs.h" #include "exec/address-spaces.h" #include "remote/iohub.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qobject.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "monitor/qdev.h" +#include "qapi/qmp/qdict.h" +#include "sysemu/sysemu.h" +#include "sysemu/blockdev.h" +#include "block/block.h" +#include "qapi/qmp/qstring.h" +#include "hw/qdev-properties.h" +#include "hw/scsi/scsi.h" +#include "block/qdict.h" +#include "qapi/qmp/qlist.h" +#include "qemu/log.h" =20 static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -138,6 +153,200 @@ fail: PUT_REMOTE_WAIT(wait); } =20 +static void process_device_add_msg(ProcMsg *msg) +{ + Error *local_err =3D NULL; + const char *json =3D (const char *)msg->data2; + int wait =3D msg->fds[0]; + QObject *qobj =3D NULL; + QDict *qdict =3D NULL; + QemuOpts *opts =3D NULL; + + qobj =3D qobject_from_json(json, &local_err); + if (local_err) { + goto fail; + } + + qdict =3D qobject_to(QDict, qobj); + assert(qdict); + + opts =3D qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_= err); + if (local_err) { + goto fail; + } + + (void)qdev_device_add(opts, &local_err); + if (local_err) { + goto fail; + } + +fail: + if (local_err) { + error_report_err(local_err); + /* TODO: communicate the exact error message to proxy */ + } + + notify_proxy(wait, 1); + + PUT_REMOTE_WAIT(wait); +} + +static void process_device_del_msg(ProcMsg *msg) +{ + Error *local_err =3D NULL; + DeviceState *dev =3D NULL; + const char *json =3D (const char *)msg->data2; + int wait =3D msg->fds[0]; + QObject *qobj =3D NULL; + QDict *qdict =3D NULL; + const char *id; + + qobj =3D qobject_from_json(json, &local_err); + if (local_err) { + goto fail; + } + + qdict =3D qobject_to(QDict, qobj); + assert(qdict); + + id =3D qdict_get_try_str(qdict, "id"); + assert(id); + + dev =3D find_device_state(id, &local_err); + if (local_err) { + goto fail; + } + + if (dev) { + qdev_unplug(dev, &local_err); + } + +fail: + if (local_err) { + error_report_err(local_err); + /* TODO: communicate the exact error message to proxy */ + } + + notify_proxy(wait, 1); + + PUT_REMOTE_WAIT(wait); +} + +static int init_drive(QDict *rqdict, Error **errp) +{ + QemuOpts *opts; + Error *local_error =3D NULL; + + if (rqdict !=3D NULL && qdict_size(rqdict) > 0) { + opts =3D qemu_opts_from_qdict(&qemu_drive_opts, + rqdict, &local_error); + if (!opts) { + error_propagate(errp, local_error); + return -EINVAL; + } + } else { + return -EINVAL; + } + + qemu_opt_unset(opts, "rid"); + qemu_opt_unset(opts, "socket"); + qemu_opt_unset(opts, "remote"); + qemu_opt_unset(opts, "command"); + + if (drive_new(opts, IF_IDE, &local_error) =3D=3D NULL) { + error_propagate(errp, local_error); + return -EINVAL; + } + + return 0; +} + +static int setup_drive(ProcMsg *msg, Error **errp) +{ + QObject *obj; + QDict *qdict; + QString *qstr; + Error *local_error =3D NULL; + int rc =3D -EINVAL; + + if (!msg->data2) { + return rc; + } + + qstr =3D qstring_from_str((char *)msg->data2); + obj =3D qobject_from_json(qstring_get_str(qstr), &local_error); + if (!obj) { + error_propagate(errp, local_error); + return rc; + } + + qdict =3D qobject_to(QDict, obj); + if (!qdict) { + return rc; + } + + if (init_drive(qdict, &local_error)) { + error_setg(errp, "init_drive failed in setup_drive."); + return rc; + } + + return 0; +} + +static int setup_device(ProcMsg *msg, Error **errp) +{ + QObject *obj; + QDict *qdict; + QString *qstr; + QemuOpts *opts; + DeviceState *dev =3D NULL; + int rc =3D -EINVAL; + Error *local_error =3D NULL; + + if (!msg->data2) { + return rc; + } + + qstr =3D qstring_from_str((char *)msg->data2); + obj =3D qobject_from_json(qstring_get_str(qstr), &local_error); + if (!obj) { + error_setg(errp, "Could not get object!"); + return rc; + } + + qdict =3D qobject_to(QDict, obj); + if (!qdict) { + return rc; + } + + g_assert(qdict_size(qdict) > 1); + + opts =3D qemu_opts_from_qdict(&qemu_device_opts, qdict, &local_error); + qemu_opt_unset(opts, "rid"); + qemu_opt_unset(opts, "socket"); + qemu_opt_unset(opts, "remote"); + qemu_opt_unset(opts, "command"); + /* + * TODO: use the bus and addr from the device options. For now + * we use default value. + */ + qemu_opt_unset(opts, "bus"); + qemu_opt_unset(opts, "addr"); + + dev =3D qdev_device_add(opts, &local_error); + if (!dev) { + error_setg(errp, "Could not add device %s.", + qstring_get_str(qobject_to_json(QOBJECT(qdict)))); + return rc; + } + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + remote_pci_dev =3D PCI_DEVICE(dev); + } + qemu_opts_del(opts); + + return 0; +} + static void process_msg(GIOCondition cond, ProcChannel *chan) { ProcMsg *msg =3D NULL; @@ -183,11 +392,33 @@ static void process_msg(GIOCondition cond, ProcChanne= l *chan) */ remote_sysmem_reconfig(msg, &err); if (err) { + error_report_err(err); goto finalize_loop; } break; case SET_IRQFD: process_set_irqfd_msg(remote_pci_dev, msg); + qdev_machine_creation_done(); + qemu_mutex_lock_iothread(); + qemu_run_machine_init_done_notifiers(); + qemu_mutex_unlock_iothread(); + + break; + case DRIVE_OPTS: + if (setup_drive(msg, &err)) { + error_report_err(err); + } + break; + case DEV_OPTS: + if (setup_device(msg, &err)) { + error_report_err(err); + } + break; + case DEVICE_ADD: + process_device_add_msg(msg); + break; + case DEVICE_DEL: + process_device_del_msg(msg); break; default: error_setg(&err, "Unknown command"); --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544030; cv=none; d=zoho.com; s=zohoarc; b=Y1cO5dfmaP2IWz25qMX/9L6YfDvqIHTMoPIr5kl0qrC3ao57nyjG8x+AhoHSVxESqhmKrKzOem3BHFRX5QzO7+fabbjZxjxP/drgqMk5EoG3H8+Bc7+WerIrsw79SrTwTeQDQY8woDt2BuRt47FLu9j1sCoZS7K7/SkGIuh8StA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544030; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FIc3D2OO49s7HejpuvfBf2ok/YTl9KnG+s8fPQomsd8=; b=Cq4k4hsGZ8Ruts1/Oo8YgSf3/KWGFwux3rTZhGRyTdR2646MLXNNtjicNj9AYpqX35gYnAsbdtRStt2Jw8RuIxXV8sGaRSQH4rxYcXjwLWbrz2gAKzb0v72Gloxmy51yp+NEFDkY4V5jbvD/atWGuyrx0dhgbePpHhs6al3KC9c= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544030440967.956173314225; Tue, 3 Sep 2019 13:53:50 -0700 (PDT) Received: from localhost ([::1]:51296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FoC-0003yN-WE for importer@patchew.org; Tue, 03 Sep 2019 16:53:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53535) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fa4-0007fw-Gp for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fa3-0000Xy-DP for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:12 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36830) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fa3-0000XN-5Y for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:11 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KYLB6066648; Tue, 3 Sep 2019 20:39:04 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2usy4u8326-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:04 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcXao178144; Tue, 3 Sep 2019 20:39:04 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2us4wegqug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:04 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kd32w012649; Tue, 3 Sep 2019 20:39:03 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:02 -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 : in-reply-to : references; s=corp-2019-08-05; bh=FIc3D2OO49s7HejpuvfBf2ok/YTl9KnG+s8fPQomsd8=; b=KcEkgLf4I8+vaPCM+sCbQMpONhaYv8IiNPrIDe67VXK7x75n/41UsCtwkvhaqnez6sHu bpLN/pppUMUm11P/z6B+OP87T/myYFKDv6VAdI3X++4GvloDDzdCzy+Lk0wnt9AjxKMc PspIKmyqrtjZGm3PJ8M2ccGB52UTox2+pwJEsDTDmFjmOmmI03rJoYu+O4bfRd0xwuXS N37NUKv8zTKevBbNR0wZwgiA2BDlMZKf+MTeF6LmRuV7MFbSdLiwmK7LiDgdTm4sK7tw DtfskEmzvyYfL+fWFxLmcb/Nfu7SUBKJkS6l6Os7NI5AOjiFc3Taij3IuK+P9CrB79xg 0A== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:51 -0400 Message-Id: <117550f9615ce46ace1721b7d98a6bd3c02ab759.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 25/45] multi-process: remote: use fd for socket from parent process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- remote/remote-main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/remote/remote-main.c b/remote/remote-main.c index 3e92a83..e284d5f 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -63,6 +63,7 @@ #include "block/qdict.h" #include "qapi/qmp/qlist.h" #include "qemu/log.h" +#include "qemu/cutils.h" =20 static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -439,6 +440,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 @@ -461,7 +463,13 @@ int main(int argc, char *argv[]) return -1; } =20 - proxy_link_init_channel(proxy_link, &proxy_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; + } + + proxy_link_init_channel(proxy_link, &proxy_link->com, fd); proxy_link_set_callback(proxy_link, process_msg); =20 start_handler(proxy_link); --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544603; cv=none; d=zoho.com; s=zohoarc; b=jVLvr+Hk5dF4iMIJJLozUxOu6MlMXFx1lTUpsRhZb9N1M3xhs3GkalSZOHnlc7HlWjQIgGKFtFvl3S4RP3J2DRMBRVgN8m+et6jj0F6rpOUPGJ6K7n4I5n/eNfLhbnSiYNMsx9VW8r0wRcULi/zFG34SJX4T0etxSG1fDGPogv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544603; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ysu5jn80UX+ZgnoT6SpiYiJ+o+4SFIvcyo89drIYcac=; b=kVnbfG5RTeifej+JRh95M1niGSLdV4K5iAUPkbRmB7zqMgBD8rQvucHUscO5EQGo0kx2a0YSnCqKnm0fXPyj6uYCQM3NWSDx5MHBb0NRENfSCvZTQcYoIqi8ylD4yxhbrswk9a3SF5noCJbHA8Aa2B6J2Hl5ZHsl7FNtk+nvy2g= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544603793503.40828726561654; Tue, 3 Sep 2019 14:03:23 -0700 (PDT) Received: from localhost ([::1]:51420 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FxR-0004CF-M6 for importer@patchew.org; Tue, 03 Sep 2019 17:03:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53562) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fa6-0007ia-8p for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fa5-0000ZD-6k for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:14 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fa4-0000Yh-Ut for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:13 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXnO7062420; Tue, 3 Sep 2019 20:39:06 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2usy66r2gg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:06 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcabZ178298; Tue, 3 Sep 2019 20:39:05 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2us4wegqvm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:05 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kd4ng012751; Tue, 3 Sep 2019 20:39:04 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=Ysu5jn80UX+ZgnoT6SpiYiJ+o+4SFIvcyo89drIYcac=; b=es5N8pgbaH6W1OgB0CwTOtuWMf77eJuEbRnweWOqhA7oKixq3eACE0Z3yYLpOt56Momi 8Z7w/Aiym1fsasSeyyI9N8pIOQwNwLi3O/iMBWrHkU2VkIxzvDknUPeOdKdrjQ52wsTd ClzncdbEmr68XrmtyK7dUQ2LdecZo9wp1A6wRw3ZbVtmau1oRYgj7MvFhvwGD5wNxRQC Bn5i4PthSdhnRGXMCHjZt/aLQ0H0vAxLt+FAzouXJO4twFQTg6xwDf6wIH+lXzFJtm4C LBtXkzeHjUgD5IxBQWMU82u2We+u321N5YRuukuOdGxdjOFVxdIqA/PwrYfrzXSJycyy Vw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:52 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 26/45] multi-process: remote: add create_done condition 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Do not allow BAR,MMIO handlers and irq setup to run before the configuration of the devices completes. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- remote/remote-main.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/remote/remote-main.c b/remote/remote-main.c index e284d5f..0c0e085 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -67,6 +67,7 @@ =20 static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; +bool create_done; =20 static void process_config_write(ProcMsg *msg) { @@ -369,21 +370,31 @@ static void process_msg(GIOCondition cond, ProcChanne= l *chan) case INIT: break; case CONF_WRITE: - process_config_write(msg); + if (create_done) { + process_config_write(msg); + } + break; case CONF_READ: - process_config_read(msg); + if (create_done) { + process_config_read(msg); + } + break; case BAR_WRITE: - process_bar_write(msg, &err); - if (err) { - goto finalize_loop; + if (create_done) { + process_bar_write(msg, &err); + if (err) { + error_report_err(err); + } } break; case BAR_READ: - process_bar_read(msg, &err); - if (err) { - goto finalize_loop; + if (create_done) { + process_bar_read(msg, &err); + if (err) { + error_report_err(err); + } } break; case SYNC_SYSMEM: @@ -403,7 +414,7 @@ static void process_msg(GIOCondition cond, ProcChannel = *chan) qemu_mutex_lock_iothread(); qemu_run_machine_init_done_notifiers(); qemu_mutex_unlock_iothread(); - + create_done =3D true; break; case DRIVE_OPTS: if (setup_drive(msg, &err)) { --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544210; cv=none; d=zoho.com; s=zohoarc; b=V0vORDNZcC5EE22sSj9e/OZNsVpdWbfuLjMr5RYr7BJbnZ+U4Ps2vBBnoHvNojEKUno2+M7rG3j91fPB2x2JevUvZ1VzklCVNkgcKGQqCKoQI+lky6ZEb7eZUe4EK12JlhmYjTw8vIcc85G19qmDNl0EY4tMPuaPCk2WQwLAfKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544210; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gvJSWIvciRUxRYvEzAMzohW12BYBfaOdbJ+gua1g6+4=; b=WyVGRH0s0egpS//Q2YhmYpj1GQt6/qQVDsw2xBnfOd9RHAwbAHzgARfSEDBfKzPjkDIYGI5beZNRGyGZ7CoZhIuztPaI9MSpg5HiL9XRQtLGeHMCqFgW4AdCR19d5xEccc9bZ+kiW6pWtag4I/RHAd6N2SurLNiHt/GfVSYz64M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544210451100.89677687206779; Tue, 3 Sep 2019 13:56:50 -0700 (PDT) Received: from localhost ([::1]:51348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fr6-0007Z7-Qa for importer@patchew.org; Tue, 03 Sep 2019 16:56:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53561) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fa6-0007iJ-5y for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fa4-0000Yy-Qo for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:13 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:36854) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fa4-0000YD-Ik for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:12 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXiFf066125; Tue, 3 Sep 2019 20:39:07 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2usy4u832a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:07 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc97C025274; Tue, 3 Sep 2019 20:39:06 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2us5pha0gx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:06 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83Kd6EQ023193; Tue, 3 Sep 2019 20:39:06 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:05 -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 : in-reply-to : references; s=corp-2019-08-05; bh=gvJSWIvciRUxRYvEzAMzohW12BYBfaOdbJ+gua1g6+4=; b=Xy/Vt7gNmbdwpqYboX89tJTi3zdK809NlRq2cx34i1pmQURS0z2vHLktfY5rswSjf95b 4yZ2RUb+n7OIqoTxiCWkMsM88tfMkC+A9+5GwSvKTC6Gl3nGXHBhGhZTzglW6azX77SI k2YmLycElFOi+Af4CJUcTG22cz9ML0NnpfrFJ/tH10S/IXvzd2w1+NTX9dnqoj/ebz71 2s5X/YpLGwAQphEcqda+iazL3lWMHvmeUZcvzR5JJBg3g7ZLCVLKh2SGWOM9dkA4Ys0E YxUtbEX59IFpWVUO1qNXF2Kxh+8TOY+zC/D0U1xh6uzcF09Y9BX1jpiAW+7xnOSTHu08 8w== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:53 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 27/45] multi-process: add processing of remote drive and device command line 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Add processing of command line options drive and device. After remote devices are created along with their proxies, signal the proxies to finish the configuration steps. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- v1 -> v2: - change command line option for remote process drive/device to use existing -drive/-device options - process drive and device options only after non-remote devices and drives are added vl.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 76 insertions(+) diff --git a/vl.c b/vl.c index b426b32..f7dae56 100644 --- a/vl.c +++ b/vl.c @@ -32,6 +32,11 @@ #include "qemu/uuid.h" #include "sysemu/seccomp.h" #include "sysemu/tcg.h" +#include "qapi/qmp/qdict.h" +#include "block/qdict.h" +#include "qapi/qmp/qstring.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qlist.h" =20 #ifdef CONFIG_SDL #if defined(__APPLE__) || defined(main) @@ -1135,11 +1140,43 @@ static int cleanup_add_fd(void *opaque, QemuOpts *o= pts, Error **errp) #define MTD_OPTS "" #define SD_OPTS "" =20 +#if defined(CONFIG_MPQEMU) +static int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + + dev =3D qdev_remote_add(opts, false /* this is drive */, errp); + if (!dev) { + error_setg(errp, "qdev_remote_add failed for drive."); + return -1; + } + object_unref(OBJECT(dev)); + return 0; +} +#endif + +static int pass; + static int drive_init_func(void *opaque, QemuOpts *opts, Error **errp) { BlockInterfaceType *block_default_type =3D opaque; =20 +#if defined(CONFIG_MPQEMU) + const char *remote; + + remote =3D qemu_opt_get(opts, "remote"); + if (pass && remote) { + return rdrive_init_func(opaque, opts, errp); + } else { + if (!remote && !pass) { + drive_new(opts, *block_default_type, errp); + } + } + + return 0; +#else return drive_new(opts, *block_default_type, errp) =3D=3D NULL; +#endif } =20 static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **err= p) @@ -2184,10 +2221,35 @@ static int device_help_func(void *opaque, QemuOpts = *opts, Error **errp) return qdev_device_help(opts); } =20 +#if defined(CONFIG_MPQEMU) +static int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + + dev =3D qdev_remote_add(opts, true /* this is device */, errp); + if (!dev) { + error_setg(errp, "qdev_remote_add failed for device."); + return -1; + } + object_unref(OBJECT(dev)); + return 0; +} +#endif + static int device_init_func(void *opaque, QemuOpts *opts, Error **errp) { DeviceState *dev; =20 +#if defined(CONFIG_MPQEMU) + const char *remote; + + remote =3D qemu_opt_get(opts, "remote"); + if (remote) { + /* This will be a remote process */ + return rdevice_init_func(opaque, opts, errp); + } +#endif + dev =3D qdev_device_add(opts, errp); if (!dev) { return -1; @@ -4367,6 +4429,17 @@ int main(int argc, char **argv, char **envp) /* Check if IGD GFX passthrough. */ igd_gfx_passthru(); =20 +#if defined(CONFIG_MPQEMU) + /* + * Parse the list for remote drives here as we launch PCIProxyDev here= and + * need PCI host initialized. As a TODO: could defer init of PCIProxyD= ev instead. + */ + if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, + &machine_class->block_default_type, &error_fatal= )) { + exit(0); + } +#endif + /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); qemu_opts_foreach(qemu_find_opts("device"), @@ -4424,6 +4497,9 @@ int main(int argc, char **argv, char **envp) qemu_register_reset(qbus_reset_all_fn, sysbus_get_default()); qemu_run_machine_init_done_notifiers(); =20 +#if defined(CONFIG_MPQEMU) + qdev_proxy_fire(); +#endif if (rom_check_and_register_reset() !=3D 0) { error_report("rom check and register reset failed"); exit(1); --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545277; cv=none; d=zoho.com; s=zohoarc; b=S+7OVJmOP9NVal0eFAU2pn+iGdYGdHWVUbBWLIPK5Gzx78SRQ6skZLqJzTOE9LpPlnIb7c9SdeQvLeeIqX+qovZoV/b7gxsIspu/8S6Tf0dmvFyM+L0mSV1XXIDc9QTAe3M/UQeCyaGctxX4zMyaY+N/Ydcm7OUfmtaw8k4sEZw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545277; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7Wh3yhe6Bpe43/29d3VnRo50DQgpolFEQ9cXqoSsgFY=; b=fM35DsAZN3GNCrsOk/ZTrLVIOpX8qS39mgKageYb1uwaq1i2z9GURU44CbNkX77TisOEYw7tmMR+RrUh7eDeYCETDxylAE1gs9abOLL9Q3B/t8Xk56BviW3GFICQI/1N54Ob6h1ea9jS23KwT/DQZfDIKvw0cYne3x/a0Ler9Oc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545277546110.16977349776994; Tue, 3 Sep 2019 14:14:37 -0700 (PDT) Received: from localhost ([::1]:51596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G8J-00060K-Uj for importer@patchew.org; Tue, 03 Sep 2019 17:14:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53605) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaB-0007ou-Tp for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaA-0000cZ-Jl for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:19 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60264) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaA-0000c0-Aj for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:18 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXlhJ062406; Tue, 3 Sep 2019 20:39:11 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2usy66r2gu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:11 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc9Ai025311; Tue, 3 Sep 2019 20:39:10 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2us5pha0jb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:10 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kd7QE017733; Tue, 3 Sep 2019 20:39:08 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:07 -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 : in-reply-to : references; s=corp-2019-08-05; bh=7Wh3yhe6Bpe43/29d3VnRo50DQgpolFEQ9cXqoSsgFY=; b=V0FaXdLJwp+v5PWI7t47FSP9CgfvBMKSpyAs03PIeTonXs6hF5r6x92Fiz59QwEKvTJA vPfZQ9wwW6mEqmc68nDk3B+FDZRxYToaIwDFVLiMj0sJGHjSfaBlN9KQ8KoRQ2Fu/9V1 0+GV7YJw2hD5xhkYPNmt2IFr0u8OXQZiq5D0NZhiyDwpBPxI0rwflx+u3c1o7cAvtq/H o8HM9MVm2ooHkhJMKEU5v8dhiRw5l3uTNVS2DnUN7kykk3fTKiLqzQxBWvbu0lh9CQcn hHvEca6+ZxKiqLL6TPjt97GPfMxP3KlGsf/GL5eVmCKbJTsb3RwDI7DnRoTlh84RCt6y +Q== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:54 -0400 Message-Id: <53b203319b96293b03adecc00b8d758fb4cc9c8c.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 28/45] multi-process: Introduce build flags to separate remote process code 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- New patch in v3 Makefile.target | 4 ++++ rules.mak | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile.target b/Makefile.target index a0c00c6..ac545fc 100644 --- a/Makefile.target +++ b/Makefile.target @@ -256,6 +256,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 967295d..22e0c36 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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545017; cv=none; d=zoho.com; s=zohoarc; b=Q1rn57mqj59OZHqJGyE7Ljxpu1F7JgFlPxIsIWtuIWtu5HdfTel1gc878wmsyB97q2sNzAlA7HYxjZq+fYYT9ZqiVtMmVXov8Rva2Pj8/F0V9wSf4izzKIiDiKuz0mpZMr3sKEFNfJO/8+bp+fFoQsHJjXPpBTlGAq5o5ERqIFY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545017; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oZ0s9yF6gcYfk3LvvZg62OIK3EiJMIcidaiEEw1KttY=; b=iXstNGHT47UUTkRjIJG9+a96njzb93oqRk7y6rQouQC1hsKmTXWsiKmH2IwkVnp27LnTaM5wNbRGQUT+nw3af7JmgjPTJ3dr4gBjUPyhY7BcL8JXB8XjTcQdCul6ZPQBb0hjzvmerWizioP5LFOCrHG7l7VQOu+fuUV7jyvcJz8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545017519794.5703104580786; Tue, 3 Sep 2019 14:10:17 -0700 (PDT) Received: from localhost ([::1]:51536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G47-0001dD-Ll for importer@patchew.org; Tue, 03 Sep 2019 17:10:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53599) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaB-0007oX-Cp for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fa9-0000bs-DA for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:19 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37054) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fa9-0000b7-4d for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:17 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXkFY066132; Tue, 3 Sep 2019 20:39:12 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2usy4u832n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:12 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcKYZ188116; Tue, 3 Sep 2019 20:39:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2usu5118dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:11 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83Kd9KM017745; Tue, 3 Sep 2019 20:39:09 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=oZ0s9yF6gcYfk3LvvZg62OIK3EiJMIcidaiEEw1KttY=; b=QuD43jlNxaDltMTQjOYeEMxoAMQ/3+8qfUw4EdkL2l4poUKu2B9txAtQTc5pbXNlQoYB JIE9QcCohHjCOOIpnnSYqDgbdic0UGGJW7xILQV/Dpnodm4+U+bCzfQLkZmM52+2JvM6 vKk5rjFS9i6x9qXVVgyvsyO8JIY31rOpjTWKihTYPe8eQRsX6qtq6w6Zwq3qsgPRx65b FuZ7r8mVLIUSIsBrfO9JO2seF8qVsOYO9k2bni+rDGwqbqT7/kML6Cm73h1XyIvlIz6U Zj2jY8Ox9eQIo6czj+qwy9duYVk3O1/7YeCr/j+p6woZsnA4rWgRz6ozinQ3NpfRNl0T YQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:55 -0400 Message-Id: <44c1faab6ab54f4ff06d7ff62e3aef9fd2a0f2c7.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 29/45] multi-process: refractor vl.c code to re-use in remote 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- New patch in v3 Makefile.objs | 2 + remote/Makefile.objs | 1 + vl-parse.c | 157 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ vl.c | 150 +----------------------------------------------- vl.h | 54 ++++++++++++++++++ 5 files changed, 215 insertions(+), 149 deletions(-) create mode 100644 vl-parse.c create mode 100644 vl.h diff --git a/Makefile.objs b/Makefile.objs index 0668509..f817cf6 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -104,6 +104,8 @@ qemu-seccomp.o-libs :=3D $(SECCOMP_LIBS) =20 common-obj-$(CONFIG_FDT) +=3D device_tree.o =20 +common-obj-y +=3D vl-parse.o + ###################################################################### # qapi =20 diff --git a/remote/Makefile.objs b/remote/Makefile.objs index cbb3065..c1349ad 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -2,3 +2,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 +remote-pci-obj-$(CONFIG_MPQEMU) +=3D../vl-parse.o diff --git a/vl-parse.c b/vl-parse.c new file mode 100644 index 0000000..d3716d1 --- /dev/null +++ b/vl-parse.c @@ -0,0 +1,157 @@ +/* + * 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/units.h" +#include "qapi/error.h" +#include "qemu/cutils.h" +#include "qemu/error-report.h" +#include "hw/qdev.h" +#include "monitor/qdev.h" +#include "sysemu/sysemu.h" +#include "qemu/option.h" +#include "qemu-options.h" +#include "sysemu/blockdev.h" + +#include "chardev/char.h" +#include "monitor/monitor.h" +#include "qemu/config-file.h" + +#include "sysemu/arch_init.h" + +#include "vl.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; + if (!popt) { + error_report("No valide qemu_options"); + } + for (;;) { + if (!popt->name) { + error_report("invalid option*"); + exit(1); + popt++; + continue; + } + if (!strcmp(popt->name, r + 1)) { + break; + } + popt++; + } + if (popt->flags & HAS_ARG) { + if (optind >=3D argc) { + error_report("optind %d, argc %d", optind, 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; + + if (!drive_new(opts, *block_default_type, errp)) { + error_report_err(*errp); + } + + return 0; +} + +#if defined(CONFIG_MPQEMU) +int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + + dev =3D qdev_remote_add(opts, false /* this is drive */, errp); + if (!dev) { + error_setg(errp, "qdev_remote_add failed for drive."); + return -1; + } + object_unref(OBJECT(dev)); + return 0; +} +#endif + +#if defined(CONFIG_MPQEMU) +int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + + dev =3D qdev_remote_add(opts, true /* this is device */, errp); + if (!dev) { + error_setg(errp, "qdev_remote_add failed for device."); + return -1; + } + return 0; +} +#endif + +int device_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + const char *remote =3D NULL; + + remote =3D qemu_opt_get(opts, "rid"); + if (remote) { + return 0; + } + + dev =3D qdev_device_add(opts, errp); + if (!dev) { + return -1; + } + object_unref(OBJECT(dev)); + return 0; +} diff --git a/vl.c b/vl.c index f7dae56..dc2558c 100644 --- a/vl.c +++ b/vl.c @@ -37,6 +37,7 @@ #include "qapi/qmp/qstring.h" #include "qapi/qmp/qjson.h" #include "qapi/qmp/qlist.h" +#include "vl.h" =20 #ifdef CONFIG_SDL #if defined(__APPLE__) || defined(main) @@ -1133,52 +1134,6 @@ static int cleanup_add_fd(void *opaque, QemuOpts *op= ts, 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 "" - -#if defined(CONFIG_MPQEMU) -static int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - DeviceState *dev; - - dev =3D qdev_remote_add(opts, false /* this is drive */, errp); - if (!dev) { - error_setg(errp, "qdev_remote_add failed for drive."); - return -1; - } - object_unref(OBJECT(dev)); - return 0; -} -#endif - -static int pass; - -static int drive_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - BlockInterfaceType *block_default_type =3D opaque; - -#if defined(CONFIG_MPQEMU) - const char *remote; - - remote =3D qemu_opt_get(opts, "remote"); - if (pass && remote) { - return rdrive_init_func(opaque, opts, errp); - } else { - if (!remote && !pass) { - drive_new(opts, *block_default_type, errp); - } - } - - return 0; -#else - return drive_new(opts, *block_default_type, errp) =3D=3D NULL; -#endif -} - static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **err= p) { if (qemu_opt_get(opts, "snapshot") =3D=3D NULL) { @@ -1860,21 +1815,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 */ @@ -2221,43 +2161,6 @@ static int device_help_func(void *opaque, QemuOpts *= opts, Error **errp) return qdev_device_help(opts); } =20 -#if defined(CONFIG_MPQEMU) -static int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - DeviceState *dev; - - dev =3D qdev_remote_add(opts, true /* this is device */, errp); - if (!dev) { - error_setg(errp, "qdev_remote_add failed for device."); - return -1; - } - object_unref(OBJECT(dev)); - return 0; -} -#endif - -static int device_init_func(void *opaque, QemuOpts *opts, Error **errp) -{ - DeviceState *dev; - -#if defined(CONFIG_MPQEMU) - const char *remote; - - remote =3D qemu_opt_get(opts, "remote"); - if (remote) { - /* This will be a remote process */ - return rdevice_init_func(opaque, opts, errp); - } -#endif - - dev =3D qdev_device_add(opts, errp); - if (!dev) { - return -1; - } - object_unref(OBJECT(dev)); - return 0; -} - static int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp) { Error *local_err =3D NULL; @@ -2587,46 +2490,6 @@ static void qemu_run_machine_init_done_notifiers(voi= d) notifier_list_notify(&machine_init_done_notifiers, NULL); } =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); @@ -4429,17 +4292,6 @@ int main(int argc, char **argv, char **envp) /* Check if IGD GFX passthrough. */ igd_gfx_passthru(); =20 -#if defined(CONFIG_MPQEMU) - /* - * Parse the list for remote drives here as we launch PCIProxyDev here= and - * need PCI host initialized. As a TODO: could defer init of PCIProxyD= ev instead. - */ - if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, - &machine_class->block_default_type, &error_fatal= )) { - exit(0); - } -#endif - /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); qemu_opts_foreach(qemu_find_opts("device"), diff --git a/vl.h b/vl.h new file mode 100644 index 0000000..8c40fed --- /dev/null +++ b/vl.h @@ -0,0 +1,54 @@ +/* + * 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. + */ + +#ifndef VL_H +#define VL_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); +int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp); +int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp); + +#endif /* VL_H */ + --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544754; cv=none; d=zoho.com; s=zohoarc; b=fE9GKlSc2VEiXLl3BmIYODY0yy4fHb1vhH75hhML+8xF7qaCzHHSXFAFoV+97l/ELXKpVUpO1YlkVhjpltsNYAlH1Fkusb7aHW0PgVKluqZ+vsrktMoRF1yluvbhCkB+ZwmrtKazrtrBasDthyZNfQOGIe5IUIS37SlX2KZgUhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544754; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=yBQRFrRvpsAiZU9EBQzZNbES+5o+LwhcwXRGcje/IzY=; b=itSd0MtPZt8215jeeAWKRxtBvsU5pl1plbKrVqDOo6N12/71WJTLJAAK33BoQrJmdjaBgwZ9Wh/W7WrbmZd525eJOHK1A2bS7dTWd3oNpjtiSg/Pr00fRj2dx7PPi/ACXXxoTfJyEpuhCTAQPI3PfosmE9hOTXrsnu1KgsMH75o= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544754410764.5593879279727; Tue, 3 Sep 2019 14:05:54 -0700 (PDT) Received: from localhost ([::1]:51492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Fzt-0006GB-3z for importer@patchew.org; Tue, 03 Sep 2019 17:05:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53607) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaB-0007pA-QJ for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaA-0000cn-T2 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:19 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57204) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaA-0000cN-N7 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:18 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXebb053258; Tue, 3 Sep 2019 20:39:12 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2usy6n021d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:11 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc9Mt025303; Tue, 3 Sep 2019 20:39:11 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2us5pha0kp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:11 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KdA7g023899; Tue, 3 Sep 2019 20:39:11 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=yBQRFrRvpsAiZU9EBQzZNbES+5o+LwhcwXRGcje/IzY=; b=iVuTcef2/ZxoGdDvVBH3ECz6QPGAT0O1cLdrx+WElLyR/e21x+CZ4/d3rL2QnhBO4c6Y 9ZZ1Ms5o/ClhfUy2Cju4NBU4lxGUpSMGdSxsQBVDmYU3P5H9KxPHGJ1XT6Cggpy0R8gP Gnleij1KvYssnJ3F4c0SY/Zm/y6w/09S+ZQIBW+59DVlGszZgtxCTfkDbwVbyFL5k1ag fdDT7LFU/K//Uyra7JBkauPA8ZkT5izQ0AqSsWANyEQElHzmvHQyRTPFb2wJMTfWyhtt iro0inBQgM4dSuHkCro3hOs+Bg8xLWEevgUottwuzfklJhq/L0W3/fpOlhWWb8HkDw8R Uw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:56 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 30/45] multi-process: add remote option 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- New patch in v3 qemu-options.hx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 9621e93..e2dca3d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -27,6 +27,27 @@ STEXI Display version information and exit ETEXI =20 +DEF("remote", HAS_ARG, QEMU_OPTION_remote, + "-remote socket[,prop[=3Dvalue][,...]]\n" + " add remote process\n" + " prop=3Dvalue,... sets driver properties\n" + " use '-remote help' to print all possible properties\n= ", + QEMU_ARCH_ALL) +STEXI +@table @option +@item rid +@findex -rid +remote id +@item socket +@findex -socket +Remote process socket +@item command +@findex -command +Remote process command. + +@end table +ETEXI + DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ "-machine [type=3D]name[,prop[=3Dvalue][,...]]\n" " selects emulated machine ('-machine help' for list)\n" --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545539; cv=none; d=zoho.com; s=zohoarc; b=MH3CX+QwhsCg8/GYGLbNxm2wb0P0PoD+Hx//mro48khsuHUj/C+JVlJ0UWAlEymyEZ0OZwr77vK3Ds7dUS9TiSmtSl1RyvchR8y+PhEA2xpIMffTbKmWgGjzhBUOBO9JiwpPVXuYfxeXiRXIArEbNAsNqGGd+8POkofOED3yI4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545539; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aFlL9hrp/8s5Ve2fji43eNKHS8OEeq+nWxFs4dHUn4g=; b=EvE7WEK/mgtlf1ZbXcTDYx+DaBZxq6/7WnNOQz7TiWTn7lz18Ob7N/VTSdRNv6ePph2wZsGthxwPG2b1cb2XZo84jUYh1ImKJRxokr6nqRpifeLohhnSLevE5j+rh3kUtbTQldFX0Ly+anlw6lxt2TgR4uzxZPCmvMT+FemmU+0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545539638113.9548117251602; Tue, 3 Sep 2019 14:18:59 -0700 (PDT) Received: from localhost ([::1]:51644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GCX-0000lC-Ap for importer@patchew.org; Tue, 03 Sep 2019 17:18:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53653) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaF-0007tz-JB for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaD-0000gP-PX for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaD-0000fW-A0 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:21 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KY2Jg066515; Tue, 3 Sep 2019 20:39:14 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2usy4u832u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:14 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcY66178165; Tue, 3 Sep 2019 20:39:13 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2us4wegr3m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:13 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KdCVg024635; Tue, 3 Sep 2019 20:39:12 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=aFlL9hrp/8s5Ve2fji43eNKHS8OEeq+nWxFs4dHUn4g=; b=MceREJfpK1thjIEbF6NZjsy9TMj917/z9fHNUaJYSEOa03hhgkpwW2C3M4P3WrkMjCXN Wo54idlqX7GGxi3icJJT7efiZ44U84ofBAKzDbKFyvOXGUf9GwEdhFqHYzg1Thn2i6KU UO4ZEtJ8qyszXi1Znnokabq2dVrI3RD7Qh9oM94a1UGqT2WJhWN/iTR8cmFIaxH9VWBW PbETBtgh9K6PkGpMpAhP1LBANsrPvz/1QCkmaCwF9dIumLld5R/vjvzv8QG2MmnLA3BR 3yBui67eMJMKD5OYah+uo13UehD4I1a5tBj5xfyjDgKEJoIoXowf/KRVoZ4D+qXa1dsc OA== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:57 -0400 Message-Id: <2bdaf006096778cd5330866ec4a6cc43f8ee958b.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 31/45] multi-process: add remote options parser 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- New patch in v3 vl.c | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 117 insertions(+) diff --git a/vl.c b/vl.c index dc2558c..08e9c09 100644 --- a/vl.c +++ b/vl.c @@ -279,6 +279,28 @@ static QemuOptsList qemu_option_rom_opts =3D { }, }; =20 +static QemuOptsList qemu_remote_opts =3D { + .name =3D "remote", + .head =3D QTAILQ_HEAD_INITIALIZER(qemu_remote_opts.head), + .desc =3D { + { + .name =3D "rid", + .type =3D QEMU_OPT_NUMBER, + .help =3D "id of the remote process" + },{ + .name =3D "socket", + .type =3D QEMU_OPT_NUMBER, + .help =3D "Socket for remote", + },{ + .name =3D "command", + .type =3D QEMU_OPT_STRING, + .help =3D "command to run", + }, + { /* end of list */ } + }, +}; + + static QemuOptsList qemu_machine_opts =3D { .name =3D "machine", .implied_opt_name =3D "type", @@ -346,6 +368,87 @@ static QemuOptsList qemu_boot_opts =3D { }, }; =20 +#if defined(CONFIG_MPQEMU) +static int device_remote_add(void *opaque, QemuOpts *opts, Error **errp) +{ + unsigned int rid =3D *(unsigned int *)opaque; + const char *opt_rid =3D NULL; + struct remote_process *p =3D NULL;; + + opt_rid =3D qemu_opt_get(opts, "rid"); + if (!opt_rid) { + return 0; + } + + p =3D get_remote_process_rid(rid); + if (!p) { + return -EINVAL; + } + + if (atoi(opt_rid) =3D=3D rid) { + qemu_opt_set(opts, "command", p->command, errp); + rdevice_init_func(opaque, opts, errp); + qemu_opts_del(opts); + } + return 0; +} + +static int parse_remote(void *opaque, QemuOpts *opts, Error **errp) +{ + int rid; + int socket; + char *c_sock; + const char *command =3D NULL; + struct remote_process r_proc; + + rid =3D atoi(qemu_opt_get(opts, "rid")); + if (rid < 0) { + error_setg(errp, "rid is required."); + return -1; + } + if (get_remote_process_rid(rid)) { + error_setg(errp, "There is already process with rid %d", rid); + goto cont_devices; + } + + c_sock =3D (char *)qemu_opt_get(opts, "socket"); + if (c_sock) { + socket =3D atoi(c_sock); + } else { + socket =3D -1; + } + + command =3D qemu_opt_get(opts, "command"); + + if (socket <=3D STDERR_FILENO && socket !=3D -1) { + socket =3D -1; + } + + if (!command && socket < 0) { + error_setg(errp, "No correct socket or command defined for remote= ."); + return -1; + } + + if (rid < 0) { + error_setg(errp, "id option is required and must be non-negative"); + return -1; + } + r_proc.rid =3D rid; + r_proc.socket =3D socket; + r_proc.command =3D g_strdup(command); + remote_process_register(&r_proc); + + cont_devices: + if (qemu_opts_foreach(qemu_find_opts("device"), device_remote_add, + &rid, NULL)) { + error_setg(errp, "Could not process some of the remote devices."); + } + + return 0; +} + +#endif + static QemuOptsList qemu_add_fd_opts =3D { .name =3D "add-fd", .head =3D QTAILQ_HEAD_INITIALIZER(qemu_add_fd_opts.head), @@ -2861,6 +2964,7 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_icount_opts); qemu_add_opts(&qemu_semihosting_config_opts); qemu_add_opts(&qemu_fw_cfg_opts); + qemu_add_opts(&qemu_remote_opts); module_call_init(MODULE_INIT_OPTS); =20 runstate_init(); @@ -3697,6 +3801,14 @@ int main(int argc, char **argv, char **envp) exit(1); #endif break; + case QEMU_OPTION_remote: + opts =3D qemu_opts_parse_noisily(qemu_find_opts("remote"), + optarg, false); + if (!opts) { + exit(1); + } + break; + case QEMU_OPTION_object: opts =3D qemu_opts_parse_noisily(qemu_find_opts("object"), optarg, true); @@ -4297,6 +4409,11 @@ int main(int argc, char **argv, char **envp) qemu_opts_foreach(qemu_find_opts("device"), device_init_func, NULL, &error_fatal); =20 +#ifdef CONFIG_MPQEMU + qemu_opts_foreach(qemu_find_opts("remote"), + parse_remote, NULL, &error_fatal); +#endif + cpu_synchronize_all_post_init(); =20 rom_reset_order_override(); --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545232; cv=none; d=zoho.com; s=zohoarc; b=fi7OnOtjwBMJjA1lyEyFb4BDv1eavm/7cCh0Bz23Zj71VKvoFMmT5pO5DPGvAU0GlpcOXAHPh7jfM02Hz7mREgJ4QrIKggJacyXX/k1K0e5osE3NZbzScDPOETKKkti8ApATfYkwFtgtY+EbnV64EqaYj5RpAWGqXBOrEsJTCdM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545232; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CjgjKQc9jVi+jktzR6sSVT0CFuUT9GdnskHc4Tlo9ew=; b=Ijmf+v/MBwCq8fEEPYli9FF/F+f/zJFV2OHb7gh8oOnrndzWkgBHxSgzm/6ldERShMmThAfCLKsT3tCA9iZQVEkSw6OSrf5Q4Ki6xebP3+G0R7AIFppJX2GJeNE8eHxRpCWgVAxK/v3PkE3QCMGDmYJEIjkgFHZRXUJOgtYkG4I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545232239735.9830154874903; Tue, 3 Sep 2019 14:13:52 -0700 (PDT) Received: from localhost ([::1]:51588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G7Z-0005Hk-OL for importer@patchew.org; Tue, 03 Sep 2019 17:13:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53662) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaG-0007up-Bu for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaD-0000g8-CJ for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:24 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57360) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaD-0000fV-5c for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:21 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXg2r053293; Tue, 3 Sep 2019 20:39:16 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2usy6n021p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:16 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcIq2094766; Tue, 3 Sep 2019 20:39:15 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2usu51u25q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:15 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KdECr028877; Tue, 3 Sep 2019 20:39:14 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=CjgjKQc9jVi+jktzR6sSVT0CFuUT9GdnskHc4Tlo9ew=; b=jkTo93TvytrK/wKQCPN/mfEiKEuGRAVJ4Dicuw7+bYL0c+x68lTnGCrtsLbYTm8h+Xu+ +f/ak5QOfBqqnAkwLJFN522Gld5Msts6YMgSSjxnSYI7zgqTfCBMNyIY1oo9ptu7qJC/ nQwOi7/HH7tiLX+VNeH3p1V+yYc8xWQ5CVxify7QNmM2bpjTx1Xc2iOk6h4XtmzwTNCo +BLzZdj+aeedHRr9hj/k8VDGJQ0YYWbep+za8QO+9f2QGs7nEjx8P6ixJGr7vQfaKq/r cc8cptcEf2vNoIfe1QPcFraxV4uTbtABk0nvIIlDDKWCRhEasM/oPvphD4qCPZFo+hif Ng== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:58 -0400 Message-Id: <0ea30ed1342457c717123a4e164dfd7e8582998a.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 32/45] multi-process: add parse_cmdline in remote process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- New patch in v3 remote/Makefile.objs | 1 + remote/remote-main.c | 11 +++++ remote/remote-opts.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ remote/remote-opts.h | 31 ++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 remote/remote-opts.c create mode 100644 remote/remote-opts.h diff --git a/remote/Makefile.objs b/remote/Makefile.objs index c1349ad..a677fce 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 0c0e085..416b8a1 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -64,6 +64,7 @@ #include "qapi/qmp/qlist.h" #include "qemu/log.h" #include "qemu/cutils.h" +#include "remote-opts.h" =20 static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -468,6 +469,13 @@ 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); + proxy_link =3D proxy_link_create(); if (!proxy_link) { printf("Could not create proxy link\n"); @@ -481,6 +489,9 @@ int main(int argc, char *argv[]) } =20 proxy_link_init_channel(proxy_link, &proxy_link->com, fd); + + parse_cmdline(argc - 2, argv + 2, NULL); + proxy_link_set_callback(proxy_link, process_msg); =20 start_handler(proxy_link); diff --git a/remote/remote-opts.c b/remote/remote-opts.c new file mode 100644 index 0000000..416ff59 --- /dev/null +++ b/remote/remote-opts.c @@ -0,0 +1,113 @@ +/* + * Remote device initialization + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#include +#include +#include +#include "qemu/osdep.h" +#include "qemu/module.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu-common.h" + +#include "remote/pcihost.h" +#include "remote/machine.h" +#include "hw/boards.h" +#include "hw/qdev-core.h" +#include "qemu/main-loop.h" +#include "remote/memory.h" +#include "io/proxy-link.h" +#include "qapi/error.h" +#include "qemu-options.h" +#include "sysemu/arch_init.h" + +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qobject.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "monitor/qdev.h" +#include "qapi/qmp/qdict.h" +#include "sysemu/sysemu.h" +#include "sysemu/blockdev.h" +#include "block/block.h" +#include "remote/remote-opts.h" +#include "include/qemu-common.h" + +#include "vl.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 arc= h_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 0000000..e15c29b --- /dev/null +++ b/remote/remote-opts.h @@ -0,0 +1,31 @@ +/* + * Remote device initialization + * + * Copyright 2019, Oracle and/or its affiliates. + * + * Permission is hereby granted, free of charge, to any person obtaining a= copy + * of this software and associated documentation files (the "Software"), t= o deal + * in the Software without restriction, including without limitation the r= ights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or se= ll + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included= in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS= OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OT= HER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING= FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS = IN + * THE SOFTWARE. + */ + +#ifndef REMOTE_OPTS_H +#define REMOTE_OPTS_H + +void parse_cmdline(int argc, char **argv, char **envp); + +#endif + --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544979; cv=none; d=zoho.com; s=zohoarc; b=nZL94MvahqZNNsxw9/9bx54kALonPy57XfmUVN74AmM3sou6FM2kZ7Ezk8v8QjnHNnNwUKN0BSRPnAB/jYRznAhP5xq51YKTdApwti2D9h6TaJCe2KgfpE+gl2JYSo8n/ane/C7oNBzPZtpIgFiaAb5YSB6miR5sr1cUpRTfA3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544979; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+GqUQTP3syTnZL0HKNUj9XLZIiMtRF+GrHU4Fhq+gWg=; b=U3QfNtbmvgrgnNDab0C+8fxbLpN9UTCt7ZpUKfR0AYtKJF8zLdRqHUDNS8sP4o+kXwT3A3r4sqsAkY52bPUpfm8zQOIdLL5RFrih53ffBoX3mHeTT8JmIrl/7b2ZShBPmhSoJBA7pY1F2PhNuHonjI+5dLnrxJ6K3V3UBt2ZYqU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 15675449794031016.6844551725619; Tue, 3 Sep 2019 14:09:39 -0700 (PDT) Received: from localhost ([::1]:51528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G3T-0000ua-3j for importer@patchew.org; Tue, 03 Sep 2019 17:09:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53683) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaK-0007w5-LX for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaI-0000l6-HL for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:28 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57472) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaI-0000jS-Ad for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:26 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXfoH053264; Tue, 3 Sep 2019 20:39:17 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2usy6n021r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:17 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcHVF094690; Tue, 3 Sep 2019 20:39:16 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2usu51u25x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:16 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KdFgp024737; Tue, 3 Sep 2019 20:39:15 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=+GqUQTP3syTnZL0HKNUj9XLZIiMtRF+GrHU4Fhq+gWg=; b=fjrSjClN4InS8TTreo+jjt3nG9ZLxKi/Oc1asSz/XPL+LGHhX/kum7NRSwLcGo2dDIOX 2JoAZDRgEwfAryfmLhPER88OlVGeiUcZDpeI/fJOuwJTmwGVc0T5JbZMrCPh8UwEW8Q8 x3gAtQJmsg50P8geydrdq24FjPpKiBkEISw5n39xptB9NBYi8Qqdxfjk+vsULturVYb9 ttTPoi7RkEIA/xH9C9ZyetZIFyk2ZupuCBwOLUh1EXDH23QBjG4wec6du2Hni/90UQb5 icaIVUOb+jKv3rF7E8hUUb4P66KgfdMiUaSo9y43iIotHBy9TUOqXce0yS3JWyoz5yMk Fw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:37:59 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 33/45] multi-process: add support for multiple devices 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Add suport for multiple devices in one remote process. Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- New patch in v3 remote/remote-main.c | 140 ++++++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 115 insertions(+), 25 deletions(-) diff --git a/remote/remote-main.c b/remote/remote-main.c index 416b8a1..5552712 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -67,19 +67,83 @@ #include "remote-opts.h" =20 static ProxyLinkState *proxy_link; -PCIDevice *remote_pci_dev; -bool create_done; =20 -static void process_config_write(ProcMsg *msg) +typedef struct remote_pci_devs { + char *id; + DeviceState *ds; + unsigned int created; + QLIST_ENTRY(remote_pci_devs) next; +} remote_pci_devs; +typedef struct pci_devs_listhead pci_devs_listhead; + +QLIST_HEAD(pci_devs_listhead, remote_pci_devs) pci_devs_head; +/* This is needed to distinguish between different devices being initializ= ed. */ + +QemuMutex remote_ds_lock; +static bool done_init; + + +static remote_pci_devs *get_ds_from_list(const char *id, unsigned int size= _id) +{ + remote_pci_devs *d; + + qemu_mutex_lock(&remote_ds_lock); + QLIST_FOREACH(d, &pci_devs_head, next) { + if (id && d->id) { + if (strncmp(id, d->id, size_id) =3D=3D 0) { + qemu_mutex_unlock(&remote_ds_lock); + return d; + } + } + } + qemu_mutex_unlock(&remote_ds_lock); + + return NULL; +} + +static void add_to_pci_devs_list(DeviceState *dev) +{ + remote_pci_devs *d; + + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { + d =3D g_malloc(sizeof(remote_pci_devs)); + d->ds =3D dev; + d->id =3D g_strdup(dev->id); + if (!d->id) { + return; + } + qemu_mutex_lock(&remote_ds_lock); + QLIST_INSERT_HEAD(&pci_devs_head, d, next); + qemu_mutex_unlock(&remote_ds_lock); + + } +} + +static void del_from_pci_devs_list(const char *id) +{ + remote_pci_devs *d; + + d =3D get_ds_from_list((char *)id, strlen((char *)id)); + if (!d) { + return; + } + g_free(d->id); + qemu_mutex_lock(&remote_ds_lock); + QLIST_REMOVE(d, next); + qemu_mutex_unlock(&remote_ds_lock); + g_free(d); +} + +static void process_config_write(ProcMsg *msg, DeviceState *ds) { struct conf_data_msg *conf =3D (struct conf_data_msg *)msg->data2; =20 qemu_mutex_lock_iothread(); - pci_default_write_config(remote_pci_dev, conf->addr, conf->val, conf->= l); + pci_default_write_config(PCI_DEVICE(ds), conf->addr, conf->val, conf->= l); qemu_mutex_unlock_iothread(); } =20 -static void process_config_read(ProcMsg *msg) +static void process_config_read(ProcMsg *msg, DeviceState *ds) { struct conf_data_msg *conf =3D (struct conf_data_msg *)msg->data2; uint32_t val; @@ -88,7 +152,7 @@ static void process_config_read(ProcMsg *msg) wait =3D msg->fds[0]; =20 qemu_mutex_lock_iothread(); - val =3D pci_default_read_config(remote_pci_dev, conf->addr, conf->l); + val =3D pci_default_read_config(PCI_DEVICE(ds), conf->addr, conf->l); qemu_mutex_unlock_iothread(); =20 notify_proxy(wait, val); @@ -233,6 +297,8 @@ fail: notify_proxy(wait, 1); =20 PUT_REMOTE_WAIT(wait); + + del_from_pci_devs_list((const char *)msg->id); } =20 static int init_drive(QDict *rqdict, Error **errp) @@ -313,7 +379,7 @@ static int setup_device(ProcMsg *msg, Error **errp) qstr =3D qstring_from_str((char *)msg->data2); obj =3D qobject_from_json(qstring_get_str(qstr), &local_error); if (!obj) { - error_setg(errp, "Could not get object!"); + error_setg(errp, "Could not get object"); return rc; } =20 @@ -338,13 +404,12 @@ static int setup_device(ProcMsg *msg, Error **errp) =20 dev =3D qdev_device_add(opts, &local_error); if (!dev) { - error_setg(errp, "Could not add device %s.", + error_setg(errp, "Could not add device %s", qstring_get_str(qobject_to_json(QOBJECT(qdict)))); return rc; } - if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - remote_pci_dev =3D PCI_DEVICE(dev); - } + + add_to_pci_devs_list(dev); qemu_opts_del(opts); =20 return 0; @@ -354,10 +419,13 @@ static void process_msg(GIOCondition cond, ProcChanne= l *chan) { ProcMsg *msg =3D NULL; Error *err =3D NULL; + remote_pci_devs *r =3D NULL; =20 if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { error_setg(&err, "socket closed, cond is %d", cond); - goto finalize_loop; + proxy_link_finalize(proxy_link); + proxy_link =3D NULL; + return; } =20 msg =3D g_malloc0(sizeof(ProcMsg)); @@ -367,23 +435,32 @@ static void process_msg(GIOCondition cond, ProcChanne= l *chan) goto finalize_loop; } =20 + if (msg->cmd !=3D DEV_OPTS && msg->cmd !=3D DRIVE_OPTS && + msg->cmd !=3D SYNC_SYSMEM) { + r =3D get_ds_from_list((const char *)msg->id, msg->size_id); + if (!r) { + error_setg(&err, "Message was received for unknown device"); + goto exit_loop; + } + } + switch (msg->cmd) { case INIT: break; case CONF_WRITE: - if (create_done) { - process_config_write(msg); + if (r->created) { + process_config_write(msg, r->ds); } =20 break; case CONF_READ: - if (create_done) { - process_config_read(msg); + if (r->created) { + process_config_read(msg, r->ds); } =20 break; case BAR_WRITE: - if (create_done) { + if (r->created) { process_bar_write(msg, &err); if (err) { error_report_err(err); @@ -391,7 +468,7 @@ static void process_msg(GIOCondition cond, ProcChannel = *chan) } break; case BAR_READ: - if (create_done) { + if (r->created) { process_bar_read(msg, &err); if (err) { error_report_err(err); @@ -410,12 +487,15 @@ static void process_msg(GIOCondition cond, ProcChanne= l *chan) } break; case SET_IRQFD: - process_set_irqfd_msg(remote_pci_dev, msg); - qdev_machine_creation_done(); - qemu_mutex_lock_iothread(); - qemu_run_machine_init_done_notifiers(); - qemu_mutex_unlock_iothread(); - create_done =3D true; + process_set_irqfd_msg(PCI_DEVICE(r->ds), msg); + r->created =3D true; + if (!done_init) { + qdev_machine_creation_done(); + qemu_mutex_lock_iothread(); + qemu_run_machine_init_done_notifiers(); + qemu_mutex_unlock_iothread(); + done_init =3D true; + } break; case DRIVE_OPTS: if (setup_drive(msg, &err)) { @@ -438,18 +518,26 @@ static void process_msg(GIOCondition cond, ProcChanne= l *chan) goto finalize_loop; } =20 +exit_loop: + if (msg->id) { + free(msg->id); + } g_free(msg); =20 return; =20 finalize_loop: error_report_err(err); + if (msg->id) { + free(msg->id); + } g_free(msg); + proxy_link_finalize(proxy_link); proxy_link =3D NULL; } =20 -int main(int argc, char *argv[]) +int main(int argc, char *argv[], char **envp) { Error *err =3D NULL; int fd =3D -1; @@ -491,6 +579,8 @@ int main(int argc, char *argv[]) proxy_link_init_channel(proxy_link, &proxy_link->com, fd); =20 parse_cmdline(argc - 2, argv + 2, NULL); + qemu_mutex_init(&remote_ds_lock); + QLIST_INIT(&pci_devs_head); =20 proxy_link_set_callback(proxy_link, process_msg); =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544471; cv=none; d=zoho.com; s=zohoarc; b=Gcy+zFfAGUTEsYxH2TQOL/MYepAjXSn6tciTlcS/qbEVgF5+cVD+PmrVeL0jowqJaX3Hy2Tz4+3WObExt9w0f/seYRv3VtfVjTwdZr1IkL02Mv4eos8qRJS4/FTP2HtTmUh7SAGeujfb8ZJ1Ff9PogW6bkt1k2ZSktdXkZ898TE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544471; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=VQ9r5agpFPvXZaIGif5pk3x4EE+3DdMUY+fVfpqcJ6s=; b=lO/SSvu3Klfw+BYPZ2iDcs2NJ2ffAVuHjyGEEe6L/jtujgzwkoGIhpnRgtg+vn+yUwiCvJjGtUGdoHCctAYqtomrd+WDMYqZxKGREZewsCGSbkZjncQnD4u7NJhmNKs/cykjeJwVVrrFQGCxyMn/RUmxlYVVfSRzygO5vP6XRho= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544471433162.36021751184023; Tue, 3 Sep 2019 14:01:11 -0700 (PDT) Received: from localhost ([::1]:51410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FvJ-0002h5-3b for importer@patchew.org; Tue, 03 Sep 2019 17:01:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53684) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaK-0007w7-LV for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaI-0000kv-BX for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:28 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaG-0000hN-AD for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:25 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KYEoK066594; Tue, 3 Sep 2019 20:39:19 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2usy4u8338-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:18 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kcb0T178493; Tue, 3 Sep 2019 20:39:18 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2us4wegr80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:18 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdHpr012834; Tue, 3 Sep 2019 20:39:17 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:16 -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 : in-reply-to : references; s=corp-2019-08-05; bh=VQ9r5agpFPvXZaIGif5pk3x4EE+3DdMUY+fVfpqcJ6s=; b=HnimO1EZrxUVtVAsN0RNGWek6HEny0kSgTOGvxFo6PIvvidcVhRMKhT+AXRn24Ck4hfD dDo5rCdHo0jpWOrbe5g3LGv1B85xGiCVlpR2/pXZTWLQ/bmecmL2uJskaOHa6FEq5x5H e6sfbbNoD7JqjaSvwLBcVEv7TT1j6+Y4MIXsdRfADQLZGSOCBFmwJWOXakVvdBIPBezQ 3Nycpu7iF1SlEwZfiNA+5LSAcPwdmE0E+038rowP6oFWHaJqeMztwHHzTXd45rF0KhpE wADdBLO4twnNhfatmboBc35zVfg9vN4uyWsEme4aWjirH9R4FQSVhHpGiaboMScu3lK/ nQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:00 -0400 Message-Id: <65301af8f70273575a6757580e282ef5401b47af.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=3 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 34/45] multi-process: add heartbeat timer and signal handler 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Add a signal handler for launched remote processes and set up the heartbeat timer for remote processes. Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman --- hw/proxy/qemu-proxy.c | 101 ++++++++++++++++++++++++++++++++++++++++++++= ++++ include/io/proxy-link.h | 1 + 2 files changed, 102 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 61808c5..699a0b1 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -53,14 +53,96 @@ #include "hw/boards.h" #include "include/qemu/log.h" =20 +QEMUTimer *hb_timer; static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); static void setup_irqfd(PCIProxyDev *dev); +static void pci_dev_exit(PCIDevice *dev); +static void start_heartbeat_timer(void); +static void stop_heartbeat_timer(void); +static void childsig_handler(int sig, siginfo_t *siginfo, void *ctx); +static void broadcast_msg(ProcMsg *msg, bool need_reply); + +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 broadcast_msg(ProcMsg *msg, bool need_reply) +{ + PCIProxyDev *entry; + unsigned int pid; + int wait; + + QLIST_FOREACH(entry, &proxy_dev_list.devices, next) { + if (need_reply) { + wait =3D GET_REMOTE_WAIT; + msg->num_fds =3D 1; + msg->fds[0] =3D wait; + } + + proxy_proc_send(entry->proxy_link, msg, entry->proxy_link->com); + if (need_reply) { + pid =3D (uint32_t)wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + /* TODO: Add proper handling. */ + if (pid) { + need_reply =3D 0; + } + } + } +} + +#define NOP_INTERVAL 1000000 + +static void remote_ping(void *opaque) +{ + ProcMsg msg; + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.num_fds =3D 0; + msg.cmd =3D PROXY_PING; + msg.bytestream =3D 0; + msg.size =3D 0; + + broadcast_msg(&msg, true); + timer_mod(hb_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NOP_INTERV= AL); + +} + +void start_heartbeat_timer(void) +{ + hb_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, + remote_ping, + &proxy_dev_list); + timer_mod(hb_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NOP_INTERV= AL); + +} + +static void stop_heartbeat_timer(void) +{ + timer_del(hb_timer); + timer_free(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); +} =20 static void proxy_ready(PCIDevice *dev) { PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); =20 setup_irqfd(pdev); + set_sigchld_handler(); + start_heartbeat_timer(); } =20 static void set_remote_opts(PCIDevice *dev, QDict *qdict, unsigned int cmd) @@ -272,6 +354,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_dev_exit; k->config_read =3D pci_proxy_read_config; k->config_write =3D pci_proxy_write_config; } @@ -408,6 +491,24 @@ static void pci_proxy_dev_realize(PCIDevice *device, E= rror **errp) dev->proxy_ready =3D proxy_ready; } =20 +static void pci_dev_exit(PCIDevice *pdev) +{ + PCIProxyDev *entry, *sentry; + PCIProxyDev *dev =3D PCI_PROXY_DEV(pdev); + + stop_heartbeat_timer(); + + QLIST_FOREACH_SAFE(entry, &proxy_dev_list.devices, next, sentry) { + if (entry->remote_pid =3D=3D dev->remote_pid) { + QLIST_REMOVE(entry, next); + } + } + + if (!QLIST_EMPTY(&proxy_dev_list.devices)) { + start_heartbeat_timer(); + } +} + static void send_bar_access_msg(PCIProxyDev *dev, MemoryRegion *mr, bool write, hwaddr addr, uint64_t *val, unsigned size, bool memory) diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 13fb312..ae98eac 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -74,6 +74,7 @@ typedef enum { DRIVE_OPTS, DEVICE_ADD, DEVICE_DEL, + PROXY_PING, MAX, } proc_cmd_t; =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567544790; cv=none; d=zoho.com; s=zohoarc; b=OQ+JQZlxhXXP+/oqP4BzpzdfcEEwA5aBBY0Sx7LVn6C1QnavKA+GBpyy6hSr6kiSmeeSXSR1bTA7Y2T9B3xR6R/8VuY1p+rflitQYJ6B84mL8bzxTgDfXWUlZWAaKbcpiWpWRd7kvg1idBpfjma14UoIj7KmOI+eJJwxBwqA2N8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567544790; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MutKmP+OHj02p9DHj3xH7q24SrwjpKc0Y4265jCiEAM=; b=l8psOPUOsL1ocswwaNWtTFUphLDllks7+21zICYF5yKk48Sxydfv5wmlJ5/N6bnJR6LT24s7FiGtzR7bei4tLCBVy5BKOTIAPfD9c//vGph/VRN9y6Wgd2STGvTCBvhHXN9beo8Z6hTwd33Y1T8+fMk+T9BiQp4ivLjmhjXgkpg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567544790514681.2194477871303; Tue, 3 Sep 2019 14:06:30 -0700 (PDT) Received: from localhost ([::1]:51496 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G0Q-0006V5-Co for importer@patchew.org; Tue, 03 Sep 2019 17:06:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53696) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaL-0007xW-MD for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaK-0000mq-L0 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:29 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaJ-0000lK-Aw for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:28 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KXev8053247; Tue, 3 Sep 2019 20:39:21 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2usy6n0221-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:21 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcKYb188137; Tue, 3 Sep 2019 20:39:21 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2usu5118h6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:21 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdJLw017788; Tue, 3 Sep 2019 20:39:19 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=MutKmP+OHj02p9DHj3xH7q24SrwjpKc0Y4265jCiEAM=; b=fLokqer8pP9v1rESLwsR0hQouEgaY9GAxfvTJddV1ZR8cqtD9frA/8LCYo+6dsAjajPD 89zahY7vCdg0paWn530PvzTyKAtYF19/xFPjBvFjystxwKwCABO9KgGw0SyZSb6xZNOL FrdovZxgRjHO5HTxb4AE4VP9e25lr0kRcCjPyxxHE9t+s+O9kd2X7HLynqZGwCd1ZtEC XB4YsGfZmnm16DXoI2NxXHTMYqu6cTYJoaR6xErN6GALo0yCxoDcwNveNSzdF1HtTg7v JLLbDxxb/z2F4+a2wkBQgwfKj7Cdg60JbeX+yD0Gs2XPdU6FnikENbv5KxU/v0dAH9eX vw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:01 -0400 Message-Id: <9342dcc0fccdbb5e23024e55c7127ab6ecc4e269.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030206 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 35/45] multi-process: handle heartbeat messages in remote process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva and reply back to proxy object. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- remote/remote-main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index 5552712..f0a4de9 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -420,6 +420,7 @@ static void process_msg(GIOCondition cond, ProcChannel = *chan) ProcMsg *msg =3D NULL; Error *err =3D NULL; remote_pci_devs *r =3D NULL; + int wait; =20 if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { error_setg(&err, "socket closed, cond is %d", cond); @@ -513,6 +514,11 @@ static void process_msg(GIOCondition cond, ProcChannel= *chan) case DEVICE_DEL: process_device_del_msg(msg); break; + case PROXY_PING: + wait =3D msg->fds[0]; + notify_proxy(wait, (uint32_t)getpid()); + PUT_REMOTE_WAIT(wait); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545592; cv=none; d=zoho.com; s=zohoarc; b=Z73gbSTggB7SnET6qEAATDq8/qG1fipDlq2LYUo4FrywPQ5kaeSd/EY8J/jyajOvsbj/xYTV85KpGnTAVIFpohIy5t1kLiuB4BWm5KM32Y1j7H4lTdcDg80Crvjyk8D/SlMEc6tuOdWoDu88QQIrMcCHnfLE9Cy7CMB/FV9FAS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545592; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=92lOO3sen5W02+vlyfSiJKk2wS4yY+jdYK76D6K75H0=; b=D8OJln9eol1VYeHNhCQYhTDGa1rD3ciqxMJyKphVLZUrvW2EkcExEwmNwBN4lIDIlJLPeNbuczMubAUatiZ5hXPBwETpE8FGt5J8YQscdpClnp/fsRthoz/amXpP2nQwsTV2bzTEySmzuOG+4F5oxyLmom5JL5o/WGaIvzjYWdQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545592970686.3779177972233; Tue, 3 Sep 2019 14:19:52 -0700 (PDT) Received: from localhost ([::1]:51652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GDM-0001aw-4v for importer@patchew.org; Tue, 03 Sep 2019 17:19:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53737) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaR-000880-Ov for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaQ-0000q3-6P for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:35 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60760) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaP-0000pR-Uk for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:34 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdRYQ067206; Tue, 3 Sep 2019 20:39:27 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2usy66r2hn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:26 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcYNW178177; Tue, 3 Sep 2019 20:39:22 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2us4wegrbb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:22 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KdLZZ028933; Tue, 3 Sep 2019 20:39:21 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:19 -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 : in-reply-to : references; s=corp-2019-08-05; bh=92lOO3sen5W02+vlyfSiJKk2wS4yY+jdYK76D6K75H0=; b=cv2zke3/VhZ2md6Wb5uBVHF8Xd3YBnQxGSG+CYIJK4Mkg2chJK8zKYnuLxGrVQknA50P AgvoGviY8qNm9MCxmy9qvFeHwcQPeC5DB2oJLhBwMf0NGU87qzOfQ5ko53pP4FRhurEY zpLnvWxDLg4rjDCfqywL5P9b4sr69gzmaqkgKH1S7wG4/N38S3xjqF6wiAVevJyCBfFn fjwOxeiCrU18kNmrzwubkl9mqPDKeA7kmNRVk84AtojZYHGiUj/2TVVJk0IATp9Par0f Yph/kJh+Al6VAJsb/huXK5dKbFtdCqUeOyLgYQC9BRPO1VfExuFxf4LmVj7Y+OCl0J7H Xw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:02 -0400 Message-Id: <6c736da21b554548b7ba2af04fb5eee1cf806883.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 36/45] multi-process: Use separate MMIO communication channel 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Using a separate communication channel for MMIO helps with improving Performance Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- New patch in v3 hw/proxy/qemu-proxy.c | 38 ++++++++++++++++++++++++++------------ include/hw/proxy/qemu-proxy.h | 1 + include/io/proxy-link.h | 7 +++++++ io/proxy-link.c | 2 ++ qdev-monitor.c | 1 + remote/remote-main.c | 20 ++++++++++++++------ 6 files changed, 51 insertions(+), 18 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 699a0b1..db9a208 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -205,20 +205,22 @@ static int make_argv(char *command_str, char **argv, = int argc) int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp) { pid_t rpid; - int fd[2] =3D {-1, -1}; + int fd[2], mmio[2]; Error *local_error =3D NULL; char *argv[64]; int argc =3D 0, _argc; char *sfd; char *exec_dir; int rc =3D -EINVAL; + struct timeval timeout =3D {.tv_sec =3D 10, .tv_usec =3D 0}; =20 if (pdev->managed) { /* Child is forked by external program (such as libvirt). */ return rc; } =20 - if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) { + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) || + socketpair(AF_UNIX, SOCK_STREAM, 0, mmio)) { error_setg(errp, "Unable to create unix socket."); return rc; } @@ -226,6 +228,8 @@ int remote_spawn(PCIProxyDev *pdev, const char *command= , Error **errp) argc =3D add_argv(exec_dir, argv, argc); sfd =3D g_strdup_printf("%d", fd[1]); argc =3D add_argv(sfd, argv, argc); + sfd =3D g_strdup_printf("%d", mmio[1]); + argc =3D add_argv(sfd, argv, argc); _argc =3D argc; argc =3D make_argv((char *)command, argv, argc); =20 @@ -235,22 +239,32 @@ int remote_spawn(PCIProxyDev *pdev, const char *comma= nd, Error **errp) if (rpid =3D=3D -1) { error_setg(errp, "Unable to spawn emulation program."); close(fd[0]); + close(mmio[0]); goto fail; } =20 if (rpid =3D=3D 0) { close(fd[0]); + close(mmio[0]); execvp(argv[0], (char *const *)argv); exit(1); } pdev->remote_pid =3D rpid; pdev->rsocket =3D fd[1]; pdev->socket =3D fd[0]; + pdev->mmio_sock =3D mmio[0]; + + if (setsockopt(mmio[0], SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, + sizeof(timeout)) < 0) { + error_setg(errp, "Unable to set timeout for socket"); + goto fail; + } =20 rc =3D 0; =20 fail: close(fd[1]); + close(mmio[1]); =20 for (int i =3D 0; i < _argc; i++) { g_free(argv[i]); @@ -466,6 +480,9 @@ static void init_proxy(PCIDevice *dev, char *command, b= ool need_spawn, Error **e proxy_link_init_channel(pdev->proxy_link, &pdev->proxy_link->com, pdev->socket); =20 + proxy_link_init_channel(pdev->proxy_link, &pdev->proxy_link->mmio, + pdev->mmio_sock); + configure_memory_sync(pdev->sync, pdev->proxy_link); } =20 @@ -514,8 +531,7 @@ static void send_bar_access_msg(PCIProxyDev *dev, Memor= yRegion *mr, unsigned size, bool memory) { ProxyLinkState *proxy_link; - ProcMsg msg; - int wait; + ProcMsg msg, ret; =20 proxy_link =3D dev->proxy_link; =20 @@ -531,11 +547,7 @@ static void send_bar_access_msg(PCIProxyDev *dev, Memo= ryRegion *mr, 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; } =20 if (dev->dev_id) { @@ -546,17 +558,19 @@ static void send_bar_access_msg(PCIProxyDev *dev, Mem= oryRegion *mr, msg.size_id =3D 0; } =20 - proxy_proc_send(proxy_link, &msg, proxy_link->com); + proxy_proc_send(proxy_link, &msg, proxy_link->mmio); =20 - if (!write) { - *val =3D wait_for_remote(wait); - PUT_REMOTE_WAIT(wait); + if (write) { + return; } =20 if (msg.id) { free(msg.id); } =20 + proxy_proc_recv(proxy_link, &ret, proxy_link->mmio); + + *val =3D ret.data1.mmio_ret.val; } =20 void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr ad= dr, diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index fb408cf..a03c6cc 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -59,6 +59,7 @@ typedef struct PCIProxyDev { pid_t remote_pid; int rsocket; int socket; + int mmio_sock; =20 char *rid; =20 diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index ae98eac..32b2c1a 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -75,6 +75,7 @@ typedef enum { DEVICE_ADD, DEVICE_DEL, PROXY_PING, + MMIO_RETURN, MAX, } proc_cmd_t; =20 @@ -108,6 +109,10 @@ typedef struct { } set_irqfd_msg_t; =20 typedef struct { + uint64_t val; +} mmio_ret_msg_t; + +typedef struct { proc_cmd_t cmd; int bytestream; size_t size; @@ -118,6 +123,7 @@ typedef struct { sync_sysmem_msg_t sync_sysmem; bar_access_msg_t bar_access; set_irqfd_msg_t set_irqfd; + mmio_ret_msg_t mmio_ret; } data1; =20 int fds[REMOTE_MAX_FDS]; @@ -170,6 +176,7 @@ struct ProxyLinkState { GMainLoop *loop; =20 ProcChannel *com; + ProcChannel *mmio; =20 proxy_link_callback callback; }; diff --git a/io/proxy-link.c b/io/proxy-link.c index 6f60117..3ca0185 100644 --- a/io/proxy-link.c +++ b/io/proxy-link.c @@ -74,6 +74,7 @@ void proxy_link_finalize(ProxyLinkState *s) g_main_loop_quit(s->loop); =20 proxy_link_destroy_channel(s->com); + proxy_link_destroy_channel(s->mmio); =20 object_unref(OBJECT(s)); } @@ -356,6 +357,7 @@ void start_handler(ProxyLinkState *s) { =20 g_assert(g_source_attach(&s->com->gsrc, s->ctx)); + g_assert(g_source_attach(&s->mmio->gsrc, s->ctx)); =20 g_main_loop_run(s->loop); } diff --git a/qdev-monitor.c b/qdev-monitor.c index 69e467e..f1065af 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -710,6 +710,7 @@ DeviceState *qdev_proxy_add(const char *rid, const char= *id, char *bus, if (old_pdev) { pdev->rsocket =3D old_pdev->rsocket; pdev->socket =3D old_pdev->socket; + pdev->mmio_sock =3D old_pdev->mmio_sock; pdev->remote_pid =3D old_pdev->remote_pid; } else { pdev->rsocket =3D managed ? rsocket : -1; diff --git a/remote/remote-main.c b/remote/remote-main.c index f0a4de9..2a9ebae 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -180,8 +180,8 @@ static void process_bar_write(ProcMsg *msg, Error **err= p) static void process_bar_read(ProcMsg *msg, Error **errp) { bar_access_msg_t *bar_access =3D &msg->data1.bar_access; + ProcMsg ret =3D { 0 }; AddressSpace *as; - int wait =3D msg->fds[0]; MemTxResult res; uint64_t val =3D 0; =20 @@ -215,9 +215,10 @@ static void process_bar_read(ProcMsg *msg, Error **err= p) } =20 fail: - notify_proxy(wait, val); - - PUT_REMOTE_WAIT(wait); + ret.cmd =3D MMIO_RETURN; + ret.data1.mmio_ret.val =3D val; + ret.size =3D sizeof(ret.data1); + proxy_proc_send(proxy_link, &ret, proxy_link->mmio); } =20 static void process_device_add_msg(ProcMsg *msg) @@ -581,10 +582,17 @@ int main(int argc, char *argv[], char **envp) printf("Failed to parse fd for remote process.\n"); return -EINVAL; } - proxy_link_init_channel(proxy_link, &proxy_link->com, fd); =20 - parse_cmdline(argc - 2, argv + 2, NULL); + fd =3D qemu_parse_fd(argv[2]); + if (fd =3D=3D -1) { + printf("Failed to parse fd for remote process.\n"); + return -EINVAL; + } + proxy_link_init_channel(proxy_link, &proxy_link->mmio, fd); + + parse_cmdline(argc - 3, argv + 3, NULL); + qemu_mutex_init(&remote_ds_lock); QLIST_INIT(&pci_devs_head); =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545188; cv=none; d=zoho.com; s=zohoarc; b=EUyvkzfDDC2820PJCeozNl9hgSjwx9CtuyAOh6ORaC+pvHiIFgSoKI6IprgmHKmeJX0ntPpkvv3fSvjxGHqSMyJFzqV5vxfCyaavY9Rb6a5r5OWevL4ktYi9yoSygViLIXBS58s6OUPDA2n0Y1LmnSzbKSqEk3Zck07qqaU8j0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545188; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=g9Q8L0XLVMN0buTbSVSf7NJVZyxcqAaV9TdcvRBTvug=; b=GadrW0O5L5RYJVBqqteMSjkJYDZxYnrJLTDtOjuGcNRdA88cB+J6yes07q+nWEGp0AHF0z4CU2kv6+94vLYj4XMjNcNLcMIiAEL8xyqNGPSz9QlerAhcR/HCpYmZ/G2qsfsYjffNn28R7vGhONmeGJT4H6ie8suUEhCC1xWIIrU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545188768322.32251420756234; Tue, 3 Sep 2019 14:13:08 -0700 (PDT) Received: from localhost ([::1]:51584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5G6s-0004Yx-VY for importer@patchew.org; Tue, 03 Sep 2019 17:13:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53735) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaR-00087c-GE for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaQ-0000qC-9W for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:35 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60762) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaQ-0000pX-19 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:34 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdRrc067219; Tue, 3 Sep 2019 20:39:27 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2usy66r2ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:27 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcCi0025802; Tue, 3 Sep 2019 20:39:23 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2us5pha0sd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:23 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdMEH012875; Tue, 3 Sep 2019 20:39:22 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=g9Q8L0XLVMN0buTbSVSf7NJVZyxcqAaV9TdcvRBTvug=; b=pV/rFPeZOZC8F/wVhNiLB709zdWVqcUxkxGc8poz9j8QzISl7hpgCeHpV2OGgQF3uGos 7rAKGgl2jQlcR9MSrEIWA4je97/0YsnalGXAmKzU6KuMEBmNH/Cjw+JzTz2f5xPCgs3g +o/cjobZcGBY8quR037xqvKvyrMtjK+qleKpGNTi9mEsN8ww4nn1o4BmcazWKMt98JQj fElB/y+v/SMLhziQhdqlXwOk92wkLRu1USqNx21niBGQ3VWaQ3jPxFzgMP7lTHsBF4lU Yu97r/hwx+hdBsLBG+KhbGQuFjSdJ5Grd4TuPBT7W/mmXL1GTkJH2ggz7ZdaCPaYpx0v Lw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:03 -0400 Message-Id: <3759424c8abd52955a2abe0a619dfaa79293e8ec.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 37/45] multi-process: perform device reset in the remote process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- New patch in v3 hw/proxy/proxy-lsi53c895a.c | 6 ++++++ hw/proxy/qemu-proxy.c | 14 ++++++++++++++ include/hw/proxy/qemu-proxy.h | 2 ++ include/io/proxy-link.h | 1 + remote/remote-main.c | 11 +++++++++++ 5 files changed, 34 insertions(+) diff --git a/hw/proxy/proxy-lsi53c895a.c b/hw/proxy/proxy-lsi53c895a.c index e8a8d36..8640749 100644 --- a/hw/proxy/proxy-lsi53c895a.c +++ b/hw/proxy/proxy-lsi53c895a.c @@ -128,6 +128,11 @@ static void proxy_lsi_realize(PCIProxyDev *dev, Error = **errp) pci_register_bar(pci_dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io= ); } =20 +static void proxy_lsi_reset(DeviceState *dev) +{ + proxy_device_reset(dev); +} + static void proxy_lsi_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -145,6 +150,7 @@ static void proxy_lsi_class_init(ObjectClass *klass, vo= id *data) set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); =20 dc->desc =3D "LSI Proxy Device"; + dc->reset =3D proxy_lsi_reset; } =20 static const TypeInfo lsi_proxy_dev_type_info =3D { diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index db9a208..c812145 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -588,3 +588,17 @@ uint64_t proxy_default_bar_read(PCIProxyDev *dev, Memo= ryRegion *mr, hwaddr addr, =20 return val; } + +void proxy_device_reset(DeviceState *dev) +{ + PCIProxyDev *pdev =3D PCI_PROXY_DEV(dev); + ProcMsg msg; + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.bytestream =3D 0; + msg.size =3D sizeof(msg.data1); + msg.cmd =3D DEVICE_RESET; + + proxy_proc_send(pdev->proxy_link, &msg, pdev->proxy_link->com); +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index a03c6cc..d88fbd4 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -100,4 +100,6 @@ void proxy_default_bar_write(PCIProxyDev *dev, MemoryRe= gion *mr, hwaddr addr, uint64_t proxy_default_bar_read(PCIProxyDev *dev, MemoryRegion *mr, hwaddr= addr, unsigned size, bool memory); =20 +void proxy_device_reset(DeviceState *dev); + #endif /* QEMU_PROXY_H */ diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 32b2c1a..eb51d29 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -76,6 +76,7 @@ typedef enum { DEVICE_DEL, PROXY_PING, MMIO_RETURN, + DEVICE_RESET, MAX, } proc_cmd_t; =20 diff --git a/remote/remote-main.c b/remote/remote-main.c index 2a9ebae..a6ff338 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -66,6 +66,9 @@ #include "qemu/cutils.h" #include "remote-opts.h" =20 +#include "monitor/monitor.h" +#include "sysemu/reset.h" + static ProxyLinkState *proxy_link; =20 typedef struct remote_pci_devs { @@ -302,6 +305,11 @@ fail: del_from_pci_devs_list((const char *)msg->id); } =20 +static void process_device_reset_msg(ProcMsg *msg) +{ + qemu_devices_reset(); +} + static int init_drive(QDict *rqdict, Error **errp) { QemuOpts *opts; @@ -520,6 +528,9 @@ static void process_msg(GIOCondition cond, ProcChannel = *chan) notify_proxy(wait, (uint32_t)getpid()); PUT_REMOTE_WAIT(wait); break; + case DEVICE_RESET: + process_device_reset_msg(msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545464; cv=none; d=zoho.com; s=zohoarc; b=alyw0TjMa4pF5YLD3/TClMCM7YdZzsoOTaWBwqQWYj3wuGf/rJ8HFRbgQETTB7EDpvUBlwMP6SS7xndy81x7AcDb2Kb+5unaN1cKb56+PHXojVGx4bCeCE+D4CTq4E05BLG2kY+keuI5i750MigcjMWOzU+SPA3A5EaQ+P/6Eg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545464; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=xLCTaxuvRZZlI92L6U6kSPhOvCb9uW2usqynrCxGCI8=; b=b7g7+QDhKS4ksXND32KDdPXNDNn49o21L3bMUSzIUOIvEYY+5F7mPYA95mViTb9NWejXbvGZf6FE6ayyyTbGPL1XSUllsKYTG6AqO3u0c/hkCIAtbSSJkZFAY8qCO7U6X6m9j4VeyZzR79KWTbDeSqW68s3VAlXoKV5E6hQZQRQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545464898521.9697567101227; Tue, 3 Sep 2019 14:17:44 -0700 (PDT) Received: from localhost ([::1]:51640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GBI-0008GO-Tj for importer@patchew.org; Tue, 03 Sep 2019 17:17:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53724) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaR-00086w-12 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaO-0000p3-OC for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:34 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60718) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaO-0000oS-FV for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:32 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdQVm067201; Tue, 3 Sep 2019 20:39:27 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2usy66r2j0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:27 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcIx1094748; Tue, 3 Sep 2019 20:39:26 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2usu51u2a4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:25 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KdO23024778; Tue, 3 Sep 2019 20:39:25 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=xLCTaxuvRZZlI92L6U6kSPhOvCb9uW2usqynrCxGCI8=; b=aQAc5vdUZWIaU15yszrzDK0R+q1JhLDtV0Lj6iKe9i0vPfy5AecLNKXW3EVTlW/Nfofj GODFyFsQ5SIFodAu5wz3h7Qy50YT/yv4nuRkkbQSIDWX8OAeBk2Zdb9bznzErKyPiDLc ubV0vbdhihV2N6/wQVBTmnC0At7oa1yUgKTREWwsw10PhsAE1VLZvNHAcuStKAbPpgcI Q+rDwgMK9NujM8fGCsWWj6e3/+Lqbiw45lSVAKKcCH7tZDvUJ+nVU8D1xNSfSjQr6AT/ PifqqFVVZeWck93PvDgpz4Kt1Y1BiSTRXWnEKkYneUVhvqY+GaVybIlEWENbDtXg/780 kw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:04 -0400 Message-Id: <6d610b663225ed2552277156dd852f123ce45d67.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 38/45] multi-process/mon: stub functions to enable QMP module for remote process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- New patch in v3 accel/stubs/tcg-stub.c | 10 +++ configure | 4 ++ include/qemu-common.h | 8 +++ stubs/gdbstub.c | 21 +++++++ stubs/migration.c | 162 +++++++++++++++++++++++++++++++++++++++++++++= ++++ stubs/monitor.c | 32 ++++++++++ stubs/net-stub.c | 69 +++++++++++++++++++++ stubs/qapi-misc.c | 41 +++++++++++++ stubs/qapi-target.c | 49 +++++++++++++++ stubs/ui-stub.c | 130 +++++++++++++++++++++++++++++++++++++++ stubs/vl-stub.c | 92 ++++++++++++++++++++++++++++ 11 files changed, 618 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/accel/stubs/tcg-stub.c b/accel/stubs/tcg-stub.c index 52722c7..37e035b 100644 --- a/accel/stubs/tcg-stub.c +++ b/accel/stubs/tcg-stub.c @@ -109,3 +109,13 @@ 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); +} diff --git a/configure b/configure index b467441..5ee2438 100755 --- a/configure +++ b/configure @@ -7290,6 +7290,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 0235cd3..9f33af3 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 */ @@ -130,4 +132,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 2b7aee5..28c574a 100644 --- a/stubs/gdbstub.c +++ b/stubs/gdbstub.c @@ -1,6 +1,27 @@ #include "qemu/osdep.h" +#include "qemu-common.h" #include "exec/gdbstub.h" /* xml_builtin */ =20 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 0000000..28ccf80 --- /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 75dafce..0dcbe09 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 "qapi/qapi-emit-events.h" #include "monitor/monitor.h" @@ -8,16 +9,37 @@ #include "qapi/qapi-commands-qdev.h" #include "hw/qdev-core.h" #include "sysemu/sysemu.h" +#include "monitor/qdev.h" +#include "sysemu/blockdev.h" +#include "sysemu/sysemu.h" +#include "monitor/hmp.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 __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; } @@ -28,29 +50,39 @@ void monitor_init_qmp(Chardev *chr, bool pretty) =20 void monitor_init_hmp(Chardev *chr, bool use_readline) { + qemu_debug_assert(0); } =20 void qapi_event_emit(QAPIEvent event, QDict *qdict) { + 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 cb2274b..962827e 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(QDict *qdict, QObject **ret, 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 0000000..3eeedd9 --- /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 0000000..b3a3ffc --- /dev/null +++ b/stubs/qapi-target.c @@ -0,0 +1,49 @@ +#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" + +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; +} + +CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType= type, + CpuModelInfo *model, + Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} + +CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) +{ + qemu_debug_assert(0); + + return NULL; +} diff --git a/stubs/ui-stub.c b/stubs/ui-stub.c new file mode 100644 index 0000000..a5a63ea --- /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 89db36c..4415990 100644 --- a/stubs/vl-stub.c +++ b/stubs/vl-stub.c @@ -7,6 +7,12 @@ #include "sysemu/replay.h" #include "disas/disas.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; @@ -19,6 +25,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; @@ -31,6 +39,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; @@ -75,3 +88,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(CaptureState *s, const char *path, int freq, + int bits, int nchannels) +{ + qemu_debug_assert(0); + + return -1; +} --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545735; cv=none; d=zoho.com; s=zohoarc; b=eCzPLk5TRKr/5YKgQ3oNp6GGZRkoxUQIvyn1jpgPEAXQlRDBVRXC4qU8+o1Dl8nL9eCt4H5XIUNiKCz3e0nkc6if607+6lLz6QJx+FttV9dQA1wfdUTRmauu6e75Nh2X8fCSLN/l9ocihx2fT2SqGTsGmQYCubOgLlwgy/n0LW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545735; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YXMntpdnHucR0S0HJkiG0v5fei/qZsExEcUB/3nWg8s=; b=QyGWMpApP8PFbuEjRN3foNyMKhLZFlYhyVpr+Vta5TNWnmqFcvu+762FBQPb4bxALuX77wWO05f2QBZWEylbwSGYWSxmXA6X0I5MNZbUOQYDo+D7/KeWbeblWgSZJpu93ASUQ3+xm0iwFVulIR6iTlm/fyqyWrd9tkfqo8zuLkg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545735639713.5501862780313; Tue, 3 Sep 2019 14:22:15 -0700 (PDT) Received: from localhost ([::1]:51692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GFh-0003tz-Uq for importer@patchew.org; Tue, 03 Sep 2019 17:22:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53750) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaS-00089G-P4 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaR-0000r6-5L for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:36 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57712) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaQ-0000qK-V2 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:35 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdS91058074; Tue, 3 Sep 2019 20:39:28 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2usy6n022e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:28 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcbDm178418; Tue, 3 Sep 2019 20:39:27 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2us4wegren-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:27 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdQK9012895; Tue, 3 Sep 2019 20:39:26 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:25 -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 : in-reply-to : references; s=corp-2019-08-05; bh=YXMntpdnHucR0S0HJkiG0v5fei/qZsExEcUB/3nWg8s=; b=DA1PNa94fDVFIaCAJuW5gU8QslIBPmwqs33Y8wA3bF2IA8uvjaX7XXXKIUrfwOeOgG0C Czw1HCFm538aTkEc6ZPSMK0DzmS/Gqht/elOMoS30Uw0iOeBs4HDS6RYJwgnZN0z6aZ+ aUqVSCDKl9rFxIK/Rh3g5QNefrrsIeWdT0796xRpknedJPesEgxjBp9BqeoNWO4r0Dhk 0E0Ke75n7DmGp2ZY/Hbr4fGzSXgTTxmm5kJKZDIo32e68SH9stoSL4COj72p63UOfznP 4yEwV2PhEvoTn4Ph++wJswWE+nPXyrBYzL7Bdl4oaMSjUAPrriNDWz43+cTyKQSDxUx5 +g== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:05 -0400 Message-Id: <3b6822d87f65f1d6e52c22094dd646f7dae13ce0.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 39/45] multi-process/mon: build system for QMP module in remote process 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Makefile changes necessary to compile QMP module for the remote process Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- New patch in v3 Makefile.objs | 7 +++++++ Makefile.target | 20 +++++++++++++++++++- hw/core/Makefile.objs | 1 + monitor/Makefile.objs | 3 +++ qapi/Makefile.objs | 2 ++ qom/Makefile.objs | 1 + ui/Makefile.objs | 2 ++ 7 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Makefile.objs b/Makefile.objs index f817cf6..04af900 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -30,6 +30,7 @@ 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 monitor/ =20 remote-pci-obj-$(CONFIG_MPQEMU) +=3D cpus-common.o remote-pci-obj-$(CONFIG_MPQEMU) +=3D dma-helpers.o @@ -42,6 +43,7 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D iothread.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/ =20 ####################################################################### # crypto-obj-y is code used by both qemu system emulation and qemu-img @@ -112,6 +114,11 @@ common-obj-y +=3D vl-parse.o common-obj-y +=3D qapi/ endif =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 ac545fc..0ca832f 100644 --- a/Makefile.target +++ b/Makefile.target @@ -135,11 +135,29 @@ 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/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 =20 ######################################################### # Linux user emulator target diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index 0229f4b..d2c5658 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -42,3 +42,4 @@ 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 machine-qmp-cmds.o diff --git a/monitor/Makefile.objs b/monitor/Makefile.objs index e91a858..11c42ec 100644 --- a/monitor/Makefile.objs +++ b/monitor/Makefile.objs @@ -1,3 +1,6 @@ obj-y +=3D misc.o common-obj-y +=3D monitor.o qmp.o hmp.o common-obj-y +=3D qmp-cmds.o hmp-cmds.o + +remote-pci-obj-$(CONFIG_MPQEMU) +=3D monitor.o qmp.o hmp.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qmp-cmds.o hmp-cmds.o diff --git a/qapi/Makefile.objs b/qapi/Makefile.objs index c5a29e8..972bdb2 100644 --- a/qapi/Makefile.objs +++ b/qapi/Makefile.objs @@ -30,3 +30,5 @@ obj-y +=3D $(QAPI_TARGET_MODULES:%=3Dqapi-events-%.o) obj-y +=3D qapi-events.o obj-y +=3D $(QAPI_TARGET_MODULES:%=3Dqapi-commands-%.o) obj-y +=3D qapi-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 05da824..e42ea7a 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -7,3 +7,4 @@ common-obj-$(CONFIG_SOFTMMU) +=3D qom-hmp-cmds.o qom-qmp-cm= ds.o 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 cpu.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qom-qmp-cmds.o diff --git a/ui/Makefile.objs b/ui/Makefile.objs index cc2bf5b..7b5219d 100644 --- a/ui/Makefile.objs +++ b/ui/Makefile.objs @@ -65,3 +65,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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545856; cv=none; d=zoho.com; s=zohoarc; b=Qg7wuUejhHkYquvmR+LBvaqGzZSNlmcyHsoLV3nj7Y2xe+ankdgSBqekIFCrOmWOT/S0szG/LHpjNJFArd+VKzSRmuEiZay6Vt77zm6W+HplUrqs4pXGi0oG7y/7i3ny/E51Kz0c0exRaIZw8Gw0DHSuy3sUFxovcXDnAHkKyqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545856; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EYC3/3Hhu1ZNcmw2+96oI5bIEQx1yWAUx+oyASHlWHc=; b=RcHI0xAf2DAg+6HMdx9yZJCqsYJjeSU8YT9F6uyLXDhaeDYWCCrmzSJEp9MA92E6sI4UFFGcmBLJWwiFZ1Y1zQee6ed5xO81gzadxl11muhO5DYfNAVS+66ipPYghqe62cgXq07p7HobrLwoIQww35zYUEjfzdoKrYwtEB3Ph8M= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 156754585652172.63297703691535; Tue, 3 Sep 2019 14:24:16 -0700 (PDT) Received: from localhost ([::1]:51718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GHf-000682-Ap for importer@patchew.org; Tue, 03 Sep 2019 17:24:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53765) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaT-0008AZ-OM for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaS-0000rk-2H for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:37 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60816) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaR-0000qx-Om for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:35 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdULG067244; Tue, 3 Sep 2019 20:39:30 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2usy66r2j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:29 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcI55094719; Tue, 3 Sep 2019 20:39:29 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2usu51u2bh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:29 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdSp4017854; Tue, 3 Sep 2019 20:39:28 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:27 -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 : in-reply-to : references; s=corp-2019-08-05; bh=EYC3/3Hhu1ZNcmw2+96oI5bIEQx1yWAUx+oyASHlWHc=; b=na1BJDyn7VygLKpZNVElc9+Ft59ESFEzOwNAeu53rgS9drRzbyjfsCP8Tb5bjNLxl6yq 9+glwlA0i4HIjel6NJvlxzXwBM1HcFdEmQg8u1jdEjSC4q+29OJJGFtAa89k3qye4D47 fq18fvPz1ogAybb024zMd4gUZ3cFffz0KSg7sGOYcPig3a8e127Hu8SkP1u3B2L/UzVR 5K/ylJ7ELnC8Mw9HtymMT56KmBw9rKTcRowZ07Jzn2M0Xo+FnfIFCRESJnBwX6NQ8rHG e40EYOVRQnotvHKQddZLCJuUu4kmG3K27OQvTRrY20SFuZGXPIuGK2Wq9s/PRLdWC5w/ ig== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:06 -0400 Message-Id: <0d668ccf7c5fa09d4968d618df069ab74787ec29.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 40/45] multi-process/mon: Refactor monitor/chardev functions out of vl.c 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some of the initialization helper functions w.r.t monitor & chardev in vl.c are also used by the remote process. Therefore, these functions are refactored into a shared file that both QEMU & remote process could use. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- New patch in v3 vl-parse.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= ++++ vl.c | 91 ----------------------------------------------------------= --- vl.h | 4 +++ 3 files changed, 96 insertions(+), 91 deletions(-) diff --git a/vl-parse.c b/vl-parse.c index d3716d1..bee904d 100644 --- a/vl-parse.c +++ b/vl-parse.c @@ -155,3 +155,95 @@ int device_init_func(void *opaque, QemuOpts *opts, Err= or **errp) object_unref(OBJECT(dev)); return 0; } + +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 mon_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + Chardev *chr; + bool qmp; + bool pretty =3D false; + const char *chardev; + const char *mode; + + mode =3D qemu_opt_get(opts, "mode"); + if (mode =3D=3D NULL) { + mode =3D "readline"; + } + if (strcmp(mode, "readline") =3D=3D 0) { + qmp =3D false; + } else if (strcmp(mode, "control") =3D=3D 0) { + qmp =3D true; + } else { + error_setg(errp, "unknown monitor mode \"%s\"", mode); + return -1; + } + + if (!qmp && qemu_opt_get(opts, "pretty")) { + warn_report("'pretty' is deprecated for HMP monitors, it has no ef= fect " + "and will be removed in future versions"); + } + if (qemu_opt_get_bool(opts, "pretty", 0)) { + pretty =3D true; + } + + chardev =3D qemu_opt_get(opts, "chardev"); + if (!chardev) { + error_report("chardev is required"); + exit(1); + } + chr =3D qemu_chr_find(chardev); + if (chr =3D=3D NULL) { + error_setg(errp, "chardev \"%s\" not found", chardev); + return -1; + } + + if (qmp) { + monitor_init_qmp(chr, pretty); + } else { + monitor_init_hmp(chr, true); + } + return 0; +} + +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/vl.c b/vl.c index 08e9c09..3c03405 100644 --- a/vl.c +++ b/vl.c @@ -2264,19 +2264,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; -} =20 #ifdef CONFIG_VIRTFS static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp) @@ -2285,84 +2272,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) -{ - Chardev *chr; - bool qmp; - bool pretty =3D false; - const char *chardev; - const char *mode; - - mode =3D qemu_opt_get(opts, "mode"); - if (mode =3D=3D NULL) { - mode =3D "readline"; - } - if (strcmp(mode, "readline") =3D=3D 0) { - qmp =3D false; - } else if (strcmp(mode, "control") =3D=3D 0) { - qmp =3D true; - } else { - error_setg(errp, "unknown monitor mode \"%s\"", mode); - return -1; - } - - if (!qmp && qemu_opt_get(opts, "pretty")) { - warn_report("'pretty' is deprecated for HMP monitors, it has no ef= fect " - "and will be removed in future versions"); - } - if (qemu_opt_get_bool(opts, "pretty", 0)) { - pretty =3D true; - } - - chardev =3D qemu_opt_get(opts, "chardev"); - if (!chardev) { - error_report("chardev is required"); - exit(1); - } - chr =3D qemu_chr_find(chardev); - if (chr =3D=3D NULL) { - error_setg(errp, "chardev \"%s\" not found", chardev); - return -1; - } - - if (qmp) { - monitor_init_qmp(chr, pretty); - } else { - monitor_init_hmp(chr, true); - } - return 0; -} - -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 */ diff --git a/vl.h b/vl.h index 8c40fed..21ca747 100644 --- a/vl.h +++ b/vl.h @@ -50,5 +50,9 @@ int device_init_func(void *opaque, QemuOpts *opts, Error = **errp); int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp); int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp); =20 +void monitor_parse(const char *optarg, const char *mode, bool pretty); +int mon_init_func(void *opaque, QemuOpts *opts, Error **errp); +int chardev_init_func(void *opaque, QemuOpts *opts, Error **errp); + #endif /* VL_H */ =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567546127; cv=none; d=zoho.com; s=zohoarc; b=RuwFshi70tXFgZMhi7eoLUwlbKnaDTk9FsivSUMs47VvhNiiyhlxXP3VcHWeCK2EKOnf+V/6kb+lII1+ZRqeJ4DWd73xTDVQxXyodpAyLrBzJBOHdoM137tPxLNbGiaaxcMTnjogIgpw4PfW+GoJMcUimVm6GIVcgMJPu7GppAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567546127; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QjNGkiktIFNQTlzT1Gx4wwJ8fVaMJjNVq/WelnMLhyw=; b=EPVnVYs/H4+fm/aoI30CR1XwQoWoP2Nq+YuEjCkhXQ/Rk/Ve5Qr6CqiP8nbtm7excRAkqYFheSQIKITnt3YvSf7OzObc0LaLCHlGfw8NpHnq7VwDOd34xq827Al8hpcHsa13gh+tJU/O53rF+tIBts6cnxNpbUHDvh73N5D5mF0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567546127601874.6578228404438; Tue, 3 Sep 2019 14:28:47 -0700 (PDT) Received: from localhost ([::1]:51764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GM1-0001WD-Pu for importer@patchew.org; Tue, 03 Sep 2019 17:28:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53844) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Faa-0008JH-6B for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaW-0000wW-Jp for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:44 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37544) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaW-0000u5-8Z for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:40 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdQ1P070881; Tue, 3 Sep 2019 20:39:32 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2usy4u8345-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:32 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc9qR025296; Tue, 3 Sep 2019 20:39:31 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2us5pha0wk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:31 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdTw2017860; Tue, 3 Sep 2019 20:39:29 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=QjNGkiktIFNQTlzT1Gx4wwJ8fVaMJjNVq/WelnMLhyw=; b=N7VkuJNLA+1UKoquHON7wtTkSUWVnpMxIsPCpZWxO36lYz9dLTGQW9lkMpR285oMGAGz ApTmAMXBqI/RSqsRuRhwZ5i84KdEyKNw9PpeBF1lm9C5lNCh25FC61KT0THMhB7NgV4s iUXkgWJuBTLdf+N3NqUrR4ulFQ697XneWK4S4TF13ildutAEWWf/5XP4iDxlvI0bGOcS HusFxkBOTPHfiXkAYLNmDxCiUAnxJu3qFf2Z4MRog1xgqWmnHqxmN1yiM7G+DTdV3/Ni W4jDK+vrg1J7m6CTAbKf24TGp6OstdH1aDNznVCQSGmg/aLtRLogelOyJJnLT9h7pjHN Qw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:07 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 41/45] multi-process/mon: trim HMP command set for remote storage processes 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Trim down the list of HMP commands available for storage class of remote processes. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- New patch in v3 Makefile.objs | 2 + Makefile.target | 14 +- hmp-scsi-commands-info.hx | 167 ++++++++++++++++++++ hmp-scsi-commands.hx | 384 +++++++++++++++++++++++++++++++++++++++++= ++++ monitor/misc.c | 84 +++++----- monitor/monitor-internal.h | 38 +++++ qom/Makefile.objs | 2 +- 7 files changed, 651 insertions(+), 40 deletions(-) create mode 100644 hmp-scsi-commands-info.hx create mode 100644 hmp-scsi-commands.hx diff --git a/Makefile.objs b/Makefile.objs index 04af900..11cd7be 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -45,6 +45,8 @@ remote-pci-obj-$(CONFIG_MPQEMU) +=3D iothread.o remote-lsi-obj-$(CONFIG_MPQEMU) +=3D hw/ remote-lsi-obj-$(CONFIG_MPQEMU) +=3D ui/ =20 +remote-lsi-obj-$(CONFIG_MPQEMU) +=3D device-hotplug.o + ####################################################################### # crypto-obj-y is code used by both qemu system emulation and qemu-img =20 diff --git a/Makefile.target b/Makefile.target index 0ca832f..00a4b85 100644 --- a/Makefile.target +++ b/Makefile.target @@ -210,6 +210,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) @@ -294,10 +298,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-scsi-commands.hx $(SRC_PATH)/scripts/= hxtool + $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$(= TARGET_DIR)$@") + +hmp-scsi-commands-info.h: $(SRC_PATH)/hmp-scsi-commands-info.hx $(SRC_PATH= )/scripts/hxtool + $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$(= TARGET_DIR)$@") +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/hmp-scsi-commands-info.hx b/hmp-scsi-commands-info.hx new file mode 100644 index 0000000..315a445 --- /dev/null +++ b/hmp-scsi-commands-info.hx @@ -0,0 +1,167 @@ +HXCOMM Use DEFHEADING() to define headings in both help text and texi +HXCOMM Text between STEXI and ETEXI are copied to texi version and +HXCOMM discarded from C version +HXCOMM DEF(command, args, callback, arg_string, help) is used to construct +HXCOMM monitor info commands +HXCOMM HXCOMM can be used for comments, discarded from both texi and C + +STEXI +@table @option +@item info @var{subcommand} +@findex info +Show various information about the system state. +@table @option +ETEXI + + { + .name =3D "version", + .args_type =3D "", + .params =3D "", + .help =3D "show the version of QEMU", + .cmd =3D hmp_info_version, + .flags =3D "p", + }, + +STEXI +@item info version +@findex info version +Show the version of QEMU. +ETEXI + + { + .name =3D "chardev", + .args_type =3D "", + .params =3D "", + .help =3D "show the character devices", + .cmd =3D hmp_info_chardev, + .flags =3D "p", + }, + +STEXI +@item info chardev +@findex info chardev +Show the character devices. +ETEXI + + { + .name =3D "block", + .args_type =3D "nodes:-n,verbose:-v,device:B?", + .params =3D "[-n] [-v] [device]", + .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, + }, + +STEXI +@item info block +@findex info block +Show info of one block device or all block devices. +ETEXI + + { + .name =3D "blockstats", + .args_type =3D "", + .params =3D "", + .help =3D "show block device statistics", + .cmd =3D hmp_info_blockstats, + }, + +STEXI +@item info blockstats +@findex info blockstats +Show block device statistics. +ETEXI + + { + .name =3D "block-jobs", + .args_type =3D "", + .params =3D "", + .help =3D "show progress of ongoing block device operations", + .cmd =3D hmp_info_block_jobs, + }, + +STEXI +@item info block-jobs +@findex info block-jobs +Show progress of ongoing block device operations. +ETEXI + + { + .name =3D "history", + .args_type =3D "", + .params =3D "", + .help =3D "show the command line history", + .cmd =3D hmp_info_history, + .flags =3D "p", + }, + +STEXI +@item info history +@findex info history +Show the command line history. +ETEXI + + { + .name =3D "pci", + .args_type =3D "", + .params =3D "", + .help =3D "show PCI info", + .cmd =3D hmp_info_pci, + }, + +STEXI +@item info pci +@findex info pci +Show PCI information. +ETEXI + + { + .name =3D "qtree", + .args_type =3D "", + .params =3D "", + .help =3D "show device tree", + .cmd =3D hmp_info_qtree, + }, + +STEXI +@item info qtree +@findex info qtree +Show device tree. +ETEXI + + { + .name =3D "qdm", + .args_type =3D "", + .params =3D "", + .help =3D "show qdev device model list", + .cmd =3D hmp_info_qdm, + }, + +STEXI +@item info qdm +@findex info qdm +Show qdev device model list. +ETEXI + + { + .name =3D "qom-tree", + .args_type =3D "path:s?", + .params =3D "[path]", + .help =3D "show QOM composition tree", + .cmd =3D hmp_info_qom_tree, + .flags =3D "p", + }, + +STEXI +@item info qom-tree +@findex info qom-tree +Show QOM composition tree. +ETEXI + +STEXI +@end table +ETEXI + +STEXI +@end table +ETEXI diff --git a/hmp-scsi-commands.hx b/hmp-scsi-commands.hx new file mode 100644 index 0000000..d3438f3 --- /dev/null +++ b/hmp-scsi-commands.hx @@ -0,0 +1,384 @@ +HXCOMM Use DEFHEADING() to define headings in both help text and texi +HXCOMM Text between STEXI and ETEXI are copied to texi version and +HXCOMM discarded from C version +HXCOMM DEF(command, args, callback, arg_string, help) is used to construct +HXCOMM monitor commands +HXCOMM HXCOMM can be used for comments, discarded from both texi and C + +STEXI +@table @option +ETEXI + + { + .name =3D "help|?", + .args_type =3D "name:S?", + .params =3D "[cmd]", + .help =3D "show the help", + .cmd =3D do_help_cmd, + .flags =3D "p", + }, + +STEXI +@item help or ? [@var{cmd}] +@findex help +Show the help for all commands or just for command @var{cmd}. +ETEXI + + { + .name =3D "q|quit", + .args_type =3D "", + .params =3D "", + .help =3D "quit the emulator", + .cmd =3D hmp_quit, + }, + +STEXI +@item q or quit +@findex quit +Quit the emulator. +ETEXI + + { + .name =3D "block_resize", + .args_type =3D "device:B,size:o", + .params =3D "device size", + .help =3D "resize a block image", + .cmd =3D hmp_block_resize, + }, + +STEXI +@item block_resize +@findex block_resize +Resize a block image while a guest is running. Usually requires guest +action to see the updated size. Resize to a lower size is supported, +but should be used with extreme caution. Note that this command only +resizes image files, it can not resize block devices like LVM volumes. +ETEXI + + { + .name =3D "block_stream", + .args_type =3D "device:B,speed:o?,base:s?", + .params =3D "device [speed [base]]", + .help =3D "copy data from a backing file into a block device= ", + .cmd =3D hmp_block_stream, + }, + +STEXI +@item block_stream +@findex block_stream +Copy data from a backing file into a block device. +ETEXI + + { + .name =3D "block_job_set_speed", + .args_type =3D "device:B,speed:o", + .params =3D "device speed", + .help =3D "set maximum speed for a background block operatio= n", + .cmd =3D hmp_block_job_set_speed, + }, + +STEXI +@item block_job_set_speed +@findex block_job_set_speed +Set maximum speed for a background block operation. +ETEXI + + { + .name =3D "block_job_cancel", + .args_type =3D "force:-f,device:B", + .params =3D "[-f] device", + .help =3D "stop an active background block operation (use -f" + "\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, + }, + +STEXI +@item block_job_cancel +@findex block_job_cancel +Stop an active background block operation (streaming, mirroring). +ETEXI + + { + .name =3D "block_job_complete", + .args_type =3D "device:B", + .params =3D "device", + .help =3D "stop an active background block operation", + .cmd =3D hmp_block_job_complete, + }, + +STEXI +@item block_job_complete +@findex block_job_complete +Manually trigger completion of an active background block operation. +For mirroring, this will switch the device to the destination path. +ETEXI + + { + .name =3D "block_job_pause", + .args_type =3D "device:B", + .params =3D "device", + .help =3D "pause an active background block operation", + .cmd =3D hmp_block_job_pause, + }, + +STEXI +@item block_job_pause +@findex block_job_pause +Pause an active block streaming operation. +ETEXI + + { + .name =3D "block_job_resume", + .args_type =3D "device:B", + .params =3D "device", + .help =3D "resume a paused background block operation", + .cmd =3D hmp_block_job_resume, + }, + +STEXI +@item block_job_resume +@findex block_job_resume +Resume a paused block streaming operation. +ETEXI + + { + .name =3D "eject", + .args_type =3D "force:-f,device:B", + .params =3D "[-f] device", + .help =3D "eject a removable medium (use -f to force it)", + .cmd =3D hmp_eject, + }, + +STEXI +@item eject [-f] @var{device} +@findex eject +Eject a removable medium (use -f to force it). +ETEXI + + { + .name =3D "drive_del", + .args_type =3D "id:B", + .params =3D "device", + .help =3D "remove host block device", + .cmd =3D hmp_drive_del, + }, + +STEXI +@item drive_del @var{device} +@findex drive_del +Remove host block device. The result is that guest generated IO is no lon= ger +submitted against the host device underlying the disk. Once a drive has +been deleted, the QEMU Block layer returns -EIO which results in IO +errors in the guest for applications that are reading/writing to the devic= e. +These errors are always reported to the guest, regardless of the drive's e= rror +actions (drive options rerror, werror). +ETEXI + + { + .name =3D "change", + .args_type =3D "device:B,target:F,arg:s?,read-only-mode:s?", + .params =3D "device filename [format [read-only-mode]]", + .help =3D "change a removable medium, optional format", + .cmd =3D hmp_change, + }, + +STEXI +@item change @var{device} @var{setting} +@findex change +Change the configuration of a device. + +@table @option +@item change @var{diskdevice} @var{filename} [@var{format} [@var{read-only= -mode}]] +Change the medium for a removable disk device to point to @var{filename}. = eg + +@example +(qemu) change ide1-cd0 /path/to/some.iso +@end example + +@var{format} is optional. + +@var{read-only-mode} may be used to change the read-only status of the dev= ice. +It accepts the following values: + +@table @var +@item retain +Retains the current status; this is the default. + +@item read-only +Makes the device read-only. + +@item read-write +Makes the device writable. +@end table + +@item change vnc @var{display},@var{options} +Change the configuration of the VNC server. The valid syntax for @var{disp= lay} +and @var{options} are described at @ref{sec_invocation}. eg + +@example +(qemu) change vnc localhost:1 +@end example + +@item change vnc password [@var{password}] + +Change the password associated with the VNC server. If the new password is= not +supplied, the monitor will prompt for it to be entered. VNC passwords are = only +significant up to 8 letters. eg + +@example +(qemu) change vnc password +Password: ******** +@end example + +@end table +ETEXI + + { + .name =3D "device_add", + .args_type =3D "device:O", + .params =3D "driver[,prop=3Dvalue][,...]", + .help =3D "add device, like -device on the command line", + .cmd =3D hmp_device_add, + .command_completion =3D device_add_completion, + }, + +STEXI +@item device_add @var{config} +@findex device_add +Add device. +ETEXI + + { + .name =3D "device_del", + .args_type =3D "id:s", + .params =3D "device", + .help =3D "remove device", + .cmd =3D hmp_device_del, + .command_completion =3D device_del_completion, + }, + +STEXI +@item device_del @var{id} +@findex device_del +Remove device @var{id}. @var{id} may be a short ID +or a QOM object path. +ETEXI + + { + .name =3D "drive_backup", + .args_type =3D "reuse:-n,full:-f,compress:-c,device:B,target:s,fo= rmat:s?", + .params =3D "[-n] [-f] [-c] device target [format]", + .help =3D "initiates a point-in-time\n\t\t\t" + "copy for a device. The device's contents are\n\t\t\= t" + "copied to the new image file, excluding data that\n= \t\t\t" + "is written after the command is started.\n\t\t\t" + "The -n flag requests QEMU to reuse the image found\= n\t\t\t" + "in new-image-file, instead of recreating it from sc= ratch.\n\t\t\t" + "The -f flag requests QEMU to copy the whole disk,\n= \t\t\t" + "so that the result does not need a backing file.\n\= t\t\t" + "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, + }, +STEXI +@item drive_backup +@findex drive_backup +Start a point-in-time copy of a block device to a specificed target. +ETEXI + + { + .name =3D "drive_add", + .args_type =3D "node:-n,pci_addr:s,opts:s", + .params =3D "[-n] [[:]:]\n" + "[file=3Dfile][,if=3Dtype][,bus=3Dn]\n" + "[,unit=3Dm][,media=3Dd][,index=3Di]\n" + "[,snapshot=3Don|off][,cache=3Don|off]\n" + "[,readonly=3Don|off][,copy-on-read=3Don|off]", + .help =3D "add drive to PCI storage controller", + .cmd =3D hmp_drive_add, + }, + +STEXI +@item drive_add +@findex drive_add +Add drive to PCI storage controller. +ETEXI + + { + .name =3D "chardev-add", + .args_type =3D "args:s", + .params =3D "args", + .help =3D "add chardev", + .cmd =3D hmp_chardev_add, + .command_completion =3D chardev_add_completion, + }, + +STEXI +@item chardev-add args +@findex chardev-add +chardev-add accepts the same parameters as the -chardev command line switc= h. + +ETEXI + + { + .name =3D "chardev-change", + .args_type =3D "id:s,args:s", + .params =3D "id args", + .help =3D "change chardev", + .cmd =3D hmp_chardev_change, + }, + +STEXI +@item chardev-change args +@findex chardev-change +chardev-change accepts existing chardev @var{id} and then the same argumen= ts +as the -chardev command line switch (except for "id"). + +ETEXI + + { + .name =3D "chardev-remove", + .args_type =3D "id:s", + .params =3D "id", + .help =3D "remove chardev", + .cmd =3D hmp_chardev_remove, + .command_completion =3D chardev_remove_completion, + }, + +STEXI +@item chardev-remove id +@findex chardev-remove +Removes the chardev @var{id}. + +ETEXI + + { + .name =3D "chardev-send-break", + .args_type =3D "id:s", + .params =3D "id", + .help =3D "send a break on chardev", + .cmd =3D hmp_chardev_send_break, + .command_completion =3D chardev_remove_completion, + }, + +STEXI +@item chardev-send-break id +@findex chardev-send-break +Send a break on the chardev @var{id}. + +ETEXI + + { + .name =3D "info", + .args_type =3D "item:s?", + .params =3D "[subcommand]", + .help =3D "show various information about the system state", + .cmd =3D hmp_info_help, + .sub_table =3D hmp_info_cmds, + .flags =3D "p", + }, + +STEXI +@end table +ETEXI diff --git a/monitor/misc.c b/monitor/misc.c index 00338c0..4914f46 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -176,12 +176,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 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"); @@ -225,7 +225,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"); } @@ -436,7 +436,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; @@ -459,7 +459,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"); @@ -470,13 +470,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); @@ -487,7 +487,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; @@ -507,7 +507,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 @@ -518,7 +518,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"); @@ -578,7 +578,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 @@ -588,7 +588,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"); @@ -605,7 +605,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")) { @@ -617,7 +617,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) @@ -633,7 +633,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) { @@ -775,7 +775,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"); @@ -785,7 +785,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"); @@ -815,7 +815,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; @@ -835,7 +835,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; @@ -890,7 +890,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; @@ -917,7 +917,7 @@ static void hmp_gpa2hpa(Monitor *mon, const QDict *qdic= t) } #endif =20 -static void do_print(Monitor *mon, const QDict *qdict) +void do_print(Monitor *mon, const QDict *qdict) { int format =3D qdict_get_int(qdict, "format"); hwaddr val =3D qdict_get_int(qdict, "val"); @@ -943,7 +943,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; @@ -963,7 +963,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"); @@ -987,7 +987,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, @@ -1004,7 +1004,7 @@ static void hmp_mouse_button(Monitor *mon, const QDic= t *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"); @@ -1038,7 +1038,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"); @@ -1060,7 +1060,7 @@ static void hmp_ioport_write(Monitor *mon, const QDic= t *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"); @@ -1073,7 +1073,7 @@ static void hmp_boot_set(Monitor *mon, const QDict *q= dict) } } =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); @@ -1086,7 +1086,7 @@ static void hmp_info_mtree(Monitor *mon, const QDict = *qdict) =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; @@ -1103,7 +1103,7 @@ static void hmp_info_profile(Monitor *mon, const QDic= t *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"); } @@ -1112,7 +1112,7 @@ static void hmp_info_profile(Monitor *mon, const QDic= t *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; @@ -1123,7 +1123,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"); @@ -1139,7 +1139,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 has_freq =3D qdict_haskey(qdict, "freq"); @@ -1192,7 +1192,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); @@ -1219,7 +1219,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); @@ -1236,7 +1236,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"); @@ -1277,7 +1277,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"); @@ -1330,7 +1330,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"); @@ -1799,13 +1799,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/monitor/monitor-internal.h b/monitor/monitor-internal.h index 7760b22..5e8abd6 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -180,4 +180,42 @@ void help_cmd(Monitor *mon, const char *name); void handle_hmp_command(MonitorHMP *mon, const char *cmdline); int hmp_compare_cmd(const char *name, const char *list); =20 +void 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 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 diff --git a/qom/Makefile.objs b/qom/Makefile.objs index e42ea7a..4410d71 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -7,4 +7,4 @@ common-obj-$(CONFIG_SOFTMMU) +=3D qom-hmp-cmds.o qom-qmp-cm= ds.o 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 cpu.o -remote-pci-obj-$(CONFIG_MPQEMU) +=3D qom-qmp-cmds.o +remote-pci-obj-$(CONFIG_MPQEMU) +=3D qom-qmp-cmds.o qom-hmp-cmds.o --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545962; cv=none; d=zoho.com; s=zohoarc; b=JofYNpxwoATyV8kqqdmhn3qTGqa1AEawd5I/XJcvOEISHOme30AnqcH1BUy8LJA9N93BYJvtVNUnFnM/KlRBuTmjJCL7Hkke4/5Alqv8SJVtd+3SzVPVrO9QMBfJYJX/vugdkK3v7JekRfAFXfXFCpAI9fP6A6wFk3k5CQ4vyY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545962; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Ua0BS30lSDPp5MEUWWufTVVG+lPd8WUQahGgCFpVYD0=; b=WwgtP95yHfsws6pQVpV8gcpErbkdIaD74ar8rU75pOIXQM7O6/7JsFNvmKVmXE6W4tOL6NYZpp+Q43oBew5r6lCjM8TV61nfwUR0khGw2WWpbXZHH5YTDDUEFbnOeS0hgqlb668zYZENZEh40nl1QAxAhmDqUUAG2bt8d2X8ODQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1567545962573175.3625369094866; Tue, 3 Sep 2019 14:26:02 -0700 (PDT) Received: from localhost ([::1]:51738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GJH-0007td-VW for importer@patchew.org; Tue, 03 Sep 2019 17:25:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53792) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaV-0008DQ-Tt for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaU-0000tQ-Ne for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:39 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:60880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaU-0000so-F4 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:38 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdXVW067263; Tue, 3 Sep 2019 20:39:33 GMT Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2usy66r2je-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:33 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcIcr094739; Tue, 3 Sep 2019 20:39:32 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2usu51u2d4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:32 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdVFb017870; Tue, 3 Sep 2019 20:39:31 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:30 -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 : in-reply-to : references; s=corp-2019-08-05; bh=Ua0BS30lSDPp5MEUWWufTVVG+lPd8WUQahGgCFpVYD0=; b=KxeBPd+VNuCRbQLVjOSv9FjSbU25ds76SpQHmfmMv7EClqHa9kPNugojjZcpIkTiV0nI pzymaKawOgp1p0kOdYxp43MeTERT/FjEEFsckvyc+T7Co8bRWZn5voaIrEriwPBd4tiD G1qneA/oPC91/XxMnDb5mnmeA5B068dGFNYkDnFwcFmmjvb8UgVSPK0Rjqm+q0bZm0lv s6l8fHPFD8uwoUws0mZqtRJyKxmSmvOkuFyg+b8zeBAO74107ntzXZLxHnW5GL4Ncr/j /fd2H1H9ZkUO2iuLG9iqtxK8FTW5hesWeVjco3cW6duOOIVXMy+wSQsgPCM4VUg558ON Jw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:08 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 42/45] multi-process/mon: Initialize QMP module for remote processes 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- New patch in v3 remote/remote-main.c | 11 +++++++++++ remote/remote-opts.c | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index a6ff338..41da405 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -68,6 +68,7 @@ =20 #include "monitor/monitor.h" #include "sysemu/reset.h" +#include "vl.h" =20 static ProxyLinkState *proxy_link; =20 @@ -562,6 +563,8 @@ int main(int argc, char *argv[], char **envp) =20 module_call_init(MODULE_INIT_QOM); =20 + monitor_init_globals(); + bdrv_init_with_whitelist(); =20 if (qemu_init_main_loop(&err)) { @@ -577,6 +580,8 @@ int main(int argc, char *argv[], char **envp) =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); @@ -609,6 +614,12 @@ int main(int argc, char *argv[], char **envp) =20 proxy_link_set_callback(proxy_link, process_msg); =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); + start_handler(proxy_link); =20 return 0; diff --git a/remote/remote-opts.c b/remote/remote-opts.c index 416ff59..7ddfe5c 100644 --- a/remote/remote-opts.c +++ b/remote/remote-opts.c @@ -95,6 +95,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 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567546222; cv=none; d=zoho.com; s=zohoarc; b=cFQT28CC0WOWg8gaPHvfMG6EsLkExDVOKXFa9XDxGm7qTLPBq3ATF8jVY/pBcVpOBZTK/Eyxrj3niibFkjV8rG8nTxKLBQRe6+Sh8iXa6aUX00+W0Az7rwpl7irg/ESlZAS95IXtQOMcJze+id/wr4ZP5Ibdfb2+lmj9SfEhvEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567546222; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pCUUTn8D7nq/xN69MM8FDXjkbfEeZhFTAK5krQ6GEbw=; b=O80fZ88elsBi4awsHej2MTdGVV92fTS2yB3Um2eDt/J7CnvUWwUxu9BJAyA2y9QCDwkfmvLxGxI7QYyPeMN8afh/DB9npmyoUmGaKkDDKhWS6Iqfl0PJgSpF28qFrTjR9hzNJmrFGxWWES50xiWcpzWXw0/Jbkc25qcVKabJx7w= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567546222116173.6653236352056; Tue, 3 Sep 2019 14:30:22 -0700 (PDT) Received: from localhost ([::1]:51774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GNX-0003CB-EJ for importer@patchew.org; Tue, 03 Sep 2019 17:30:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53817) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FaX-0008FD-7T for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FaV-0000uM-Uf for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:41 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37532) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FaV-0000tp-Mm for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:39 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdY8c070955; Tue, 3 Sep 2019 20:39:34 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2usy4u834b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:34 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc9Ri025299; Tue, 3 Sep 2019 20:39:33 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2us5pha0yb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:33 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x83KdXBO013045; Tue, 3 Sep 2019 20:39:33 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39: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 : in-reply-to : references; s=corp-2019-08-05; bh=pCUUTn8D7nq/xN69MM8FDXjkbfEeZhFTAK5krQ6GEbw=; b=RNtqDbqlMd2UJ44Nl9/5oORW7j6Bjo+6Zw4td79nQbC1t8Hi19Ef4myJwCj4DOB4sSg6 Sr4dKrqvf3qxgvHBLNR53W1MKn/oPvB1rOfjO6dwJnLGf6dTdpWcm8BIShqtiQ6L2Tfl L6q18gA3btgSTEWCV/wntEpvYZMJYKGFEl0/MT9Ejnr273li7140wvdlA254UQeDp8d5 ippHCkzyVtv2nkS93+cB/BKIvkAHkR+RmW6eWwaL52Q4uMXuF3136zLFKSzB5I9SiM6z SNGjCrqIvC5vGT5BhC2+uxa4eJlt8mtjvu12PC8SokBf93iLwYOLQvBbUq9JLnFB0v4V Qg== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:09 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC v3 PATCH 43/45] multi-process: prevent duplicate memory initialization in remote 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When multiple controllers are configured in a remote process, it's better for the memory to be managed by only one of the proxy objects for that process, in order to conserve file descriptors. Added "mem_int" flag for this purpose. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- New patch in v3 hw/proxy/qemu-proxy.c | 13 ++++++++++++- include/hw/proxy/qemu-proxy.h | 1 + qdev-monitor.c | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index c812145..8b820cf 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -363,6 +363,13 @@ static void pci_proxy_write_config(PCIDevice *d, uint3= 2_t addr, uint32_t val, PCI_PROXY_DEV(d)->dev_id, CONF_WRITE); } =20 +static void pci_proxy_dev_inst_init(Object *obj) +{ + PCIProxyDev *dev =3D PCI_PROXY_DEV(obj); + + dev->mem_init =3D false; +} + static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); @@ -377,6 +384,7 @@ 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), + .instance_init =3D pci_proxy_dev_inst_init, .abstract =3D true, .class_size =3D sizeof(PCIProxyDevClass), .class_init =3D pci_proxy_dev_class_init, @@ -483,7 +491,10 @@ static void init_proxy(PCIDevice *dev, char *command, = bool need_spawn, Error **e proxy_link_init_channel(pdev->proxy_link, &pdev->proxy_link->mmio, pdev->mmio_sock); =20 - configure_memory_sync(pdev->sync, pdev->proxy_link); + if (!pdev->mem_init) { + pdev->mem_init =3D true; + configure_memory_sync(pdev->sync, pdev->proxy_link); + } } =20 static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index d88fbd4..610695f 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -51,6 +51,7 @@ typedef struct PCIProxyDev { ProxyLinkState *proxy_link; =20 RemoteMemSync *sync; + bool mem_init; struct kvm_irqfd irqfd; =20 EventNotifier intr; diff --git a/qdev-monitor.c b/qdev-monitor.c index f1065af..3b08e23 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -712,10 +712,10 @@ DeviceState *qdev_proxy_add(const char *rid, const ch= ar *id, char *bus, pdev->socket =3D old_pdev->socket; pdev->mmio_sock =3D old_pdev->mmio_sock; pdev->remote_pid =3D old_pdev->remote_pid; + pdev->mem_init =3D true; } else { pdev->rsocket =3D managed ? rsocket : -1; pdev->socket =3D managed ? rsocket : -1; - } pdev->managed =3D managed; =20 --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545570; cv=none; d=zoho.com; s=zohoarc; b=GsmqD0jSqGezSmln+4HCTVHJ3BqV6xPvAWSJiLDHLmZyQ9xGWqKDDQcy/nfomzt/eXd5Jo0VyCuOuGBiJGqoFqd/8iS9Izox4EZ1whDEdxuYMol6kNinkmW2o2MPO16Ao65n4UO0tUrISYTii6yyvWHeTwMGSWSGYUyO/JYXnuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545570; 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:ARC-Authentication-Results; bh=di0afMSsgXXi9QitPeqh1yXRtmcsYXkhWDdKFzn2tBI=; b=U3luZNt1zngTjtig/uFvvyivoUZdIfn4SN43buVBGCnA8zfYbYfDpoQFhVGV9n2fzcXHZedLxPEMe/TNQ6isPuuAQ8HOSGHUjQ3O/hySdM4mXX2rxVNfr21qLd7uPxc+S/82HwGEHxtZ0wkUqP0zXzDF2O8LVjaL+AsBFQEhOAo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1567545570280488.9722281118285; Tue, 3 Sep 2019 14:19:30 -0700 (PDT) Received: from localhost ([::1]:51648 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GD2-000181-A4 for importer@patchew.org; Tue, 03 Sep 2019 17:19:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53871) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Faf-0008QM-JB for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5Fab-00010o-Rw for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:49 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:32800) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5Fab-00010E-GM for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:39:45 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KdaR1067287; Tue, 3 Sep 2019 20:39:38 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2usy66r2jt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:37 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83KcAlB025388; Tue, 3 Sep 2019 20:39:37 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2us5pha10m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:36 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83KdYIN029143; Tue, 3 Sep 2019 20:39:34 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:33 -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 : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=hxeKK/qh9ZE+ORb7l8efNgDV+/6JxPDwkO6gyQ0/c4M=; b=R/d0dGkcmia69JtABjjUBj7TVlg2AvkW3p4dfAeB5KZikCi2NcYJ0GMeutSOFZGB8nCS HXXDKSSxbWt96y1rUn4zzxXm8Appr56O+hndtQunWwEv5mQhqjGxPLNEdAr0BhJhitNz Pk/2N6JumPcejLNx0ipTD+2PxI7nkuIwOYOQq82jpe20cisxQFdELCsqy10LNEOlEQ7o foRJqNNKrxH3WoeThYmIAHqX87geDranz7aZIhkxce/vRRJT2P5FNpuJ/YeyHLYyp3Ci 6YV7xPTDdsElL8k25zXSSTqEWw3yJedUrSVI3Q3GDtkWH/xfekObhqWaeMSTEMw8pSYt Tw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:10 -0400 Message-Id: <59cb496983f03b05f6da87af73bc2a2ac0bb7f81.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id x83KdaR1067287 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC v3 PATCH 44/45] multi-process: add the concept description to docs/devel/qemu-multiprocess 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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 --- v2 -> v3: - Updated with latest design of this project docs/devel/qemu-multiprocess.txt | 627 +++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 627 insertions(+) create mode 100644 docs/devel/qemu-multiprocess.txt diff --git a/docs/devel/qemu-multiprocess.txt b/docs/devel/qemu-multiproces= s.txt new file mode 100644 index 0000000..5b94c8d --- /dev/null +++ b/docs/devel/qemu-multiprocess.txt @@ -0,0 +1,627 @@ +Disaggregating QEMU + +This document describes implementation details of multi-process +qemu. + +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=E2=80=99s VT +extensions. Finally, it provides IO services to the VM by emulating HW +IO devices, such as disk and network devices. + +A disaggregated QEMU + +A disaggregated 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 disaggregated mode, it would +be a control point that executes the processes needed to support the VM +being created, but 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 disaggregated 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 QEMU disaggregating +for a couple of reasons. 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 =E2=80=9Cfoo=E2=80=9D 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 =E2=80=9Cpci-device=E2=80=9D for a PCI device) and = QEMU will +instantiate a parent object before calling the device=E2=80=99s instantiat= ion +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=E2=80=99s running on behalf of can a= ccess. + + +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 =E2=80=9Cid=E2=80=9D = option that +identifies the process to later _-device_ options. The process version +is: + + -remote id=3Ddisk-proc,command=3D"disk-proc " + +And the socket version is: + + -remote id=3Ddisk-proc,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 be identify +the remote process with a =E2=80=9Cremote=E2=80=9D option on their _-devic= e_ 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 =E2=80=9Cdisk-proc,=E2=80= =9D as +described in the previous section, the QEMU command line would be: + + -device lsi53c895a,id=3Dscsi0,remote=3Ddisk-proc + -device scsi-hd,drive=3Ddrive0,bus=3Dscsi0.0,scsi-id=3D0,remote=3Ddisk= -proc + +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 =E2=80=9Cid=E2=80=9D of =E2=80=9Cdisk-= proc=E2=80=9D 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 =E2=80=9Cid=E2=80=9D property. The remote process p= roxy 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=E2=80=99t= 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 + +There will be a new =E2=80=9Cattach-process=E2=80=9D QMP command to facili= tate device +hot-plug. This command=E2=80=99s arguments will be the same as the _-remot= e_ +command line when it=E2=80=99s used to attach to a remote process. i.e., i= t will +need an =E2=80=9Cid=E2=80=9D argument so that hot-plugged devices can late= r find it, and +a =E2=80=9Csocket=E2=80=9D argument to identify the UNIX domain socket tha= t will be used +to communicate with QEMU. + + +QEMU device proxy objects + +QEMU has an object model based on sub-classes inherited from the +=E2=80=9Cobject=E2=80=9D super-class. The sub-classes that are of interest= here are the +=E2=80=9Cdevice=E2=80=9D and =E2=80=9Cbus=E2=80=9D 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 =E2=80=9Cpci-device=E2=80=9D class, and will have the sam= e 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 =E2=80=9C-proxy=E2=80=9D appended. e.g., the =E2=80=9Clsi53= c895a=E2=80=9D proxy class +will be =E2=80=9Clsi53c895a-proxy.=E2=80=9D + +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 =E2=80=9Cdriver=E2=80=9D option is assigned to the d= evice name +when the command line is parsed, so the =E2=80=9C-proxy=E2=80=9D appended = by the command +line parsing code is removed. The =E2=80=9Cremote=E2=80=9D option isn=E2= =80=99t 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 =E2=80=9Cscsi-hd=E2=80=9D class = has its +class_init() function called only once) The second phase happens when +each object=E2=80=99s instance_init() function is called to initialize each +instance of the object. + +All device objects are sub-classes of the =E2=80=9Cdevice=E2=80=9D class, = so they also +have a realize() function that is called after instance_init() is called +and after the object=E2=80=99s static properties have been initialized. Ma= ny +device objects don=E2=80=99t 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=E2=80=99s memory region +function calls (such as memory_region_init_io()) to add callback +functions that QEMU will invoke when the guest accesses the device=E2=80= =99s +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 +=E2=80=9Cpci-device-proxy=E2=80=9D class that can serve as the parent of a= PCI device +proxy object. This class=E2=80=99s parent would be =E2=80=9Cpci-device=E2= =80=9D and it would +override the PCI parent=E2=80=99s 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=E2=80=99s _vmstate_; that will be handled by the remote proc= ess +proxy (see below). + + +QEMU remote device operation + +Generic device operations, such as DMA, will be performs 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=E2=80=99s 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 =E2=80=9Cdevice_add=E2=80=9D command can add a device emulated by a= remote +process. It needs to add a =E2=80=9Cremote=E2=80=9D 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 =E2=80=9Cadd-process=E2=80= =9D QMP +command described above. In either case, the remote process proxy will +forward the new device=E2=80=99s JSON description to the corresponding emu= lation +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=E2=80=99s device _vmstate_ over. The incoming byte +stream length and data will be saved as the proxy=E2=80=99s _vmstate_. Whe= n 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=E2=80= =99s +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=E2=80=99s bus object hierarchy until the point w= here 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=E2=80=99s 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=E2=80=99s 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. + --=20 1.8.3.1 From nobody Sun May 19 08:30:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1567545813; cv=none; d=zoho.com; s=zohoarc; b=aliWnn7DUb/njYAyE0ZVCGk8b009wDxvoOhCOpRzclHEzj+hzevGNbDrdGKV/5AB0Pl9So4BUGBdPBuJ3VfnXLhJN6KPoRjoFV3CxFCBxDk7vZsUxhQuQ8eSIl8URNRf4+exoxrY8B/BvoYa3x9BdISOD14/1J1Qvb9YLxRehKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567545813; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EYAzeaVP/SXNXnkqG9utwSGLQ8673c7bclN594zH3ig=; b=IkHSZiam+JXVezenJULA5Y1Tu480b7t/QwjJFXjZILnDG1P8X0Hncb8uERGET1jKpTrxY/JoVNznyEht9vY8np+TsXeKHUkSI57iZ71vD6SV4KNneV4GMuNnOK9QvVqzy2D9d1Xj1yrOHX2FhUY1/SVlAhGg4wMnwm1J23UNEU0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 156754581330265.26721244936607; Tue, 3 Sep 2019 14:23:33 -0700 (PDT) Received: from localhost ([::1]:51702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5GGx-0005Iw-E6 for importer@patchew.org; Tue, 03 Sep 2019 17:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54285) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5FcY-0001kB-77 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:41:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5FcW-0003Nz-Sc for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:41:46 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59980) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5FcW-0003NT-KI for qemu-devel@nongnu.org; Tue, 03 Sep 2019 16:41:44 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kfc7Z059938; Tue, 3 Sep 2019 20:41:38 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2usy6n02bh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:41:38 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x83Kc9wp025372; Tue, 3 Sep 2019 20:39:38 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2us5pha116-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2019 20:39:37 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x83Kda4I029155; Tue, 3 Sep 2019 20:39:36 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2019 13:39:35 -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 : in-reply-to : references; s=corp-2019-08-05; bh=EYAzeaVP/SXNXnkqG9utwSGLQ8673c7bclN594zH3ig=; b=bGhH486QfjL0WU25EWhsW1+Fd0qmAggVRuQFoxIdAkreCapGVcqaeostiR5gM3CexBBj 81Nzwh/YeSl4YsoOS/7rv5EZv/coYeo27TmXTeo806OOWH1XzUXLIychpsqpjnRgQ8+x 38ES8BSpinewXc776GixMnS0oArLPPUqT0BaWS0RiAYb2H3iHlmRDex4Q/P1mIofrCUj StSVwpNuN+GMSa0dKCT5+apyAZBDzNGNfWfpN2/5pXhpNftXfDwJRo4REmjT2y//wyqj GmlEffH9WUXhk+YjLfG3KMQ++kB/g+j4mrv2w8cw9WHXO4kzZ1poHv9D1OBsK37lZdVg Tw== From: Jagannathan Raman To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 16:38:11 -0400 Message-Id: <0cef793b85d14a3ca56925488126eb3de6979b57.1567534653.git.jag.raman@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9369 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1909030207 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC v3 PATCH 45/45] multi-process: add configure and usage information 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, 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, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 --- Changes in v3: - since the changes were made to use existing device/drive options, the document was modified to reflect this. --- docs/qemu-multiprocess.txt | 86 ++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 86 insertions(+) create mode 100644 docs/qemu-multiprocess.txt diff --git a/docs/qemu-multiprocess.txt b/docs/qemu-multiprocess.txt new file mode 100644 index 0000000..c29f4df --- /dev/null +++ b/docs/qemu-multiprocess.txt @@ -0,0 +1,86 @@ +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 +-------- + +To start qemu with devices intended to run in a separate emulation +process without libvirtd support, the following should be used on QEMU +command line. As of now, we only support the emulation of lsi53c895a +in a separate process + +* 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,s= hare=3Don + +* The devices to be emulated in the separate process are defined as + before with addition of "rid" suboption that serves as a remote group + identificator. + + -device ,rid=3D"remote process id" + + For exmaple, for non multi-process qemu: + -device lsi53c895a,id=3Dscsi0 device + -device scsi-hd,drive=3Ddrive0,bus=3Dscsi0.0,scsi-id=3D0 + -drive id=3Ddrive0,file=3Ddata-disk.img + + and for multi-process qemu and no libvirt + support (i.e. QEMU forks child processes): + -device lsi53c895a,id=3Dscsi0,rid=3D0 + -device scsi-hd,drive=3Ddrive0,bus=3Dscsi0.0,scsi-id=3D0,rid=3D"0" + +* The command-line options for the remote process is added to the "command" + suboption of the newly added "-remote" option.=20 + + -remote [socket],rid=3D,command=3D"..." + + The drives to be emulated by the remote process are specified as part of + this command sub-option. The device to be used to connect to the monitor + is also specified as part of this suboption. + + For example, the following option adds a drive and monitor to the remote + process: + -remote rid=3D0,command=3D"-drive id=3Ddrive0,,file=3Ddata-disk.img -mon= itor unix:/home/qmp-sock,,server,,nowait" + + Note: There's an issue with this "command" subtion which we are in the + process of fixing. To work around this issue, it requires additional + "comma" characters as illustrated above, and in the example below. + +* Example QEMU command-line to launch lsi53c895a in a remote process + + #/bin/sh + qemu-system-x86_64 \ + -name "OL7.4" \ + -machine q35,accel=3Dkvm \ + -smp sockets=3D1,cores=3D1,threads=3D1 \ + -cpu host \ + -m 2048 \ + -object memory-backend-file,id=3Dmem,mem-path=3D/dev/shm/,size=3D2G,shar= e=3Don \ + -numa node,memdev=3Dmem \ + -device virtio-scsi-pci,id=3Dvirtio_scsi_pci0 \ + -drive id=3Ddrive_image1,if=3Dnone,format=3Draw,file=3D/root/ol7.qcow2 \ + -device scsi-hd,id=3Dimage1,drive=3Ddrive_image1,bus=3Dvirtio_scsi_pci0.= 0 \ + -boot d \ + -monitor stdio \ + -vnc :0 \ + -device lsi53c895a,id=3Dlsi0,remote,rid=3D8,command=3D"qemu-scsi-dev" \ + -device scsi-hd,id=3Ddrive2,drive=3Ddrive_image2,bus=3Dlsi0.0,scsi-id=3D= 0,remote,rid=3D8,command=3D"qemu-scsi-dev"\ + -remote rid=3D8,command=3D"-drive id=3Ddrive_image2,,file=3D/root/remote= -process-disk.img -monitor unix:/home/qmp-sock,,server,,nowait" + + We could connect to the monitor using the following command: + socat /home/qmp-sock stdio + + After hotplugging disks to the remote process, please execute the + following command in the guest to refresh the list of storage devices: + rescan_scsi_bus.sh -a --=20 1.8.3.1