vbox_uniformed_api.h 31.0 KB
Newer Older
T
Taowei 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 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
/*
 * Copyright 2014, Taowei Luo (uaedante@gmail.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, see
 * <http://www.gnu.org/licenses/>.
 */

#ifndef VBOX_UNIFORMED_API_H
# define VBOX_UNIFORMED_API_H

# include "internal.h"

/* This file may be used in three place. That is vbox_tmpl.c,
 * vbox_common.c and vbox_driver.c. The vboxUniformedAPI and some
 * types used for vboxUniformedAPI is defined here.
 *
 * The vbox_tmpl.c is the only place where the driver knows the inside
 * architecture of those vbox structs(vboxObj, vboxSession,
 * pFuncs, vboxCallback and vboxQueue). The file should be included
 * after the currect vbox_CAPI_v*.h, then we can use the vbox structs
 * in vboxGlobalData. The vbox_tmpl.c should implement functions
 * defined in vboxUniformedAPI.
 *
 * In vbox_driver.c, it is used to define the struct vboxUniformedAPI.
 * The vbox_driver.c collects vboxUniformedAPI for all versions.
 * Then vboxRegister calls the vboxRegisterUniformedAPI to register.
 * Note: In vbox_driver.c, the vbox structs in vboxGlobalData is
 * defined by vbox_CAPI_v2.2.h.
 *
 * The vbox_common.c, it is used to generate common codes for all vbox
 * versions. Bacause the same member varible's offset in a vbox struct
 * may change between different vbox versions. The vbox_common.c
 * shouldn't directly use struct's member varibles defined in
 * vbox_CAPI_v*.h. To make things safety, we include the
 * vbox_common.h in vbox_common.c. In this case, we treat structs
 * defined by vbox as a void*. The common codes don't concern about
 * the inside of this structs(actually, we can't, in the common level).
 * With the help of vboxUniformed API, we call VirtualBox's API and
 * implement the vbox driver in a high level.
 *
 * In conclusion:
 *  * In vbox_tmpl.c, this file is included after vbox_CAPI_v*.h
 *  * In vbox_driver.c, this file is included after vbox_glue.h
 *  * In vbox_common.c, this file is included after vbox_common.h
 *
 */

T
Taowei 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
/* Extracted define from vbox_tmpl.c */

# ifdef WIN32
struct _vboxIID_v2_x_WIN32 {
    /* IID is represented by a GUID value. */
    GUID value;
};
# endif /* !WIN32 */

struct _vboxIID_v2_x {
    /* IID is represented by a pointer to a nsID. */
    nsID *value;

    /* backing is used in cases where we need to create or copy an IID.
     * We cannot allocate memory that can be freed by ComUnallocMem.
     * Therefore, we use this stack allocated nsID instead. */
    nsID backing;
};

struct _vboxIID_v3_x {
    /* IID is represented by a UTF-16 encoded UUID in string form. */
    PRUnichar *value;

    /* owner indicates if we own the value and need to free it. */
    bool owner;
};

typedef union {
# ifdef WIN32
    struct _vboxIID_v2_x_WIN32 vboxIID_v2_x_WIN32;
# endif /* !WIN32 */
    struct _vboxIID_v2_x vboxIID_v2_x;
    struct _vboxIID_v3_x vboxIID_v3_x;
} vboxIIDUnion;

typedef union {
    nsresult uResultCode;
    PRInt32 resultCode;
} resultCodeUnion;

T
Taowei 已提交
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
typedef struct {
    virMutex lock;
    unsigned long version;

    virCapsPtr caps;
    virDomainXMLOptionPtr xmlopt;

    IVirtualBox *vboxObj;
    ISession *vboxSession;

    /** Our version specific API table pointer. */
    PCVBOXXPCOM pFuncs;

    /* The next is used for domainEvent */
# if defined(VBOX_API_VERSION) && VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000

    /* Async event handling */
    virObjectEventStatePtr domainEvents;
    int fdWatch;
    IVirtualBoxCallback *vboxCallback;
    nsIEventQueue  *vboxQueue;

    int volatile vboxCallBackRefCount;

    /* pointer back to the connection */
    virConnectPtr conn;

# else /* VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 || VBOX_API_VERSION undefined */

    virObjectEventStatePtr domainEvents;
    int fdWatch;
    void *vboxCallback;
    void *vboxQueue;
    int volatile vboxCallBackRefCount;
    virConnectPtr conn;

# endif /* VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 || VBOX_API_VERSION undefined */

} vboxGlobalData;

/* vboxUniformedAPI gives vbox_common.c a uniformed layer to see
 * vbox API.
 */

/* Functions for pFuncs */
typedef struct {
    int (*Initialize)(vboxGlobalData *data);
    void (*Uninitialize)(vboxGlobalData *data);
    void (*ComUnallocMem)(PCVBOXXPCOM pFuncs, void *pv);
    void (*Utf16Free)(PCVBOXXPCOM pFuncs, PRUnichar *pwszString);
    void (*Utf8Free)(PCVBOXXPCOM pFuncs, char *pszString);
    int (*Utf16ToUtf8)(PCVBOXXPCOM pFuncs, const PRUnichar *pwszString, char **ppszString);
    int (*Utf8ToUtf16)(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar **ppwszString);
} vboxUniformedPFN;

