summaryrefslogtreecommitdiff
path: root/virtinst/domain/memorybacking.py
blob: c883c57d8adc2303f5fcc991e8abfd22b202bfb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# Copyright 2014 Fujitsu Limited.
# Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.

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")


class DomainMemoryBacking(XMLBuilder):
    """
    Class for generating <memoryBacking> XML
    """

    XML_NAME = "memoryBacking"
    _XML_PROP_ORDER = ["hugepages", "nosharepages", "locked", "pages"]

    hugepages = XMLProperty("./hugepages", is_bool=True)
    nosharepages = XMLProperty("./nosharepages", is_bool=True)
    locked = XMLProperty("./locked", is_bool=True)
    discard = XMLProperty("./discard", is_bool=True)
    access_mode = XMLProperty("./access/@mode")
    source_type = XMLProperty("./source/@type")
    allocation_mode = XMLProperty("./allocation/@mode")

    pages = XMLChildProperty(_HugepagesPage, relative_xpath="./hugepages")