esx_vmx.h 4.5 KB
Newer Older
1 2

/*
3
 * esx_vmx.h: VMX related functions for the VMware ESX driver
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * Copyright (C) 2009 Matthias Bolte <matthias.bolte@googlemail.com>
 *
 * 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
 *
 */

#ifndef __ESX_VMX_H__
24
# define __ESX_VMX_H__
25

26 27
# include <stdbool.h>

28 29 30 31
# include "internal.h"
# include "conf.h"
# include "domain_conf.h"
# include "esx_vi.h"
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
typedef struct _esxVMX_Context esxVMX_Context;



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Context
 */

typedef char * (*esxVMX_ParseFileName)(const char *fileName, void *opaque);
typedef char * (*esxVMX_FormatFileName)(const char *src, void *opaque);
typedef int (*esxVMX_AutodetectSCSIControllerModel)(virDomainDiskDefPtr def,
                                                    int *model, void *opaque);

/*
 * esxVMX_ParseFileName is only used by esxVMX_ParseConfig.
 * esxVMX_FormatFileName is only used by esxVMX_FormatConfig.
 * esxVMX_AutodetectSCSIControllerModel is optionally used by esxVMX_FormatConfig.
 */
struct _esxVMX_Context {
    void *opaque;
    esxVMX_ParseFileName parseFileName;
    esxVMX_FormatFileName formatFileName;
    esxVMX_AutodetectSCSIControllerModel autodetectSCSIControllerModel;
};



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Helpers
 */

M
Matthias Bolte 已提交
64
int
65 66
esxVMX_SCSIDiskNameToControllerAndUnit(const char *name, int *controller,
                                       int *unit);
M
Matthias Bolte 已提交
67

M
Matthias Bolte 已提交
68
int
69
esxVMX_IDEDiskNameToBusAndUnit(const char *name, int *bus, int *unit);
M
Matthias Bolte 已提交
70

M
Matthias Bolte 已提交
71
int
72
esxVMX_FloppyDiskNameToUnit(const char *name, int *unit);
M
Matthias Bolte 已提交
73 74

int
75 76 77 78 79 80 81
esxVMX_VerifyDiskAddress(virCapsPtr caps, virDomainDiskDefPtr disk);

int
esxVMX_HandleLegacySCSIDiskDriverName(virDomainDefPtr def,
                                      virDomainDiskDefPtr disk);

int
82
esxVMX_GatherSCSIControllers(esxVMX_Context *ctx, virDomainDefPtr def,
83
                             int virtualDev[4], bool present[4]);
M
Matthias Bolte 已提交
84 85


86

M
Matthias Bolte 已提交
87 88 89 90
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * VMX -> Domain XML
 */

91
virDomainDefPtr
92
esxVMX_ParseConfig(esxVMX_Context *ctx, virCapsPtr caps, const char *vmx,
93
                   esxVI_ProductVersion productVersion);
94

M
Matthias Bolte 已提交
95
int
96
esxVMX_ParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);
M
Matthias Bolte 已提交
97

98
int
99
esxVMX_ParseSCSIController(virConfPtr conf, int controller, bool *present,
100
                           int *virtualDev);
101 102

int
103
esxVMX_ParseDisk(esxVMX_Context *ctx, virCapsPtr caps, virConfPtr conf,
104
                 int device, int busType, int controllerOrBus, int unit,
105
                 virDomainDiskDefPtr *def);
106
int
107
esxVMX_ParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def);
108 109

int
110
esxVMX_ParseSerial(esxVMX_Context *ctx, virConfPtr conf, int port,
111
                   virDomainChrDefPtr *def);
112 113

int
114
esxVMX_ParseParallel(esxVMX_Context *ctx, virConfPtr conf, int port,
115
                     virDomainChrDefPtr *def);
116

M
Matthias Bolte 已提交
117 118 119 120 121 122 123


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Domain XML -> VMX
 */

char *
124
esxVMX_FormatConfig(esxVMX_Context *ctx, virCapsPtr caps, virDomainDefPtr def,
125
                    esxVI_ProductVersion productVersion);
M
Matthias Bolte 已提交
126

M
Matthias Bolte 已提交
127
int
128
esxVMX_FormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer);
M
Matthias Bolte 已提交
129

M
Matthias Bolte 已提交
130
int
131
esxVMX_FormatHardDisk(esxVMX_Context *ctx, virDomainDiskDefPtr def,
132
                      virBufferPtr buffer);
M
Matthias Bolte 已提交
133 134

int
135
esxVMX_FormatCDROM(esxVMX_Context *ctx, virDomainDiskDefPtr def,
136
                   virBufferPtr buffer);
M
Matthias Bolte 已提交
137 138

int
139
esxVMX_FormatFloppy(esxVMX_Context *ctx, virDomainDiskDefPtr def,
140
                    virBufferPtr buffer, bool floppy_present[2]);
M
Matthias Bolte 已提交
141 142

int
143 144
esxVMX_FormatEthernet(virDomainNetDefPtr def, int controller,
                      virBufferPtr buffer);
M
Matthias Bolte 已提交
145 146

int
147
esxVMX_FormatSerial(esxVMX_Context *ctx, virDomainChrDefPtr def,
148
                    virBufferPtr buffer);
M
Matthias Bolte 已提交
149 150

int
151
esxVMX_FormatParallel(esxVMX_Context *ctx, virDomainChrDefPtr def,
152
                      virBufferPtr buffer);
M
Matthias Bolte 已提交
153

154
#endif /* __ESX_VMX_H__ */