virt-install: Add --memtune option
This patch provides the ability to tune memroy tunable parameters for the domain. Also add test cases for --memtune option and update man page. Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
This commit is contained in:
parent
6722d2049e
commit
a48f75078d
|
@ -151,6 +151,15 @@ mode.
|
|||
|
||||
Use --numatune=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsNUMATuning>
|
||||
|
||||
=item --memtune=SOFT_LIMIT,[hard_limit=HARD_LIMIT,swap_hard_limit=SW_HARD_LIMIT,min_guarantee=MIN_GUARANTEE]
|
||||
|
||||
Tune memory policy for the domain process. Example invocations
|
||||
|
||||
--memtune 1000
|
||||
--memtune hard_limit=100,soft_limit=60,swap_hard_limit=150,min_guarantee=80
|
||||
|
||||
Use --memtune=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsMemoryTuning>
|
||||
|
||||
=item --blkiotune=WEIGHT,[device_path=DEVICE_PATH,device_weight=DEVICE_WEIGHT]
|
||||
|
||||
Tune blkio policy for the domain process. Example invocations
|
||||
|
|
|
@ -464,6 +464,7 @@ c.add_valid("--cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo,forbid=bar,di
|
|||
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("--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
|
||||
|
|
|
@ -81,6 +81,12 @@
|
|||
<memoryBacking>
|
||||
<hugepages/>
|
||||
</memoryBacking>
|
||||
<memtune>
|
||||
<hard_limit>2048</hard_limit>
|
||||
<soft_limit>200</soft_limit>
|
||||
<swap_hard_limit>400</swap_hard_limit>
|
||||
<min_guarantee>500</min_guarantee>
|
||||
</memtune>
|
||||
<blkiotune>
|
||||
<weight>200</weight>
|
||||
<device>
|
||||
|
|
|
@ -191,6 +191,12 @@ class XMLParseTest(unittest.TestCase):
|
|||
check("memory_mode", "interleave", "strict", None)
|
||||
check("memory_nodeset", "1-5,^3,7", "2,4,6")
|
||||
|
||||
check = self._make_checker(guest.memtune)
|
||||
check("hard_limit", None, 1024, 2048)
|
||||
check("soft_limit", None, 100, 200)
|
||||
check("swap_hard_limit", None, 300, 400)
|
||||
check("min_guarantee", None, 400, 500)
|
||||
|
||||
check = self._make_checker(guest.blkiotune)
|
||||
check("weight", None, 100, 200)
|
||||
check("device_weight", None, 300)
|
||||
|
|
|
@ -27,6 +27,7 @@ from virtinst.osxml import OSXML
|
|||
from virtinst.domainfeatures import DomainFeatures
|
||||
from virtinst.domainnumatune import DomainNumatune
|
||||
from virtinst.domainblkiotune import DomainBlkiotune
|
||||
from virtinst.domainmemorytune import DomainMemorytune
|
||||
from virtinst.clock import Clock
|
||||
from virtinst.cpu import CPU, CPUFeature
|
||||
from virtinst.seclabel import Seclabel
|
||||
|
|
|
@ -782,6 +782,8 @@ def add_guest_xml_options(geng):
|
|||
help=_("Set domain security driver configuration."))
|
||||
geng.add_argument("--numatune",
|
||||
help=_("Tune NUMA policy for the domain process."))
|
||||
geng.add_argument("--memtune", action="append",
|
||||
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("--features",
|
||||
|
@ -1248,6 +1250,21 @@ class ParserMemory(VirtCLIParser):
|
|||
self.set_param("hugepage", "hugepages", is_onoff=True)
|
||||
|
||||
|
||||
#####################
|
||||
# --memtune parsing #
|
||||
#####################
|
||||
|
||||
class ParserMemorytune(VirtCLIParser):
|
||||
def _init_params(self):
|
||||
self.remove_first = "soft_limit"
|
||||
self.clear_attr = "memtune"
|
||||
|
||||
self.set_param("memtune.hard_limit", "hard_limit")
|
||||
self.set_param("memtune.soft_limit", "soft_limit")
|
||||
self.set_param("memtune.swap_hard_limit", "swap_hard_limit")
|
||||
self.set_param("memtune.min_guarantee", "min_guarantee")
|
||||
|
||||
|
||||
###################
|
||||
# --vcpus parsing #
|
||||
###################
|
||||
|
@ -2176,6 +2193,7 @@ def build_parser_map(options, skip=None, only=None):
|
|||
|
||||
register_parser("metadata", ParserMetadata)
|
||||
register_parser("memory", ParserMemory)
|
||||
register_parser("memtune", ParserMemorytune)
|
||||
register_parser("vcpus", ParserVCPU)
|
||||
register_parser("cpu", ParserCPU)
|
||||
register_parser("numatune", ParserNumatune)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# 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 DomainMemorytune(XMLBuilder):
|
||||
"""
|
||||
Class for generating <memtune> XML
|
||||
"""
|
||||
|
||||
_XML_ROOT_NAME = "memtune"
|
||||
_XML_PROP_ORDER = ["hard_limit", "soft_limit", "swap_hard_limit",
|
||||
"min_guarantee"]
|
||||
|
||||
hard_limit = XMLProperty("./hard_limit", is_int=True)
|
||||
soft_limit = XMLProperty("./soft_limit", is_int=True)
|
||||
swap_hard_limit = XMLProperty("./swap_hard_limit", is_int=True)
|
||||
min_guarantee = XMLProperty("./min_guarantee", is_int=True)
|
|
@ -35,6 +35,7 @@ from virtinst import Clock
|
|||
from virtinst import Seclabel
|
||||
from virtinst import CPU
|
||||
from virtinst import DomainNumatune
|
||||
from virtinst import DomainMemorytune
|
||||
from virtinst import DomainBlkiotune
|
||||
from virtinst import DomainFeatures
|
||||
from virtinst import PM
|
||||
|
@ -91,7 +92,7 @@ class Guest(XMLBuilder):
|
|||
|
||||
_XML_ROOT_NAME = "domain"
|
||||
_XML_PROP_ORDER = ["type", "name", "uuid", "title", "description",
|
||||
"maxmemory", "memory", "hugepage", "vcpus", "curvcpus",
|
||||
"maxmemory", "memory", "hugepage", "vcpus", "curvcpus", "memtune",
|
||||
"numatune", "blkiotune", "bootloader", "os", "idmap", "features", "cpu",
|
||||
"clock", "on_poweroff", "on_reboot", "on_crash", "pm", "emulator", "_devices",
|
||||
"seclabel"]
|
||||
|
@ -192,6 +193,7 @@ class Guest(XMLBuilder):
|
|||
numatune = XMLChildProperty(DomainNumatune, is_single=True)
|
||||
pm = XMLChildProperty(PM, is_single=True)
|
||||
blkiotune = XMLChildProperty(DomainBlkiotune, is_single=True)
|
||||
memtune = XMLChildProperty(DomainMemorytune, is_single=True)
|
||||
idmap = XMLChildProperty(IdMap, is_single=True)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue