qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: kwolf@redhat.com, den@openvz.org, armbru@redhat.com,
	stefanha@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v7 5/9] block/nbd: refactor nbd connection parameters
Date: Fri, 9 Aug 2019 10:12:33 -0500	[thread overview]
Message-ID: <f49e0d24-4b00-0b58-6d72-a865910bc514@redhat.com> (raw)
In-Reply-To: <20190618114328.55249-6-vsementsov@virtuozzo.com>


[-- Attachment #1.1: Type: text/plain, Size: 2500 bytes --]

On 6/18/19 6:43 AM, Vladimir Sementsov-Ogievskiy wrote:
> We'll need some connection parameters to be available all the time to
> implement nbd reconnect. So, let's refactor them: define additional
> parameters in BDRVNBDState, drop them from function parameters, drop
> nbd_client_init and separate options parsing instead from nbd_open.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/nbd.c | 125 +++++++++++++++++++++++++++-------------------------
>  1 file changed, 64 insertions(+), 61 deletions(-)
> 

> @@ -1659,20 +1630,19 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
>              error_setg(errp, "TLS only supported over IP sockets");
>              goto error;
>          }
> -        hostname = s->saddr->u.inet.host;
> +        s->hostname = s->saddr->u.inet.host;
>      }
>  
> -    /* NBD handshake */
> -    ret = nbd_client_init(bs, s->saddr, s->export, tlscreds, hostname,
> -                          qemu_opt_get(opts, "x-dirty-bitmap"),
> -                          qemu_opt_get_number(opts, "reconnect-delay", 0),
> -                          errp);
> +    s->x_dirty_bitmap = g_strdup(qemu_opt_get(opts, "x-dirty-bitmap"));
> +    s->reconnect_delay = qemu_opt_get_number(opts, "reconnect-delay", 0);
> +
> +    ret = 0;
>  
>   error:
> -    if (tlscreds) {
> -        object_unref(OBJECT(tlscreds));
> -    }
>      if (ret < 0) {
> +        if (s->tlscreds) {
> +            object_unref(OBJECT(s->tlscreds));
> +        }

Pre-existing, but object_unref(NULL) is safe, making this a useless 'if'.


> @@ -1726,9 +1725,13 @@ static void nbd_close(BlockDriverState *bs)
>  
>      nbd_client_close(bs);
>  
> +    if (s->tlscreds) {
> +        object_unref(OBJECT(s->tlscreds));
> +    }

and copied here.

>      qapi_free_SocketAddress(s->saddr);
>      g_free(s->export);
>      g_free(s->tlscredsid);
> +    g_free(s->x_dirty_bitmap);

Do we need to duplicate s->x_dirty_bitmap with s->info.x_dirty_bitmap,
or make the latter be const char * and reuse the pointer from the former
rather than strdup'ing it? (I don't think it affects the refactoring
done in this patch, but is possibly worth a separate cleanup patch).

I can fix up the two useless 'if's.

Reviewed-by: Eric Blake <eblake@redhat.com>

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-08-09 15:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 11:43 [Qemu-devel] [PATCH v7 0/9] NBD reconnect Vladimir Sementsov-Ogievskiy
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 1/9] block/nbd: split connection_co start out of nbd_client_connect Vladimir Sementsov-Ogievskiy
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 2/9] block/nbd: use non-blocking io channel for nbd negotiation Vladimir Sementsov-Ogievskiy
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 3/9] block/nbd: move from quit to state Vladimir Sementsov-Ogievskiy
2019-08-08  2:01   ` Eric Blake
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 4/9] block/nbd: add cmdline and qapi parameter reconnect-delay Vladimir Sementsov-Ogievskiy
2019-08-08  2:03   ` Eric Blake
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 5/9] block/nbd: refactor nbd connection parameters Vladimir Sementsov-Ogievskiy
2019-08-09 15:12   ` Eric Blake [this message]
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 6/9] qemu-coroutine-sleep: introduce qemu_co_sleep_wake Vladimir Sementsov-Ogievskiy
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 7/9] qemu/units: add SI decimal units Vladimir Sementsov-Ogievskiy
2019-08-09 15:39   ` Eric Blake
2019-08-09 15:56     ` Peter Maydell
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 8/9] block/nbd: nbd reconnect Vladimir Sementsov-Ogievskiy
2019-06-18 11:43 ` [Qemu-devel] [PATCH v7 9/9] iotests: test " Vladimir Sementsov-Ogievskiy
2019-07-25 10:07 ` [Qemu-devel] [PATCH v7 0/9] NBD reconnect Vladimir Sementsov-Ogievskiy
2019-08-21 11:41   ` Vladimir Sementsov-Ogievskiy
2019-08-21 14:47     ` 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=f49e0d24-4b00-0b58-6d72-a865910bc514@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).