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