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