Blame SOURCES/libvirt-qemu-domain-Add-dev-sev-into-the-domain-mount-namespace-selectively.patch

edecca
From d0f98bd3ab59c5c4fa085f22df4763caabcef3b0 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <d0f98bd3ab59c5c4fa085f22df4763caabcef3b0@dist-git>
edecca
From: Erik Skultety <eskultet@redhat.com>
edecca
Date: Fri, 1 Feb 2019 17:21:56 +0100
edecca
Subject: [PATCH] qemu: domain: Add /dev/sev into the domain mount namespace
edecca
 selectively
edecca
MIME-Version: 1.0
edecca
Content-Type: text/plain; charset=UTF-8
edecca
Content-Transfer-Encoding: 8bit
edecca
edecca
Instead of exposing /dev/sev to every domain, do it selectively.
edecca
edecca
Signed-off-by: Erik Skultety <eskultet@redhat.com>
edecca
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
edecca
(cherry picked from commit 6fd4c8f8785a063112c8161a3a3f5ad3cb6647ea)
edecca
edecca
https: //bugzilla.redhat.com/show_bug.cgi?id=1665400
edecca
Signed-off-by: Erik Skultety <eskultet@redhat.com>
edecca
Reviewed-by: Ján Tomko <jtomko@redhat.com>
edecca
---
edecca
 src/qemu/qemu_domain.c | 24 ++++++++++++++++++++++++
edecca
 1 file changed, 24 insertions(+)
edecca
edecca
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
edecca
index 0ddc6ef4a7..c530733e97 100644
edecca
--- a/src/qemu/qemu_domain.c
edecca
+++ b/src/qemu/qemu_domain.c
edecca
@@ -118,6 +118,7 @@ VIR_ENUM_IMPL(qemuDomainNamespace, QEMU_DOMAIN_NS_LAST,
edecca
 #define DEVPREFIX "/dev/"
edecca
 #define DEV_VFIO "/dev/vfio/vfio"
edecca
 #define DEVICE_MAPPER_CONTROL_PATH "/dev/mapper/control"
edecca
+#define DEV_SEV "/dev/sev"
edecca
 
edecca
 
edecca
 struct _qemuDomainLogContext {
edecca
@@ -11652,6 +11653,26 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
edecca
 }
edecca
 
edecca
 
edecca
+static int
edecca
+qemuDomainSetupLaunchSecurity(virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
edecca
+                              virDomainObjPtr vm,
edecca
+                              const struct qemuDomainCreateDeviceData *data)
edecca
+{
edecca
+    virDomainSEVDefPtr sev = vm->def->sev;
edecca
+
edecca
+    if (!sev || sev->sectype != VIR_DOMAIN_LAUNCH_SECURITY_SEV)
edecca
+        return 0;
edecca
+
edecca
+    VIR_DEBUG("Setting up launch security");
edecca
+
edecca
+    if (qemuDomainCreateDevice(DEV_SEV, data, false) < 0)
edecca
+        return -1;
edecca
+
edecca
+    VIR_DEBUG("Set up launch security");
edecca
+    return 0;
edecca
+}
edecca
+
edecca
+
edecca
 int
edecca
 qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
edecca
                          virSecurityManagerPtr mgr,
edecca
@@ -11723,6 +11744,9 @@ qemuDomainBuildNamespace(virQEMUDriverConfigPtr cfg,
edecca
     if (qemuDomainSetupLoader(cfg, vm, &data) < 0)
edecca
         goto cleanup;
edecca
 
edecca
+    if (qemuDomainSetupLaunchSecurity(cfg, vm, &data) < 0)
edecca
+        goto cleanup;
edecca
+
edecca
     /* Save some mount points because we want to share them with the host */
edecca
     for (i = 0; i < ndevMountsPath; i++) {
edecca
         struct stat sb;
edecca
-- 
edecca
2.20.1
edecca