T
Taowei 已提交
154 155 156 157 158 159 160 161
/* Functions for vboxIID */
typedef struct {
    void (*vboxIIDInitialize)(vboxIIDUnion *iidu);
    void (*vboxIIDUnalloc)(vboxGlobalData *data, vboxIIDUnion *iidu);
    void (*vboxIIDToUUID)(vboxGlobalData *data, vboxIIDUnion *iidu, unsigned char *uuid);
    void (*vboxIIDFromUUID)(vboxGlobalData *data, vboxIIDUnion *iidu, const unsigned char *uuid);
    bool (*vboxIIDIsEqual)(vboxGlobalData *data, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2);
    void (*vboxIIDFromArrayItem)(vboxGlobalData *data, vboxIIDUnion *iidu, vboxArray *array, int idx);
162
    void (*vboxIIDToUtf8)(vboxGlobalData *data, vboxIIDUnion *iidu, char **utf8);
T
Taowei 已提交
163 164 165
    void (*DEBUGIID)(const char *msg, vboxIIDUnion *iidu);
} vboxUniformedIID;

T
Taowei 已提交
166 167 168
/* Functions for vboxArray */
typedef struct {
    nsresult (*vboxArrayGet)(vboxArray *array, void *self, void *getter);
169
    nsresult (*vboxArrayGetWithIIDArg)(vboxArray *array, void *self, void *getter, vboxIIDUnion *iidu);
T
Taowei 已提交
170 171 172
    void (*vboxArrayRelease)(vboxArray *array);
    /* Generate function pointers for vboxArrayGet */
    void* (*handleGetMachines)(IVirtualBox *vboxObj);
T
Taowei 已提交
173 174 175
    void* (*handleUSBGetDeviceFilters)(IUSBCommon *USBCommon);
    void* (*handleMachineGetMediumAttachments)(IMachine *machine);
    void* (*handleMachineGetSharedFolders)(IMachine *machine);
176 177 178
    void* (*handleSnapshotGetChildren)(ISnapshot *snapshot);
    void* (*handleMediumGetChildren)(IMedium *medium);
    void* (*handleMediumGetSnapshotIds)(IMedium *medium);
T
Taowei 已提交
179 180
} vboxUniformedArray;

T
Taowei 已提交
181 182 183
/* Functions for nsISupports */
typedef struct {
    nsresult (*Release)(nsISupports *nsi);
184
    nsresult (*AddRef)(nsISupports *nsi);
T
Taowei 已提交
185 186
} vboxUniformednsISupports;

T
Taowei 已提交
187 188 189
/* Functions for IVirtualBox */
typedef struct {
    nsresult (*GetVersion)(IVirtualBox *vboxObj, PRUnichar **versionUtf16);
T
Taowei 已提交
190
    nsresult (*GetMachine)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine);
191
    nsresult (*OpenMachine)(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine);
T
Taowei 已提交
192
    nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties);
T
Taowei 已提交
193
    nsresult (*CreateMachine)(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr);
194
    nsresult (*CreateHardDiskMedium)(IVirtualBox *vboxObj, PRUnichar *format, PRUnichar *location, IMedium **medium);
T
Taowei 已提交
195 196 197
    nsresult (*RegisterMachine)(IVirtualBox *vboxObj, IMachine *machine);
    nsresult (*FindMedium)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, PRUint32 accessMode, IMedium **medium);
    nsresult (*OpenMedium)(IVirtualBox *vboxObj, PRUnichar *location, PRUint32 deviceType, PRUint32 accessMode, IMedium **medium);
T
Taowei 已提交
198 199
} vboxUniformedIVirtualBox;

