Signed-off-by: Pavel Hrdina <phrd...@redhat.com>
---
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_cgroup.c   | 17 +----------------
 src/util/vircgroup.c     | 24 ++++++++++++++++++++++++
 src/util/vircgroup.h     |  3 +++
 4 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e13dacf590..0051a5574c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1954,6 +1954,7 @@ virCgroupSetCpusetCpus;
 virCgroupSetCpusetMemoryMigrate;
 virCgroupSetCpusetMems;
 virCgroupSetCpuShares;
+virCgroupSetFCAppid;
 virCgroupSetFreezerState;
 virCgroupSetMemory;
 virCgroupSetMemoryHardLimit;
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 42dba1750d..736ef11c6e 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -908,27 +908,12 @@ static int
 qemuSetupCgroupAppid(virDomainObj *vm)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
-    int inode = -1;
-    const char *path = "/sys/class/fc/fc_udev_device/appid_store";
-    g_autofree char *appid = NULL;
     virDomainResourceDef *resource = vm->def->resource;
 
     if (!resource || !resource->appid)
         return 0;
 
-    inode = virCgroupGetInode(priv->cgroup);
-    if (inode < 0)
-        return -1;
-
-    appid = g_strdup_printf("%X:%s", inode, resource->appid);
-
-    if (virFileWriteStr(path, appid, 0) < 0) {
-        virReportSystemError(errno,
-                             _("Unable to write '%s' to '%s'"), appid, path);
-        return -1;
-    }
-
-    return 0;
+    return virCgroupSetFCAppid(priv->cgroup, resource->appid);
 }
 
 
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 37b63a2e2d..ad0ee20862 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -4012,3 +4012,27 @@ virCgroupGetCpuPeriodQuota(virCgroup *cgroup, unsigned 
long long *period,
 
     return 0;
 }
+
+
+int
+virCgroupSetFCAppid(virCgroup *group,
+                    const char *appid)
+{
+    int inode = -1;
+    const char *path = "/sys/class/fc/fc_udev_device/appid_store";
+    g_autofree char *vmid = NULL;
+
+    inode = virCgroupGetInode(group);
+    if (inode < 0)
+        return -1;
+
+    vmid = g_strdup_printf("%X:%s", inode, appid);
+
+    if (virFileWriteStr(path, vmid, 0) < 0) {
+        virReportSystemError(errno,
+                             _("Unable to write '%s' to '%s'"), vmid, path);
+        return -1;
+    }
+
+    return 0;
+}
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 690f09465c..a69b435b71 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -285,3 +285,6 @@ int virCgroupHasEmptyTasks(virCgroup *cgroup, int 
controller);
 bool virCgroupControllerAvailable(int controller);
 
 int virCgroupGetInode(virCgroup *cgroup);
+
+int virCgroupSetFCAppid(virCgroup *group,
+                        const char *appid);
-- 
2.31.1

Reply via email to