From patchwork Fri Feb 16 17:29:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 10225189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F36F2602CB for ; Fri, 16 Feb 2018 17:31:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4DCD28BBF for ; Fri, 16 Feb 2018 17:31:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9AAD2961A; Fri, 16 Feb 2018 17:31: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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 89B9528BBF for ; Fri, 16 Feb 2018 17:31:01 +0000 (UTC) Received: from localhost ([::1]:43050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emjqe-0003kC-N3 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 16 Feb 2018 12:31:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43037) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emjp8-0002RT-2i for qemu-devel@nongnu.org; Fri, 16 Feb 2018 12:29:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emjp4-0007hH-UE for qemu-devel@nongnu.org; Fri, 16 Feb 2018 12:29:26 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43600 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1emjp4-0007gQ-Q1 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 12:29:22 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8F0B3402290A for ; Fri, 16 Feb 2018 17:29:19 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-44.ams2.redhat.com [10.36.112.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67DEF2024CA1; Fri, 16 Feb 2018 17:29:18 +0000 (UTC) From: Maxime Coquelin To: stefanha@redhat.com, mst@redhat.com, mlureau@redhat.com, qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 18:29:06 +0100 Message-Id: <20180216172910.8549-2-maxime.coquelin@redhat.com> In-Reply-To: <20180216172910.8549-1-maxime.coquelin@redhat.com> References: <20180216172910.8549-1-maxime.coquelin@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 16 Feb 2018 17:29:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 16 Feb 2018 17:29:19 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'maxime.coquelin@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC 1/5] vhost: send virtio device status update to the backend 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: Maxime Coquelin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a function to notify the vhost backend with virtio device status updates. Suggested-by: Stefan Hajnoczi Signed-off-by: Maxime Coquelin --- hw/virtio/vhost.c | 11 +++++++++++ include/hw/virtio/vhost-backend.h | 3 +++ include/hw/virtio/vhost.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 338e4395b7..95981e5a32 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1546,6 +1546,17 @@ void vhost_dev_set_config_notifier(struct vhost_dev *hdev, hdev->config_ops = ops; } +int vhost_dev_set_virtio_status(struct vhost_dev *hdev, uint8_t status) +{ + const VhostOps *vhost_ops = hdev->vhost_ops; + + if (vhost_ops && vhost_ops->vhost_set_virtio_status) { + return vhost_ops->vhost_set_virtio_status(hdev, status); + } + + return 0; +} + /* Host notifiers must be enabled at this point. */ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) { diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index 592254f40d..45f6b8f6c5 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -94,6 +94,8 @@ typedef int (*vhost_set_config_op)(struct vhost_dev *dev, const uint8_t *data, uint32_t flags); typedef int (*vhost_get_config_op)(struct vhost_dev *dev, uint8_t *config, uint32_t config_len); +typedef int (*vhost_set_virtio_status_op)(struct vhost_dev *dev, + uint8_t status); typedef struct VhostOps { VhostBackendType backend_type; @@ -130,6 +132,7 @@ typedef struct VhostOps { vhost_send_device_iotlb_msg_op vhost_send_device_iotlb_msg; vhost_get_config_op vhost_get_config; vhost_set_config_op vhost_set_config; + vhost_set_virtio_status_op vhost_set_virtio_status; } VhostOps; extern const VhostOps user_ops; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 1dc2d73d76..fe055b2bd5 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -121,4 +121,7 @@ int vhost_dev_set_config(struct vhost_dev *dev, const uint8_t *data, */ void vhost_dev_set_config_notifier(struct vhost_dev *dev, const VhostDevConfigOps *ops); + +int vhost_dev_set_virtio_status(struct vhost_dev *hdev, uint8_t status); + #endif