T
Taowei 已提交
200 201
/* Functions for IMachine */
typedef struct {
T
Taowei 已提交
202 203
    nsresult (*AddStorageController)(IMachine *machine, PRUnichar *name,
        PRUint32 connectionType, IStorageController **controller);
T
Taowei 已提交
204 205
    nsresult (*GetStorageControllerByName)(IMachine *machine, PRUnichar *name,
                                           IStorageController **storageController);
T
Taowei 已提交
206 207 208 209 210 211
    nsresult (*AttachDevice)(IMachine *machine, PRUnichar *name,
                             PRInt32 controllerPort, PRInt32 device,
                             PRUint32 type, IMedium *medium);
    nsresult (*CreateSharedFolder)(IMachine *machine, PRUnichar *name,
                                   PRUnichar *hostPath, PRBool writable,
                                   PRBool automount);
T
Taowei 已提交
212
    nsresult (*RemoveSharedFolder)(IMachine *machine, PRUnichar *name);
T
Taowei 已提交
213 214 215 216
    nsresult (*LaunchVMProcess)(vboxGlobalData *data, IMachine *machine,
                                vboxIIDUnion *iidu,
                                PRUnichar *sessionType, PRUnichar *env,
                                IProgress **progress);
217 218
    nsresult (*Unregister)(IMachine *machine, PRUint32 cleanupMode,
                           PRUint32 *aMediaSize, IMedium ***aMedia);
219
    nsresult (*FindSnapshot)(IMachine *machine, vboxIIDUnion *iidu, ISnapshot **snapshot);
T
Taowei 已提交
220 221
    nsresult (*GetAccessible)(IMachine *machine, PRBool *isAccessible);
    nsresult (*GetState)(IMachine *machine, PRUint32 *state);
T
Taowei 已提交
222 223
    nsresult (*GetName)(IMachine *machine, PRUnichar **name);
    nsresult (*GetId)(IMachine *machine, vboxIIDUnion *iidu);
T
Taowei 已提交
224 225 226 227 228 229 230 231
    nsresult (*GetBIOSSettings)(IMachine *machine, IBIOSSettings **bios);
    nsresult (*GetAudioAdapter)(IMachine *machine, IAudioAdapter **audioAdapter);
    nsresult (*GetNetworkAdapter)(IMachine *machine, PRUint32 slot, INetworkAdapter **adapter);
    nsresult (*GetChipsetType)(IMachine *machine, PRUint32 *chipsetType);
    nsresult (*GetSerialPort)(IMachine *machine, PRUint32 slot, ISerialPort **port);
    nsresult (*GetParallelPort)(IMachine *machine, PRUint32 slot, IParallelPort **port);
    nsresult (*GetVRDxServer)(IMachine *machine, IVRDxServer **VRDxServer);
    nsresult (*GetUSBCommon)(IMachine *machine, IUSBCommon **USBCommon);
232 233
    nsresult (*GetCurrentSnapshot)(IMachine *machine, ISnapshot **currentSnapshot);
    nsresult (*GetSettingsFilePath)(IMachine *machine, PRUnichar **settingsFilePath);
T
Taowei 已提交
234
    nsresult (*GetCPUCount)(IMachine *machine, PRUint32 *CPUCount);
T
Taowei 已提交
235
    nsresult (*SetCPUCount)(IMachine *machine, PRUint32 CPUCount);
T
Taowei 已提交
236
    nsresult (*GetMemorySize)(IMachine *machine, PRUint32 *memorySize);
T
Taowei 已提交
237
    nsresult (*SetMemorySize)(IMachine *machine, PRUint32 memorySize);
T
Taowei 已提交
238
    nsresult (*GetCPUProperty)(IMachine *machine, PRUint32 property, PRBool *value);
T
Taowei 已提交
239
    nsresult (*SetCPUProperty)(IMachine *machine, PRUint32 property, PRBool value);
T
Taowei 已提交
240
    nsresult (*GetBootOrder)(IMachine *machine, PRUint32 position, PRUint32 *device);
T
Taowei 已提交
241
    nsresult (*SetBootOrder)(IMachine *machine, PRUint32 position, PRUint32 device);
T
Taowei 已提交
242
    nsresult (*GetVRAMSize)(IMachine *machine, PRUint32 *VRAMSize);
T
Taowei 已提交
243
    nsresult (*SetVRAMSize)(IMachine *machine, PRUint32 VRAMSize);
T
Taowei 已提交
244
    nsresult (*GetMonitorCount)(IMachine *machine, PRUint32 *monitorCount);
T
Taowei 已提交
245
    nsresult (*SetMonitorCount)(IMachine *machine, PRUint32 monitorCount);
T
Taowei 已提交
246
    nsresult (*GetAccelerate3DEnabled)(IMachine *machine, PRBool *accelerate3DEnabled);
T
Taowei 已提交
247
    nsresult (*SetAccelerate3DEnabled)(IMachine *machine, PRBool accelerate3DEnabled);
T
Taowei 已提交
248
    nsresult (*GetAccelerate2DVideoEnabled)(IMachine *machine, PRBool *accelerate2DVideoEnabled);
T
Taowei 已提交
249
    nsresult (*SetAccelerate2DVideoEnabled)(IMachine *machine, PRBool accelerate2DVideoEnabled);
T
Taowei 已提交
250
    nsresult (*GetExtraData)(IMachine *machine, PRUnichar *key, PRUnichar **value);
T
Taowei 已提交
251
    nsresult (*SetExtraData)(IMachine *machine, PRUnichar *key, PRUnichar *value);
252
    nsresult (*GetSnapshotCount)(IMachine *machine, PRUint32 *snapshotCount);
T
Taowei 已提交
253
    nsresult (*SaveSettings)(IMachine *machine);
T
Taowei 已提交
254 255
} vboxUniformedIMachine;

T
Taowei 已提交
256 257
/* Functions for ISession */
typedef struct {
T
Taowei 已提交
258
    nsresult (*Open)(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine);
T
Taowei 已提交
259 260
    nsresult (*OpenExisting)(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine);
    nsresult (*GetConsole)(ISession *session, IConsole **console);
T
Taowei 已提交
261
    nsresult (*GetMachine)(ISession *session, IMachine **machine);
T
Taowei 已提交
262 263 264 265 266 267
    nsresult (*Close)(ISession *session);
} vboxUniformedISession;

