All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: qemu-devel@nongnu.org
Cc: Niklas Cassel <cassel@kernel.org>,
	dlemoal@kernel.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Hanna Reitz <hreitz@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Eric Blake <eblake@redhat.com>,
	qemu-block@nongnu.org, Sam Li <faithilikerun@gmail.com>
Subject: [PATCH v15 0/7] Add full zoned storage emulation to the qcow2 driver
Date: Mon, 26 Oct 2026 13:12:48 +0100	[thread overview]
Message-ID: <20261026121259.3354561-1-cassel@kernel.org> (raw)

This patch series adds a new extension - zoned format - to the
qcow2 driver, allowing full zoned storage emulation on a qcow2
image file. A user can attach such an image to a guest and have
it appear as a host-managed zoned block device.

The zoned format is opt-in through a new qcow2 header extension
that pins the zone geometry. Behind the extension is a dedicated
zoned metadata region that stores one 8-byte write pointer (WP)
per zone. The extension is gated by an incompatible bit, so an
older qcow2 implementation cannot accidentally open the image.

Each write pointer is routed through the write pointer cache,
a Qcow2Cache object. The write pointer cache is written to disk
after the qcow2 metadata is written, thus guaranteeing that
the write pointer is updated after the corresponding data is
written.

Zone states are in memory. Read-only and offline states are
device-internal events, which are not modelled in qcow2
emulation for simplicity. The other zone states
(closed, empty, full) can be inferred from write pointer
values, persistent across QEMU reboots. The open states are
kept in memory using open zone lists.

To create a qcow2 file with the zoned format:

    qemu-img create -f qcow2 zbc.qcow2 \
        -o size=768M \
        -o zone.size=64M \
        -o zone.capacity=64M \
        -o zone.conventional_zones=0 \
        -o zone.max_open_zones=6 \
        -o zone.max_active_zones=8 \
        -o zone.mode=host-managed

Then attach it to a guest via the QEMU command line:
    -blockdev node-name=drive1,driver=qcow2,file.driver=file,file.filename=zbc.qcow2 \
    -device virtio-blk-pci,drive=drive1 \

Tested with blktests, fio, zbd_state (an internal test suite) and
zonefs, comparing a zoned qcow2 image attached via virtio-blk with
zloop, null_blk and scsi_debug (passed/failed/skipped):

    +--------------------+----------+---------+-----------+---------+
    | Testrun            | blktests | fio     | zbd_state | zonefs  |
    +--------------------+----------+---------+-----------+---------+
    | zloop              | 9/0/10   | 57/0/18 | 29/0/8    | 113/0/0 |
    | null_blk           | 9/0/10   | 57/0/18 | 29/0/8    | 113/0/0 |
    | scsi_debug         | 10/0/12  | 61/0/14 | 29/0/8    | 113/0/0 |
    | virtio-blk + qcow2 | 9/0/10   | 57/0/18 | 29/0/8    | 113/0/0 |
    +--------------------+----------+---------+-----------+---------+

This series depends on the (still not merged) series "block: fix the
zone write granularity and the zone append limit":
https://lore.kernel.org/qemu-devel/20260921142819.2916043-1-cassel@kernel.org/

Git branch which includes the dependency series can be found at:
https://github.com/floatious/qemu/tree/qcow2-v15

Based-on: <20260921142819.2916043-1-cassel@kernel.org>

v14->v15:
- rebase on the series above, which now contains the v14 patches
  "block: widen BlockLimits.zone_size to uint64_t" and "virtio-blk: do
  not merge writes across a zone boundary", and which moves the zone
  append checks to the block layer
- drop zone.max_append_bytes; zonedmeta_offset moves to bytes 24-31 of
  the zoned header extension, so images created with v14 are not
  compatible
- require a version 3 image, a zone size that is a multiple of the
  cluster size, and a zone capacity that is a multiple of the zone
  write granularity
