diff --git a/man/virt-install.pod b/man/virt-install.pod index 360ebe44..04b034a9 100644 --- a/man/virt-install.pod +++ b/man/virt-install.pod @@ -151,6 +151,15 @@ mode. Use --numatune=? to see a list of all available sub options. Complete details at L +=item --blkiotune=WEIGHT,[device_path=DEVICE_PATH,device_weight=DEVICE_WEIGHT] + +Tune blkio policy for the domain process. Example invocations + + --blkiotune weight=100 + --blkiotune weight=100,device_path=/home/1.img,device_weight=200 + +Use --blkiotune=? to see a list of all available sub options. Complete details at L + =item --cpu MODEL[,+feature][,-feature][,match=MATCH][,vendor=VENDOR] Configure the CPU model and CPU features exposed to the guest. The only diff --git a/tests/clitest.py b/tests/clitest.py index 686cb1fa..f5915be7 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -465,6 +465,7 @@ c.add_valid("--cpu somemodel") # Simple --cpu c.add_valid("--cpu foobar,+x2apic,+x2apicagain,-distest,forbid=foo,forbid=bar,disable=distest2,optional=opttest,require=reqtest,match=strict,vendor=meee") # Crazy --cpu 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_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=autofoo") # Bogus cpuset diff --git a/tests/xmlparse-xml/change-guest-out.xml b/tests/xmlparse-xml/change-guest-out.xml index c11c20bc..4d189f4a 100644 --- a/tests/xmlparse-xml/change-guest-out.xml +++ b/tests/xmlparse-xml/change-guest-out.xml @@ -81,5 +81,12 @@ + + 200 + + /home/1.img + 300 + + pygrub diff --git a/tests/xmlparse.py b/tests/xmlparse.py index a34e8183..5fb12780 100644 --- a/tests/xmlparse.py +++ b/tests/xmlparse.py @@ -192,6 +192,11 @@ 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.blkiotune) + check("weight", None, 100, 200) + check("device_weight", None, 300) + check("device_path", None, "/home/1.img") + check = self._make_checker(guest.get_devices("memballoon")[0]) check("model", "virtio", "none") diff --git a/virtinst/__init__.py b/virtinst/__init__.py index 6c849755..b9186e0d 100644 --- a/virtinst/__init__.py +++ b/virtinst/__init__.py @@ -26,6 +26,7 @@ from virtinst import support from virtinst.osxml import OSXML from virtinst.domainfeatures import DomainFeatures from virtinst.domainnumatune import DomainNumatune +from virtinst.domainblkiotune import DomainBlkiotune 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 7341b74f..32534381 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -703,6 +703,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("--blkiotune", action="append", + help=_("Tune blkio policy for the domain process.")) geng.add_argument("--features", help=_("Set domain XML. Ex:\n" "--features acpi=off\n" @@ -1879,6 +1881,17 @@ class ParserPanic(VirtCLIParser): self.set_param(None, "iobase", setter_cb=set_iobase_cb) +####################### +# --blkiotune parsing # +####################### + +class ParserBlkiotune(VirtCLIParser): + def _init_params(self): + self.set_param("blkiotune.weight", "weight") + self.set_param("blkiotune.device_path", "device_path") + self.set_param("blkiotune.device_weight", "device_weight") + + ###################################################### # --serial, --parallel, --channel, --console parsing # ###################################################### @@ -2041,6 +2054,7 @@ def build_parser_map(options, skip=None, only=None): register_parser("vcpus", ParserVCPU) register_parser("cpu", ParserCPU) register_parser("numatune", ParserNumatune) + register_parser("blkiotune", ParserBlkiotune) register_parser("boot", ParserBoot) register_parser("security", ParserSecurity) register_parser("features", ParserFeatures) diff --git a/virtinst/domainblkiotune.py b/virtinst/domainblkiotune.py new file mode 100644 index 00000000..9a2e0229 --- /dev/null +++ b/virtinst/domainblkiotune.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 DomainBlkiotune(XMLBuilder): + """ + Class for generating XML + """ + + _XML_ROOT_NAME = "blkiotune" + _XML_PROP_ORDER = ["weight", "device_path", "device_weight"] + + weight = XMLProperty("./weight", is_int=True) + device_path = XMLProperty("./device/path") + device_weight = XMLProperty("./device/weight", is_int=True) diff --git a/virtinst/guest.py b/virtinst/guest.py index adca8be4..dbeb0be7 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 DomainBlkiotune from virtinst import DomainFeatures from virtinst import PM from virtinst.xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty @@ -90,7 +91,7 @@ class Guest(XMLBuilder): _XML_ROOT_NAME = "domain" _XML_PROP_ORDER = ["type", "name", "uuid", "title", "description", "maxmemory", "memory", "hugepage", "vcpus", "curvcpus", - "numatune", "bootloader", "os", "features", "cpu", "clock", + "numatune", "blkiotune", "bootloader", "os", "features", "cpu", "clock", "on_poweroff", "on_reboot", "on_crash", "pm", "emulator", "_devices", "seclabel"] @@ -188,6 +189,7 @@ class Guest(XMLBuilder): cpu = XMLChildProperty(CPU, is_single=True) numatune = XMLChildProperty(DomainNumatune, is_single=True) pm = XMLChildProperty(PM, is_single=True) + blkiotune = XMLChildProperty(DomainBlkiotune, is_single=True) ###############################