mirror of
https://github.com/virt-manager/virt-manager.git
synced 2026-08-04 10:23:08 -05:00
cli: --blkiotune: Convert device.* to device[0-9]*.
Libvirt can represent multiple <device> blocks here, so mirror that on the command line
This commit is contained in:
+3
-2
@@ -213,8 +213,9 @@ class XMLParseTest(unittest.TestCase):
|
||||
|
||||
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.blkiotune.devices.add_new())
|
||||
check("weight", None, 300)
|
||||
check("path", None, "/home/1.img")
|
||||
|
||||
check = self._make_checker(guest.idmap)
|
||||
check("uid_start", None, 0)
|
||||
|
||||
+12
-4
@@ -1728,16 +1728,24 @@ class ParserBlkiotune(VirtCLIParser):
|
||||
guest_propname = "blkiotune"
|
||||
remove_first = "weight"
|
||||
aliases = {
|
||||
"device.path": "device_path",
|
||||
"device.weight": "device_weight",
|
||||
"device[0-9]*.path": "device_path",
|
||||
"device[0-9]*.weight": "device_weight",
|
||||
}
|
||||
|
||||
def device_find_inst_cb(self, *args, **kwargs):
|
||||
cliarg = "device" # device[0-9]*
|
||||
list_propname = "devices" # blkiotune.devices
|
||||
cb = self._make_find_inst_cb(cliarg, list_propname)
|
||||
return cb(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def _init_class(cls, **kwargs):
|
||||
VirtCLIParser._init_class(**kwargs)
|
||||
cls.add_arg("weight", "weight")
|
||||
cls.add_arg("device.path", "device_path")
|
||||
cls.add_arg("device.weight", "device_weight")
|
||||
cls.add_arg("device[0-9]*.path", "path",
|
||||
find_inst_cb=cls.device_find_inst_cb)
|
||||
cls.add_arg("device[0-9]*.weight", "weight",
|
||||
find_inst_cb=cls.device_find_inst_cb)
|
||||
|
||||
|
||||
###########################
|
||||
|
||||
@@ -5,7 +5,15 @@
|
||||
# This work is licensed under the GNU GPLv2 or later.
|
||||
# See the COPYING file in the top-level directory.
|
||||
|
||||
from ..xmlbuilder import XMLBuilder, XMLProperty
|
||||
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
||||
|
||||
|
||||
class _BlkiotuneDevice(XMLBuilder):
|
||||
XML_NAME = "device"
|
||||
_XML_PROP_ORDER = ["path", "weight"]
|
||||
|
||||
path = XMLProperty("./path")
|
||||
weight = XMLProperty("./weight")
|
||||
|
||||
|
||||
class DomainBlkiotune(XMLBuilder):
|
||||
@@ -14,8 +22,7 @@ class DomainBlkiotune(XMLBuilder):
|
||||
"""
|
||||
|
||||
XML_NAME = "blkiotune"
|
||||
_XML_PROP_ORDER = ["weight", "device_path", "device_weight"]
|
||||
_XML_PROP_ORDER = ["weight"]
|
||||
|
||||
weight = XMLProperty("./weight", is_int=True)
|
||||
device_path = XMLProperty("./device/path")
|
||||
device_weight = XMLProperty("./device/weight", is_int=True)
|
||||
devices = XMLChildProperty(_BlkiotuneDevice)
|
||||
|
||||
Reference in New Issue
Block a user