From nobody Wed Dec 17 21:51:51 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612950122; cv=none; d=zohomail.com; s=zohoarc; b=RWwDYC9ST7YPLqLUkNAK1HZwDCJgQ/RDjcDPYfVI8Ds7Oq+4HGGJzS2ZE9Ve3pmGzZFBnA+XmIxudIqGFU7NXDFJeIUdxaU0BthRuJFGtBx/ScG/8zjikoYy5DUw4R7bh010sZ6d2hXNLHwo8vISK82TSy8mpu18fDCKmv4TPeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612950122; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kC6xi6m39FXqeRA66AyLL0LKhHsR4nPB2jXX26aU2Ns=; b=DJOS5KatvcJ8jSEO7+sdOcvnjVjcpNzZxq88eh7seHaez8M1CUczshrvE2ZoCs/t1IlqQt4Df6bRBL/wahRetfBZNujRUiEf3sJzoZE/Fzif2ZmJ6pVqTmWo1GuHMlgVFARNzHYX0z7XRNQDnza/l9LvDzmCNj3Qa+aUeW4g8KM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612950122113442.3625062788972; Wed, 10 Feb 2021 01:42:02 -0800 (PST) Received: from localhost ([::1]:41778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9m0W-0007sH-UC for importer@patchew.org; Wed, 10 Feb 2021 04:42:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9loa-0005X5-Vd for qemu-devel@nongnu.org; Wed, 10 Feb 2021 04:29:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9loY-00075k-Vw for qemu-devel@nongnu.org; Wed, 10 Feb 2021 04:29:40 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-pGFBC4SOPZmNUMBitZ9-dw-1; Wed, 10 Feb 2021 04:29:36 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 95004C73A0; Wed, 10 Feb 2021 09:29:34 +0000 (UTC) Received: from localhost (ovpn-115-120.ams2.redhat.com [10.36.115.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id B03886268D; Wed, 10 Feb 2021 09:29:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612949378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kC6xi6m39FXqeRA66AyLL0LKhHsR4nPB2jXX26aU2Ns=; b=WWVzebxm0w9bHuU6JMpPdr5pqLHs7Ir7D43ctKgvDDzfnpQCLhwdqlHyctEY1kJIfE/7g6 z1R0lb0FFEWvzyg9/bWXGrJr5wj8L18QYfDMSFObUdXJHTSJ+WOKD94ULr+hRmS73y/VTl MIqz46RltyvzVsABuiwitT5QzxSXFnA= X-MC-Unique: pGFBC4SOPZmNUMBitZ9-dw-1 From: Stefan Hajnoczi To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL v4 16/27] multi-process: Initialize message handler in remote device Date: Wed, 10 Feb 2021 09:26:17 +0000 Message-Id: <20210210092628.193785-17-stefanha@redhat.com> In-Reply-To: <20210210092628.193785-1-stefanha@redhat.com> References: <20210210092628.193785-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=stefanha@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: Fam Zheng , John G Johnson , thuth@redhat.com, Jagannathan Raman , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , "Denis V. Lunev" , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Wainer dos Santos Moschetta , Elena Ufimtseva , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Jagannathan Raman Initializes the message handler function in the remote process. It is called whenever there's an event pending on QIOChannel that registers this function. Signed-off-by: Elena Ufimtseva Signed-off-by: John G Johnson Signed-off-by: Jagannathan Raman Reviewed-by: Stefan Hajnoczi Message-id: 99d38d8b93753a6409ac2340e858858cda59ab1b.1611938319.git.jag.ram= an@oracle.com Signed-off-by: Stefan Hajnoczi --- MAINTAINERS | 1 + include/hw/remote/machine.h | 9 ++++++ hw/remote/message.c | 57 +++++++++++++++++++++++++++++++++++++ hw/remote/meson.build | 1 + 4 files changed, 68 insertions(+) create mode 100644 hw/remote/message.c diff --git a/MAINTAINERS b/MAINTAINERS index 389693f59a..8d2693525c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3213,6 +3213,7 @@ F: hw/remote/machine.c F: include/hw/remote/machine.h F: hw/remote/mpqemu-link.c F: include/hw/remote/mpqemu-link.h +F: hw/remote/message.c =20 Build and test automation ------------------------- diff --git a/include/hw/remote/machine.h b/include/hw/remote/machine.h index bdfbca40b9..b92b2ce705 100644 --- a/include/hw/remote/machine.h +++ b/include/hw/remote/machine.h @@ -14,6 +14,7 @@ #include "qom/object.h" #include "hw/boards.h" #include "hw/pci-host/remote.h" +#include "io/channel.h" =20 struct RemoteMachineState { MachineState parent_obj; @@ -21,7 +22,15 @@ struct RemoteMachineState { RemotePCIHost *host; }; =20 +/* Used to pass to co-routine device and ioc. */ +typedef struct RemoteCommDev { + PCIDevice *dev; + QIOChannel *ioc; +} RemoteCommDev; + #define TYPE_REMOTE_MACHINE "x-remote-machine" OBJECT_DECLARE_SIMPLE_TYPE(RemoteMachineState, REMOTE_MACHINE) =20 +void coroutine_fn mpqemu_remote_msg_loop_co(void *data); + #endif diff --git a/hw/remote/message.c b/hw/remote/message.c new file mode 100644 index 0000000000..36e2d4fb0c --- /dev/null +++ b/hw/remote/message.c @@ -0,0 +1,57 @@ +/* + * Copyright =C2=A9 2020, 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL-v2, version 2 or l= ater. + * + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu-common.h" + +#include "hw/remote/machine.h" +#include "io/channel.h" +#include "hw/remote/mpqemu-link.h" +#include "qapi/error.h" +#include "sysemu/runstate.h" + +void coroutine_fn mpqemu_remote_msg_loop_co(void *data) +{ + g_autofree RemoteCommDev *com =3D (RemoteCommDev *)data; + PCIDevice *pci_dev =3D NULL; + Error *local_err =3D NULL; + + assert(com->ioc); + + pci_dev =3D com->dev; + for (; !local_err;) { + MPQemuMsg msg =3D {0}; + + if (!mpqemu_msg_recv(&msg, com->ioc, &local_err)) { + break; + } + + if (!mpqemu_msg_valid(&msg)) { + error_setg(&local_err, "Received invalid message from proxy" + "in remote process pid=3D"FMT_pid"", + getpid()); + break; + } + + switch (msg.cmd) { + default: + error_setg(&local_err, + "Unknown command (%d) received for device %s" + " (pid=3D"FMT_pid")", + msg.cmd, DEVICE(pci_dev)->id, getpid()); + } + } + + if (local_err) { + error_report_err(local_err); + qemu_system_shutdown_request(SHUTDOWN_CAUSE_HOST_ERROR); + } else { + qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN); + } +} diff --git a/hw/remote/meson.build b/hw/remote/meson.build index a2b2fc0e59..9f5c57f35a 100644 --- a/hw/remote/meson.build +++ b/hw/remote/meson.build @@ -2,5 +2,6 @@ remote_ss =3D ss.source_set() =20 remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('machine.c')) remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('mpqemu-link.c')) +remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('message.c')) =20 softmmu_ss.add_all(when: 'CONFIG_MULTIPROCESS', if_true: remote_ss) --=20 2.29.2