/* Functions for IConsole */
typedef struct {
    nsresult (*SaveState)(IConsole *console, IProgress **progress);
T
Taowei 已提交
268
    nsresult (*Pause)(IConsole *console);
T
Taowei 已提交
269
    nsresult (*Resume)(IConsole *console);
T
Taowei 已提交
270
    nsresult (*PowerButton)(IConsole *console);
T
Taowei 已提交
271
    nsresult (*PowerDown)(IConsole *console);
T
Taowei 已提交
272
    nsresult (*Reset)(IConsole *console);
273 274
    nsresult (*TakeSnapshot)(IConsole *console, PRUnichar *name,
                             PRUnichar *description, IProgress **progress);
T
Taowei 已提交
275
    nsresult (*DeleteSnapshot)(IConsole *console, vboxIIDUnion *iidu, IProgress **progress);
T
Taowei 已提交
276
    nsresult (*GetDisplay)(IConsole *console, IDisplay **display);
T
Taowei 已提交
277 278 279 280 281 282
} vboxUniformedIConsole;

/* Functions for IProgress */
typedef struct {
    nsresult (*WaitForCompletion)(IProgress *progress, PRInt32 timeout);
    nsresult (*GetResultCode)(IProgress *progress, resultCodeUnion *resultCode);
T
Taowei 已提交
283
    nsresult (*GetCompleted)(IProgress *progress, PRBool *completed);
T
Taowei 已提交
284 285
} vboxUniformedIProgress;

T
Taowei 已提交
286 287 288
/* Functions for ISystemProperties */
typedef struct {
    nsresult (*GetMaxGuestCPUCount)(ISystemProperties *systemProperties, PRUint32 *maxCPUCount);
T
Taowei 已提交
289 290 291 292 293 294 295 296 297
    nsresult (*GetMaxBootPosition)(ISystemProperties *systemProperties, PRUint32 *maxBootPosition);
    nsresult (*GetMaxNetworkAdapters)(ISystemProperties *systemProperties, PRUint32 chipset,
                                      PRUint32 *maxNetworkAdapters);
    nsresult (*GetSerialPortCount)(ISystemProperties *systemProperties, PRUint32 *SerialPortCount);
    nsresult (*GetParallelPortCount)(ISystemProperties *systemProperties, PRUint32 *ParallelPortCount);
    nsresult (*GetMaxPortCountForStorageBus)(ISystemProperties *systemProperties, PRUint32 bus,
                                             PRUint32 *maxPortCount);
    nsresult (*GetMaxDevicesPerPortForStorageBus)(ISystemProperties *systemProperties,
                                                  PRUint32 bus, PRUint32 *maxDevicesPerPort);
T
Taowei 已提交
298
    nsresult (*GetMaxGuestRAM)(ISystemProperties *systemProperties, PRUint32 *maxGuestRAM);
T
Taowei 已提交
299 300
} vboxUniformedISystemProperties;

T
Taowei 已提交
301 302
/* Functions for IBIOSSettings */
typedef struct {
T
Taowei 已提交
303
    nsresult (*GetACPIEnabled)(IBIOSSettings *bios, PRBool *ACPIEnabled);
T
Taowei 已提交
304
    nsresult (*SetACPIEnabled)(IBIOSSettings *bios, PRBool ACPIEnabled);
T
Taowei 已提交
305
    nsresult (*GetIOAPICEnabled)(IBIOSSettings *bios, PRBool *IOAPICEnabled);
T
Taowei 已提交
306 307 308 309 310
    nsresult (*SetIOAPICEnabled)(IBIOSSettings *bios, PRBool IOAPICEnabled);
} vboxUniformedIBIOSSettings;

/* Functions for IAudioAdapter */
typedef struct {
T
Taowei 已提交
311
    nsresult (*GetEnabled)(IAudioAdapter *audioAdapter, PRBool *enabled);
T
Taowei 已提交
312
    nsresult (*SetEnabled)(IAudioAdapter *audioAdapter, PRBool enabled);
T
Taowei 已提交
313
    nsresult (*GetAudioController)(IAudioAdapter *audioAdapter, PRUint32 *audioController);
T
Taowei 已提交
314 315 316 317 318
    nsresult (*SetAudioController)(IAudioAdapter *audioAdapter, PRUint32 audioController);
} vboxUniformedIAudioAdapter;

/* Functions for INetworkAdapter */
typedef struct {
T
Taowei 已提交
319 320
    nsresult (*GetAttachmentType)(INetworkAdapter *adapter, PRUint32 *attachmentType);
    nsresult (*GetEnabled)(INetworkAdapter *adapter, PRBool *enabled);
T
Taowei 已提交
321
    nsresult (*SetEnabled)(INetworkAdapter *adapter, PRBool enabled);
T
Taowei 已提交
322
    nsresult (*GetAdapterType)(INetworkAdapter *adapter, PRUint32 *adapterType);
T
Taowei 已提交
323
    nsresult (*SetAdapterType)(INetworkAdapter *adapter, PRUint32 adapterType);
T
Taowei 已提交
324
    nsresult (*GetBridgedInterface)(INetworkAdapter *adapter, PRUnichar **bridgedInterface);
T
Taowei 已提交
325
    nsresult (*SetBridgedInterface)(INetworkAdapter *adapter, PRUnichar *bridgedInterface);
T
Taowei 已提交
326
    nsresult (*GetInternalNetwork)(INetworkAdapter *adapter, PRUnichar **internalNetwork);
T
Taowei 已提交
327
    nsresult (*SetInternalNetwork)(INetworkAdapter *adapter, PRUnichar *internalNetwork);
T
Taowei 已提交
328
    nsresult (*GetHostOnlyInterface)(INetworkAdapter *adapter, PRUnichar **hostOnlyInterface);
T
Taowei 已提交
329
    nsresult (*SetHostOnlyInterface)(INetworkAdapter *adapter, PRUnichar *hostOnlyInterface);
T
Taowei 已提交
330
    nsresult (*GetMACAddress)(INetworkAdapter *adapter, PRUnichar **MACAddress);
T
Taowei 已提交
331 332 333 334 335 336 337 338 339
    nsresult (*SetMACAddress)(INetworkAdapter *adapter, PRUnichar *MACAddress);
    nsresult (*AttachToBridgedInterface)(INetworkAdapter *adapter);
    nsresult (*AttachToInternalNetwork)(INetworkAdapter *adapter);
    nsresult (*AttachToHostOnlyInterface)(INetworkAdapter *adapter);
    nsresult (*AttachToNAT)(INetworkAdapter *adapter);
} vboxUniformedINetworkAdapter;

