|
|
a41c76 |
From 79e5b82ba66bbf8cbf55701013749ed155d92633 Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <79e5b82ba66bbf8cbf55701013749ed155d92633@dist-git>
|
|
|
a41c76 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Date: Mon, 16 Mar 2020 22:12:05 +0100
|
|
|
a41c76 |
Subject: [PATCH] qemu: block: Add support for HTTP cookies
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Pass the alias of the secret object holding the cookie data as
|
|
|
a41c76 |
'cookie-secret' to qemu.
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit 06d3e8d5398f9ed292b84a18c3bb6ea4034a772e)
|
|
|
a41c76 |
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
|
|
|
a41c76 |
Message-Id: <1bed750b384b4f553f36cff4782fc29e32af7ca4.1584391727.git.pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/qemu/qemu_block.c | 14 +++++++++++---
|
|
|
a41c76 |
.../disk-network-http.x86_64-latest.args | 11 +++++++++--
|
|
|
a41c76 |
tests/qemuxml2argvdata/disk-network-http.xml | 8 ++++++++
|
|
|
a41c76 |
3 files changed, 28 insertions(+), 5 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
|
|
|
a41c76 |
index f07420b6e2..80a8c7296d 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_block.c
|
|
|
a41c76 |
+++ b/src/qemu/qemu_block.c
|
|
|
a41c76 |
@@ -680,6 +680,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src,
|
|
|
a41c76 |
{
|
|
|
a41c76 |
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
|
|
|
a41c76 |
const char *passwordalias = NULL;
|
|
|
a41c76 |
+ const char *cookiealias = NULL;
|
|
|
a41c76 |
const char *username = NULL;
|
|
|
a41c76 |
virJSONValuePtr ret = NULL;
|
|
|
a41c76 |
g_autoptr(virURI) uri = NULL;
|
|
|
a41c76 |
@@ -704,9 +705,15 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src,
|
|
|
a41c76 |
if (!(uristr = virURIFormat(uri)))
|
|
|
a41c76 |
return NULL;
|
|
|
a41c76 |
|
|
|
a41c76 |
- if (!onlytarget && src->auth) {
|
|
|
a41c76 |
- username = src->auth->username;
|
|
|
a41c76 |
- passwordalias = srcPriv->secinfo->s.aes.alias;
|
|
|
a41c76 |
+ if (!onlytarget) {
|
|
|
a41c76 |
+ if (src->auth) {
|
|
|
a41c76 |
+ username = src->auth->username;
|
|
|
a41c76 |
+ passwordalias = srcPriv->secinfo->s.aes.alias;
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ if (srcPriv &&
|
|
|
a41c76 |
+ srcPriv->httpcookie)
|
|
|
a41c76 |
+ cookiealias = srcPriv->httpcookie->s.aes.alias;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
|
|
|
a41c76 |
ignore_value(virJSONValueObjectCreate(&ret,
|
|
|
a41c76 |
@@ -714,6 +721,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src,
|
|
|
a41c76 |
"S:username", username,
|
|
|
a41c76 |
"S:password-secret", passwordalias,
|
|
|
a41c76 |
"T:sslverify", src->sslverify,
|
|
|
a41c76 |
+ "S:cookie-secret", cookiealias,
|
|
|
a41c76 |
NULL));
|
|
|
a41c76 |
|
|
|
a41c76 |
return ret;
|
|
|
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 86e4597a81..cbb69e16a9 100644
|
|
|
a41c76 |
--- a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
|
|
|
a41c76 |
+++ b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
|
|
|
a41c76 |
@@ -39,15 +39,22 @@ id=virtio-disk0,bootindex=1 \
|
|
|
a41c76 |
"file":"libvirt-3-storage"}' \
|
|
|
a41c76 |
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=libvirt-3-format,\
|
|
|
a41c76 |
id=virtio-disk1 \
|
|
|
a41c76 |
+-object secret,id=libvirt-2-storage-httpcookie-secret0,\
|
|
|
a41c76 |
+data=DrPR9NA6GKJb7qi1KbjHad3f3UIGTTDmAmOZHHv1F5w5T8rhnk3f+uSKStHe0J2O,\
|
|
|
a41c76 |
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
|
|
|
a41c76 |
-blockdev '{"driver":"http","url":"http://example.org:1234/test3.img",\
|
|
|
a41c76 |
+"cookie-secret":"libvirt-2-storage-httpcookie-secret0",\
|
|
|
a41c76 |
"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
|
|
|
a41c76 |
-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw",\
|
|
|
a41c76 |
"file":"libvirt-2-storage"}' \
|
|
|
a41c76 |
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=libvirt-2-format,\
|
|
|
a41c76 |
id=virtio-disk2 \
|
|
|
a41c76 |
+-object secret,id=libvirt-1-storage-httpcookie-secret0,\
|
|
|
a41c76 |
+data=DrPR9NA6GKJb7qi1KbjHad3f3UIGTTDmAmOZHHv1F5w5T8rhnk3f+uSKStHe0J2O,\
|
|
|
a41c76 |
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
|
|
|
a41c76 |
-blockdev '{"driver":"https","url":"https://example.org:1234/test4.img",\
|
|
|
a41c76 |
-"sslverify":false,"node-name":"libvirt-1-storage","auto-read-only":true,\
|
|
|
a41c76 |
-"discard":"unmap"}' \
|
|
|
a41c76 |
+"sslverify":false,"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 |
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=libvirt-1-format,\
|
|
|
a41c76 |
diff --git a/tests/qemuxml2argvdata/disk-network-http.xml b/tests/qemuxml2argvdata/disk-network-http.xml
|
|
|
a41c76 |
index 8c475aec1d..6acf75cf65 100644
|
|
|
a41c76 |
--- a/tests/qemuxml2argvdata/disk-network-http.xml
|
|
|
a41c76 |
+++ b/tests/qemuxml2argvdata/disk-network-http.xml
|
|
|
a41c76 |
@@ -31,6 +31,10 @@
|
|
|
a41c76 |
<driver name='qemu' type='raw'/>
|
|
|
a41c76 |
<source protocol='http' name='test3.img'>
|
|
|
a41c76 |
<host name='example.org' port='1234'/>
|
|
|
a41c76 |
+ <cookies>
|
|
|
a41c76 |
+ <cookie name='test'>testcookievalue</cookie>
|
|
|
a41c76 |
+ <cookie name='test2'>blurb</cookie>
|
|
|
a41c76 |
+ </cookies>
|
|
|
a41c76 |
</source>
|
|
|
a41c76 |
<target dev='vdc' bus='virtio'/>
|
|
|
a41c76 |
</disk>
|
|
|
a41c76 |
@@ -39,6 +43,10 @@
|
|
|
a41c76 |
<source protocol='https' name='test4.img'>
|
|
|
a41c76 |
<host name='example.org' port='1234'/>
|
|
|
a41c76 |
<ssl verify='no'/>
|
|
|
a41c76 |
+ <cookies>
|
|
|
a41c76 |
+ <cookie name='test'>testcookievalue</cookie>
|
|
|
a41c76 |
+ <cookie name='test2'>blurb</cookie>
|
|
|
a41c76 |
+ </cookies>
|
|
|
a41c76 |
</source>
|
|
|
a41c76 |
<target dev='vdd' bus='virtio'/>
|
|
|
a41c76 |
</disk>
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.25.1
|
|
|
a41c76 |
|