All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Guillaume Vincke <guillaume.vincke@ovhcloud.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	 vsementsov@yandex-team.ru, kwolf@redhat.com, hreitz@redhat.com,
	stefanha@redhat.com, fam@euphon.net
Subject: Re: [PATCH 4/5] iotests: Add coverage for NBD resize
Date: Thu, 19 Nov 2026 16:51:56 -0600	[thread overview]
Message-ID: <av98gYPX3Wsoiq7N@redhat.com> (raw)
In-Reply-To: <20261119144632.232457-5-guillaume.vincke@ovhcloud.com>

On Thu, Nov 19, 2026 at 03:46:31PM +0100, Guillaume Vincke wrote:
> Test the block_resize QMP function on an NBD device. Prior to the
> addition of bdrv_co_refresh_connection(), running block_resize on a
> node that did not process any requests between the device size
> update and the function call failed with "Cannot grow NBD nodes".
> 
> Add a test that updates an NBD node size and verifies that the
> block_resize behaves as expected. The first part configures a reconnect
> delay and asserts that the call succeeds. The second uses the default
> reconnect-delay=0 and asserts that, even though the function returns an
> error, the reconnection routine gets started and that retrying succeeds
> once the node has successfully reconnected.
> 
> Signed-off-by: Guillaume Vincke <guillaume.vincke@ovhcloud.com>
> ---
>  tests/qemu-iotests/tests/nbd-resize     | 81 +++++++++++++++++++++++++
>  tests/qemu-iotests/tests/nbd-resize.out | 24 ++++++++
>  2 files changed, 105 insertions(+)
>  create mode 100755 tests/qemu-iotests/tests/nbd-resize
>  create mode 100644 tests/qemu-iotests/tests/nbd-resize.out
> 
> diff --git a/tests/qemu-iotests/tests/nbd-resize b/tests/qemu-iotests/tests/nbd-resize
> new file mode 100755
> index 0000000000..4f305eaebf
> --- /dev/null
> +++ b/tests/qemu-iotests/tests/nbd-resize
> @@ -0,0 +1,81 @@
> +#!/usr/bin/env python3
> +# group: quick

Can this also go in the 'auto' group?

> +
> +for reconnect_delay in [10, 0]:
> +    iotests.log(f"=== Resize with reconnect-delay={reconnect_delay} ===")
> +    with iotests.VM() as vm:
> +        vm.launch()
> +
> +        iotests.qemu_img_create('-f', iotests.imgfmt, disk, '1M')
> +        with iotests.qemu_nbd_popen('-k',
> +                                    nbd_sock,
> +                                    '-f',
> +                                    iotests.imgfmt,
> +                                    disk):
> +            vm.cmd('blockdev-add', {
> +                'driver': 'nbd',
> +                'node-name': node_name,
> +                'server': { 'type': 'unix', 'path': nbd_sock },
> +                'reconnect-delay': reconnect_delay,
> +            })
> +
> +            iotests.log('Size before resize:')
> +            iotests.log(node_size(vm))
> +
> +        iotests.qemu_img('resize', '-f', iotests.imgfmt, disk, '2M')
> +        with iotests.qemu_nbd_popen('-k',
> +                                    nbd_sock,
> +                                    '-f',
> +                                    iotests.imgfmt,
> +                                    disk):
> +            iotests.log(vm.qmp('block_resize', {
> +                'node-name': node_name,
> +                'size': 2097152,
> +            }))
> +            iotests.log('Size after resize:')
> +            iotests.log(node_size(vm))

After growing the image from 1M to 2M, is it also worth doing IO to
offsets in the newly-expanded part of the file to prove the resized
region is accessible?

> +            if reconnect_delay == 0:
> +                # With delay=0, block_resize fails while the client reconnects.
> +                # Retry once parked.
> +                iotests.log('Waiting until the reconnection succeeds')
> +                wait_for_parked_connection(vm)
> +
> +                iotests.log(vm.qmp('block_resize', {
> +                    'node-name': node_name,
> +                    'size': 2097152,
> +                }))
> +                iotests.log('Size after retried resize:')
> +                iotests.log(node_size(vm))
> +
> +            vm.shutdown()
> diff --git a/tests/qemu-iotests/tests/nbd-resize.out b/tests/qemu-iotests/tests/nbd-resize.out
> new file mode 100644
> index 0000000000..89eda39740
> --- /dev/null
> +++ b/tests/qemu-iotests/tests/nbd-resize.out
> @@ -0,0 +1,24 @@
> +=== Resize with reconnect-delay=10 ===
> +Start NBD server
> +Size before resize:
> +1048576
> +Kill NBD server
> +Start NBD server
> +{"return": {}}
> +Size after resize:
> +2097152
> +Kill NBD server
> +=== Resize with reconnect-delay=0 ===
> +Start NBD server
> +Size before resize:
> +1048576
> +Kill NBD server
> +Start NBD server
> +{"error": {"class": "GenericError", "desc": "Failed to reconnect NBD node"}}
> +Size after resize:
> +1048576
> +Waiting until the reconnection succeeds
> +{"return": {}}
> +Size after retried resize:
> +2097152
> +Kill NBD server
> -- 
> 2.43.0
> 

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



  reply	other threads:[~2026-11-19 22:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:46 [PATCH 0/5] block/nbd: Fix block resize on idle device Guillaume Vincke
2026-11-19 14:46 ` [PATCH 1/5] block/nbd: Extract request slot access and reconnection Guillaume Vincke
2026-11-19 22:16   ` Eric Blake
2026-11-19 14:46 ` [PATCH 2/5] block: Refresh the connection before block_resize Guillaume Vincke
2026-11-19 22:32   ` Eric Blake
2026-11-20 10:40     ` guillaume vincke
2026-11-19 14:46 ` [PATCH 3/5] block/nbd: Refresh the connection on block_resize Guillaume Vincke
2026-11-19 16:25   ` Eric Blake
2026-11-20 10:12     ` guillaume vincke
2026-11-19 14:46 ` [PATCH 4/5] iotests: Add coverage for NBD resize Guillaume Vincke
2026-11-19 22:51   ` Eric Blake [this message]
2026-11-20 10:17     ` guillaume vincke
2026-11-19 14:46 ` [PATCH 5/5] block: Add refresh connection support to raw and luks Guillaume Vincke
2026-11-19 16:20 ` [PATCH 0/5] block/nbd: Fix block resize on idle device Eric Blake
2026-11-20 10:04   ` guillaume vincke

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=av98gYPX3Wsoiq7N@redhat.com \
    --to=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=guillaume.vincke@ovhcloud.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --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.