cpu_conf.h 2.9 KB
Newer Older
1 2 3
/*
 * cpu_conf.h: CPU XML handling
 *
E
Eric Blake 已提交
4
 * Copyright (C) 2009, 2010 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * 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, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 *
 * Authors:
 *      Jiri Denemark <jdenemar@redhat.com>
 */

#ifndef __VIR_CPU_CONF_H__
25
# define __VIR_CPU_CONF_H__
26

27 28
# include "util.h"
# include "buf.h"
29
# include "xml.h"
30 31 32 33

enum virCPUType {
    VIR_CPU_TYPE_HOST,
    VIR_CPU_TYPE_GUEST,
34 35 36
    VIR_CPU_TYPE_AUTO,

    VIR_CPU_TYPE_LAST
37 38
};

39 40
VIR_ENUM_DECL(virCPU)

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
enum virCPUMatch {
    VIR_CPU_MATCH_MINIMUM,
    VIR_CPU_MATCH_EXACT,
    VIR_CPU_MATCH_STRICT,

    VIR_CPU_MATCH_LAST
};

VIR_ENUM_DECL(virCPUMatch)

enum virCPUFeaturePolicy {
    VIR_CPU_FEATURE_FORCE,
    VIR_CPU_FEATURE_REQUIRE,
    VIR_CPU_FEATURE_OPTIONAL,
    VIR_CPU_FEATURE_DISABLE,
    VIR_CPU_FEATURE_FORBID,

    VIR_CPU_FEATURE_LAST
};

VIR_ENUM_DECL(virCPUFeaturePolicy)

typedef struct _virCPUFeatureDef virCPUFeatureDef;
typedef virCPUFeatureDef *virCPUFeatureDefPtr;
struct _virCPUFeatureDef {
    char *name;
    int policy;         /* enum virCPUFeaturePolicy */
};

typedef struct _virCPUDef virCPUDef;
typedef virCPUDef *virCPUDefPtr;
struct _virCPUDef {
    int type;           /* enum virCPUType */
    int match;          /* enum virCPUMatch */
    char *arch;
    char *model;
J
Jiri Denemark 已提交
77
    char *vendor;
78 79 80
    unsigned int sockets;
    unsigned int cores;
    unsigned int threads;
E
Eric Blake 已提交
81 82
    size_t nfeatures;
    size_t nfeatures_max;
83 84 85 86 87 88 89
    virCPUFeatureDefPtr features;
};


void
virCPUDefFree(virCPUDefPtr def);

90 91 92
virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu);

93
virCPUDefPtr
94
virCPUDefParseXML(const xmlNodePtr node,
95 96 97 98 99 100 101 102
                  xmlXPathContextPtr ctxt,
                  enum virCPUType mode);

enum virCPUFormatFlags {
    VIR_CPU_FORMAT_EMBEDED  = (1 << 0)  /* embed into existing <cpu/> element
                                         * in host capabilities */
};

103 104 105
bool
virCPUDefIsEqual(virCPUDefPtr src,
                 virCPUDefPtr dst);
106 107

char *
108
virCPUDefFormat(virCPUDefPtr def,
109 110 111 112
                const char *indent,
                int flags);

int
113
virCPUDefFormatBuf(virBufferPtr buf,
114 115 116 117 118
                   virCPUDefPtr def,
                   const char *indent,
                   int flags);

int
119
virCPUDefAddFeature(virCPUDefPtr cpu,
120 121 122 123
                    const char *name,
                    int policy);

#endif /* __VIR_CPU_CONF_H__ */