[virt-tools-list] [virt-manager PATCH] virt-install: Add --blkiotune option

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Thu Feb 6 09:40:42 UTC 2014


From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>

This patch provides the ability to
tune Blkio cgroup tunable parameters for the domain.

Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 man/virt-install.pod                    |  9 +++++++++
 tests/clitest.py                        |  1 +
 tests/xmlparse-xml/change-guest-out.xml |  7 +++++++
 tests/xmlparse.py                       |  5 +++++
 virtinst/__init__.py                    |  1 +
 virtinst/cli.py                         | 14 ++++++++++++++
 virtinst/domainblkiotune.py             | 33 +++++++++++++++++++++++++++++++++
 virtinst/guest.py                       |  4 +++-
 8 files changed, 73 insertions(+), 1 deletion(-)
 create mode 100644 virtinst/domainblkiotune.py

diff --git a/man/virt-install.pod b/man/virt-install.pod
index 360ebe4..a45849b 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<http://libvirt.org/formatdomain.html#elementsNUMATuning>
 
+=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<http://libvirt.org/formatdomain.html#elementsBlockTuning>
+
 =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 686cb1f..f5915be 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 c11c20b..4d189f4 100644
--- a/tests/xmlparse-xml/change-guest-out.xml
+++ b/tests/xmlparse-xml/change-guest-out.xml
@@ -81,5 +81,12 @@
   <memoryBacking>
     <hugepages/>
   </memoryBacking>
+  <blkiotune>
+    <weight>200</weight>
+    <device>
+      <path>/home/1.img</path>
+      <weight>300</weight>
+    </device>
+  </blkiotune>
   <bootloader>pygrub</bootloader>
 </domain>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index a34e818..508d946 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 6c84975..b9186e0 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 4e054cd..6c06a2e 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 <features> 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 0000000..9a2e022
--- /dev/null
+++ b/virtinst/domainblkiotune.py
@@ -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 DomainBlkiotune(XMLBuilder):
+    """
+    Class for generating <blkiotune> 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 adca8be..dbeb0be 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)
 
 
     ###############################
-- 
1.8.2.1




More information about the virt-tools-list mailing list