This patch provides the ability to tune memroy tunable parameters for the domain. Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx> --- virtinst/__init__.py | 1 + virtinst/cli.py | 18 ++++++++++++++++++ virtinst/domainmemorytune.py | 35 +++++++++++++++++++++++++++++++++++ virtinst/guest.py | 4 +++- 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 virtinst/domainmemorytune.py diff --git a/virtinst/__init__.py b/virtinst/__init__.py index 62b6b36..e197bd4 100644 --- a/virtinst/__init__.py +++ b/virtinst/__init__.py @@ -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 diff --git a/virtinst/cli.py b/virtinst/cli.py index fb2569e..5bdc1de 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -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) diff --git a/virtinst/domainmemorytune.py b/virtinst/domainmemorytune.py new file mode 100644 index 0000000..efc917f --- /dev/null +++ b/virtinst/domainmemorytune.py @@ -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) diff --git a/virtinst/guest.py b/virtinst/guest.py index 4b01593..9f8ead5 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -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) -- 1.8.5.3 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list