[PATCH v2 0/4] Preserve query component of path for HTTP disks

v2: - fixed docs to mention http/ftp/tftp protocols - query part is stored separately to prevent ambiguity in using of the '?' sign - added checks that query is valid only for http - added tests for pre-blockdev configurations Peter Krempa (4): docs: formatdomain: Mention missing protocols conf: Add support for http(s) query strings qemuBlockStorageSourceGetURI: Pass through query component virStorageSourceParseBackingURI: Preserve query string of URI for http(s) docs/formatdomain.html.in | 14 ++++++++++---- docs/schemas/domaincommon.rng | 6 ++++++ src/conf/domain_conf.c | 5 +++++ src/qemu/qemu_block.c | 2 ++ src/qemu/qemu_domain.c | 9 +++++++++ src/util/virstoragefile.c | 14 +++++++++++--- src/util/virstoragefile.h | 1 + tests/qemuxml2argvdata/disk-cdrom-network.args | 4 ++-- .../disk-cdrom-network.x86_64-2.12.0.args | 4 ++-- .../disk-cdrom-network.x86_64-latest.args | 3 ++- tests/qemuxml2argvdata/disk-cdrom-network.xml | 2 +- .../disk-network-http.x86_64-latest.args | 5 +++-- tests/qemuxml2argvdata/disk-network-http.xml | 2 +- .../disk-network-http.x86_64-latest.xml | 2 +- tests/virstoragetest.c | 4 ++-- 15 files changed, 58 insertions(+), 19 deletions(-) -- 2.24.1

http, https, ftp, ftps, and tftp were not mentioned in the documentation. Note that 'ssh' is still omitted as it's used only internally. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/formatdomain.html.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 28e779b90a..6dbf449698 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3096,10 +3096,11 @@ <dd> The <code>protocol</code> attribute specifies the protocol to access to the requested image. Possible values are "nbd", - "iscsi", "rbd", "sheepdog", "gluster" or "vxhs". + "iscsi", "rbd", "sheepdog", "gluster", "vxhs", "http", "https", + "ftp", ftps", or "tftp". - <p>If the <code>protocol</code> attribute is "rbd", "sheepdog", - "gluster", or "vxhs", an additional attribute <code>name</code> + <p>For any <code>protocol</code> other than <code>nbd</code> + an additional attribute <code>name</code> is mandatory to specify which volume/image will be used. </p> -- 2.24.1

