All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Daniil Tatianin <d-tatianin@yandex-team.ru>
Cc: qemu-devel@nongnu.org, mst@redhat.com,
	raphael.norwitz@nutanix.com, kwolf@redhat.com, hreitz@redhat.com,
	qemu-block@nongnu.org, yc-core@yandex-team.ru
Subject: Re: [PATCH v1 2/5] virtio-blk: move config space sizing code to virtio-blk-common
Date: Wed, 24 Aug 2022 14:13:41 -0400	[thread overview]
Message-ID: <YwZqVbnbIthrW5ov@fedora> (raw)
In-Reply-To: <20220824091837.301708-3-d-tatianin@yandex-team.ru>

[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]

On Wed, Aug 24, 2022 at 12:18:34PM +0300, Daniil Tatianin wrote:
> +size_t virtio_blk_common_get_config_size(uint64_t host_features)
> +{
> +    size_t config_size = MAX(VIRTIO_BLK_CFG_SIZE,
> +        virtio_feature_get_config_size(feature_sizes, host_features));
> +
> +    assert(config_size <= sizeof(struct virtio_blk_config));
> +    return config_size;
> +}

This logic is common to all VIRTIO devices and I think it can be moved
to virtio_feature_get_config_size(). Then
virtio_blk_common_get_config_size() is no longer necessary and the
generic virtio_feature_get_config_size() can be called directly.

The only virtio-blk common part would be the
virtio_feature_get_config_size() parameter struct that describes the
minimum and maximum config space size, as well as how the feature bits
affect the size:

  size = virtio_feature_get_config_size(virtio_blk_config_size_params, host_features)

where virtio_blk_config_size_params is:

  const VirtIOConfigSizeParams virtio_blk_config_size_params = {
      .min_size = offsetof(struct virtio_blk_config, max_discard_sectors),
      .max_size = sizeof(struct virtio_blk_config),
      .features = {
          {.flags = 1ULL << VIRTIO_BLK_F_DISCARD,
           .end = endof(struct virtio_blk_config, discard_sector_alignment)},
          ...,
      },
  };

Then virtio-blk-common.h just needs to define:

  extern const VirtIOConfigSizeParams virtio_blk_config_size_params;

Taking it one step further, maybe VirtioDeviceClass should include a
const VirtIOConfigSizeParams *config_size_params field so
vdev->config_size can be computed by common VIRTIO code and the devices
only need to describe the parameters.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-08-24 18:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24  9:18 [PATCH v1 0/5] vhost-user-blk: dynamically resize config space based on features Daniil Tatianin
2022-08-24  9:18 ` [PATCH v1 1/5] virtio-blk: decouple config size determination code from VirtIOBlock Daniil Tatianin
2022-08-24  9:18 ` [PATCH v1 2/5] virtio-blk: move config space sizing code to virtio-blk-common Daniil Tatianin
2022-08-24 18:13   ` Stefan Hajnoczi [this message]
2022-08-24 21:11     ` Daniil Tatianin
2022-08-25 13:45       ` Stefan Hajnoczi
2022-08-24  9:18 ` [PATCH v1 3/5] vhost-user-blk: make it possible to disable write-zeroes/discard Daniil Tatianin
2022-08-24 18:00   ` Stefan Hajnoczi
2022-08-24 20:24     ` Daniil Tatianin
2022-08-25 13:34       ` Stefan Hajnoczi
2022-08-24  9:18 ` [PATCH v1 4/5] vhost-user-blk: make 'config_wce' part of 'host_features' Daniil Tatianin
2022-08-24 18:01   ` Stefan Hajnoczi
2022-08-24  9:18 ` [PATCH v1 5/5] vhost-user-blk: dynamically resize config space based on features Daniil Tatianin
2022-08-24 18:28   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YwZqVbnbIthrW5ov@fedora \
    --to=stefanha@redhat.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=yc-core@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.