[PATCH v1 15/21] qemu: Prepare RNGs when starting a domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 4afa15e..b9492a9 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7093,6 +7093,46 @@ qemuDomainSetupAllInputs(virQEMUDriverPtr driver,
 }
 
 
+static int
+qemuDomainSetupRNG(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
+                   virDomainRNGDefPtr rng,
+                   const char *devPath)
+{
+    switch ((virDomainRNGBackend) rng->backend) {
+    case VIR_DOMAIN_RNG_BACKEND_RANDOM:
+        if (qemuDomainCreateDevice(rng->source.file, devPath, false) < 0)
+            return -1;
+
+    case VIR_DOMAIN_RNG_BACKEND_EGD:
+    case VIR_DOMAIN_RNG_BACKEND_LAST:
+        /* nada */
+        break;
+    }
+
+    return 0;
+}
+
+
+static int
+qemuDomainSetupAllRNGs(virQEMUDriverPtr driver,
+                       virDomainObjPtr vm,
+                       const char *devPath)
+{
+    size_t i;
+
+    VIR_DEBUG("Setting up RNGs");
+    for (i = 0; i < vm->def->nrngs; i++) {
+        if (qemuDomainSetupRNG(driver,
+                               vm->def->rngs[i],
+                               devPath) < 0)
+            return -1;
+    }
+
+    VIR_DEBUG("Setup all RNGs");
+    return 0;
+}
+
+
 int
 qemuDomainBuildNamespace(virQEMUDriverPtr driver,
                          virDomainObjPtr vm)
@@ -7141,6 +7181,9 @@ qemuDomainBuildNamespace(virQEMUDriverPtr driver,
     if (qemuDomainSetupAllInputs(driver, vm, devPath) < 0)
         goto cleanup;
 
+    if (qemuDomainSetupAllRNGs(driver, vm, devPath) < 0)
+        goto cleanup;
+
     if (mount(devPath, "/dev", NULL, mount_flags, NULL) < 0) {
         virReportSystemError(errno,
                              _("Failed to mount %s on /dev"),
-- 
2.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux