From nobody Sun Nov 9 16:00:47 2025 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=fail; 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=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551344389799893.1219238147736; Thu, 28 Feb 2019 00:59:49 -0800 (PST) Received: from localhost ([127.0.0.1]:34560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzHXe-00049i-Nz for importer@patchew.org; Thu, 28 Feb 2019 03:59:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzHT7-0000VH-7p for qemu-devel@nongnu.org; Thu, 28 Feb 2019 03:55:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzHT3-0004Lw-8N for qemu-devel@nongnu.org; Thu, 28 Feb 2019 03:55:05 -0500 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:34248) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gzHT1-0004KV-5M for qemu-devel@nongnu.org; Thu, 28 Feb 2019 03:55:01 -0500 Received: by mail-pg1-x541.google.com with SMTP id i130so9401663pgd.1 for ; Thu, 28 Feb 2019 00:54:57 -0800 (PST) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id p5sm14353356pfn.154.2019.02.28.00.54.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Feb 2019 00:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=slWfpnGw8tZys3H9fBrwFQqWU/09SRe8VQgxBOnTr1M=; b=bUvEOm6Gzmg4y2hSXyR/yPf2+G4APo2PxQNWnJTJFAIQT3yx/imcyyFCfOUhQgAJZr sVUP/RY4QwE77wSJGivMbWphiskBwaxhuTMPjq7Mni/PLkdK0rJSuAzN5a3NYmoOWmAh qVRcBKi+5id2xMENqJ0rJA3fXB8hQwaekp1WVSTfShdBgJazJNNupt79/OhuroRLlWFi cv92IsmaHk1vLOPTfbRYHi2OTXe7vSIAMUUBtTctfVzLF4iVj6wdFJ1eOMuCoBREoNpI 7CJ7SMsD1H35osiXNheIsLsdoXMkqhvhNPoUeXs6TAKHU8mt+tt6p2bc4Q0tcTv/ZS8e 2Syw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=slWfpnGw8tZys3H9fBrwFQqWU/09SRe8VQgxBOnTr1M=; b=i8CkZqAbdsIgvwDLkuLqdZRxLi4EjT4+iG2dN3tdFngk049KPzus0CAW5H0/5csghQ 1EGikkfC6R7xCfS5ef8ygVRtjctKoIxPdX7r4Zb6YDcdyXCFZMNEXhuaahlMnMhYq/vc yHsA+QQpNDSSQzDwsRMATRKP16ZNBZ1/D1CYQMv7acvHoxWkNexb4RyIZmCVg94YsTEW nvki/cZnxG5qdJfgCHBP8+Jadszaivb/lU3RDBAZH3G22NA6DkS1FcKGItDmR9qA0Pp2 3yGecmR30RxZArIUgEQvuk4/WpfGeArHloN4PqgwmDqS5kyac2IOAtybD6eMnkr0PtZJ nlUA== X-Gm-Message-State: AHQUAuZJiYeBtmpqq3F25rG6opBaIos378dWHJ9Mr9TqwlQwbyoX11vC /d7DRKA3kZre7jug4hGhl6U= X-Google-Smtp-Source: AHgI3IZELotzOyNp8kwHCS/EcWoDGOzFpCQoCzOrM5eqPn1HnakMtd2XbVXLAjDErPaVuB56Ng2u9g== X-Received: by 2002:a62:f51d:: with SMTP id n29mr6238572pfh.21.1551344097063; Thu, 28 Feb 2019 00:54:57 -0800 (PST) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, stefanha@gmail.com, marcandre.lureau@redhat.com, berrange@redhat.com, jasowang@redhat.com, maxime.coquelin@redhat.com, yury-kotov@yandex-team.ru, wrfsh@yandex-team.ru Date: Thu, 28 Feb 2019 16:53:53 +0800 Message-Id: <20190228085355.9614-6-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190228085355.9614-1-xieyongji@baidu.com> References: <20190228085355.9614-1-xieyongji@baidu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::541 Subject: [Qemu-devel] [PATCH v7 5/7] vhost-user-blk: Add support to get/set inflight buffer 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: nixun@baidu.com, qemu-devel@nongnu.org, lilin24@baidu.com, zhangyu31@baidu.com, chaiwen@baidu.com, Xie Yongji Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Xie Yongji This patch adds support for vhost-user-blk device to get/set inflight buffer from/to backend. Signed-off-by: Xie Yongji Signed-off-by: Zhang Yu --- hw/block/vhost-user-blk.c | 28 ++++++++++++++++++++++++++++ include/hw/virtio/vhost-user-blk.h | 1 + 2 files changed, 29 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 44ac814016..9682df1a7b 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -128,6 +128,21 @@ static void vhost_user_blk_start(VirtIODevice *vdev) } =20 s->dev.acked_features =3D vdev->guest_features; + + if (!s->inflight->addr) { + ret =3D vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight= ); + if (ret < 0) { + error_report("Error get inflight: %d", -ret); + goto err_guest_notifiers; + } + } + + ret =3D vhost_dev_set_inflight(&s->dev, s->inflight); + if (ret < 0) { + error_report("Error set inflight: %d", -ret); + goto err_guest_notifiers; + } + ret =3D vhost_dev_start(&s->dev, vdev); if (ret < 0) { error_report("Error starting vhost: %d", -ret); @@ -249,6 +264,13 @@ static void vhost_user_blk_handle_output(VirtIODevice = *vdev, VirtQueue *vq) } } =20 +static void vhost_user_blk_reset(VirtIODevice *vdev) +{ + VHostUserBlk *s =3D VHOST_USER_BLK(vdev); + + vhost_dev_free_inflight(s->inflight); +} + static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); @@ -289,6 +311,8 @@ static void vhost_user_blk_device_realize(DeviceState *= dev, Error **errp) vhost_user_blk_handle_output); } =20 + s->inflight =3D g_new0(struct vhost_inflight, 1); + s->dev.nvqs =3D s->num_queues; s->dev.vqs =3D g_new(struct vhost_virtqueue, s->dev.nvqs); s->dev.vq_index =3D 0; @@ -321,6 +345,7 @@ vhost_err: vhost_dev_cleanup(&s->dev); virtio_err: g_free(vqs); + g_free(s->inflight); virtio_cleanup(vdev); =20 vhost_user_cleanup(user); @@ -336,7 +361,9 @@ static void vhost_user_blk_device_unrealize(DeviceState= *dev, Error **errp) =20 vhost_user_blk_set_status(vdev, 0); vhost_dev_cleanup(&s->dev); + vhost_dev_free_inflight(s->inflight); g_free(vqs); + g_free(s->inflight); virtio_cleanup(vdev); =20 if (s->vhost_user) { @@ -386,6 +413,7 @@ static void vhost_user_blk_class_init(ObjectClass *klas= s, void *data) vdc->set_config =3D vhost_user_blk_set_config; vdc->get_features =3D vhost_user_blk_get_features; vdc->set_status =3D vhost_user_blk_set_status; + vdc->reset =3D vhost_user_blk_reset; } =20 static const TypeInfo vhost_user_blk_info =3D { diff --git a/include/hw/virtio/vhost-user-blk.h b/include/hw/virtio/vhost-u= ser-blk.h index d52944aeeb..445516604a 100644 --- a/include/hw/virtio/vhost-user-blk.h +++ b/include/hw/virtio/vhost-user-blk.h @@ -36,6 +36,7 @@ typedef struct VHostUserBlk { uint32_t queue_size; uint32_t config_wce; struct vhost_dev dev; + struct vhost_inflight *inflight; VhostUserState *vhost_user; } VHostUserBlk; =20 --=20 2.17.1