render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 45181b943720b46caf3263c2edbc5c0427870369 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <45181b943720b46caf3263c2edbc5c0427870369@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:12:04 +0100
a41c76
Subject: [PATCH] qemu: Handle hotplug and commandline for secret objects for
a41c76
 http cookies
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Implement both commandline support and hotplug by adding the http cookie
a41c76
handling to 'qemuBlockStorageSourceAttachData' handling functions for
a41c76
it.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit b512935b17d991dcdd1a14e39e5f13ca828bd416)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
a41c76
Message-Id: <40869b86260516bd56253a39e5dfb54519e5313e.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_block.c   | 13 +++++++++++++
a41c76
 src/qemu/qemu_block.h   |  3 +++
a41c76
 src/qemu/qemu_command.c |  5 +++++
a41c76
 3 files changed, 21 insertions(+)
a41c76
a41c76
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
a41c76
index e60975a142..f07420b6e2 100644
a41c76
--- a/src/qemu/qemu_block.c
a41c76
+++ b/src/qemu/qemu_block.c
a41c76
@@ -1499,11 +1499,13 @@ qemuBlockStorageSourceAttachDataFree(qemuBlockStorageSourceAttachDataPtr data)
a41c76
     virJSONValueFree(data->formatProps);
a41c76
     virJSONValueFree(data->prmgrProps);
a41c76
     virJSONValueFree(data->authsecretProps);
a41c76
+    virJSONValueFree(data->httpcookiesecretProps);
a41c76
     virJSONValueFree(data->encryptsecretProps);
a41c76
     virJSONValueFree(data->tlsProps);
a41c76
     VIR_FREE(data->tlsAlias);
a41c76
     VIR_FREE(data->authsecretAlias);
a41c76
     VIR_FREE(data->encryptsecretAlias);
a41c76
+    VIR_FREE(data->httpcookiesecretAlias);
a41c76
     VIR_FREE(data->driveCmd);
a41c76
     VIR_FREE(data->driveAlias);
a41c76
     VIR_FREE(data);
a41c76
@@ -1570,6 +1572,11 @@ qemuBlockStorageSourceAttachApplyStorageDeps(qemuMonitorPtr mon,
a41c76
                              &data->authsecretAlias) < 0)
a41c76
         return -1;
a41c76
 
a41c76
+    if (data->httpcookiesecretProps &&
a41c76
+        qemuMonitorAddObject(mon, &data->httpcookiesecretProps,
a41c76
+                             &data->httpcookiesecretAlias) < 0)
a41c76
+        return -1;
a41c76
+
a41c76
     if (data->tlsProps &&
a41c76
         qemuMonitorAddObject(mon, &data->tlsProps, &data->tlsAlias) < 0)
a41c76
         return -1;
a41c76
@@ -1713,6 +1720,9 @@ qemuBlockStorageSourceAttachRollback(qemuMonitorPtr mon,
a41c76
     if (data->encryptsecretAlias)
a41c76
         ignore_value(qemuMonitorDelObject(mon, data->encryptsecretAlias));
a41c76
 
a41c76
+    if (data->httpcookiesecretAlias)
a41c76
+        ignore_value(qemuMonitorDelObject(mon, data->httpcookiesecretAlias));
a41c76
+
a41c76
     if (data->tlsAlias)
a41c76
         ignore_value(qemuMonitorDelObject(mon, data->tlsAlias));
a41c76
 
a41c76
@@ -1768,6 +1778,9 @@ qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr src,
a41c76
 
a41c76
         if (srcpriv->encinfo && srcpriv->encinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES)
a41c76
             data->encryptsecretAlias = g_strdup(srcpriv->encinfo->s.aes.alias);
a41c76
+
a41c76
+        if (srcpriv->httpcookie)
a41c76
+            data->httpcookiesecretAlias = g_strdup(srcpriv->httpcookie->s.aes.alias);
a41c76
     }
a41c76
 
a41c76
     return g_steal_pointer(&data);
a41c76
diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h
a41c76
index eab0128d5d..197f5dae97 100644
a41c76
--- a/src/qemu/qemu_block.h
a41c76
+++ b/src/qemu/qemu_block.h
a41c76
@@ -100,6 +100,9 @@ struct qemuBlockStorageSourceAttachData {
a41c76
     virJSONValuePtr encryptsecretProps;
a41c76
     char *encryptsecretAlias;
a41c76
 
a41c76
+    virJSONValuePtr httpcookiesecretProps;
a41c76
+    char *httpcookiesecretAlias;
a41c76
+
a41c76
     virJSONValuePtr tlsProps;
a41c76
     char *tlsAlias;
a41c76
 };
a41c76
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
a41c76
index fc5366d88d..de97504ce1 100644
a41c76
--- a/src/qemu/qemu_command.c
a41c76
+++ b/src/qemu/qemu_command.c
a41c76
@@ -2413,6 +2413,7 @@ qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
a41c76
     if (qemuBuildObjectCommandline(cmd, data->prmgrProps) < 0 ||
a41c76
         qemuBuildObjectCommandline(cmd, data->authsecretProps) < 0 ||
a41c76
         qemuBuildObjectCommandline(cmd, data->encryptsecretProps) < 0 ||
a41c76
+        qemuBuildObjectCommandline(cmd, data->httpcookiesecretProps) < 0 ||
a41c76
         qemuBuildObjectCommandline(cmd, data->tlsProps) < 0)
a41c76
         return -1;
a41c76
 
a41c76
@@ -10349,6 +10350,10 @@ qemuBuildStorageSourceAttachPrepareCommon(virStorageSourcePtr src,
a41c76
         if (srcpriv->encinfo &&
a41c76
             qemuBuildSecretInfoProps(srcpriv->encinfo, &data->encryptsecretProps) < 0)
a41c76
             return -1;
a41c76
+
a41c76
+        if (srcpriv->httpcookie &&
a41c76
+            qemuBuildSecretInfoProps(srcpriv->httpcookie, &data->httpcookiesecretProps) < 0)
a41c76
+            return -1;
a41c76
     }
a41c76
 
a41c76
     if (src->haveTLS == VIR_TRISTATE_BOOL_YES &&
a41c76
-- 
a41c76
2.25.1
a41c76