[PATCH 2/3] qemuBlockStorageSourceGetURI: Properly preserve query component

Jiri Denemark jdenemar at redhat.com
Mon Mar 30 09:36:43 UTC 2020


On Fri, Mar 27, 2020 at 16:51:20 +0100, Peter Krempa wrote:
> Look for the questionmark in the name and move the contents into the
> query portion so that we format the URI back properly.
> 
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
>  src/qemu/qemu_block.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
> index 648c3f1026..c51fb2b6ea 100644
> --- a/src/qemu/qemu_block.c
> +++ b/src/qemu/qemu_block.c
> @@ -429,12 +429,18 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src)
>      }
> 
>      if (src->path) {
> +        char *query;
>          if (src->volume) {
>              uri->path = g_strdup_printf("/%s/%s", src->volume, src->path);
>          } else {
>              uri->path = g_strdup_printf("%s%s", src->path[0] == '/' ? "" : "/",
>                                          src->path);
>          }
> +
> +        if ((query = strchr(uri->path, '?'))) {
> +            uri->query = g_strdup(query + 1);
> +            *query = '\0';
> +        }

This would be quite fragile I'm afraid. We should only do this when we
know we got src->path from a URI with a query string, otherwise we could
find a random '?' possibly used in a file's name.

Jirka




More information about the libvir-list mailing list