From 45ecbd824c92bd05a46557bfcaff39196f701e6c Mon Sep 17 00:00:00 2001 Message-Id: <45ecbd824c92bd05a46557bfcaff39196f701e6c@dist-git> From: Peter Krempa Date: Mon, 30 Mar 2020 17:21:45 +0200 Subject: [PATCH] conf: Add support for http(s) query strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new attribute for holding the query part for http(s) disks. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko (cherry picked from commit 56368124728f0d65dde07244c741b459fcd6b939) https://bugzilla.redhat.com/show_bug.cgi?id=1804750 Message-Id: Reviewed-by: Jiri Denemark --- docs/formatdomain.html.in | 7 ++++++- docs/schemas/domaincommon.rng | 6 ++++++ src/conf/domain_conf.c | 5 +++++ src/util/virstoragefile.c | 2 ++ src/util/virstoragefile.h | 1 + tests/qemuxml2argvdata/disk-network-http.xml | 2 +- .../qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml | 2 +- 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 143db21d4d..9c588185df 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -2837,7 +2837,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&amp;baz=flurb> <host name="hostname" port="80"/> <cookies> <cookie name="test">somevalue</cookie> @@ -3103,6 +3103,11 @@ ('tls' Since 4.5.0)

+

For protocols http and https an + optional attribute query specifies the query string. + (Since 6.2.0) +

+

For "iscsi" (since 1.0.4), the name 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 e17f7ff8c0..dd8f27243a 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1869,6 +1869,9 @@ + + + @@ -1894,6 +1897,9 @@ + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e3755fa285..28160a2967 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9382,6 +9382,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; @@ -24390,6 +24394,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 f8d741f040..4082e3f5f7 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); @@ -2696,6 +2697,7 @@ virStorageSourceClear(virStorageSourcePtr def) VIR_FREE(def->volume); VIR_FREE(def->snapshot); VIR_FREE(def->configFile); + VIR_FREE(def->query); virStorageSourceNetCookiesClear(def); virStorageSourcePoolDefFree(def->srcpool); virBitmapFree(def->features); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 0230f44652..8089d1e07f 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -285,6 +285,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 @@ - + diff --git a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml index 60073c227c..45b01841ec 100644 --- a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml +++ b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml @@ -46,7 +46,7 @@ - + -- 2.26.0