summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Hanxiao <chenhanxiao@cn.fujitsu.com>2014-03-22 18:15:46 +0800
committerCole Robinson <crobinso@redhat.com>2014-03-22 12:16:24 -0400
commit7096c3708e8d9b8b14302782734319f81278dd83 (patch)
tree9bec9bcfed376c90faeff5034218d04fc82106e6
parent58a07d04fbc4ce240769b9732a577111f6ccd001 (diff)
downloadvirt-manager-7096c3708e8d9b8b14302782734319f81278dd83.tar.gz
virt-install: Add --membacking option
Add option --membacking for "Memory Backing". Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
-rw-r--r--man/virt-install.pod6
-rw-r--r--tests/clitest.py1
-rw-r--r--tests/xmlparse-xml/change-guest-out.xml2
-rw-r--r--tests/xmlparse.py5
-rw-r--r--virtinst/__init__.py1
-rw-r--r--virtinst/cli.py16
-rw-r--r--virtinst/domainmemorybacking.py33
-rw-r--r--virtinst/guest.py2
8 files changed, 66 insertions, 0 deletions
diff --git a/man/virt-install.pod b/man/virt-install.pod
index bec1c609..fef3a47b 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -100,6 +100,12 @@ like 'maxmemory' and 'hugepages'. This deprecates the -r/--ram option.
Use --memory=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsMemoryAllocation>
+=item --membacking OPT1=yes|no[,OPT2=yes|no][...]
+
+This option will influence how virtual memory pages are backed by host pages.
+
+Use --membacking=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsMemoryBacking>
+
=item --arch=ARCH
Request a non-native CPU architecture for the guest virtual machine.
diff --git a/tests/clitest.py b/tests/clitest.py
index 6ba9a484..926064f0 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -470,6 +470,7 @@ c.add_valid("--numatune 1,2,3,5-7,^6") # Simple --numatune
c.add_valid("--numatune 1-3,4,mode=strict") # More complex, parser should do the right thing here
c.add_valid("--blkiotune weight=100,device_path=/home/test/1.img,device_weight=200") # --blkiotune
c.add_valid("--memtune hard_limit=10,soft_limit=20,swap_hard_limit=30,min_guarantee=40") # --memtune
+c.add_valid("--membacking hugepages=yes,nosharepages=yes,locked=yes") # --membacking nosharepages,locked
c.add_valid("--idmap uid_start=0,uid_target=1000,uid_count=10,gid_start=0,gid_target=1000,gid_count=10") # --idmap
c.add_compare("--connect %(DEFAULTURI)s --cpuset auto --vcpus 2", "cpuset-auto") # --cpuset=auto actually works
c.add_invalid("--vcpus 32 --cpuset=969-1000") # Bogus cpuset
diff --git a/tests/xmlparse-xml/change-guest-out.xml b/tests/xmlparse-xml/change-guest-out.xml
index 43e58eb7..5b1a12be 100644
--- a/tests/xmlparse-xml/change-guest-out.xml
+++ b/tests/xmlparse-xml/change-guest-out.xml
@@ -80,6 +80,8 @@
<description>Hey desc changed&amp;</description>
<memoryBacking>
<hugepages/>
+ <nosharepages/>
+ <locked/>
</memoryBacking>
<memtune>
<hard_limit>2048</hard_limit>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index 8f592b67..1aab55df 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -213,6 +213,11 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(guest.get_devices("memballoon")[0])
check("model", "virtio", "none")
+ check = self._make_checker(guest.memoryBacking)
+ check("hugepages", False, True)
+ check("nosharepages", False, True)
+ check("locked", False, True)
+
self._alter_compare(guest.get_xml_config(), outfile)
def testAlterMinimalGuest(self):
diff --git a/virtinst/__init__.py b/virtinst/__init__.py
index e197bd46..31beae41 100644
--- a/virtinst/__init__.py
+++ b/virtinst/__init__.py
@@ -28,6 +28,7 @@ from virtinst.domainfeatures import DomainFeatures
from virtinst.domainnumatune import DomainNumatune
from virtinst.domainblkiotune import DomainBlkiotune
from virtinst.domainmemorytune import DomainMemorytune
+from virtinst.domainmemorybacking import DomainMemorybacking
from virtinst.clock import Clock
from virtinst.cpu import CPU, CPUFeature
from virtinst.seclabel import Seclabel
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 41d6a8c1..2decdb90 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -786,6 +786,8 @@ def add_guest_xml_options(geng):
help=_("Tune memory policy for the domain process."))
geng.add_argument("--blkiotune", action="append",
help=_("Tune blkio policy for the domain process."))
+ geng.add_argument("--membacking", action="append",
+ help=_("Set memory backing policy for the domain process."))
geng.add_argument("--features",
help=_("Set domain <features> XML. Ex:\n"
"--features acpi=off\n"
@@ -2034,6 +2036,19 @@ class ParserBlkiotune(VirtCLIParser):
self.set_param("blkiotune.device_weight", "device_weight")
+########################
+# --membacking parsing #
+########################
+
+class ParserMemorybacking(VirtCLIParser):
+ def _init_params(self):
+ self.clear_attr = "memoryBacking"
+
+ self.set_param("memoryBacking.hugepages", "hugepages", is_onoff=True)
+ self.set_param("memoryBacking.nosharepages", "nosharepages", is_onoff=True)
+ self.set_param("memoryBacking.locked", "locked", is_onoff=True)
+
+
######################################################
# --serial, --parallel, --channel, --console parsing #
######################################################
@@ -2200,6 +2215,7 @@ def build_parser_map(options, skip=None, only=None):
register_parser("cpu", ParserCPU)
register_parser("numatune", ParserNumatune)
register_parser("blkiotune", ParserBlkiotune)
+ register_parser("membacking", ParserMemorybacking)
register_parser("idmap", ParserIdmap)
register_parser("boot", ParserBoot)
register_parser("security", ParserSecurity)
diff --git a/virtinst/domainmemorybacking.py b/virtinst/domainmemorybacking.py
new file mode 100644
index 00000000..1ab1932f
--- /dev/null
+++ b/virtinst/domainmemorybacking.py
@@ -0,0 +1,33 @@
+#
+# Copyright 2014 Fujitsu Limited.
+# Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA.
+
+from virtinst.xmlbuilder import XMLBuilder, XMLProperty
+
+
+class DomainMemorybacking(XMLBuilder):
+ """
+ Class for generating <memoryBacking> XML
+ """
+
+ _XML_ROOT_NAME = "memoryBacking"
+ _XML_PROP_ORDER = ["hugepages", "nosharepages", "locked"]
+
+ hugepages = XMLProperty("./hugepages", is_bool=True)
+ nosharepages = XMLProperty("./nosharepages", is_bool=True)
+ locked = XMLProperty("./locked", is_bool=True)
diff --git a/virtinst/guest.py b/virtinst/guest.py
index c7af16f9..51eda9e0 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -36,6 +36,7 @@ from virtinst import Seclabel
from virtinst import CPU
from virtinst import DomainNumatune
from virtinst import DomainMemorytune
+from virtinst import DomainMemorybacking
from virtinst import DomainBlkiotune
from virtinst import DomainFeatures
from virtinst import PM
@@ -194,6 +195,7 @@ class Guest(XMLBuilder):
pm = XMLChildProperty(PM, is_single=True)
blkiotune = XMLChildProperty(DomainBlkiotune, is_single=True)
memtune = XMLChildProperty(DomainMemorytune, is_single=True)
+ memoryBacking = XMLChildProperty(DomainMemorybacking, is_single=True)
idmap = XMLChildProperty(IdMap, is_single=True)