On a Monday in 2020, Peter Krempa wrote:
http, https, ftp, ftps, and tftp were not mentioned in the documentation. Note that 'ssh' is still omitted as it's used only internally.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/formatdomain.html.in | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Add a new attribute for holding the query part for http(s) disks. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/formatdomain.html.in | 7 ++++++- docs/schemas/domaincommon.rng | 6 ++++++ src/conf/domain_conf.c | 5 +++++ src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 1 + tests/qemuxml2argvdata/disk-network-http.xml | 2 +- .../qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml | 2 +- 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6dbf449698..aaeb05961f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2847,7 +2847,7 @@ </disk> <disk type='network' device='cdrom'> <driver name='qemu' type='raw'/> - <source protocol="http" name="url_path"> + <source protocol="http" name="url_path" query="foo=bar&baz=flurb> <host name="hostname" port="80"/> <cookies> <cookie name="test">somevalue</cookie> @@ -3113,6 +3113,11 @@ ('tls' <span class="since">Since 4.5.0</span>) </p> + <p>For protocols <code>http</code> and <code>https</code> an + optional attribute <code>query</code> specifies the query string. + (<span class="since">Since 6.2.0</span>) + </p> + <p>For "iscsi" (<span class="since">since 1.0.4</span>), the <code>name</code> attribute may include a logical unit number, separated from the target's name by a slash (e.g., diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 5de17593c1..1807df521c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1869,6 +1869,9 @@ </choice> </attribute> <attribute name="name"/> + <optional> + <attribute name="query"/> + </optional> <ref name="diskSourceCommon"/> <ref name="diskSourceNetworkHost"/> <optional> @@ -1894,6 +1897,9 @@ </choice> </attribute> <attribute name="name"/> + <optional> + <attribute name="query"/> + </optional> <ref name="diskSourceCommon"/> <ref name="diskSourceNetworkHost"/> <optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 27bc5a797b..914e03c705 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9482,6 +9482,10 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, /* config file currently only works with remote disks */ src->configFile = virXPathString("string(./config/@file)", ctxt); + if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP || + src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS) + src->query = virXMLPropString(node, "query"); + if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts) < 0) return -1; @@ -24591,6 +24595,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, path = g_strdup_printf("%s/%s", src->volume, src->path); virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path); + virBufferEscapeString(attrBuf, " query='%s'", src->query); if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT && !(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c43e52d1f6..bccef863b4 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2418,6 +2418,7 @@ virStorageSourceCopy(const virStorageSource *src, def->compat = g_strdup(src->compat); def->tlsAlias = g_strdup(src->tlsAlias); def->tlsCertdir = g_strdup(src->tlsCertdir); + def->query = g_strdup(src->query); if (src->sliceStorage) def->sliceStorage = virStorageSourceSliceCopy(src->sliceStorage); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 9427057f94..7939c09cd5 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -284,6 +284,7 @@ struct _virStorageSource { char *snapshot; /* for storage systems supporting internal snapshots */ char *configFile; /* some storage systems use config file as part of the source definition */ + char *query; /* query string for HTTP based protocols */ size_t nhosts; virStorageNetHostDefPtr hosts; size_t ncookies; diff --git a/tests/qemuxml2argvdata/disk-network-http.xml b/tests/qemuxml2argvdata/disk-network-http.xml index 93e6617433..3abf499019 100644 --- a/tests/qemuxml2argvdata/disk-network-http.xml +++ b/tests/qemuxml2argvdata/disk-network-http.xml @@ -42,7 +42,7 @@ </disk> <disk type='network' device='disk'> <driver name='qemu' type='raw'/> - <source protocol='https' name='test4.img'> + <source protocol='https' name='test4.img' query='par=val&other=ble'> <host name='example.org' port='1234'/> <ssl verify='no'/> <cookies> diff --git a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml index cf36331286..aaae21c5af 100644 --- a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml @@ -49,7 +49,7 @@ </disk> <disk type='network' device='disk'> <driver name='qemu' type='raw'/> - <source protocol='https' name='test4.img'> + <source protocol='https' name='test4.img' query='par=val&other=ble'> <host name='example.org' port='1234'/> <ssl verify='no'/> <cookies> -- 2.24.1

On a Monday in 2020, Peter Krempa wrote:
Add a new attribute for holding the query part for http(s) disks.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/formatdomain.html.in | 7 ++++++- docs/schemas/domaincommon.rng | 6 ++++++ src/conf/domain_conf.c | 5 +++++ src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 1 + tests/qemuxml2argvdata/disk-network-http.xml | 2 +- .../qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml | 2 +- 7 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6dbf449698..aaeb05961f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2847,7 +2847,7 @@ </disk> <disk type='network' device='cdrom'> <driver name='qemu' type='raw'/> - <source protocol="http" name="url_path"> + <source protocol="http" name="url_path" query="foo=bar&baz=flurb> <host name="hostname" port="80"/> <cookies> <cookie name="test">somevalue</cookie> @@ -3113,6 +3113,11 @@ ('tls' <span class="since">Since 4.5.0</span>) </p>
+ <p>For protocols <code>http</code> and <code>https</code> an + optional attribute <code>query</code> specifies the query string. + (<span class="since">Since 6.2.0</span>)
Should this be 6.3.0? Or are we calling this a bugfix?
+ </p> + <p>For "iscsi" (<span class="since">since 1.0.4</span>), the <code>name</code> attribute may include a logical unit number, separated from the target's name by a slash (e.g., diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 5de17593c1..1807df521c 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1869,6 +1869,9 @@ </choice> </attribute> <attribute name="name"/> + <optional> + <attribute name="query"/> + </optional> <ref name="diskSourceCommon"/> <ref name="diskSourceNetworkHost"/> <optional> @@ -1894,6 +1897,9 @@ </choice> </attribute> <attribute name="name"/> + <optional> + <attribute name="query"/> + </optional> <ref name="diskSourceCommon"/> <ref name="diskSourceNetworkHost"/> <optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 27bc5a797b..914e03c705 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9482,6 +9482,10 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node, /* config file currently only works with remote disks */ src->configFile = virXPathString("string(./config/@file)", ctxt);
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP || + src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS) + src->query = virXMLPropString(node, "query"); + if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts) < 0) return -1;
@@ -24591,6 +24595,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, path = g_strdup_printf("%s/%s", src->volume, src->path);
virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path); + virBufferEscapeString(attrBuf, " query='%s'", src->query);
if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT && !(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c43e52d1f6..bccef863b4 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2418,6 +2418,7 @@ virStorageSourceCopy(const virStorageSource *src, def->compat = g_strdup(src->compat); def->tlsAlias = g_strdup(src->tlsAlias); def->tlsCertdir = g_strdup(src->tlsCertdir); + def->query = g_strdup(src->query);
The string also needs to be freed in virStorageSourceClear.
if (src->sliceStorage) def->sliceStorage = virStorageSourceSliceCopy(src->sliceStorage);
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

On Mon, Mar 30, 2020 at 16:18:26 +0200, Ján Tomko wrote:
On a Monday in 2020, Peter Krempa wrote:
Add a new attribute for holding the query part for http(s) disks.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/formatdomain.html.in | 7 ++++++- docs/schemas/domaincommon.rng | 6 ++++++ src/conf/domain_conf.c | 5 +++++ src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 1 + tests/qemuxml2argvdata/disk-network-http.xml | 2 +- .../qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml | 2 +- 7 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6dbf449698..aaeb05961f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2847,7 +2847,7 @@ </disk> <disk type='network' device='cdrom'> <driver name='qemu' type='raw'/> - <source protocol="http" name="url_path"> + <source protocol="http" name="url_path" query="foo=bar&baz=flurb> <host name="hostname" port="80"/> <cookies> <cookie name="test">somevalue</cookie> @@ -3113,6 +3113,11 @@ ('tls' <span class="since">Since 4.5.0</span>) </p>
+ <p>For protocols <code>http</code> and <code>https</code> an + optional attribute <code>query</code> specifies the query string. + (<span class="since">Since 6.2.0</span>)
Should this be 6.3.0? Or are we calling this a bugfix?
This is breaking certain versions of virt-v2v which didn't switch to nbdkit yet so I'm willing to call this a bugfix.

On a Monday in 2020, Peter Krempa wrote:
On Mon, Mar 30, 2020 at 16:18:26 +0200, Ján Tomko wrote:
On a Monday in 2020, Peter Krempa wrote:
Add a new attribute for holding the query part for http(s) disks.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- docs/formatdomain.html.in | 7 ++++++- docs/schemas/domaincommon.rng | 6 ++++++ src/conf/domain_conf.c | 5 +++++ src/util/virstoragefile.c | 1 + src/util/virstoragefile.h | 1 + tests/qemuxml2argvdata/disk-network-http.xml | 2 +- .../qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml | 2 +- 7 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 6dbf449698..aaeb05961f 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2847,7 +2847,7 @@ </disk> <disk type='network' device='cdrom'> <driver name='qemu' type='raw'/> - <source protocol="http" name="url_path"> + <source protocol="http" name="url_path" query="foo=bar&baz=flurb> <host name="hostname" port="80"/> <cookies> <cookie name="test">somevalue</cookie> @@ -3113,6 +3113,11 @@ ('tls' <span class="since">Since 4.5.0</span>) </p>
+ <p>For protocols <code>http</code> and <code>https</code> an + optional attribute <code>query</code> specifies the query string. + (<span class="since">Since 6.2.0</span>)
Should this be 6.3.0? Or are we calling this a bugfix?
This is breaking certain versions of virt-v2v which didn't switch to nbdkit yet so I'm willing to call this a bugfix.
Fine by me. Jano

If the storage source has the query part set, format it in the output. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_block.c | 2 ++ src/qemu/qemu_domain.c | 9 +++++++++ tests/qemuxml2argvdata/disk-cdrom-network.args | 4 ++-- .../disk-cdrom-network.x86_64-2.12.0.args | 4 ++-- .../disk-cdrom-network.x86_64-latest.args | 3 ++- tests/qemuxml2argvdata/disk-cdrom-network.xml | 2 +- .../disk-network-http.x86_64-latest.args | 5 +++-- 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 648c3f1026..2ce14615a0 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -437,6 +437,8 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src) } } + uri->query = g_strdup(src->query); + uri->server = g_strdup(src->hosts->name); return g_steal_pointer(&uri); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index adda17a49f..dd48b6fff3 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7132,6 +7132,15 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src, } } + if (src->query && + (actualType != VIR_STORAGE_TYPE_NETWORK || + (src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTPS && + src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTP))) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("query is supported only with HTTP(S) protocols")); + return -1; + } + return 0; } diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.args b/tests/qemuxml2argvdata/disk-cdrom-network.args index be19bad68a..81ff324a0f 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-network.args +++ b/tests/qemuxml2argvdata/disk-cdrom-network.args @@ -30,8 +30,8 @@ id=drive-ide0-0-0,readonly=on \ -drive file=ftps://host.name:990/url/path/file.iso,format=raw,if=none,\ id=drive-ide0-0-1,readonly=on \ -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive file=https://host.name:443/url/path/file.iso,format=raw,if=none,\ -id=drive-ide0-1-0,readonly=on \ +-drive 'file=https://host.name:443/url/path/file.iso?test=val,format=raw,\ +if=none,id=drive-ide0-1-0,readonly=on' \ -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -drive file=tftp://host.name:69/url/path/file.iso,format=raw,if=none,\ id=drive-ide0-1-1,readonly=on \ diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-2.12.0.args b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-2.12.0.args index 1ece3d6f46..81f6b400aa 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-2.12.0.args +++ b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-2.12.0.args @@ -32,8 +32,8 @@ id=drive-ide0-0-0,readonly=on \ -drive file=ftps://host.name:990/url/path/file.iso,format=raw,if=none,\ id=drive-ide0-0-1,readonly=on \ -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \ --drive file=https://host.name:443/url/path/file.iso,format=raw,if=none,\ -id=drive-ide0-1-0,readonly=on \ +-drive 'file=https://host.name:443/url/path/file.iso?test=val,format=raw,\ +if=none,id=drive-ide0-1-0,readonly=on' \ -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \ -drive file=tftp://host.name:69/url/path/file.iso,format=raw,if=none,\ id=drive-ide0-1-1,readonly=on \ diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args index 0b4ac07f07..2515b256d0 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args @@ -37,7 +37,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ -blockdev '{"node-name":"libvirt-3-format","read-only":true,"driver":"raw",\ "file":"libvirt-3-storage"}' \ -device ide-cd,bus=ide.0,unit=1,drive=libvirt-3-format,id=ide0-0-1 \ --blockdev '{"driver":"https","url":"https://host.name:443/url/path/file.iso",\ +-blockdev '{"driver":"https",\ +"url":"https://host.name:443/url/path/file.iso?test=val",\ "node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw",\ "file":"libvirt-2-storage"}' \ diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.xml b/tests/qemuxml2argvdata/disk-cdrom-network.xml index 0bdc0e1883..44473f8ad4 100644 --- a/tests/qemuxml2argvdata/disk-cdrom-network.xml +++ b/tests/qemuxml2argvdata/disk-cdrom-network.xml @@ -39,7 +39,7 @@ </disk> <disk type='network' device='cdrom'> <driver name='qemu' type='raw'/> - <source protocol='https' name='/url/path/file.iso'> + <source protocol='https' name='/url/path/file.iso' query='test=val'> <host name='host.name' port='443'/> </source> <target dev='hdc' bus='ide'/> diff --git a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args index ed44424dc3..7b4674a588 100644 --- a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args +++ b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args @@ -55,8 +55,9 @@ id=virtio-disk2 \ -object secret,id=libvirt-1-storage-httpcookie-secret0,\ data=DrPR9NA6GKJb7qi1KbjHaealKEMVtOWUl2h3yvO5lgIh6cyLHemmlg+h9fcgwREA,\ keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ --blockdev '{"driver":"https","url":"https://example.org:1234/test4.img",\ -"sslverify":false,"cookie-secret":"libvirt-1-storage-httpcookie-secret0",\ +-blockdev '{"driver":"https",\ +"url":"https://example.org:1234/test4.img?par=val&other=ble","sslverify":false,\ +"cookie-secret":"libvirt-1-storage-httpcookie-secret0",\ "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw",\ "file":"libvirt-1-storage"}' \ -- 2.24.1

