|
|
a41c76 |
From 41504cefb5ab3f473680bd7498fc940811cefc26 Mon Sep 17 00:00:00 2001
|
|
|
a41c76 |
Message-Id: <41504cefb5ab3f473680bd7498fc940811cefc26@dist-git>
|
|
|
a41c76 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Date: Tue, 24 Mar 2020 16:26:06 +0100
|
|
|
a41c76 |
Subject: [PATCH] qemu: block: Extract formatting of cookie string
|
|
|
a41c76 |
MIME-Version: 1.0
|
|
|
a41c76 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a41c76 |
Content-Transfer-Encoding: 8bit
|
|
|
a41c76 |
|
|
|
a41c76 |
Introduce qemuBlockStorageSourceGetCookieString which does the
|
|
|
a41c76 |
concatenation so that we can reuse it later.
|
|
|
a41c76 |
|
|
|
a41c76 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
a41c76 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
a41c76 |
(cherry picked from commit bafd2e94fabfe12bdc64c9972f56af536e6ad0eb)
|
|
|
a41c76 |
|
|
|
a41c76 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804617
|
|
|
a41c76 |
|
|
|
a41c76 |
Conflicts:
|
|
|
a41c76 |
src/qemu/qemu_block.c
|
|
|
a41c76 |
src/qemu/qemu_block.h
|
|
|
a41c76 |
|
|
|
a41c76 |
Context, a8bcbb42172 not backported
|
|
|
a41c76 |
|
|
|
a41c76 |
src/qemu/qemu_domain.c
|
|
|
a41c76 |
|
|
|
a41c76 |
virBufferTrim change not backported, the conflict is on a
|
|
|
a41c76 |
previous conflict resolution
|
|
|
a41c76 |
Message-Id: <bbc4bf3b1ebdc99aec680487c22d2a68c1cdda5f.1585063415.git.pkrempa@redhat.com>
|
|
|
a41c76 |
|
|
|
a41c76 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
a41c76 |
---
|
|
|
a41c76 |
src/qemu/qemu_block.c | 25 +++++++++++++++++++++++++
|
|
|
a41c76 |
src/qemu/qemu_block.h | 3 +++
|
|
|
a41c76 |
src/qemu/qemu_domain.c | 13 +------------
|
|
|
a41c76 |
3 files changed, 29 insertions(+), 12 deletions(-)
|
|
|
a41c76 |
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
|
|
|
a41c76 |
index 73a424f7a8..1f48f559e3 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_block.c
|
|
|
a41c76 |
+++ b/src/qemu/qemu_block.c
|
|
|
a41c76 |
@@ -3306,3 +3306,28 @@ qemuBlockReopenReadOnly(virDomainObjPtr vm,
|
|
|
a41c76 |
|
|
|
a41c76 |
return 0;
|
|
|
a41c76 |
}
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+/**
|
|
|
a41c76 |
+ * qemuBlockStorageSourceGetCookieString:
|
|
|
a41c76 |
+ * @src: storage source
|
|
|
a41c76 |
+ *
|
|
|
a41c76 |
+ * Returns a properly formatted string representing cookies of @src in format
|
|
|
a41c76 |
+ * accepted by qemu.
|
|
|
a41c76 |
+ */
|
|
|
a41c76 |
+char *
|
|
|
a41c76 |
+qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src)
|
|
|
a41c76 |
+{
|
|
|
a41c76 |
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
+ size_t i;
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ for (i = 0; i < src->ncookies; i++) {
|
|
|
a41c76 |
+ virStorageNetCookieDefPtr cookie = src->cookies[i];
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ virBufferAsprintf(&buf, "%s=%s; ", cookie->name, cookie->value);
|
|
|
a41c76 |
+ }
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ virBufferTrim(&buf, "; ", -1);
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+ return virBufferContentAndReset(&buf;;
|
|
|
a41c76 |
+}
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
|
|
|
a41c76 |
index 506957c3d5..4e7708ce74 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_block.h
|
|
|
a41c76 |
+++ b/src/qemu/qemu_block.h
|
|
|
a41c76 |
@@ -255,3 +255,6 @@ int
|
|
|
a41c76 |
qemuBlockReopenReadOnly(virDomainObjPtr vm,
|
|
|
a41c76 |
virStorageSourcePtr src,
|
|
|
a41c76 |
qemuDomainAsyncJob asyncJob);
|
|
|
a41c76 |
+
|
|
|
a41c76 |
+char *
|
|
|
a41c76 |
+qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src);
|
|
|
a41c76 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
a41c76 |
index 3d31e176d1..4007b4dbda 100644
|
|
|
a41c76 |
--- a/src/qemu/qemu_domain.c
|
|
|
a41c76 |
+++ b/src/qemu/qemu_domain.c
|
|
|
a41c76 |
@@ -1747,18 +1747,7 @@ qemuDomainSecretStorageSourcePrepareCookies(qemuDomainObjPrivatePtr priv,
|
|
|
a41c76 |
const char *aliasprotocol)
|
|
|
a41c76 |
{
|
|
|
a41c76 |
g_autofree char *secretalias = qemuAliasForSecret(aliasprotocol, "httpcookie");
|
|
|
a41c76 |
- g_autofree char *cookies = NULL;
|
|
|
a41c76 |
- g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
|
|
a41c76 |
- size_t i;
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- for (i = 0; i < src->ncookies; i++) {
|
|
|
a41c76 |
- virStorageNetCookieDefPtr cookie = src->cookies[i];
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- virBufferAsprintf(&buf, "%s=%s; ", cookie->name, cookie->value);
|
|
|
a41c76 |
- }
|
|
|
a41c76 |
-
|
|
|
a41c76 |
- virBufferTrim(&buf, "; ", -1);
|
|
|
a41c76 |
- cookies = virBufferContentAndReset(&buf;;
|
|
|
a41c76 |
+ g_autofree char *cookies = qemuBlockStorageSourceGetCookieString(src);
|
|
|
a41c76 |
|
|
|
a41c76 |
return qemuDomainSecretAESSetup(priv, secretalias, NULL,
|
|
|
a41c76 |
(uint8_t *) cookies, strlen(cookies));
|
|
|
a41c76 |
--
|
|
|
a41c76 |
2.26.0
|
|
|
a41c76 |
|