]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: implement support for Fibre Channel VMID
authorPavel Hrdina <phrdina@redhat.com>
Mon, 2 Aug 2021 18:26:57 +0000 (20:26 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 17 Aug 2021 11:51:40 +0000 (13:51 +0200)
Based on kernel commit messages the interface is

    /sys/class/fc/fc_udev_device/appid_store

where we need to write the following string "$INODE:$APPID".

$INODE is the VM root cgroup inode in hexadecimal and $APPID is user
provided string that will be attached to each FC frame for the VM
within the cgroup identified by inode and has limit 128 bytes.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_cgroup.c

index f2d99abcfaf71e9b0b38f16b2ad6707e83520119..42dba1750dfe5149b7590e084e04fff452057207 100644 (file)
@@ -904,6 +904,34 @@ qemuSetupCpuCgroup(virDomainObj *vm)
 }
 
 
+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;
+}
+
+
 static int
 qemuInitCgroup(virDomainObj *vm,
                size_t nnicindexes,
@@ -1096,6 +1124,9 @@ qemuSetupCgroup(virDomainObj *vm,
     if (qemuSetupCpusetCgroup(vm) < 0)
         return -1;
 
+    if (qemuSetupCgroupAppid(vm) < 0)
+        return -1;
+
     return 0;
 }