conf: domcaps: Report <memoryBacking>

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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Kristina Hanicova 2021-07-15 14:18:04 +02:00 committed by Michal Privoznik
parent 439eaf6399
commit e27e22585a
4 changed files with 60 additions and 0 deletions

View File

@ -290,6 +290,34 @@
&lt;domainCapabilities&gt;
</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>
&lt;domainCapabilities&gt;
...
&lt;memoryBacking supported='yes'&gt;
&lt;enum name='sourceType'&gt;
&lt;value&gt;anonymous&lt;/value&gt;
&lt;value&gt;file&lt;/value&gt;
&lt;value&gt;memfd&lt;/value&gt;
&lt;/enum&gt;
&lt;/memoryBacking&gt;
...
&lt;domainCapabilities&gt;
</pre>
<dl>
<dt><code>sourceType</code></dt>
<dd>Options for the <code>type</code> attribute of the
&lt;memoryBacking&gt;&lt;source&gt; element.</dd>
</dl>
<h3><a id="elementsDevices">Devices</a></h3>
<p>

View File

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

View File

@ -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);

View File

@ -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;