vmx.h 4.8 KB
Newer Older
1 2 3
/*
 * vmx.h: VMware VMX parsing/formatting functions
 *
4
 * Copyright (C) 2009-2011, 2015 Matthias Bolte <matthias.bolte@googlemail.com>
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * 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
17
 * License along with this library.  If not, see
O
Osier Yang 已提交
18
 * <http://www.gnu.org/licenses/>.
19 20 21 22 23 24 25
 *
 */

#ifndef __VIR_VMX_H__
# define __VIR_VMX_H__

# include "internal.h"
26
# include "virconf.h"
27 28 29 30
# include "domain_conf.h"

typedef struct _virVMXContext virVMXContext;

31
virDomainXMLOptionPtr virVMXDomainXMLConfInit(void);
32 33 34 35 36 37 38 39 40 41 42 43


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

typedef char * (*virVMXParseFileName)(const char *fileName, void *opaque);
typedef char * (*virVMXFormatFileName)(const char *src, void *opaque);
typedef int (*virVMXAutodetectSCSIControllerModel)(virDomainDiskDefPtr def,
                                                   int *model, void *opaque);

/*
44 45 46 47
 * parseFileName is only used by virVMXParseConfig.
 * formatFileName is only used by virVMXFormatConfig.
 * autodetectSCSIControllerModel is optionally used by virVMXFormatConfig.
 * datacenterPath is only used by virVMXFormatConfig.
48 49 50 51 52 53
 */
struct _virVMXContext {
    void *opaque;
    virVMXParseFileName parseFileName;
    virVMXFormatFileName formatFileName;
    virVMXAutodetectSCSIControllerModel autodetectSCSIControllerModel;
54
    const char *datacenterPath; /* including folders */
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
};



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

char *virVMXEscapeHex(const char *string, char escape, const char *special);

# define virVMXEscapeHexPipe(_string) virVMXEscapeHex(_string, '|', "\"")

# define virVMXEscapeHexPercent(_string) virVMXEscapeHex(_string, '%', "/\\")

int virVMXUnescapeHex(char *string, char escape);

# define virVMXUnescapeHexPipe(_string) virVMXUnescapeHex(_string, '|')

# define virVMXUnescapeHexPercent(_string) virVMXUnescapeHex(_string, '%')

char *virVMXConvertToUTF8(const char *encoding, const char *string);



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

83 84
virDomainDefPtr virVMXParseConfig(virVMXContext *ctx,
                                  virDomainXMLOptionPtr xmlopt,
85
                                  virCapsPtr caps,
86 87 88 89 90 91 92
                                  const char *vmx);

int virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def);

int virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
                              int *virtualDev);

93 94
int virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
                    virConfPtr conf, int device, int busType,
95 96
                    int controllerOrBus, int unit, virDomainDiskDefPtr *def,
                    virDomainDefPtr vmdef);
97

98 99
int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def);

100 101 102 103 104 105 106 107
int virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def);

int virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
                      virDomainChrDefPtr *def);

int virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
                        virDomainChrDefPtr *def);

108 109
int virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def);

110 111 112 113 114 115


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

116
char *virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt,
117 118 119 120
                         virDomainDefPtr def, int virtualHW_version);

int virVMXFormatVNC(virDomainGraphicsDefPtr def, virBufferPtr buffer);

121 122
int virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def,
                     virBufferPtr buffer);
123 124 125 126

int virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def,
                       virBufferPtr buffer, bool floppy_present[2]);

127 128 129
int virVMXFormatFileSystem(virDomainFSDefPtr def, int number,
                           virBufferPtr buffer);

130 131 132 133 134 135 136 137 138
int virVMXFormatEthernet(virDomainNetDefPtr def, int controller,
                         virBufferPtr buffer);

int virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def,
                       virBufferPtr buffer);

int virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def,
                         virBufferPtr buffer);

139 140
int virVMXFormatSVGA(virDomainVideoDefPtr def, virBufferPtr buffer);

141
#endif /* __VIR_VMX_H__ */