]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add hw random number generator (/dev/hwrng) to cgroup ACL
authorPradipta Kr. Banerjee <bpradip@in.ibm.com>
Thu, 16 Jan 2014 13:41:17 +0000 (19:11 +0530)
committerEric Blake <eblake@redhat.com>
Mon, 27 Jan 2014 16:48:39 +0000 (09:48 -0700)
Creating a qemu VM with /dev/hwrng as backend RNG device throws the
following error - "Could not open '/dev/hwrng': Permission denied"
This patch fixes the issue

Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_cgroup.c

index bb99f7436e6a5e9bc9a93f274e6d3871424c9b7d..de20f2d2a3c2330b0b81aff129b844e72f5f0fde 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * qemu_cgroup.c: QEMU cgroup management
  *
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2014 Red Hat, Inc.
  * Copyright (C) 2006 Daniel P. Berrange
  *
  * This library is free software; you can redistribute it and/or
@@ -553,6 +553,18 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
             goto cleanup;
     }
 
+    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,
+                                      VIR_CGROUP_DEVICE_RW);
+        virDomainAuditCgroupPath(vm, priv->cgroup, "allow",
+                                 vm->def->rng->source.file, "rw", rv == 0);
+        if (rv < 0 &&
+            !virLastErrorIsSystemErrno(ENOENT))
+            goto cleanup;
+    }
+
     ret = 0;
 cleanup:
     virObjectUnref(cfg);