render / rpms / libvirt

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