On a Monday in 2020, Peter Krempa wrote:
If the storage source has the query part set, format it in the output.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/qemu/qemu_block.c | 2 ++ src/qemu/qemu_domain.c | 9 +++++++++ tests/qemuxml2argvdata/disk-cdrom-network.args | 4 ++-- .../disk-cdrom-network.x86_64-2.12.0.args | 4 ++-- .../disk-cdrom-network.x86_64-latest.args | 3 ++- tests/qemuxml2argvdata/disk-cdrom-network.xml | 2 +- .../disk-network-http.x86_64-latest.args | 5 +++-- 7 files changed, 21 insertions(+), 8 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

For http/https URIs we need to preserve the query part as it may be important to refer to the image. Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virstoragefile.c | 13 ++++++++++--- tests/virstoragetest.c | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index bccef863b4..069bc8d776 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2852,9 +2852,16 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src, return -1; } - /* handle socket stored as a query */ - if (uri->query) - src->hosts->socket = g_strdup(STRSKIP(uri->query, "socket=")); + if (uri->query) { + if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP || + src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS) { + src->query = g_strdup(uri->query); + } else { + /* handle socket stored as a query */ + if (STRPREFIX(uri->query, "socket=")) + src->hosts->socket = g_strdup(STRSKIP(uri->query, "socket=")); + } + } /* uri->path is NULL if the URI does not contain slash after host: * transport://host:port */ diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 10d5421150..6e8ebeba13 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -1632,7 +1632,7 @@ mymain(void) "\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\"," "\"file.timeout\": 2000" "}", - "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk'>\n" + "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&dsName=esx6.5-matrix'>\n" " <host name='host' port='443'/>\n" " <ssl verify='no'/>\n" " <cookies>\n" @@ -1647,7 +1647,7 @@ mymain(void) "\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\"," "\"file.timeout\": 2000" "}", - "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk'>\n" + "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&dsName=esx6.5-matrix'>\n" " <host name='host' port='443'/>\n" " <ssl verify='no'/>\n" " <cookies>\n" -- 2.24.1

On a Monday in 2020, Peter Krempa wrote:
For http/https URIs we need to preserve the query part as it may be important to refer to the image.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/virstoragefile.c | 13 ++++++++++--- tests/virstoragetest.c | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-)
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa