numa_conf.h 6.3 KB
Newer Older
1
/*
2
 * numa_conf.h
3
 *
4
 * Copyright (C) 2014-2015 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 * Author: Martin Kletzander <mkletzan@redhat.com>
 */

23 24
#ifndef __NUMA_CONF_H__
# define __NUMA_CONF_H__
25

26 27
# include <libxml/xpath.h>

28 29 30
# include "internal.h"
# include "virutil.h"
# include "virbitmap.h"
31 32 33
# include "virbuffer.h"


34 35
typedef struct _virDomainNuma virDomainNuma;
typedef virDomainNuma *virDomainNumaPtr;
36 37

typedef enum {
38 39 40
    VIR_DOMAIN_NUMATUNE_PLACEMENT_DEFAULT = 0,
    VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC,
    VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO,
41

42 43
    VIR_DOMAIN_NUMATUNE_PLACEMENT_LAST
} virDomainNumatunePlacement;
44

45
VIR_ENUM_DECL(virDomainNumatunePlacement)
46 47
VIR_ENUM_DECL(virDomainNumatuneMemMode)

48
typedef enum {
49 50 51
    VIR_DOMAIN_MEMORY_ACCESS_DEFAULT = 0,  /*  No memory access defined */
    VIR_DOMAIN_MEMORY_ACCESS_SHARED,    /* Memory access is set as shared */
    VIR_DOMAIN_MEMORY_ACCESS_PRIVATE,   /* Memory access is set as private */
52

53 54 55
    VIR_DOMAIN_MEMORY_ACCESS_LAST,
} virDomainMemoryAccess;
VIR_ENUM_DECL(virDomainMemoryAccess)
56

57

58
virDomainNumaPtr virDomainNumaNew(void);
59
void virDomainNumaFree(virDomainNumaPtr numa);
60 61 62 63

/*
 * XML Parse/Format functions
 */
64
int virDomainNumatuneParseXML(virDomainNumaPtr numa,
65 66
                              bool placement_static,
                              xmlXPathContextPtr ctxt)
67
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
68

69
int virDomainNumatuneFormatXML(virBufferPtr buf, virDomainNumaPtr numatune)
70 71 72 73 74
    ATTRIBUTE_NONNULL(1);

/*
 * Getters
 */
75 76 77
int virDomainNumatuneGetMode(virDomainNumaPtr numatune,
                             int cellid,
                             virDomainNumatuneMemMode *mode);
78

79
virBitmapPtr virDomainNumatuneGetNodeset(virDomainNumaPtr numatune,
80 81
                                         virBitmapPtr auto_nodeset,
                                         int cellid);
82

83
int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune,
84 85 86 87
                                     virBitmapPtr auto_nodeset,
                                     virBitmapPtr *retNodeset,
                                     int cellid);

88 89
size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa);

90 91 92 93
bool virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
                                              size_t node,
                                              size_t sibling)
    ATTRIBUTE_NONNULL(1);
94 95 96 97 98
size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
                                    size_t node,
                                    size_t sibling)
    ATTRIBUTE_NONNULL(1);

99
virBitmapPtr virDomainNumaGetNodeCpumask(virDomainNumaPtr numa,
100 101
                                         size_t node)
    ATTRIBUTE_NONNULL(1);
102
virDomainMemoryAccess virDomainNumaGetNodeMemoryAccessMode(virDomainNumaPtr numa,
103 104
                                                      size_t node)
    ATTRIBUTE_NONNULL(1);
105
unsigned long long virDomainNumaGetNodeMemorySize(virDomainNumaPtr numa,
106 107
                                                  size_t node)
    ATTRIBUTE_NONNULL(1);
108 109
unsigned long long virDomainNumaGetMemorySize(virDomainNumaPtr numa)
    ATTRIBUTE_NONNULL(1);
110

111 112 113
unsigned int
virDomainNumaGetMaxCPUID(virDomainNumaPtr numa);

114 115 116
/*
 * Formatters
 */
117
char *virDomainNumatuneFormatNodeset(virDomainNumaPtr numatune,
118 119
                                     virBitmapPtr auto_nodeset,
                                     int cellid);
120

121
int virDomainNumatuneMaybeFormatNodeset(virDomainNumaPtr numatune,
122
                                        virBitmapPtr auto_nodeset,
123 124
                                        char **mask,
                                        int cellid);
125 126 127 128

/*
 * Setters
 */
129
int virDomainNumatuneSet(virDomainNumaPtr numa,
130 131 132 133
                         bool placement_static,
                         int placement,
                         int mode,
                         virBitmapPtr nodeset)
134 135
    ATTRIBUTE_NONNULL(1);

136 137 138 139
size_t virDomainNumaSetNodeCount(virDomainNumaPtr numa,
                                 size_t nmem_nodes)
    ATTRIBUTE_NONNULL(1);

140
void virDomainNumaSetNodeMemorySize(virDomainNumaPtr numa,
141 142 143 144
                                    size_t node,
                                    unsigned long long size)
    ATTRIBUTE_NONNULL(1);

145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
int virDomainNumaSetNodeDistance(virDomainNumaPtr numa,
                                 size_t node,
                                 size_t sibling,
                                 unsigned int value)
    ATTRIBUTE_NONNULL(1);

size_t virDomainNumaSetNodeDistanceCount(virDomainNumaPtr numa,
                                         size_t node,
                                         size_t ndistances)
    ATTRIBUTE_NONNULL(1);

virBitmapPtr virDomainNumaSetNodeCpumask(virDomainNumaPtr numa,
                                         size_t node,
                                         virBitmapPtr cpumask)
    ATTRIBUTE_NONNULL(1);

161 162 163
/*
 * Other accessors
 */
164 165
bool virDomainNumaEquals(virDomainNumaPtr n1,
                         virDomainNumaPtr n2);
166

167 168 169
bool virDomainNumaCheckABIStability(virDomainNumaPtr src,
                                    virDomainNumaPtr tgt);

170
bool virDomainNumatuneHasPlacementAuto(virDomainNumaPtr numatune);
171

172
bool virDomainNumatuneHasPerNodeBinding(virDomainNumaPtr numatune);
173

174
int virDomainNumatuneSpecifiedMaxNode(virDomainNumaPtr numatune);
175

176
bool virDomainNumatuneNodesetIsAvailable(virDomainNumaPtr numatune,
177
                                         virBitmapPtr auto_nodeset);
178

179
bool virDomainNumatuneNodeSpecified(virDomainNumaPtr numatune,
180
                                    int cellid);
181

182
int virDomainNumaDefCPUParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt);
183
int virDomainNumaDefCPUFormatXML(virBufferPtr buf, virDomainNumaPtr def);
184

185
unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa);
186 187


188
#endif /* __NUMA_CONF_H__ */