[PATCH 22/30] qemu: block: Add support for HTTP cookies

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pass the alias of the secret object holding the cookie data as
'cookie-secret' to qemu.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_block.c                              | 14 +++++++++++---
 .../disk-network-http.x86_64-latest.args           | 11 +++++++++--
 tests/qemuxml2argvdata/disk-network-http.xml       |  8 ++++++++
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index aba0f31f94..119b34f869 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -680,6 +680,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src,
 {
     qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
     const char *passwordalias = NULL;
+    const char *cookiealias = NULL;
     const char *username = NULL;
     virJSONValuePtr ret = NULL;
     g_autoptr(virURI) uri = NULL;
@@ -704,9 +705,15 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src,
     if (!(uristr = virURIFormat(uri)))
         return NULL;

-    if (!onlytarget && src->auth) {
-        username = src->auth->username;
-        passwordalias = srcPriv->secinfo->s.aes.alias;
+    if (!onlytarget) {
+        if (src->auth) {
+            username = src->auth->username;
+            passwordalias = srcPriv->secinfo->s.aes.alias;
+        }
+
+        if (srcPriv &&
+            srcPriv->httpcookie)
+            cookiealias = srcPriv->httpcookie->s.aes.alias;
     }

     ignore_value(virJSONValueObjectCreate(&ret,
@@ -714,6 +721,7 @@ qemuBlockStorageSourceGetCURLProps(virStorageSourcePtr src,
                                           "S:username", username,
                                           "S:password-secret", passwordalias,
                                           "T:sslverify", src->sslverify,
+                                          "S:cookie-secret", cookiealias,
                                           NULL));

     return ret;
diff --git a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
index a700c26bf6..5798235b55 100644
--- a/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-network-http.x86_64-latest.args
@@ -40,15 +40,22 @@ id=virtio-disk0,bootindex=1 \
 "file":"libvirt-3-storage"}' \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=libvirt-3-format,\
 id=virtio-disk1 \
+-object secret,id=libvirt-2-storage-httpcookie-secret0,\
+data=DrPR9NA6GKJb7qi1KbjHad3f3UIGTTDmAmOZHHv1F5w5T8rhnk3f+uSKStHe0J2O,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -blockdev '{"driver":"http","url":"http://example.org:1234/test3.img",\
+"cookie-secret":"libvirt-2-storage-httpcookie-secret0",\
 "node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
 -blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw",\
 "file":"libvirt-2-storage"}' \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=libvirt-2-format,\
 id=virtio-disk2 \
+-object secret,id=libvirt-1-storage-httpcookie-secret0,\
+data=DrPR9NA6GKJb7qi1KbjHad3f3UIGTTDmAmOZHHv1F5w5T8rhnk3f+uSKStHe0J2O,\
+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \
 -blockdev '{"driver":"https","url":"https://example.org:1234/test4.img",\
-"sslverify":false,"node-name":"libvirt-1-storage","auto-read-only":true,\
-"discard":"unmap"}' \
+"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"}' \
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=libvirt-1-format,\
diff --git a/tests/qemuxml2argvdata/disk-network-http.xml b/tests/qemuxml2argvdata/disk-network-http.xml
index 8c475aec1d..6acf75cf65 100644
--- a/tests/qemuxml2argvdata/disk-network-http.xml
+++ b/tests/qemuxml2argvdata/disk-network-http.xml
@@ -31,6 +31,10 @@
       <driver name='qemu' type='raw'/>
       <source protocol='http' name='test3.img'>
         <host name='example.org' port='1234'/>
+        <cookies>
+          <cookie name='test'>testcookievalue</cookie>
+          <cookie name='test2'>blurb</cookie>
+        </cookies>
       </source>
       <target dev='vdc' bus='virtio'/>
     </disk>
@@ -39,6 +43,10 @@
       <source protocol='https' name='test4.img'>
         <host name='example.org' port='1234'/>
         <ssl verify='no'/>
+        <cookies>
+          <cookie name='test'>testcookievalue</cookie>
+          <cookie name='test2'>blurb</cookie>
+        </cookies>
       </source>
       <target dev='vdd' bus='virtio'/>
     </disk>
-- 
2.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux