qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v3 2/5] qapi: add nbd-server-remove


From: Eric Blake
Subject: Re: [Qemu-block] [PATCH v3 2/5] qapi: add nbd-server-remove
Date: Mon, 22 Jan 2018 16:33:26 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2

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 <address@hidden>
> ---

> +++ 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 <address@hidden>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]