cpu.h 3.8 KB
Newer Older
J
Jiri Denemark 已提交
1 2 3
/*
 * cpu.h: internal functions for CPU manipulation
 *
4
 * Copyright (C) 2009-2010 Red Hat, Inc.
J
Jiri Denemark 已提交
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_H__
25
# define __VIR_CPU_H__
J
Jiri Denemark 已提交
26

27 28 29 30
# include "virterror_internal.h"
# include "datatypes.h"
# include "conf/cpu_conf.h"
# include "cpu_x86_data.h"
J
Jiri Denemark 已提交
31 32


33
# define virCPUReportError(code, ...)                              \
34
    virReportErrorHelper(NULL, VIR_FROM_CPU, code, __FILE__,      \
35
                         __FUNCTION__, __LINE__, __VA_ARGS__)
J
Jiri Denemark 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50


union cpuData {
    struct cpuX86Data x86;
    /* generic driver needs no data */
};


typedef virCPUCompareResult
(*cpuArchCompare)   (virCPUDefPtr host,
                     virCPUDefPtr cpu);

typedef int
(*cpuArchDecode)    (virCPUDefPtr cpu,
                     const union cpuData *data,
51 52
                     const char **models,
                     unsigned int nmodels);
J
Jiri Denemark 已提交
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

typedef int
(*cpuArchEncode)    (const virCPUDefPtr cpu,
                     union cpuData **forced,
                     union cpuData **required,
                     union cpuData **optional,
                     union cpuData **disabled,
                     union cpuData **forbidden);

typedef void
(*cpuArchDataFree)  (union cpuData *data);

typedef union cpuData *
(*cpuArchNodeData)  (void);

typedef virCPUCompareResult
(*cpuArchGuestData) (virCPUDefPtr host,
                     virCPUDefPtr guest,
                     union cpuData **data);

73 74 75 76 77 78
typedef virCPUDefPtr
(*cpuArchBaseline)  (virCPUDefPtr *cpus,
                     unsigned int ncpus,
                     const char **models,
                     unsigned int nmodels);

J
Jiri Denemark 已提交
79 80 81 82 83 84 85 86 87 88 89

struct cpuArchDriver {
    const char *name;
    const char **arch;
    unsigned int narch;
    cpuArchCompare      compare;
    cpuArchDecode       decode;
    cpuArchEncode       encode;
    cpuArchDataFree     free;
    cpuArchNodeData     nodeData;
    cpuArchGuestData    guestData;
90
    cpuArchBaseline     baseline;
J
Jiri Denemark 已提交
91 92 93 94
};


extern virCPUCompareResult
95
cpuCompareXML(virCPUDefPtr host,
J
Jiri Denemark 已提交
96 97 98
              const char *xml);

extern virCPUCompareResult
99
cpuCompare  (virCPUDefPtr host,
J
Jiri Denemark 已提交
100 101 102
             virCPUDefPtr cpu);

extern int
103
cpuDecode   (virCPUDefPtr cpu,
J
Jiri Denemark 已提交
104
             const union cpuData *data,
105 106
             const char **models,
             unsigned int nmodels);
J
Jiri Denemark 已提交
107 108

extern int
109
cpuEncode   (const char *arch,
J
Jiri Denemark 已提交
110 111 112 113 114 115 116 117
             const virCPUDefPtr cpu,
             union cpuData **forced,
             union cpuData **required,
             union cpuData **optional,
             union cpuData **disabled,
             union cpuData **forbidden);

extern void
118
cpuDataFree (const char *arch,
J
Jiri Denemark 已提交
119 120 121
             union cpuData *data);

extern union cpuData *
122
cpuNodeData (const char *arch);
J
Jiri Denemark 已提交
123 124

extern virCPUCompareResult
125
cpuGuestData(virCPUDefPtr host,
J
Jiri Denemark 已提交
126 127 128
             virCPUDefPtr guest,
             union cpuData **data);

129 130 131 132 133 134 135 136 137 138 139 140
extern char *
cpuBaselineXML(const char **xmlCPUs,
               unsigned int ncpus,
               const char **models,
               unsigned int nmodels);

extern virCPUDefPtr
cpuBaseline (virCPUDefPtr *cpus,
             unsigned int ncpus,
             const char **models,
             unsigned int nmodels);

J
Jiri Denemark 已提交
141
#endif /* __VIR_CPU_H__ */