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