[libvirt] [PATCH 1 of 2] Add virCgroupAllowMajor()

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

 



This interface provides a way to allow an entire major device type

diff -r 388beff59a32 -r 48a9209668ab src/cgroup.c
--- a/src/cgroup.c	Wed Oct 15 10:33:01 2008 +0000
+++ b/src/cgroup.c	Thu Oct 16 14:01:13 2008 -0700
@@ -761,6 +761,36 @@
     return rc;
 }
 
+/**
+ * virCgroupAllowDeviceMajor:
+ *
+ * @group: The cgroup to allow an entire device major type for
+ * @type: The device type (i.e., 'c' or 'b')
+ * @major: The major number of the device type
+ *
+ * Returns: 0 on success
+ */
+int virCgroupAllowDeviceMajor(virCgroupPtr group,
+                              char type,
+                              int major)
+{
+    int rc;
+    char *devstr = NULL;
+
+    if (asprintf(&devstr, "%c %i:* rwm", type, major) == -1) {
+        rc = -ENOMEM;
+        goto out;
+    }
+
+    rc = virCgroupSetValueStr(group,
+                              "devices.allow",
+                              devstr);
+ out:
+    VIR_FREE(devstr);
+
+    return rc;
+}
+
 int virCgroupSetCpuShares(virCgroupPtr group, unsigned long shares)
 {
     return virCgroupSetValueU64(group, "cpu.shares", (uint64_t)shares);
diff -r 388beff59a32 -r 48a9209668ab src/cgroup.h
--- a/src/cgroup.h	Wed Oct 15 10:33:01 2008 +0000
+++ b/src/cgroup.h	Thu Oct 16 14:01:13 2008 -0700
@@ -35,6 +35,9 @@
                          char type,
                          int major,
                          int minor);
+int virCgroupAllowDeviceMajor(virCgroupPtr group,
+                              char type,
+                              int major);
 
 int virCgroupSetCpuShares(virCgroupPtr group, unsigned long shares);
 int virCgroupGetCpuShares(virCgroupPtr group, unsigned long *shares);

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