Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
docs/formatdomain.rst | 21 +++++++++++++++++++
docs/schemas/domaincommon.rng | 13 ++++++++++++
src/conf/domain_conf.c | 9 +++++++-
src/conf/domain_conf.h | 1 +
src/conf/domain_validate.c | 19 +++++++++++++++++
.../fibrechannel-vmid.xml | 21 +++++++++++++++++++
tests/genericxml2xmltest.c | 2 ++
7 files changed, 85 insertions(+), 1 deletion(-)
create mode 100644 tests/genericxml2xmlindata/fibrechannel-vmid.xml
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 61ccd8895a..f9ea2de59c 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1221,6 +1221,27 @@ Resource partitions are currently supported by the QEMU and LXC
drivers, which
map partition paths to cgroups directories, in all mounted controllers.
:since:`Since 1.0.5`
+Fibre Channel VMID
+-------------------
+
+The FC SAN can provide various QOS levels, access control depending on the
+VMID. Also it can collect telemetry data at per-VM level which can be used
+to enhance the IO performance of the VM. This can be configured by using
+the ``vmid`` attribute of ``fibrechannel`` element. The attribute contains
+single string (max 128 bytes).
+
+::
+
+ ...
+ <resource>
+ <fibrechannel vmid='userProvidedID'/>
+ </resource>
+ ...
+
+Using this feature requires Fibre Channel capable HW, kernel compiled with
+option ``CONFIG_BLK_CGROUP_FC_APPID`` and ``nvme_fc`` kernel module loaded.
+:since:`Since 7.7.0`
+
:anchor:`<a id="elementsCPU"/>`
CPU model and topology
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 9b669d9de5..1087269fc7 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -576,6 +576,16 @@
</element>
</define>
+ <define name="fibrechannel">
+ <element name="fibrechannel">
+ <attribute name="vmid">
+ <data type="string">
+ <param name="pattern">.{1,128}</param>
+ </data>
+ </attribute>
+ </element>
+ </define>
+
<!--
The Identifiers can be:
- an optional id attribute with a number on the domain element
@@ -1177,6 +1187,9 @@
<ref name="absFilePath"/>
</element>
</optional>
+ <optional>
+ <ref name="fibrechannel"/>
+ </optional>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d33d708189..85eb5205df 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3446,6 +3446,7 @@ virDomainResourceDefFree(virDomainResourceDef *resource)
return;
g_free(resource->partition);
+ g_free(resource->vmid);
g_free(resource);
}
@@ -17293,16 +17294,19 @@ virDomainResourceDefParse(xmlNodePtr node,
VIR_XPATH_NODE_AUTORESTORE(ctxt)
virDomainResourceDef *def = NULL;
char *partition = NULL;
+ char *vmid = NULL;
ctxt->node = node;
partition = virXPathString("string(./partition)", ctxt);
+ vmid = virXPathString("string(./fibrechannel/@vmid)", ctxt);
- if (!partition)
+ if (!partition && !vmid)
return NULL;
def = g_new0(virDomainResourceDef, 1);
def->partition = partition;
+ def->vmid = vmid;
return def;
}
@@ -26802,6 +26806,9 @@ virDomainResourceDefFormat(virBuffer *buf,
if (def->partition)
virBufferEscapeString(&childBuf,
"<partition>%s</partition>\n", def->partition);
+ if (def->vmid)
+ virBufferEscapeString(&childBuf, "<fibrechannel
vmid='%s'/>\n", def->vmid);
+
virXMLFormatElement(buf, "resource", NULL, &childBuf);
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9f32bcf9cf..c978e5b4dc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2538,6 +2538,7 @@ void virBlkioDeviceArrayClear(virBlkioDevice *deviceWeights,
struct _virDomainResourceDef {
char *partition;
+ char *vmid;
};
struct _virDomainHugePage {
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index a9e4519b1a..7f27ec3fd9 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -55,6 +55,22 @@ virDomainDefBootValidate(const virDomainDef *def)
}
+static int
+virDomainDefResourceValidate(const virDomainDef *def)
+{
+ if (!def->resource)
+ return 0;
+
+ if (def->resource->vmid && strlen(def->resource->vmid) > 128)
{
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("Fibre Channel VMID cannot be longer then 128
characters"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
virDomainDefVideoValidate(const virDomainDef *def)
{
@@ -1538,6 +1554,9 @@ static int
virDomainDefValidateInternal(const virDomainDef *def,
virDomainXMLOption *xmlopt)
{
+ if (virDomainDefResourceValidate(def) < 0)
+ return -1;
+
if (virDomainDefDuplicateDiskInfoValidate(def) < 0)
return -1;
diff --git a/tests/genericxml2xmlindata/fibrechannel-vmid.xml
b/tests/genericxml2xmlindata/fibrechannel-vmid.xml
new file mode 100644
index 0000000000..fef2c86e3c
--- /dev/null
+++ b/tests/genericxml2xmlindata/fibrechannel-vmid.xml
@@ -0,0 +1,21 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>4</vcpu>
+ <resource>
+ <fibrechannel vmid='someapp:c7a5fdbd-edaf-9455-926a-d65c16db1809'/>
+ </resource>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ </devices>
+</domain>
diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c
index ef51ed91a6..62789fb7eb 100644
--- a/tests/genericxml2xmltest.c
+++ b/tests/genericxml2xmltest.c
@@ -225,6 +225,8 @@ mymain(void)
DO_TEST_DIFFERENT("cputune");
DO_TEST("device-backenddomain");
+ DO_TEST("fibrechannel-vmid");
+
#define DO_TEST_BACKUP_FULL(name, intrnl) \
do { \
const struct testCompareBackupXMLData data = { .testname = name, \
--
2.31.1