From 555866389c26a1bcf4f6cec9406e3c8ad435d778 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Thu, 16 May 2013 22:00:03 +0200 Subject: [PATCH] Add support for locking domain's memory pages 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): --- 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 c6c0728a4f..a71c484671 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -595,22 +595,28 @@ <memoryBacking> <hugepages/> <nosharepages/> + <locked/> </memoryBacking> ... </domain> +

The optional memoryBacking element may contain several + elements that influence how virtual memory pages are backed by host + pages.

+
-
memoryBacking
-
The optional memoryBacking element has two - optional elements. The element hugepages tells - the hypervisor that the guest should have its memory allocated - using hugepages instead of the normal native page size. And the - optional element nosharepages - (since 1.0.6) tells the hypervisor - that share pages (memory merge, KSM) should be disabled on guest - startup. -
+
hugepages
+
This tells the hypervisor that the guest should have its memory + allocated using hugepages instead of the normal native page size.
+
nosharepages
+
Instructs hypervisor to disable shared pages (memory merge, KSM) for + this domain. Since 1.0.6
+
locked
+
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. + Since 1.0.6
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 8c7c1bcf01..018ca0b6be 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -501,6 +501,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 11978dbe2e..b5e5d4d050 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, " \n"); - if (def->mem.hugepage_backed || def->mem.nosharepages) + if (def->mem.hugepage_backed || def->mem.nosharepages || def->mem.locked) { virBufferAddLit(buf, " \n"); - - if (def->mem.hugepage_backed) - virBufferAddLit(buf, " \n"); - - if (def->mem.nosharepages) - virBufferAddLit(buf, " \n"); - - if (def->mem.hugepage_backed || def->mem.nosharepages) + if (def->mem.hugepage_backed) + virBufferAddLit(buf, " \n"); + if (def->mem.nosharepages) + virBufferAddLit(buf, " \n"); + if (def->mem.locked) + virBufferAddLit(buf, " \n"); virBufferAddLit(buf, " \n"); + } virBufferAddLit(buf, "