Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 5584b57

Browse files
dpejeshcrobinso
authored andcommitted
virtual-disk: add iotune properties
(crobinso: add David to AUTHORS)
1 parent 250aa88 commit 5584b57

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Patches also received from
7373
Geoff Simmons <gsimmons@gsimmons.org>
7474
Martin Kletzander <mkletzan-at-redhat-dot-com>
7575
Chen Hanxiao <chenhanxiao-at-cn-dot-fujitsu-dot-com>
76+
David Shane Holden <dpejesh@yahoo.com>
7677

7778
...send patches and get your name here...
7879

virtinst/VirtualDisk.py

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,12 @@ def __init__(self, path=None, size=None, transient=False, type=None,
627627
self._error_policy = None
628628
self._serial = None
629629
self._target = None
630+
self._iotune_read_bytes_sec = None
631+
self._iotune_read_iops_sec = None
632+
self._iotune_total_bytes_sec = None
633+
self._iotune_total_iops_sec = None
634+
self._iotune_write_bytes_sec = None
635+
self._iotune_write_iops_sec = None
630636
self._validate = validate
631637

632638
# XXX: No property methods for these
@@ -901,6 +907,84 @@ def _set_serial(self, val, validate=True):
901907
self.serial)
902908
serial = _xml_property(_get_serial, _set_serial,
903909
xpath="./serial")
910+
911+
def _get_iotune_read_bytes_sec(self):
912+
return self._iotune_read_bytes_sec
913+
def _set_iotune_read_bytes_sec(self, val):
914+
if (type(val) is not type(1) or val < 0):
915+
raise ValueError(_("IOTune read bytes per second value must be an "
916+
"integer"))
917+
self._iotune_read_bytes_sec = val
918+
iotune_read_bytes_sec = _xml_property(_get_iotune_read_bytes_sec,
919+
_set_iotune_read_bytes_sec,
920+
xpath="./iotune/read_bytes_sec",
921+
get_converter=lambda s, x: int(x or 0),
922+
set_converter=lambda s, x: int(x))
923+
924+
def _get_iotune_read_iops_sec(self):
925+
return self._iotune_read_iops_sec
926+
def _set_iotune_read_iops_sec(self, val):
927+
if (type(val) is not type(1) or val < 0):
928+
raise ValueError(_("IOTune read iops per second value must be an "
929+
"integer"))
930+
self._iotune_read_iops_sec = val
931+
iotune_read_iops_sec = _xml_property(_get_iotune_read_iops_sec,
932+
_set_iotune_read_iops_sec,
933+
xpath="./iotune/read_iops_sec",
934+
get_converter=lambda s, x: int(x or 0),
935+
set_converter=lambda s, x: int(x))
936+
937+
def _get_iotune_total_bytes_sec(self):
938+
return self._iotune_total_bytes_sec
939+
def _set_iotune_total_bytes_sec(self, val):
940+
if (type(val) is not type(1) or val < 0):
941+
raise ValueError(_("IOTune total bytes per second value must be an "
942+
"integer"))
943+
self._iotune_total_bytes_sec = val
944+
iotune_total_bytes_sec = _xml_property(_get_iotune_total_bytes_sec,
945+
_set_iotune_total_bytes_sec,
946+
xpath="./iotune/total_bytes_sec",
947+
get_converter=lambda s, x: int(x or 0),
948+
set_converter=lambda s, x: int(x))
949+
950+
def _get_iotune_total_iops_sec(self):
951+
return self._iotune_total_iops_sec
952+
def _set_iotune_total_iops_sec(self, val):
953+
if (type(val) is not type(1) or val < 0):
954+
raise ValueError(_("IOTune total iops per second value must be an "
955+
"integer"))
956+
self._iotune_total_iops_sec = val
957+
iotune_total_iops_sec = _xml_property(_get_iotune_total_iops_sec,
958+
_set_iotune_total_iops_sec,
959+
xpath="./iotune/total_iops_sec",
960+
get_converter=lambda s, x: int(x or 0),
961+
set_converter=lambda s, x: int(x))
962+
963+
def _get_iotune_write_bytes_sec(self):
964+
return self._iotune_write_bytes_sec
965+
def _set_iotune_write_bytes_sec(self, val):
966+
if (type(val) is not type(1) or val < 0):
967+
raise ValueError(_("IOTune write bytes per second value must be an "
968+
"integer"))
969+
self._iotune_write_bytes_sec = val
970+
iotune_write_bytes_sec = _xml_property(_get_iotune_write_bytes_sec,
971+
_set_iotune_write_bytes_sec,
972+
xpath="./iotune/write_bytes_sec",
973+
get_converter=lambda s, x: int(x or 0),
974+
set_converter=lambda s, x: int(x))
975+
976+
def _get_iotune_write_iops_sec(self):
977+
return self._iotune_write_iops_sec
978+
def _set_iotune_write_iops_sec(self, val):
979+
if (type(val) is not type(1) or val < 0):
980+
raise ValueError(_("IOTune write iops per second value must be an "
981+
"integer"))
982+
self._iotune_write_iops_sec = val
983+
iotune_write_iops_sec = _xml_property(_get_iotune_write_iops_sec,
984+
_set_iotune_write_iops_sec,
985+
xpath="./iotune/write_iops_sec",
986+
get_converter=lambda s, x: int(x or 0),
987+
set_converter=lambda s, x: int(x))
904988

905989
# If there is no selinux support on the libvirt connection or the
906990
# system, we won't throw errors if this is set, just silently ignore.
@@ -1536,6 +1620,24 @@ def _get_xml_config(self, disknode=None):
15361620
if self.serial:
15371621
ret += (" <serial>%s</serial>\n" %
15381622
_util.xml_escape(self.serial))
1623+
1624+
if (self.iotune_read_bytes_sec or self.iotune_read_iops_sec or
1625+
self.iotune_total_bytes_sec or self.iotune_total_iops_sec or
1626+
self.iotune_write_bytes_sec or self.iotune_write_iops_sec):
1627+
ret += " <iotune>"
1628+
if self.iotune_read_bytes_sec:
1629+
ret += " <read_bytes_sec>%s</read_bytes_sec>" % (self.iotune_read_bytes_sec)
1630+
if self.iotune_read_iops_sec:
1631+
ret += " <read_iops_sec>%s</read_iops_sec>" % (self.iotune_read_iops_sec)
1632+
if self.iotune_total_bytes_sec:
1633+
ret += " <total_bytes_sec>%s</total_bytes_sec>" % (self.iotune_total_bytes_sec)
1634+
if self.iotune_total_iops_sec:
1635+
ret += " <total_iops_sec>%s</total_iops_sec>" % (self.iotune_total_iops_sec)
1636+
if self.iotune_write_bytes_sec:
1637+
ret += " <write_bytes_sec>%s</write_bytes_sec>" % (self.iotune_write_bytes_sec)
1638+
if self.iotune_write_iops_sec:
1639+
ret += " <write_iops_sec>%s</write_iops_sec>" % (self.iotune_write_iops_sec)
1640+
ret += " </iotune>"
15391641

15401642
ret += " </disk>"
15411643
return ret

0 commit comments

Comments
 (0)