render / rpms / libvirt

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