From nobody Sun May 5 09:19:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1599718537; cv=none; d=zohomail.com; s=zohoarc; b=SNRgm1+mTo/Dg16otQxL+ZJMsC9Cv4wuyGN9B/viW9bdRfSGINytDePYw2/7QbeyU4ptZCk+x8r6x+4NTZcck9CWsGEvbjvDfAUBF1eyVGfM7wuE3W/sHJ5olaGGb0LgbVsWI+YUNUb5z7HLRWYSpq6vxocNUwbtz9GHNQn+anY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599718537; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=9yQtVcaMJW/WHxp2NkAXXz0qVT+Nw+OSrDXlcK9FCKY=; b=IH+yA9BdGF+DP/E63Jkjed580A7pVBtWRLurLsBP8X23CAtkkinECx9WCvo+mZkryJnkN9POJeL+GIWAuEOREo/D25DQxitUr6EGmdvCfVfNNJtYW+D6SSo67b/8snWWvspAtBmd4jNWLEY1IM5rfL3B17SNe6rNALJCkKpISJc= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 159971853707661.4426732771941; Wed, 9 Sep 2020 23:15:37 -0700 (PDT) Received: from localhost ([::1]:54450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGFrp-0008DA-RS for importer@patchew.org; Thu, 10 Sep 2020 02:15:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGFrD-0007lX-0K for qemu-devel@nongnu.org; Thu, 10 Sep 2020 02:14:55 -0400 Received: from mga06.intel.com ([134.134.136.31]:1173) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGFr9-0004bF-Tm for qemu-devel@nongnu.org; Thu, 10 Sep 2020 02:14:54 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2020 23:14:45 -0700 Received: from storage36.sh.intel.com ([10.67.111.10]) by fmsmga005.fm.intel.com with ESMTP; 09 Sep 2020 23:14:43 -0700 IronPort-SDR: BlgkQLSe2wEwYAkB4vsoJAx4Tj2o4jijndEvAYRv+3Nb/yyRXPmpEvJLbuZ7aI8hLLw66r2uCy JSKKUfXfXpKA== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="220034573" X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="220034573" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False IronPort-SDR: BTC/yktDs7aoQ/3SEde8007XchjckOVetglJhnMLk2oS5rGrt2HV+t/044qWt+NHc2Yy2FxsHy /vGpBxncqu9A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,412,1592895600"; d="scan'208";a="505724534" From: Jin Yu To: mst@redhat.com, raphael.norwitz@nutanix.com, kwolf@redhat.com, mreitz@redhat.com Subject: [PATCH] vhost-blk: set features before setting inflight feature Date: Thu, 10 Sep 2020 21:48:51 +0800 Message-Id: <20200910134851.7817-1-jin.yu@intel.com> X-Mailer: git-send-email 2.17.2 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=134.134.136.31; envelope-from=jin.yu@intel.com; helo=mga06.intel.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 02:14:45 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_FUTURE_06_12=1.947, RCVD_IN_DNSWL_MED=-2.3, 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: Jin Yu , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format. Signed-off-by: Jin Yu Acked-by: Raphael Norwitz --- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 18 ++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 25 insertions(+) diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index 39aec42dae..9e0e9ebec0 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) =20 s->dev.acked_features =3D vdev->guest_features; =20 + ret =3D vhost_dev_prepare_inflight(&s->dev); + if (ret < 0) { + error_report("Error set inflight format: %d", -ret); + goto err_guest_notifiers; + } + if (!s->inflight->addr) { ret =3D vhost_dev_get_inflight(&s->dev, s->queue_size, s->inflight= ); if (ret < 0) { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 1a1384e7a6..4027c11886 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1616,6 +1616,24 @@ int vhost_dev_load_inflight(struct vhost_inflight *i= nflight, QEMUFile *f) return 0; } =20 +int vhost_dev_prepare_inflight(struct vhost_dev *hdev) +{ + int r; +=20 + if (hdev->vhost_ops->vhost_get_inflight_fd =3D=3D NULL || + hdev->vhost_ops->vhost_set_inflight_fd =3D=3D NULL) { + return 0; + } +=20 + r =3D vhost_dev_set_features(hdev, hdev->log_enabled); + if (r < 0) { + VHOST_OPS_DEBUG("vhost_dev_prepare_inflight failed"); + return r; + } + + return 0; +} + int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 767a95ec0b..4e2fc75528 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *in= flight); void vhost_dev_free_inflight(struct vhost_inflight *inflight); void vhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f); int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f); +int vhost_dev_prepare_inflight(struct vhost_dev *hdev); int vhost_dev_set_inflight(struct vhost_dev *dev, struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, --=20 2.17.2