The following XML configuration can be used to request all domain's memory pages to be kept locked in host's memory (i.e., domain's memory pages will not be swapped out): <memoryBacking> <locked/> </memoryBacking> --- docs/formatdomain.html.in | 26 ++++++++++++++++---------- docs/schemas/domaincommon.rng | 5 +++++ src/conf/domain_conf.c | 20 +++++++++++--------- src/conf/domain_conf.h | 1 + 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index c6c0728..a71c484 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -595,22 +595,28 @@ <memoryBacking> <hugepages/> <nosharepages/> + <locked/> </memoryBacking> ... </domain> </pre> + <p>The optional <code>memoryBacking</code> element may contain several + elements that influence how virtual memory pages are backed by host + pages.</p> + <dl> - <dt><code>memoryBacking</code></dt> - <dd>The optional <code>memoryBacking</code> element has two - optional elements. The element <code>hugepages</code> tells - the hypervisor that the guest should have its memory allocated - using hugepages instead of the normal native page size. And the - optional element <code>nosharepages</code> - (<span class="since">since 1.0.6</span>) tells the hypervisor - that share pages (memory merge, KSM) should be disabled on guest - startup. - </dd> + <dt><code>hugepages</code></dt> + <dd>This tells the hypervisor that the guest should have its memory + allocated using hugepages instead of the normal native page size.</dd> + <dt><code>nosharepages</code></dt> + <dd>Instructs hypervisor to disable shared pages (memory merge, KSM) for + this domain. <span class="since">Since 1.0.6</span></dd> + <dt><code>locked</code></dt> + <dd>When set and supported by the hypervisor, memory pages belonging + to the domain will be locked in host's memory and the host will not + be allowed to swap them out. + <span class="since">Since 1.0.6</span></dd> </dl> diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 8c7c1bc..018ca0b 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -501,6 +501,11 @@ <empty/> </element> </optional> + <optional> + <element name="locked"> + <empty/> + </element> + </optional> </interleave> </element> </optional> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 11978db..b5e5d4d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10411,6 +10411,9 @@ virDomainDefParseXML(xmlDocPtr xml, if ((node = virXPathNode("./memoryBacking/nosharepages", ctxt))) def->mem.nosharepages = true; + if (virXPathBoolean("boolean(./memoryBacking/locked)", ctxt)) + def->mem.locked = true; + /* Extract blkio cgroup tunables */ if (virXPathUInt("string(./blkiotune/weight)", ctxt, &def->blkio.weight) < 0) @@ -15766,17 +15769,16 @@ virDomainDefFormatInternal(virDomainDefPtr def, def->mem.swap_hard_limit) virBufferAddLit(buf, " </memtune>\n"); - if (def->mem.hugepage_backed || def->mem.nosharepages) + if (def->mem.hugepage_backed || def->mem.nosharepages || def->mem.locked) { virBufferAddLit(buf, " <memoryBacking>\n"); - - if (def->mem.hugepage_backed) - virBufferAddLit(buf, " <hugepages/>\n"); - - if (def->mem.nosharepages) - virBufferAddLit(buf, " <nosharepages/>\n"); - - if (def->mem.hugepage_backed || def->mem.nosharepages) + if (def->mem.hugepage_backed) + virBufferAddLit(buf, " <hugepages/>\n"); + if (def->mem.nosharepages) + virBufferAddLit(buf, " <nosharepages/>\n"); + if (def->mem.locked) + virBufferAddLit(buf, " <locked/>\n"); virBufferAddLit(buf, " </memoryBacking>\n"); + } virBufferAddLit(buf, " <vcpu"); virBufferAsprintf(buf, " placement='%s'", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f40bfc6..a10b2ab 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1863,6 +1863,7 @@ struct _virDomainDef { unsigned long long cur_balloon; /* in kibibytes */ bool hugepage_backed; bool nosharepages; + bool locked; int dump_core; /* enum virDomainMemDump */ unsigned long long hard_limit; /* in kibibytes */ unsigned long long soft_limit; /* in kibibytes */ -- 1.8.2.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list