All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	integration@gluster.org, sheepdog@lists.wpkg.org,
	qemu-block@nongnu.org, Peter Lieven <pl@kamp.de>,
	qemu-devel@nongnu.org, "Richard W.M. Jones" <rjones@redhat.com>,
	Liu Yuan <namei.unix@gmail.com>, Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH 09/13] nbd: add GUri-based URI parsing version
Date: Fri, 10 Jul 2020 09:31:35 +0100	[thread overview]
Message-ID: <20200710083135.GB4017912@redhat.com> (raw)
In-Reply-To: <20200709194234.2117650-10-marcandre.lureau@redhat.com>

On Thu, Jul 09, 2020 at 11:42:30PM +0400, Marc-André Lureau wrote:
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  block/nbd.c        | 86 +++++++++++++++++++++++++++++++++++-----------
>  util/Makefile.objs |  2 +-
>  2 files changed, 66 insertions(+), 22 deletions(-)
> 
> diff --git a/block/nbd.c b/block/nbd.c
> index faadcab442b..fdc4a53a98f 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -31,7 +31,10 @@
>  #include "qemu/osdep.h"
>  
>  #include "trace.h"
> +#ifndef HAVE_GLIB_GURI
>  #include "qemu/uri.h"
> +#endif
> +#include "qemu/error-report.h"
>  #include "qemu/option.h"
>  #include "qemu/cutils.h"
>  #include "qemu/main-loop.h"
> @@ -1513,71 +1516,112 @@ static int nbd_client_connect(BlockDriverState *bs, Error **errp)
>  /*
>   * Parse nbd_open options
>   */
> -
>  static int nbd_parse_uri(const char *filename, QDict *options)
>  {
> +    const char *p, *scheme, *server, *socket = NULL;
> +    int port;
> +    bool is_unix;
> +
> +#ifdef HAVE_GLIB_GURI
> +    g_autoptr(GUri) uri = NULL;
> +    g_autoptr(GHashTable) params = NULL;
> +    g_autoptr(GError) err = NULL;
> +
> +    uri = g_uri_parse(filename, G_URI_FLAGS_ENCODED_QUERY, &err);
> +    if (!uri) {
> +        error_report("Failed to parse NBD URI: %s", err->message);
> +        return -EINVAL;
> +    }
> +
> +    p = g_uri_get_path(uri);
> +    scheme = g_uri_get_scheme(uri);
> +    server = g_uri_get_host(uri);
> +    port = g_uri_get_port(uri);

I would have expected this code to fail to compile as we're setting
GLIB_VERSION_MAX_ALLOWED == GLIB_VERSION_2_48  and GUri is tagged
as newer than that.

In any case, having this conditonal code in all callers is definitely
not a desirable approach. If we want to use it, then I think we need to
pull a copy of GUri into QEMU and expose it via glib-compat.h, so that
callers can use it unconditionally.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2020-07-10  8:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09 19:42 [PATCH 00/13] RFC: use upcoming GUri for URI handling Marc-André Lureau
2020-07-09 19:42 ` [PATCH 01/13] uri: add g_auto macros for URI & QueryParams Marc-André Lureau
2020-07-09 19:42 ` [PATCH 02/13] block/nbd: auto-ify URI parsing variables Marc-André Lureau
2020-07-09 19:42 ` [PATCH 03/13] block/vxhs: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 04/13] block/sheepdog: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 05/13] block/ssh: " Marc-André Lureau
2020-07-23 12:30   ` Richard W.M. Jones
2020-07-09 19:42 ` [PATCH 06/13] block/nfs: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 07/13] block/gluster: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 08/13] build-sys: add HAVE_GLIB_GURI Marc-André Lureau
2020-07-09 19:42 ` [PATCH 09/13] nbd: add GUri-based URI parsing version Marc-André Lureau
2020-07-10  8:31   ` Daniel P. Berrangé [this message]
2020-07-09 19:42 ` [PATCH 10/13] sheepdog: add GUri-based URI parsing Marc-André Lureau
2020-07-09 19:42 ` [PATCH 11/13] nfs: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 12/13] gluster: " Marc-André Lureau
2020-07-09 19:42 ` [PATCH 13/13] ssh: " Marc-André Lureau
2020-07-23 12:31   ` Richard W.M. Jones
2020-07-23 12:58     ` Marc-André Lureau
2020-07-23 13:06       ` Daniel P. Berrangé

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=20200710083135.GB4017912@redhat.com \
    --to=berrange@redhat.com \
    --cc=integration@gluster.org \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=namei.unix@gmail.com \
    --cc=pl@kamp.de \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=sheepdog@lists.wpkg.org \
    /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.