render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
a41c76
From 2d27c71da092e9232c2d79738a431c04db649a96 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <2d27c71da092e9232c2d79738a431c04db649a96@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 30 Mar 2020 17:21:46 +0200
a41c76
Subject: [PATCH] qemuBlockStorageSourceGetURI: Pass through query component
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
If the storage source has the query part set, format it in the output.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 216860dd8b93c7da4d625055cf353e0eedda6093)
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
a41c76
Message-Id: <832f573fd69341b7d730925c9df5b23e5f168408.1585581552.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_block.c                                    | 2 ++
a41c76
 src/qemu/qemu_domain.c                                   | 9 +++++++++
a41c76
 tests/qemuxml2argvdata/disk-cdrom-network.args           | 4 ++--
a41c76
 .../disk-cdrom-network.x86_64-2.12.0.args                | 4 ++--
a41c76
 .../disk-cdrom-network.x86_64-latest.args                | 3 ++-
a41c76
 tests/qemuxml2argvdata/disk-cdrom-network.xml            | 2 +-
a41c76
 .../disk-network-http.x86_64-latest.args                 | 5 +++--
a41c76
 7 files changed, 21 insertions(+), 8 deletions(-)
a41c76
a41c76
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
a41c76
index e7577c1312..6790f05ff7 100644
a41c76
--- a/src/qemu/qemu_block.c
a41c76
+++ b/src/qemu/qemu_block.c
a41c76
@@ -437,6 +437,8 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src)
a41c76
         }
a41c76
     }
a41c76
 
a41c76
+    uri->query = g_strdup(src->query);
a41c76
+
a41c76
     uri->server = g_strdup(src->hosts->name);
a41c76
 
a41c76
     return g_steal_pointer(&uri);
a41c76
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
a41c76
index 4007b4dbda..bb28716ff0 100644
a41c76
--- a/src/qemu/qemu_domain.c
a41c76
+++ b/src/qemu/qemu_domain.c
a41c76
@@ -7107,6 +7107,15 @@ qemuDomainValidateStorageSource(virStorageSourcePtr src,
a41c76
         }
a41c76
     }
a41c76
 
a41c76
+    if (src->query &&
a41c76
+        (actualType != VIR_STORAGE_TYPE_NETWORK ||
a41c76
+         (src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTPS &&
a41c76
+          src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTP))) {
a41c76
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
a41c76
+                       _("query is supported only with HTTP(S) protocols"));
a41c76
+        return -1;
a41c76
+    }
a41c76
+
a41c76
     return 0;
a41c76
 }
a41c76
 
a41c76
diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.args b/tests/qemuxml2argvdata/disk-cdrom-network.args
a41c76
index be19bad68a..81ff324a0f 100644
a41c76
--- a/tests/qemuxml2argvdata/disk-cdrom-network.args
a41c76
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.args
a41c76
@@ -30,8 +30,8 @@ id=drive-ide0-0-0,readonly=on \
a41c76
 -drive file=ftps://host.name:990/url/path/file.iso,format=raw,if=none,\
a41c76
 id=drive-ide0-0-1,readonly=on \
a41c76
 -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
a41c76
--drive file=https://host.name:443/url/path/file.iso,format=raw,if=none,\
a41c76
-id=drive-ide0-1-0,readonly=on \
a41c76
+-drive 'file=https://host.name:443/url/path/file.iso?test=val,format=raw,\
a41c76
+if=none,id=drive-ide0-1-0,readonly=on' \
a41c76
 -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
a41c76
 -drive file=tftp://host.name:69/url/path/file.iso,format=raw,if=none,\
a41c76
 id=drive-ide0-1-1,readonly=on \
a41c76
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
a41c76
index 1ece3d6f46..81f6b400aa 100644
a41c76
--- a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-2.12.0.args
a41c76
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-2.12.0.args
a41c76
@@ -32,8 +32,8 @@ id=drive-ide0-0-0,readonly=on \
a41c76
 -drive file=ftps://host.name:990/url/path/file.iso,format=raw,if=none,\
a41c76
 id=drive-ide0-0-1,readonly=on \
a41c76
 -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1 \
a41c76
--drive file=https://host.name:443/url/path/file.iso,format=raw,if=none,\
a41c76
-id=drive-ide0-1-0,readonly=on \
a41c76
+-drive 'file=https://host.name:443/url/path/file.iso?test=val,format=raw,\
a41c76
+if=none,id=drive-ide0-1-0,readonly=on' \
a41c76
 -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 \
a41c76
 -drive file=tftp://host.name:69/url/path/file.iso,format=raw,if=none,\
a41c76
 id=drive-ide0-1-1,readonly=on \
a41c76
diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
a41c76
index 0b4ac07f07..2515b256d0 100644
a41c76
--- a/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
a41c76
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.x86_64-latest.args
a41c76
@@ -37,7 +37,8 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
a41c76
 -blockdev '{"node-name":"libvirt-3-format","read-only":true,"driver":"raw",\
a41c76
 "file":"libvirt-3-storage"}' \
a41c76
 -device ide-cd,bus=ide.0,unit=1,drive=libvirt-3-format,id=ide0-0-1 \
a41c76
--blockdev '{"driver":"https","url":"https://host.name:443/url/path/file.iso",\
a41c76
+-blockdev '{"driver":"https",\
a41c76
+"url":"https://host.name:443/url/path/file.iso?test=val",\
a41c76
 "node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
a41c76
 -blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw",\
a41c76
 "file":"libvirt-2-storage"}' \
a41c76
diff --git a/tests/qemuxml2argvdata/disk-cdrom-network.xml b/tests/qemuxml2argvdata/disk-cdrom-network.xml
a41c76
index 0bdc0e1883..44473f8ad4 100644
a41c76
--- a/tests/qemuxml2argvdata/disk-cdrom-network.xml
a41c76
+++ b/tests/qemuxml2argvdata/disk-cdrom-network.xml
a41c76
@@ -39,7 +39,7 @@
a41c76
     </disk>
a41c76
     <disk type='network' device='cdrom'>
a41c76
       <driver name='qemu' type='raw'/>
a41c76
-      <source protocol='https' name='/url/path/file.iso'>
a41c76
+      <source protocol='https' name='/url/path/file.iso' query='test=val'>
a41c76
         <host name='host.name' port='443'/>
a41c76
       </source>
a41c76
       <target dev='hdc' bus='ide'/>
a41c76
diff --git a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
a41c76
index 46aa5f23ce..d1bf0b9caa 100644
a41c76
--- a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
a41c76
+++ b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
a41c76
@@ -54,8 +54,9 @@ id=virtio-disk2 \
a41c76
 -object secret,id=libvirt-1-storage-httpcookie-secret0,\
a41c76
 data=DrPR9NA6GKJb7qi1KbjHaealKEMVtOWUl2h3yvO5lgIh6cyLHemmlg+h9fcgwREA,\
a41c76
 keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
a41c76
--blockdev '{"driver":"https","url":"https://example.org:1234/test4.img",\
a41c76
-"sslverify":false,"cookie-secret":"libvirt-1-storage-httpcookie-secret0",\
a41c76
+-blockdev '{"driver":"https",\
a41c76
+"url":"https://example.org:1234/test4.img?par=val&other=ble","sslverify":false,\
a41c76
+"cookie-secret":"libvirt-1-storage-httpcookie-secret0",\
a41c76
 "node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
a41c76
 -blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw",\
a41c76
 "file":"libvirt-1-storage"}' \
a41c76
-- 
a41c76
2.26.0
a41c76