From patchwork Mon Jun 17 18:14:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F09BA1398 for ; Mon, 17 Jun 2019 18:22:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5AF628732 for ; Mon, 17 Jun 2019 18:22:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9CFA289A2; Mon, 17 Jun 2019 18:22:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B5A028732 for ; Mon, 17 Jun 2019 18:22:29 +0000 (UTC) Received: from localhost ([::1]:50910 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwGy-0003Jr-N6 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58160) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcw9z-0004rC-CR for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcw9x-0000kz-DK for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:15 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56426) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcw9v-0000iM-LK for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:13 -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 x5HI9EWE066342; Mon, 17 Jun 2019 18:15:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=IoT2XzQvmkNBooFRvl3BkFSE45nFLX+0VW53K0OzyOI=; b=vdiMSapFO4R7j9oXquUFUK1Ck2bYKxi5CynokusSBeuQhZ/+Y3LX3e4nlmpuH3BfQNLn pPW19kLe4Oc5uAzQUKH21qXKhu8G+nSN9yJzjdXs4HR0Cx2IOvq2vY8vsWo4TFystFVQ 81bud9CHk9xMkVT2iSHwpdsqiLNXqIRcyS/uQfWZj58fcpBv+FNze48dZG1CSwQ83LHA 0va54Y9d9QEoFTZL19KHhNbErwImjINqgx7Gfm06blbhiea2GBq28rRW86alkOSk0pXz 6Iz4xVqorLTYbJOEKDMMr16rWtEMTJ0pK930RSecpMGOdz6innj1UpxIfnYbVVRIOdZy vg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2t4rmp00gh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:09 +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 x5HIF4Nj050052; Mon, 17 Jun 2019 18:15:08 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2t5h5t9f3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:08 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIF71r031497; Mon, 17 Jun 2019 18:15:07 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:07 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:14:59 -0700 Message-Id: <20190617181459.29139-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 01/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 | 9 +++++---- include/exec/ram_addr.h | 2 +- include/qemu/mmap-alloc.h | 2 +- memory.c | 2 +- util/mmap-alloc.c | 5 +++-- util/oslib-posix.c | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/exec.c b/exec.c index 2646207661..ffe25169a8 100644 --- a/exec.c +++ b/exec.c @@ -1829,6 +1829,7 @@ static void *file_ram_alloc(RAMBlock *block, ram_addr_t memory, int fd, bool truncate, + off_t offset, Error **errp) { void *area; @@ -1879,7 +1880,7 @@ static void *file_ram_alloc(RAMBlock *block, } area = qemu_ram_mmap(fd, memory, block->mr->align, - block->flags & RAM_SHARED); + block->flags & RAM_SHARED, offset); if (area == MAP_FAILED) { error_setg_errno(errp, errno, "unable to map backing store for guest RAM"); @@ -2268,7 +2269,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 = NULL; @@ -2313,7 +2314,7 @@ RAMBlock *qemu_ram_alloc_from_fd(ram_addr_t size, MemoryRegion *mr, new_block->used_length = size; new_block->max_length = size; new_block->flags = ram_flags; - new_block->host = file_ram_alloc(new_block, size, fd, !file_size, errp); + new_block->host = file_ram_alloc(new_block, size, fd, !file_size, offset, errp); if (!new_block->host) { g_free(new_block); return NULL; @@ -2343,7 +2344,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *mr, return NULL; } - block = qemu_ram_alloc_from_fd(size, mr, ram_flags, fd, errp); + block = 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 9ecd911c3e..2ed457905c 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -100,7 +100,7 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, MemoryRegion *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); 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 ef04f0ed5b..25c4b12224 100644 --- a/include/qemu/mmap-alloc.h +++ b/include/qemu/mmap-alloc.h @@ -7,7 +7,7 @@ size_t qemu_fd_getpagesize(int fd); size_t qemu_mempath_getpagesize(const char *mem_path); -void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared); +void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared, off_t start); void qemu_ram_munmap(int fd, void *ptr, size_t size); diff --git a/memory.c b/memory.c index bb2b71ee38..858271b08b 100644 --- a/memory.c +++ b/memory.c @@ -1617,7 +1617,7 @@ void memory_region_init_ram_from_fd(MemoryRegion *mr, mr->destructor = memory_region_destructor_ram; mr->ram_block = qemu_ram_alloc_from_fd(size, mr, share ? RAM_SHARED : 0, - fd, &err); + fd, 0, &err); mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; if (err) { mr->size = int128_zero(); diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c index 8565885420..58cb4cc267 100644 --- a/util/mmap-alloc.c +++ b/util/mmap-alloc.c @@ -75,7 +75,7 @@ size_t qemu_mempath_getpagesize(const char *mem_path) return getpagesize(); } -void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) +void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared, off_t start) { int flags; int guardfd; @@ -130,7 +130,8 @@ void *qemu_ram_mmap(int fd, size_t size, size_t align, bool shared) flags |= shared ? MAP_SHARED : MAP_PRIVATE; offset = QEMU_ALIGN_UP((uintptr_t)guardptr, align) - (uintptr_t)guardptr; - ptr = mmap(guardptr + offset, size, PROT_READ | PROT_WRITE, flags, fd, 0); + ptr = mmap(guardptr + offset, size, PROT_READ | PROT_WRITE, flags, fd, + start); if (ptr == MAP_FAILED) { munmap(guardptr, total); diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 88dda9cd39..2d4907dc59 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -203,7 +203,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 = QEMU_VMALLOC_ALIGN; - void *ptr = qemu_ram_mmap(-1, size, align, shared); + void *ptr = qemu_ram_mmap(-1, size, align, shared, 0); if (ptr == MAP_FAILED) { return NULL; From patchwork Mon Jun 17 18:15:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 90E6B1398 for ; Mon, 17 Jun 2019 18:26:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8700B289A2 for ; Mon, 17 Jun 2019 18:26:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A699289A6; Mon, 17 Jun 2019 18:26:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 27A70289A2 for ; Mon, 17 Jun 2019 18:26:06 +0000 (UTC) Received: from localhost ([::1]:50936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwKS-0007JV-Dh for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:26:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58221) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwA5-0004z5-C6 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwA3-0000uD-57 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:21 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56476) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwA1-0000mf-8N for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15: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 x5HI8u10066189; Mon, 17 Jun 2019 18:15:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=afzFpJbnCukv4mnymrxDok4pSggne4cWFNRNQPHI5sk=; b=YgRt6i4o77ncu+SPjnZH+oPbBlIOkOC8SKQQmdqHhPbiYJF++J4PFwFvIkDQWNvb89tW CyloN7tgER76aZZYtImzXXLxkpU1fdW5BmVqYZ2xmuKoFTIxV049nYaGYm7mGZsulCme tEbk9J/UiqdMe8m9tT50BAVxqZoGNLX1TQ/Ud+M4ahN99dzDai/9DZ01olGIXifSTFOq Qai4I2QXr5JGBkVoUHt3mNIH1V6bhhZvon8L+NJvfAXQfYJwPjVJFYwJwBhxGzHKVL0+ b22nHYH60fHOLzTp/Mh4jtb/Lzgua5G9dBSJMCShoOjjxE6HQYODo5ze4hBtyEu+LWUJ bQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2t4rmp00gw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:13 +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 x5HIEQ1h175589; Mon, 17 Jun 2019 18:15:12 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t5mgbgab0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:12 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIFBDH024366; Mon, 17 Jun 2019 18:15:11 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:11 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:07 -0700 Message-Id: <20190617181507.29189-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 02/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 55d83a907c..78791beae9 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 1bf5e65dea..7c89071048 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 = pthread_cancel(thread->thread); + if (err) { + error_exit(err, __func__); + } +} From patchwork Mon Jun 17 18:15:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E62CC924 for ; Mon, 17 Jun 2019 18:18:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCBAA28984 for ; Mon, 17 Jun 2019 18:18:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D09A928989; Mon, 17 Jun 2019 18:18:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A45728984 for ; Mon, 17 Jun 2019 18:18:36 +0000 (UTC) Received: from localhost ([::1]:50886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwDD-0006t0-LD for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:18:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58242) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwA7-0004zL-2l for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwA5-0000w5-A5 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:23 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55002) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwA3-0000ry-6V for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:19 -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 x5HI8vMx159160; Mon, 17 Jun 2019 18:15:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=g0brjdPoFqSGXV8EpwoiUayDN0EU0yUvRFAXEBTg4HE=; b=eDUZ5Dsmw1bMmwbIrc9evWdzoHrrYcXJj2yVi4tOLfaEYQzLZ8C7ntbu7Z7lWlkPOcuD Gt9dSdexS7ZspO/HCLX7pOFxFnQZ+1agbbuys/4yjs6kVar3t9uqPZJmKnFgtbvO1zQJ d7Qy2KISf+PN3q7WwW90xbTiksXNEMrrDm2VdKxNqlUWMfHiLjXusLNZg8f6OtbkCb5F wqeH5WMfR4Xy/IKwLOC1Wlx2KZoY1AT8Fq/zl7osxlLscPW3DELiulhblJL219+9Ag0e 4mj8QYFUjNzUVwCjTJw2S5cl6yTPkLAk0uoJiAMMbOR60s9p1H8E7UAM5UUM3xYHFRp4 eg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2t4saq7ybt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:16 +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 x5HIF9Hu118020; Mon, 17 Jun 2019 18:15:15 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2t5cpdkeey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:15 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFEj4027587; Mon, 17 Jun 2019 18:15:14 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:14 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:11 -0700 Message-Id: <20190617181511.29234-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 03/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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 b097a6cae1..ca6f490303 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) /* 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 c0dbbd4700..c7461255c3 100644 --- a/util/log.c +++ b/util/log.c @@ -274,6 +274,8 @@ const QEMULogItem qemu_log_items[] = { { 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 }, }; From patchwork Mon Jun 17 18:15:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2FECA1398 for ; Mon, 17 Jun 2019 18:26:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 244CA289A5 for ; Mon, 17 Jun 2019 18:26:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17B4E289BF; Mon, 17 Jun 2019 18:26:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 63C40289A5 for ; Mon, 17 Jun 2019 18:26:10 +0000 (UTC) Received: from localhost ([::1]:50938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwKX-0007Uy-Hy for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:26:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58317) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwAE-000544-3r for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwAC-00012I-AS for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:29 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:42466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAB-00010l-Gt for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:28 -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 x5HI8r4M149269; Mon, 17 Jun 2019 18:15:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=E8zoilbpdkiqhSjJiQHntdxJU4bfuLt15p8xby96L7k=; b=qgK5oOyzT+0nnbM5CBUdhefEDVvfhq5OiQjMHVmRMw/8OR+nI4QwqjM1WjKjyzgm9h+l UgDPm+Hk+TxuOdZiKBjU09WjCM+/5jc08aQbrcDBTvjwFic+nuyZpcLmyJb3ni6IONHV iiglXbAEY2T6h5+gVcvDw0uskL5uHDFgJxtrAllGjfh7umpUhhZ2YFy2OQyaTW9dHApw 7u6FjCNZ6Sly3WZhLlBgMnn7nSNMSkAK+Vkk9Lge4ZQ2R3hN45ClXN6py3lEs+Dzd1BL cbyELWYjTzlJohHPW/u0/Z6KHBKfxBgl2TXF5iPzZQ5okAO8M6UdI0lQ9qbRkvJxQ1vv wQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2t4r3tg2tj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15: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 x5HIF9bA118051; Mon, 17 Jun 2019 18:15:20 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2t5cpdkefx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:20 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFHS3031584; Mon, 17 Jun 2019 18:15:17 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:17 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:14 -0700 Message-Id: <20190617181514.29279-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 04/35] 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, john.g.johnson@oracle.com, sstabellini@kernel.org, jag.raman@oracle.com, pavel.dovgaluk@ispras.ru, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, paul.durrant@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, anthony.perard@citrix.com, kanth.ghatraju@oracle.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 | 22 ++++++++++ stubs/net-stub.c | 31 ++++++++++++++ stubs/replay.c | 14 +++++++ stubs/vl-stub.c | 75 ++++++++++++++++++++++++++++++++++ stubs/vmstate.c | 20 +++++++++ stubs/xen-mapcache.c | 22 ++++++++++ 9 files changed, 278 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 02d5170031..573b4da5be 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -32,6 +32,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; int kvm_destroy_vcpu(CPUState *cpu) { @@ -59,6 +60,10 @@ void kvm_cpu_synchronize_post_init(CPUState *cpu) { } +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 76ae461749..52722c70af 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; void tb_flush(CPUState *cpu) { } +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 end, + 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 = -1; + cpu_loop_exit(cpu); +} + +void cpu_loop_exit(CPUState *cpu) +{ + cpu->can_do_io = 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 4121f1709b..5bff245ade 100644 --- a/stubs/machine-init-done.c +++ b/stubs/machine-init-done.c @@ -7,3 +7,7 @@ bool machine_init_done = 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 b2ea975e40..f3dc2750cb 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -3,6 +3,8 @@ #include "qapi/qapi-emit-events.h" #include "qemu-common.h" #include "monitor/monitor.h" +#include "qapi/qapi-types-misc.h" +#include "qapi/qapi-commands-misc.h" __thread Monitor *cur_mon; @@ -24,3 +26,23 @@ void monitor_init(Chardev *chr, int flags) 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; +} diff --git a/stubs/net-stub.c b/stubs/net-stub.c new file mode 100644 index 0000000000..cb2274ba40 --- /dev/null +++ b/stubs/net-stub.c @@ -0,0 +1,31 @@ +#include "qemu/osdep.h" +#include "qemu-common.h" +#include "net/net.h" + +int qemu_find_net_clients_except(const char *id, NetClientState **ncs, + NetClientDriver type, int max) +{ + return -ENOSYS; +} + +NetClientState *net_hub_port_find(int hub_id) +{ + return NULL; +} + +int net_hub_id_for_client(NetClientState *nc, int *id) +{ + return -ENOSYS; +} + +int qemu_show_nic_models(const char *arg, const char *const *models) +{ + return -ENOSYS; +} + +int qemu_find_nic_model(NICInfo *nd, const char * const *models, + const char *default_model) +{ + return -ENOSYS; +} + diff --git a/stubs/replay.c b/stubs/replay.c index 4ac607895d..38fd1d3d6d 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 0000000000..893a854c53 --- /dev/null +++ b/stubs/vl-stub.c @@ -0,0 +1,75 @@ +#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 = VGA_NONE; +int smp_cores = 1; +int smp_threads = 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) +{ +} + +void x86_cpu_list(void) +{ +} diff --git a/stubs/vmstate.c b/stubs/vmstate.c index 6399474e49..a9a2bc25a0 100644 --- a/stubs/vmstate.c +++ b/stubs/vmstate.c @@ -1,9 +1,12 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "migration/vmstate.h" +#include "migration/misc.h" const VMStateDescription vmstate_dummy = {}; +const VMStateInfo vmstate_info_timer; + int vmstate_register_with_alias_id(DeviceState *dev, int instance_id, const VMStateDescription *vmsd, @@ -24,3 +27,20 @@ bool vmstate_check_only_migratable(const VMStateDescription *vmsd) { return true; } + +void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev) +{ +} + +void vmstate_unregister_ram(MemoryRegion *mr, DeviceState *dev) +{ +} + +void vmstate_register_ram_global(MemoryRegion *mr) +{ +} + +bool migration_is_idle(void) +{ + return true; +} diff --git a/stubs/xen-mapcache.c b/stubs/xen-mapcache.c new file mode 100644 index 0000000000..af5c031727 --- /dev/null +++ b/stubs/xen-mapcache.c @@ -0,0 +1,22 @@ +#include "qemu/osdep.h" +#include "exec/hwaddr.h" +#include "exec/cpu-common.h" +#include "sysemu/xen-mapcache.h" + +#ifdef CONFIG_XEN + +void xen_invalidate_map_cache_entry(uint8_t *buffer) +{ +} + +uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, uint8_t lock, bool dma) +{ + return NULL; +} + +ram_addr_t xen_ram_addr_from_mapcache(void *ptr) +{ + return 0; +} + +#endif From patchwork Mon Jun 17 18:15:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 884871902 for ; Mon, 17 Jun 2019 18:22:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C8AC28732 for ; Mon, 17 Jun 2019 18:22:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70961289A2; Mon, 17 Jun 2019 18:22:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1AECC28732 for ; Mon, 17 Jun 2019 18:22:34 +0000 (UTC) Received: from localhost ([::1]:50912 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwH3-0003VL-Ch for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:22:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58264) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwAB-00050v-17 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwAA-0000zp-1F for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:26 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwA9-0000yN-OZ for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:25 -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 x5HI8vH2066196; Mon, 17 Jun 2019 18:15:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=IsiySJFqk5iTUWpDwM0EVFDRV5zBmyZpcH2UaSxLkzE=; b=3f2Bd/ZLcSFYk4Ae/rGaq5d/2/Y5RHmoA2+Lr+fPx4DWOZYBv3p/ZtIiT40B8+3WXXo0 WNnclRhJ0wS6uGNBbr1pEF3O/9vEDXS0yJgpLoRh/LhZvtdfTO/r0wluT0GtIhlwyEOc MvToumfyYrO+TLQ6yA0KOpXnWe0GQa4gzOci72DJ+8AsaeO/8wpul1wa099nzQovmjD8 I/M+f2NnQSFwLB7YJs1WyfuRpM+UVZkJo+b7koB+kRgGTg91ZocXQ/s4ExaaJIAQRf1x IPMOQ1Di3rT1jSRvsXZLSG8flDi0XqHai9qYBjBRkEKKJbTCno8OGWXpz440x4Op+QZa hw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2t4rmp00hc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:22 +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 x5HIF9NL118044; Mon, 17 Jun 2019 18:15:22 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2t5cpdkegd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:22 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFLeU027618; Mon, 17 Jun 2019 18:15:21 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:21 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:18 -0700 Message-Id: <20190617181518.29324-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 05/35] 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, john.g.johnson@oracle.com, thuth@redhat.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, kraxel@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com, philmd@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 e1ad87b697..3834d69af5 100755 --- a/configure +++ b/configure @@ -491,6 +491,7 @@ docker="no" debug_mutex="no" libpmem="" default_devices="yes" +mpqemu="no" # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64="aarch64-linux-gnu-gcc" @@ -1518,6 +1519,10 @@ for opt do ;; --disable-libpmem) libpmem=no ;; + --enable-mpqemu) mpqemu=yes + ;; + --disable-mpqemu) mpqemu=no + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1818,6 +1823,7 @@ disabled with --disable-FEATURE, default is enabled if available: capstone capstone disassembler support debug-mutex mutex debugging support libpmem libpmem support + mpqemu multi-process QEMU support NOTE: The object files are built at the place where configure is launched EOF @@ -6438,6 +6444,7 @@ echo "docker $docker" echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" +echo "multiprocess QEMU $mpqemu" if test "$supported_cpu" = "no"; then echo @@ -7226,6 +7233,10 @@ if test "$libpmem" = "yes" ; then echo "CONFIG_LIBPMEM=y" >> $config_host_mak fi +if test "$mpqemu" = "yes" ; then + echo "CONFIG_MPQEMU=y" >> $config_host_mak +fi + if test "$bochs" = "yes" ; then echo "CONFIG_BOCHS=y" >> $config_host_mak fi From patchwork Mon Jun 17 18:15:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9F4231398 for ; Mon, 17 Jun 2019 18:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 920CA28732 for ; Mon, 17 Jun 2019 18:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8573928985; Mon, 17 Jun 2019 18:19:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7FB3F28732 for ; Mon, 17 Jun 2019 18:19:26 +0000 (UTC) Received: from localhost ([::1]:50890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwE1-0007jm-HI for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:19:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58445) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwAM-0005DG-Co for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwAJ-0001BM-Mu for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:38 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:42586) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAJ-0001A4-B9 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:35 -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 x5HI9175149332; Mon, 17 Jun 2019 18:15:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=2JTdks2T660NsSLjsk5mhaG7Y9bk06luO7AA8iBoKoU=; b=DAE2ICbTK/Uw/fD83irXP4wSmsS8LFvrC/YgcsKjbQSO0oSQF0QLxgx4eVsW7hhH3eus rR1w/V1r4125PpXAxFFpGSRjrHV9LbgO7o5Ujt4UyomMMX0flvuRY0AeEd+/4bSORbqq M8P1THWner8eI9+id+qj3GLLjQxaqzG0jQ44Fm5nWJCpxtBHvsCQ8qpQG4VdA5XP/R60 DDWj8M4sw7LEz4tW4YgC74yh7PVp1qyJGzL70J93YhgEw29+t6Mtzjcz6ScLvGZ+WPI0 W2e04E4QjXvcgLyWm55HE/LsdRc/H+WHVJe17vEPXp+T22ww/UjA+ejN/xRjIxCAAQ/L Gw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2t4r3tg2tw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:27 +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 x5HIF93S118052; Mon, 17 Jun 2019 18:15:26 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2t5cpdkehm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:26 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFPY4027637; Mon, 17 Jun 2019 18:15:25 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:24 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:21 -0700 Message-Id: <20190617181521.29371-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 06/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, mst@redhat.com, dgilbert@redhat.com, mreitz@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com, fam@euphon.net, kwolf@redhat.com, quintela@redhat.com, afaerber@suse.de Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 | 5 +++- Makefile.objs | 22 +++++++++++++++++ Makefile.target | 52 +++++++++++++++++++++++++++++++++++++++-- backends/Makefile.objs | 2 ++ block/Makefile.objs | 2 ++ hw/Makefile.objs | 7 ++++++ hw/block/Makefile.objs | 2 ++ hw/core/Makefile.objs | 14 +++++++++++ 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 +++++++++++++++++++++++++++ 15 files changed, 153 insertions(+), 3 deletions(-) create mode 100644 remote/Makefile.objs create mode 100644 remote/remote-main.c diff --git a/Makefile b/Makefile index 626a04d305..8650212b0a 100644 --- a/Makefile +++ b/Makefile @@ -414,6 +414,8 @@ dummy := $(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 \ @@ -483,7 +485,8 @@ subdir-slirp: .git-submodule-status $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp BUILD_DIR="$(BUILD_DIR)/slirp" CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" CFLAGS="$(QEMU_CFLAGS)") $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \ - $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) + $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY)) \ + $(remote-pci-obj-y) $(remote-lsi-obj-y) ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS)) # Only keep -O and -g cflags diff --git a/Makefile.objs b/Makefile.objs index cf065de5ed..74bd8914f0 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -21,6 +21,28 @@ block-obj-$(CONFIG_REPLICATION) += replication.o block-obj-m = block/ +######################################################### +# remote-pci-obj-y is common code used by remote devices + +remote-pci-obj-$(CONFIG_MPQEMU) += hw/ +remote-pci-obj-$(CONFIG_MPQEMU) += qom/ +remote-pci-obj-$(CONFIG_MPQEMU) += backends/ +remote-pci-obj-$(CONFIG_MPQEMU) += block/ +remote-pci-obj-$(CONFIG_MPQEMU) += migration/ +remote-pci-obj-$(CONFIG_MPQEMU) += remote/ + +remote-pci-obj-$(CONFIG_MPQEMU) += cpus-common.o +remote-pci-obj-$(CONFIG_MPQEMU) += dma-helpers.o +remote-pci-obj-$(CONFIG_MPQEMU) += blockdev.o +remote-pci-obj-$(CONFIG_MPQEMU) += qdev-monitor.o +remote-pci-obj-$(CONFIG_MPQEMU) += bootdevice.o +remote-pci-obj-$(CONFIG_MPQEMU) += iothread.o + +############################################################## +# remote-lsi-obj-y is code used to implement remote LSI device + +remote-lsi-obj-$(CONFIG_MPQEMU) += hw/ + ####################################################################### # crypto-obj-y is code used by both qemu system emulation and qemu-img diff --git a/Makefile.target b/Makefile.target index ae02495951..f45af2b851 100644 --- a/Makefile.target +++ b/Makefile.target @@ -36,7 +36,12 @@ QEMU_PROG_BUILD = $(QEMU_PROG) endif endif -PROGS=$(QEMU_PROG) $(QEMU_PROGW) +ifdef CONFIG_MPQEMU +SCSI_DEV_PROG=qemu-scsi-dev +SCSI_DEV_BUILD = $(SCSI_DEV_PROG) +endif + +PROGS=$(QEMU_PROG) $(QEMU_PROGW) $(SCSI_DEV_PROG) STPFILES= # Makefile Tests @@ -118,6 +123,16 @@ obj-y += target/$(TARGET_BASE_ARCH)/ obj-y += disas.o obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += accel/stubs/kvm-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += accel/stubs/tcg-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += accel/stubs/hax-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += accel/stubs/whpx-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/vl-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/net-stub.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/monitor.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/replay.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/xen-mapcache.o + ######################################################### # Linux user emulator target @@ -173,6 +188,18 @@ endif # CONFIG_SOFTMMU dummy := $(call unnest-vars,,obj-y) all-obj-y := $(obj-y) +dummy := $(call unnest-vars,..,remote-pci-tgt-obj-y) +all-remote-pci-obj-y := $(remote-pci-tgt-obj-y) + +all-remote-pci-obj-y += memory.o +all-remote-pci-obj-y += exec.o +all-remote-pci-obj-y += numa.o +all-remote-pci-obj-y += ioport.o +all-remote-pci-obj-y += cpus.o + +remote-pci-obj-y := +remote-lsi-obj-y := + include $(SRC_PATH)/Makefile.objs dummy := $(call unnest-vars,.., \ authz-obj-y \ @@ -184,7 +211,10 @@ dummy := $(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 += $(common-obj-y) all-obj-y += $(qom-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(authz-obj-y) @@ -193,8 +223,19 @@ all-obj-$(CONFIG_USER_ONLY) += $(crypto-aes-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y) +all-remote-pci-obj-y += $(authz-obj-y) +all-remote-pci-obj-y += $(block-obj-y) +all-remote-pci-obj-y += $(crypto-obj-y) +all-remote-pci-obj-y += $(io-obj-y) +all-remote-pci-obj-y += $(chardev-obj-y) +all-remote-pci-obj-y += $(remote-pci-obj-y) + + +all-remote-lsi-obj-y += $(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 COMMON_LDADDS = ../libqemuutil.a @@ -207,6 +248,13 @@ ifdef CONFIG_DARWIN $(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@") endif +$(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)$@") diff --git a/backends/Makefile.objs b/backends/Makefile.objs index ff619d31b4..47c4161b49 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -15,3 +15,5 @@ common-obj-$(CONFIG_VHOST_CRYPTO) += cryptodev-vhost-user.o endif common-obj-$(CONFIG_LINUX) += hostmem-memfd.o + +remote-pci-obj-$(CONFIG_MPQEMU) += hostmem.o diff --git a/block/Makefile.objs b/block/Makefile.objs index 7a81892a52..cfc7719f62 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -63,3 +63,5 @@ qcow.o-libs := -lz linux-aio.o-libs := -laio parallels.o-cflags := $(LIBXML2_CFLAGS) parallels.o-libs := $(LIBXML2_LIBS) + +remote-pci-obj-$(CONFIG_MPQEMU) += stream.o diff --git a/hw/Makefile.objs b/hw/Makefile.objs index 82aa7fab8e..80e0a6ab14 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -39,3 +39,10 @@ devices-dirs-$(CONFIG_SOFTMMU) += smbios/ devices-dirs-y += core/ common-obj-y += $(devices-dirs-y) obj-y += $(devices-dirs-y) + +remote-pci-obj-$(CONFIG_MPQEMU) += core/ +remote-pci-obj-$(CONFIG_MPQEMU) += block/ +remote-pci-obj-$(CONFIG_MPQEMU) += pci/ +remote-pci-obj-$(CONFIG_MPQEMU) += nvram/ + +remote-lsi-obj-$(CONFIG_MPQEMU) += scsi/ diff --git a/hw/block/Makefile.objs b/hw/block/Makefile.objs index f5f643f0cc..7286fbd885 100644 --- a/hw/block/Makefile.objs +++ b/hw/block/Makefile.objs @@ -15,3 +15,5 @@ obj-$(CONFIG_VIRTIO_BLK) += virtio-blk.o obj-$(CONFIG_VHOST_USER_BLK) += vhost-user-blk.o obj-y += dataplane/ + +remote-pci-obj-$(CONFIG_MPQEMU) += block.o cdrom.o hd-geometry.o diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs index a799c83815..3e3afaa271 100644 --- a/hw/core/Makefile.objs +++ b/hw/core/Makefile.objs @@ -22,3 +22,17 @@ common-obj-$(CONFIG_SOFTMMU) += split-irq.o common-obj-$(CONFIG_PLATFORM_BUS) += platform-bus.o common-obj-$(CONFIG_SOFTMMU) += generic-loader.o common-obj-$(CONFIG_SOFTMMU) += null-machine.o + +remote-pci-obj-$(CONFIG_MPQEMU) += qdev-properties.o +remote-pci-obj-$(CONFIG_MPQEMU) += qdev.o +remote-pci-obj-$(CONFIG_MPQEMU) += bus.o +remote-pci-obj-$(CONFIG_MPQEMU) += irq.o +remote-pci-obj-$(CONFIG_MPQEMU) += hotplug.o +remote-pci-obj-$(CONFIG_MPQEMU) += machine.o +remote-pci-obj-$(CONFIG_MPQEMU) += fw-path-provider.o +remote-pci-obj-$(CONFIG_MPQEMU) += reset.o +remote-pci-obj-$(CONFIG_MPQEMU) += sysbus.o +remote-pci-obj-$(CONFIG_MPQEMU) += loader.o +remote-pci-obj-$(CONFIG_MPQEMU) += nmi.o +remote-pci-obj-$(CONFIG_MPQEMU) += qdev-properties-system.o +remote-pci-obj-$(CONFIG_MPQEMU) += qdev-fw.o diff --git a/hw/nvram/Makefile.objs b/hw/nvram/Makefile.objs index 26f7b4ca35..9802a31fbb 100644 --- a/hw/nvram/Makefile.objs +++ b/hw/nvram/Makefile.objs @@ -6,3 +6,5 @@ common-obj-y += chrp_nvram.o common-obj-$(CONFIG_MAC_NVRAM) += mac_nvram.o obj-$(CONFIG_PSERIES) += spapr_nvram.o obj-$(CONFIG_NRF51_SOC) += nrf51_nvm.o + +remote-pci-obj-$(CONFIG_MPQEMU) += fw_cfg.o diff --git a/hw/pci/Makefile.objs b/hw/pci/Makefile.objs index c78f2fb24b..955be54472 100644 --- a/hw/pci/Makefile.objs +++ b/hw/pci/Makefile.objs @@ -12,3 +12,7 @@ common-obj-$(CONFIG_PCI_EXPRESS) += pcie_port.o pcie_host.o common-obj-$(call lnot,$(CONFIG_PCI)) += pci-stub.o common-obj-$(CONFIG_ALL) += pci-stub.o + +remote-pci-obj-$(CONFIG_MPQEMU) += pci.o pci_bridge.o +remote-pci-obj-$(CONFIG_MPQEMU) += msi.o msix.o +remote-pci-obj-$(CONFIG_MPQEMU) += pcie.o diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs index 54b36ed8b1..ef97770922 100644 --- a/hw/scsi/Makefile.objs +++ b/hw/scsi/Makefile.objs @@ -13,3 +13,5 @@ obj-y += virtio-scsi.o virtio-scsi-dataplane.o obj-$(CONFIG_VHOST_SCSI) += vhost-scsi-common.o vhost-scsi.o obj-$(CONFIG_VHOST_USER_SCSI) += vhost-scsi-common.o vhost-user-scsi.o endif + +remote-lsi-obj-$(CONFIG_MPQEMU) += scsi-generic.o scsi-bus.o lsi53c895a.o scsi-disk.o emulation.o diff --git a/migration/Makefile.objs b/migration/Makefile.objs index a4f3bafd86..016b6abd6e 100644 --- a/migration/Makefile.objs +++ b/migration/Makefile.objs @@ -13,3 +13,5 @@ common-obj-$(CONFIG_RDMA) += rdma.o common-obj-$(CONFIG_LIVE_BLOCK_MIGRATION) += block.o rdma.o-libs := $(RDMA_LIBS) + +remote-pci-obj-$(CONFIG_MPQEMU) += qemu-file.o vmstate.o qjson.o vmstate-types.o diff --git a/qom/Makefile.objs b/qom/Makefile.objs index 516349eec3..f0392c2b55 100644 --- a/qom/Makefile.objs +++ b/qom/Makefile.objs @@ -2,3 +2,7 @@ qom-obj-y = object.o container.o qom-qobject.o qom-obj-y += object_interfaces.o common-obj-y = cpu.o + +remote-pci-obj-$(CONFIG_MPQEMU) += object.o qom-qobject.o container.o +remote-pci-obj-$(CONFIG_MPQEMU) += object_interfaces.o +remote-pci-obj-$(CONFIG_MPQEMU) += cpu.o diff --git a/remote/Makefile.objs b/remote/Makefile.objs new file mode 100644 index 0000000000..a9b2256b2a --- /dev/null +++ b/remote/Makefile.objs @@ -0,0 +1 @@ +remote-pci-obj-$(CONFIG_MPQEMU) += remote-main.o diff --git a/remote/remote-main.c b/remote/remote-main.c new file mode 100644 index 0000000000..ffcf47f185 --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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; +} From patchwork Mon Jun 17 18:15:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D226A1398 for ; Mon, 17 Jun 2019 18:19:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C159128732 for ; Mon, 17 Jun 2019 18:19:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1D3028985; Mon, 17 Jun 2019 18:19:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B871828732 for ; Mon, 17 Jun 2019 18:19:21 +0000 (UTC) Received: from localhost ([::1]:50888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwDx-0007ZN-23 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:19:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58386) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwAJ-000593-9L for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwAG-00018M-5X for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:35 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:42524) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAF-000178-OJ for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:32 -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 x5HI8kX5149217; Mon, 17 Jun 2019 18:15:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=UyK3zkxmP+RF5OK1eFM3wHGEgIEkAjDWj4q/n2YLGOM=; b=BmP2BWpqvYpv9kgX/LBsH6bpk+f1//GPh953PRS2IWQ6nbWhmMUsS9lusjFvqYUL+5hB ujNJJ0HiYOIvUERjEt6koT9Jz8Q5l9TKYV1svXyadCWJOsNABfhE8XSg35NSrtTrPeI1 PuslrLlXvLTOC1w+1xlLbvKnv2mLQKHeWovNEHsCUR6BPx1M6NeDH0EaPI9qpHPma9c9 JA8XCYpIt0gL8jmAlLWf5o1AiCy9DifaB/3EHKZ0O+jkYTUbOyOa2ryEqtT10UsqngvX 80O6gHeMuSLTqlAv52GUKcPp4UhR/4gRGSDy9kqk0ubvvnHLJeUU7k5Cbosvk4AtZGv7 Fw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2t4r3tg2u4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:30 +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 x5HIF9Tn117968; Mon, 17 Jun 2019 18:15:29 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2t5cpdkejj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:29 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFSTK027776; Mon, 17 Jun 2019 18:15:28 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:28 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:25 -0700 Message-Id: <20190617181525.29419-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 07/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 --- Changes in v2: - Use default context for main loop instead of a new context; --- include/glib-compat.h | 4 + include/io/proxy-link.h | 136 ++++++++++++++++++++ io/Makefile.objs | 2 + io/proxy-link.c | 275 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 417 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 1291628e09..6189b9a41d 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 /* 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 #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 0000000000..fb266ca2a8 --- /dev/null +++ b/include/io/proxy-link.h @@ -0,0 +1,136 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = 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; +}; + +typedef void (*proxy_link_callback)(GIOCondition cond); + +typedef struct ProxySrc { + GSource gsrc; + GPollFD gpfd; +} ProxySrc; + +/* + * ProxyLinkState Instance info. of the communication + * link between QEMU and remote process + * + * ctx GMainContext to be used for communication + * loop Main loop that would be used to poll for incoming data + * src Source fds to poll on, and which events to poll on + * sock Unix socket used for the link + * lock Lock to synchronize access to the link + * + */ +struct ProxyLinkState { + Object obj; + + GMainContext *ctx; + GMainLoop *loop; + ProxySrc *src; + + int sock; + QemuMutex lock; + + proxy_link_callback callback; +}; + +ProxyLinkState *proxy_link_create(void); +void proxy_link_finalize(ProxyLinkState *s); + +void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg); +int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg); +void proxy_link_set_sock(ProxyLinkState *s, int fd); +void proxy_link_set_callback(ProxyLinkState *s, proxy_link_callback callback); +void start_handler(ProxyLinkState *s); + +#endif diff --git a/io/Makefile.objs b/io/Makefile.objs index 9a20fce4ed..ff88b46c90 100644 --- a/io/Makefile.objs +++ b/io/Makefile.objs @@ -10,3 +10,5 @@ io-obj-y += channel-util.o io-obj-y += dns-resolver.o io-obj-y += net-listener.o io-obj-y += task.o + +io-obj-$(CONFIG_MPQEMU) += proxy-link.o diff --git a/io/proxy-link.c b/io/proxy-link.c new file mode 100644 index 0000000000..75e0bb5e27 --- /dev/null +++ b/io/proxy-link.c @@ -0,0 +1,275 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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" + +static void proxy_link_inst_init(Object *obj) +{ + ProxyLinkState *s = PROXY_LINK(obj); + + qemu_mutex_init(&s->lock); + + s->sock = STDIN_FILENO; + s->ctx = g_main_context_default(); + s->loop = g_main_loop_new(s->ctx, FALSE); +} + +static const TypeInfo proxy_link_info = { + .name = TYPE_PROXY_LINK, + .parent = TYPE_OBJECT, + .instance_size = sizeof(ProxyLinkState), + .instance_init = 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_source_unref(&s->src->gsrc); + g_main_loop_unref(s->loop); + g_main_context_unref(s->ctx); + g_main_loop_quit(s->loop); + + close(s->sock); + + qemu_mutex_destroy(&s->lock); + + object_unref(OBJECT(s)); +} + +void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg) +{ + int rc; + uint8_t *data; + char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))] = { }; + struct msghdr hdr; + struct cmsghdr *chdr; + + struct iovec iov = { + .iov_base = (char *) msg, + .iov_len = PROC_HDR_SIZE, + }; + + memset(&hdr, 0, sizeof(hdr)); + memset(control, 0, sizeof(control)); + + hdr.msg_iov = &iov; + hdr.msg_iovlen = 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 = msg->num_fds * sizeof(int); + + hdr.msg_control = control; + hdr.msg_controllen = sizeof(control); + + chdr = CMSG_FIRSTHDR(&hdr); + chdr->cmsg_len = CMSG_LEN(fdsize); + chdr->cmsg_level = SOL_SOCKET; + chdr->cmsg_type = SCM_RIGHTS; + memcpy(CMSG_DATA(chdr), msg->fds, fdsize); + hdr.msg_controllen = chdr->cmsg_len; + } + + qemu_mutex_lock(&s->lock); + + do { + rc = sendmsg(s->sock, &hdr, 0); + } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); + + if (rc < 0) { + qemu_log_mask(LOG_REMOTE_DEBUG, "%s - sendmsg rc is %d, errno is %d," + " sock %d\n", __func__, rc, errno, s->sock); + qemu_mutex_unlock(&s->lock); + return; + } + + if (msg->bytestream) { + data = msg->data2; + } else { + data = (uint8_t *)msg + PROC_HDR_SIZE; + } + + do { + rc = write(s->sock, data, msg->size); + } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); + + qemu_mutex_unlock(&s->lock); +} + + +int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg) +{ + int rc; + uint8_t *data; + char control[CMSG_SPACE(REMOTE_MAX_FDS * sizeof(int))] = { }; + struct msghdr hdr; + struct cmsghdr *chdr; + size_t fdsize; + + struct iovec iov = { + .iov_base = (char *) msg, + .iov_len = PROC_HDR_SIZE, + }; + + memset(&hdr, 0, sizeof(hdr)); + memset(control, 0, sizeof(control)); + + hdr.msg_iov = &iov; + hdr.msg_iovlen = 1; + hdr.msg_control = control; + hdr.msg_controllen = sizeof(control); + + qemu_mutex_lock(&s->lock); + + do { + rc = recvmsg(s->sock, &hdr, 0); + } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); + + if (rc < 0) { + qemu_log_mask(LOG_REMOTE_DEBUG, "%s - recvmsg rc is %d, errno is %d," + " sock %d\n", __func__, rc, errno, s->sock); + qemu_mutex_unlock(&s->lock); + return rc; + } + + msg->num_fds = 0; + for (chdr = CMSG_FIRSTHDR(&hdr); chdr != NULL; + chdr = CMSG_NXTHDR(&hdr, chdr)) { + if ((chdr->cmsg_level == SOL_SOCKET) && + (chdr->cmsg_type == SCM_RIGHTS)) { + fdsize = chdr->cmsg_len - CMSG_LEN(0); + msg->num_fds = fdsize / sizeof(int); + memcpy(msg->fds, CMSG_DATA(chdr), fdsize); + break; + } + } + + if (msg->size && msg->bytestream) { + msg->data2 = calloc(1, msg->size); + data = msg->data2; + } else { + data = (uint8_t *)&msg->data1; + } + + if (msg->size) { + do { + rc = read(s->sock, data, msg->size); + } while (rc < 0 && (errno == EINTR || errno == EAGAIN)); + } + + qemu_mutex_unlock(&s->lock); + + return rc; +} + +static gboolean proxy_link_handler_prepare(GSource *gsrc, gint *timeout) +{ + g_assert(timeout); + + *timeout = -1; + + return FALSE; +} + +static gboolean proxy_link_handler_check(GSource *gsrc) +{ + ProxySrc *src = (ProxySrc *)gsrc; + + return src->gpfd.events & src->gpfd.revents; +} + +static gboolean proxy_link_handler_dispatch(GSource *gsrc, GSourceFunc func, + gpointer data) +{ + ProxySrc *src = (ProxySrc *)gsrc; + ProxyLinkState *s = (ProxyLinkState *)data; + + s->callback(src->gpfd.revents); + + if ((src->gpfd.revents & G_IO_HUP) || (src->gpfd.revents & G_IO_ERR)) { + return G_SOURCE_REMOVE; + } + + return G_SOURCE_CONTINUE; +} + +void proxy_link_set_sock(ProxyLinkState *s, int fd) +{ + s->sock = fd; +} + +void proxy_link_set_callback(ProxyLinkState *s, proxy_link_callback callback) +{ + s->callback = callback; +} + +void start_handler(ProxyLinkState *s) +{ + GSourceFuncs gsrc_funcs = (GSourceFuncs){ + .prepare = proxy_link_handler_prepare, + .check = proxy_link_handler_check, + .dispatch = proxy_link_handler_dispatch, + .finalize = NULL, + }; + ProxySrc *src = (ProxySrc *)g_source_new(&gsrc_funcs, sizeof(ProxySrc)); + guint id; + + g_source_set_callback(&src->gsrc, NULL, (gpointer)s, NULL); + + src->gpfd.fd = s->sock; + src->gpfd.events = G_IO_IN | G_IO_HUP | G_IO_ERR; + g_source_add_poll(&src->gsrc, &src->gpfd); + id = g_source_attach(&src->gsrc, s->ctx); + g_assert(id); + s->src = src; + + g_main_loop_run(s->loop); +} From patchwork Mon Jun 17 18:15:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F135C14B6 for ; Mon, 17 Jun 2019 18:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E585028732 for ; Mon, 17 Jun 2019 18:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9CB6289A2; Mon, 17 Jun 2019 18:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73E1028732 for ; Mon, 17 Jun 2019 18:23:01 +0000 (UTC) Received: from localhost ([::1]:50916 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwHU-000414-Nx for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:23:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58573) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwAd-0005Mj-M6 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwAb-0001U6-Jp for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:55 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:42700) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAZ-0001IL-F7 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:51 -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 x5HI8r4P149269; Mon, 17 Jun 2019 18:15:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=KEujIo1vEx2wWhB0PXsc+4rd8jpemrHqR8jjUc1zmd0=; b=KpsstjzSXfsbojkpYLmBgcsK1TNUyYNbU56v9mrjEdcsivdyO8NPxC2bVLZ5HZ3b3WW+ W9pBCunQO2qMsvYMZhQdyDok95O/Z2iaDzaZ8z0pZThFHXfI4AyhUAYP9mjTBEVnWUqY 9QwY9XxftDSooDDfYo7Q4q/MV748j/9k1VBYE8mtEv6CaVXWVhom9JusmtZpQijB1eJ/ hR/0jCAPEovoTUvhwazvH8AGzqM5qO0PzgFEeb9nrCrdsotwrhNDod4SKUZYWiwbq5xx YnT7gR1nO/umYl0/wOjZ9UM0uodvlAeilfMxsXhW9RIhRNfyVK7dxe5ZgASzo3WFyv7f sg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2t4r3tg2uu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:41 +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 x5HIF9Y9117981; Mon, 17 Jun 2019 18:15:40 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2t5cpdkend-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:40 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIFdhx024697; Mon, 17 Jun 2019 18:15:39 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:38 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:29 -0700 Message-Id: <20190617181529.29468-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 08/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 --- Changes in v2: - Added timeout to communication channel. --- include/io/proxy-link.h | 9 +++++++++ io/proxy-link.c | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index fb266ca2a8..2f1584e87d 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -28,7 +28,9 @@ #include #include #include +#include #include +#include #include "qemu/osdep.h" #include "qom/object.h" @@ -124,11 +126,18 @@ struct ProxyLinkState { proxy_link_callback callback; }; +#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); void proxy_proc_send(ProxyLinkState *s, ProcMsg *msg); int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg); +uint64_t wait_for_remote(int efd); +void notify_proxy(int fd, uint64_t val); + void proxy_link_set_sock(ProxyLinkState *s, int fd); void proxy_link_set_callback(ProxyLinkState *s, proxy_link_callback callback); void start_handler(ProxyLinkState *s); diff --git a/io/proxy-link.c b/io/proxy-link.c index 75e0bb5e27..9bda646f39 100644 --- a/io/proxy-link.c +++ b/io/proxy-link.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "qemu/module.h" #include "io/proxy-link.h" @@ -210,6 +212,46 @@ int proxy_proc_recv(ProxyLinkState *s, ProcMsg *msg) return rc; } +uint64_t wait_for_remote(int efd) +{ + struct pollfd pfd = { .fd = efd, .events = POLLIN }; + uint64_t val; + int ret; + + ret = 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)) == -1) { + qemu_log_mask(LOG_REMOTE_DEBUG, "Error wait_for_remote: %s\n", + strerror(errno)); + return ULLONG_MAX; + } + } + + val = (val == ULLONG_MAX) ? val : (val - 1); + + return val; +} + +void notify_proxy(int efd, uint64_t val) +{ + val = (val == ULLONG_MAX) ? val : (val + 1); + + if (write(efd, &val, sizeof(val)) == -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); From patchwork Mon Jun 17 18:15:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8258714C0 for ; Mon, 17 Jun 2019 18:59:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7739D289D8 for ; Mon, 17 Jun 2019 18:59:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75176289F2; Mon, 17 Jun 2019 18:59:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E02A289DA for ; Mon, 17 Jun 2019 18:59:03 +0000 (UTC) Received: from localhost ([::1]:51206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwqL-0004nC-Ce for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:59:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59474) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwD1-0006f4-Bj for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:18:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwCz-0002wX-Ti for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:18:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:44662) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwCz-0002si-LH for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:18: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 x5HI8vRZ149290; Mon, 17 Jun 2019 18:18:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=W5uSpSwoAv5+n4+ooPEXKB4UZo+/RcB4M0VkMIT++Lk=; b=FmJi9ELkwTCg7OoEfaWIFiHXkSf4/uhoFXkyZB9xBOQMZ6L5lbbqomKhUO+DLunLlAVh B4H3ZcTIs47E1ttYvqpqz7H1yVhqbcI6iguHOJ1sF0Nabw1tqacpXphqcccWHuSfrd0C F/YwG0yW+wPPJ94RZMstoiwwkz5f+ra6EeQ/dvUPWOMsO3uVfH6gub5jYts+RX51V1YT FA3+whL3bBcCHQFy0fB21FR9fhLJKgnIMIfZdsfte2dREU9sYHKzZxH34Y0vvfFVqQXZ Jh7I3ZsK8+Gd3+bg0KiQX9fKxCsbqELHdf87SKKWjOEoFi6TV1UQCgH1DhxzZfLaDy89 0Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2t4r3tg34n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:18:10 +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 x5HIEOPt175475; Mon, 17 Jun 2019 18:16:09 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t5mgbgat3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:09 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFjES031901; Mon, 17 Jun 2019 18:15:45 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:44 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:39 -0700 Message-Id: <20190617181539.29532-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 09/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, mst@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 | 58 +++++++++++++++++++++++++++ remote/Makefile.objs | 1 + remote/pcihost.c | 84 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 144 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 955be54472..90693a7695 100644 --- a/hw/pci/Makefile.objs +++ b/hw/pci/Makefile.objs @@ -13,6 +13,6 @@ common-obj-$(CONFIG_PCI_EXPRESS) += pcie_port.o pcie_host.o common-obj-$(call lnot,$(CONFIG_PCI)) += pci-stub.o common-obj-$(CONFIG_ALL) += pci-stub.o -remote-pci-obj-$(CONFIG_MPQEMU) += pci.o pci_bridge.o +remote-pci-obj-$(CONFIG_MPQEMU) += pci.o pci_bridge.o pci_host.o pcie_host.o remote-pci-obj-$(CONFIG_MPQEMU) += msi.o msix.o remote-pci-obj-$(CONFIG_MPQEMU) += pcie.o diff --git a/include/remote/pcihost.h b/include/remote/pcihost.h new file mode 100644 index 0000000000..daf39c1291 --- /dev/null +++ b/include/remote/pcihost.h @@ -0,0 +1,58 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 the + * emulation program are: + * - Provide a PCI bus for IO devices + * - Enable translation of guest PA to the PCI bar regions + * + * For both the above mentioned purposes, it doesn't look like we would + * need the MCH + */ + + MemoryRegion *mr_pci_mem; + MemoryRegion *mr_sys_mem; + MemoryRegion *mr_sys_io; +} RemPCIHost; + +#endif diff --git a/remote/Makefile.objs b/remote/Makefile.objs index a9b2256b2a..2757f5a265 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1 +1,2 @@ remote-pci-obj-$(CONFIG_MPQEMU) += remote-main.o +remote-pci-obj-$(CONFIG_MPQEMU) += pcihost.o diff --git a/remote/pcihost.c b/remote/pcihost.c new file mode 100644 index 0000000000..bcdd214950 --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = PCI_HOST_BRIDGE(dev); + RemPCIHost *s = REMOTE_HOST_DEVICE(dev); + + /* + * TODO: the name of the bus would be provided by QEMU. Use + * "pcie.0" for now. + */ + pci->bus = 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[] = { + DEFINE_PROP_END_OF_LIST(), +}; + +static void remote_host_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass); + + hc->root_bus_path = remote_host_root_bus_path; + dc->realize = remote_host_realize; + dc->props = remote_host_props; + + dc->user_creatable = false; + set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + dc->fw_name = "pci"; +} + +static const TypeInfo remote_host_info = { + .name = TYPE_REMOTE_HOST_DEVICE, + .parent = TYPE_PCIE_HOST_BRIDGE, + .instance_size = sizeof(RemPCIHost), + .class_init = remote_host_class_init, +}; + +static void remote_machine_register(void) +{ + type_register_static(&remote_host_info); +} + +type_init(remote_machine_register) From patchwork Mon Jun 17 18:15:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BBDAB14DB for ; Mon, 17 Jun 2019 18:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B101C28960 for ; Mon, 17 Jun 2019 18:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4983289B9; Mon, 17 Jun 2019 18:36:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED48828960 for ; Mon, 17 Jun 2019 18:36:52 +0000 (UTC) Received: from localhost ([::1]:51000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwUu-0007Us-AR for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:36:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58754) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwB5-0005Yw-Bv for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwB1-0001px-8R for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43054) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAy-0001lH-W7 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:19 -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 x5HI8r7v149266; Mon, 17 Jun 2019 18:16:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=xKcJJVM+Px1Efmb6GACuVRxl4kOaAuJgnkj4m6Ch378=; b=JZlbFxMnSyhxCbr10Px0XS4sc0wWqsODY7Dv4GvZDPEo2xZnJ1SeomVKSNp9SZDSEXTt /zQYd0ZFmf8GlF2q8Nv0EgxWh1sRmRX0/bjFc6EnmGzMdqrYlSN+H6ZIi4Ixp/Ym9S0K TTVSS0+a9S94THqHppbZglz8WI2CC3hwYguVRQ6fM0QnqfRy95GWa+ZcKlMRV/EpRJu8 rnXOYASzcl58anb+5vWSNI1yvpz7gj2LJ+wdDwgSDA9wvNJVwH2g3hhLVWqkKWfcisk8 kT2Sz5hvt3dzdte7qvgLRgZlxXAXnw8Z1EwwRhdJ44ig5i4c+qztDEXiJbChT0GRJiMY 3Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2t4r3tg2w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:10 +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 x5HIEOtm175517; Mon, 17 Jun 2019 18:16:09 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t5mgbgat5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:09 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFnXl031921; Mon, 17 Jun 2019 18:15:49 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:49 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:45 -0700 Message-Id: <20190617181545.29586-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 10/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 ffe25169a8..5de7eeb719 100644 --- a/exec.c +++ b/exec.c @@ -194,7 +194,6 @@ typedef struct subpage_t { #define PHYS_SECTION_WATCH 3 static void io_mem_init(void); -static void memory_map_init(void); static void tcg_commit(MemoryListener *listener); static MemoryRegion io_mem_watch; @@ -3106,7 +3105,7 @@ static void tcg_commit(MemoryListener *listener) tlb_flush(cpuas->cpu); } -static void memory_map_init(void) +void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); diff --git a/include/exec/address-spaces.h b/include/exec/address-spaces.h index db8bfa9a92..56a877b7ba 100644 --- a/include/exec/address-spaces.h +++ b/include/exec/address-spaces.h @@ -33,6 +33,8 @@ MemoryRegion *get_system_memory(void); */ MemoryRegion *get_system_io(void); +void memory_map_init(void); + extern AddressSpace address_space_memory; extern AddressSpace address_space_io; diff --git a/include/remote/machine.h b/include/remote/machine.h new file mode 100644 index 0000000000..a00732d045 --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 2757f5a265..13d4c48988 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1,2 +1,3 @@ remote-pci-obj-$(CONFIG_MPQEMU) += remote-main.o remote-pci-obj-$(CONFIG_MPQEMU) += pcihost.o +remote-pci-obj-$(CONFIG_MPQEMU) += machine.o diff --git a/remote/machine.c b/remote/machine.c new file mode 100644 index 0000000000..4ce197d300 --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = + 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 = true; + notifier_list_notify(&machine_init_done_notifiers, NULL); +} + +static void remote_machine_init(Object *obj) +{ + RemMachineState *s = REMOTE_MACHINE(obj); + RemPCIHost *rem_host; + MemoryRegion *system_memory, *system_io, *pci_memory; + + Error *error_abort = NULL; + + qemu_mutex_init(&ram_list.mutex); + + object_property_add_child(object_get_root(), "machine", obj, &error_abort); + if (error_abort) { + error_report_err(error_abort); + } + + memory_map_init(); + + system_memory = get_system_memory(); + system_io = get_system_io(); + + pci_memory = g_new(MemoryRegion, 1); + memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); + + rem_host = REMOTE_HOST_DEVICE(qdev_create(NULL, TYPE_REMOTE_HOST_DEVICE)); + + rem_host->mr_pci_mem = pci_memory; + rem_host->mr_sys_mem = system_memory; + rem_host->mr_sys_io = system_io; + + s->host = 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 = { + .name = TYPE_REMOTE_MACHINE, + .parent = TYPE_MACHINE, + .instance_size = sizeof(RemMachineState), + .instance_init = 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 ffcf47f185..97dd8327a2 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -26,10 +26,17 @@ #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" int main(int argc, char *argv[]) { module_call_init(MODULE_INIT_QOM); + current_machine = MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACHINE))); + return 0; } From patchwork Mon Jun 17 18:15:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000049 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9E01F1398 for ; Mon, 17 Jun 2019 18:26:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9301A288AA for ; Mon, 17 Jun 2019 18:26:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86A2B289A6; Mon, 17 Jun 2019 18:26:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE371288AA for ; Mon, 17 Jun 2019 18:26:49 +0000 (UTC) Received: from localhost ([::1]:50942 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwLB-00085A-8E for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:26:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58601) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwAf-0005RG-Ue for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwAe-0001Wf-Am for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:57 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:42840) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAd-0001VZ-V8 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:15:56 -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 x5HI8n18149250; Mon, 17 Jun 2019 18:15:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=QsrM+NGtd26oRHAt0LAUHOmtyzzuZEKIkpyw1SF0fu0=; b=B3QrbzRRe5NYSPm30Lq26LPec0FkfJThinDssHrQcs6omlqpJWhRCrTANXSM8I/SL/ka Q3RATlnZwEfGPpbDI4His/nfPcMLAa2GzyKtuJKxOR/Rj54eSiOPGpTUdVccYMADUYbf ZXTO19RsQ3/xJlbBbnaF/KxJWnkldXQgtF3Xl8vqhQttBW63gmNZvawT3Zbun1Ql0IXX mZv1BAvRykP9BgbxKcdP9bUAIVpwVsEMLFUOs6vWrSpC666lxKYm7f0+YHzYtEAMIV2K uEhZeJ2kixyGM887t574Ctj21KkbkWIen/7IyBC4NFaKavrLPpZzVxjVudR7q3/NFfcd 6Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2t4r3tg2v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:54 +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 x5HIF5ud050139; Mon, 17 Jun 2019 18:15:53 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2t5h5t9ff7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:15:53 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIFqtF014697; Mon, 17 Jun 2019 18:15:52 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:52 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:49 -0700 Message-Id: <20190617181549.29631-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 11/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 | 98 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 include/remote/memory.h create mode 100644 remote/memory.c diff --git a/Makefile.target b/Makefile.target index f45af2b851..30e81ddb5a 100644 --- a/Makefile.target +++ b/Makefile.target @@ -133,6 +133,8 @@ remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/monitor.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/replay.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) += stubs/xen-mapcache.o +remote-pci-tgt-obj-$(CONFIG_MPQEMU) += remote/memory.o + ######################################################### # Linux user emulator target diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 2f1584e87d..e9efe531ad 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" typedef struct ProxyLinkState ProxyLinkState; @@ -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 = 0, CONF_READ, CONF_WRITE, + SYNC_SYSMEM, MAX, } proc_cmd_t; @@ -74,6 +78,12 @@ typedef enum { * data2 Unstructured data * */ +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; @@ -81,6 +91,7 @@ typedef struct { union { uint64_t u64; + sync_sysmem_msg_t sync_sysmem; } data1; int fds[REMOTE_MAX_FDS]; diff --git a/include/remote/memory.h b/include/remote/memory.h new file mode 100644 index 0000000000..0ffbca0145 --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 0000000000..69a0ee8c6a --- /dev/null +++ b/remote/memory.c @@ -0,0 +1,98 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 size, + ram_addr_t offset, Error **errp) +{ + char *name = g_strdup_printf("%d", fd); + + memory_region_init(mr, NULL, name, size); + mr->ram = true; + mr->terminates = true; + mr->destructor = remote_ram_destructor; + mr->align = 0; + mr->ram_block = qemu_ram_alloc_from_fd(size, mr, RAM_SHARED, fd, offset, errp); + mr->dirty_log_mask = tcg_enabled() ? (1 << DIRTY_MEMORY_CODE) : 0; + + g_free(name); +} + +void remote_sysmem_reconfig(ProcMsg *msg, Error **errp) +{ + sync_sysmem_msg_t *sysmem_info = &msg->data1.sync_sysmem; + MemoryRegion *sysmem, *subregion, *next; + Error *local_err = NULL; + int region; + + sysmem = get_system_memory(); + + qemu_mutex_lock_iothread(); + + memory_region_transaction_begin(); + + QTAILQ_FOREACH_SAFE(subregion, &sysmem->subregions, subregions_link, next) { + if (subregion->ram) { + memory_region_del_subregion(sysmem, subregion); + /* TODO: should subregion be finalized separately? */ + } + } + + for (region = 0; region < msg->num_fds; region++) { + subregion = 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(); +} From patchwork Mon Jun 17 18:15:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 605AB1398 for ; Mon, 17 Jun 2019 18:29:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 557DC288AA for ; Mon, 17 Jun 2019 18:29:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 482A0289A5; Mon, 17 Jun 2019 18:29:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 50C46288AA for ; Mon, 17 Jun 2019 18:29:35 +0000 (UTC) Received: from localhost ([::1]:50960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwNq-0002UX-L6 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:29:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58753) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwB5-0005Yu-Bv for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwB1-0001ps-72 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAy-0001lC-VM for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:19 -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 x5HI9xFw159764; Mon, 17 Jun 2019 18:16:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=KM7t1jnu/GE3MIwd7uWHaGuh95c2hTbDnVcnU4+bpKw=; b=pHAs9uceKgmjE8mL46W4SWZ7Ey2kv/FoXP4CIKGSpm/O/hpjk1PKaBO6dYyET3kqTirJ DOaF4NaFtGMQV0i1vi21Ge1Wo0p9a6jLFQmeKVI8eCKUQLN9Q0UjFwzxblk5SfKPLmzk QyED7yFnHmx9EivL3igtdy+Xb31PmcESF3ydGiN/nQA/pmZC+lJ0pUHvmgNNFF5OawMd EZ8B7e+x3ptCuQaUlYtk616QuhFh7z/YaFkdaD/nGOUDpO7zAR9PwuOOc+yuGRANXZZc bHtlVjez1/vsu6rTXVbDvRMrnQbzvpQxWxF4Sb4eyhh+Oa5CRKlSw9LsQJldWJE6pMld nQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t4saq7yf4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:10 +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 x5HIEO0F175390; Mon, 17 Jun 2019 18:16:09 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t5mgbgat6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:09 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIFtSp032037; Mon, 17 Jun 2019 18:15:55 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:55 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:53 -0700 Message-Id: <20190617181553.29677-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 12/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Adds the handler to process message from QEMU, Initialize remote process main loop, handles SYNC_SYSMEM message by updating its "system_memory" container using shared file descriptors received from QEMU. Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman --- Changes in v2: - Separate thread for message processing is removed. --- remote/remote-main.c | 81 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index 97dd8327a2..f36483b3ae 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -23,6 +23,8 @@ */ #include +#include +#include #include "qemu/osdep.h" #include "qemu/module.h" @@ -31,12 +33,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) +{ + ProcMsg *msg = NULL; + Error *err = NULL; + + if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { + error_setg(&err, "socket closed, cond is %d", cond); + goto finalize_loop; + } + + msg = g_malloc0(sizeof(ProcMsg)); + + if (proxy_proc_recv(proxy_link, msg) < 0) { + error_setg(&err, "Failed to receive message"); + goto finalize_loop; + } + + switch (msg->cmd) { + case INIT: + break; + case CONF_WRITE: + break; + case CONF_READ: + break; + default: + error_setg(&err, "Unknown command"); + goto finalize_loop; + } + + g_free(msg); + + return; + +finalize_loop: + error_report_err(err); + g_free(msg); + proxy_link_finalize(proxy_link); + proxy_link = NULL; +} int main(int argc, char *argv[]) { + Error *err = NULL; + module_call_init(MODULE_INIT_QOM); + bdrv_init_with_whitelist(); + + if (qemu_init_main_loop(&err)) { + error_report_err(err); + return -EBUSY; + } + + qemu_init_cpu_loop(); + + page_size_init(); + current_machine = MACHINE(REMOTE_MACHINE(object_new(TYPE_REMOTE_MACHINE))); + proxy_link = proxy_link_create(); + if (!proxy_link) { + printf("Could not create proxy link\n"); + return -1; + } + + proxy_link_set_sock(proxy_link, STDIN_FILENO); + proxy_link_set_callback(proxy_link, process_msg); + + start_handler(proxy_link); + return 0; } From patchwork Mon Jun 17 18:15:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6408314BB for ; Mon, 17 Jun 2019 18:36:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 561A928960 for ; Mon, 17 Jun 2019 18:36:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47657289BA; Mon, 17 Jun 2019 18:36:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4688428960 for ; Mon, 17 Jun 2019 18:36:00 +0000 (UTC) Received: from localhost ([::1]:50994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwU3-0006i1-A4 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:35:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58757) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwB5-0005Yy-CA for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwB1-0001ot-1z for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:23 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43072) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAy-0001lb-Tp for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16: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 x5HI8wYD149305; Mon, 17 Jun 2019 18:16:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=1ZwVqQ+C9S/mfS2DjmonBx9P2Aj+vwsjsrWFSRP93mk=; b=BhTeUtkq54R+C0kbkN1/n8d4+NF4vJfkpMiH9mg3hsDySP4sOfIPAB8vmf2M3RzVspDt XpE10F8T9OamsWcMras1zAmm+vzdHgkKu0TfjMaAXkjO7g1OUYcqLCoNWa7GmlS0MJaj E5C3lcMjiKAnTeBjCIQUJIvXJ376tmL/SktftryNd8BetPwtKHR18zfoPwVW7m6Cavqt 5ap3AJZIcxrSO200oWtDjt+bOUo47HzDGrPH+REIhTF8g6/zn8fuKKdlTE6KCayHX/xP onLUEBYi7vr38j/qhjqkUSCdGPYaV2KDByssJX3NabSPkhT0DcYkMM4C7G30ZrL5ipGH dw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2t4r3tg2vx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16: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 x5HIF5ui050139; Mon, 17 Jun 2019 18:16:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2t5h5t9fjt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:06 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIFxiM024922; Mon, 17 Jun 2019 18:15:59 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:15:58 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:55 -0700 Message-Id: <20190617181555.29725-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 13/35] 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, john.g.johnson@oracle.com, thuth@redhat.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 | 250 ++++++++++++++++++++++++++++++++++ include/hw/proxy/qemu-proxy.h | 79 +++++++++++ remote/remote-main.c | 28 ++++ 5 files changed, 360 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 80e0a6ab14..11121c0cef 100644 --- a/hw/Makefile.objs +++ b/hw/Makefile.objs @@ -40,6 +40,8 @@ devices-dirs-y += core/ common-obj-y += $(devices-dirs-y) obj-y += $(devices-dirs-y) +common-obj-$(CONFIG_MPQEMU) += proxy/ + remote-pci-obj-$(CONFIG_MPQEMU) += core/ remote-pci-obj-$(CONFIG_MPQEMU) += block/ remote-pci-obj-$(CONFIG_MPQEMU) += pci/ diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs new file mode 100644 index 0000000000..eb81624cf8 --- /dev/null +++ b/hw/proxy/Makefile.objs @@ -0,0 +1 @@ +common-obj-$(CONFIG_MPQEMU) += qemu-proxy.o diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c new file mode 100644 index 0000000000..6ae584b5ad --- /dev/null +++ b/hw/proxy/qemu-proxy.c @@ -0,0 +1,250 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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] = {-1, -1}; + Error *local_error = 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 = qemu_fork(&local_error); + + if (rpid == -1) { + error_setg(errp, "Unable to spawn emulation program."); + close(fd[0]); + close(fd[1]); + return -1; + } + + if (rpid == 0) { + close(fd[0]); + + args[0] = g_strdup(command); + args[1] = g_strdup_printf("%d", fd[1]); + args[2] = NULL; + execvp(args[0], (char *const *)args); + exit(1); + } + pdev->remote_pid = rpid; + pdev->rsocket = fd[0]; + + if (fd[1] != -1) { + close(fd[1]); + return -1; + } + + return 0; + +} + +static int get_proxy_sock(PCIDevice *dev) +{ + PCIProxyDev *pdev; + + pdev = PCI_PROXY_DEV(dev); + + return pdev->rsocket; +} + +static void set_proxy_sock(PCIDevice *dev, int socket) +{ + PCIProxyDev *pdev; + + pdev = PCI_PROXY_DEV(dev); + + pdev->rsocket = socket; + pdev->managed = 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 = addr; + conf_data.val = (op == CONF_WRITE) ? *val : 0; + conf_data.l = l; + + msg.data2 = (uint8_t *)malloc(sizeof(conf_data)); + if (!msg.data2) { + return -ENOMEM; + } + + memcpy(msg.data2, (const uint8_t *)&conf_data, sizeof(conf_data)); + msg.size = sizeof(conf_data); + msg.cmd = op; + msg.bytestream = 1; + + if (op == CONF_WRITE) { + msg.num_fds = 0; + } else { + wait = GET_REMOTE_WAIT; + msg.num_fds = 1; + msg.fds[0] = wait; + } + + proxy_proc_send(dev->proxy_link, &msg); + + if (op == CONF_READ) { + *val = (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 val, + 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 = PCI_DEVICE_CLASS(klass); + + k->realize = pci_proxy_dev_realize; + k->config_read = pci_proxy_read_config; + k->config_write = pci_proxy_write_config; +} + +static const TypeInfo pci_proxy_dev_type_info = { + .name = TYPE_PCI_PROXY_DEV, + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(PCIProxyDev), + .abstract = true, + .class_size = sizeof(PCIProxyDevClass), + .class_init = pci_proxy_dev_class_init, + .interfaces = (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 = PCI_PROXY_DEV(dev); + Error *local_error = NULL; + + if (!pdev->managed) { + if (command) { + remote_spawn(pdev, command, &local_error); + } else { + return; + } + } else { + pdev->remote_pid = atoi(pdev->rid); + if (pdev->remote_pid == -1) { + error_setg(errp, "Remote PID is -1"); + return; + } + } + + pdev->proxy_link = proxy_link_create(); + + if (!pdev->proxy_link) { + error_setg(errp, "Failed to create proxy link"); + return; + } + + proxy_link_set_sock(pdev->proxy_link, pdev->rsocket); +} + +static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) +{ + PCIProxyDev *dev = PCI_PROXY_DEV(device); + PCIProxyDevClass *k = PCI_PROXY_DEV_GET_CLASS(dev); + Error *local_err = NULL; + + if (k->realize) { + k->realize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } + } + + dev->set_proxy_sock = set_proxy_sock; + dev->get_proxy_sock = get_proxy_sock; + dev->init_proxy = init_proxy; +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h new file mode 100644 index 0000000000..911da6a306 --- /dev/null +++ b/include/hw/proxy/qemu-proxy.h @@ -0,0 +1,79 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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_DEV) + +#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; + + char *rid; + + bool managed; + + 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 cmd); + 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 f36483b3ae..bb0d5f5178 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -49,6 +49,32 @@ static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; +static void process_config_write(ProcMsg *msg) +{ + struct conf_data_msg *conf = (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 = (struct conf_data_msg *)msg->data2; + uint32_t val; + int wait; + + wait = msg->fds[0]; + + qemu_mutex_lock_iothread(); + val = 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) { ProcMsg *msg = NULL; @@ -70,8 +96,10 @@ static void process_msg(GIOCondition cond) 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"); From patchwork Mon Jun 17 18:15:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E275C14B6 for ; Mon, 17 Jun 2019 18:23:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D79C928732 for ; Mon, 17 Jun 2019 18:23:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAEBE289A2; Mon, 17 Jun 2019 18:23:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 50DD02882D for ; Mon, 17 Jun 2019 18:23:00 +0000 (UTC) Received: from localhost ([::1]:50914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwHT-0003ym-LZ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:22:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58659) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwAy-0005U3-6Q for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwAv-0001lX-3s for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:16 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAr-0001hA-Cy for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:11 -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 x5HI8tMn159137; Mon, 17 Jun 2019 18:16:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=QAbbsNXjuZnlhha+vIc2Ur6Q0CBLGlGcdmYuVa78Qss=; b=Wf4rjmX5AKj+w6lOTfNDuSdHvrePslXKgfH8SXK+iUkpoFz95uz4cF7ogxD0HyZWH+lk Z1b/95qHaeCMHCBbqBpSsyLDe+icN8rgEYr2Si4jptczKzXAMHvlhFHrRxOFRS81VrIX l1Rinb732SKKDKR7LxHBiDGiuB6k601ZSO7hnMSPxZKQLr5zZHoX4gjFk5wWfPhC0QlW GxSLc7NmNDgcuvsy0ZYaxhuhDTXwpR1hAPU0ah8g7diMGQQUI7LfGtI4q5Vt7U7yRriI vt2f3rNVeDr4i0D0UmBD5fWSdbvT7ZlTlqMy0D5Gjdacic9CdS3BkKuf94pZhN1ejoBF ng== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2t4saq7yep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:03 +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 x5HIF5Ce050134; Mon, 17 Jun 2019 18:16:03 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2t5h5t9fhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:03 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIG2o7024949; Mon, 17 Jun 2019 18:16:02 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:02 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:15:59 -0700 Message-Id: <20190617181559.29770-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 14/35] multi-process: PCI BAR 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Proxy device object implements handler for PCI BAR writes. The handler sends BAR_WRITE message to the remote process with the BAR address and value to be written The remote process implements handler for BAR_WRITE message. Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson --- hw/proxy/qemu-proxy.c | 28 ++++++++++++++++++++++++++++ include/hw/proxy/qemu-proxy.h | 2 ++ include/io/proxy-link.h | 10 ++++++++++ remote/remote-main.c | 24 ++++++++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 6ae584b5ad..7f796a8e67 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -248,3 +248,31 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) dev->get_proxy_sock = get_proxy_sock; dev->init_proxy = 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; + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.bytestream = 0; + msg.size = sizeof(msg.data1); + msg.data1.bar_access.addr = mr->addr + addr; + msg.data1.bar_access.size = size; + msg.data1.bar_access.memory = memory; + + if (write) { + msg.cmd = BAR_WRITE; + msg.data1.bar_access.val = *val; + } + + proxy_proc_send(proxy_link, &msg); +} + +void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr, + uint64_t val, unsigned size, bool memory) +{ + send_bar_access_msg(dev->proxy_link, mr, true, addr, &val, size, memory); +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 911da6a306..b717c8d767 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -75,5 +75,7 @@ typedef struct PCIProxyDevClass { int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp); +void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr, + uint64_t val, unsigned size, bool memory); #endif /* QEMU_PROXY_H */ diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index e9efe531ad..20bc217212 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -56,6 +56,7 @@ 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 * */ typedef enum { @@ -63,6 +64,7 @@ typedef enum { CONF_READ, CONF_WRITE, SYNC_SYSMEM, + BAR_WRITE, MAX, } proc_cmd_t; @@ -84,6 +86,13 @@ typedef struct { ram_addr_t offsets[REMOTE_MAX_FDS]; } sync_sysmem_msg_t; +typedef struct { + hwaddr addr; + uint64_t val; + unsigned size; + bool memory; +} bar_access_msg_t; + typedef struct { proc_cmd_t cmd; int bytestream; @@ -92,6 +101,7 @@ typedef struct { union { uint64_t u64; sync_sysmem_msg_t sync_sysmem; + bar_access_msg_t bar_access; } data1; int fds[REMOTE_MAX_FDS]; diff --git a/remote/remote-main.c b/remote/remote-main.c index bb0d5f5178..90e979289c 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" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -75,6 +76,23 @@ static void process_config_read(ProcMsg *msg) PUT_REMOTE_WAIT(wait); } +/* TODO: confirm memtx attrs. */ +static void process_bar_write(ProcMsg *msg, Error **errp) +{ + bar_access_msg_t *bar_access = &msg->data1.bar_access; + AddressSpace *as = + bar_access->memory ? &address_space_memory : &address_space_io; + MemTxResult res; + + res = address_space_rw(as, bar_access->addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *)&bar_access->val, bar_access->size, true); + + if (res != MEMTX_OK) { + error_setg(errp, "Could not perform address space write operation," + " inaccessible address: %lx.", bar_access->addr); + } +} + static void process_msg(GIOCondition cond) { ProcMsg *msg = NULL; @@ -101,6 +119,12 @@ static void process_msg(GIOCondition cond) case CONF_READ: process_config_read(msg); break; + case BAR_WRITE: + process_bar_write(msg, &err); + if (err) { + goto finalize_loop; + } + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; From patchwork Mon Jun 17 18:16:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFF1914B6 for ; Mon, 17 Jun 2019 18:26:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4BA3288AA for ; Mon, 17 Jun 2019 18:26:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A81B7289A5; Mon, 17 Jun 2019 18:26:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2EE39288AA for ; Mon, 17 Jun 2019 18:26:42 +0000 (UTC) Received: from localhost ([::1]:50940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwL3-000835-GG for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:26:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58755) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwB5-0005Yx-By for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwB1-0001pe-5E for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55686) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAz-0001j6-1K for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:19 -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 x5HI9Ofj159576; Mon, 17 Jun 2019 18:16:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=wAbYWjTDPTNdGXz4juao/Kn/TenPE6WdVD5YQrfPQwc=; b=cNuYhgM88UND9sEqbVSNa/REfrBAiZsy4z77idHqVaPTfLNozuLzX9Q+m/YXJ28BX1fE CnfyjkrXJjqKF7aNsDv05HFx9zis9fr1NxKVw8QWg43Dp1R8zZvCMN2nQ3c5g5ERn5h3 em7bH2ndV6DBp0ptCaz3Hl/7zvxG2x2QqBYeF4832WcYni2SxZZPvaJUVZF+9gFhHze9 g8d3NFuxy/JhHL9O0ZV8nEZvMywkYqUu8YTK65Q6EbOgkHaYBwcVU4zXU6vn/HWzD/sc 34HoJ+QUjsgQ7lDXqxLWUG4CmQBqyzJpHpQ4ftiduITep58JjzANmyhUEjJ+XKKfOt7y jQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t4saq7yew-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16: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 x5HIEN2w175334; Mon, 17 Jun 2019 18:16:06 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t5mgbgasa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:06 +0000 Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIG5PR024976; Mon, 17 Jun 2019 18:16:05 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:05 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:02 -0700 Message-Id: <20190617181602.29817-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 15/35] multi-process: PCI BAR read 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Proxy device object implements the read handler for PCI BAR accesses. The handler sends BAR_READ message to the remote process. The remote process implements handler for BAR_READ message. Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson --- hw/proxy/qemu-proxy.c | 22 ++++++++++++++++ include/hw/proxy/qemu-proxy.h | 3 +++ include/io/proxy-link.h | 2 ++ remote/remote-main.c | 49 +++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 7f796a8e67..3ee3854f40 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -254,6 +254,7 @@ static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *mr, unsigned size, bool memory) { ProcMsg msg; + int wait; memset(&msg, 0, sizeof(ProcMsg)); @@ -266,9 +267,20 @@ static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *mr, if (write) { msg.cmd = BAR_WRITE; msg.data1.bar_access.val = *val; + } else { + wait = GET_REMOTE_WAIT; + + msg.cmd = BAR_READ; + msg.num_fds = 1; + msg.fds[0] = wait; } proxy_proc_send(proxy_link, &msg); + + if (!write) { + *val = wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + } } void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr, @@ -276,3 +288,13 @@ void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr, { send_bar_access_msg(dev->proxy_link, mr, true, addr, &val, size, memory); } + +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, memory); + + return val; +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index b717c8d767..a0db811de4 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -78,4 +78,7 @@ int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp); void proxy_default_bar_write(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr, uint64_t val, unsigned size, bool memory); +uint64_t proxy_default_bar_read(PCIProxyDev *dev, MemoryRegion *mr, hwaddr addr, + unsigned size, bool memory); + #endif /* QEMU_PROXY_H */ diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 20bc217212..69074a3519 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -57,6 +57,7 @@ typedef struct ProxyLinkState ProxyLinkState; * 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 { @@ -65,6 +66,7 @@ typedef enum { CONF_WRITE, SYNC_SYSMEM, BAR_WRITE, + BAR_READ, MAX, } proc_cmd_t; diff --git a/remote/remote-main.c b/remote/remote-main.c index 90e979289c..4372b71e89 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -93,6 +93,49 @@ static void process_bar_write(ProcMsg *msg, Error **errp) } } +static void process_bar_read(ProcMsg *msg, Error **errp) +{ + bar_access_msg_t *bar_access = &msg->data1.bar_access; + AddressSpace *as; + int wait = msg->fds[0]; + MemTxResult res; + uint64_t val = 0; + + as = bar_access->memory ? &address_space_memory : &address_space_io; + + assert(bar_access->size <= sizeof(uint64_t)); + + res = address_space_rw(as, bar_access->addr, MEMTXATTRS_UNSPECIFIED, + (uint8_t *)&val, bar_access->size, false); + + if (res != MEMTX_OK) { + error_setg(errp, "Could not perform address space read operation," + " inaccessible address: %lx.", bar_access->addr); + val = (uint64_t)-1; + goto fail; + } + + switch (bar_access->size) { + case 4: + val = *((uint32_t *)&val); + break; + case 2: + val = *((uint16_t *)&val); + break; + case 1: + val = *((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) { ProcMsg *msg = NULL; @@ -125,6 +168,12 @@ static void process_msg(GIOCondition cond) 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; From patchwork Mon Jun 17 18:16:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A49941398 for ; Mon, 17 Jun 2019 18:30:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 989CE288B3 for ; Mon, 17 Jun 2019 18:30:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8724B288F6; Mon, 17 Jun 2019 18:30:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D5282288B3 for ; Mon, 17 Jun 2019 18:30:39 +0000 (UTC) Received: from localhost ([::1]:50972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwOr-0003Tw-Ed for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:30:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58752) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwB5-0005Yt-Br for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwB1-0001po-5q for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:22 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwAz-0001mN-1D for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:19 -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 x5HI8uWv149284; Mon, 17 Jun 2019 18:16:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=u0KD8hGcmwoPPEuwNGAsbOvcFDGhZdCGGwz4LvnSoPE=; b=rytlw6tWvqXPdPxpL1wH46+dxvh3Iqc+Ndl1vn6afpgH1zLGKBtxqlu9Ta7rrSzjG9XS bJjsZF94j6oAilSRmHnPMrzp2uGAy3czynWEj068mF2Arn37AvF8JlBDd+Fc5Y17qvOT bbr/ouzLHWgkoQvChaTLwDeKfOThhtmhS7tL3k1qUkbZ28nypFDWIwFOOinncTHsaYvL qCNa8A57tZJ/TMLPmOE8+ShZ8OKYYASlZIfcrvniugPZz2qXUj+6VNFOu89yx5a7bnMw O6D32DaFuIyL4qYBS040cA/9D5eSnc0xrl5TJaI4ygd4vouPApjHR5yOuUbVBNcNtA0p zQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2t4r3tg2wh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16: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 x5HIF9OB117990; Mon, 17 Jun 2019 18:16:11 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2t5cpdkew5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:11 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIGB55028136; Mon, 17 Jun 2019 18:16:11 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:11 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:05 -0700 Message-Id: <20190617181605.29863-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 16/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Adds 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 eb81624cf8..f562f5a0e9 100644 --- a/hw/proxy/Makefile.objs +++ b/hw/proxy/Makefile.objs @@ -1 +1,2 @@ common-obj-$(CONFIG_MPQEMU) += qemu-proxy.o +common-obj-$(CONFIG_MPQEMU) += proxy-lsi53c895a.o diff --git a/hw/proxy/proxy-lsi53c895a.c b/hw/proxy/proxy-lsi53c895a.c new file mode 100644 index 0000000000..e8a8d36f6e --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = 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 = opaque; + + proxy_default_bar_write(PCI_PROXY_DEV(s), &s->io_io, addr, val, size, + false); +} + +static const MemoryRegionOps proxy_lsi_io_ops = { + .read = proxy_lsi_io_read, + .write = proxy_lsi_io_write, + .endianness = DEVICE_NATIVE_ENDIAN, + .impl = { + .min_access_size = 1, + .max_access_size = 1, + }, +}; + +static uint64_t proxy_lsi_ram_read(void *opaque, hwaddr addr, unsigned size) +{ + ProxyLSIState *s = 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 = opaque; + + proxy_default_bar_write(PCI_PROXY_DEV(s), &s->ram_io, addr, val, size, + true); +} + +static const MemoryRegionOps proxy_lsi_ram_ops = { + .read = proxy_lsi_ram_read, + .write = proxy_lsi_ram_write, + .endianness = DEVICE_NATIVE_ENDIAN, +}; + +static uint64_t proxy_lsi_mmio_read(void *opaque, hwaddr addr, unsigned size) +{ + ProxyLSIState *s = opaque; + + return proxy_default_bar_read(PCI_PROXY_DEV(s), &s->mmio_io, addr, size, + true); +} + +static void proxy_lsi_mmio_write(void *opaque, hwaddr addr, uint64_t val, + unsigned size) +{ + ProxyLSIState *s = opaque; + + proxy_default_bar_write(PCI_PROXY_DEV(s), &s->mmio_io, addr, val, size, + true); +} + +static const MemoryRegionOps proxy_lsi_mmio_ops = { + .read = proxy_lsi_mmio_read, + .write = proxy_lsi_mmio_write, + .endianness = DEVICE_NATIVE_ENDIAN, + .impl = { + .min_access_size = 1, + .max_access_size = 1, + }, +}; + +static void proxy_lsi_realize(PCIProxyDev *dev, Error **errp) +{ + ProxyLSIState *s = LSI_PROXY_DEV(dev); + PCIDevice *pci_dev = PCI_DEVICE(dev); + uint8_t *pci_conf = pci_dev->config; + + pci_conf[PCI_LATENCY_TIMER] = 0xff; + pci_conf[PCI_INTERRUPT_PIN] = 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_io); + 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 = DEVICE_CLASS(klass); + PCIDeviceClass *pci_class = PCI_DEVICE_CLASS(klass); + PCIProxyDevClass *proxy_class = PCI_PROXY_DEV_CLASS(klass); + + proxy_class->realize = proxy_lsi_realize; + proxy_class->command = g_strdup("qemu-scsi-dev"); + + pci_class->vendor_id = PCI_VENDOR_ID_LSI_LOGIC; + pci_class->device_id = PCI_DEVICE_ID_LSI_53C895A; + pci_class->class_id = PCI_CLASS_STORAGE_SCSI; + pci_class->subsystem_id = 0x1000; + + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); + + dc->desc = "LSI Proxy Device"; +} + +static const TypeInfo lsi_proxy_dev_type_info = { + .name = TYPE_PROXY_LSI53C895A, + .parent = TYPE_PCI_PROXY_DEV, + .instance_size = sizeof(ProxyLSIState), + .class_init = 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-lsi53c895a.h new file mode 100644 index 0000000000..8afb8f3fec --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 From patchwork Mon Jun 17 18:16:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000127 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 534EA112C for ; Mon, 17 Jun 2019 18:42:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4791328820 for ; Mon, 17 Jun 2019 18:42:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BB082881E; Mon, 17 Jun 2019 18:42:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3DEFD28685 for ; Mon, 17 Jun 2019 18:42:01 +0000 (UTC) Received: from localhost ([::1]:51030 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwZs-00046q-Fo for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:42:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58806) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBA-0005a7-8i for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwB5-0001sb-Cp for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:27 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57206) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwB1-0001oV-8l for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:22 -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 x5HI9EWL066342; Mon, 17 Jun 2019 18:16:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=ogANGKzTUhVUwQvsBSa/yI6M9N2WE5GfXHklfqrFL4I=; b=EfnkiItHQ4DmF6gnv2Pcvefm5txrRosct1pnfjm3APdNHAs8rT7Ps67QtIvbKB7YdStM QC/bvhszqCiliYb4peXpY9khmJ2xAToSOvFyXqAxWZRZywWrugQt+iJMaDCArIfTOSO0 plTL0cSvnum420/cPfnlH76gsjX2VRbHt69hzdXPG2rFlPTsRR6vZVcQdpDxelCHZpTH TutGodFuKw1exyfQ6LvauqSpchOLNkaEnMtICMSZZaesjyPsXkt8nTauJREaM3HL3hgT Yw/Hcl+v5PebkTpV7y0syQhU9lGDgOeRorqhyr/tVNphh+pmIVPj89nyU51KCXwiX2tZ Cw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2t4rmp00mm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16: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 x5HIG9Hd188014; Mon, 17 Jun 2019 18:16:15 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2t59gdcctn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:15 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIGFi8032152; Mon, 17 Jun 2019 18:16:15 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:14 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:11 -0700 Message-Id: <20190617181611.29910-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=4 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 17/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, armbru@redhat.com, ross.lagerwall@citrix.com, pbonzini@redhat.com, liran.alon@oracle.com, stefanha@redhat.com, marcandre.lureau@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 --- Makefile.target | 1 + hw/proxy/memory-sync.c | 214 +++++++++++++++++++++++++++++++++ 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, 284 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 30e81ddb5a..4df0ba27cc 100644 --- a/Makefile.target +++ b/Makefile.target @@ -122,6 +122,7 @@ obj-$(CONFIG_TCG) += fpu/softfloat.o obj-y += target/$(TARGET_BASE_ARCH)/ obj-y += disas.o obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o +obj-$(CONFIG_MPQEMU) += hw/proxy/memory-sync.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) += accel/stubs/kvm-stub.o remote-pci-tgt-obj-$(CONFIG_MPQEMU) += accel/stubs/tcg-stub.o diff --git a/hw/proxy/memory-sync.c b/hw/proxy/memory-sync.c new file mode 100644 index 0000000000..d3762dc117 --- /dev/null +++ b/hw/proxy/memory-sync.c @@ -0,0 +1,214 @@ +/* + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = { + .name = TYPE_MEMORY_LISTENER, + .parent = TYPE_OBJECT, + .instance_size = 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 = container_of(listener, RemoteMemSync, listener); + int mrs; + + for (mrs = 0; mrs < sync->n_mr_sections; mrs++) { + memory_region_unref(sync->mr_sections[mrs].mr); + } + + g_free(sync->mr_sections); + sync->mr_sections = NULL; + sync->n_mr_sections = 0; +} + +static bool proxy_mrs_can_merge(uint64_t host, uint64_t prev_host, size_t size) +{ + bool merge; + ram_addr_t offset; + int fd1, fd2; + MemoryRegion *mr; + + mr = memory_region_from_host((void *)(uintptr_t)host, &offset); + fd1 = memory_region_get_fd(mr); + + mr = memory_region_from_host((void *)(uintptr_t)prev_host, &offset); + fd2 = memory_region_get_fd(mr); + + merge = (fd1 == fd2); + + merge &= ((prev_host + size) == host); + + return merge; +} + +static void proxy_ml_region_addnop(MemoryListener *listener, + MemoryRegionSection *section) +{ + RemoteMemSync *sync = container_of(listener, RemoteMemSync, listener); + bool need_add = 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 = section->mr->ram_block; + mrs_page = (uint64_t)qemu_ram_pagesize(mrs_rb); + mrs_size = int128_get64(section->size); + mrs_gpa = section->offset_within_address_space; + mrs_host = (uintptr_t)memory_region_get_ram_ptr(section->mr) + + section->offset_within_region; + + mrs_host = mrs_host & ~(mrs_page - 1); + mrs_gpa = mrs_gpa & ~(mrs_page - 1); + mrs_size = ROUND_UP(mrs_size, mrs_page); + + if (sync->n_mr_sections) { + prev_sec = sync->mr_sections + (sync->n_mr_sections - 1); + uint64_t prev_gpa_start = prev_sec->offset_within_address_space; + uint64_t prev_size = int128_get64(prev_sec->size); + uint64_t prev_gpa_end = range_get_last(prev_gpa_start, prev_size); + uint64_t prev_host_start = + (uintptr_t)memory_region_get_ram_ptr(prev_sec->mr) + + prev_sec->offset_within_region; + uint64_t prev_host_end = range_get_last(prev_host_start, prev_size); + + if (mrs_gpa <= (prev_gpa_end + 1)) { + if (mrs_gpa < prev_gpa_start) { + assert(0); + } + + if ((section->mr == prev_sec->mr) && + proxy_mrs_can_merge(mrs_host, prev_host_start, + (mrs_gpa - prev_gpa_start))) { + uint64_t max_end = MAX(prev_host_end, mrs_host + mrs_size); + need_add = false; + prev_sec->offset_within_address_space = + MIN(prev_gpa_start, mrs_gpa); + prev_sec->offset_within_region = + MIN(prev_host_start, mrs_host) - + (uintptr_t)memory_region_get_ram_ptr(prev_sec->mr); + prev_sec->size = int128_make64(max_end - MIN(prev_host_start, + mrs_host)); + } + } + } + + if (need_add) { + ++sync->n_mr_sections; + sync->mr_sections = g_renew(MemoryRegionSection, sync->mr_sections, + sync->n_mr_sections); + sync->mr_sections[sync->n_mr_sections - 1] = *section; + sync->mr_sections[sync->n_mr_sections - 1].fv = NULL; + memory_region_ref(section->mr); + } +} + +static void proxy_ml_commit(MemoryListener *listener) +{ + RemoteMemSync *sync = container_of(listener, RemoteMemSync, listener); + ProcMsg msg; + ram_addr_t offset; + MemoryRegion *mr; + MemoryRegionSection section; + uintptr_t host_addr; + int region; + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.cmd = SYNC_SYSMEM; + msg.bytestream = 0; + msg.num_fds = sync->n_mr_sections; + msg.size = sizeof(msg.data1); + assert(msg.num_fds <= REMOTE_MAX_FDS); + + for (region = 0; region < sync->n_mr_sections; region++) { + section = sync->mr_sections[region]; + msg.data1.sync_sysmem.gpas[region] = + section.offset_within_address_space; + msg.data1.sync_sysmem.sizes[region] = int128_get64(section.size); + host_addr = (uintptr_t)memory_region_get_ram_ptr(section.mr) + + section.offset_within_region; + mr = memory_region_from_host((void *)host_addr, &offset); + msg.fds[region] = memory_region_get_fd(mr); + msg.data1.sync_sysmem.offsets[region] = offset; + } + proxy_proc_send(sync->proxy_link, &msg); +} + +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 = 0; + sync->mr_sections = NULL; + + sync->proxy_link = proxy_link; + + sync->listener.begin = proxy_ml_begin; + sync->listener.commit = proxy_ml_commit; + sync->listener.region_add = proxy_ml_region_addnop; + sync->listener.region_nop = proxy_ml_region_addnop; + sync->listener.priority = 10; + + memory_listener_register(&sync->listener, &address_space_memory); +} diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 3ee3854f40..76e29dc873 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" static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); @@ -229,6 +231,7 @@ static void init_proxy(PCIDevice *dev, char *command, Error **errp) } proxy_link_set_sock(pdev->proxy_link, pdev->rsocket); + configure_memory_sync(dev->sync, dev->proxy_link); } static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) @@ -247,6 +250,8 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) dev->set_proxy_sock = set_proxy_sock; dev->get_proxy_sock = get_proxy_sock; dev->init_proxy = init_proxy; + dev->sync = REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); + } static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *mr, diff --git a/include/hw/proxy/memory-sync.h b/include/hw/proxy/memory-sync.h new file mode 100644 index 0000000000..56d72689a1 --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 a0db811de4..eb9491eca4 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -24,6 +24,7 @@ #define QEMU_PROXY_H #include "io/proxy-link.h" +#include "hw/proxy/memory-sync.h" #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" @@ -44,6 +45,7 @@ typedef struct PCIProxyDev { ProxyLinkState *proxy_link; + RemoteMemSync *sync; EventNotifier intr; EventNotifier resample; diff --git a/remote/remote-main.c b/remote/remote-main.c index 4372b71e89..95908e16fd 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" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -174,6 +175,16 @@ static void process_msg(GIOCondition cond) 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; From patchwork Mon Jun 17 18:16:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 789BF14B6 for ; Mon, 17 Jun 2019 18:45:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B6BA28538 for ; Mon, 17 Jun 2019 18:45:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EF762865F; Mon, 17 Jun 2019 18:45:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 39B8D28538 for ; Mon, 17 Jun 2019 18:45:29 +0000 (UTC) Received: from localhost ([::1]:51060 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwdE-0007vS-H1 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:45:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58841) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBR-0005bg-Hs for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBM-00021d-Eq for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:45 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43236) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBI-0001qx-IT for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16: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 x5HI8k5m149224; Mon, 17 Jun 2019 18:16:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=5kOb/03J4hwquD/DIpJPUY4JHvr+hzQ0JyKZLrfLMKk=; b=RzRbV8/Ar/CSmzkYwCM91JjLiKt8ivFcL90Zd4XR/KsJzhnJzcRw42dGkYMqlpV2HxGj WrUMHOlzOGoG3tTHZ8n72vMd6/x9+hyTQyjcHMIK0bJm9LDnZVP9nZ3wrvJLHlIuDyHG Wnv/IUjIYVrrgABJVgHrqYgYRpu8zI42eANlfgRyN/Mml1Ger/9zFADOuPc8lP2bgESf Rxg3HLujWieor5jQVpTXEz043r70aNgvm/mNq0HtNcD7DQNvAH0u/+R8nLTswgAP5kGm CB/2Q2DYX/j0gt/6C967uet/MH0jBGXjKUL/5iNOFO7tQk4O04FECXhg4V+pcwnVbIwp 8g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2t4r3tg2wu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16: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 x5HIF5cv050106; Mon, 17 Jun 2019 18:16:18 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2t5h5t9fp4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:18 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIGHxh032170; Mon, 17 Jun 2019 18:16:17 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:16 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:15 -0700 Message-Id: <20190617181615.29957-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 18/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, mst@redhat.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman 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 --- hw/proxy/qemu-proxy.c | 62 ++++++++++++- 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 + 10 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 include/remote/iohub.h create mode 100644 remote/iohub.c diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 76e29dc873..6e65600c45 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,16 @@ #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" + +/* + * TODO: kvm_vm_ioctl is only available for per-target objects (NEED_CPU_H). + * The invocation of kvm_vm_ioctl should be moved to a per-target object. Until + * the the following definition is necessary + */ +int kvm_vm_ioctl(KVMState *s, int type, ...); static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); @@ -204,6 +217,52 @@ static void pci_proxy_dev_register_types(void) type_init(pci_proxy_dev_register_types) +static void proxy_intx_update(PCIDevice *pci_dev) +{ + PCIProxyDev *dev = PCI_PROXY_DEV(pci_dev); + PCIINTxRoute route; + int pin = pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1; + + if (dev->irqfd.fd) { + dev->irqfd.flags = KVM_IRQFD_FLAG_DEASSIGN; + (void) kvm_vm_ioctl(kvm_state, KVM_IRQFD, &dev->irqfd); + memset(&dev->irqfd, 0, sizeof(struct kvm_irqfd)); + } + + route = pci_device_route_intx_to_irq(pci_dev, pin); + + dev->irqfd.fd = event_notifier_get_fd(&dev->intr); + dev->irqfd.resamplefd = event_notifier_get_fd(&dev->resample); + dev->irqfd.gsi = route.irq; + dev->irqfd.flags |= KVM_IRQFD_FLAG_RESAMPLE; + (void) kvm_vm_ioctl(kvm_state, KVM_IRQFD, &dev->irqfd); +} + +static void setup_irqfd(PCIProxyDev *dev) +{ + PCIDevice *pci_dev = PCI_DEVICE(dev); + ProcMsg msg; + + event_notifier_init(&dev->intr, 0); + event_notifier_init(&dev->resample, 0); + + memset(&msg, 0, sizeof(ProcMsg)); + msg.cmd = SET_IRQFD; + msg.num_fds = 2; + msg.fds[0] = event_notifier_get_fd(&dev->intr); + msg.fds[1] = event_notifier_get_fd(&dev->resample); + msg.data1.set_irqfd.intx = + pci_get_byte(pci_dev->config + PCI_INTERRUPT_PIN) - 1; + + proxy_proc_send(dev->proxy_link, &msg); + + 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, Error **errp) { PCIProxyDev *pdev = PCI_PROXY_DEV(dev); @@ -231,7 +290,8 @@ static void init_proxy(PCIDevice *dev, char *command, Error **errp) } proxy_link_set_sock(pdev->proxy_link, pdev->rsocket); - configure_memory_sync(dev->sync, dev->proxy_link); + configure_memory_sync(pdev->sync, pdev->proxy_link); + setup_irqfd(pdev); } 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 0abe27a53a..9cc5e28052 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 +#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 diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index eb9491eca4..c27817f780 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 +#include + #include "io/proxy-link.h" #include "hw/proxy/memory-sync.h" +#include "qemu/event_notifier.h" #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" @@ -46,6 +49,8 @@ typedef struct PCIProxyDev { ProxyLinkState *proxy_link; RemoteMemSync *sync; + struct kvm_irqfd irqfd; + EventNotifier intr; EventNotifier resample; diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 69074a3519..843ac30e87 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; @@ -95,6 +98,10 @@ typedef struct { bool memory; } bar_access_msg_t; +typedef struct { + int intx; +} set_irqfd_msg_t; + typedef struct { proc_cmd_t cmd; int bytestream; @@ -104,6 +111,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; int fds[REMOTE_MAX_FDS]; diff --git a/include/remote/iohub.h b/include/remote/iohub.h new file mode 100644 index 0000000000..0a799d6fb0 --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 a00732d045..0a16cc6009 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" typedef struct RemMachineState { MachineState parent_obj; RemPCIHost *host; + RemoteIOHubState *iohub; } RemMachineState; #define TYPE_REMOTE_MACHINE "remote-machine" diff --git a/remote/Makefile.objs b/remote/Makefile.objs index 13d4c48988..cbb3065b69 100644 --- a/remote/Makefile.objs +++ b/remote/Makefile.objs @@ -1,3 +1,4 @@ remote-pci-obj-$(CONFIG_MPQEMU) += remote-main.o remote-pci-obj-$(CONFIG_MPQEMU) += pcihost.o remote-pci-obj-$(CONFIG_MPQEMU) += machine.o +remote-pci-obj-$(CONFIG_MPQEMU) += iohub.o diff --git a/remote/iohub.c b/remote/iohub.c new file mode 100644 index 0000000000..3ae062085c --- /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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 = REMOTE_IOHUB_DEVICE(obj); + int slot, intx, pirq; + + memset(&iohub->irqfds, 0, sizeof(iohub->irqfds)); + memset(&iohub->resamplefds, 0, sizeof(iohub->resamplefds)); + + for (slot = 0; slot < PCI_SLOT_MAX; slot++ ) { + for (intx = 0; intx < PCI_NUM_PINS; intx++) { + iohub->irq_num[slot][intx] = (slot + intx) % 4 + 4; + } + } + + for (pirq = 0; pirq < REMOTE_IOHUB_NB_PIRQS; pirq++) { + qemu_mutex_init(&iohub->irq_level_lock[pirq]); + iohub->irq_level[pirq] = 0; + } +} + +static void remote_iohub_class_init(ObjectClass *klass, void *data) +{ + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + k->vendor_id = PCI_VENDOR_ID_ORACLE; + k->device_id = PCI_DEVICE_ID_REMOTE_IOHUB; +} + +static const TypeInfo remote_iohub_info = { + .name = TYPE_REMOTE_IOHUB_DEVICE, + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(RemoteIOHubState), + .instance_init = remote_iohub_initfn, + .class_init = remote_iohub_class_init, + .interfaces = (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 = qdev_get_parent_bus(&pci_dev->qdev); + PCIBus *pci_bus = PCI_BUS(bus); + PCIDevice *pci_iohub = + pci_bus->devices[PCI_DEVFN(REMOTE_IOHUB_DEV, REMOTE_IOHUB_FUNC)]; + RemoteIOHubState *iohub = 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 = opaque; + + assert(pirq >= 0); + assert(pirq < REMOTE_IOHUB_NB_PIRQS); + + qemu_mutex_lock(&iohub->irq_level_lock[pirq]); + + if (level) { + if (++iohub->irq_level[pirq] == 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 = opaque; + RemoteIOHubState *iohub = token->iohub; + uint64_t val; + int pirq, s; + + pirq = token->pirq; + + s = read(event_notifier_get_fd(&iohub->resamplefds[pirq]), &val, + sizeof(uint64_t)); + + assert(s >= 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 = REMOTE_MACHINE(current_machine); + RemoteIOHubState *iohub = machine->iohub; + ResampleToken *token; + int pirq = remote_iohub_map_irq(pci_dev, msg->data1.set_irqfd.intx); + + assert(msg->num_fds == 2); + + event_notifier_init_fd(&iohub->irqfds[pirq], msg->fds[0]); + event_notifier_init_fd(&iohub->resamplefds[pirq], msg->fds[1]); + + token = g_malloc0(sizeof(ResampleToken)); + token->iohub = iohub; + token->pirq = pirq; + + qemu_set_fd_handler(msg->fds[1], intr_resample_handler, NULL, token); +} diff --git a/remote/machine.c b/remote/machine.c index 4ce197d300..5b03167dd5 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" static NotifierList machine_init_done_notifiers = NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers); @@ -70,6 +72,8 @@ static void remote_machine_init(Object *obj) RemMachineState *s = REMOTE_MACHINE(obj); RemPCIHost *rem_host; MemoryRegion *system_memory, *system_io, *pci_memory; + PCIHostState *pci_host; + PCIDevice *pci_dev; Error *error_abort = NULL; @@ -101,6 +105,17 @@ static void remote_machine_init(Object *obj) qemu_mutex_unlock_iothread(); qdev_init_nofail(DEVICE(rem_host)); + + pci_host = PCI_HOST_BRIDGE(rem_host); + pci_dev = pci_create_simple_multifunction(pci_host->bus, + PCI_DEVFN(REMOTE_IOHUB_DEV, + REMOTE_IOHUB_FUNC), + true, TYPE_REMOTE_IOHUB_DEVICE); + + s->iohub = 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); } static const TypeInfo remote_machine = { diff --git a/remote/remote-main.c b/remote/remote-main.c index 95908e16fd..f4ded7afb4 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" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -185,6 +186,9 @@ static void process_msg(GIOCondition cond) 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; From patchwork Mon Jun 17 18:16:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000119 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5141614DB for ; Mon, 17 Jun 2019 18:41:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 447A6286F6 for ; Mon, 17 Jun 2019 18:41:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3081A2881E; Mon, 17 Jun 2019 18:41:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BEA47289C9 for ; Mon, 17 Jun 2019 18:41:22 +0000 (UTC) Received: from localhost ([::1]:51028 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwZ5-00032M-Vj for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:41:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58947) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBW-0005em-Ni for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBR-000249-Vn for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:48 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBR-0001tY-Kr for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:45 -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 x5HI8u8Y066180; Mon, 17 Jun 2019 18:16:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=NigSNlV5R/RXaRrwwYi+FqS0o/n/JBNM0AEzbryJCMU=; b=ZAyB0HTRlvRv1wwlshHm4Dajzs1jkWEhTGViIFk//4sxCm3fbAktO8UyXOf22QlAZAWO 5Y+lp70wG2rzkVXBtQ/nX+9z0niD+EFqI/19j1TStNUWkGDL5Tcp82dMmbMD4fw9atOo 01mqfcwVaLGRkGDFo3IGb1kseNz9cEXKAUxqTHCHmdsofES7HhFC/vVViWaFFqXc5x5F 0IUSmAi5ex8HZ21LgBECtEoUiYGQW/iv9R8eTB+XH74IQacsmK+MlKxOfUUejCV7vY3K gtboBsjwIKzSQBtUjUKJ5JCwlAnLjvMUGW1XAHVr5SXAwWUmjcOz8qlZrLMwsEbHTVBu sg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2t4rmp00mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:21 +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 x5HIF5CL050176; Mon, 17 Jun 2019 18:16:21 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2t5h5t9fps-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:21 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGK2I014940; Mon, 17 Jun 2019 18:16:20 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:19 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:17 -0700 Message-Id: <20190617181617.30002-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-MIME-Autoconverted: from 8bit to quoted-printable by aserp2120.oracle.com id x5HI8u8Y066180 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 19/35] multi-process: store info about 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, john.g.johnson@oracle.com, jag.raman@oracle.com, ehabkost@redhat.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Elena Ufimtseva Store info about the remote process in a hash table, so that it could be used later for QMP/HMP commands. Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman --- Changes in v2: - moved the “remote_devs” object from “pcms” (PCMachineState) to “ms” (MachineState). --- hw/core/machine.c | 12 ++++++++++++ hw/proxy/qemu-proxy.c | 7 +++++++ include/hw/boards.h | 4 ++++ 3 files changed, 23 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index 743fef2898..0e6e6c0829 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -821,6 +821,14 @@ static void machine_class_base_init(ObjectClass *oc, void *data) } } +#ifdef CONFIG_MPQEMU +static void rem_list_destroy_key(gpointer data) +{ + void *key = data; + g_free(key); +} +#endif + static void machine_initfn(Object *obj) { MachineState *ms = MACHINE(obj); @@ -854,6 +862,10 @@ static void machine_initfn(Object *obj) NULL); } +#ifdef CONFIG_MPQEMU + ms->remote_devs = g_hash_table_new_full(g_str_hash, g_str_equal, + rem_list_destroy_key, NULL); +#endif /* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify; diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index 6e65600c45..c691a05dac 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -50,6 +50,7 @@ #include "qemu/event_notifier.h" #include "sysemu/kvm.h" #include "util/event_notifier-posix.c" +#include "hw/boards.h" /* * TODO: kvm_vm_ioctl is only available for per-target objects (NEED_CPU_H). @@ -299,6 +300,12 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) PCIProxyDev *dev = PCI_PROXY_DEV(device); PCIProxyDevClass *k = PCI_PROXY_DEV_GET_CLASS(dev); Error *local_err = NULL; + MachineState *ms = MACHINE(current_machine); + DeviceState *d = DEVICE(dev); + + + (void)g_hash_table_insert(ms->remote_devs, (gpointer)g_strdup(d->id), + (gpointer)dev); if (k->realize) { k->realize(dev, &local_err); diff --git a/include/hw/boards.h b/include/hw/boards.h index e231860666..bdc519aba9 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -3,6 +3,8 @@ #ifndef HW_BOARDS_H #define HW_BOARDS_H +#include + #include "sysemu/blockdev.h" #include "sysemu/accel.h" #include "hw/qdev.h" @@ -274,6 +276,8 @@ struct MachineState { AccelState *accelerator; CPUArchIdList *possible_cpus; struct NVDIMMState *nvdimms_state; + + GHashTable *remote_devs; }; #define DEFINE_MACHINE(namestr, machine_initfn) \ From patchwork Mon Jun 17 18:16:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 595C51398 for ; Mon, 17 Jun 2019 18:29:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DE99288AA for ; Mon, 17 Jun 2019 18:29:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F54C289A5; Mon, 17 Jun 2019 18:29:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F03F288AA for ; Mon, 17 Jun 2019 18:29:56 +0000 (UTC) Received: from localhost ([::1]:50962 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwOA-0002jD-1l for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:29:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58842) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBR-0005bh-Hx for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBO-00022W-Ky for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:45 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57348) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBN-0001vU-Nv for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:42 -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 x5HI8krm065843; Mon, 17 Jun 2019 18:16:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=LnCxHUpKKe53qjka/nW/IVl2C48b5NGyGGM3Oe5vEt4=; b=YPFJ+F4D1bgBa5kb34ZvfznjtbPEE0hfJUDU1OUy7slKVnkydJgZ0DqtMsgP5e6oJXfm nX8yUOi5Y/rSlMgE7X0iP/ivsq9vcWCdnzbMO7EIgtSTiImNTcXwQUDo3w3gIq2cHKVG WSWVOHfwQzmwyjS+8kQIsuxW19JwliahcLyv361btNcok6eO/GGJqQwFmKCdbI+p9tfn Uh2ON5+COazYuO16sVaZgrCqQQMLrZRTohNYdTvOlegSqVmdBl7+n62w4jW++D7mIYiB vCRYaYUqU5F17erKSk71q2WG+e9z82KOiXSo3NsbzBYkvhFe2gEQRMmIwbEYO3LP6NPU nw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2t4rmp00np-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:26 +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 x5HIGPtX181181; Mon, 17 Jun 2019 18:16:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t5mgbgayk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:25 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGNsr025209; Mon, 17 Jun 2019 18:16:23 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:22 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:20 -0700 Message-Id: <20190617181620.30047-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 20/35] multi-process: Add QMP & extend HMP commands to list remote info 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, dgilbert@redhat.com, armbru@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Add query-remote QMP command and extend "info" HMP command, to list the remote objects used by QEMU. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- hmp-commands-info.hx | 16 +++++++ hmp.h | 1 + hw/proxy/Makefile.objs | 1 + hw/proxy/monitor.c | 88 +++++++++++++++++++++++++++++++++++ include/hw/proxy/qemu-proxy.h | 1 + qapi/block-core.json | 29 ++++++++++++ 6 files changed, 136 insertions(+) create mode 100644 hw/proxy/monitor.c diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index c59444c461..b145e755eb 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -932,6 +932,22 @@ STEXI Show SEV information. ETEXI +#if defined(CONFIG_MPQEMU) + { + .name = "remote", + .args_type = "", + .params = "", + .help = "list remote objects", + .cmd = hmp_info_remote, + }, + +STEXI +@item remote +@findex remote +list remote objects. +ETEXI +#endif + STEXI @end table ETEXI diff --git a/hmp.h b/hmp.h index 43617f2646..6919f99218 100644 --- a/hmp.h +++ b/hmp.h @@ -150,5 +150,6 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict); void hmp_info_sev(Monitor *mon, const QDict *qdict); +void hmp_info_remote(Monitor *mon, const QDict *qdict); #endif diff --git a/hw/proxy/Makefile.objs b/hw/proxy/Makefile.objs index f562f5a0e9..e6420602b8 100644 --- a/hw/proxy/Makefile.objs +++ b/hw/proxy/Makefile.objs @@ -1,2 +1,3 @@ common-obj-$(CONFIG_MPQEMU) += qemu-proxy.o common-obj-$(CONFIG_MPQEMU) += proxy-lsi53c895a.o +common-obj-$(CONFIG_MPQEMU) += monitor.o diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c new file mode 100644 index 0000000000..694f34a446 --- /dev/null +++ b/hw/proxy/monitor.c @@ -0,0 +1,88 @@ +/* + * QEMU monitor command handler for multi-process QEMU + * + * 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"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * 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 OTHER + * 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 "qapi/qapi-types-block-core.h" +#include "qapi/qapi-commands-block-core.h" +#include "monitor/monitor.h" +#include "qemu/option.h" +#include "hmp.h" +#include "hw/boards.h" +#include "hw/proxy/qemu-proxy.h" + +/* + * TODO: Is there a callback where the allocated memory for QMP could be free'd + */ +RemoteProcList *qmp_query_remote(Error **errp) +{ + MachineState *ms = MACHINE(current_machine); + RemoteProcList *proclist, *proc; + GHashTableIter itr; + PCIProxyDev *pdev; + PCIProxyDevClass *k; + DeviceState *d; + char *id; + + proclist = NULL; + + g_hash_table_iter_init(&itr, ms->remote_devs); + + while (g_hash_table_iter_next(&itr, (gpointer *)&id, (gpointer *)&pdev)) { + k = PCI_PROXY_DEV_GET_CLASS(pdev); + d = DEVICE(pdev); + + proc = g_malloc0(sizeof(RemoteProcList)); + proc->next = proclist; + proclist = proc; + proc->value = g_malloc0(sizeof(RemoteProc)); + proc->value->pid = pdev->remote_pid; + proc->value->id = g_strdup(d->id); + proc->value->proc = g_strdup(k->command); + } + + return proclist; +} + +void hmp_info_remote(Monitor *mon, const QDict *qdict) +{ + MachineState *ms = MACHINE(current_machine); + GHashTableIter itr; + PCIProxyDev *pdev; + PCIProxyDevClass *k; + char *id; + + g_hash_table_iter_init(&itr, ms->remote_devs); + + monitor_printf(mon, "%8.8s\t%16.16s\t%16.16s\t%16.16s\n\n", "PID", "RID", + "QEMU ID", "PROCESS NAME"); + + while (g_hash_table_iter_next(&itr, (gpointer *)&id, (gpointer *)&pdev)) { + k = PCI_PROXY_DEV_GET_CLASS(pdev); + + monitor_printf(mon, "%8.8d\t%16.16s\t%16.16s\t%16.16s\n", + pdev->remote_pid, pdev->rid, id, k->command); + } +} diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index c27817f780..b73077940c 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -27,6 +27,7 @@ #include "io/proxy-link.h" #include "hw/proxy/memory-sync.h" +#include "hw/pci/pci.h" #include "qemu/event_notifier.h" #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" diff --git a/qapi/block-core.json b/qapi/block-core.json index 7ccbfff9d0..6a0bfe26a2 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -673,6 +673,23 @@ '*tray_open': 'bool', '*io-status': 'BlockDeviceIoStatus', '*dirty-bitmaps': ['BlockDirtyInfo'] } } +## +# @RemoteProc: +# +# Remote process information. +# +# @id: Device ID +# +# @pid: Linux Process ID +# +# @proc: Process name +# +# Since: 3.0.93 +## +{ 'struct': 'RemoteProc', + 'data': {'id': 'str', 'pid': 'int32', 'proc': 'str' }, + 'if': 'defined(CONFIG_MPQEMU)' } + ## # @BlockMeasureInfo: # @@ -795,6 +812,18 @@ ## { 'command': 'query-block', 'returns': ['BlockInfo'] } +## +# @query-remote: +# +# Get a list of all the remote processes spawned by QEMU. +# +# Returns: a list of @RemoteProc describing each remote process. +# +# Since: 3.0.93 +# +## +{ 'command': 'query-remote', 'returns': ['RemoteProc'], + 'if': 'defined(CONFIG_MPQEMU)' } ## # @BlockDeviceTimedStats: From patchwork Mon Jun 17 18:16:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D5BD14DB for ; Mon, 17 Jun 2019 18:39:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41025289BF for ; Mon, 17 Jun 2019 18:39:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 338FC289C5; Mon, 17 Jun 2019 18:39:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D340289BF for ; Mon, 17 Jun 2019 18:39:54 +0000 (UTC) Received: from localhost ([::1]:51024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwXp-00023g-Be for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:39:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58952) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBW-0005et-Oz for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBS-00024H-0o for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:48 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:55970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBR-0001vy-Lb for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16: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 x5HI9xFx159764; Mon, 17 Jun 2019 18:16:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=kt9k8lGfADW3bbD0lOnFJDXER1tr+LSKD0g4331gr2E=; b=vzY4ZPthEeuszYkSBu4tXJa4fhrW0XQTZA3dtpiESumG5QPY6IHvgXLY8VdfSXJkrCe8 ltgNSQcc0pukOh+DmafpmVYu45MDRiSEYcehSnOnA3w+JazvH+4AeG7urwr7HFQLV3Ho bQPJyj+oZXbxCKBydlCGNeIJQI5/j7mjYFYwMzlt9jgGI+RIVkVJsR6/sp6QrDOJsTJz 5lqHv9ogBlBLGYyAuYnnxDo3wW33SDsFzLJqv4XQno3gW1TxPQ75p/wY+d1+Z59klfo2 9UzGJTTI4dbskPtZJMQUJ0k2BHwVZLnvz5wXeLjjWOF67z38m0BRt/O2hPCfKsFLznMa qA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t4saq7ygq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16: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 x5HIGP9O181124; Mon, 17 Jun 2019 18:16:26 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2t5mgbgb0c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:26 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGQFL014985; Mon, 17 Jun 2019 18:16:26 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:25 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:23 -0700 Message-Id: <20190617181623.30093-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 21/35] multi-process: Extend monitor commands to add a device to 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, dgilbert@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Extend device_add QMP & HMP commands to hotplug device to a remote process Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- hmp-commands.hx | 4 +- hmp.c | 8 ++++ hw/proxy/monitor.c | 93 +++++++++++++++++++++++++++++++++++++++++ include/io/proxy-link.h | 2 + include/monitor/qdev.h | 2 + qdev-monitor.c | 7 ++++ remote/remote-main.c | 48 +++++++++++++++++++++ stubs/monitor.c | 5 +++ 8 files changed, 167 insertions(+), 2 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 9b4035965c..605d18be85 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -712,8 +712,8 @@ ETEXI { .name = "device_add", - .args_type = "device:O", - .params = "driver[,prop=value][,...]", + .args_type = "device:O,rid:s?", + .params = "driver[,prop=value][,...][rid=rid]", .help = "add device, like -device on the command line", .cmd = hmp_device_add, .command_completion = device_add_completion, diff --git a/hmp.c b/hmp.c index 4bb3af748e..ccc95d3feb 100644 --- a/hmp.c +++ b/hmp.c @@ -2164,7 +2164,15 @@ void hmp_device_add(Monitor *mon, const QDict *qdict) { Error *err = NULL; +#ifdef CONFIG_MPQEMU + if (qdict_get_try_str(qdict, "rid")) { + qmp_rdevice_add((QDict *)qdict, NULL, &err); + return; + } +#endif + qmp_device_add((QDict *)qdict, NULL, &err); + hmp_handle_error(mon, &err); } diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c index 694f34a446..400c83c0d5 100644 --- a/hw/proxy/monitor.c +++ b/hw/proxy/monitor.c @@ -23,6 +23,7 @@ */ #include +#include #include "qemu/osdep.h" #include "qapi/qapi-types-block-core.h" @@ -32,6 +33,13 @@ #include "hmp.h" #include "hw/boards.h" #include "hw/proxy/qemu-proxy.h" +#include "qapi/qapi-commands-misc.h" +#include "monitor/qdev.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qjson.h" +#include "qapi/qmp/qstring.h" +#include "qapi/error.h" +#include "io/proxy-link.h" /* * TODO: Is there a callback where the allocated memory for QMP could be free'd @@ -86,3 +94,88 @@ void hmp_info_remote(Monitor *mon, const QDict *qdict) pdev->remote_pid, pdev->rid, id, k->command); } } + +static PCIProxyDev *get_proxy_device(QDict *qdict, const char *opt, + Error **errp) +{ + MachineState *ms = MACHINE(current_machine); + PCIProxyDev *pdev = NULL; + const char *key; + + key = qdict_get_try_str(qdict, opt); + if (!key) { + error_setg(errp, "Please specify %s option", opt); + return NULL; + } + + pdev = (PCIProxyDev *)g_hash_table_lookup(ms->remote_devs, key); + if (!pdev) { + error_setg(errp, + "No remote device by ID %s. Use query-remote command to get remote devices", + key); + } + + return pdev; +} + +static int send_monitor_msg(PCIProxyDev *pdev, proc_cmd_t cmd, size_t size, + uint8_t *data) +{ + ProcMsg msg = {0}; + int wait; + + wait = GET_REMOTE_WAIT; + + msg.cmd = cmd; + msg.bytestream = 1; + msg.size = size; + msg.data2 = data; + msg.num_fds = 1; + msg.fds[0] = wait; + + proxy_proc_send(pdev->proxy_link, &msg); + (void)wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + + /* Indicate success/failure of remote operation */ + return 0; +} + +static void rdevice_add_del(QDict *qdict, proc_cmd_t cmd, Error **errp) +{ + MachineState *ms = MACHINE(current_machine); + PCIProxyDev *pdev = NULL; + const char *id; + QString *json; + int ret; + + pdev = get_proxy_device(qdict, "rid", errp); + if (*errp) { + return; + } + + qdict_del(qdict, "rid"); + + id = qdict_get_str(qdict, "id"); + + json = qobject_to_json(QOBJECT(qdict)); + + ret = send_monitor_msg(pdev, cmd, strlen(qstring_get_str(json)), + (uint8_t *)qstring_get_str(json)); + + qstring_destroy_obj(QOBJECT(json)); + + if (ret) { + return; + } + + if (cmd == DEVICE_ADD) { + (void)g_hash_table_insert(ms->remote_devs, (gpointer)g_strdup(id), + (gpointer)pdev); + } +} + +void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp) +{ + rdevice_add_del(qdict, DEVICE_ADD, errp); +} diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 843ac30e87..07a08a9175 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -60,6 +60,7 @@ typedef struct ProxyLinkState ProxyLinkState; * BAR_READ Reads from PCI BAR region * SET_IRQFD Sets the IRQFD to be used to raise interrupts directly * from remote device + * DEVICE_ADD QMP/HMP command to hotplug device * */ typedef enum { @@ -70,6 +71,7 @@ typedef enum { BAR_WRITE, BAR_READ, SET_IRQFD, + DEVICE_ADD, MAX, } proc_cmd_t; diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index 0ff3331284..e21692677e 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -10,6 +10,8 @@ void hmp_info_qdm(Monitor *mon, const QDict *qdict); void hmp_info_qom_tree(Monitor *mon, const QDict *dict); void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp); +void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp); + int qdev_device_help(QemuOpts *opts); DeviceState *qdev_device_add(QemuOpts *opts, Error **errp); void qdev_set_id(DeviceState *dev, const char *id); diff --git a/qdev-monitor.c b/qdev-monitor.c index 373b9ad445..80d570263f 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -802,6 +802,13 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp) QemuOpts *opts; DeviceState *dev; +#ifdef CONFIG_MPQEMU + if (qdict_get_try_str(qdict, "rid")) { + qmp_rdevice_add(qdict, NULL, errp); + return; + } +#endif + opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err); if (local_err) { error_propagate(errp, local_err); diff --git a/remote/remote-main.c b/remote/remote-main.c index f4ded7afb4..ba39ab6a46 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -48,6 +48,11 @@ #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" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -138,6 +143,44 @@ fail: PUT_REMOTE_WAIT(wait); } +static void process_device_add_msg(ProcMsg *msg) +{ + Error *local_err = NULL; + const char *json = (const char *)msg->data2; + int wait = msg->fds[0]; + QObject *qobj = NULL; + QDict *qdict = NULL; + QemuOpts *opts = NULL; + + qobj = qobject_from_json(json, &local_err); + if (local_err) { + goto fail; + } + + qdict = qobject_to(QDict, qobj); + assert(qdict); + + opts = 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_msg(GIOCondition cond) { ProcMsg *msg = NULL; @@ -189,6 +232,9 @@ static void process_msg(GIOCondition cond) case SET_IRQFD: process_set_irqfd_msg(remote_pci_dev, msg); break; + case DEVICE_ADD: + process_device_add_msg(msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; @@ -213,6 +259,8 @@ int main(int argc, char *argv[]) bdrv_init_with_whitelist(); + qemu_add_opts(&qemu_device_opts); + if (qemu_init_main_loop(&err)) { error_report_err(err); return -EBUSY; diff --git a/stubs/monitor.c b/stubs/monitor.c index f3dc2750cb..a55b674777 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -5,6 +5,7 @@ #include "monitor/monitor.h" #include "qapi/qapi-types-misc.h" #include "qapi/qapi-commands-misc.h" +#include "monitor/qdev.h" __thread Monitor *cur_mon; @@ -46,3 +47,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, { return NULL; } + +void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp) +{ +} From patchwork Mon Jun 17 18:16:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98C4A112C for ; Mon, 17 Jun 2019 18:44:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CD8628820 for ; Mon, 17 Jun 2019 18:44:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80AC6289C9; Mon, 17 Jun 2019 18:44:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE4BF28820 for ; Mon, 17 Jun 2019 18:44:14 +0000 (UTC) Received: from localhost ([::1]:51048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwc2-0006cA-4u for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:44:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58963) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBW-0005ew-Qe for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBS-00025r-VB for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:50 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBS-0001xo-FL for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:46 -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 x5HI8l7F065868; Mon, 17 Jun 2019 18:16:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=phtcguYrmxHbOtradT+KkWmWpDrxCK7VlmMbgNif274=; b=OiDUomOPm440S86UJZcWxiDTTpyojKWdXrdugWlvXRdE4eeno6jDFsVRToT3k5El82kg FdR/iWOe9xMshz8XeIOaigMAkmzNGkEpA8o55BJ8vTLDhl+PPyBpWWSRklZSYXphHGSk qJHtiGPX7S7pCE7y62fodM2lg+ojdFQD4/w6tbVVHZ+L5y+13cmmjJjJF4m74W+Bm4JJ 7tYKG0o+jROcRa1zht0lUS0uVYssKaZ3GBl4riRlrYyOrEDxpfFsTqBTRxeN0KBArtwI vsdbnHek1v52sn/GRqLMDWLCMikKAns3O/rdEUgireIh3sBqrenSJYnsFKTLS2un5cEb /g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2t4rmp00p1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:30 +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 x5HIF6Z2050383; Mon, 17 Jun 2019 18:16:29 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2t5h5t9fsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:29 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGSCw014992; Mon, 17 Jun 2019 18:16:28 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:28 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:26 -0700 Message-Id: <20190617181626.30141-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 22/35] multi-process: Extend monitor commands to remove device from 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, dgilbert@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Extend device_del QMP & HMP commands to hot-unplug device from remote process. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- hmp.c | 9 +++++++++ hw/proxy/monitor.c | 15 ++++++++++++++ include/hw/qdev-core.h | 1 + include/io/proxy-link.h | 2 ++ include/monitor/qdev.h | 1 + qdev-monitor.c | 15 ++++++++++++-- remote/remote-main.c | 45 +++++++++++++++++++++++++++++++++++++++++ stubs/monitor.c | 4 ++++ 8 files changed, 90 insertions(+), 2 deletions(-) diff --git a/hmp.c b/hmp.c index ccc95d3feb..89cdaebfde 100644 --- a/hmp.c +++ b/hmp.c @@ -54,6 +54,7 @@ #include "hw/rdma/rdma.h" #include "migration/snapshot.h" #include "migration/misc.h" +#include "hw/boards.h" #ifdef CONFIG_SPICE #include @@ -2178,9 +2179,17 @@ void hmp_device_add(Monitor *mon, const QDict *qdict) void hmp_device_del(Monitor *mon, const QDict *qdict) { + MachineState *ms = MACHINE(current_machine); const char *id = qdict_get_str(qdict, "id"); Error *err = NULL; +#ifdef CONFIG_MPQEMU + if (g_hash_table_lookup(ms->remote_devs, id)) { + qmp_rdevice_del(id, &err); + return; + } +#endif + qmp_device_del(id, &err); hmp_handle_error(mon, &err); } diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c index 400c83c0d5..c4d0ff1213 100644 --- a/hw/proxy/monitor.c +++ b/hw/proxy/monitor.c @@ -172,6 +172,8 @@ static void rdevice_add_del(QDict *qdict, proc_cmd_t cmd, Error **errp) if (cmd == DEVICE_ADD) { (void)g_hash_table_insert(ms->remote_devs, (gpointer)g_strdup(id), (gpointer)pdev); + } else { + (void)g_hash_table_remove(ms->remote_devs, (gpointer)id); } } @@ -179,3 +181,16 @@ void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp) { rdevice_add_del(qdict, DEVICE_ADD, errp); } + +void qmp_rdevice_del(const char *id, Error **errp) +{ + QDict *qdict = qdict_new(); + + qdict_put_str(qdict, "id", id); + + qdict_put_str(qdict, "rid", id); + + rdevice_add_del(qdict, DEVICE_DEL, errp); + + qobject_unref(qdict); +} diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index 33ed3b8dde..cea42a92ab 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -358,6 +358,7 @@ BusState *qdev_get_parent_bus(DeviceState *dev); /*** BUS API. ***/ DeviceState *qdev_find_recursive(BusState *bus, const char *id); +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); diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 07a08a9175..bf2555c97e 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -61,6 +61,7 @@ typedef struct ProxyLinkState ProxyLinkState; * SET_IRQFD Sets the IRQFD to be used to raise interrupts directly * from remote device * DEVICE_ADD QMP/HMP command to hotplug device + * DEVICE_DEL QMP/HMP command to hot-unplug device * */ typedef enum { @@ -72,6 +73,7 @@ typedef enum { BAR_READ, SET_IRQFD, DEVICE_ADD, + DEVICE_DEL, MAX, } proc_cmd_t; diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index e21692677e..c7642f7c2d 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -11,6 +11,7 @@ void hmp_info_qom_tree(Monitor *mon, const QDict *dict); void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp); void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp); +void qmp_rdevice_del(const char *id, Error **errp); int qdev_device_help(QemuOpts *opts); DeviceState *qdev_device_add(QemuOpts *opts, Error **errp); diff --git a/qdev-monitor.c b/qdev-monitor.c index 80d570263f..744c807b0f 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -34,6 +34,7 @@ #include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "migration/misc.h" +#include "hw/boards.h" /* * Aliases were a bad idea from the start. Let's keep them @@ -827,7 +828,7 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp) object_unref(OBJECT(dev)); } -static DeviceState *find_device_state(const char *id, Error **errp) +DeviceState *find_device_state(const char *id, Error **errp) { Object *obj; @@ -902,7 +903,17 @@ void qdev_unplug(DeviceState *dev, Error **errp) void qmp_device_del(const char *id, Error **errp) { - DeviceState *dev = find_device_state(id, errp); + MachineState *ms = MACHINE(current_machine); + DeviceState *dev; + +#ifdef CONFIG_MPQEMU + if (g_hash_table_lookup(ms->remote_devs, id)) { + qmp_rdevice_del(id, errp); + return; + } +#endif + + dev = find_device_state(id, errp); if (dev != NULL) { qdev_unplug(dev, errp); } diff --git a/remote/remote-main.c b/remote/remote-main.c index ba39ab6a46..c5dc7c0009 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -53,6 +53,7 @@ #include "qemu/option.h" #include "qemu/config-file.h" #include "monitor/qdev.h" +#include "qapi/qmp/qdict.h" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -181,6 +182,47 @@ fail: PUT_REMOTE_WAIT(wait); } +static void process_device_del_msg(ProcMsg *msg) +{ + Error *local_err = NULL; + DeviceState *dev = NULL; + const char *json = (const char *)msg->data2; + int wait = msg->fds[0]; + QObject *qobj = NULL; + QDict *qdict = NULL; + const char *id; + + qobj = qobject_from_json(json, &local_err); + if (local_err) { + goto fail; + } + + qdict = qobject_to(QDict, qobj); + assert(qdict); + + id = qdict_get_try_str(qdict, "id"); + assert(id); + + dev = 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 void process_msg(GIOCondition cond) { ProcMsg *msg = NULL; @@ -235,6 +277,9 @@ static void process_msg(GIOCondition cond) case DEVICE_ADD: process_device_add_msg(msg); break; + case DEVICE_DEL: + process_device_del_msg(msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; diff --git a/stubs/monitor.c b/stubs/monitor.c index a55b674777..ac24eeb5d4 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -51,3 +51,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp) { } + +void qmp_rdevice_del(const char *id, Error **errp) +{ +} From patchwork Mon Jun 17 18:16:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4FE81398 for ; Mon, 17 Jun 2019 18:30:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B98B5288B3 for ; Mon, 17 Jun 2019 18:30:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ADABC288F6; Mon, 17 Jun 2019 18:30:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4847A288B3 for ; Mon, 17 Jun 2019 18:30:34 +0000 (UTC) Received: from localhost ([::1]:50970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwOm-0003TF-3a for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:30:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58949) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBW-0005en-OC for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBS-00025S-Mg for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:48 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57448) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBS-0001ym-AX for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:46 -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 x5HI8kVc065846; Mon, 17 Jun 2019 18:16:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=qHA0XPWNpBUQCEDqLyXVYTH83m+elOu8Ro8OwumTiLs=; b=o6EJ/39CTVnff8SG+xpuzF1gavK09pDx69afZ7YGGL5zNXcEuLJKuMKI8NENCaIj6Gpf r6OBfgc8CzFkDF3KOJ0LzvQ5Mm1VlFCjDiAcutCRK/hSACR18i0k/gub2/Bn6zdxsFeD lj6DZYw68UEU60Nxu8TjSG3H6tKOJXBtYnh1DfkmRhC52en13sSAL3v3ATpdqlWm7QIz D7F7nXawiEjMwtlW/QQLmtRqC5cJMlORYW7Br7pmlHasxsRP3/tW7E6hjINnz+dumEZk O+NPqDQlDkNOpnmR0RBV2kCEeAfshw0gQlAqPvFmWyqHfCmgYGSR5JG5dqyKta2WOt++ kg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2t4rmp00pd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:33 +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 x5HIF5X8050183; Mon, 17 Jun 2019 18:16:32 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2t5h5t9ftb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:32 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGVAf025270; Mon, 17 Jun 2019 18:16:31 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 18:16:31 +0000 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:29 -0700 Message-Id: <20190617181629.30187-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 23/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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 | 38 ++++++++++++++++++++++++++++++++++- include/hw/proxy/qemu-proxy.h | 2 ++ include/io/proxy-link.h | 2 ++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index c691a05dac..1666cc546e 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -51,6 +51,7 @@ #include "sysemu/kvm.h" #include "util/event_notifier-posix.c" #include "hw/boards.h" +#include "include/qemu/log.h" /* * TODO: kvm_vm_ioctl is only available for per-target objects (NEED_CPU_H). @@ -60,6 +61,39 @@ int kvm_vm_ioctl(KVMState *s, int type, ...); static void pci_proxy_dev_realize(PCIDevice *dev, Error **errp); +static void setup_irqfd(PCIProxyDev *dev); + +static void proxy_ready(PCIDevice *dev) +{ + PCIProxyDev *pdev = 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 = PCI_PROXY_DEV(dev); + + qstr = qobject_to_json(QOBJECT(qdict)); + str = qstring_get_str(qstr); + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.data2 = (uint8_t *)str; + msg.cmd = cmd; + msg.bytestream = 1; + msg.size = qstring_get_length(qstr) + 1; + msg.num_fds = 0; + + proxy_proc_send(pdev->proxy_link, &msg); + + return; +} int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp) { @@ -292,7 +326,6 @@ static void init_proxy(PCIDevice *dev, char *command, Error **errp) proxy_link_set_sock(pdev->proxy_link, pdev->rsocket); configure_memory_sync(pdev->sync, pdev->proxy_link); - setup_irqfd(pdev); } static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) @@ -319,6 +352,9 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) dev->init_proxy = init_proxy; dev->sync = REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); + dev->set_remote_opts = set_remote_opts; + dev->proxy_ready = proxy_ready; + } static void send_bar_access_msg(ProxyLinkState *proxy_link, MemoryRegion *mr, diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index b73077940c..4e949f778b 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -29,6 +29,8 @@ #include "hw/proxy/memory-sync.h" #include "hw/pci/pci.h" #include "qemu/event_notifier.h" +#include "hw/pci/pci.h" +#include "block/qdict.h" #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index bf2555c97e..38bd80535a 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -72,6 +72,8 @@ typedef enum { BAR_WRITE, BAR_READ, SET_IRQFD, + DEV_OPTS, + DRIVE_OPTS, DEVICE_ADD, DEVICE_DEL, MAX, From patchwork Mon Jun 17 18:16:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 698E214BB for ; Mon, 17 Jun 2019 18:36:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E85328866 for ; Mon, 17 Jun 2019 18:36:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5261E289B8; Mon, 17 Jun 2019 18:36:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A782F289B9 for ; Mon, 17 Jun 2019 18:36:06 +0000 (UTC) Received: from localhost ([::1]:50996 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwU9-0006uE-Uc for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:36:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58954) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBW-0005eu-P4 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBS-00025A-Jm for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:50 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBS-00022d-08 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:46 -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 x5HI8ku8065840; Mon, 17 Jun 2019 18:16:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=scmLrVP4xYg0Tw9BE11vcEOCdPW9WepFgHJ0GpUVuMU=; b=rgkFdnnwvYbteX7UK6QxopcUysjNIZHBkg1sq3Y/HL7pNSQXHPJst+zmwRn58PuTgsFd qur8mTFdZh6M7QV6TBByKrB7u4bRRz5AuRZT/O11bGPDeAESz3bZH0xXDYFA1VfttiIR 36JikwrCOXonR6j7wdhph6sVwolAcxnn/5rbY3WmTeXWlucqNpQugKicqzKpl554lwV5 0IVLpe6oEjKKgYAJlrKHCA9UC09NA/JRC8v1YCryz31W2G8W0153B4pTExcWWhHPmBGZ Bgv3x4JmHKuN3oA//iGnldU3/japw4kPju0nCol8rwMukP+auU9cI7qewV5nGJDdhvFA yQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2t4rmp00pw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:41 +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 x5HIGPUk181160; Mon, 17 Jun 2019 18:16:41 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t5mgbgb5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:41 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGeYL025311; Mon, 17 Jun 2019 18:16:40 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:39 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:31 -0700 Message-Id: <20190617181631.30233-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 24/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, imammedo@redhat.com, liran.alon@oracle.com, stefanha@redhat.com, marcandre.lureau@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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. Changes in v2: - parse socket and command suboptions of drive/device commands; Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- include/hw/proxy/qemu-proxy.h | 7 ++ include/monitor/qdev.h | 5 + qdev-monitor.c | 166 ++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+) diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 4e949f778b..a4c6989248 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -85,6 +85,13 @@ typedef struct PCIProxyDevClass { int remote_spawn(PCIProxyDev *pdev, const char *command, Error **errp); +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 addr, uint64_t val, unsigned size, bool memory); diff --git a/include/monitor/qdev.h b/include/monitor/qdev.h index c7642f7c2d..965c58d127 100644 --- a/include/monitor/qdev.h +++ b/include/monitor/qdev.h @@ -2,6 +2,7 @@ #define MONITOR_QDEV_H #include "hw/qdev-core.h" +#include "hw/proxy/qemu-proxy.h" /*** monitor commands ***/ @@ -12,8 +13,12 @@ void qmp_device_add(QDict *qdict, QObject **ret_data, Error **errp); void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp); void qmp_rdevice_del(const char *id, Error **errp); +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 *command, + int rsocket, bool managed, Error **errp); DeviceState *qdev_device_add(QemuOpts *opts, Error **errp); void qdev_set_id(DeviceState *dev, const char *id); diff --git a/qdev-monitor.c b/qdev-monitor.c index 744c807b0f..596d01f49a 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -35,6 +35,16 @@ #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" /* * Aliases were a bad idea from the start. Let's keep them @@ -47,6 +57,8 @@ typedef struct QDevAlias uint32_t arch_mask; } QDevAlias; +proxy_dev_list_t proxy_dev_list; +QemuMutex proxy_list_lock; /* Please keep this table sorted by typename. */ static const QDevAlias qdev_alias_table[] = { { "e1000", "e1000-82540em" }, @@ -562,6 +574,160 @@ void qdev_set_id(DeviceState *dev, const char *id) } } +#if defined(CONFIG_MPQEMU) +PCIProxyDev *get_proxy_object(const char *rid); +PCIProxyDev *get_proxy_object(const char *rid) +{ + PCIProxyDev *entry; + + qemu_mutex_lock(&proxy_list_lock); + QLIST_FOREACH(entry, &proxy_dev_list.devices, next) { + if (strncmp(entry->rid, rid, strlen(entry->rid)) == 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 *command, + int rsocket, bool managed, Error **errp) +{ + DeviceState *ds; + PCIProxyDev *pdev; + QemuOpts *proxy_opts; + const char *proxy_type; + Error *local_err = NULL; + QDict *qdict; + const char *str; + + pdev = get_proxy_object(rid); + if (pdev) { + return DEVICE(pdev); + } + + if (strlen(rid) > MAX_RID_LENGTH) { + error_setg(errp, "rid %s is too long.", rid); + return NULL; + } + + proxy_opts = qemu_opts_create(&qemu_device_opts, NULL, 0, + errp); + + /* TODO: remove hardcoded type and add approptiate type identification. */ + proxy_type = TYPE_PROXY_LSI53C895A; + + qemu_opts_set_id(proxy_opts, (char *)rid); + qemu_opt_set(proxy_opts, "driver", proxy_type, &local_err); + + qdict = qemu_opts_to_qdict(proxy_opts, NULL); + str = qstring_get_str(qobject_to_json(QOBJECT(qdict))); + + ds = 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 = PCI_PROXY_DEV(ds); + if (!pdev) { + error_setg(errp, "qdev_device_add failed."); + qemu_opts_del(proxy_opts); + return NULL; + } + pdev->rid = g_strdup(rid); + pdev->rsocket = managed ? rsocket : -1; + pdev->managed = managed; + pdev->init_proxy(PCI_DEVICE(ds), command, 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 = NULL; + DeviceState *dev; + const char *rid, *rsocket = NULL, *command = NULL; + QDict *qdict_new; + + if (!proxy_list_lock.initialized) { + QLIST_INIT(&proxy_dev_list.devices); + qemu_mutex_init(&proxy_list_lock); + } + + rid = qemu_opt_get(opts, "rid"); + if (!rid) { + error_setg(errp, "rdevice option needs rid specified."); + return NULL; + } + + rsocket = 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 support? + */ + command = qemu_opt_get(opts, "command"); + if (!rsocket && !command) { + error_setg(errp, "rdevice option needs socket or command specified."); + return NULL; + } + dev = qdev_proxy_add(rid, qemu_opt_get(opts, "id"), (char *)command, + rsocket ? atoi(rsocket) : -1, rsocket ? true : false, errp); + if (!dev) { + error_setg(errp, "qdev_proxy_add error."); + return NULL; + } + + qdict_new = qemu_opts_to_qdict(opts, NULL); + + if (!qdict_new) { + error_setg(errp, "Could not parse rdevice options."); + return NULL; + } + + pdev = PCI_PROXY_DEV(dev); + if (!pdev->set_remote_opts) { + /* TODO: destroy proxy? */ + error_setg(errp, "set_remote_opts not set."); + return NULL; + } else { + 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; From patchwork Mon Jun 17 18:16:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16FF6112C for ; Mon, 17 Jun 2019 18:49:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B9062858E for ; Mon, 17 Jun 2019 18:49:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3E32289D3; Mon, 17 Jun 2019 18:49:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 782912858E for ; Mon, 17 Jun 2019 18:49:33 +0000 (UTC) Received: from localhost ([::1]:51106 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwhA-0001t5-Bw for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:49:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59117) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBc-0005kZ-SV for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBb-0002CI-2P for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:56 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43586) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBa-00024R-L2 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:54 -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 x5HI8v4E149300; Mon, 17 Jun 2019 18:16:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=3uLBtALvohcNLxi6toagSE1sKXSECqfCo0r/AsNw64g=; b=Q04EoOR5uOrcTqbaYJQdhaik68lMKyvD+wRIYPh1qrG3JbVH6/rQF1hAqS1tapqVcx31 Lu2lvLB07cRBsm/jD0RJ6O+JrBrvYERBxiLmNpt1xKHrUL2/PX0a3AiH5d3GC2tr4tJl ov2L4X7jfw8SbJPF+batRwB/Z8qY7D1lSDOsxJGeNaOWWYtaUUQ8sYJMIPwp7DLEcOho PYZxAIBuVRADZlxNWv/jB2GVcB/syk1qOczHbuXc58cAMSJgHVt2w7wuRkiv5D/YH0u3 fYzhwYzbPCAT6XCMj0pgPYcoZTCh3k1ZTbZ/WQ4CeY/Fc/mPVfEVj2euxIgSS8xhAZJh ag== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2t4r3tg308-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:45 +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 x5HIGP9W181124; Mon, 17 Jun 2019 18:16:44 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t5mgbgb6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:44 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGhwr025332; Mon, 17 Jun 2019 18:16:43 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:42 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:40 -0700 Message-Id: <20190617181640.30279-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 25/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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 --- Changes in v2: - for new command line suboptions with libvirtd support, clean the options before creating drives/devices. - use default pci bus/address for now. --- remote/remote-main.c | 140 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/remote/remote-main.c b/remote/remote-main.c index c5dc7c0009..8db2f36b90 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -54,6 +54,15 @@ #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" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -223,6 +232,121 @@ fail: PUT_REMOTE_WAIT(wait); } +static int init_drive(QDict *rqdict, Error **errp) +{ + QemuOpts *opts; + Error *local_error = NULL; + + if (rqdict != NULL && qdict_size(rqdict) > 0) { + opts = 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) == 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 = NULL; + int rc = -EINVAL; + + if (!msg->data2) { + return rc; + } + + qstr = qstring_from_str((char *)msg->data2); + obj = qobject_from_json(qstring_get_str(qstr), &local_error); + if (!obj) { + error_propagate(errp, local_error); + return rc; + } + + qdict = 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 = NULL; + int rc = -EINVAL; + Error *local_error = NULL; + + if (!msg->data2) { + return rc; + } + + qstr = qstring_from_str((char *)msg->data2); + obj = qobject_from_json(qstring_get_str(qstr), &local_error); + if (!obj) { + error_setg(errp, "Could not get object!"); + return rc; + } + + qdict = qobject_to(QDict, obj); + if (!qdict) { + return rc; + } + + g_assert(qdict_size(qdict) > 1); + + opts = 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 = 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 = PCI_DEVICE(dev); + } + qemu_opts_del(opts); + + return 0; +} + static void process_msg(GIOCondition cond) { ProcMsg *msg = NULL; @@ -268,11 +392,27 @@ static void process_msg(GIOCondition cond) */ 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); From patchwork Mon Jun 17 18:16:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55197112C for ; Mon, 17 Jun 2019 18:44:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49756286DA for ; Mon, 17 Jun 2019 18:44:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E161289BA; Mon, 17 Jun 2019 18:44:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E03E7286DA for ; Mon, 17 Jun 2019 18:44:36 +0000 (UTC) Received: from localhost ([::1]:51052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwcO-000795-8p for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:44:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59080) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBc-0005jN-17 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBa-0002Bi-OX for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:55 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBY-00026g-Kg for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16: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 x5HI96fL066293; Mon, 17 Jun 2019 18:16:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=fzWDbqWeYkychPkQmnwoxt/Uk7kD+2/Z9WON2aFL7qw=; b=skC2ZNvdkn+cyfxlfXSRQ5rexBnXNJp94uSqYDePEWBHw6meSd0/6DJeJbzMZwf5QkMI zj5NmMGi1TWuOK/avCW33FpT17EhLIAXL5N97lDKIhRSw96iCiNlgwVI5YqCZJoBXvbf UsAk8dnGjh1+aL0iy9cRaEHPOTdvpBIJGmTdvd80na840VabeD0QgPYmpHRj12DI6bao p3UViyR3ppvdASf6mdwscPEJe1Q5vYdFSJXttNFwn1X+6e27N6zHYERLe5GQWoBo9Ez6 GM+u9KRhjuipuJOvZ8tO8KuN/Sid+5pHXixWT6jNmmqONe2YoibDg1+IW5uBGZl+50q4 nw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2t4rmp00qa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16: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 x5HIF56o050154; Mon, 17 Jun 2019 18:16:46 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2t5h5t9fyg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:46 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGjlU025381; Mon, 17 Jun 2019 18:16:45 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:45 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:43 -0700 Message-Id: <20190617181643.30325-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 26/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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 8db2f36b90..5c26339ed7 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" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -439,6 +440,7 @@ finalize_loop: int main(int argc, char *argv[]) { Error *err = NULL; + int fd = -1; module_call_init(MODULE_INIT_QOM); @@ -463,7 +465,13 @@ int main(int argc, char *argv[]) return -1; } - proxy_link_set_sock(proxy_link, STDIN_FILENO); + fd = qemu_parse_fd(argv[1]); + if (fd == -1) { + printf("Failed to parse fd for remote process.\n"); + return -EINVAL; + } + + proxy_link_set_sock(proxy_link, fd); proxy_link_set_callback(proxy_link, process_msg); start_handler(proxy_link); From patchwork Mon Jun 17 18:16:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000199 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E012814B6 for ; Mon, 17 Jun 2019 18:50:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0694286B0 for ; Mon, 17 Jun 2019 18:50:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C45C6286F6; Mon, 17 Jun 2019 18:50:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 708382852A for ; Mon, 17 Jun 2019 18:50:45 +0000 (UTC) Received: from localhost ([::1]:51110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwiK-0003Kv-JI for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:50:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59109) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBc-0005kI-P4 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBb-0002CQ-4W for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:56 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:43626) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBa-00027T-Pb for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:55 -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 x5HI8pLO149263; Mon, 17 Jun 2019 18:16:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=LzNHre/dMqP+ulT94D53LrSVfQM6ghTZ76CN8SCm75g=; b=dOin0zfyVRK/MPR5PBCF6MbPjYutewOqRVdhLzbWJ2QCHPDo2pIr9JJ/LZhbtTMbHm8o b+OrtrJarLYtiVBoC+yFU9OijI9pFgpHElBXUy5XTSc+3yQsdBwFdOLpoIWfFmj2osiB kEocWFIaB7PxKm3xYWxHp6NHW3zS8PcFgtORcQ+Puee/XL3s7BqCjf65Pc5iYR3ZrV7U JEc5xeLsGlkkUBAksS1Qf+e19VdUueEbxMOrSaxUW3rQnei/USXO7ONN6o+LT/rJU+l+ XXpb3uWGtX/FLcIuf8edfdLEfd6R1AUcltpzEZfp8ppa61yuuKYG1mdH3+e4WWcXsd4D Pg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 2t4r3tg30j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:49 +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 x5HIG86K188001; Mon, 17 Jun 2019 18:16:48 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2t59gdcd6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:48 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIGlK1028429; Mon, 17 Jun 2019 18:16:47 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:47 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:45 -0700 Message-Id: <20190617181645.30370-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [RFC PATCH v2 27/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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 5c26339ed7..c1362be93e 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -67,6 +67,7 @@ static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; +bool create_done; static void process_config_write(ProcMsg *msg) { @@ -369,21 +370,31 @@ static void process_msg(GIOCondition cond) 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) qemu_mutex_lock_iothread(); qemu_run_machine_init_done_notifiers(); qemu_mutex_unlock_iothread(); - + create_done = true; break; case DRIVE_OPTS: if (setup_drive(msg, &err)) { From patchwork Mon Jun 17 18:16:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000197 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B449112C for ; Mon, 17 Jun 2019 18:50:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FC6328538 for ; Mon, 17 Jun 2019 18:50:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1400528585; Mon, 17 Jun 2019 18:50:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F1DED28606 for ; Mon, 17 Jun 2019 18:50:04 +0000 (UTC) Received: from localhost ([::1]:51108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwhg-0002Sk-8p for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:50:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59131) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBd-0005lk-9d for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBb-0002CV-6b for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:57 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBa-0002AR-Qv for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:55 -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 x5HI8kdq065855; Mon, 17 Jun 2019 18:16:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=jmY+mxEc9E6wa+00MVvwZiziNDZ83zIQadXW1VBFKCk=; b=RF8axvmM+vYVFzZnx2HmFBGsNnaObm4j2j5iBTWw0wwF+n812Jr0eHso3lO2l10b0FET MypPsVKc3XcYkj0GgPj/HsihBsf6SZjstJm8TYt/J8czoJnUOYnyEQKPJVDZr66ebk8Q RWAFYtJDk7a7rXSKGn+pXIZuMS4LsyP4cQYsZMmVGBNSe03L/jP9bSDcxGl1LAAujEoa HA400+rhHmKyqvKaRWjMzKyci4V+waon3bqTrzrVyUGCU5CJx/O5ALyQWQmBWshsaB9m 7KgZVgmGdSjRUBRKExLPWpVsKp4U30F8UaXeOlQGDtqPDNBF4ojLGn/ZYA4FOPy9MqZm 4w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2t4rmp00qq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:52 +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 x5HIGR6f181417; Mon, 17 Jun 2019 18:16:51 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t5mgbgb8b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:51 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIGoEY032468; Mon, 17 Jun 2019 18:16:50 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:50 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:48 -0700 Message-Id: <20190617181648.30416-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 28/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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 --- Changes in 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 | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/vl.c b/vl.c index ff5dfb6fbc..de16dbcbc9 100644 --- a/vl.c +++ b/vl.c @@ -30,6 +30,11 @@ #include "qemu/help_option.h" #include "qemu/uuid.h" #include "sysemu/seccomp.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" #ifdef CONFIG_SDL #if defined(__APPLE__) || defined(main) @@ -1156,11 +1161,38 @@ static int cleanup_add_fd(void *opaque, QemuOpts *opts, Error **errp) #define MTD_OPTS "" #define SD_OPTS "" +#if defined(CONFIG_MPQEMU) +static int rdrive_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + + dev = 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 = opaque; + const char *remote; - return drive_new(opts, *block_default_type, errp) == NULL; + remote = 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; } static int drive_enable_snapshot(void *opaque, QemuOpts *opts, Error **errp) @@ -2333,9 +2365,31 @@ static int device_help_func(void *opaque, QemuOpts *opts, Error **errp) return qdev_device_help(opts); } +#if defined(CONFIG_MPQEMU) +static int rdevice_init_func(void *opaque, QemuOpts *opts, Error **errp) +{ + DeviceState *dev; + + dev = 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; + const char *remote; + + remote = qemu_opt_get(opts, "remote"); + if (remote) { + /* This will be a remote process */ + return rdevice_init_func(opaque, opts, errp); + } dev = qdev_device_add(opts, errp); if (!dev) { @@ -4498,6 +4552,15 @@ int main(int argc, char **argv, char **envp) /* Check if IGD GFX passthrough. */ igd_gfx_passthru(); + pass = 1; + /* + * Parse the list for remote drives here as we launch PCIProxyDev here and + * need PCI host initialized. As a TODO: could defer init of PCIProxyDev instead. + */ + if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func, + &machine_class->block_default_type, &error_fatal)) { + exit(0); + } /* init generic devices */ rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE); qemu_opts_foreach(qemu_find_opts("device"), @@ -4555,10 +4618,13 @@ int main(int argc, char **argv, char **envp) qemu_register_reset(qbus_reset_all_fn, sysbus_get_default()); qemu_run_machine_init_done_notifiers(); +#if defined(CONFIG_MPQEMU) + qdev_proxy_fire(); if (rom_check_and_register_reset() != 0) { error_report("rom check and register reset failed"); exit(1); } +#endif replay_start(); From patchwork Mon Jun 17 18:16:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D8723924 for ; Mon, 17 Jun 2019 18:52:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBD32289D4 for ; Mon, 17 Jun 2019 18:52:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFD2B289CF; Mon, 17 Jun 2019 18:52:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 47E5428538 for ; Mon, 17 Jun 2019 18:52:18 +0000 (UTC) Received: from localhost ([::1]:51130 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwjp-0005nP-9E for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:52:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59140) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBd-0005n3-RJ for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBb-0002DN-Pn for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16:57 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56364) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBb-0002Bs-EE for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:16: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 x5HI8mXw159114; Mon, 17 Jun 2019 18:16:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=R5l+VuYvr/6NBbItTEbfPVYS+QRH6VWHAFYxJS+dhpk=; b=3pOMMzA7VvdC9Pb5jj2aeH5nmpLtIfRABSH9gxaUMTgN4O/R1facniMM2zkPAdS62Csw EVMPBeiJ7vXMoU96JbpImVK9Ar0Cyhv9NyERHGFFw5JhuJiQB6+n/YhPJb/ETPVB//at 6/SWSLDmhswjg8yjikpr8hlJvSu/m9kdnBPhRw2+stnY9W0QeCoL5vmQlACcUPtwYcnh S7h0kvElxjmuG9CEXBx/BnuSIDZgotwe1FTqIuwf/L8bQfyGXwkJvqRShpKvOgt4DrIn i7Jnj3ktFDsjTSEoJgEbRkX/Gk5qabCDK6Xi1hXaS3tBaxesYsZyxbgphOL6TqKTrSnE 4w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2t4saq7yjs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:54 +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 x5HIF9mq118034; Mon, 17 Jun 2019 18:16:53 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2t5cpdkfbr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:53 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIGquJ028456; Mon, 17 Jun 2019 18:16:52 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:52 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:50 -0700 Message-Id: <20190617181650.30461-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 29/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, berrange@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Elena Ufimtseva Add a signal handler for launched remote processes and set up the heartbit 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 1666cc546e..4ee7521987 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -60,14 +60,96 @@ */ int kvm_vm_ioctl(KVMState *s, int type, ...); +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 = GET_REMOTE_WAIT; + msg->num_fds = 1; + msg->fds[0] = wait; + } + + proxy_proc_send(entry->proxy_link, msg); + if (need_reply) { + pid = (uint32_t)wait_for_remote(wait); + PUT_REMOTE_WAIT(wait); + /* TODO: Add proper handling. */ + if (pid) { + need_reply = 0; + } + } + } +} + +#define NOP_INTERVAL 1000000 + +static void remote_ping(void *opaque) +{ + ProcMsg msg; + + memset(&msg, 0, sizeof(ProcMsg)); + + msg.num_fds = 0; + msg.cmd = PROXY_PING; + msg.bytestream = 0; + msg.size = 0; + + broadcast_msg(&msg, true); + timer_mod(hb_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NOP_INTERVAL); + +} + +void start_heartbeat_timer(void) +{ + hb_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, + remote_ping, + &proxy_dev_list); + timer_mod(hb_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + NOP_INTERVAL); + +} + +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 = childsig_handler; + sa_sigterm.sa_flags = SA_SIGINFO | SA_NOCLDWAIT | SA_NOCLDSTOP; + sigaction(SIGCHLD, &sa_sigterm, NULL); +} static void proxy_ready(PCIDevice *dev) { PCIProxyDev *pdev = PCI_PROXY_DEV(dev); setup_irqfd(pdev); + set_sigchld_handler(); + start_heartbeat_timer(); } static void set_remote_opts(PCIDevice *dev, QDict *qdict, unsigned int cmd) @@ -228,6 +310,7 @@ static void pci_proxy_dev_class_init(ObjectClass *klass, void *data) PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->realize = pci_proxy_dev_realize; + k->exit = pci_dev_exit; k->config_read = pci_proxy_read_config; k->config_write = pci_proxy_write_config; } @@ -357,6 +440,24 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) } +static void pci_dev_exit(PCIDevice *pdev) +{ + PCIProxyDev *entry, *sentry; + PCIProxyDev *dev = PCI_PROXY_DEV(pdev); + + stop_heartbeat_timer(); + + QLIST_FOREACH_SAFE(entry, &proxy_dev_list.devices, next, sentry) { + if (entry->remote_pid == dev->remote_pid) { + QLIST_REMOVE(entry, next); + } + } + + if (!QLIST_EMPTY(&proxy_dev_list.devices)) { + start_heartbeat_timer(); + } +} + static void send_bar_access_msg(ProxyLinkState *proxy_link, 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 38bd80535a..2ba3e614f0 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -76,6 +76,7 @@ typedef enum { DRIVE_OPTS, DEVICE_ADD, DEVICE_DEL, + PROXY_PING, MAX, } proc_cmd_t; From patchwork Mon Jun 17 18:16:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7427614DB for ; Mon, 17 Jun 2019 19:04:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A0922889C for ; Mon, 17 Jun 2019 19:04:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67F1B289DA; Mon, 17 Jun 2019 19:04:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 11749288B8 for ; Mon, 17 Jun 2019 19:04:46 +0000 (UTC) Received: from localhost ([::1]:51258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwvt-0000eR-Hd for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 15:04:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59651) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwDk-0007VK-6t for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:19:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwDi-0003LG-31 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:19:08 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58088) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwDe-0003Ga-6k for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:19:04 -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 x5HI8kqW159089; Mon, 17 Jun 2019 18:18:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=9UgWmtvvAV/ZZCrYFl6U+Qd9jb1Xm7JEF6cA8cbvnzw=; b=2Zz/+LHaYm7wZks12HQ5QRKhV9ueWCDRaOHcs5MlUa8orfAxGdbw/puu2n7iYp1l8ssE bPX6O6DziDgtUDFLdLuDY9f6m3jUlFiqbJIHDmbDv9N1lofYKG6y98XkYlCmJhOI7o2S mdOEPrMG7OHwupV5bF+oWFwjywIFS3dFRa4EQEBLOokLnaQvKoc9PVtImEorx84mjdjb 9noQv2VF0D6KWbl0UG3sPMHj5HfXJayegaHOcElgEOP+107OavOPWyKBauDusLmnJRAx yk2NwHuJjJLzKWSugpnj2e5thltJzxoh7ZnAZiuT74zo9bWWb9yKJAtFMkFKO/Bubnl7 Cg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t4saq7yu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:18: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 x5HIGPCx181193; Mon, 17 Jun 2019 18:16:56 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t5mgbgbaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:56 +0000 Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIGtmZ032583; Mon, 17 Jun 2019 18:16:55 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:54 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:52 -0700 Message-Id: <20190617181653.30506-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 30/35] multi-process: handle heartbit 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: 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 c1362be93e..43134762bc 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -353,6 +353,7 @@ static void process_msg(GIOCondition cond) { ProcMsg *msg = NULL; Error *err = NULL; + int wait; if ((cond & G_IO_HUP) || (cond & G_IO_ERR)) { error_setg(&err, "socket closed, cond is %d", cond); @@ -432,6 +433,11 @@ static void process_msg(GIOCondition cond) case DEVICE_DEL: process_device_del_msg(msg); break; + case PROXY_PING: + wait = msg->fds[0]; + notify_proxy(wait, (uint32_t)getpid()); + PUT_REMOTE_WAIT(wait); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; From patchwork Mon Jun 17 18:16:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFA84112C for ; Mon, 17 Jun 2019 18:37:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F2B286F6 for ; Mon, 17 Jun 2019 18:37:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A83DE289B9; Mon, 17 Jun 2019 18:37:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1D4CB286F6 for ; Mon, 17 Jun 2019 18:37:59 +0000 (UTC) Received: from localhost ([::1]:51010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwVy-0000Kt-Et for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:37:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59179) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwBj-0005sA-PT for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBh-0002JS-QO for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:03 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56446) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBh-0002HB-02 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:01 -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 x5HI8uWC159143; Mon, 17 Jun 2019 18:16:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=luvCTnUgcQuSR2sA80lgp+w2naBhphhsCAlzxkjYxZo=; b=a/PHizzktPgDOWTbyoHmtW8iILBSe34hhJQKEI9HY3sEtU0AHnXYcM6myKR/aORnwTne f/OV9AUK8Nitf+t+Szph/gmpwQqZUn1Utpzny5Or0S9jHvZk5FBzxhwTVeO8pWXNg5UJ 7lXTOmatmmEHwDzMrGgCjRPiYqf4if9mDLuNLJ0Iya9a8HddUYZyIykmY6fMJ9E2Yg9k OX2PtVm8H/FNvN9PL9iiFWGZhLMaguxpBPDlqNx2AQXZenrOXpH+UfnLmBdhyAimhokq IWxw1M7WQKdMFj6qv4CddE5P3ntSJSIN4uCkGdW10j6uT+L0UTBfgQkRWb8n3J96+v62 aA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2t4saq7yk5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:59 +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 x5HIF5D0050134; Mon, 17 Jun 2019 18:16:58 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2t5h5t9g38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:16:58 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIGv7P015218; Mon, 17 Jun 2019 18:16:57 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:16:57 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:55 -0700 Message-Id: <20190617181655.30551-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 31/35] multi-process: Extend drive_add to add drive to 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, dgilbert@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, berrange@redhat.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Extend drive_add HMP command to hot-plug drive to a remote device. Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva --- device-hotplug.c | 7 +++++++ hmp-commands.hx | 5 +++-- hw/proxy/monitor.c | 35 +++++++++++++++++++++++++++++++++++ include/io/proxy-link.h | 2 ++ include/sysemu/sysemu.h | 1 + remote/machine.c | 8 ++++++++ remote/remote-main.c | 31 +++++++++++++++++++++++++++++++ 7 files changed, 87 insertions(+), 2 deletions(-) diff --git a/device-hotplug.c b/device-hotplug.c index 6153259d71..094702ff3e 100644 --- a/device-hotplug.c +++ b/device-hotplug.c @@ -63,6 +63,13 @@ void hmp_drive_add(Monitor *mon, const QDict *qdict) const char *opts = qdict_get_str(qdict, "opts"); bool node = qdict_get_try_bool(qdict, "node", false); +#ifdef CONFIG_MPQEMU + if (qdict_get_try_str(qdict, "rid")) { + hmp_rdrive_add(mon, qdict); + return; + } +#endif + if (node) { hmp_drive_add_node(mon, opts); return; diff --git a/hmp-commands.hx b/hmp-commands.hx index 605d18be85..2757b07ecf 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1341,12 +1341,13 @@ ETEXI { .name = "drive_add", - .args_type = "node:-n,pci_addr:s,opts:s", + .args_type = "node:-n,pci_addr:s,opts:s,rid:s?", .params = "[-n] [[:]:]\n" "[file=file][,if=type][,bus=n]\n" "[,unit=m][,media=d][,index=i]\n" "[,snapshot=on|off][,cache=on|off]\n" - "[,readonly=on|off][,copy-on-read=on|off]", + "[,readonly=on|off][,copy-on-read=on|off]\n", + "[rid=rid]", .help = "add drive to PCI storage controller", .cmd = hmp_drive_add, }, diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c index c4d0ff1213..e3f368aa94 100644 --- a/hw/proxy/monitor.c +++ b/hw/proxy/monitor.c @@ -40,6 +40,7 @@ #include "qapi/qmp/qstring.h" #include "qapi/error.h" #include "io/proxy-link.h" +#include "sysemu/sysemu.h" /* * TODO: Is there a callback where the allocated memory for QMP could be free'd @@ -194,3 +195,37 @@ void qmp_rdevice_del(const char *id, Error **errp) qobject_unref(qdict); } + +void hmp_rdrive_add(Monitor *mon, const QDict *qdict) +{ + MachineState *ms = MACHINE(current_machine); + Error *local_err = NULL; + PCIProxyDev *pdev = NULL; + const char *id, *optstr; + QemuOpts *opts; + char *data; + int ret; + + pdev = get_proxy_device((QDict *)qdict, "rid", &local_err); + if (local_err) { + monitor_printf(mon, "rdrive_add error: %s\n", + error_get_pretty(local_err)); + error_free(local_err); + return; + } + + optstr = qdict_get_str(qdict, "opts"); + opts = drive_def(optstr); + + id = g_strdup(qemu_opts_id(opts)); + data = g_strdup(optstr); + + ret = send_monitor_msg(pdev, DRIVE_ADD, strlen(data), (uint8_t *)data); + + if (!ret) { + (void)g_hash_table_insert(ms->remote_devs, (gpointer)g_strdup(id), + (gpointer)pdev); + } + + g_free(data); +} diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index 2ba3e614f0..e102bcc8f5 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -62,6 +62,7 @@ typedef struct ProxyLinkState ProxyLinkState; * from remote device * DEVICE_ADD QMP/HMP command to hotplug device * DEVICE_DEL QMP/HMP command to hot-unplug device + * DRIVE_ADD HMP command to hotplug drive * */ typedef enum { @@ -76,6 +77,7 @@ typedef enum { DRIVE_OPTS, DEVICE_ADD, DEVICE_DEL, + DRIVE_ADD, PROXY_PING, MAX, } proc_cmd_t; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 5f133cae83..be2c533b9a 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -138,6 +138,7 @@ extern unsigned int nb_prom_envs; /* generic hotplug */ void hmp_drive_add(Monitor *mon, const QDict *qdict); +void hmp_rdrive_add(Monitor *mon, const QDict *qdict); /* pcie aer error injection */ void hmp_pcie_aer_inject_error(Monitor *mon, const QDict *qdict); diff --git a/remote/machine.c b/remote/machine.c index 5b03167dd5..3c9a53010e 100644 --- a/remote/machine.c +++ b/remote/machine.c @@ -74,6 +74,8 @@ static void remote_machine_init(Object *obj) MemoryRegion *system_memory, *system_io, *pci_memory; PCIHostState *pci_host; PCIDevice *pci_dev; + MachineState *ms; + MachineClass *mc; Error *error_abort = NULL; @@ -116,6 +118,12 @@ static void remote_machine_init(Object *obj) pci_bus_irqs(pci_host->bus, remote_iohub_set_irq, remote_iohub_map_irq, s->iohub, REMOTE_IOHUB_NB_PIRQS); + + ms = MACHINE(s); + + mc = MACHINE_GET_CLASS(ms); + + mc->block_default_type = IF_IDE; } static const TypeInfo remote_machine = { diff --git a/remote/remote-main.c b/remote/remote-main.c index 43134762bc..860b5e30f9 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -234,6 +234,29 @@ fail: PUT_REMOTE_WAIT(wait); } +static void process_drive_add_msg(ProcMsg *msg) +{ + Error *local_err = NULL; + const char *optstr = (const char *)msg->data2; + int wait = msg->fds[0]; + QemuOpts *opts; + MachineClass *mc; + + opts = drive_def(optstr); + assert(opts); + + mc = MACHINE_GET_CLASS(current_machine); + (void)drive_new(opts, mc->block_default_type, &local_err); + + if (local_err) { + error_report_err(local_err); + } + + notify_proxy(wait, 1); + + PUT_REMOTE_WAIT(wait); +} + static int init_drive(QDict *rqdict, Error **errp) { QemuOpts *opts; @@ -433,6 +456,9 @@ static void process_msg(GIOCondition cond) case DEVICE_DEL: process_device_del_msg(msg); break; + case DRIVE_ADD: + process_drive_add_msg(msg); + break; case PROXY_PING: wait = msg->fds[0]; notify_proxy(wait, (uint32_t)getpid()); @@ -464,6 +490,11 @@ int main(int argc, char *argv[]) bdrv_init_with_whitelist(); 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); if (qemu_init_main_loop(&err)) { error_report_err(err); From patchwork Mon Jun 17 18:16:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D118E112C for ; Mon, 17 Jun 2019 18:42:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6BD128538 for ; Mon, 17 Jun 2019 18:42:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B20AA289B8; Mon, 17 Jun 2019 18:42:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 14CB2289BA for ; Mon, 17 Jun 2019 18:42:40 +0000 (UTC) Received: from localhost ([::1]:51034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwaV-0004l6-Bm for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:42:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59266) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwC0-00061z-Vc for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBz-0002RF-B7 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:20 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:57840) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBx-0002Ly-76 for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:19 -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 x5HI8kF5065852; Mon, 17 Jun 2019 18:17:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=c/oRzO5GwQrsLOuRCTKoMevsHyRTNOaXCBnIeWLFI0M=; b=3cdDLhHRm/e/EtTmHSPcwpHbZoUKFGM0KFbpGm6bpTaagxhdehNe2onYGk3tY8P+IMK8 2NvorOuP4GEWmixb0VWB73aCE6FFCpYQryAs75O+21O0JHh8qxA/foA6GWmh+vIYXV2Y /ga8VygTLnBv/M7ACAsn5ltY5+cJfClo87SHkAjCBlyE4dEOY6MPXtOgx7hv51Jftgzq qnhOSZQY4uDI4X3W805ZWLn8+YNoc/vxg68TOsHAW5RNNkhzn8y+2Zw6HCCBjtsGWDm4 ROTG4+hXAkZn55qaC2cfUoF2MnL2sIlgVZVAYfrcklva/bq7r2mMT0NVjuanQStx7kv6 xw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2t4rmp00rs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:17: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 x5HIH5NU055935; Mon, 17 Jun 2019 18:17:05 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2t5h5t9g4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:17:05 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIH0iq025530; Mon, 17 Jun 2019 18:17:00 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:17:00 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:16:57 -0700 Message-Id: <20190617181657.30598-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [RFC PATCH v2 32/35] multi-process: Extend drive_del command to delete drive from 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, armbru@redhat.com, mreitz@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com, kwolf@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Extend drive_del HMP command to hot-unplug drive from a remote process. Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson --- blockdev.c | 9 +++++++++ hw/proxy/monitor.c | 26 ++++++++++++++++++++++++++ include/io/proxy-link.h | 2 ++ include/sysemu/blockdev.h | 1 + remote/remote-main.c | 18 ++++++++++++++++++ stubs/monitor.c | 5 +++++ 6 files changed, 61 insertions(+) diff --git a/blockdev.c b/blockdev.c index 79fbac8450..d554b1802f 100644 --- a/blockdev.c +++ b/blockdev.c @@ -61,6 +61,7 @@ #include "qemu/cutils.h" #include "qemu/help_option.h" #include "qemu/throttle-options.h" +#include "hw/boards.h" static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states = QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states); @@ -3044,12 +3045,20 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node, void hmp_drive_del(Monitor *mon, const QDict *qdict) { + MachineState *ms = MACHINE(current_machine); const char *id = qdict_get_str(qdict, "id"); BlockBackend *blk; BlockDriverState *bs; AioContext *aio_context; Error *local_err = NULL; +#ifdef CONFIG_MPQEMU + if (g_hash_table_lookup(ms->remote_devs, id)) { + hmp_rdrive_del(mon, qdict); + return; + } +#endif + bs = bdrv_find_node(id); if (bs) { qmp_blockdev_del(id, &local_err); diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c index e3f368aa94..e48b7f05d7 100644 --- a/hw/proxy/monitor.c +++ b/hw/proxy/monitor.c @@ -41,6 +41,7 @@ #include "qapi/error.h" #include "io/proxy-link.h" #include "sysemu/sysemu.h" +#include "sysemu/blockdev.h" /* * TODO: Is there a callback where the allocated memory for QMP could be free'd @@ -229,3 +230,28 @@ void hmp_rdrive_add(Monitor *mon, const QDict *qdict) g_free(data); } + +void hmp_rdrive_del(Monitor *mon, const QDict *qdict) +{ + MachineState *ms = MACHINE(current_machine); + Error *local_err = NULL; + PCIProxyDev *pdev = NULL; + const char *id; + int ret; + + pdev = get_proxy_device((QDict *)qdict, "id", &local_err); + if (local_err) { + monitor_printf(mon, "rdrive_del error: %s\n", + error_get_pretty(local_err)); + error_free(local_err); + return; + } + + id = qdict_get_str(qdict, "id"); + + ret = send_monitor_msg(pdev, DRIVE_DEL, strlen(id), (uint8_t *)id); + + if (!ret) { + (void)g_hash_table_remove(ms->remote_devs, (gpointer)id); + } +} diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index e102bcc8f5..bcec97d615 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -63,6 +63,7 @@ typedef struct ProxyLinkState ProxyLinkState; * DEVICE_ADD QMP/HMP command to hotplug device * DEVICE_DEL QMP/HMP command to hot-unplug device * DRIVE_ADD HMP command to hotplug drive + * DRIVE_DEL HMP command to hot-unplug drive * */ typedef enum { @@ -78,6 +79,7 @@ typedef enum { DEVICE_ADD, DEVICE_DEL, DRIVE_ADD, + DRIVE_DEL, PROXY_PING, MAX, } proc_cmd_t; diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index d34c4920dc..e6a9780025 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -61,4 +61,5 @@ DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type, void hmp_commit(Monitor *mon, const QDict *qdict); void hmp_drive_del(Monitor *mon, const QDict *qdict); +void hmp_rdrive_del(Monitor *mon, const QDict *qdict); #endif diff --git a/remote/remote-main.c b/remote/remote-main.c index 860b5e30f9..4866322b7e 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -257,6 +257,21 @@ static void process_drive_add_msg(ProcMsg *msg) PUT_REMOTE_WAIT(wait); } +static void process_drive_del_msg(ProcMsg *msg) +{ + const char *idstr = (const char *)msg->data2; + int wait = msg->fds[0]; + QDict *qdict = qdict_new(); + + qdict_put_str(qdict, "id", idstr); + + hmp_drive_del(NULL, qdict); + + notify_proxy(wait, 1); + + PUT_REMOTE_WAIT(wait); +} + static int init_drive(QDict *rqdict, Error **errp) { QemuOpts *opts; @@ -459,6 +474,9 @@ static void process_msg(GIOCondition cond) case DRIVE_ADD: process_drive_add_msg(msg); break; + case DRIVE_DEL: + process_drive_del_msg(msg); + break; case PROXY_PING: wait = msg->fds[0]; notify_proxy(wait, (uint32_t)getpid()); diff --git a/stubs/monitor.c b/stubs/monitor.c index ac24eeb5d4..653c308934 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -6,6 +6,7 @@ #include "qapi/qapi-types-misc.h" #include "qapi/qapi-commands-misc.h" #include "monitor/qdev.h" +#include "sysemu/blockdev.h" __thread Monitor *cur_mon; @@ -55,3 +56,7 @@ void qmp_rdevice_add(QDict *qdict, QObject **ret_data, Error **errp) void qmp_rdevice_del(const char *id, Error **errp) { } + +void hmp_rdrive_del(Monitor *mon, const QDict *qdict) +{ +} From patchwork Mon Jun 17 18:17:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB8DE14B6 for ; Mon, 17 Jun 2019 18:52:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C07B1289E9 for ; Mon, 17 Jun 2019 18:52:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4932289DD; Mon, 17 Jun 2019 18:52:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C93B289CA for ; Mon, 17 Jun 2019 18:52:31 +0000 (UTC) Received: from localhost ([::1]:51132 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwk2-0006Ni-F3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:52:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59675) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwDo-0007YG-5b for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:19:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwDm-0003Np-7y for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:19:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwDk-0003Ld-5T for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:19:10 -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 x5HI9xG6159764; Mon, 17 Jun 2019 18:19:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=GVfZaEumk+tL1PxhWsdZuCbVi1wtcAWJo1xAyAk8fG8=; b=AF6MvbdkDxmj7pznfwLxoBmAiw1kY25w1qfOemn3oBqPEHxY/eDdtwL3qQVFl62jgpp/ 2Ek5c0hbSqGwpnj3aMnNatWfn14LMrWWPqLJf+cyNNKL0YLloVPGOSionGUUyCVWd8YK kQpR0vPak7A+7rp0zZSN/HY/2kQ6T3VlGVrET9zO9Eblh3DoN3Soow4FK0uXR+WMciux 5Z26eo1i9m7jtVfcwA45eGFWku6XYWv9i2ia9nVlrI4mf17de2jvOOiILxrVFGKwid5E OENEnP7oiVkd/0aBWtJopNT6KlaaMU/JD473wn0ctmlcQWEYd97xRpa+rCIGidmo9pdm Wg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t4saq7yuq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:19:04 +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 x5HIGPAE181089; Mon, 17 Jun 2019 18:17:04 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2t5mgbgbd3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:17:04 +0000 Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIH3fC015304; Mon, 17 Jun 2019 18:17:03 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:17:03 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:17:00 -0700 Message-Id: <20190617181700.30700-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 33/35] multi-process: Extend block_resize command to support remote block 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, armbru@redhat.com, mreitz@redhat.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, kanth.ghatraju@oracle.com, kwolf@redhat.com, dgilbert@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Jagannathan Raman Extend block_resize QMP/HMP commands to resize block devices on a remote process. Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Signed-off-by: Elena Ufimtseva --- Changes in v2: - removed separate QMP/HMP command. - extended existing QMP command - refactor code to send messages to remote --- blockdev.c | 15 +++++++++++++++ hmp.c | 8 ++++++++ hmp.h | 1 + hw/proxy/monitor.c | 39 +++++++++++++++++++++++++++++++++++++++ include/io/proxy-link.h | 2 ++ include/sysemu/blockdev.h | 4 ++++ remote/remote-main.c | 36 ++++++++++++++++++++++++++++++++++++ stubs/monitor.c | 5 +++++ 8 files changed, 110 insertions(+) diff --git a/blockdev.c b/blockdev.c index d554b1802f..6e1ad12a95 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3115,12 +3115,27 @@ void qmp_block_resize(bool has_device, const char *device, bool has_node_name, const char *node_name, int64_t size, Error **errp) { + MachineState *ms = MACHINE(current_machine); Error *local_err = NULL; BlockBackend *blk = NULL; BlockDriverState *bs; AioContext *aio_context; int ret; +#ifdef CONFIG_MPQEMU + /* + * TODO: Assumes "device" for remote drive. Add support for + * "nodename" as well + */ + if (has_device && g_hash_table_lookup(ms->remote_devs, device)) { + qmp_rblock_resize(device, device, size, errp); + if (local_err) { + error_propagate(errp, local_err); + } + return; + } +#endif + bs = bdrv_lookup_bs(has_device ? device : NULL, has_node_name ? node_name : NULL, &local_err); diff --git a/hmp.c b/hmp.c index 89cdaebfde..e56b3b1f96 100644 --- a/hmp.c +++ b/hmp.c @@ -1339,10 +1339,18 @@ void hmp_balloon(Monitor *mon, const QDict *qdict) void hmp_block_resize(Monitor *mon, const QDict *qdict) { + MachineState *ms = MACHINE(current_machine); const char *device = qdict_get_str(qdict, "device"); int64_t size = qdict_get_int(qdict, "size"); Error *err = NULL; +#ifdef CONFIG_MPQEMU + if (g_hash_table_lookup(ms->remote_devs, device)) { + hmp_rblock_resize(mon, qdict, &err); + return; + } +#endif + qmp_block_resize(true, device, false, NULL, size, &err); hmp_handle_error(mon, &err); } diff --git a/hmp.h b/hmp.h index 6919f99218..5f46783d25 100644 --- a/hmp.h +++ b/hmp.h @@ -151,5 +151,6 @@ void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); void hmp_info_memory_size_summary(Monitor *mon, const QDict *qdict); void hmp_info_sev(Monitor *mon, const QDict *qdict); void hmp_info_remote(Monitor *mon, const QDict *qdict); +void hmp_rblock_resize(Monitor *mon, const QDict *qdict, Error **errp); #endif diff --git a/hw/proxy/monitor.c b/hw/proxy/monitor.c index e48b7f05d7..90f66aec6a 100644 --- a/hw/proxy/monitor.c +++ b/hw/proxy/monitor.c @@ -255,3 +255,42 @@ void hmp_rdrive_del(Monitor *mon, const QDict *qdict) (void)g_hash_table_remove(ms->remote_devs, (gpointer)id); } } + +void qmp_rblock_resize(const char *id, const char *device, int64_t size, + Error **errp) +{ + MachineState *ms = MACHINE(current_machine); + PCIProxyDev *pdev = NULL; + QString *json; + QDict *qdict; + + pdev = (PCIProxyDev *)g_hash_table_lookup(ms->remote_devs, id); + if (!pdev) { + error_setg(errp, "No remote device named %s", device); + return; + } + + qdict = qdict_new(); + qdict_put_str(qdict, "device", device); + qdict_put_int(qdict, "size", size); + + json = qobject_to_json(QOBJECT(qdict)); + + (void)send_monitor_msg(pdev, BLOCK_RESIZE, strlen(qstring_get_str(json)), + (uint8_t *)qstring_get_str(json)); +} + +void hmp_rblock_resize(Monitor *mon, const QDict *qdict, Error **errp) +{ + Error *local_err = NULL; + const char *device; + int64_t size; + + device = qdict_get_str(qdict, "device"); + size = qdict_get_int(qdict, "size"); + + qmp_rblock_resize(device, device, size, &local_err); + if (local_err) { + error_propagate(errp, local_err); + } +} diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index bcec97d615..fea9fe5ae1 100644 --- a/include/io/proxy-link.h +++ b/include/io/proxy-link.h @@ -64,6 +64,7 @@ typedef struct ProxyLinkState ProxyLinkState; * DEVICE_DEL QMP/HMP command to hot-unplug device * DRIVE_ADD HMP command to hotplug drive * DRIVE_DEL HMP command to hot-unplug drive + * BLOCK_RESIZE QMP/HMP command to resize block backend * */ typedef enum { @@ -81,6 +82,7 @@ typedef enum { DRIVE_ADD, DRIVE_DEL, PROXY_PING, + BLOCK_RESIZE, MAX, } proc_cmd_t; diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h index e6a9780025..975ecae54f 100644 --- a/include/sysemu/blockdev.h +++ b/include/sysemu/blockdev.h @@ -62,4 +62,8 @@ DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type, void hmp_commit(Monitor *mon, const QDict *qdict); void hmp_drive_del(Monitor *mon, const QDict *qdict); void hmp_rdrive_del(Monitor *mon, const QDict *qdict); + +void qmp_rblock_resize(const char *id, const char *device, int64_t size, + Error **errp); + #endif diff --git a/remote/remote-main.c b/remote/remote-main.c index 4866322b7e..fbaae8bf3a 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 "qapi/qapi-commands-block-core.h" static ProxyLinkState *proxy_link; PCIDevice *remote_pci_dev; @@ -272,6 +273,38 @@ static void process_drive_del_msg(ProcMsg *msg) PUT_REMOTE_WAIT(wait); } +static void process_block_resize_msg(ProcMsg *msg) +{ + const char *json = (const char *)msg->data2; + Error *local_err = NULL; + int wait = msg->fds[0]; + const char *device; + int64_t size; + QObject *qobj = NULL; + QDict *qdict = NULL; + + qobj = qobject_from_json(json, &local_err); + if (local_err) { + error_report_err(local_err); + return; + } + + qdict = qobject_to(QDict, qobj); + assert(qdict); + + device = qdict_get_str(qdict, "device"); + size = qdict_get_int(qdict, "size"); + + qmp_block_resize(true, device, false, NULL, size, &local_err); + if (local_err) { + error_report_err(local_err); + } + + notify_proxy(wait, 1); + + PUT_REMOTE_WAIT(wait); +} + static int init_drive(QDict *rqdict, Error **errp) { QemuOpts *opts; @@ -482,6 +515,9 @@ static void process_msg(GIOCondition cond) notify_proxy(wait, (uint32_t)getpid()); PUT_REMOTE_WAIT(wait); break; + case BLOCK_RESIZE: + process_block_resize_msg(msg); + break; default: error_setg(&err, "Unknown command"); goto finalize_loop; diff --git a/stubs/monitor.c b/stubs/monitor.c index 653c308934..79e008df41 100644 --- a/stubs/monitor.c +++ b/stubs/monitor.c @@ -60,3 +60,8 @@ void qmp_rdevice_del(const char *id, Error **errp) void hmp_rdrive_del(Monitor *mon, const QDict *qdict) { } + +void qmp_rblock_resize(const char *id, const char *device, int64_t size, + Error **errp) +{ +} From patchwork Mon Jun 17 18:17:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 367CB14B6 for ; Mon, 17 Jun 2019 18:54:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23AD728702 for ; Mon, 17 Jun 2019 18:54:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 177F8289D2; Mon, 17 Jun 2019 18:54:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA54428702 for ; Mon, 17 Jun 2019 18:54:36 +0000 (UTC) Received: from localhost ([::1]:51162 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwm3-0000vh-Vz for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:54:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59299) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwC5-0006Bp-LE for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBz-0002RT-De for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:25 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBx-0002NK-7q for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:19 -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 x5HI8sul159134; Mon, 17 Jun 2019 18:17:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=l4cjbWrWepXOv5QlHHp3UiHTn8WQMC+MFGsAprzxklM=; b=lDd70t092lesgoa9Gyo023X2c96A4vVHbK0JCP0hX5uWroiRqHmj6cmh8b/c/g0qGtpn A1BfLM7Pi7lkg3zN7ENNqhOtL7S0op0HV8Ddr6rkdQNSMIeBJR40q9o21GXVVWeIIh7B LO93jIKyljMIGJUBBKJgoLRNeXzid2jirXY22oYBxe23J2YkhegFZfJFQd1+ztAkMKEp KNJA8L3HUUXC8MgHC7aLRkPgPY6gnGIG2nE3MghvPO0HJ+Ip4x5CI/4bCD/kAugF4Viy YlvJKMTPwHbRBcW2F9wWF217oUls1mqzl2YrfrNf7YgZ3CX+0TKzAygSmvFZbd5XuG4T Dg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t4saq7ym7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:17:09 +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 x5HIGaYC181989; Mon, 17 Jun 2019 18:17:08 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2t5mgbgbe5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:17:07 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x5HIH6fU032708; Mon, 17 Jun 2019 18:17:06 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:17:06 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:17:04 -0700 Message-Id: <20190617181704.30751-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 34/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman --- Changes in v2: - changed the command line options descriptions; - added section about communication with remote process for MMIO and QMP commands using different sockets; --- docs/devel/qemu-multiprocess.txt | 1137 ++++++++++++++++++++++++++++++ 1 file changed, 1137 insertions(+) create mode 100644 docs/devel/qemu-multiprocess.txt diff --git a/docs/devel/qemu-multiprocess.txt b/docs/devel/qemu-multiprocess.txt new file mode 100644 index 0000000000..f814522178 --- /dev/null +++ b/docs/devel/qemu-multiprocess.txt @@ -0,0 +1,1137 @@ +Disaggregating QEMU + +This document describes implementation details of multi-process +qemu. + +1. QEMU services + + QEMU can be broadly described as providing three main +services. One is a VM control point, where VMs can be created, +migrated, re-configured, and destroyed. A second is to emulate the +CPU instructions within the VM, often accelerated by HW virtualization +features such as Intel's VT extensions. Finally, it provides IO +services to the VM by emulating HW IO devices, such as disk and +network devices. + +1.1 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 control QEMU process would remain, but in disaggregated +mode, it would be a control point that exec()s the processes needed to +support the VM being created, but have no direct interface 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 QEMU control process. + + +2. 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. + +2.1 QEMU device emulation + + QEMU uses a object oriented SW architecture for device +emulation code. Configured objects are all compiled into the QEMU +binary, then objects are instantiated by name when used by the guest +VM. For example, the code to emulate a device named "foo" is always +present in QEMU, but its instantiation code is only run when a device +named "foo" is included in the target VM (such as via the QEMU command +line as -device "foo".) + + The object model is hierarchical, so device emulation code can +name its parent object (such as "pci-device" for a PCI device) and +QEMU will instantiate a parent object before calling the device's +instantiation code. + +2.2 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. + +2.2.1 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. + +2.2.1.1 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. + +2.2.1.2 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 return 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. + +2.2.1.3 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. + +2.2.1.4 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 mmap()d 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. + +2.2.1.5 applicability to device separation + + Much of the vhost model can be re-used by separated device +emulation. In particular, the ideas of using a socket between QEMU +and the device emulation application, using a file descriptor to +inject interrupts into the VM via KVM, and allowing the application to +mmap() the guest should be re-used. + + There are, however, some notable differences between how a +vhost application works and the needs of separated device emulation. +The most basic is that vhost uses custom virtio device drivers which +always trigger IO with MMIO stores. A separated device emulation model +must work with existing IO device models and guest device drivers. +MMIO loads break vhost store acceleration since they are synchronous - +guest progress cannot continue until the load has been emulated. By +contrast, stores are asynchronous, the guest can continue after the +store event has been sent to the vhost application. + + Another difference is that in the vhost user model, a single +daemon can support multiple QEMU instances. This is contrary to the +security regime desired, in which the emulation application should +only be allowed to access the files or devices the VM it's running on +behalf of can access. + +2.2.2 qemu-io model + + Qemu-io is a test harness used to test changes to the QEMU +block backend object code. (e.g., the code that implements disk images +for disk driver emulation) Qemu-io is not a device emulation +application per se, but it does compile the QEMU block objects into a +separate binary from the main QEMU one. This could be useful for disk +device emulation, since its emulation applications will need to +include the QEMU block objects. + +2.3 New separation model based on proxy objects + + A different model based on proxy objects in the QEMU program +communicating with proxy objects the separated 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. + +2.3.1 command line specification + + 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. + +2.3.1.1 devices + +Devices that are to be emulated in a separate process will be identify the +remote process with a "remote" option on their *-device* command line +specification. e.g., an LSI SCSI controller and disk can be specified as: + +-device lsi53c895a,id=scsi0 +-device scsi-hd,drive=drive0,bus=scsi0.0,scsi-id=0 + +If these devices are emulated by remote process "lsi-scsi0," as described in +the previous section, the QEMU command line would be: + +-device lsi53c895a,id=scsi0,remote,command=lsi-scsi0,rid=0 +-device scsi-hd,drive=drive0,bus=scsi0.0,scsi-id=0,remote,command=lsi-scsi0,rid=0 + +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=ahci-ide0 + +will use the remote process with an "id" of "ahci-ide" 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=drive0,bus=ide.0,unit=0,remote=ahci-ide0 + +2.3.1.2 backends + + The device's backend would similarly have a changed command +line specification. e.g., a qcow2 block backend specified as: + +-blockdev driver=file,node-name=file0,filename=disk-file0 +-blockdev driver=qcow2,node-name=drive0,file=file0 + +becomes + +-blockdev driver=file,node-name=file0,filename=disk-file0,remote=lsi-scsi0 +-blockdev driver=qcow2,node-name=drive0,file=file0,remote=lsi-scsi0 + +2.3.1.3 emote processes + +Each *-remote* instance on the QEMU command line will create an entry +on a *QList* that can be searched for by its "id" property. It will also create +a communication channel between QEMU and a remote process. This is done in one +of two methods: direction execution of the process by QEMU with `fork()` and +`exec()` system calls, and connecting to an existing process. + +direct execution + +When the remote process is directly executed, QEMU will setup a communication +channel between it and the emulation process. This channel will be created +using `socketpair()` so that file descriptors can be passed from QEMU to the +process. + +connecting to 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 a remote emulation 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, or interrupt notifications +generated by the device being emulated. These secondary sockets will be created +at the behest of the device proxies that require them. A disk device proxy +wouldn't need any secondary sockets, but a disk controller device proxy may need +both an MMIO socket and an interrupt socket. + +Only one secondary socket is needed for each type: for example, if multiple +devices emulated by the same process each have MMIO registers, only one MMIO +socket is needed. The MMIO address is used to distinguish which device is being +accessed. + +#### remote process attached by QMP + +There will be a new "attach-process" QMP command to facilitate device hot-plug. +This command's arguments will be the same as the *-remote* command line when +it's used to attach to a remote process. i.e., it will need an "id" argument +so that hot-plugged devices can later find it, and a "socket" argument to +identify the UNIX domain socket that will be used to communicate with QEMU. + + +2.3.2 device proxy objects + + QEMU has an object model based on sub-classes inherited from +the "object" super-class. The sub-classes that are of interest here +are the "device" and "bus" sub-classes whose child sub-classes make up +the device tree of a QEMU emulated system. + + The proxy object model will use device proxy objects to +replace the device emulation code within the QEMU process. These +objects will live in the same place in the object and bus hierarchies +as the objects they replace. i.e., the proxy object for an LSI SCSI +controller will be a sub-class of the "pci-device" class, and will +have the same PCI bus parent and the same SCSI bus child objects as +the LSI controller object it replaces. + + After the QEMU command line has been parsed, the "-rdevice" +devices will be instantiated in the same manner as "-device" devices +are. (i.e., qdev_device_add()). In order to distinguish them from +regular "-device" device objects, their class name will be the name of +the class it replaces, with "-proxy" appended. e.g., the "scsi-hd" +proxy class will be "scsi-hd-proxy" + +2.3.2.1 object initialization + + QEMU object initialization occurs in two phases. The first +initialization happens once per object class. (i.e., there can be many +SCSI disks in an emulated system, but the "scsi-hd" class has its +class_init() function called only once) The second phase happens when +each object's instance_init() function is called to initialize each +instance of the object. + + All device objects are sub-classes of the "device" class, so +they also have a realize() function that is called after +instance_init() is called and after the object's static properties +have been initialized. Many device objects don't even provide an +instance_init() function, and do all their per-instance work in +realize(). + +2.3.2.1.1 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. + +2.3.2.1.2 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. They also need to add a "json_device" string +property that contains the JSON representation of the command line +options used to create the object. + + This JSON representation is used to create the corresponding +object in an emulation process. e.g., for an LSI SCSI controller +invoked as: + + -device lsi53c895a,id=scsi0,remote,command="lsi-scsi" + +the proxy object would create a + +{ "driver" : "lsi53c895a", "id" : "scsi0" } + +JSON description. The "driver" option is assigned to the device name +when the command line is parsed, so the "-proxy" appended by the +command line parsing code must be removed. The "command" option isn't +needed in the JSON description since it only applies to the proxy +object in the QEMU process. + + Other tasks will are device-specific. PCI device objects will +initialize the PCI config space in order to make a valid PCI device +tree within the QEMU process. Disk devices will probe their backend +object to get its JSON description, and publish this description as a +"json_backend" string property (see the backend discussion below.) + +2.3.2.2 address space registration + + Most devices are driven by guest device driver accesses to IO +addresses or ports. The QEMU device emulation code uses QEMU's memory +region function calls (such as memory_region_init_io()) to add +callback functions that QEMU will invoke when the guest accesses the +device's areas of the IO address space. When a guest driver does +access the device, the VM will exit HW virtualization mode and return +to QEMU, which will then lookup and execute the corresponding callback +function. + + A proxy object would need to mirror the memory region calls +the actual device emulator would perform in its initialization code, +but with its own callbacks. When invoked by QEMU as a result of a +guest IO operation, they will forward the operation to the device +emulation process via a proxy_proc_send() call. Any response will +be read via proxy_proc_recv(). + + Note that the callbacks are called with an address space lock, +so it would not be a appropriate to synchronously wait for any +response. Instead the QEMU code must be changed to check if the +thread needs to sleep after the address_space_rw() call (in +kvm_cpu_exec().) + +2.3.2.3 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 it's 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. + +2.3.2.3.1 PCI parent proxy + + One way to propagate guest PCI config accesses is to create a +"pci-device-proxy" class that can serve as the parent of a PCI device +proxy object. This class's parent would be "pci-device" and it would +override the PCI parent's config_read and config_write methods with +ones that forward these operations to the emulation program. + +2.3.2.4 interrupt receipt + + A proxy for a device that generates interrupts will receive +the interrupt indication via the read callback it provided to +proxy_ctx_alloc(). The 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(). + +2.3.3 device backends + + Each type of device has backends which perform IO operations +in the host system. For example, block backend objects emulate the +disk images configured into the VM. While block backends are +implemented as objects, not all backends are. For example, display +backends (e.g., vnc) are not objects, they register a set of virtual +functions that are called by QEMU's display emulation. + + These device backends also need run in the device emulation +processes, and the emulation process must be given access the the +corresponding host files or devices. + +2.3.3.1 block backends + + Block backends are objects that can implement file protocols +(such as a local file or an iSCSI volume), implement disk image +formats (such as qcow2), or serve as a request filter (such as IO +throttling). They are often stacked on each other (such as a qcow2 +format on a local file protocol.) They're are named by "node-name" +properties that are then matched to "drive" properties of the +corresponding disk devices. + + Block backend objects are not part of the QEMU object model +(i.e., they're not sub-classes of "object"). They are instantiated +when the bdrv_file_open() method is invoked with a Qdict dictionary +of the backend's command line options. + +2.3.3.1.1 initialization + + When a "-rblockdev" backend is initialized, it will not open +the underlying backend object, as is done for "-blockdev" backends. +Instead, it will create a BlockDriverState node that has a proxy name +and the original options Qdict. The proxy name will consist of the +backend's node-name with "-peer" appended to it (i.e., a "drive0" +node-name would have a "drive0-peer" peer.) + + A proxy backend object with then be opened, using an +initialization Qdict containing the "node-name" of the underlying +backend, so that disk device objects and QMP commands can find it. +The proxy's Qdict will also be given the proxy name as a "peer" +property so it can lookup its underlying backend object and its +associated Qdict. + +2.3.3.1.2 bdrv_probe_json + + This API returns the JSON description of the peer of a given +backend proxy. It will be used by disk device proxy objects to get +the JSON descriptions of the block backend (and any backends layered +below) needed to emulate the disk image. + +2.3.3.1.3 bdrv_get_json + + This is a new block backend object method that returns the +JSON description this object, and all of its underlying objects. It +will recursively descend any layered backend objects (e.g., a format +object will call its underlying protocol object) This method can be +invoked on an object that has not been opened. It will mainly be used +by bdrv_probe_json(). + +2.3.3.1.4 bdrv_assign_proxy_name + + The API creates the node with a proxy name, and enters it on a +list of peer nodes. This list can be searched by proxy backends to +find their associated peers. + +2.3.3.1.5 QMP commands + + Various QMP command operate on blockdevs. These will need +to work on rblockevs in separated processes as well. There are +several cases that need to be handled. + +2.3.3.1.5.1 adding rblockdevs + + QMP allows users to add blockdevs to a running QEMU instance. +This is done not just to hot-plug a disk device into a guest, but also +for advanced blockdev features such as changing quorum devices. +Likewise, QMP needs be able to add an rblockdev to the guest, so +similar operations can be performed on devices being emulated in a +separate process. + + This operation doesn't need to be performed differently from +adding an rblockdev from the command line. Blockdevs are added with a +qmp_blockdev_add() routine that can be called from either the command +line parser or from QMP. Note the name of the C routine called from +QMP is generated by a python script, so a "rblockdev-add" command must +be implemented by qmp_rblockdev_add(). + +2.3.3.1.5.2 targeted commands + + Many QMP commands operate on specified blockdevs. These +commands will find the proxy node when they lookup the targeted name, +which will then forward the request to the emulation process managing +the peer node. + +2.3.3.1.5.3 blockdev lists + + Several QMP query commands (such as query-block or +query-block-jobs) operate on all blockdevs. These will function +much like targeted commands, with the proxy nodes forwarding the +request to its peer emulation process. + +2.3.4 proxy APIs + + There will be a set of APIs provided by a process execution +service for proxy objects to use to manage the separate emulation +program. + +2.3.4.1 proxy_register + + A proxy device object must register itself with the +proxy_register() API. The registration call will include validation +and execution callbacks that will be invoked after the emulated +machine has been setup in QEMU. + +2.3.4.1.1 validation callback + + This callback will invoked after all devices in the emulated +system have been initialized. Its purpose is to validate the device +configuration by checking that its parent and child bus objects are +compatible with being proxied. For example, a disk controller can +check that all the devices on its bus are all proxy objects, or a disk +object can check that its backend object is a proxy. If any of the +validation callbacks return an error, QEMU will exit. If there are no +errors, the execution callbacks will be invoked. + +2.3.4.1.2 execution callback + + A device proxy object that manages an emulation process will +provide an execution callback in its proxy_register() call. This +callback will allocate an execution context with proxy_ctx_alloc(), +marshal the arguments needed for the emulation program, and invoke +proxy_execute() to execute it. + +2.3.4.2 proxy_ctx_alloc + + Before the emulation program can be executed, the proxy object +must call proxy_ctx_alloc() to create an execution context for the +process. The execution context will serve as a handle on which the +other proxy APIs operate. + +2.3.4.3 proxy_ctx_callbacks + + This API registers two callback functions: get_reply() and +get_request(), on the context. get_reply() is invoked to handle +replies to requests sent to the emulation process. get_request() is +invoked to handle requests from the emulation process. This API can +be called multiple times on the same context; a class field within an +incoming message indicates which callbacks will be invoked. + +2.3.4.4 proxy_execute + + This function executes an emulation program. It needs to be +provided with an execution context, the file to execute, and any +arguments needed by the program. Before executing the given program, +it will setup the communications channels for the new process. + +2.3.5 communication with emulation process + + The execution service will setup two communication channels +between the main QEMU process and the emulation process. The channels +will be created using socketpair() so that file descriptors can be +passed from QEMU to the process. + +2.3.5.1 requests to emulation process + + The stdin file descriptor of the emulation process will be +used for requests from QEMU to the emulation process. The execution +service provides APIs to send and receive messages from the emulation +process. + +2.3.5.1.1 proxy_proc_send + + This API is for the proxy object in QEMU to send messages to +the emulation process. Its arguments will include an execution +context in addition to the actual message. + +2.3.5.1.2 proxy_proc_recv + + This API receives replies from the emulation process. It +requires the execution context of the target process, and will usually +be called from the get_reply() callback specified in proxy_ctx_alloc. + +2.3.5.2 requests to QEMU process + + The stdout file descriptor to the emulation process will be +used for requests from the emulation process to QEMU. As with +requests to the emulation process, APIs will be provided to facilitate +communication. + +2.3.5.2.1 proxy_qemu_recv + + This API receives requests from the emulation process. It +requires the execution context of the target process, and will usually +be called from the get_request() callback specified in +proxy_ctx_alloc. + +2.3.5.2.2 proxy_qemu_send + + This API is for the proxy object in QEMU to send replies to +the emulation process. Its arguments will include an execution +context in addition to the actual reply. + +2.3.5.3 JSON descriptions + + The initial messages sent to the emulation process will +describe the devices its will be tasked to emulate. The will be +described as JSON arrays of backend and device objects that need to be +instantiated by the emulation process. + +2.3.5.3.1 backend JSON + + The device proxy object will aggregate the "json_backend" +properties from the disk devices on the bus it controls, and send +them as a JSON array of objects. e.g., this command line: + +-rblockdev driver=file,node-name=file0,filename=disk-file0 +-rblockdev driver=qcow2,node-name=drive0,file=file0 + +would generate + +[ + { "driver" : "file", "node-name" : "file0", "filename" : "disk-file0" }. + { "driver" : "qcow2", "node-name" : "drive0", "file" : "file0" } +] + +2.3.5.3.2 device JSON + + The device proxy object will aggregate a JSON description of +itself and devices on the bus it controls (via their "json_device" +properties), and send them to the emulation process as a JSON array of +objects. + +2.3.5.4 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. + +2.3.5.5 IOMMU operations + + When the emulated system includes an IOMMU, the proxy +execution service will need to handle IOMMU requests from the +emulation process using an address_space_get_iotlb_entry() call. In +order to handle IOMMU unmaps, the proxy execution service will also +register as a listener on the device's DMA address space. When an +IOMMU memory region is created within the DMA address space, an IOMMU +notifier for unmaps will be added to the memory region that will +forward unmaps to the emulation process. + + This also will require a proxy_ctx_callbacks() call to +register an IOMMU handler for incoming IOMMU requests from the +emulation program. + +2.3.6 device emulation process + + The device emulation process will run the object hierarchy of +the device, hopefully unmodified. It will be based on the QEMU source +code, because for anything but the simplest device, it would not be a +tractable problem to re-implement both the object model and the many +device backends that QEMU has. + + The parts of QEMU that the emulation program will need include +the object model; the memory emulation objects; the device emulation +objects of the targeted device, and any dependent devices; and, the +device's backends. It will also need code to setup the machine +environment, handle requests from the QEMU process, and route +machine-level requests (such as interrupts or IOMMU mappings) back to +the QEMU process. + +2.3.6.1 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 arrays sent by the +QEMU process will drive which objects need to be created. + +2.3.6.1.1 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). + +2.3.6.1.2 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(). + +2.3.6.1.3 PCI + + IO initialization will be driven by the JSON description 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. + +2.3.6.2 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 withing 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. + +2.3.6.3 interrupt injection + + When device emulation wants to inject an interrupt into the +VM, the request climbs the device's bus object hierarchy until the +point where a bus object knows how to signal the interrupt to the +guest. The details depend on the type of interrupt being raised. + +2.3.6.3.1 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. + +2.3.6.3.2 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. + +2.3.6.4 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. + +2.3.6.5 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. + +2.3.6.5.1 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. + +2.3.6.5.2 IOTLB purge + + The IOMMU emulation will also need to act on unmap requests +from QEMU. These happen when the guest IOMMU driver purges an entry +from the guest's translation table. + +2.4 Accelerating device emulation + + The messages that are required to be sent between QEMU and the +emulation process can add considerable latency to IO operations. The +optimizations described below attempt to ameliorate this effect by +allowing the emulation process to communicate directly with the kernel +KVM driver. The KVM file descriptors created wold be passed to the +emulation process via initialization messages, much like the guest +memory table is done. + +2.4.1 MMIO acceleration + + Vhost user applications can receive guest virtio driver stores +directly from KVM. The issue with the eventfd mechanism used by vhost +user is that it does not pass any data with the event indication, so +it cannot handle guest loads or guest stores that carry store data. +This concept could, however, be expanded to cover more cases. + + The expanded idea would require a new type of KVM device: +KVM_DEV_TYPE_USER. This device has two file descriptors: a master +descriptor that QEMU can use for configuration, and a slave descriptor +that the emulation process can use to receive MMIO notifications. +QEMU would create both descriptors using the KVM driver, and pass the +slave descriptor to the emulation process via an initialization +message. + +2.4.1.1 data structures + +2.4.1.1.1 guest physical range + + The guest physical range structure describes the address range +that a device will respond to. It includes the base and length of the +range, as well as which bus the range resides on (e.g., on an x86 +machine, it can specify whether the range refers to memory or IO +addresses). + + A device can have multiple physical address ranges it responds +to (e.g., a PCI device can have multiple BARs), so the structure will +also include an enumeration value to specify which of the device's +ranges is being referred to. + +2.4.1.1.2 MMIO request structure + + This structure describes an MMIO operation. It includes which +guest physical range the MMIO was within, the offset within that +range, the MMIO type (e.g., load or store), and its length and data. +It also includes a sequence number that can be used to reply to the +MMIO, and the CPU that issued the MMIO. + +2.4.1.1.3 MMIO request queues + + MMIO request queues are FIFO arrays of MMIO request +structures. There are two queues: pending queue is for MMIOs that +haven't been read by the emulation program, and the sent queue is for +MMIOs that haven't been acknowledged. The main use of the second +queue is to validate MMIO replies from the emulation program. + +2.4.1.1.4 scoreboard + + Each CPU in the VM is emulated in QEMU by a separate thread, +so multiple MMIOs may be waiting to be consumed by an emulation +program and multiple threads may be waiting for MMIO replies. The +scoreboard would contain a wait queue and sequence number for the +per-CPU threads, allowing them to be individually woken when the MMIO +reply is received from the emulation program. It also tracks the +number of posted MMIO stores to the device that haven't been replied +to, in order to satisfy the PCI constraint that a load to a device +will not complete until all previous stores to that device have been +completed. + +2.4.1.1.5 device shadow memory + + Some MMIO loads do not have device side-effects. These MMIOs +can be completed without sending a MMIO request to the emulation +program if the emulation program shares a shadow image of the device's +memory image with the KVM driver. + + The emulation program will ask the KVM driver to allocate +memory for the shadow image, and will then use mmap() to directly +access it. The emulation program can control KVM access to the shadow +image by sending KVM an access map telling it which areas of the image +have no side-effects (and can be completed immediately), and which +require a MMIO request to the emulation program. The access map can +also inform the KVM drive which size accesses are allowed to the +image. + +2.4.1.2 master descriptor + + The master descriptor is used by QEMU to configure the new KVM +device. The descriptor would be returned by the KVM driver when QEMU +issues a KVM_CREATE_DEVICE ioctl() with a KVM_DEV_TYPE_USER type. + +2.4.1.2.1 KVM_DEV_TYPE_USER device ops + + The KVM_DEV_TYPE_USER operations vector will be registered by +a kvm_register_device_ops() call when the KVM system in initialized by +kvm_init(). These device ops are called by the KVM driver when QEMU +executes certain ioctls() on its KVM file descriptor. They include: + +2.4.1.1.2.1 create + + This routine is called when QEMU issues a KVM_CREATE_DEVICE +ioctl() on its per-VM file descriptor. It will allocate and +initialize a KVM user device specific data structure, and assign the +kvm_device private field to it. + +2.4.1.1.2.2 ioctl + + This routine is invoked when QEMU issues an ioctl() on the +master descriptor. The ioctl() commands supported are defined by the +KVM device type. KVM_DEV_TYPE_USER ones will need several commands: + + KVM_DEV_USER_SLAVE_FD creates the slave file descriptor that +will be passed to the device emulation program. Only one slave can be +created by each master descriptor. The file operations performed by +this descriptor are described below. + + The KVM_DEV_USER_PA_RANGE command configures a guest physical +address range that the slave descriptor will receive MMIO +notifications for. The range is specified by a guest physical range +structure argument. For buses that assign addresses to devices +dynamically, this command can be executed while the guest is running, +such as the case when a guest changes a device's PCI BAR registers. + + KVM_DEV_USER_PA_RANGE will use kvm_io_bus_register_dev() to +register kvm_io_device_ops callbacks to be invoked when the guest +performs a MMIO operation within the range. When a range is changed, +kvm_io_bus_unregister_dev() is used to remove the previous +instantiation. + + KVM_DEV_USER_TIMEOUT will configure a timeout value that +specifies how long KVM will wait for the emulation process to respond +to a MMIO indication. + +2.4.1.1.2.3 destroy + + This routine is called when the VM instance is destroyed. It +will need to destroy the slave descriptor; and free any memory +allocated by the driver, as well as the kvm_device structure itself. + +2.4.1.3 slave descriptor + + The slave descriptor will have its own file operations vector, +which responds to system calls on the descriptor performed by the +device emulation program. + +2.4.1.3.1 read + + A read returns any pending MMIO requests from the KVM driver +as MMIO request structures. Multiple structures can be returned if +there are multiple MMIO operations pending. The MMIO requests are +moved from the pending queue to the sent queue, and if there are +threads waiting for space in the pending to add new MMIO operations, +they will be woken here. + +2.4.1.3.2 write + + A write also consists of a set of MMIO requests. They are +compared to the MMIO requests in the sent queue. Matches are removed +from the sent queue, and any threads waiting for the reply are woken. +If a store is removed, then the number of posted stores in the per-CPU +scoreboard is decremented. When the number is zero, and a non +side-effect load was waiting for posted stores to complete, the load +is continued. + +2.4.1.3.3 ioctl + + There are several ioctl()s that can be performed on the +slave descriptor. + + A KVM_DEV_USER_SHADOW_SIZE ioctl() causes the KVM driver to +allocate memory for the shadow image. This memory can later be +mmap()ed by the emulation process to share the emulation's view of +device memory with the KVM driver. + + A KVM_DEV_USER_SHADOW_CTRL ioctl() controls access to the +shadow image. It will send the KVM driver a shadow control map, which +specifies which areas of the image can complete guest loads without +sending the load request to the emulation program. It will also +specify the size of load operations that are allowed. + +2.4.1.3.4 poll + + An emulation program will use the poll() call with a POLLIN +flag to determine if there are MMIO requests waiting to be read. It +will return if the pending MMIO request queue is not empty. + +2.4.1.3.5 mmap + + This call allows the emulation program to directly access the +shadow image allocated by the KVM driver. As device emulation updates +device memory, changes with no side-effects will be reflected in the +shadow, and the KVM driver can satisfy guest loads from the shadow +image without needing to wait for the emulation program. + +2.4.1.4 kvm_io_device ops + + Each KVM per-CPU thread can handle MMIO operation on behalf of +the guest VM. KVM will use the MMIO's guest physical address to +search for a matching kvm_io_devce to see if the MMIO can be handled +by the KVM driver instead of exiting back to QEMU. If a match is +found, the corresponding callback will be invoked. + +2.4.1.4.1 read + + This callback is invoked when the guest performs a load to the +device. Loads with side-effects must be handled synchronously, with +the KVM driver putting the QEMU thread to sleep waiting for the +emulation process reply before re-starting the guest. Loads that do +not have side-effects may be optimized by satisfying them from the +shadow image, if there are no outstanding stores to the device by this +CPU. PCI memory ordering demands that a load cannot complete before +all older stores to the same device have been completed. + +2.4.1.4.2 write + + Stores can be handled asynchronously unless the pending MMIO +request queue is full. In this case, the QEMU thread must sleep +waiting for space in the queue. Stores will increment the number of +posted stores in the per-CPU scoreboard, in order to implement the PCI +ordering constraint above. + +2.4.2 interrupt acceleration + + This performance optimization would work much like a vhost +user application does, where the QEMU process sets up eventfds that +cause the device's corresponding interrupt to be triggered by the KVM +driver. These irq file descriptors are sent to the emulation process +at initialization, and are used when the emulation code raises a +device interrupt. + +2.4.2.1 intx acceleration + + Traditional PCI pin interrupts are level based, so, in +addition to an irq file descriptor, a re-sampling file descriptor +needs to be sent to the emulation program. This second file +descriptor allows multiple devices sharing an irq to be notified when +the interrupt has been acknowledged by the guest, so they can +re-trigger the interrupt if their device has not de-asserted it. + +2.4.2.1.1 intx irq descriptor + + The irq descriptors are created by the proxy object using +event_notifier_init() to create the irq and re-sampling eventds, and +kvm_vm_ioctl(KVM_IRQFD) to bind them to an interrupt. The interrupt +route can be found with pci_device_route_intx_to_irq(). + +2.4.2.1.2 intx routing changes + + Intx routing can be changed when the guest programs the APIC +the device pin is connected to. The proxy object in QEMU will use +pci_device_set_intx_routing_notifier() to be informed of any guest +changes to the route. This handler will broadly follow the VFIO +interrupt logic to change the route: de-assigning the existing irq +descriptor from its route, then assigning it the new route. (see +vfio_intx_update()) + +2.4.2.2 MSI/X acceleration + + MSI/X interrupts are sent as DMA transactions to the host. +The interrupt data contains a vector that is programed by the guest, A +device may have multiple MSI interrupts associated with it, so +multiple irq descriptors may need to be sent to the emulation program. + +2.4.2.2.1 MSI/X irq descriptor + + This case will also follow the VFIO example. For each MSI/X +interrupt, an eventfd is created, a virtual interrupt is allocated by +kvm_irqchip_add_msi_route(), and the virtual interrupt is bound to the +eventfd with kvm_irqchip_add_irqfd_notifier(). + +2.4.2.2.2 MSI/X config space changes + + The guest may dynamically update several MSI-related tables in +the device's PCI config space. These include per-MSI interrupt +enables and vector data. Additionally, MSIX tables exist in device +memory space, not config space. Much like the BAR case above, the +proxy object must look at guest config space programming to keep the +MSI interrupt state consistent between QEMU and the emulation program. + + +3. Disaggregated CPU emulation + + After IO services have been disaggregated, a second phase +would be to separate a process to handle CPU instruction emulation +from the main QEMU control function. There are no object separation +points for this code, so the first task would be to create one. + + +4. Host access controls + + Separating QEMU relies on the host OS's access restriction +mechanisms to enforce that the differing processes can only access the +objects they are entitled to. There are a couple types of mechanisms +usually provided by general purpose OSs. + +4.1 Discretionary access control + + Discretionary access control allows each user to control who +can access their files. In Linux, this type of control is usually too +coarse for QEMU separation, since it only provides three separate +access controls: one for the same user ID, the second for users IDs +with the same group ID, and the third for all other user IDs. Each +device instance would need a separate user ID to provide access +control, which is likely to be unwieldy for dynamically created VMs. + +4.2 Mandatory access control + + Mandatory access control allows the OS to add an additional +set of controls on top of discretionary access for the OS to control. +It also adds other attributes to processes and files such as types, +roles, and categories, and can establish rules for how processes and +files can interact. + +4.2.1 Type enforcement + + Type enforcement assigns a 'type' attribute to processes and +files, and allows rules to be written on what operations a process +with a given type can perform on a file with a given type. QEMU +separation could take advantage of type enforcement by running the +emulation processes with different types, both from the main QEMU +process, and from the emulation processes of different classes of +devices. + + For example, guest disk images and disk emulation processes +could have types separate from the main QEMU process and non-disk +emulation processes, and the type rules could prevent processes other +than disk emulation ones from accessing guest disk images. Similarly, +network emulation processes can have a type separate from the main +QEMU process and non-network emulation process, and only that type can +access the host tun/tap device used to provide guest networking. + +4.2.2 Category enforcement + + Category enforcement assigns a set of numbers within a given + range to the process or file. The process is granted access to the + file if the process's set is a superset of the file's set. This + enforcement can be used to separate multiple instances of devices in + the same class. + + For example, if there are multiple disk devices provides to a +guest, each device emulation process could be provisioned with a +separate category. The different device emulation processes would not +be able to access each other's backing disk images. + + Alternatively, categories could be used in lieu of the type +enforcement scheme described above. In this scenario, different +categories would be used to prevent device emulation processes in +different classes from accessing resources assigned to other classes. + From patchwork Mon Jun 17 18:17:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 11000213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C07AB14C0 for ; Mon, 17 Jun 2019 18:52:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4C90289CC for ; Mon, 17 Jun 2019 18:52:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9653289CF; Mon, 17 Jun 2019 18:52:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 468C2289D1 for ; Mon, 17 Jun 2019 18:52:49 +0000 (UTC) Received: from localhost ([::1]:51134 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwkK-00074K-JQ for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Jun 2019 14:52:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59258) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcwC0-00060L-PE for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcwBz-0002Qt-9g for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17:20 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56636) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcwBx-0002Nq-5t for qemu-devel@nongnu.org; Mon, 17 Jun 2019 14:17: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 x5HI8uog159142; Mon, 17 Jun 2019 18:17:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=YO8N8nOS0K9k+My27NffQ5m9MVn76qfiiCp83Mmd+2E=; b=fKTjME7VOEau9vlnkNK3ybs2QATOoAjc0teN/Ml/i4/1GENRZqJcUTRULEmyYPvl4TVy QNTqxHn7X4t5+NOlY4kupCSHyaWegovHTmnPhfeAWue4pCm6Ge/aqrS5ur+tT/HS7xKC OClMa3P2vmx7ewpqZKNuQmi1NthQS5R9NHjZ1Wibeqyxkk7vQnPlo7IYgr3Ennu/vgXf ITXaDzYiRMFMEJDvKB8yCydMWzxZ8FMzzcupkApQz5vo2+j1s3JQnr+gxRlJWZSNEcY3 NXiB1XAPaQBAGqR+iIWIAz/ULCpc5gwzI2IfqoLtwtZSqIqLB/IflEj555lCaQOi6IVU SQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2t4saq7yme-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:17:10 +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 x5HIGPpe181142; Mon, 17 Jun 2019 18:17:10 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2t5mgbgben-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Jun 2019 18:17:10 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5HIH8PJ025578; Mon, 17 Jun 2019 18:17:09 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 17 Jun 2019 11:17:08 -0700 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Mon, 17 Jun 2019 11:17:06 -0700 Message-Id: <20190617181706.30796-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9291 signatures=668687 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-1810050000 definitions=main-1906170162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [RFC PATCH v2 35/35] 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, john.g.johnson@oracle.com, jag.raman@oracle.com, konrad.wilk@oracle.com, ross.lagerwall@citrix.com, liran.alon@oracle.com, stefanha@redhat.com, kanth.ghatraju@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Elena Ufimtseva Signed-off-by: Elena Ufimtseva Signed-off-by: Jagannathan Raman Signed-off-by: John G Johnson --- Changes in v2: - since the changes were made to use existing device/drive options, the document was modified to reflect this. --- docs/qemu-multiprocess.txt | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 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 0000000000..3b11ca9cc2 --- /dev/null +++ b/docs/qemu-multiprocess.txt @@ -0,0 +1,59 @@ +Multi-process QEMU + +This document describes how to configure and use multi-process qemu. +For the design document refer to docs/devel/qemu-multiprocess. + +Configure + +To enable support for multi-process add --enable-mpqemu +to the list of options for configure. + +Usage + +Command line + +To start qemu with devices intended to run in the separate emulation +process, the following suboptions are used: + + remote, [socket=[socket_number],|command="command to run",] rid="remote process id" +For exmaple, for non multi-process qemu: + -device lsi53c895a,id=scsi0 device + -device scsi-hd,drive=drive0,bus=scsi0.0,scsi-id=0 + -drive id=drive0,file=data-disk.img + +and for multi-process qemu and no libvirt support (i.e. QEMU forks child processes): + -device lsi53c895a,id=scsi0,remote,rid=0,command="qemu-scsi-dev" + -device scsi-hd,drive=drive0,bus=scsi0.0,scsi-id=0,remote,rid="0",command="qemu-scsi-dev" + -drive id=drive0,file=data-disk.img,remote,rid=0,command="qemu-scsi-dev" + + +The memorybackend object has to be specified on the command line: +-object memory-backend-file,id=mem,mem-path=/dev/shm/,size=4096M,share=on + + +Example of running scsi drive in the guest in separate qemu +process: + +qemu-system-x86_64 -enable-kvm -machine q35 -smp 4 -m 4096M -vnc :0 \ +-net nic -net user,hostfwd=tcp::5022-:22 -hda os.qcow2 \ +-device lsi53c895a,id=scsi0,remote,rid=0,command="qemu-scsi-dev" \ +-device scsi-hd,drive=drive0,bus=scsi0.0,scsi-id=0,remote,rid="0",command="qemu-scsi-dev" \ +-drive id=drive0,file=data-disk.img,remote,rid=0,command="qemu-scsi-dev" \ +-object memory-backend-file,id=mem,mem-path=/dev/shm/,size=4096M,share=on -numa node,memdev=mem + +HMP commands + +For hotplugging in multi-process qemu the following commands +can be used: + +- rdevice_add; +- rdevice_del; +- rdrive_add; +- rdrive_del; +- remote_proc_list + +After running rescan_scsi_bus.sh -a, guest will be able to identify newly +added devices. + + +