Re: [PATCH v8 2/4] virtio-blk: add zoned storage emulation for zoned devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23/03/2023 06.28, Sam Li wrote:
This patch extends virtio-blk emulation to handle zoned device commands
by calling the new block layer APIs to perform zoned device I/O on
behalf of the guest. It supports Report Zone, four zone oparations (open,
close, finish, reset), and Append Zone.

The VIRTIO_BLK_F_ZONED feature bit will only be set if the host does
support zoned block devices. Regular block devices(conventional zones)
will not be set.

The guest os can use blktests, fio to test those commands on zoned devices.
Furthermore, using zonefs to test zone append write is also supported.

Signed-off-by: Sam Li <faithilikerun@xxxxxxxxx>
---
  hw/block/virtio-blk-common.c |   2 +
  hw/block/virtio-blk.c        | 389 +++++++++++++++++++++++++++++++++++
  2 files changed, 391 insertions(+)

diff --git a/hw/block/virtio-blk-common.c b/hw/block/virtio-blk-common.c
index ac52d7c176..e2f8e2f6da 100644
--- a/hw/block/virtio-blk-common.c
+++ b/hw/block/virtio-blk-common.c
@@ -29,6 +29,8 @@ static const VirtIOFeature feature_sizes[] = {
       .end = endof(struct virtio_blk_config, discard_sector_alignment)},
      {.flags = 1ULL << VIRTIO_BLK_F_WRITE_ZEROES,
       .end = endof(struct virtio_blk_config, write_zeroes_may_unmap)},
+    {.flags = 1ULL << VIRTIO_BLK_F_ZONED,
+     .end = endof(struct virtio_blk_config, zoned)},
      {}
  };

I used the qemu monitor to expect the state of the devices, and on the zoned block device specific entries, the zoned device feature shows up in the "unknown-features" field (info virtio-status <device>)

What is missing is an entry in the blk_feature_map structure within hw/virtio/virtio-qmp.c. The below fixes it up.

diff --git i/hw/virtio/virtio-qmp.c w/hw/virtio/virtio-qmp.c
index b70148aba9..3efa529bab 100644
--- i/hw/virtio/virtio-qmp.c
+++ w/hw/virtio/virtio-qmp.c
@@ -176,6 +176,8 @@ static const qmp_virtio_feature_map_t virtio_blk_feature_map[] = {
             "VIRTIO_BLK_F_DISCARD: Discard command supported"),
     FEATURE_ENTRY(VIRTIO_BLK_F_WRITE_ZEROES, \
             "VIRTIO_BLK_F_WRITE_ZEROES: Write zeroes command supported"),
+    FEATURE_ENTRY(VIRTIO_BLK_F_ZONED, \
+            "VIRTIO_BLK_F_ZONED: Zoned block device"),
 #ifndef VIRTIO_BLK_NO_LEGACY
     FEATURE_ENTRY(VIRTIO_BLK_F_BARRIER, \
             "VIRTIO_BLK_F_BARRIER: Request barriers supported"),

Which then lets qemu report the support like this:

(qemu) info virtio-status /machine/peripheral/virtblk0/virtio-backend
/machine/peripheral/virtblk0/virtio-backend:
  device_name:             virtio-blk
  device_id:               2
  vhost_started:           false
  bus_name:                (null)
  broken:                  false
  disabled:                false
  disable_legacy_check:    false
  started:                 true
  use_started:             true
  start_on_kick:           false
  use_guest_notifier_mask: true
  vm_running:              true
  num_vqs:                 4
  queue_sel:               3
  isr:                     1
  endianness:              little
  status:
        VIRTIO_CONFIG_S_ACKNOWLEDGE: Valid virtio device found,
        VIRTIO_CONFIG_S_DRIVER: Guest OS compatible with device,
        VIRTIO_CONFIG_S_FEATURES_OK: Feature negotiation complete,
        VIRTIO_CONFIG_S_DRIVER_OK: Driver setup and ready
  Guest features:
        VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled,
        VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported,
        VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy)
        VIRTIO_BLK_F_CONFIG_WCE: Cache writeback and ...,
        VIRTIO_BLK_F_FLUSH: Flush command supported,
        VIRTIO_BLK_F_ZONED: Zoned block device,
        VIRTIO_BLK_F_WRITE_ZEROES: Write zeroes command supported,
        VIRTIO_BLK_F_MQ: Multiqueue supported,
        VIRTIO_BLK_F_TOPOLOGY: Topology information available,
        VIRTIO_BLK_F_BLK_SIZE: Block size of disk available,
        VIRTIO_BLK_F_GEOMETRY: Legacy geometry available,
        VIRTIO_BLK_F_SEG_MAX: Max segments in a request is seg_max
  unknown-features(0x0000010000000000)
  Host features:
        VIRTIO_RING_F_EVENT_IDX: Used & avail. event fields enabled,
        VIRTIO_RING_F_INDIRECT_DESC: Indirect descriptors supported,
        VIRTIO_F_VERSION_1: Device compliant for v1 spec (legacy),
        VIRTIO_F_ANY_LAYOUT: Device accepts arbitrary desc. layouts,
        VIRTIO_F_NOTIFY_ON_EMPTY: Notify when device ...,
        VHOST_USER_F_PROTOCOL_FEATURES: Vhost-user protocol ...,
        VIRTIO_BLK_F_CONFIG_WCE: Cache writeback and w...,
        VIRTIO_BLK_F_FLUSH: Flush command supported,
        VIRTIO_BLK_F_ZONED: Zoned block device,
        VIRTIO_BLK_F_WRITE_ZEROES: Write zeroes command supported,
        VIRTIO_BLK_F_MQ: Multiqueue supported,
        VIRTIO_BLK_F_TOPOLOGY: Topology information available,
        VIRTIO_BLK_F_BLK_SIZE: Block size of disk available,
        VIRTIO_BLK_F_GEOMETRY: Legacy geometry available,
        VIRTIO_BLK_F_SEG_MAX: Max segments in a request is seg_max
  unknown-features(0x0000010000000000)
  Backend features:

Cheers, Matias



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux