On Wed, Jan 22, 2025 at 12:50:43PM +0100, Kevin Wolf wrote: > In order to support running an NBD export on inactive nodes, we must > make sure to return errors for any operations that aren't allowed on > inactive nodes. Reads are the only operation we know we need for > inactive images, so to err on the side of caution, return errors for > everything else, even if some operations could possibly be okay.
Block status might be the only other command I could see being needed, but I also agree with the approach of not supporting it until we have a use case in mind (if ever). > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > nbd/server.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > @@ -2920,6 +2921,22 @@ static coroutine_fn int nbd_handle_request(NBDClient > *client, > NBDExport *exp = client->exp; > char *msg; > size_t i; > + bool inactive; > + > + WITH_GRAPH_RDLOCK_GUARD() { > + inactive = bdrv_is_inactive(blk_bs(exp->common.blk)); Can the declaration of bool inactive be moved inside the lock guard block? Not a problem if you want to leave it with all other declarations, though. Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org