2014-03-22 14:15:46 +04:00
#
# Copyright 2014 Fujitsu Limited.
# Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
#
2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2014-03-22 14:15:46 +04:00
2019-05-14 22:45:16 +03:00
from . . xmlbuilder import XMLBuilder , XMLChildProperty , XMLProperty
class _HugepagesPage ( XMLBuilder ) :
"""
Class representing < memoryBacking > < hugepages > < page > elements
"""
XML_NAME = " page "
size = XMLProperty ( " ./@size " )
unit = XMLProperty ( " ./@unit " )
nodeset = XMLProperty ( " ./@nodeset " )
2014-03-22 14:15:46 +04:00
2018-03-20 22:10:04 +03:00
class DomainMemoryBacking ( XMLBuilder ) :
2014-03-22 14:15:46 +04:00
"""
Class for generating < memoryBacking > XML
"""
2018-03-21 17:53:34 +03:00
XML_NAME = " memoryBacking "
2019-05-14 22:45:16 +03:00
_XML_PROP_ORDER = [ " hugepages " , " nosharepages " , " locked " , " pages " ]
2014-03-22 14:15:46 +04:00
hugepages = XMLProperty ( " ./hugepages " , is_bool = True )
nosharepages = XMLProperty ( " ./nosharepages " , is_bool = True )
locked = XMLProperty ( " ./locked " , is_bool = True )
2019-05-14 22:50:51 +03:00
discard = XMLProperty ( " ./discard " , is_bool = True )
2018-09-17 13:59:06 +03:00
access_mode = XMLProperty ( " ./access/@mode " )
source_type = XMLProperty ( " ./source/@type " )
2019-05-14 22:50:51 +03:00
allocation_mode = XMLProperty ( " ./allocation/@mode " )
2022-06-21 00:54:50 +03:00
allocation_threads = XMLProperty ( " ./allocation/@threads " , is_int = True )
2019-05-14 22:45:16 +03:00
pages = XMLChildProperty ( _HugepagesPage , relative_xpath = " ./hugepages " )