/* Functions for ISerialPort */
typedef struct {
T
Taowei 已提交
340
    nsresult (*GetEnabled)(ISerialPort *port, PRBool *enabled);
T
Taowei 已提交
341
    nsresult (*SetEnabled)(ISerialPort *port, PRBool enabled);
T
Taowei 已提交
342
    nsresult (*GetPath)(ISerialPort *port, PRUnichar **path);
T
Taowei 已提交
343
    nsresult (*SetPath)(ISerialPort *port, PRUnichar *path);
T
Taowei 已提交
344
    nsresult (*GetIRQ)(ISerialPort *port, PRUint32 *IRQ);
T
Taowei 已提交
345
    nsresult (*SetIRQ)(ISerialPort *port, PRUint32 IRQ);
T
Taowei 已提交
346
    nsresult (*GetIOBase)(ISerialPort *port, PRUint32 *IOBase);
T
Taowei 已提交
347
    nsresult (*SetIOBase)(ISerialPort *port, PRUint32 IOBase);
T
Taowei 已提交
348
    nsresult (*GetHostMode)(ISerialPort *port, PRUint32 *hostMode);
T
Taowei 已提交
349 350 351 352 353
    nsresult (*SetHostMode)(ISerialPort *port, PRUint32 hostMode);
} vboxUniformedISerialPort;

/* Functions for IParallelPort */
typedef struct {
T
Taowei 已提交
354
    nsresult (*GetEnabled)(IParallelPort *port, PRBool *enabled);
T
Taowei 已提交
355
    nsresult (*SetEnabled)(IParallelPort *port, PRBool enabled);
T
Taowei 已提交
356
    nsresult (*GetPath)(IParallelPort *port, PRUnichar **path);
T
Taowei 已提交
357
    nsresult (*SetPath)(IParallelPort *port, PRUnichar *path);
T
Taowei 已提交
358
    nsresult (*GetIRQ)(IParallelPort *port, PRUint32 *IRQ);
T
Taowei 已提交
359
    nsresult (*SetIRQ)(IParallelPort *port, PRUint32 IRQ);
T
Taowei 已提交
360
    nsresult (*GetIOBase)(IParallelPort *port, PRUint32 *IOBase);
T
Taowei 已提交
361 362 363 364 365
    nsresult (*SetIOBase)(IParallelPort *port, PRUint32 IOBase);
} vboxUniformedIParallelPort;

/* Functions for IVRDPServer and IVRDEServer */
typedef struct {
T
Taowei 已提交
366
    nsresult (*GetEnabled)(IVRDxServer *VRDxServer, PRBool *enabled);
T
Taowei 已提交
367
    nsresult (*SetEnabled)(IVRDxServer *VRDxServer, PRBool enabled);
T
Taowei 已提交
368 369
    nsresult (*GetPorts)(vboxGlobalData *data, IVRDxServer *VRDxServer,
                         virDomainGraphicsDefPtr graphics);
T
Taowei 已提交
370 371
    nsresult (*SetPorts)(vboxGlobalData *data, IVRDxServer *VRDxServer,
                         virDomainGraphicsDefPtr graphics);
T
Taowei 已提交
372
    nsresult (*GetReuseSingleConnection)(IVRDxServer *VRDxServer, PRBool *enabled);
T
Taowei 已提交
373
    nsresult (*SetReuseSingleConnection)(IVRDxServer *VRDxServer, PRBool enabled);
T
Taowei 已提交
374
    nsresult (*GetAllowMultiConnection)(IVRDxServer *VRDxServer, PRBool *enabled);
T
Taowei 已提交
375
    nsresult (*SetAllowMultiConnection)(IVRDxServer *VRDxServer, PRBool enabled);
T
Taowei 已提交
376 377
    nsresult (*GetNetAddress)(vboxGlobalData *data, IVRDxServer *VRDxServer,
                              PRUnichar **netAddress);
T
Taowei 已提交
378 379 380 381 382 383 384
    nsresult (*SetNetAddress)(vboxGlobalData *data, IVRDxServer *VRDxServer,
                              PRUnichar *netAddress);
} vboxUniformedIVRDxServer;

