On 01/19/2018 07:57 AM, Vladimir Sementsov-Ogievskiy wrote: > Add command for removing an export. It is needed for cases when we > don't want to keep export after the operation on it was completed. > The other example is temporary node, created with blockdev-add. > If we want to delete it we should firstly remove corresponding > NBD export. > > Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com> > ---
> +++ b/nbd/server.c > @@ -1177,6 +1177,26 @@ void nbd_export_close(NBDExport *exp) > nbd_export_put(exp); > } > > +void nbd_export_remove(NBDExport *exp, NbdServerRemoveMode mode, Error > **errp) > +{ > + NBDClient *client; > + int nb_clients = 0; > + > + if (mode == NBD_SERVER_REMOVE_MODE_HARD || QTAILQ_EMPTY(&exp->clients)) { > + nbd_export_close(exp); > + return; > + } > + > + assert(mode == NBD_SERVER_REMOVE_MODE_SAFE); > + > + QTAILQ_FOREACH(client, &exp->clients, next) { > + nb_clients++; > + } > + Now that the error message is not using nb_clients, we can simplify the code to quit computing it. > + error_setg(errp, "export '%s' still in use", exp->name); > + error_append_hint(errp, "Use mode='hard' to force client disconnect\n"); > +} > + > void nbd_export_get(NBDExport *exp) > { > assert(exp->refcount > 0); > I'll make that change as part of adding it to my NBD queue. Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature