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 <mpriv...@redhat.com>
---
 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 6dd7c029d..a7d26e58c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7174,6 +7174,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)
@@ -7221,6 +7261,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.11.0

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

Reply via email to