- report zone errors with dedicated errnos (new patch) instead of EIO,
  EINVAL and EBUSY
- manage the zone resources as in NVMe ZNS (2.1.1.4.1) and ZBC-3, and
  fix OPEN ZONE of a full zone, writes that fill a closed zone, writes
  from a conventional into a sequential zone, conventional zone and
  zone capacity reporting, and a shorter last zone
- validate the zoned header extension, and the write pointer table (new
  patch), when opening an image
- account for the zoned metadata in qemu-img check
- report zone errors with their zone status codes in virtio-blk (new
  patch)
- extend the iotest with zone errors, zone resources and image checks

Niklas Cassel (3):
  block: define errnos for zone protocol errors
  qcow2: validate the write pointer table when opening an image
  virtio-blk: report zone errors with their zone status codes

Sam Li (4):
  docs/qcow2: add the zoned format feature
  qcow2: add configurations for zoned format extension
  qcow2: add zoned emulation capability
  iotests: test the zoned format feature for qcow2 file

 MAINTAINERS                                   |    1 +
 block/io.c                                    |   13 +-
 block/qcow2-cache.c                           |   11 +-
 block/qcow2-refcount.c                        |   18 +
 block/qcow2.c                                 | 1674 ++++++++++++++++-
 block/qcow2.h                                 |   86 +-
 block/trace-events                            |    2 +
 docs/interop/qcow2.rst                        |  115 +-
 docs/system/qemu-block-drivers.rst.inc        |   44 +
 hw/block/block.c                              |    7 +
 hw/block/virtio-blk.c                         |   48 +-
 include/block/block-common.h                  |   16 +
 include/block/block-io.h                      |    6 +
 include/block/block_int-common.h              |   12 +
 include/qemu/osdep.h                          |    3 +
 qapi/block-core.json                          |   86 +-
 tests/qemu-iotests/031.out                    |    8 +-
 tests/qemu-iotests/036.out                    |    4 +-
 tests/qemu-iotests/061.out                    |   14 +-
 tests/qemu-iotests/082.out                    |  108 ++
 tests/qemu-iotests/303.out                    |    4 +-
 tests/qemu-iotests/tests/qcow2-encryption.out |    4 +-
 tests/qemu-iotests/tests/zoned-qcow2          |  362 ++++
 tests/qemu-iotests/tests/zoned-qcow2.out      |  265 +++
 24 files changed, 2874 insertions(+), 37 deletions(-)
 create mode 100755 tests/qemu-iotests/tests/zoned-qcow2
 create mode 100644 tests/qemu-iotests/tests/zoned-qcow2.out

-- 
2.56.0



             reply	other threads:[~2026-10-26 12:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 12:12 Niklas Cassel [this message]
2026-10-26 12:12 ` [PATCH v15 1/7] docs/qcow2: add the zoned format feature Niklas Cassel
2026-10-26 12:12 ` [PATCH v15 2/7] qcow2: add configurations for zoned format extension Niklas Cassel
2026-10-26 12:12 ` [PATCH v15 3/7] block: define errnos for zone protocol errors Niklas Cassel
2026-10-26 12:12 ` [PATCH v15 4/7] qcow2: add zoned emulation capability Niklas Cassel
2026-10-26 12:12 ` [PATCH v15 5/7] iotests: test the zoned format feature for qcow2 file Niklas Cassel
2026-10-26 12:12 ` [PATCH v15 6/7] qcow2: validate the write pointer table when opening an image Niklas Cassel
2026-10-26 12:12 ` [PATCH v15 7/7] virtio-blk: report zone errors with their zone status codes Niklas Cassel

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=20261026121259.3354561-1-cassel@kernel.org \
    --to=cassel@kernel.org \
    --cc=armbru@redhat.com \
    --cc=dlemoal@kernel.org \
    --cc=eblake@redhat.com \
    --cc=faithilikerun@gmail.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.