Pablo Greco 40546a
From 0e97054a08adcd9648d006a8b03effa7f7cf2e94 Mon Sep 17 00:00:00 2001
Pablo Greco 40546a
Message-Id: <0e97054a08adcd9648d006a8b03effa7f7cf2e94@dist-git>
Pablo Greco 40546a
From: Erik Skultety <eskultet@redhat.com>
Pablo Greco 40546a
Date: Thu, 3 Jan 2019 10:03:45 +0100
Pablo Greco 40546a
Subject: [PATCH] qemu: process: SEV: Assume libDir to be the directory to
Pablo Greco 40546a
 create files in
Pablo Greco 40546a
Pablo Greco 40546a
Since SEV operates on a per domain basis, it's very likely that all
Pablo Greco 40546a
SEV launch-related data will be created under
Pablo Greco 40546a
/var/lib/libvirt/qemu/<domain_name>. Therefore, when calling into
Pablo Greco 40546a
qemuProcessSEVCreateFile we can assume @libDir as the directory prefix
Pablo Greco 40546a
rather than passing it explicitly.
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Pablo Greco 40546a
Acked-by: Michal Privoznik <mprivozn@redhat.com>
Pablo Greco 40546a
(cherry picked from commit 2c4c7de1595330a828015dd750b5ef3874f289d1)
Pablo Greco 40546a
Pablo Greco 40546a
https://bugzilla.redhat.com/show_bug.cgi?id=1658112
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Pablo Greco 40546a
Message-Id: <0f59cc4873d5faab4339e79714377da9f889703c.1546506016.git.eskultet@redhat.com>
Pablo Greco 40546a
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Pablo Greco 40546a
---
Pablo Greco 40546a
 src/qemu/qemu_process.c | 9 +++++----
Pablo Greco 40546a
 1 file changed, 5 insertions(+), 4 deletions(-)
Pablo Greco 40546a
Pablo Greco 40546a
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
Pablo Greco 40546a
index c0f95dd5f1..757e2d33a4 100644
Pablo Greco 40546a
--- a/src/qemu/qemu_process.c
Pablo Greco 40546a
+++ b/src/qemu/qemu_process.c
Pablo Greco 40546a
@@ -5985,14 +5985,15 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
 static int
Pablo Greco 40546a
-qemuProcessSEVCreateFile(const char *configDir,
Pablo Greco 40546a
+qemuProcessSEVCreateFile(virDomainObjPtr vm,
Pablo Greco 40546a
                          const char *name,
Pablo Greco 40546a
                          const char *data)
Pablo Greco 40546a
 {
Pablo Greco 40546a
+    qemuDomainObjPrivatePtr priv = vm->privateData;
Pablo Greco 40546a
     char *configFile;
Pablo Greco 40546a
     int ret = -1;
Pablo Greco 40546a
 
Pablo Greco 40546a
-    if (!(configFile = virFileBuildPath(configDir, name, ".base64")))
Pablo Greco 40546a
+    if (!(configFile = virFileBuildPath(priv->libDir, name, ".base64")))
Pablo Greco 40546a
         return -1;
Pablo Greco 40546a
 
Pablo Greco 40546a
     if (virFileRewriteStr(configFile, S_IRUSR | S_IWUSR, data) < 0) {
Pablo Greco 40546a
@@ -6029,12 +6030,12 @@ qemuProcessPrepareSEVGuestInput(virDomainObjPtr vm)
Pablo Greco 40546a
     }
Pablo Greco 40546a
 
Pablo Greco 40546a
     if (sev->dh_cert) {
Pablo Greco 40546a
-        if (qemuProcessSEVCreateFile(priv->libDir, "dh_cert", sev->dh_cert) < 0)
Pablo Greco 40546a
+        if (qemuProcessSEVCreateFile(vm, "dh_cert", sev->dh_cert) < 0)
Pablo Greco 40546a
             return -1;
Pablo Greco 40546a
     }
Pablo Greco 40546a
 
Pablo Greco 40546a
     if (sev->session) {
Pablo Greco 40546a
-        if (qemuProcessSEVCreateFile(priv->libDir, "session", sev->session) < 0)
Pablo Greco 40546a
+        if (qemuProcessSEVCreateFile(vm, "session", sev->session) < 0)
Pablo Greco 40546a
             return -1;
Pablo Greco 40546a
     }
Pablo Greco 40546a
 
Pablo Greco 40546a
-- 
Pablo Greco 40546a
2.22.0
Pablo Greco 40546a