From patchwork Thu Mar 7 07:22: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: 10842311 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 8D8671515 for ; Thu, 7 Mar 2019 07:40:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76CA82E22D for ; Thu, 7 Mar 2019 07:40:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 751E32E4A5; Thu, 7 Mar 2019 07:40:32 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED5BF2E48C for ; Thu, 7 Mar 2019 07:40:31 +0000 (UTC) Received: from localhost ([127.0.0.1]:46828 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1ndn-0000fN-3c for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Mar 2019 02:40:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1nMa-0002m7-JP for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:22:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1nMY-0005jh-JX for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:22:44 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:48722) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h1nMW-0005gb-Lv for qemu-devel@nongnu.org; Thu, 07 Mar 2019 02:22:41 -0500 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 x277JBgE037788; Thu, 7 Mar 2019 07:22:31 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=W/RxEEXxKWivQvni8rzZcFqi2Xe5ocfOrHDOr3/2Ies=; b=TYCIeEbzk/EltlAHtefTbvYeLQiNXMzWb2/H/kV+N/e63Tl4gdVDPkYlZBVHkg2zqcHR coU8bGMnD2p+fm6JD9ARAydlvmK5tjVdcTN7ZJ2JCKV5EvkxNgRkm59Q/JTByhOysOuh j6EMGAG7+K5wWKMxaMQUlS5b+Ba7v12CYwIwwHnkjNa1zGi9e/tgzjdyC2UAULBndt7w 5ZHeHNnxe2bSU56n48kLDmvHgHoqtWVwykn0ACKNczMKMhUJ0Bgg1g7IFfGpipFjSCfq KrvKY+draNNq2mV1/inpOriyoELqSyPUVLoZv5LhGDD/XUsJxI5i6LyTs0MebH5bTXxu iw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2qyh8ug98a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 07 Mar 2019 07:22:30 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x277MTed001788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 7 Mar 2019 07:22:29 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x277MT4Q011802; Thu, 7 Mar 2019 07:22:29 GMT Received: from heatpipe.hsd1.ca.comcast.net (/73.170.27.202) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Mar 2019 23:22:28 -0800 From: elena.ufimtseva@oracle.com To: qemu-devel@nongnu.org Date: Wed, 6 Mar 2019 23:22:26 -0800 Message-Id: <20190307072226.9362-1-elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.17.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9187 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903070053 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [multiprocess RFC PATCH 25/37] multi-process: configure remote side devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: elena.ufimtseva@oracle.com, john.g.johnson@oracle.com, sstabellini@kernel.org, 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 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 | 41 +++++++++++++++++++++++++++++++++++++++-- include/hw/proxy/qemu-proxy.h | 2 ++ include/io/proxy-link.h | 2 ++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index f519beb..9d075ec 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -52,6 +52,7 @@ #include "util/event_notifier-posix.c" #include "hw/i386/pc.h" #include "hw/boards.h" +#include "include/qemu/log.h" /* * TODO: kvm_vm_ioctl is only available for per-target objects (NEED_CPU_H). @@ -61,6 +62,40 @@ 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); + qemu_log_mask(LOG_REMOTE_DEBUG, "remote qdict in proxy: %s.\n", str); + + 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; +} static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, int l, unsigned int op) @@ -76,7 +111,8 @@ static int config_op_send(PCIProxyDev *dev, uint32_t addr, uint32_t *val, int l, msg.data2 = (uint8_t *)malloc(sizeof(conf_data)); if (!msg.data2) { - printf("Failed to allocate memory for msg.data2."); + qemu_log_mask(LOG_REMOTE_DEBUG, "Failed to allocate memory" + " for msg.data2.\n"); return -ENOMEM; } @@ -268,8 +304,9 @@ static void pci_proxy_dev_realize(PCIDevice *device, Error **errp) dev->sync = REMOTE_MEM_SYNC(object_new(TYPE_MEMORY_LISTENER)); configure_memory_sync(dev->sync, dev->proxy_link); + dev->set_remote_opts = set_remote_opts; + dev->proxy_ready = proxy_ready; - setup_irqfd(dev); } 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 55160b0..6b61bb7 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -28,6 +28,8 @@ #include "io/proxy-link.h" #include "hw/proxy/memory-sync.h" #include "qemu/event_notifier.h" +#include "hw/pci/pci.h" +#include "block/qdict.h" #define TYPE_PCI_PROXY_DEV "pci-proxy-dev" diff --git a/include/io/proxy-link.h b/include/io/proxy-link.h index ce2fcc3..21d63cc 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,