virt-install: Add --membacking option

Add option --membacking for "Memory Backing".

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
Chen Hanxiao 2014-03-22 18:15:46 +08:00 committed by Cole Robinson
parent 58a07d04fb
commit 7096c3708e
8 changed files with 66 additions and 0 deletions

View File

@ -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> 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 =item --arch=ARCH
Request a non-native CPU architecture for the guest virtual machine. Request a non-native CPU architecture for the guest virtual machine.

View File

@ -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("--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("--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("--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_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_compare("--connect %(DEFAULTURI)s --cpuset auto --vcpus 2", "cpuset-auto") # --cpuset=auto actually works
c.add_invalid("--vcpus 32 --cpuset=969-1000") # Bogus cpuset c.add_invalid("--vcpus 32 --cpuset=969-1000") # Bogus cpuset

View File

@ -80,6 +80,8 @@
<description>Hey desc changed&amp;</description> <description>Hey desc changed&amp;</description>
<memoryBacking> <memoryBacking>
<hugepages/> <hugepages/>
<nosharepages/>
<locked/>
</memoryBacking> </memoryBacking>
<memtune> <memtune>
<hard_limit>2048</hard_limit> <hard_limit>2048</hard_limit>

View File

@ -213,6 +213,11 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(guest.get_devices("memballoon")[0]) check = self._make_checker(guest.get_devices("memballoon")[0])
check("model", "virtio", "none") 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) self._alter_compare(guest.get_xml_config(), outfile)
def testAlterMinimalGuest(self): def testAlterMinimalGuest(self):

View File

@ -28,6 +28,7 @@ from virtinst.domainfeatures import DomainFeatures
from virtinst.domainnumatune import DomainNumatune from virtinst.domainnumatune import DomainNumatune
from virtinst.domainblkiotune import DomainBlkiotune from virtinst.domainblkiotune import DomainBlkiotune
from virtinst.domainmemorytune import DomainMemorytune from virtinst.domainmemorytune import DomainMemorytune
from virtinst.domainmemorybacking import DomainMemorybacking
from virtinst.clock import Clock from virtinst.clock import Clock
from virtinst.cpu import CPU, CPUFeature from virtinst.cpu import CPU, CPUFeature
from virtinst.seclabel import Seclabel from virtinst.seclabel import Seclabel

View File

@ -786,6 +786,8 @@ def add_guest_xml_options(geng):
help=_("Tune memory policy for the domain process.")) help=_("Tune memory policy for the domain process."))
geng.add_argument("--blkiotune", action="append", geng.add_argument("--blkiotune", action="append",
help=_("Tune blkio policy for the domain process.")) 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", geng.add_argument("--features",
help=_("Set domain <features> XML. Ex:\n" help=_("Set domain <features> XML. Ex:\n"
"--features acpi=off\n" "--features acpi=off\n"
@ -2034,6 +2036,19 @@ class ParserBlkiotune(VirtCLIParser):
self.set_param("blkiotune.device_weight", "device_weight") 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 # # --serial, --parallel, --channel, --console parsing #
###################################################### ######################################################
@ -2200,6 +2215,7 @@ def build_parser_map(options, skip=None, only=None):
register_parser("cpu", ParserCPU) register_parser("cpu", ParserCPU)
register_parser("numatune", ParserNumatune) register_parser("numatune", ParserNumatune)
register_parser("blkiotune", ParserBlkiotune) register_parser("blkiotune", ParserBlkiotune)
register_parser("membacking", ParserMemorybacking)
register_parser("idmap", ParserIdmap) register_parser("idmap", ParserIdmap)
register_parser("boot", ParserBoot) register_parser("boot", ParserBoot)
register_parser("security", ParserSecurity) register_parser("security", ParserSecurity)

View File

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

View File

@ -36,6 +36,7 @@ from virtinst import Seclabel
from virtinst import CPU from virtinst import CPU
from virtinst import DomainNumatune from virtinst import DomainNumatune
from virtinst import DomainMemorytune from virtinst import DomainMemorytune
from virtinst import DomainMemorybacking
from virtinst import DomainBlkiotune from virtinst import DomainBlkiotune
from virtinst import DomainFeatures from virtinst import DomainFeatures
from virtinst import PM from virtinst import PM
@ -194,6 +195,7 @@ class Guest(XMLBuilder):
pm = XMLChildProperty(PM, is_single=True) pm = XMLChildProperty(PM, is_single=True)
blkiotune = XMLChildProperty(DomainBlkiotune, is_single=True) blkiotune = XMLChildProperty(DomainBlkiotune, is_single=True)
memtune = XMLChildProperty(DomainMemorytune, is_single=True) memtune = XMLChildProperty(DomainMemorytune, is_single=True)
memoryBacking = XMLChildProperty(DomainMemorybacking, is_single=True)
idmap = XMLChildProperty(IdMap, is_single=True) idmap = XMLChildProperty(IdMap, is_single=True)