From nobody Mon Feb 9 11:07:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1571916004; cv=none; d=zoho.com; s=zohoarc; b=N4rFJDFp7CIFTMi7xyQBSUS1Lr11hLfsMj00VhXh+KKTpGoFr+ZTZ8gIiTHoOSPq4JWzm/TAZ5XEZCxa9UAqCwDuoOmKwHO+EvkLZi2iLQzHtCbZ4KTfVznpB1wjMmUuA9DLFhZ3mcVzHERlK6g+dl+jU+inX5dR1WU0GW7aVp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571916004; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=gCWsykrT2ZYwtnVJc3JGpccSZ6Ixl2ZrCx98KSbpob0=; b=QhBwQjQQKyau2WWEIZQ321VHme3XCXc9r4Mh70Og2UnlZX3V3xxD2bTMubxGKQggLWkuhyqElBKivKkuvfK0MwCKfePDEbIvwDDPNrk+Qy+q72QfwbEW7tx9jiVcKpkrEjjXhND1MUBtKnDX1Plba5atKctjv8BG22/zAc08yy8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1571916004117384.0014362657322; Thu, 24 Oct 2019 04:20:04 -0700 (PDT) Received: from localhost ([::1]:36790 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNZYW-0003nV-9u for importer@patchew.org; Thu, 24 Oct 2019 05:37:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44278) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNZAA-0001FK-Jk for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:12:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNZA9-00058N-3q for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:12:10 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:33766) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iNZA8-00057q-Rw for qemu-devel@nongnu.org; Thu, 24 Oct 2019 05:12:09 -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 x9O94MZM094876; Thu, 24 Oct 2019 09:12:03 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2vqu4r24u0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 09:12: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 x9O97jeA170529; Thu, 24 Oct 2019 09:12:03 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 2vtsk489s5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Oct 2019 09:12:02 +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 x9O9C11F024604; Thu, 24 Oct 2019 09:12:01 GMT Received: from jaraman-bur-1.us.oracle.com (/10.152.33.39) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 Oct 2019 02:12:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=corp-2019-08-05; bh=gCWsykrT2ZYwtnVJc3JGpccSZ6Ixl2ZrCx98KSbpob0=; b=T7ipIBkPDjTApC0Ir+dPxrP0oYEqzLyBNE2Rr9bCHxp1Hq+DF6GSc9gyCaWZ0D4TFKj2 7Q/rq7WPmteWmnGSVRjfzf4GGSMUuon5Mfb+YwggZugRuO5rrmzebnx5ngE9zBvNHvap V9jvF5C0rn3n0k/iZBVM/x0wBg2AHeNia1QUigA45yiR7sOdZixutwaXhkpOWOWDa4bx QjVvbKjHULXPfN2GK6Pg3cW4Il78hMtIIMigNk47Psry+e2eFfHa7MhylV6luuCEMHk9 TMz/qPRec3omKJaJvuyM+BqsA+0AKUU/Cg/Q32FWCxZYSi6O80NpwXAJQdrcQevMEq/R wQ== From: Jagannathan Raman To: qemu-devel@nongnu.org Subject: [RFC v4 PATCH 47/49] multi-process: Enable support for multiple devices in remote Date: Thu, 24 Oct 2019 05:09:28 -0400 Message-Id: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 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-1908290000 definitions=main-1910240089 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9419 signatures=668684 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-1908290000 definitions=main-1910240089 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.85 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: elena.ufimtseva@oracle.com, fam@euphon.net, john.g.johnson@oracle.com, kraxel@redhat.com, jag.raman@oracle.com, quintela@redhat.com, mst@redhat.com, armbru@redhat.com, kanth.ghatraju@oracle.com, thuth@redhat.com, ehabkost@redhat.com, konrad.wilk@oracle.com, dgilbert@redhat.com, liran.alon@oracle.com, stefanha@redhat.com, rth@twiddle.net, kwolf@redhat.com, berrange@redhat.com, mreitz@redhat.com, ross.lagerwall@citrix.com, marcandre.lureau@gmail.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @oracle.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Elena Ufimtseva Add support to allow multiple devices to be configured in the remote process Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman --- New patch in v4 hw/proxy/qemu-proxy.c | 3 +++ include/hw/proxy/qemu-proxy.h | 3 +++ include/io/mpqemu-link.h | 1 + qdev-monitor.c | 2 ++ remote/remote-main.c | 34 ++++++++++++++++++++++++---------- 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/hw/proxy/qemu-proxy.c b/hw/proxy/qemu-proxy.c index eff299b..2231c36 100644 --- a/hw/proxy/qemu-proxy.c +++ b/hw/proxy/qemu-proxy.c @@ -176,6 +176,7 @@ static void set_remote_opts(PCIDevice *dev, QDict *qdic= t, unsigned int cmd) msg.bytestream =3D 1; msg.size =3D qstring_get_length(qstr) + 1; msg.num_fds =3D 0; + msg.id =3D pdev->id; =20 mpqemu_msg_send(pdev->mpqemu_link, &msg, pdev->mpqemu_link->com); =20 @@ -322,6 +323,7 @@ static int config_op_send(PCIProxyDev *dev, uint32_t ad= dr, uint32_t *val, int l, msg.size =3D sizeof(conf_data); msg.cmd =3D op; msg.bytestream =3D 1; + msg.id =3D dev->id; =20 if (op =3D=3D CONF_WRITE) { msg.num_fds =3D 0; @@ -602,6 +604,7 @@ static void setup_irqfd(PCIProxyDev *dev) =20 memset(&msg, 0, sizeof(MPQemuMsg)); msg.cmd =3D SET_IRQFD; + msg.id =3D dev->id; msg.num_fds =3D 2; msg.fds[0] =3D event_notifier_get_fd(&dev->intr); msg.fds[1] =3D event_notifier_get_fd(&dev->resample); diff --git a/include/hw/proxy/qemu-proxy.h b/include/hw/proxy/qemu-proxy.h index 7fe987d..6a0a574 100644 --- a/include/hw/proxy/qemu-proxy.h +++ b/include/hw/proxy/qemu-proxy.h @@ -57,6 +57,9 @@ extern const MemoryRegionOps proxy_default_ops; struct PCIProxyDev { PCIDevice parent_dev; =20 + uint64_t id; + uint64_t nr_devices; + int n_mr_sections; MemoryRegionSection *mr_sections; =20 diff --git a/include/io/mpqemu-link.h b/include/io/mpqemu-link.h index f5a0bbb..ba81515 100644 --- a/include/io/mpqemu-link.h +++ b/include/io/mpqemu-link.h @@ -124,6 +124,7 @@ typedef struct { typedef struct { mpqemu_cmd_t cmd; int bytestream; + uint64_t id; size_t size; =20 union { diff --git a/qdev-monitor.c b/qdev-monitor.c index c6aa35c..70a7a5a 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -716,9 +716,11 @@ DeviceState *qdev_proxy_add(const char *rid, const cha= r *id, char *bus, pdev->mmio_sock =3D old_pdev->mmio_sock; pdev->remote_pid =3D old_pdev->remote_pid; pdev->mem_init =3D true; + pdev->id =3D old_pdev->nr_devices++; } else { pdev->rsocket =3D managed ? rsocket : -1; pdev->socket =3D managed ? rsocket : -1; + pdev->id =3D pdev->nr_devices++; } pdev->managed =3D managed; =20 diff --git a/remote/remote-main.c b/remote/remote-main.c index 600c894..93b8500 100644 --- a/remote/remote-main.c +++ b/remote/remote-main.c @@ -85,7 +85,8 @@ =20 static MPQemuLinkState *mpqemu_link; =20 -PCIDevice *remote_pci_dev; +PCIDevice **remote_pci_devs; +uint64_t nr_devices; bool create_done; =20 static void process_config_write(MPQemuMsg *msg) @@ -93,7 +94,8 @@ static void process_config_write(MPQemuMsg *msg) struct conf_data_msg *conf =3D (struct conf_data_msg *)msg->data2; =20 qemu_mutex_lock_iothread(); - pci_default_write_config(remote_pci_dev, conf->addr, conf->val, conf->= l); + pci_default_write_config(remote_pci_devs[msg->id], conf->addr, conf->v= al, + conf->l); qemu_mutex_unlock_iothread(); } =20 @@ -106,7 +108,8 @@ static void process_config_read(MPQemuMsg *msg) wait =3D msg->fds[0]; =20 qemu_mutex_lock_iothread(); - val =3D pci_default_read_config(remote_pci_dev, conf->addr, conf->l); + val =3D pci_default_read_config(remote_pci_devs[msg->id], conf->addr, + conf->l); qemu_mutex_unlock_iothread(); =20 notify_proxy(wait, val); @@ -366,9 +369,17 @@ static int setup_device(MPQemuMsg *msg, Error **errp) qstring_get_str(qobject_to_json(QOBJECT(qdict)))); return rc; } + if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - remote_pci_dev =3D PCI_DEVICE(dev); + if (nr_devices <=3D msg->id) { + nr_devices =3D msg->id + 1; + remote_pci_devs =3D g_realloc(remote_pci_devs, + nr_devices * sizeof(PCIDevice *)); + } + + remote_pci_devs[msg->id] =3D PCI_DEVICE(dev); } + qemu_opts_del(opts); =20 return 0; @@ -489,12 +500,15 @@ static void process_msg(GIOCondition cond, MPQemuChan= nel *chan) } break; case SET_IRQFD: - process_set_irqfd_msg(remote_pci_dev, msg); - qdev_machine_creation_done(); - qemu_mutex_lock_iothread(); - qemu_run_machine_init_done_notifiers(); - qemu_mutex_unlock_iothread(); - create_done =3D true; + process_set_irqfd_msg(remote_pci_devs[msg->id], msg); + + if (!create_done) { + qdev_machine_creation_done(); + qemu_mutex_lock_iothread(); + qemu_run_machine_init_done_notifiers(); + qemu_mutex_unlock_iothread(); + create_done =3D true; + } break; case DRIVE_OPTS: if (setup_drive(msg, &err)) { --=20 1.8.3.1