numa_conf.h 5.2 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
size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa)
89
    ATTRIBUTE_NONNULL(1);
90
virBitmapPtr virDomainNumaGetNodeCpumask(virDomainNumaPtr numa,
91 92
                                         size_t node)
    ATTRIBUTE_NONNULL(1);
93
virDomainMemoryAccess virDomainNumaGetNodeMemoryAccessMode(virDomainNumaPtr numa,
94 95
                                                      size_t node)
    ATTRIBUTE_NONNULL(1);
96
unsigned long long virDomainNumaGetNodeMemorySize(virDomainNumaPtr numa,
97 98
                                                  size_t node)
    ATTRIBUTE_NONNULL(1);
99 100
unsigned long long virDomainNumaGetMemorySize(virDomainNumaPtr numa)
    ATTRIBUTE_NONNULL(1);
101

102 103 104
unsigned int
virDomainNumaGetMaxCPUID(virDomainNumaPtr numa);

105 106 107
/*
 * Formatters
 */
108
char *virDomainNumatuneFormatNodeset(virDomainNumaPtr numatune,
109 110
                                     virBitmapPtr auto_nodeset,
                                     int cellid);
111

112
int virDomainNumatuneMaybeFormatNodeset(virDomainNumaPtr numatune,
113
                                        virBitmapPtr auto_nodeset,
114 115
                                        char **mask,
                                        int cellid);
116 117 118 119

/*
 * Setters
 */
120
int virDomainNumatuneSet(virDomainNumaPtr numa,
121 122 123 124
                         bool placement_static,
                         int placement,
                         int mode,
                         virBitmapPtr nodeset)
125 126
    ATTRIBUTE_NONNULL(1);

127
void virDomainNumaSetNodeMemorySize(virDomainNumaPtr numa,
128 129 130 131
                                    size_t node,
                                    unsigned long long size)
    ATTRIBUTE_NONNULL(1);

132 133 134
/*
 * Other accessors
 */
135 136
bool virDomainNumaEquals(virDomainNumaPtr n1,
                         virDomainNumaPtr n2);
137

138 139 140
bool virDomainNumaCheckABIStability(virDomainNumaPtr src,
                                    virDomainNumaPtr tgt);

141
bool virDomainNumatuneHasPlacementAuto(virDomainNumaPtr numatune);
142

143
bool virDomainNumatuneHasPerNodeBinding(virDomainNumaPtr numatune);
144

145
int virDomainNumatuneSpecifiedMaxNode(virDomainNumaPtr numatune);
146

147
bool virDomainNumatuneNodesetIsAvailable(virDomainNumaPtr numatune,
148
                                         virBitmapPtr auto_nodeset);
149

150
bool virDomainNumatuneNodeSpecified(virDomainNumaPtr numatune,
151
                                    int cellid);
152

153 154
int virDomainNumaDefCPUParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt);
int virDomainNumaDefCPUFormat(virBufferPtr buf, virDomainNumaPtr def);
155

156
unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa);
157 158


159
#endif /* __NUMA_CONF_H__ */