From nobody Mon May 5 22:12:15 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; 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=redhat.com Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549864630869476.9184966127975; Sun, 10 Feb 2019 21:57:10 -0800 (PST) Received: from localhost ([127.0.0.1]:44991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+importer=patchew.org@nongnu.org>) id 1gt4ab-0006Pw-PR for importer@patchew.org; Mon, 11 Feb 2019 00:57:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <stefanha@redhat.com>) id 1gt4VD-0002EU-Cu for qemu-devel@nongnu.org; Mon, 11 Feb 2019 00:51:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <stefanha@redhat.com>) id 1gt4VB-0002nj-Gw for qemu-devel@nongnu.org; Mon, 11 Feb 2019 00:51:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55710) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <stefanha@redhat.com>) id 1gt4Uz-0002jS-9a; Mon, 11 Feb 2019 00:51:22 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64C4936807; Mon, 11 Feb 2019 05:51:19 +0000 (UTC) Received: from localhost (unknown [10.64.242.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5314010E81CD; Mon, 11 Feb 2019 05:51:14 +0000 (UTC) From: Stefan Hajnoczi <stefanha@redhat.com> To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2019 13:50:36 +0800 Message-Id: <20190211055040.13528-6-stefanha@redhat.com> In-Reply-To: <20190211055040.13528-1-stefanha@redhat.com> References: <20190211055040.13528-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 11 Feb 2019 05:51:19 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/9] virtio-blk: add host_features field in VirtIOBlock X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: Laurent Vivier <lvivier@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Thomas Huth <thuth@redhat.com>, qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>, Pankaj Gupta <pagupta@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, Max Reitz <mreitz@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Eduardo Habkost <ehabkost@redhat.com> Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+importer=patchew.org@nongnu.org> Content-Type: text/plain; charset="utf-8" From: Stefano Garzarella <sgarzare@redhat.com> Since configurable features for virtio-blk are growing, this patch adds host_features field in the struct VirtIOBlock. (as in virtio-net) In this way, we can avoid to add new fields for new properties and we can directly set VIRTIO_BLK_F* flags in the host_features. We update "config-wce" and "scsi" property definition to use the new host_features field without change the behaviour. Suggested-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Acked-by: Pankaj Gupta <pagupta@redhat.com> Message-id: 20190208134950.187665-3-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> --- include/hw/virtio/virtio-blk.h | 3 +-- hw/block/virtio-blk.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/hw/virtio/virtio-blk.h b/include/hw/virtio/virtio-blk.h index 5117431d96..f7345b0511 100644 --- a/include/hw/virtio/virtio-blk.h +++ b/include/hw/virtio/virtio-blk.h @@ -35,8 +35,6 @@ struct VirtIOBlkConf BlockConf conf; IOThread *iothread; char *serial; - uint32_t scsi; - uint32_t config_wce; uint32_t request_merging; uint16_t num_queues; uint16_t queue_size; @@ -57,6 +55,7 @@ typedef struct VirtIOBlock { bool dataplane_disabled; bool dataplane_started; struct VirtIOBlockDataPlane *dataplane; + uint64_t host_features; } VirtIOBlock; =20 typedef struct VirtIOBlockReq { diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index c95a6f4c9b..6526b94910 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -241,7 +241,7 @@ static int virtio_blk_handle_scsi_req(VirtIOBlockReq *r= eq) */ scsi =3D (void *)elem->in_sg[elem->in_num - 2].iov_base; =20 - if (!blk->conf.scsi) { + if (!virtio_has_feature(blk->host_features, VIRTIO_BLK_F_SCSI)) { status =3D VIRTIO_BLK_S_UNSUPP; goto fail; } @@ -779,12 +779,15 @@ static uint64_t virtio_blk_get_features(VirtIODevice = *vdev, uint64_t features, { VirtIOBlock *s =3D VIRTIO_BLK(vdev); =20 + /* Firstly sync all virtio-blk possible supported features */ + features |=3D s->host_features; + virtio_add_feature(&features, VIRTIO_BLK_F_SEG_MAX); virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY); virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY); virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE); if (virtio_has_feature(features, VIRTIO_F_VERSION_1)) { - if (s->conf.scsi) { + if (virtio_has_feature(s->host_features, VIRTIO_BLK_F_SCSI)) { error_setg(errp, "Please set scsi=3Doff for virtio-blk devices= in order to use virtio 1.0"); return 0; } @@ -793,9 +796,6 @@ static uint64_t virtio_blk_get_features(VirtIODevice *v= dev, uint64_t features, virtio_add_feature(&features, VIRTIO_BLK_F_SCSI); } =20 - if (s->conf.config_wce) { - virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE); - } if (blk_enable_write_cache(s->blk)) { virtio_add_feature(&features, VIRTIO_BLK_F_WCE); } @@ -1010,9 +1010,11 @@ static Property virtio_blk_properties[] =3D { DEFINE_BLOCK_ERROR_PROPERTIES(VirtIOBlock, conf.conf), DEFINE_BLOCK_CHS_PROPERTIES(VirtIOBlock, conf.conf), DEFINE_PROP_STRING("serial", VirtIOBlock, conf.serial), - DEFINE_PROP_BIT("config-wce", VirtIOBlock, conf.config_wce, 0, true), + DEFINE_PROP_BIT64("config-wce", VirtIOBlock, host_features, + VIRTIO_BLK_F_CONFIG_WCE, true), #ifdef __linux__ - DEFINE_PROP_BIT("scsi", VirtIOBlock, conf.scsi, 0, false), + DEFINE_PROP_BIT64("scsi", VirtIOBlock, host_features, + VIRTIO_BLK_F_SCSI, false), #endif DEFINE_PROP_BIT("request-merging", VirtIOBlock, conf.request_merging, = 0, true), --=20 2.20.1