numa_conf.h 4.8 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
# include "virbuffer.h"
32
# include "cpu_conf.h"
33 34


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

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

43 44
    VIR_DOMAIN_NUMATUNE_PLACEMENT_LAST
} virDomainNumatunePlacement;
45

46
VIR_ENUM_DECL(virDomainNumatunePlacement)
47 48
VIR_ENUM_DECL(virDomainNumatuneMemMode)

49 50 51 52 53 54 55 56 57
typedef enum {
    VIR_NUMA_MEM_ACCESS_DEFAULT,
    VIR_NUMA_MEM_ACCESS_SHARED,
    VIR_NUMA_MEM_ACCESS_PRIVATE,

    VIR_NUMA_MEM_ACCESS_LAST
} virNumaMemAccess;

VIR_ENUM_DECL(virNumaMemAccess)
58

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

/*
 * XML Parse/Format functions
 */
65
int virDomainNumatuneParseXML(virDomainNumaPtr numa,
66 67 68 69
                              bool placement_static,
                              size_t ncells,
                              xmlXPathContextPtr ctxt)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
70

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

/*
 * Getters
 */
77
virDomainNumatuneMemMode virDomainNumatuneGetMode(virDomainNumaPtr numatune,
78
                                                  int cellid);
79

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

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

89 90
size_t virDomainNumaGetNodeCount(virCPUDefPtr numa)
    ATTRIBUTE_NONNULL(1);
91 92 93
virBitmapPtr virDomainNumaGetNodeCpumask(virCPUDefPtr numa,
                                         size_t node)
    ATTRIBUTE_NONNULL(1);
94 95 96
virNumaMemAccess virDomainNumaGetNodeMemoryAccessMode(virCPUDefPtr numa,
                                                      size_t node)
    ATTRIBUTE_NONNULL(1);
97 98 99
unsigned long long virDomainNumaGetNodeMemorySize(virCPUDefPtr numa,
                                                  size_t node)
    ATTRIBUTE_NONNULL(1);
100

101 102 103
/*
 * Formatters
 */
104
char *virDomainNumatuneFormatNodeset(virDomainNumaPtr numatune,
105 106
                                     virBitmapPtr auto_nodeset,
                                     int cellid);
107

108
int virDomainNumatuneMaybeFormatNodeset(virDomainNumaPtr numatune,
109
                                        virBitmapPtr auto_nodeset,
110 111
                                        char **mask,
                                        int cellid);
112 113 114 115

/*
 * Setters
 */
116
int virDomainNumatuneSet(virDomainNumaPtr numa,
117 118 119 120
                         bool placement_static,
                         int placement,
                         int mode,
                         virBitmapPtr nodeset)
121 122
    ATTRIBUTE_NONNULL(1);

123 124 125 126 127
void virDomainNumaSetNodeMemorySize(virCPUDefPtr numa,
                                    size_t node,
                                    unsigned long long size)
    ATTRIBUTE_NONNULL(1);

128 129 130
/*
 * Other accessors
 */
131 132
bool virDomainNumaEquals(virDomainNumaPtr n1,
                         virDomainNumaPtr n2);
133

134
bool virDomainNumatuneHasPlacementAuto(virDomainNumaPtr numatune);
135

136
bool virDomainNumatuneHasPerNodeBinding(virDomainNumaPtr numatune);
137

138
int virDomainNumatuneSpecifiedMaxNode(virDomainNumaPtr numatune);
139

140
bool virDomainNumatuneNodesetIsAvailable(virDomainNumaPtr numatune,
141
                                         virBitmapPtr auto_nodeset);
142

143
bool virDomainNumatuneNodeSpecified(virDomainNumaPtr numatune,
144
                                    int cellid);
145 146

int virDomainNumaDefCPUParseXML(virCPUDefPtr def, xmlXPathContextPtr ctxt);
147
int virDomainNumaDefCPUFormat(virBufferPtr buf, virCPUDefPtr def);
148

149 150 151
unsigned int virDomainNumaGetCPUCountTotal(virCPUDefPtr numa);


152
#endif /* __NUMA_CONF_H__ */