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 +=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 + =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 @@ Hey desc changed& + + 2048 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 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 +# +# 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 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)