qemu: block: Add support for HTTP cookies

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2017-05-04 12:55:49 +02:00
parent b512935b17
commit 06d3e8d539
3 changed files with 28 additions and 5 deletions

View File

@ -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;

View File

@ -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,\

View File

@ -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>