|
|
a41c76 |
From 45ecbd824c92bd05a46557bfcaff39196f701e6c Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <45ecbd824c92bd05a46557bfcaff39196f701e6c@dist-git>
|
|
|
a41c76 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Date: Mon, 30 Mar 2020 17:21:45 +0200
|
|
|
a41c76 |
Subject: [PATCH] conf: Add support for http(s) query strings
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Add a new attribute for holding the query part for http(s) disks.
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit 56368124728f0d65dde07244c741b459fcd6b939)
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
|
|
|
a41c76 |
Message-Id: <b60abcf1e7711e9e29175e1fdcfe2820d5694a17.1585581552.git.pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
docs/formatdomain.html.in | 7 ++++++-
|
|
|
a41c76 |
docs/schemas/domaincommon.rng | 6 ++++++
|
|
|
a41c76 |
src/conf/domain_conf.c | 5 +++++
|
|
|
a41c76 |
src/util/virstoragefile.c | 2 ++
|
|
|
a41c76 |
src/util/virstoragefile.h | 1 +
|
|
|
a41c76 |
tests/qemuxml2argvdata/disk-network-http.xml | 2 +-
|
|
|
a41c76 |
.../qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml | 2 +-
|
|
|
a41c76 |
7 files changed, 22 insertions(+), 3 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
|
|
a41c76 |
index 143db21d4d..9c588185df 100644
|
|
|
a41c76 |
--- a/docs/formatdomain.html.in
|
|
|
a41c76 |
+++ b/docs/formatdomain.html.in
|
|
|
a41c76 |
@@ -2837,7 +2837,7 @@
|
|
|
a41c76 |
</disk>
|
|
|
a41c76 |
<disk type='network' device='cdrom'>
|
|
|
a41c76 |
<driver name='qemu' type='raw'/>
|
|
|
a41c76 |
- <source protocol="http" name="url_path">
|
|
|
a41c76 |
+ <source protocol="http" name="url_path" query="foo=bar&baz=flurb>
|
|
|
a41c76 |
<host name="hostname" port="80"/>
|
|
|
a41c76 |
<cookies>
|
|
|
a41c76 |
<cookie name="test">somevalue</cookie>
|
|
|
a41c76 |
@@ -3103,6 +3103,11 @@
|
|
|
a41c76 |
('tls' Since 4.5.0)
|
|
|
a41c76 |
|
|
|
a41c76 |
|
|
|
a41c76 |
+ For protocols http and https an
|
|
|
a41c76 |
+ optional attribute query specifies the query string.
|
|
|
a41c76 |
+ (Since 6.2.0)
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+
|
|
|
a41c76 |
For "iscsi" (since 1.0.4), the
|
|
|
a41c76 |
name attribute may include a logical unit number,
|
|
|
a41c76 |
separated from the target's name by a slash (e.g.,
|
|
|
a41c76 |
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
|
|
|
a41c76 |
index e17f7ff8c0..dd8f27243a 100644
|
|
|
a41c76 |
--- a/docs/schemas/domaincommon.rng
|
|
|
a41c76 |
+++ b/docs/schemas/domaincommon.rng
|
|
|
a41c76 |
@@ -1869,6 +1869,9 @@
|
|
|
a41c76 |
</choice>
|
|
|
a41c76 |
</attribute>
|
|
|
a41c76 |
<attribute name="name"/>
|
|
|
a41c76 |
+ <optional>
|
|
|
a41c76 |
+ <attribute name="query"/>
|
|
|
a41c76 |
+ </optional>
|
|
|
a41c76 |
<ref name="diskSourceCommon"/>
|
|
|
a41c76 |
<ref name="diskSourceNetworkHost"/>
|
|
|
a41c76 |
<optional>
|
|
|
a41c76 |
@@ -1894,6 +1897,9 @@
|
|
|
a41c76 |
</choice>
|
|
|
a41c76 |
</attribute>
|
|
|
a41c76 |
<attribute name="name"/>
|
|
|
a41c76 |
+ <optional>
|
|
|
a41c76 |
+ <attribute name="query"/>
|
|
|
a41c76 |
+ </optional>
|
|
|
a41c76 |
<ref name="diskSourceCommon"/>
|
|
|
a41c76 |
<ref name="diskSourceNetworkHost"/>
|
|
|
a41c76 |
<optional>
|
|
|
a41c76 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
a41c76 |
index e3755fa285..28160a2967 100644
|
|
|
a41c76 |
--- a/src/conf/domain_conf.c
|
|
|
a41c76 |
+++ b/src/conf/domain_conf.c
|
|
|
a41c76 |
@@ -9382,6 +9382,10 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
|
|
|
a41c76 |
/* config file currently only works with remote disks */
|
|
|
a41c76 |
src->configFile = virXPathString("string(./config/@file)", ctxt);
|
|
|
a41c76 |
|
|
|
a41c76 |
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
|
|
|
a41c76 |
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS)
|
|
|
a41c76 |
+ src->query = virXMLPropString(node, "query");
|
|
|
a41c76 |
+
|
|
|
a41c76 |
if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts) < 0)
|
|
|
a41c76 |
return -1;
|
|
|
a41c76 |
|
|
|
a41c76 |
@@ -24390,6 +24394,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
|
|
|
a41c76 |
path = g_strdup_printf("%s/%s", src->volume, src->path);
|
|
|
a41c76 |
|
|
|
a41c76 |
virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path);
|
|
|
a41c76 |
+ virBufferEscapeString(attrBuf, " query='%s'", src->query);
|
|
|
a41c76 |
|
|
|
a41c76 |
if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT &&
|
|
|
a41c76 |
!(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
|
|
|
a41c76 |
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
|
a41c76 |
index f8d741f040..4082e3f5f7 100644
|
|
|
a41c76 |
--- a/src/util/virstoragefile.c
|
|
|
a41c76 |
+++ b/src/util/virstoragefile.c
|
|
|
a41c76 |
@@ -2418,6 +2418,7 @@ virStorageSourceCopy(const virStorageSource *src,
|
|
|
a41c76 |
def->compat = g_strdup(src->compat);
|
|
|
a41c76 |
def->tlsAlias = g_strdup(src->tlsAlias);
|
|
|
a41c76 |
def->tlsCertdir = g_strdup(src->tlsCertdir);
|
|
|
a41c76 |
+ def->query = g_strdup(src->query);
|
|
|
a41c76 |
|
|
|
a41c76 |
if (src->sliceStorage)
|
|
|
a41c76 |
def->sliceStorage = virStorageSourceSliceCopy(src->sliceStorage);
|
|
|
a41c76 |
@@ -2696,6 +2697,7 @@ virStorageSourceClear(virStorageSourcePtr def)
|
|
|
a41c76 |
VIR_FREE(def->volume);
|
|
|
a41c76 |
VIR_FREE(def->snapshot);
|
|
|
a41c76 |
VIR_FREE(def->configFile);
|
|
|
a41c76 |
+ VIR_FREE(def->query);
|
|
|
a41c76 |
virStorageSourceNetCookiesClear(def);
|
|
|
a41c76 |
virStorageSourcePoolDefFree(def->srcpool);
|
|
|
a41c76 |
virBitmapFree(def->features);
|
|
|
a41c76 |
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
|
|
|
a41c76 |
index 0230f44652..8089d1e07f 100644
|
|
|
a41c76 |
--- a/src/util/virstoragefile.h
|
|
|
a41c76 |
+++ b/src/util/virstoragefile.h
|
|
|
a41c76 |
@@ -285,6 +285,7 @@ struct _virStorageSource {
|
|
|
a41c76 |
char *snapshot; /* for storage systems supporting internal snapshots */
|
|
|
a41c76 |
char *configFile; /* some storage systems use config file as part of
|
|
|
a41c76 |
the source definition */
|
|
|
a41c76 |
+ char *query; /* query string for HTTP based protocols */
|
|
|
a41c76 |
size_t nhosts;
|
|
|
a41c76 |
virStorageNetHostDefPtr hosts;
|
|
|
a41c76 |
size_t ncookies;
|
|
|
a41c76 |
diff --git a/tests/qemuxml2argvdata/disk-network-http.xml b/tests/qemuxml2argvdata/disk-network-http.xml
|
|
|
a41c76 |
index 93e6617433..3abf499019 100644
|
|
|
a41c76 |
--- a/tests/qemuxml2argvdata/disk-network-http.xml
|
|
|
a41c76 |
+++ b/tests/qemuxml2argvdata/disk-network-http.xml
|
|
|
a41c76 |
@@ -42,7 +42,7 @@
|
|
|
a41c76 |
</disk>
|
|
|
a41c76 |
<disk type='network' device='disk'>
|
|
|
a41c76 |
<driver name='qemu' type='raw'/>
|
|
|
a41c76 |
- <source protocol='https' name='test4.img'>
|
|
|
a41c76 |
+ <source protocol='https' name='test4.img' query='par=val&other=ble'>
|
|
|
a41c76 |
<host name='example.org' port='1234'/>
|
|
|
a41c76 |
<ssl verify='no'/>
|
|
|
a41c76 |
<cookies>
|
|
|
a41c76 |
diff --git a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml
|
|
|
a41c76 |
index 60073c227c..45b01841ec 100644
|
|
|
a41c76 |
--- a/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml
|
|
|
a41c76 |
+++ b/tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml
|
|
|
a41c76 |
@@ -46,7 +46,7 @@
|
|
|
a41c76 |
</disk>
|
|
|
a41c76 |
<disk type='network' device='disk'>
|
|
|
a41c76 |
<driver name='qemu' type='raw'/>
|
|
|
a41c76 |
- <source protocol='https' name='test4.img'>
|
|
|
a41c76 |
+ <source protocol='https' name='test4.img' query='par=val&other=ble'>
|
|
|
a41c76 |
<host name='example.org' port='1234'/>
|
|
|
a41c76 |
<ssl verify='no'/>
|
|
|
a41c76 |
<cookies>
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.26.0
|
|
|
a41c76 |
|