2018-02-06 12:56:41 +01:00
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
2018-04-04 14:35:41 +01:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 15:00:02 -04:00
# See the COPYING file in the top-level directory.
2018-02-06 12:56:41 +01:00
2018-03-20 15:10:04 -04:00
from . . xmlbuilder import XMLBuilder , XMLProperty , XMLChildProperty
2018-02-06 12:56:41 +01:00
2021-08-06 17:09:31 +02:00
###############
# CPU Pinning #
###############
2018-02-06 12:56:41 +01:00
class _VCPUPin ( XMLBuilder ) :
"""
Class for generating < cputune > child < vcpupin > XML
"""
2018-03-21 10:53:34 -04:00
XML_NAME = " vcpupin "
2018-02-06 12:56:41 +01:00
_XML_PROP_ORDER = [ " vcpu " , " cpuset " ]
vcpu = XMLProperty ( " ./@vcpu " , is_int = True )
cpuset = XMLProperty ( " ./@cpuset " )
2021-07-26 15:53:51 +02:00
class _IOThreadPin ( XMLBuilder ) :
"""
Class for generating < cputune > child < iothreadpin > XML
"""
XML_NAME = " iothreadpin "
_XML_PROP_ORDER = [ " iothread " , " cpuset " ]
iothread = XMLProperty ( " ./@iothread " , is_int = True )
cpuset = XMLProperty ( " ./@cpuset " )
2021-08-06 17:42:43 +02:00
##############
# Scheduling #
##############
class _VCPUSched ( XMLBuilder ) :
"""
Class for generating < cputune > child < vcpusched > XML
"""
XML_NAME = " vcpusched "
_XML_PROP_ORDER = [ " vcpus " , " scheduler " , " priority " ]
vcpus = XMLProperty ( " ./@vcpus " )
scheduler = XMLProperty ( " ./@scheduler " )
priority = XMLProperty ( " ./@priority " , is_int = True )
class _IOThreadSched ( XMLBuilder ) :
"""
Class for generating < cputune > child < iothreadsched > XML
"""
XML_NAME = " iothreadsched "
_XML_PROP_ORDER = [ " iothreads " , " scheduler " , " priority " ]
iothreads = XMLProperty ( " ./@iothreads " )
scheduler = XMLProperty ( " ./@scheduler " )
priority = XMLProperty ( " ./@priority " , is_int = True )
2021-08-07 11:03:35 +02:00
###########################
# Cache & Memory Tunables #
###########################
class _CacheTuneCache ( XMLBuilder ) :
2019-08-09 12:14:05 +03:00
"""
Class for generating < cachetune > child < cache > XML
"""
XML_NAME = " cache "
2021-08-07 11:03:35 +02:00
_XML_PROP_ORDER = [ " id " , " level " , " type " , " size " , " unit " ]
2019-08-09 12:14:05 +03:00
id = XMLProperty ( " ./@id " , is_int = True )
2021-08-07 11:03:35 +02:00
level = XMLProperty ( " ./@level " , is_int = True )
2019-08-09 12:14:05 +03:00
type = XMLProperty ( " ./@type " )
size = XMLProperty ( " ./@size " , is_int = True )
unit = XMLProperty ( " ./@unit " )
2021-08-07 11:03:35 +02:00
class _CacheTuneMonitor ( XMLBuilder ) :
"""
Class for generating < cachetune > child < monitor > XML
"""
XML_NAME = " monitor "
_XML_PROP_ORDER = [ " level " , " vcpus " ]
level = XMLProperty ( " ./@level " , is_int = True )
vcpus = XMLProperty ( " ./@vcpus " )
class _CacheTune ( XMLBuilder ) :
2019-08-09 12:14:05 +03:00
"""
Class for generating < cputune > child < cachetune > XML
"""
XML_NAME = " cachetune "
_XML_PROP_ORDER = [ " vcpus " , " caches " ]
vcpus = XMLProperty ( " ./@vcpus " )
2021-08-07 11:03:35 +02:00
caches = XMLChildProperty ( _CacheTuneCache )
monitors = XMLChildProperty ( _CacheTuneMonitor )
2019-08-09 12:14:05 +03:00
2021-08-07 11:03:35 +02:00
class _MemoryTuneNode ( XMLBuilder ) :
2019-08-14 18:50:40 +03:00
"""
Class for generating < memorytune > child < node > XML
"""
XML_NAME = " node "
_XML_PROP_ORDER = [ " id " , " bandwidth " ]
id = XMLProperty ( " ./@id " , is_int = True )
bandwidth = XMLProperty ( " ./@bandwidth " , is_int = True )
2021-08-07 11:03:35 +02:00
class _MemoryTune ( XMLBuilder ) :
2019-08-14 18:50:40 +03:00
"""
Class for generating < cputune > child < memorytune > XML
"""
XML_NAME = " memorytune "
2021-08-07 11:03:35 +02:00
_XML_PROP_ORDER = [ " vcpus " , " nodes " ]
2019-08-14 18:50:40 +03:00
vcpus = XMLProperty ( " ./@vcpus " )
2021-08-07 11:03:35 +02:00
nodes = XMLChildProperty ( _MemoryTuneNode )
2019-08-14 18:50:40 +03:00
2021-08-07 11:03:35 +02:00
#########################
# Actual CPUTune domain #
#########################
2019-08-14 18:50:40 +03:00
2018-03-20 15:10:04 -04:00
class DomainCputune ( XMLBuilder ) :
2018-02-06 12:56:41 +01:00
"""
2021-08-07 11:03:35 +02:00
Class for generating < cputune > XML
2018-02-06 12:56:41 +01:00
"""
2018-03-21 10:53:34 -04:00
XML_NAME = " cputune "
2021-08-06 17:09:31 +02:00
_XML_PROP_ORDER = [ " shares " , " period " , " quota " , " global_period " , " global_quota " ,
" emulator_period " , " emulator_quota " , " iothread_period " , " iothread_quota " ,
" vcpupins " , " emulatorpin_cpuset " , " iothreadpins " ,
2021-08-06 17:42:43 +02:00
" emulatorsched_scheduler " , " emulatorsched_priority " , " vcpuscheds " , " iothreadscheds " ,
" cachetunes " , " memorytunes " ]
2019-08-09 12:14:05 +03:00
2021-08-06 16:56:21 +02:00
# Resource quotas
shares = XMLProperty ( " ./shares " , is_int = True )
period = XMLProperty ( " ./period " , is_int = True )
quota = XMLProperty ( " ./quota " , is_int = True )
global_period = XMLProperty ( " ./global_period " , is_int = True )
global_quota = XMLProperty ( " ./global_quota " , is_int = True )
emulator_period = XMLProperty ( " ./emulator_period " , is_int = True )
emulator_quota = XMLProperty ( " ./emulator_quota " , is_int = True )
iothread_period = XMLProperty ( " ./iothread_period " , is_int = True )
iothread_quota = XMLProperty ( " ./iothread_quota " , is_int = True )
2021-08-06 17:09:31 +02:00
# CPU Pinning
vcpupins = XMLChildProperty ( _VCPUPin )
2021-07-26 15:48:08 +02:00
emulatorpin_cpuset = XMLProperty ( " ./emulatorpin/@cpuset " )
2021-08-06 17:09:31 +02:00
iothreadpins = XMLChildProperty ( _IOThreadPin )
2021-08-06 17:42:43 +02:00
# Scheduling
emulatorsched_scheduler = XMLProperty ( " ./emulatorsched/@scheduler " )
emulatorsched_priority = XMLProperty ( " ./emulatorsched/@priority " , is_int = True )
vcpuscheds = XMLChildProperty ( _VCPUSched )
iothreadscheds = XMLChildProperty ( _IOThreadSched )
2021-08-07 11:03:35 +02:00
# Cache & Memory Tunables
cachetunes = XMLChildProperty ( _CacheTune )
memorytunes = XMLChildProperty ( _MemoryTune )