/* Common Functions for IUSBController and IUSBDeviceFilters */
typedef struct {
    nsresult (*Enable)(IUSBCommon *USBCommon);
T
Taowei 已提交
385
    nsresult (*GetEnabled)(IUSBCommon *USBCommon, PRBool *enabled);
T
Taowei 已提交
386 387 388 389 390 391 392
    nsresult (*CreateDeviceFilter)(IUSBCommon *USBCommon, PRUnichar *name,
                                   IUSBDeviceFilter **filter);
    nsresult (*InsertDeviceFilter)(IUSBCommon *USBCommon, PRUint32 position,
                                   IUSBDeviceFilter *filter);
} vboxUniformedIUSBCommon;

typedef struct {
T
Taowei 已提交
393
    nsresult (*GetProductId)(IUSBDeviceFilter *USBDeviceFilter, PRUnichar **productId);
T
Taowei 已提交
394
    nsresult (*SetProductId)(IUSBDeviceFilter *USBDeviceFilter, PRUnichar *productId);
T
Taowei 已提交
395
    nsresult (*GetActive)(IUSBDeviceFilter *USBDeviceFilter, PRBool *active);
T
Taowei 已提交
396
    nsresult (*SetActive)(IUSBDeviceFilter *USBDeviceFilter, PRBool active);
T
Taowei 已提交
397
    nsresult (*GetVendorId)(IUSBDeviceFilter *USBDeviceFilter, PRUnichar **vendorId);
T
Taowei 已提交
398 399 400 401 402 403
    nsresult (*SetVendorId)(IUSBDeviceFilter *USBDeviceFilter, PRUnichar *vendorId);
} vboxUniformedIUSBDeviceFilter;

/* Functions for IMedium */
typedef struct {
    nsresult (*GetId)(IMedium *medium, vboxIIDUnion *iidu);
T
Taowei 已提交
404 405
    nsresult (*GetLocation)(IMedium *medium, PRUnichar **location);
    nsresult (*GetReadOnly)(IMedium *medium, PRBool *readOnly);
406 407 408 409
    nsresult (*GetParent)(IMedium *medium, IMedium **parent);
    nsresult (*GetChildren)(IMedium *medium, PRUint32 *childrenSize, IMedium ***children);
    nsresult (*GetFormat)(IMedium *medium, PRUnichar **format);
    nsresult (*DeleteStorage)(IMedium *medium, IProgress **progress);
T
Taowei 已提交
410
    nsresult (*Release)(IMedium *medium);
411
    nsresult (*Close)(IMedium *medium);
T
Taowei 已提交
412
    nsresult (*SetType)(IMedium *medium, PRUint32 type);
413 414
    nsresult (*CreateDiffStorage)(IMedium *medium, IMedium *target, PRUint32 variantSize,
                                  PRUint32 *variant, IProgress **progress);
T
Taowei 已提交
415 416
} vboxUniformedIMedium;

T
Taowei 已提交
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
/* Functions for IMediumAttachment */
typedef struct {
    nsresult (*GetMedium)(IMediumAttachment *mediumAttachment, IMedium **medium);
    nsresult (*GetController)(IMediumAttachment *mediumAttachment, PRUnichar **controller);
    nsresult (*GetType)(IMediumAttachment *mediumAttachment, PRUint32 *type);
    nsresult (*GetPort)(IMediumAttachment *mediumAttachment, PRInt32 *port);
    nsresult (*GetDevice)(IMediumAttachment *mediumAttachment, PRInt32 *device);
} vboxUniformedIMediumAttachment;


/* Functions for IStorageController */
typedef struct {
    nsresult (*GetBus)(IStorageController *storageController, PRUint32 *bus);
} vboxUniformedIStorageController;

/* Functions for ISharedFolder */
typedef struct {
    nsresult (*GetHostPath)(ISharedFolder *sharedFolder, PRUnichar **hostPath);
    nsresult (*GetName)(ISharedFolder *sharedFolder, PRUnichar **name);
    nsresult (*GetWritable)(ISharedFolder *sharedFolder, PRBool *writable);
} vboxUniformedISharedFolder;

439 440 441 442 443 444 445 446 447 448 449
/* Functions for ISnapshot */
typedef struct {
    nsresult (*GetName)(ISnapshot *snapshot, PRUnichar **name);
    nsresult (*GetId)(ISnapshot *snapshot, vboxIIDUnion *iidu);
    nsresult (*GetMachine)(ISnapshot *snapshot, IMachine **machine);
    nsresult (*GetDescription)(ISnapshot *snapshot, PRUnichar **description);
    nsresult (*GetTimeStamp)(ISnapshot *snapshot, PRInt64 *timeStamp);
    nsresult (*GetParent)(ISnapshot *snapshot, ISnapshot **parent);
    nsresult (*GetOnline)(ISnapshot *snapshot, PRBool *online);
} vboxUniformedISnapshot;

T
Taowei 已提交
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
/* Functions for IDisplay */
typedef struct {
    nsresult (*GetScreenResolution)(IDisplay *display,
                                    PRUint32 screenId,
                                    PRUint32 *width,
                                    PRUint32 *height,
                                    PRUint32 *bitsPerPixel,
                                    PRInt32 *xOrigin,
                                    PRInt32 *yOrigin);
    nsresult (*TakeScreenShotPNGToArray)(IDisplay *display,
                                         PRUint32 screenId,
                                         PRUint32 width,
                                         PRUint32 height,
                                         PRUint32 *screenDataSize,
                                         PRUint8** screenData);
} vboxUniformedIDisplay;

