summaryrefslogtreecommitdiff
path: root/virtinst/domain/cputune.py
blob: 3f1a541cbd587a18073f2ed53ea0014eab6e0cd4 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.

from ..xmlbuilder import XMLBuilder, XMLProperty, XMLChildProperty


class _VCPUPin(XMLBuilder):
    """
    Class for generating <cputune> child <vcpupin> XML
    """
    XML_NAME = "vcpupin"
    _XML_PROP_ORDER = ["vcpu", "cpuset"]

    vcpu = XMLProperty("./@vcpu", is_int=True)
    cpuset = XMLProperty("./@cpuset")


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


class _CacheCPU(XMLBuilder):
    """
    Class for generating <cachetune> child <cache> XML
    """
    XML_NAME = "cache"
    _XML_PROP_ORDER = ["level", "id", "type", "size", "unit"]

    level = XMLProperty("./@level", is_int=True)
    id = XMLProperty("./@id", is_int=True)
    type = XMLProperty("./@type")
    size = XMLProperty("./@size", is_int=True)
    unit = XMLProperty("./@unit")


class _CacheTuneCPU(XMLBuilder):
    """
    Class for generating <cputune> child <cachetune> XML
    """
    XML_NAME = "cachetune"
    _XML_PROP_ORDER = ["vcpus", "caches"]

    vcpus = XMLProperty("./@vcpus")
    caches = XMLChildProperty(_CacheCPU)


class _NodeCPU(XMLBuilder):
    """
    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)


class _MemoryTuneCPU(XMLBuilder):
    """
    Class for generating <cputune> child <memorytune> XML
    """
    XML_NAME = "memorytune"

    vcpus = XMLProperty("./@vcpus")
    nodes = XMLChildProperty(_NodeCPU)


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 DomainCputune(XMLBuilder):
    """
    Class for generating <cpu> XML
    """
    XML_NAME = "cputune"
    _XML_PROP_ORDER = ["vcpus", "emulatorpin_cpuset", "iothreadpin",
             "cachetune", "memorytune", "vcpusched"]

    vcpus = XMLChildProperty(_VCPUPin)
    iothreadpin = XMLChildProperty(_IOThreadPin)
    cachetune = XMLChildProperty(_CacheTuneCPU)
    memorytune = XMLChildProperty(_MemoryTuneCPU)
    vcpusched = XMLChildProperty(_VCPUSched)

    emulatorpin_cpuset = XMLProperty("./emulatorpin/@cpuset")