All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: qemu-devel@nongnu.org,
	Pierrick Bouvier <pierrick.bouvier@linaro.org>,
	 Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
	 "open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: Re: [PATCH] qemu-nbd: Support -s and -l at the same time
Date: Tue, 6 Oct 2026 11:18:08 -0500	[thread overview]
Message-ID: <asUeiDNcvRf0VGy9@redhat.com> (raw)
In-Reply-To: <fa352330-32a8-4491-b045-812eb8a05966@yandex-team.ru>

[checking through my old branches]

On Wed, Apr 08, 2026 at 11:03:31AM +0300, Vladimir Sementsov-Ogievskiy wrote:
> On 08.04.26 05:16, Eric Blake wrote:
> > qemu-nbd already has the ability to wrap a read-write layer on top of
> > the export of a read-only image (-s) and the ability to export an
> > internal snapshot rather than the main image in a qcow2 file (-l
> > SNAPID).  But it gave a confusing error message when trying to mix the
> > two, because the snapshot overlay created first no longer has access
> > to the internal snapshots of the image being wrapped.
> > 
> > WIth a bit of finesse, this useful scenario is now supported.
> > 
> > https://gitlab.com/qemu-project/qemu/-/work_items/159
> > 
> > Signed-off-by: Eric Blake <eblake@redhat.com>
> 
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> 
> Some optional suggestions below:
> 
> > +
> > +echo
> > +echo "=== Main image in snapshot mode ==="
> > +echo
> > +
> > +nbd_server_start_unix_socket -s -f qcow2 "$TEST_IMG"
> > +$QEMU_IO -c 'r -P 2 3M 1M' -c 'w -P 3 3M 1M' -f raw \
> 
> Maybe, add read command after write, to check write correctness. [*]

Good idea.

> 
> > +  nbd:unix:$nbd_unix_socket | _filter_qemu_io
> > +nbd_server_stop
> > +
> > +echo
> > +echo "=== Read-only snapshot access ==="
> > +echo
> > +
> > +nbd_server_start_unix_socket -l snap -f qcow2 "$TEST_IMG"
> > +$QEMU_IO -r -c 'r -P 1 3M 1M' -f raw \
> 
> Suggest, add write command, to check that it fails.

qemu-io rejects attempts to do -c 'w ...' on a read-only connection,
but it is a good idea to prove that qemu-io won't connect read-write
to a read-only server.

I'm queueing this patch with the following squashed in.

diff --git i/tests/qemu-iotests/tests/qemu-nbd-snapshots w/tests/qemu-iotests/tests/qemu-nbd-snapshots
index de405e43720..5bc7a1a5d23 100755
--- i/tests/qemu-iotests/tests/qemu-nbd-snapshots
+++ w/tests/qemu-iotests/tests/qemu-nbd-snapshots
@@ -45,7 +45,7 @@ echo "=== Main image in snapshot mode ==="
 echo

 nbd_server_start_unix_socket -s -f qcow2 "$TEST_IMG"
-$QEMU_IO -c 'r -P 2 3M 1M' -c 'w -P 3 3M 1M' -f raw \
+$QEMU_IO -c 'r -P 2 3M 1M' -c 'w -P 3 3M 1M' -c 'r -P 3 3M 1M' -f raw \
   nbd:unix:$nbd_unix_socket | _filter_qemu_io
 nbd_server_stop

@@ -56,6 +56,9 @@ echo
 nbd_server_start_unix_socket -l snap -f qcow2 "$TEST_IMG"
 $QEMU_IO -r -c 'r -P 1 3M 1M' -f raw \
   nbd:unix:$nbd_unix_socket | _filter_qemu_io
+$QEMU_IO -c 'r -P 1 3M 1M' -f raw \
+  nbd:unix:$nbd_unix_socket 2>&1 | _filter_qemu_io | _filter_testdir
+
 nbd_server_stop

 echo
@@ -63,7 +66,7 @@ echo "=== Combine -s and -l for read-write internal snapshot access ==="
 echo

 nbd_server_start_unix_socket -s -l snap -f qcow2 "$TEST_IMG"
-$QEMU_IO -c 'r -P 1 3M 1M' -c 'w -P 3 3M 1M' -f raw \
+$QEMU_IO -c 'r -P 1 3M 1M' -c 'w -P 3 3M 1M' -c 'r -P 3 3M 1M' -f raw \
   nbd:unix:$nbd_unix_socket | _filter_qemu_io
 nbd_server_stop

diff --git i/tests/qemu-iotests/tests/qemu-nbd-snapshots.out w/tests/qemu-iotests/tests/qemu-nbd-snapshots.out
index 6bce9d90253..47289c30f1d 100644
--- i/tests/qemu-iotests/tests/qemu-nbd-snapshots.out
+++ w/tests/qemu-iotests/tests/qemu-nbd-snapshots.out
@@ -14,11 +14,14 @@ read 1048576/1048576 bytes at offset 3145728
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 1048576/1048576 bytes at offset 3145728
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 1048576/1048576 bytes at offset 3145728
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)

 === Read-only snapshot access ===

 read 1048576/1048576 bytes at offset 3145728
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+qemu-io: can't open device nbd:unix:SOCK_DIR/qemu-nbd.sock: Could not open image: Permission denied

 === Combine -s and -l for read-write internal snapshot access ===

@@ -26,6 +29,8 @@ read 1048576/1048576 bytes at offset 3145728
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 wrote 1048576/1048576 bytes at offset 3145728
 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 1048576/1048576 bytes at offset 3145728
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)

 === Check that original image is unchanged ===


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org



  reply	other threads:[~2026-10-07  8:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08  2:16 [PATCH] qemu-nbd: Support -s and -l at the same time Eric Blake
2026-04-08  8:03 ` Vladimir Sementsov-Ogievskiy
2026-10-06 16:18   ` Eric Blake [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-04-07 21:36 Eric Blake

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=asUeiDNcvRf0VGy9@redhat.com \
    --to=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@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.