We need to report via domcapabilities if specifying shared memory
is supported without hugepages or numa config in order to find
out if domain has suitable setup to make virtiofs work.
The solution is to report source types of memory backing to
determine if memfd is a valid option.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
docs/formatdomaincaps.html.in | 28 ++++++++++++++++++++++++++++
docs/schemas/domaincaps.rng | 10 ++++++++++
src/conf/domain_capabilities.c | 14 ++++++++++++++
src/conf/domain_capabilities.h | 8 ++++++++
4 files changed, 60 insertions(+)
diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in
index 62f1940e6a..10d23f4c0b 100644
--- a/docs/formatdomaincaps.html.in
+++ b/docs/formatdomaincaps.html.in
@@ -290,6 +290,34 @@
<domainCapabilities>
</pre>
+ <h3><a id="elementsMemoryBacking">Memory
Backing</a></h3>
+
+ <p>
+ The <code>memory backing</code> element indicates whether or not
+ <a href="formatdomain.html#memory-backing">memory
backing</a>
+ is supported.
+ </p>
+
+<pre>
+<domainCapabilities>
+ ...
+ <memoryBacking supported='yes'>
+ <enum name='sourceType'>
+ <value>anonymous</value>
+ <value>file</value>
+ <value>memfd</value>
+ </enum>
+ </memoryBacking>
+ ...
+<domainCapabilities>
+</pre>
+
+ <dl>
+ <dt><code>sourceType</code></dt>
+ <dd>Options for the <code>type</code> attribute of the
+ <memoryBacking><source> element.</dd>
+ </dl>
+
<h3><a id="elementsDevices">Devices</a></h3>
<p>
diff --git a/docs/schemas/domaincaps.rng b/docs/schemas/domaincaps.rng
index fc668e0c78..69d7824e7c 100644
--- a/docs/schemas/domaincaps.rng
+++ b/docs/schemas/domaincaps.rng
@@ -37,6 +37,9 @@
<optional>
<ref name="cpu"/>
</optional>
+ <optional>
+ <ref name="memoryBacking"/>
+ </optional>
<optional>
<ref name="devices"/>
</optional>
@@ -165,6 +168,13 @@
</element>
</define>
+ <define name="memoryBacking">
+ <element name="memoryBacking">
+ <ref name="supported"/>
+ <ref name="enum"/>
+ </element>
+ </define>
+
<define name="devices">
<element name="devices">
<optional>
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index cb90ae0176..73139d0ec6 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -457,6 +457,18 @@ virDomainCapsCPUFormat(virBuffer *buf,
virBufferAddLit(buf, "</cpu>\n");
}
+static void
+virDomainCapsMemoryBackingFormat(virBuffer *buf,
+ const virDomainCapsMemoryBacking *memoryBacking)
+{
+ FORMAT_PROLOGUE(memoryBacking);
+
+ ENUM_PROCESS(memoryBacking, sourceType, virDomainMemorySourceTypeToString);
+
+ FORMAT_EPILOGUE(memoryBacking);
+}
+
+
static void
virDomainCapsDeviceDiskFormat(virBuffer *buf,
const virDomainCapsDeviceDisk *disk)
@@ -632,6 +644,8 @@ virDomainCapsFormat(const virDomainCaps *caps)
virDomainCapsOSFormat(&buf, &caps->os);
virDomainCapsCPUFormat(&buf, &caps->cpu);
+ virDomainCapsMemoryBackingFormat(&buf, &caps->memoryBacking);
+
virBufferAddLit(&buf, "<devices>\n");
virBufferAdjustIndent(&buf, 2);
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index b6433b20c9..a3765832c1 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -62,6 +62,13 @@ struct _virDomainCapsOS {
virDomainCapsLoader loader; /* Info about virDomainLoaderDef */
};
+STATIC_ASSERT_ENUM(VIR_DOMAIN_MEMORY_SOURCE_LAST);
+typedef struct _virDomainCapsMemoryBacking virDomainCapsMemoryBacking;
+struct _virDomainCapsMemoryBacking {
+ virTristateBool supported;
+ virDomainCapsEnum sourceType; /* virDomainMemorySource */
+};
+
STATIC_ASSERT_ENUM(VIR_DOMAIN_DISK_DEVICE_LAST);
STATIC_ASSERT_ENUM(VIR_DOMAIN_DISK_BUS_LAST);
STATIC_ASSERT_ENUM(VIR_DOMAIN_DISK_MODEL_LAST);
@@ -196,6 +203,7 @@ struct _virDomainCaps {
virDomainCapsOS os;
virDomainCapsCPU cpu;
+ virDomainCapsMemoryBacking memoryBacking;
virDomainCapsDeviceDisk disk;
virDomainCapsDeviceGraphics graphics;
virDomainCapsDeviceVideo video;
--
2.31.1