[PATCH 1/3] qemu: cgroup: Don't use NULL path on default backed RNGs

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

 



The "random" backend for virtio-rng can be started with no path
specified which equals to /dev/random. The cgroup code didn't consider
this and called few of the functions with NULL resulting into:

 $ virsh start rng-vm
 error: Failed to start domain rng-vm
 error: Path '(null)' is not accessible: Bad address

Problem introduced by commit c6320d34637a9883e31c4081d418fc33a4277cf2
---
 src/qemu/qemu_cgroup.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 795ad90..f649d66 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -587,10 +587,16 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
     if (vm->def->rng &&
         (vm->def->rng->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM)) {
         VIR_DEBUG("Setting Cgroup ACL for RNG device");
-        rv = virCgroupAllowDevicePath(priv->cgroup, vm->def->rng->source.file,
+        const char *rngpath = vm->def->rng->source.file;
+
+        /* fix path when using the default */
+        if (!rngpath)
+            rngpath = "/dev/random";
+
+        rv = virCgroupAllowDevicePath(priv->cgroup, rngpath,
                                       VIR_CGROUP_DEVICE_RW);
         virDomainAuditCgroupPath(vm, priv->cgroup, "allow",
-                                 vm->def->rng->source.file, "rw", rv == 0);
+                                 rngpath, "rw", rv == 0);
         if (rv < 0 &&
             !virLastErrorIsSystemErrno(ENOENT))
             goto cleanup;
-- 
2.0.0

--
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]