T
Taowei 已提交
467 468
typedef struct {
    bool (*Online)(PRUint32 state);
469
    bool (*Inactive)(PRUint32 state);
T
Taowei 已提交
470
    bool (*NotStart)(PRUint32 state);
T
Taowei 已提交
471
    bool (*Running)(PRUint32 state);
T
Taowei 已提交
472
    bool (*Paused)(PRUint32 state);
T
Taowei 已提交
473
    bool (*PoweredOff)(PRUint32 state);
T
Taowei 已提交
474 475
} uniformedMachineStateChecker;

T
Taowei 已提交
476 477 478 479 480 481 482
typedef struct {
    /* vbox API version */
    uint32_t APIVersion;
    uint32_t XPCOMCVersion;
    /* vbox APIs */
    int (*initializeDomainEvent)(vboxGlobalData *data);
    void (*registerGlobalData)(vboxGlobalData *data);
T
Taowei 已提交
483 484 485
    void (*detachDevices)(vboxGlobalData *data, IMachine *machine, PRUnichar *hddcnameUtf16);
    nsresult (*unregisterMachine)(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine **machine);
    void (*deleteConfig)(IMachine *machine);
T
Taowei 已提交
486
    void (*vboxAttachDrivesOld)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine);
T
Taowei 已提交
487
    virDomainState (*vboxConvertState)(PRUint32 state);
T
Taowei 已提交
488 489
    void (*dumpIDEHDDsOld)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine);
    void (*dumpDVD)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine);
T
Taowei 已提交
490
    int (*attachDVD)(vboxGlobalData *data, IMachine *machine, const char *src);
T
Taowei 已提交
491
    int (*detachDVD)(IMachine *machine);
T
Taowei 已提交
492
    void (*dumpFloppy)(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine);
T
Taowei 已提交
493
    int (*attachFloppy)(vboxGlobalData *data, IMachine *machine, const char *src);
T
Taowei 已提交
494
    int (*detachFloppy)(IMachine *machine);
495
    int (*snapshotRestore)(virDomainPtr dom, IMachine *machine, ISnapshot *snapshot);
T
Taowei 已提交
496
    vboxUniformedPFN UPFN;
T
Taowei 已提交
497
    vboxUniformedIID UIID;
T
Taowei 已提交
498
    vboxUniformedArray UArray;
T
Taowei 已提交
499
    vboxUniformednsISupports nsUISupports;
T
Taowei 已提交
500
    vboxUniformedIVirtualBox UIVirtualBox;
T
Taowei 已提交
501
    vboxUniformedIMachine UIMachine;
T
Taowei 已提交
502 503 504
    vboxUniformedISession UISession;
    vboxUniformedIConsole UIConsole;
    vboxUniformedIProgress UIProgress;
T
Taowei 已提交
505
    vboxUniformedISystemProperties UISystemProperties;
T
Taowei 已提交
506 507 508 509 510 511 512 513 514
    vboxUniformedIBIOSSettings UIBIOSSettings;
    vboxUniformedIAudioAdapter UIAudioAdapter;
    vboxUniformedINetworkAdapter UINetworkAdapter;
    vboxUniformedISerialPort UISerialPort;
    vboxUniformedIParallelPort UIParallelPort;
    vboxUniformedIVRDxServer UIVRDxServer;
    vboxUniformedIUSBCommon UIUSBCommon;
    vboxUniformedIUSBDeviceFilter UIUSBDeviceFilter;
    vboxUniformedIMedium UIMedium;
T
Taowei 已提交
515 516 517
    vboxUniformedIMediumAttachment UIMediumAttachment;
    vboxUniformedIStorageController UIStorageController;
    vboxUniformedISharedFolder UISharedFolder;
518
    vboxUniformedISnapshot UISnapshot;
T
Taowei 已提交
519
    vboxUniformedIDisplay UIDisplay;
T
Taowei 已提交
520
    uniformedMachineStateChecker machineStateChecker;
T
Taowei 已提交
521 522 523
    /* vbox API features */
    bool domainEventCallbacks;
    bool hasStaticGlobalData;
T
Taowei 已提交
524
    bool getMachineForSession;
T
Taowei 已提交
525
    bool detachDevicesExplicitly;
T
Taowei 已提交
526 527 528
    bool chipsetType;
    bool accelerate2DVideo;
    bool vboxAttachDrivesUseOld;
T
Taowei 已提交
529
    bool oldMediumInterface;
530
    bool vboxSnapshotRedefine;
T
Taowei 已提交
531
    bool supportScreenshot;
T
Taowei 已提交
532 533 534 535 536 537 538 539 540
} vboxUniformedAPI;

/* libvirt API
 * These API would be removed after we generate the
 * vboxDriver in common code.
 */
virDrvOpenStatus vboxConnectOpen(virConnectPtr conn,
                                 virConnectAuthPtr auth,
                                 unsigned int flags);
