]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Prepare TPM when starting a domain
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Nov 2016 14:25:15 +0000 (15:25 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 15 Dec 2016 08:25:16 +0000 (09:25 +0100)
When starting a domain and separate mount namespace is used, we
have to create all the /dev entries that are configured for the
domain.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_domain.c

index 66d142ca1676be42ad6ea64a4acdcc1b63cdc452..9aa1a9f90fa8197080260158358b11bbec9c0828 100644 (file)
@@ -7146,6 +7146,35 @@ qemuDomainSetupAllChardevs(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
 }
 
 
+static int
+qemuDomainSetupTPM(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+                   virDomainObjPtr vm,
+                   const char *devPath)
+{
+    virDomainTPMDefPtr dev = vm->def->tpm;
+
+    if (!dev)
+        return 0;
+
+    VIR_DEBUG("Setting up TPM");
+
+    switch (dev->type) {
+    case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+        if (qemuDomainCreateDevice(dev->data.passthrough.source.data.file.path,
+                                   devPath, false) < 0)
+            return -1;
+        break;
+
+    case VIR_DOMAIN_TPM_TYPE_LAST:
+        /* nada */
+        break;
+    }
+
+    VIR_DEBUG("Setup TPM");
+    return 0;
+}
+
+
 int
 qemuDomainBuildNamespace(virQEMUDriverPtr driver,
                          virDomainObjPtr vm)
@@ -7193,6 +7222,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
     if (qemuDomainSetupAllChardevs(driver, vm, devPath) < 0)
         goto cleanup;
 
+    if (qemuDomainSetupTPM(driver, vm, devPath) < 0)
+        goto cleanup;
+
     if (mount(devPath, "/dev", NULL, mount_flags, NULL) < 0) {
         virReportSystemError(errno,
                              _("Failed to mount %s on /dev"),