T
Taowei 已提交
541
int vboxConnectClose(virConnectPtr conn);
T
Taowei 已提交
542
int vboxDomainSave(virDomainPtr dom, const char *path);
T
Taowei 已提交
543
int vboxConnectGetVersion(virConnectPtr conn, unsigned long *version);
T
Taowei 已提交
544
char *vboxConnectGetHostname(virConnectPtr conn);
T
Taowei 已提交
545
int vboxConnectIsSecure(virConnectPtr conn);
T
Taowei 已提交
546
int vboxConnectIsEncrypted(virConnectPtr conn);
T
Taowei 已提交
547
int vboxConnectIsAlive(virConnectPtr conn);
T
Taowei 已提交
548
int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type);
549
char *vboxConnectGetCapabilities(virConnectPtr conn);
T
Taowei 已提交
550
int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids);
T
Taowei 已提交
551
int vboxConnectNumOfDomains(virConnectPtr conn);
T
Taowei 已提交
552
virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id);
T
Taowei 已提交
553 554
virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn,
                                    const unsigned char *uuid);
T
Taowei 已提交
555 556
virDomainPtr
vboxDomainLookupByName(virConnectPtr conn, const char *name);
T
Taowei 已提交
557
virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml);
T
Taowei 已提交
558
int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags);
T
Taowei 已提交
559
int vboxDomainUndefine(virDomainPtr dom);
T
Taowei 已提交
560
int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags);
T
Taowei 已提交
561
int vboxDomainCreate(virDomainPtr dom);
T
Taowei 已提交
562 563
virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
                                 unsigned int flags);
T
Taowei 已提交
564
int vboxDomainIsActive(virDomainPtr dom);
T
Taowei 已提交
565
int vboxDomainIsPersistent(virDomainPtr dom);
T
Taowei 已提交
566
int vboxDomainIsUpdated(virDomainPtr dom);
T
Taowei 已提交
567
int vboxDomainSuspend(virDomainPtr dom);
T
Taowei 已提交
568
int vboxDomainResume(virDomainPtr dom);
T
Taowei 已提交
569
int vboxDomainShutdownFlags(virDomainPtr dom, unsigned int flags);
T
Taowei 已提交
570
int vboxDomainShutdown(virDomainPtr dom);
T
Taowei 已提交
571
int vboxDomainReboot(virDomainPtr dom, unsigned int flags);
T
Taowei 已提交
572
int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags);
T
Taowei 已提交
573
int vboxDomainDestroy(virDomainPtr dom);
T
Taowei 已提交
574
char *vboxDomainGetOSType(virDomainPtr dom);
T
Taowei 已提交
575
int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory);
T
Taowei 已提交
576
int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info);
T
Taowei 已提交
577 578
int vboxDomainGetState(virDomainPtr dom, int *state,
                       int *reason, unsigned int flags);
T
Taowei 已提交
579 580
int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
                            unsigned int flags);
T
Taowei 已提交
581
int vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
T
Taowei 已提交
582
int vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags);
T
Taowei 已提交
583
int vboxDomainGetMaxVcpus(virDomainPtr dom);
T
Taowei 已提交
584
char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags);
585 586
int vboxConnectListDefinedDomains(virConnectPtr conn,
                                  char ** const names, int maxnames);
587
int vboxConnectNumOfDefinedDomains(virConnectPtr conn);
T
Taowei 已提交
588
int vboxDomainAttachDevice(virDomainPtr dom, const char *xml);
589 590
int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
                                unsigned int flags);
591 592
int vboxDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
                                unsigned int flags);
T
Taowei 已提交
593
int vboxDomainDetachDevice(virDomainPtr dom, const char *xml);
594 595
int vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
                                unsigned int flags);
596 597 598 599
virDomainSnapshotPtr
vboxDomainSnapshotCreateXML(virDomainPtr dom,
                            const char *xmlDesc,
                            unsigned int flags);
600 601
char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
                                   unsigned int flags);
T
Taowei 已提交
602
int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags);
603 604
int vboxDomainSnapshotListNames(virDomainPtr dom, char **names,
                                int nameslen, unsigned int flags);
T
Taowei 已提交
605 606 607
virDomainSnapshotPtr
vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name,
                               unsigned int flags);
608
int vboxDomainHasCurrentSnapshot(virDomainPtr dom, unsigned int flags);
609 610 611
virDomainSnapshotPtr
vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
                            unsigned int flags);
T
Taowei 已提交
612 613
virDomainSnapshotPtr
vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags);
614 615
int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
                                unsigned int flags);
616 617
int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
                                unsigned int flags);
618 619
int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
                               unsigned int flags);
T
Taowei 已提交
620 621
int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
                             unsigned int flags);
T
Taowei 已提交
622 623
char *vboxDomainScreenshot(virDomainPtr dom, virStreamPtr st,
                           unsigned int screen, unsigned int flags);
T
Taowei 已提交
624 625
int vboxConnectListAllDomains(virConnectPtr conn, virDomainPtr **domains,
                              unsigned int flags);
T
Taowei 已提交
626 627 628 629 630 631 632 633 634 635 636 637 638 639

/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox30InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox31InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox32InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox40InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox41InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox42InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox42_20InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox43InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox43_4InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);

#endif /* VBOX_UNIFORMED_API_H */