1 /** @file vbox_tmpl.c
2 * Template File to support multiple versions of VirtualBox
3 * at runtime :).
4 */
5
6 /*
7 * Copyright (C) 2010-2014 Red Hat, Inc.
8 * Copyright (C) 2008-2009 Sun Microsystems, Inc.
9 *
10 * This file is part of a free software library; you can redistribute
11 * it and/or modify it under the terms of the GNU Lesser General
12 * Public License version 2.1 as published by the Free Software
13 * Foundation and shipped in the "COPYING.LESSER" file with this library.
14 * The library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if
18 * any license choice other than GPL or LGPL is available it will
19 * apply instead, Sun elects to use only the Lesser General Public
20 * License version 2.1 (LGPLv2) at this time for any software where
21 * a choice of LGPL license versions is made available with the
22 * language indicating that LGPLv2 or any later version may be used,
23 * or where a choice of which version of the LGPL is applied is
24 * otherwise unspecified.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31 #include <config.h>
32
33 #include <unistd.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <fcntl.h>
37
38 #include "internal.h"
39 #include "datatypes.h"
40 #include "domain_conf.h"
41 #include "domain_event.h"
42 #include "viralloc.h"
43 #include "virlog.h"
44 #include "virstring.h"
45 #include "virutil.h"
46
47 /* This one changes from version to version. */
48 #if VBOX_API_VERSION == 5002000
49 # include "vbox_CAPI_v5_2.h"
50 #elif VBOX_API_VERSION == 6000000
51 # include "vbox_CAPI_v6_0.h"
52 #elif VBOX_API_VERSION == 6001000
53 # include "vbox_CAPI_v6_1.h"
54 #else
55 # error "Unsupported VBOX_API_VERSION"
56 #endif
57
58 /* Include this *last* or we'll get the wrong vbox_CAPI_*.h. */
59 #include "vbox_XPCOMCGlue.h"
60
61 typedef IUSBDeviceFilters IUSBCommon;
62
63
64 #include "vbox_uniformed_api.h"
65
66 #define VIR_FROM_THIS VIR_FROM_VBOX
67
68 VIR_LOG_INIT("vbox.vbox_tmpl");
69
70 #define vboxUnsupported() \
71 VIR_WARN("No %s in current vbox version %d.", __FUNCTION__, VBOX_API_VERSION);
72
73 #define VBOX_UTF16_FREE(arg) \
74 do { \
75 if (arg) { \
76 data->pFuncs->pfnUtf16Free(arg); \
77 (arg) = NULL; \
78 } \
79 } while (0)
80
81 #define VBOX_UTF8_FREE(arg) \
82 do { \
83 if (arg) { \
84 data->pFuncs->pfnUtf8Free(arg); \
85 (arg) = NULL; \
86 } \
87 } while (0)
88
89 #define VBOX_UTF16_TO_UTF8(arg1, arg2) data->pFuncs->pfnUtf16ToUtf8(arg1, arg2)
90 #define VBOX_UTF8_TO_UTF16(arg1, arg2) data->pFuncs->pfnUtf8ToUtf16(arg1, arg2)
91
92 #define VBOX_RELEASE(arg) \
93 do { \
94 if (arg) { \
95 (arg)->vtbl->nsisupports.Release((nsISupports *)(arg)); \
96 (arg) = NULL; \
97 } \
98 } while (0)
99
100 #define VBOX_MEDIUM_RELEASE(arg) VBOX_RELEASE(arg)
101
102 #define DEBUGPRUnichar(msg, strUtf16) \
103 if (strUtf16) {\
104 char *strUtf8 = NULL;\
105 \
106 data->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8);\
107 if (strUtf8) {\
108 VIR_DEBUG("%s: %s", msg, strUtf8);\
109 data->pFuncs->pfnUtf8Free(strUtf8);\
110 }\
111 }
112
113 #define DEBUGUUID(msg, iid) \
114 {\
115 VIR_DEBUG("%s: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", msg,\
116 (unsigned)(iid)->m0,\
117 (unsigned)(iid)->m1,\
118 (unsigned)(iid)->m2,\
119 (unsigned)(iid)->m3[0],\
120 (unsigned)(iid)->m3[1],\
121 (unsigned)(iid)->m3[2],\
122 (unsigned)(iid)->m3[3],\
123 (unsigned)(iid)->m3[4],\
124 (unsigned)(iid)->m3[5],\
125 (unsigned)(iid)->m3[6],\
126 (unsigned)(iid)->m3[7]);\
127 }\
128
129 #define VBOX_IID_INITIALIZER { NULL, true }
130
131 /* default RDP port range to use for auto-port setting */
132 #define VBOX_RDP_AUTOPORT_RANGE "3389-3689"
133
134 static void
_vboxIIDUnalloc(struct _vboxDriver * data,vboxIID * iid)135 _vboxIIDUnalloc(struct _vboxDriver *data, vboxIID *iid)
136 {
137 if (iid->value != NULL && iid->owner)
138 data->pFuncs->pfnUtf16Free(iid->value);
139
140 iid->value = NULL;
141 iid->owner = true;
142 }
143
144 static void
_vboxIIDToUUID(struct _vboxDriver * data,vboxIID * iid,unsigned char * uuid)145 _vboxIIDToUUID(struct _vboxDriver *data, vboxIID *iid,
146 unsigned char *uuid)
147 {
148 char *utf8 = NULL;
149
150 data->pFuncs->pfnUtf16ToUtf8(iid->value, &utf8);
151
152 ignore_value(virUUIDParse(utf8, uuid));
153
154 data->pFuncs->pfnUtf8Free(utf8);
155 }
156
157 static void
_vboxIIDFromUUID(struct _vboxDriver * data,vboxIID * iid,const unsigned char * uuid)158 _vboxIIDFromUUID(struct _vboxDriver *data, vboxIID *iid,
159 const unsigned char *uuid)
160 {
161 char utf8[VIR_UUID_STRING_BUFLEN];
162
163 _vboxIIDUnalloc(data, iid);
164
165 virUUIDFormat(uuid, utf8);
166
167 data->pFuncs->pfnUtf8ToUtf16(utf8, &iid->value);
168 }
169
170 static bool
_vboxIIDIsEqual(struct _vboxDriver * data,vboxIID * iid1,vboxIID * iid2)171 _vboxIIDIsEqual(struct _vboxDriver *data, vboxIID *iid1,
172 vboxIID *iid2)
173 {
174 unsigned char uuid1[VIR_UUID_BUFLEN];
175 unsigned char uuid2[VIR_UUID_BUFLEN];
176
177 /* Note: we can't directly compare the utf8 strings here
178 * cause the two UUID's may have separators as space or '-'
179 * or mixture of both and we don't want to fail here by
180 * using direct string comparison. Here virUUIDParse() takes
181 * care of these cases. */
182 _vboxIIDToUUID(data, iid1, uuid1);
183 _vboxIIDToUUID(data, iid2, uuid2);
184
185 return memcmp(uuid1, uuid2, VIR_UUID_BUFLEN) == 0;
186 }
187
188 static void
_vboxIIDFromArrayItem(struct _vboxDriver * data,vboxIID * iid,vboxArray * array,int idx)189 _vboxIIDFromArrayItem(struct _vboxDriver *data, vboxIID *iid,
190 vboxArray *array, int idx)
191 {
192 _vboxIIDUnalloc(data, iid);
193
194 iid->value = array->items[idx];
195 iid->owner = false;
196 }
197
198 #define vboxIIDUnalloc(iid) _vboxIIDUnalloc(data, iid)
199 #define vboxIIDToUUID(iid, uuid) _vboxIIDToUUID(data, iid, uuid)
200 #define vboxIIDFromUUID(iid, uuid) _vboxIIDFromUUID(data, iid, uuid)
201 #define vboxIIDIsEqual(iid1, iid2) _vboxIIDIsEqual(data, iid1, iid2)
202 #define vboxIIDFromArrayItem(iid, array, idx) \
203 _vboxIIDFromArrayItem(data, iid, array, idx)
204 #define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
205
206 /**
207 * Converts int to Utf-16 string
208 */
PRUnicharFromInt(PCVBOXXPCOM pFuncs,int n)209 static PRUnichar *PRUnicharFromInt(PCVBOXXPCOM pFuncs, int n) {
210 PRUnichar *strUtf16 = NULL;
211 char s[24];
212
213 g_snprintf(s, sizeof(s), "%d", n);
214
215 pFuncs->pfnUtf8ToUtf16(s, &strUtf16);
216
217 return strUtf16;
218 }
219
_vboxConvertState(PRUint32 state)220 static virDomainState _vboxConvertState(PRUint32 state)
221 {
222 switch (state) {
223 case MachineState_Running:
224 return VIR_DOMAIN_RUNNING;
225 case MachineState_Stuck:
226 return VIR_DOMAIN_BLOCKED;
227 case MachineState_Paused:
228 return VIR_DOMAIN_PAUSED;
229 case MachineState_Stopping:
230 return VIR_DOMAIN_SHUTDOWN;
231 case MachineState_PoweredOff:
232 case MachineState_Saved:
233 return VIR_DOMAIN_SHUTOFF;
234 case MachineState_Aborted:
235 return VIR_DOMAIN_CRASHED;
236 case MachineState_Null:
237 default:
238 return VIR_DOMAIN_NOSTATE;
239 }
240 }
241
242
243 static int
vboxGetActiveVRDEServerPort(ISession * session,IMachine * machine)244 vboxGetActiveVRDEServerPort(ISession *session, IMachine *machine)
245 {
246 nsresult rc;
247 PRInt32 port = -1;
248 IVRDEServerInfo *vrdeInfo = NULL;
249 IConsole *console = NULL;
250
251 rc = machine->vtbl->LockMachine(machine, session, LockType_Shared);
252 if (NS_FAILED(rc)) {
253 VIR_WARN("Could not obtain shared lock on VBox VM, rc=%08x", rc);
254 return -1;
255 }
256
257 rc = session->vtbl->GetConsole(session, &console);
258 if (NS_FAILED(rc)) {
259 VIR_WARN("Could not get VBox session console, rc=%08x", rc);
260 goto cleanup;
261 }
262
263 /* it may be null if VM is not running */
264 if (!console)
265 goto cleanup;
266
267 rc = console->vtbl->GetVRDEServerInfo(console, &vrdeInfo);
268
269 if (NS_FAILED(rc) || !vrdeInfo) {
270 VIR_WARN("Could not get VBox VM VRDEServerInfo, rc=%08x", rc);
271 goto cleanup;
272 }
273
274 rc = vrdeInfo->vtbl->GetPort(vrdeInfo, &port);
275
276 if (NS_FAILED(rc)) {
277 VIR_WARN("Could not read port from VRDEServerInfo, rc=%08x", rc);
278 goto cleanup;
279 }
280
281 cleanup:
282 VBOX_RELEASE(console);
283 VBOX_RELEASE(vrdeInfo);
284 session->vtbl->UnlockMachine(session);
285
286 return port;
287 }
288
289
290 static int
_vboxDomainSnapshotRestore(virDomainPtr dom,IMachine * machine,ISnapshot * snapshot)291 _vboxDomainSnapshotRestore(virDomainPtr dom,
292 IMachine *machine,
293 ISnapshot *snapshot)
294 {
295 struct _vboxDriver *data = dom->conn->privateData;
296 IProgress *progress = NULL;
297 PRUint32 state;
298 nsresult rc;
299 PRInt32 result;
300 vboxIID domiid = VBOX_IID_INITIALIZER;
301 int ret = -1;
302
303 if (!data->vboxObj)
304 return ret;
305
306 rc = machine->vtbl->GetId(machine, &domiid.value);
307 if (NS_FAILED(rc)) {
308 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
309 _("could not get domain UUID"));
310 goto cleanup;
311 }
312
313 rc = machine->vtbl->GetState(machine, &state);
314 if (NS_FAILED(rc)) {
315 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
316 _("could not get domain state"));
317 goto cleanup;
318 }
319
320 if (state >= MachineState_FirstOnline
321 && state <= MachineState_LastOnline) {
322 virReportError(VIR_ERR_OPERATION_INVALID,
323 _("domain %s is already running"), dom->name);
324 goto cleanup;
325 }
326
327 rc = machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write);
328 if (NS_FAILED(rc)) {
329 virReportError(VIR_ERR_INTERNAL_ERROR,
330 _("could not open VirtualBox session with domain %s"),
331 dom->name);
332 goto cleanup;
333 }
334
335 rc = machine->vtbl->RestoreSnapshot(machine, snapshot, &progress);
336
337 if (NS_FAILED(rc) || !progress) {
338 if (rc == VBOX_E_INVALID_VM_STATE) {
339 virReportError(VIR_ERR_OPERATION_INVALID, "%s",
340 _("cannot restore domain snapshot for running domain"));
341 } else {
342 virReportError(VIR_ERR_INTERNAL_ERROR,
343 _("could not restore snapshot for domain %s"),
344 dom->name);
345 }
346 goto cleanup;
347 }
348
349 progress->vtbl->WaitForCompletion(progress, -1);
350 progress->vtbl->GetResultCode(progress, &result);
351 if (NS_FAILED(result)) {
352 virReportError(VIR_ERR_INTERNAL_ERROR,
353 _("could not restore snapshot for domain %s"), dom->name);
354 goto cleanup;
355 }
356
357 ret = 0;
358
359 cleanup:
360 VBOX_RELEASE(progress);
361 data->vboxSession->vtbl->UnlockMachine(data->vboxSession);
362 vboxIIDUnalloc(&domiid);
363 return ret;
364 }
365
366 static nsresult
_unregisterMachine(struct _vboxDriver * data,vboxIID * iid,IMachine ** machine)367 _unregisterMachine(struct _vboxDriver *data, vboxIID *iid, IMachine **machine)
368 {
369 nsresult rc;
370 vboxArray media = VBOX_ARRAY_INITIALIZER;
371 size_t i;
372
373 rc = data->vboxObj->vtbl->FindMachine(data->vboxObj, iid->value, machine);
374 if (NS_FAILED(rc)) {
375 virReportError(VIR_ERR_NO_DOMAIN, "%s",
376 _("no domain with matching uuid"));
377 return rc;
378 }
379
380 rc = vboxArrayGetWithUintArg(&media, *machine, (*machine)->vtbl->Unregister,
381 CleanupMode_DetachAllReturnHardDisksOnly);
382
383 if (NS_FAILED(rc))
384 goto cleanup;
385
386 /* close each medium attached to VM to remove from media registry */
387 for (i = 0; i < media.count; i++) {
388 IMedium *medium = media.items[i];
389
390 if (!medium)
391 continue;
392
393 /* it's ok to ignore failure here - e.g. it may be used by another VM */
394 ignore_value(medium->vtbl->Close(medium));
395 }
396
397 cleanup:
398 vboxArrayUnalloc(&media);
399 return rc;
400 }
401
402 static void
_deleteConfig(IMachine * machine)403 _deleteConfig(IMachine *machine)
404 {
405 IProgress *progress = NULL;
406
407 /* The IMachine Delete method takes an array of IMedium items to be
408 * deleted along with the virtual machine. We just want to pass an
409 * empty array. But instead of adding a full vboxArraySetWithReturn to
410 * the glue layer (in order to handle the required signature of the
411 * Delete method) we use a local solution here. */
412 #ifdef WIN32
413 SAFEARRAY *safeArray = NULL;
414 typedef HRESULT __stdcall (*IMachine_Delete)(IMachine *self,
415 SAFEARRAY **media,
416 IProgress **progress);
417
418 ((IMachine_Delete)machine->vtbl->DeleteConfig)(machine, &safeArray, &progress);
419 #else
420 /* XPCOM doesn't like NULL as an array, even when the array size is 0.
421 * Instead pass it a dummy array to avoid passing NULL. */
422 IMedium *array[] = { NULL };
423 machine->vtbl->DeleteConfig(machine, 0, array, &progress);
424 #endif
425 if (progress != NULL) {
426 progress->vtbl->WaitForCompletion(progress, -1);
427 VBOX_RELEASE(progress);
428 }
429 }
430
_pfnInitialize(struct _vboxDriver * driver)431 static int _pfnInitialize(struct _vboxDriver *driver)
432 {
433 nsresult rc;
434
435 if (!(driver->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION)))
436 return -1;
437
438 rc = driver->pFuncs->pfnClientInitialize(IVIRTUALBOXCLIENT_IID_STR,
439 &driver->vboxClient);
440
441 if (NS_FAILED(rc)) {
442 return -1;
443 } else {
444 driver->vboxClient->vtbl->GetVirtualBox(driver->vboxClient, &driver->vboxObj);
445 driver->vboxClient->vtbl->GetSession(driver->vboxClient, &driver->vboxSession);
446 }
447
448 return 0;
449 }
450
_pfnUninitialize(struct _vboxDriver * data)451 static void _pfnUninitialize(struct _vboxDriver *data)
452 {
453 if (data->pFuncs) {
454 VBOX_RELEASE(data->vboxObj);
455 VBOX_RELEASE(data->vboxSession);
456 VBOX_RELEASE(data->vboxClient);
457
458 data->pFuncs->pfnClientUninitialize();
459 }
460 }
461
_pfnComUnallocMem(PCVBOXXPCOM pFuncs,void * pv)462 static void _pfnComUnallocMem(PCVBOXXPCOM pFuncs, void *pv)
463 {
464 pFuncs->pfnComUnallocMem(pv);
465 }
466
_pfnUtf16Free(PCVBOXXPCOM pFuncs,PRUnichar * pwszString)467 static void _pfnUtf16Free(PCVBOXXPCOM pFuncs, PRUnichar *pwszString)
468 {
469 pFuncs->pfnUtf16Free(pwszString);
470 }
471
_pfnUtf8Free(PCVBOXXPCOM pFuncs,char * pszString)472 static void _pfnUtf8Free(PCVBOXXPCOM pFuncs, char *pszString)
473 {
474 pFuncs->pfnUtf8Free(pszString);
475 }
476
_pfnUtf16ToUtf8(PCVBOXXPCOM pFuncs,const PRUnichar * pwszString,char ** ppszString)477 static int _pfnUtf16ToUtf8(PCVBOXXPCOM pFuncs, const PRUnichar *pwszString, char **ppszString)
478 {
479 return pFuncs->pfnUtf16ToUtf8(pwszString, ppszString);
480 }
481
_pfnUtf8ToUtf16(PCVBOXXPCOM pFuncs,const char * pszString,PRUnichar ** ppwszString)482 static int _pfnUtf8ToUtf16(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar **ppwszString)
483 {
484 return pFuncs->pfnUtf8ToUtf16(pszString, ppwszString);
485 }
486
_vboxIIDInitialize(vboxIID * iid)487 static void _vboxIIDInitialize(vboxIID *iid)
488 {
489 memset(iid, 0, sizeof(vboxIID));
490 iid->owner = true;
491 }
492
_DEBUGIID(struct _vboxDriver * data,const char * msg,vboxIID * iid)493 static void _DEBUGIID(struct _vboxDriver *data, const char *msg, vboxIID *iid)
494 {
495 DEBUGPRUnichar(msg, iid->value);
496 }
497
498 static void
_vboxIIDToUtf8(struct _vboxDriver * data G_GNUC_UNUSED,vboxIID * iid G_GNUC_UNUSED,char ** utf8 G_GNUC_UNUSED)499 _vboxIIDToUtf8(struct _vboxDriver *data G_GNUC_UNUSED,
500 vboxIID *iid G_GNUC_UNUSED,
501 char **utf8 G_GNUC_UNUSED)
502 {
503 data->pFuncs->pfnUtf16ToUtf8(iid->value, utf8);
504 }
505
506 static nsresult
_vboxArrayGetWithIIDArg(vboxArray * array,void * self,void * getter,vboxIID * iid)507 _vboxArrayGetWithIIDArg(vboxArray *array, void *self, void *getter, vboxIID *iid)
508 {
509 return vboxArrayGetWithPtrArg(array, self, getter, iid->value);
510 }
511
_handleGetMachines(IVirtualBox * vboxObj)512 static void* _handleGetMachines(IVirtualBox *vboxObj)
513 {
514 return vboxObj->vtbl->GetMachines;
515 }
516
_handleGetHardDisks(IVirtualBox * vboxObj)517 static void* _handleGetHardDisks(IVirtualBox *vboxObj)
518 {
519 return vboxObj->vtbl->GetHardDisks;
520 }
521
_handleUSBGetDeviceFilters(IUSBCommon * USBCommon)522 static void* _handleUSBGetDeviceFilters(IUSBCommon *USBCommon)
523 {
524 return USBCommon->vtbl->GetDeviceFilters;
525 }
526
_handleMachineGetStorageControllers(IMachine * machine)527 static void* _handleMachineGetStorageControllers(IMachine *machine)
528 {
529 return machine->vtbl->GetStorageControllers;
530 }
531
_handleMachineGetMediumAttachments(IMachine * machine)532 static void* _handleMachineGetMediumAttachments(IMachine *machine)
533 {
534 return machine->vtbl->GetMediumAttachments;
535 }
536
_handleMachineGetSharedFolders(IMachine * machine)537 static void* _handleMachineGetSharedFolders(IMachine *machine)
538 {
539 return machine->vtbl->GetSharedFolders;
540 }
541
_handleSnapshotGetChildren(ISnapshot * snapshot)542 static void* _handleSnapshotGetChildren(ISnapshot *snapshot)
543 {
544 return snapshot->vtbl->GetChildren;
545 }
546
_handleMediumGetChildren(IMedium * medium G_GNUC_UNUSED)547 static void* _handleMediumGetChildren(IMedium *medium G_GNUC_UNUSED)
548 {
549 return medium->vtbl->GetChildren;
550 }
551
_handleMediumGetSnapshotIds(IMedium * medium)552 static void* _handleMediumGetSnapshotIds(IMedium *medium)
553 {
554 return medium->vtbl->GetSnapshotIds;
555 }
556
_handleMediumGetMachineIds(IMedium * medium)557 static void* _handleMediumGetMachineIds(IMedium *medium)
558 {
559 return medium->vtbl->GetMachineIds;
560 }
561
_handleHostGetNetworkInterfaces(IHost * host)562 static void* _handleHostGetNetworkInterfaces(IHost *host)
563 {
564 return host->vtbl->GetNetworkInterfaces;
565 }
566
_nsisupportsRelease(nsISupports * nsi)567 static nsresult _nsisupportsRelease(nsISupports *nsi)
568 {
569 return nsi->vtbl->Release(nsi);
570 }
571
_nsisupportsAddRef(nsISupports * nsi)572 static nsresult _nsisupportsAddRef(nsISupports *nsi)
573 {
574 return nsi->vtbl->AddRef(nsi);
575 }
576
577 static nsresult
_virtualboxGetVersion(IVirtualBox * vboxObj,PRUnichar ** versionUtf16)578 _virtualboxGetVersion(IVirtualBox *vboxObj, PRUnichar **versionUtf16)
579 {
580 return vboxObj->vtbl->GetVersion(vboxObj, versionUtf16);
581 }
582
583 static nsresult
_virtualboxGetMachine(IVirtualBox * vboxObj,vboxIID * iid,IMachine ** machine)584 _virtualboxGetMachine(IVirtualBox *vboxObj, vboxIID *iid, IMachine **machine)
585 {
586 return vboxObj->vtbl->FindMachine(vboxObj, iid->value, machine);
587 }
588
589 static nsresult
_virtualboxOpenMachine(IVirtualBox * vboxObj,PRUnichar * settingsFile,IMachine ** machine)590 _virtualboxOpenMachine(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine)
591 {
592 return vboxObj->vtbl->OpenMachine(vboxObj, settingsFile, machine);
593 }
594
595 static nsresult
_virtualboxGetSystemProperties(IVirtualBox * vboxObj,ISystemProperties ** systemProperties)596 _virtualboxGetSystemProperties(IVirtualBox *vboxObj, ISystemProperties **systemProperties)
597 {
598 return vboxObj->vtbl->GetSystemProperties(vboxObj, systemProperties);
599 }
600
601 static nsresult
_virtualboxGetHost(IVirtualBox * vboxObj,IHost ** host)602 _virtualboxGetHost(IVirtualBox *vboxObj, IHost **host)
603 {
604 return vboxObj->vtbl->GetHost(vboxObj, host);
605 }
606
607 static nsresult
_virtualboxCreateMachine(struct _vboxDriver * data,virDomainDef * def,IMachine ** machine,char * uuidstr G_GNUC_UNUSED)608 _virtualboxCreateMachine(struct _vboxDriver *data, virDomainDef *def, IMachine **machine, char *uuidstr G_GNUC_UNUSED)
609 {
610 vboxIID iid = VBOX_IID_INITIALIZER;
611 PRUnichar *machineNameUtf16 = NULL;
612 char *createFlags = NULL;
613 PRUnichar *createFlagsUtf16 = NULL;
614 nsresult rc = -1;
615
616 VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16);
617 vboxIIDFromUUID(&iid, def->uuid);
618 createFlags = g_strdup_printf("UUID=%s,forceOverwrite=0", uuidstr);
619 VBOX_UTF8_TO_UTF16(createFlags, &createFlagsUtf16);
620 rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
621 NULL,
622 machineNameUtf16,
623 0,
624 nsnull,
625 nsnull,
626 createFlagsUtf16,
627 machine);
628 VIR_FREE(createFlags);
629 VBOX_UTF16_FREE(machineNameUtf16);
630 vboxIIDUnalloc(&iid);
631 return rc;
632 }
633
634 static nsresult
_virtualboxCreateHardDisk(IVirtualBox * vboxObj,PRUnichar * format,PRUnichar * location,IMedium ** medium)635 _virtualboxCreateHardDisk(IVirtualBox *vboxObj, PRUnichar *format,
636 PRUnichar *location, IMedium **medium)
637 {
638 /* This function will create a IMedium object.
639 */
640 return vboxObj->vtbl->CreateMedium(vboxObj, format, location,
641 AccessMode_ReadWrite,
642 DeviceType_HardDisk, medium);
643 }
644
645 static nsresult
_virtualboxRegisterMachine(IVirtualBox * vboxObj,IMachine * machine)646 _virtualboxRegisterMachine(IVirtualBox *vboxObj, IMachine *machine)
647 {
648 return vboxObj->vtbl->RegisterMachine(vboxObj, machine);
649 }
650
651 static nsresult
_virtualboxFindHardDisk(IVirtualBox * vboxObj,PRUnichar * location,PRUint32 deviceType,PRUint32 accessMode G_GNUC_UNUSED,IMedium ** medium)652 _virtualboxFindHardDisk(IVirtualBox *vboxObj,
653 PRUnichar *location,
654 PRUint32 deviceType,
655 PRUint32 accessMode G_GNUC_UNUSED,
656 IMedium **medium)
657 {
658 return vboxObj->vtbl->OpenMedium(vboxObj, location, deviceType, accessMode,
659 PR_FALSE, medium);
660 }
661
662 static nsresult
_virtualboxOpenMedium(IVirtualBox * vboxObj,PRUnichar * location,PRUint32 deviceType,PRUint32 accessMode,IMedium ** medium)663 _virtualboxOpenMedium(IVirtualBox *vboxObj,
664 PRUnichar *location,
665 PRUint32 deviceType,
666 PRUint32 accessMode,
667 IMedium **medium)
668 {
669 return vboxObj->vtbl->OpenMedium(vboxObj, location, deviceType, accessMode,
670 false, medium);
671 }
672
673 static nsresult
_virtualboxGetHardDiskByIID(IVirtualBox * vboxObj,vboxIID * iid,IMedium ** medium)674 _virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIID *iid, IMedium **medium)
675 {
676 return vboxObj->vtbl->OpenMedium(vboxObj, iid->value, DeviceType_HardDisk,
677 AccessMode_ReadWrite, PR_FALSE, medium);
678 }
679
680 static nsresult
_virtualboxFindDHCPServerByNetworkName(IVirtualBox * vboxObj,PRUnichar * name,IDHCPServer ** server)681 _virtualboxFindDHCPServerByNetworkName(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server)
682 {
683 return vboxObj->vtbl->FindDHCPServerByNetworkName(vboxObj, name, server);
684 }
685
686 static nsresult
_virtualboxCreateDHCPServer(IVirtualBox * vboxObj,PRUnichar * name,IDHCPServer ** server)687 _virtualboxCreateDHCPServer(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server)
688 {
689 return vboxObj->vtbl->CreateDHCPServer(vboxObj, name, server);
690 }
691
692 static nsresult
_virtualboxRemoveDHCPServer(IVirtualBox * vboxObj,IDHCPServer * server)693 _virtualboxRemoveDHCPServer(IVirtualBox *vboxObj, IDHCPServer *server)
694 {
695 return vboxObj->vtbl->RemoveDHCPServer(vboxObj, server);
696 }
697
698 static nsresult
_machineAddStorageController(IMachine * machine,PRUnichar * name,PRUint32 connectionType,IStorageController ** controller)699 _machineAddStorageController(IMachine *machine, PRUnichar *name,
700 PRUint32 connectionType,
701 IStorageController **controller)
702 {
703 return machine->vtbl->AddStorageController(machine, name, connectionType,
704 controller);
705 }
706
707 static nsresult
_machineGetStorageControllerByName(IMachine * machine,PRUnichar * name,IStorageController ** storageController)708 _machineGetStorageControllerByName(IMachine *machine, PRUnichar *name,
709 IStorageController **storageController)
710 {
711 return machine->vtbl->GetStorageControllerByName(machine, name,
712 storageController);
713 }
714
715 static nsresult
_machineAttachDevice(IMachine * machine,PRUnichar * name,PRInt32 controllerPort,PRInt32 device,PRUint32 type,IMedium * medium)716 _machineAttachDevice(IMachine *machine,
717 PRUnichar *name,
718 PRInt32 controllerPort,
719 PRInt32 device,
720 PRUint32 type,
721 IMedium * medium)
722 {
723 return machine->vtbl->AttachDevice(machine, name, controllerPort,
724 device, type, medium);
725 }
726
727 static nsresult
_machineCreateSharedFolder(IMachine * machine,PRUnichar * name,PRUnichar * hostPath,PRBool writable,PRBool automount G_GNUC_UNUSED)728 _machineCreateSharedFolder(IMachine *machine, PRUnichar *name,
729 PRUnichar *hostPath, PRBool writable,
730 PRBool automount G_GNUC_UNUSED)
731 {
732 #if VBOX_API_VERSION >= 6000000
733 return machine->vtbl->CreateSharedFolder(machine, name, hostPath,
734 writable, automount, NULL);
735 #else
736 return machine->vtbl->CreateSharedFolder(machine, name, hostPath,
737 writable, automount);
738 #endif
739 }
740
741 static nsresult
_machineRemoveSharedFolder(IMachine * machine,PRUnichar * name)742 _machineRemoveSharedFolder(IMachine *machine, PRUnichar *name)
743 {
744 return machine->vtbl->RemoveSharedFolder(machine, name);
745 }
746
747 static nsresult
_machineLaunchVMProcess(struct _vboxDriver * data,IMachine * machine G_GNUC_UNUSED,vboxIID * iid G_GNUC_UNUSED,PRUnichar * sessionType,PRUnichar * env,IProgress ** progress)748 _machineLaunchVMProcess(struct _vboxDriver *data,
749 IMachine *machine G_GNUC_UNUSED,
750 vboxIID *iid G_GNUC_UNUSED,
751 PRUnichar *sessionType, PRUnichar *env,
752 IProgress **progress)
753 {
754 #if VBOX_API_VERSION >= 6001000
755 PRUnichar *envlist[] = { env };
756 return machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
757 sessionType, 1, envlist, progress);
758 #else
759 return machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
760 sessionType, env, progress);
761 #endif
762 }
763
764 static nsresult
_machineUnregister(IMachine * machine G_GNUC_UNUSED,PRUint32 cleanupMode G_GNUC_UNUSED,PRUint32 * aMediaSize G_GNUC_UNUSED,IMedium *** aMedia G_GNUC_UNUSED)765 _machineUnregister(IMachine *machine G_GNUC_UNUSED,
766 PRUint32 cleanupMode G_GNUC_UNUSED,
767 PRUint32 *aMediaSize G_GNUC_UNUSED,
768 IMedium ***aMedia G_GNUC_UNUSED)
769 {
770 return machine->vtbl->Unregister(machine, cleanupMode, aMediaSize, aMedia);
771 }
772
773 static nsresult
_machineFindSnapshot(IMachine * machine,vboxIID * iid,ISnapshot ** snapshot)774 _machineFindSnapshot(IMachine *machine, vboxIID *iid, ISnapshot **snapshot)
775 {
776 return machine->vtbl->FindSnapshot(machine, iid->value, snapshot);
777 }
778
779 static nsresult
_machineDetachDevice(IMachine * machine,PRUnichar * name,PRInt32 controllerPort,PRInt32 device)780 _machineDetachDevice(IMachine *machine, PRUnichar *name,
781 PRInt32 controllerPort, PRInt32 device)
782 {
783 return machine->vtbl->DetachDevice(machine, name, controllerPort, device);
784 }
785
786 static nsresult
_machineGetAccessible(IMachine * machine,PRBool * isAccessible)787 _machineGetAccessible(IMachine *machine, PRBool *isAccessible)
788 {
789 return machine->vtbl->GetAccessible(machine, isAccessible);
790 }
791
792 static nsresult
_machineGetState(IMachine * machine,PRUint32 * state)793 _machineGetState(IMachine *machine, PRUint32 *state)
794 {
795 return machine->vtbl->GetState(machine, state);
796 }
797
798 static nsresult
_machineGetName(IMachine * machine,PRUnichar ** name)799 _machineGetName(IMachine *machine, PRUnichar **name)
800 {
801 return machine->vtbl->GetName(machine, name);
802 }
803
804 static nsresult
_machineGetId(IMachine * machine,vboxIID * iid)805 _machineGetId(IMachine *machine, vboxIID *iid)
806 {
807 return machine->vtbl->GetId(machine, &iid->value);
808 }
809
810 static nsresult
_machineGetBIOSSettings(IMachine * machine,IBIOSSettings ** bios)811 _machineGetBIOSSettings(IMachine *machine, IBIOSSettings **bios)
812 {
813 return machine->vtbl->GetBIOSSettings(machine, bios);
814 }
815
816 static nsresult
_machineGetAudioAdapter(IMachine * machine,IAudioAdapter ** audioadapter)817 _machineGetAudioAdapter(IMachine *machine, IAudioAdapter **audioadapter)
818 {
819 return machine->vtbl->GetAudioAdapter(machine, audioadapter);
820 }
821
822 static nsresult
_machineGetNetworkAdapter(IMachine * machine,PRUint32 slot,INetworkAdapter ** adapter)823 _machineGetNetworkAdapter(IMachine *machine, PRUint32 slot, INetworkAdapter **adapter)
824 {
825 return machine->vtbl->GetNetworkAdapter(machine, slot, adapter);
826 }
827
828 static nsresult
_machineGetChipsetType(IMachine * machine G_GNUC_UNUSED,PRUint32 * chipsetType G_GNUC_UNUSED)829 _machineGetChipsetType(IMachine *machine G_GNUC_UNUSED, PRUint32 *chipsetType G_GNUC_UNUSED)
830 {
831 return machine->vtbl->GetChipsetType(machine, chipsetType);
832 }
833
834 static nsresult
_machineGetSerialPort(IMachine * machine,PRUint32 slot,ISerialPort ** port)835 _machineGetSerialPort(IMachine *machine, PRUint32 slot, ISerialPort **port)
836 {
837 return machine->vtbl->GetSerialPort(machine, slot, port);
838 }
839
840 static nsresult
_machineGetParallelPort(IMachine * machine,PRUint32 slot,IParallelPort ** port)841 _machineGetParallelPort(IMachine *machine, PRUint32 slot, IParallelPort **port)
842 {
843 return machine->vtbl->GetParallelPort(machine, slot, port);
844 }
845
846 static nsresult
_machineGetVRDEServer(IMachine * machine,IVRDEServer ** VRDEServer)847 _machineGetVRDEServer(IMachine *machine, IVRDEServer **VRDEServer)
848 {
849 return machine->vtbl->GetVRDEServer(machine, VRDEServer);
850 }
851
852 static nsresult
_machineGetUSBCommon(IMachine * machine,IUSBCommon ** USBCommon)853 _machineGetUSBCommon(IMachine *machine, IUSBCommon **USBCommon)
854 {
855 return machine->vtbl->GetUSBDeviceFilters(machine, USBCommon);
856 }
857
858 static nsresult
_machineGetCurrentSnapshot(IMachine * machine,ISnapshot ** currentSnapshot)859 _machineGetCurrentSnapshot(IMachine *machine, ISnapshot **currentSnapshot)
860 {
861 return machine->vtbl->GetCurrentSnapshot(machine, currentSnapshot);
862 }
863
864 static nsresult
_machineGetSettingsFilePath(IMachine * machine,PRUnichar ** settingsFilePath)865 _machineGetSettingsFilePath(IMachine *machine, PRUnichar **settingsFilePath)
866 {
867 return machine->vtbl->GetSettingsFilePath(machine, settingsFilePath);
868 }
869
870 static nsresult
_machineGetCPUCount(IMachine * machine,PRUint32 * CPUCount)871 _machineGetCPUCount(IMachine *machine, PRUint32 *CPUCount)
872 {
873 return machine->vtbl->GetCPUCount(machine, CPUCount);
874 }
875
876 static nsresult
_machineSetCPUCount(IMachine * machine,PRUint32 CPUCount)877 _machineSetCPUCount(IMachine *machine, PRUint32 CPUCount)
878 {
879 return machine->vtbl->SetCPUCount(machine, CPUCount);
880 }
881
882 static nsresult
_machineGetMemorySize(IMachine * machine,PRUint32 * memorySize)883 _machineGetMemorySize(IMachine *machine, PRUint32 *memorySize)
884 {
885 return machine->vtbl->GetMemorySize(machine, memorySize);
886 }
887
888 static nsresult
_machineSetMemorySize(IMachine * machine,PRUint32 memorySize)889 _machineSetMemorySize(IMachine *machine, PRUint32 memorySize)
890 {
891 return machine->vtbl->SetMemorySize(machine, memorySize);
892 }
893
894 static nsresult
_machineGetCPUProperty(IMachine * machine,PRUint32 property G_GNUC_UNUSED,PRBool * value)895 _machineGetCPUProperty(IMachine *machine, PRUint32 property G_GNUC_UNUSED, PRBool *value)
896 {
897 return machine->vtbl->GetCPUProperty(machine, property, value);
898 }
899
900 static nsresult
_machineSetCPUProperty(IMachine * machine,PRUint32 property G_GNUC_UNUSED,PRBool value)901 _machineSetCPUProperty(IMachine *machine, PRUint32 property G_GNUC_UNUSED, PRBool value)
902 {
903 return machine->vtbl->SetCPUProperty(machine, property, value);
904 }
905
906 static nsresult
_machineGetBootOrder(IMachine * machine,PRUint32 position,PRUint32 * device)907 _machineGetBootOrder(IMachine *machine, PRUint32 position, PRUint32 *device)
908 {
909 return machine->vtbl->GetBootOrder(machine, position, device);
910 }
911
912 static nsresult
_machineSetBootOrder(IMachine * machine,PRUint32 position,PRUint32 device)913 _machineSetBootOrder(IMachine *machine, PRUint32 position, PRUint32 device)
914 {
915 return machine->vtbl->SetBootOrder(machine, position, device);
916 }
917
918 static nsresult
_machineGetVRAMSize(IMachine * machine,PRUint32 * VRAMSize)919 _machineGetVRAMSize(IMachine *machine, PRUint32 *VRAMSize)
920 {
921 #if VBOX_API_VERSION >= 6001000
922 IGraphicsAdapter *ga;
923 nsresult ret;
924 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
925 if (NS_FAILED(ret))
926 return ret;
927 return ga->vtbl->GetVRAMSize(ga, VRAMSize);
928 #else
929 return machine->vtbl->GetVRAMSize(machine, VRAMSize);
930 #endif
931 }
932
933 static nsresult
_machineSetVRAMSize(IMachine * machine,PRUint32 VRAMSize)934 _machineSetVRAMSize(IMachine *machine, PRUint32 VRAMSize)
935 {
936 #if VBOX_API_VERSION >= 6001000
937 IGraphicsAdapter *ga;
938 nsresult ret;
939 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
940 if (NS_FAILED(ret))
941 return ret;
942 return ga->vtbl->SetVRAMSize(ga, VRAMSize);
943 #else
944 return machine->vtbl->SetVRAMSize(machine, VRAMSize);
945 #endif
946 }
947
948 static nsresult
_machineGetMonitorCount(IMachine * machine,PRUint32 * monitorCount)949 _machineGetMonitorCount(IMachine *machine, PRUint32 *monitorCount)
950 {
951 #if VBOX_API_VERSION >= 6001000
952 IGraphicsAdapter *ga;
953 nsresult ret;
954 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
955 if (NS_FAILED(ret))
956 return ret;
957 return ga->vtbl->GetMonitorCount(ga, monitorCount);
958 #else
959 return machine->vtbl->GetMonitorCount(machine, monitorCount);
960 #endif
961 }
962
963 static nsresult
_machineSetMonitorCount(IMachine * machine,PRUint32 monitorCount)964 _machineSetMonitorCount(IMachine *machine, PRUint32 monitorCount)
965 {
966 #if VBOX_API_VERSION >= 6001000
967 IGraphicsAdapter *ga;
968 nsresult ret;
969 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
970 if (NS_FAILED(ret))
971 return ret;
972 return ga->vtbl->SetMonitorCount(ga, monitorCount);
973 #else
974 return machine->vtbl->SetMonitorCount(machine, monitorCount);
975 #endif
976 }
977
978 static nsresult
_machineGetAccelerate3DEnabled(IMachine * machine,PRBool * accelerate3DEnabled)979 _machineGetAccelerate3DEnabled(IMachine *machine, PRBool *accelerate3DEnabled)
980 {
981 #if VBOX_API_VERSION >= 6001000
982 IGraphicsAdapter *ga;
983 nsresult ret;
984 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
985 if (NS_FAILED(ret))
986 return ret;
987 return ga->vtbl->GetAccelerate3DEnabled(ga, accelerate3DEnabled);
988 #else
989 return machine->vtbl->GetAccelerate3DEnabled(machine, accelerate3DEnabled);
990 #endif
991 }
992
993 static nsresult
_machineSetAccelerate3DEnabled(IMachine * machine,PRBool accelerate3DEnabled)994 _machineSetAccelerate3DEnabled(IMachine *machine, PRBool accelerate3DEnabled)
995 {
996 #if VBOX_API_VERSION >= 6001000
997 IGraphicsAdapter *ga;
998 nsresult ret;
999 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
1000 if (NS_FAILED(ret))
1001 return ret;
1002 return ga->vtbl->SetAccelerate3DEnabled(ga, accelerate3DEnabled);
1003 #else
1004 return machine->vtbl->SetAccelerate3DEnabled(machine, accelerate3DEnabled);
1005 #endif
1006 }
1007
1008 static nsresult
_machineGetAccelerate2DVideoEnabled(IMachine * machine,PRBool * accelerate2DVideoEnabled)1009 _machineGetAccelerate2DVideoEnabled(IMachine *machine,
1010 PRBool *accelerate2DVideoEnabled)
1011 {
1012 #if VBOX_API_VERSION >= 6001000
1013 IGraphicsAdapter *ga;
1014 nsresult ret;
1015 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
1016 if (NS_FAILED(ret))
1017 return ret;
1018 return ga->vtbl->GetAccelerate2DVideoEnabled(ga, accelerate2DVideoEnabled);
1019 #else
1020 return machine->vtbl->GetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
1021 #endif
1022 }
1023
1024 static nsresult
_machineSetAccelerate2DVideoEnabled(IMachine * machine,PRBool accelerate2DVideoEnabled)1025 _machineSetAccelerate2DVideoEnabled(IMachine *machine,
1026 PRBool accelerate2DVideoEnabled)
1027 {
1028 #if VBOX_API_VERSION >= 6001000
1029 IGraphicsAdapter *ga;
1030 nsresult ret;
1031 ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
1032 if (NS_FAILED(ret))
1033 return ret;
1034 return ga->vtbl->SetAccelerate2DVideoEnabled(ga, accelerate2DVideoEnabled);
1035 #else
1036 return machine->vtbl->SetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
1037 #endif
1038 }
1039
1040 static nsresult
_machineGetExtraData(IMachine * machine,PRUnichar * key,PRUnichar ** value)1041 _machineGetExtraData(IMachine *machine, PRUnichar *key, PRUnichar **value)
1042 {
1043 return machine->vtbl->GetExtraData(machine, key, value);
1044 }
1045
1046 static nsresult
_machineSetExtraData(IMachine * machine,PRUnichar * key,PRUnichar * value)1047 _machineSetExtraData(IMachine *machine, PRUnichar *key, PRUnichar *value)
1048 {
1049 return machine->vtbl->SetExtraData(machine, key, value);
1050 }
1051
1052 static nsresult
_machineGetSnapshotCount(IMachine * machine,PRUint32 * snapshotCount)1053 _machineGetSnapshotCount(IMachine *machine, PRUint32 *snapshotCount)
1054 {
1055 return machine->vtbl->GetSnapshotCount(machine, snapshotCount);
1056 }
1057
1058 static nsresult
_machineSaveSettings(IMachine * machine)1059 _machineSaveSettings(IMachine *machine)
1060 {
1061 return machine->vtbl->SaveSettings(machine);
1062 }
1063
1064 static nsresult
_sessionOpen(struct _vboxDriver * data,vboxIID * iid G_GNUC_UNUSED,IMachine * machine)1065 _sessionOpen(struct _vboxDriver *data, vboxIID *iid G_GNUC_UNUSED, IMachine *machine)
1066 {
1067 return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write);
1068 }
1069
1070 static nsresult
_sessionOpenExisting(struct _vboxDriver * data,vboxIID * iid G_GNUC_UNUSED,IMachine * machine)1071 _sessionOpenExisting(struct _vboxDriver *data, vboxIID *iid G_GNUC_UNUSED, IMachine *machine)
1072 {
1073 return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Shared);
1074 }
1075
1076 static nsresult
_sessionClose(ISession * session)1077 _sessionClose(ISession *session)
1078 {
1079 return session->vtbl->UnlockMachine(session);
1080 }
1081
1082 static nsresult
_sessionGetConsole(ISession * session,IConsole ** console)1083 _sessionGetConsole(ISession *session, IConsole **console)
1084 {
1085 return session->vtbl->GetConsole(session, console);
1086 }
1087
1088 static nsresult
_sessionGetMachine(ISession * session,IMachine ** machine)1089 _sessionGetMachine(ISession *session, IMachine **machine)
1090 {
1091 return session->vtbl->GetMachine(session, machine);
1092 }
1093
1094 static nsresult
_consoleSaveState(IConsole * console,IProgress ** progress)1095 _consoleSaveState(IConsole *console, IProgress **progress)
1096 {
1097 IMachine *machine;
1098 nsresult rc;
1099
1100 rc = console->vtbl->GetMachine(console, &machine);
1101
1102 if (NS_SUCCEEDED(rc))
1103 rc = machine->vtbl->SaveState(machine, progress);
1104 else
1105 virReportError(VIR_ERR_INTERNAL_ERROR,
1106 _("unable to get machine from console. (error %d)"), rc);
1107
1108 return rc;
1109 }
1110
1111 static nsresult
_consolePause(IConsole * console)1112 _consolePause(IConsole *console)
1113 {
1114 return console->vtbl->Pause(console);
1115 }
1116
1117 static nsresult
_consoleResume(IConsole * console)1118 _consoleResume(IConsole *console)
1119 {
1120 return console->vtbl->Resume(console);
1121 }
1122
1123 static nsresult
_consolePowerButton(IConsole * console)1124 _consolePowerButton(IConsole *console)
1125 {
1126 return console->vtbl->PowerButton(console);
1127 }
1128
1129 static nsresult
_consolePowerDown(IConsole * console)1130 _consolePowerDown(IConsole *console)
1131 {
1132 nsresult rc;
1133 IProgress *progress = NULL;
1134 rc = console->vtbl->PowerDown(console, &progress);
1135 if (progress) {
1136 rc = progress->vtbl->WaitForCompletion(progress, -1);
1137 VBOX_RELEASE(progress);
1138 }
1139
1140 return rc;
1141 }
1142
1143 static nsresult
_consoleReset(IConsole * console)1144 _consoleReset(IConsole *console)
1145 {
1146 return console->vtbl->Reset(console);
1147 }
1148
1149 static nsresult
_consoleTakeSnapshot(IConsole * console,PRUnichar * name,PRUnichar * description,IProgress ** progress)1150 _consoleTakeSnapshot(IConsole *console, PRUnichar *name,
1151 PRUnichar *description, IProgress **progress)
1152 {
1153 IMachine *machine;
1154 nsresult rc;
1155 PRUnichar *id = NULL;
1156 bool bpause = true; /* NO live snapshot */
1157
1158 rc = console->vtbl->GetMachine(console, &machine);
1159
1160 if (NS_SUCCEEDED(rc))
1161 rc = machine->vtbl->TakeSnapshot(machine, name, description, bpause, &id, progress);
1162 else
1163 virReportError(VIR_ERR_INTERNAL_ERROR,
1164 _("unable to get machine from console. (error %d)"), rc);
1165
1166 VBOX_RELEASE(machine);
1167 return rc;
1168 }
1169
1170 static nsresult
_consoleDeleteSnapshot(IConsole * console,vboxIID * iid,IProgress ** progress)1171 _consoleDeleteSnapshot(IConsole *console, vboxIID *iid, IProgress **progress)
1172 {
1173 IMachine *machine;
1174 nsresult rc;
1175
1176 rc = console->vtbl->GetMachine(console, &machine);
1177
1178 if (NS_SUCCEEDED(rc))
1179 rc = machine->vtbl->DeleteSnapshot(machine, iid->value, progress);
1180 else
1181 virReportError(VIR_ERR_INTERNAL_ERROR,
1182 _("unable to get machine from console. (error %d)"), rc);
1183
1184 VBOX_RELEASE(machine);
1185
1186 return rc;
1187 }
1188
1189 static nsresult
_consoleGetDisplay(IConsole * console,IDisplay ** display)1190 _consoleGetDisplay(IConsole *console, IDisplay **display)
1191 {
1192 return console->vtbl->GetDisplay(console, display);
1193 }
1194
1195 static nsresult
_consoleGetKeyboard(IConsole * console,IKeyboard ** keyboard)1196 _consoleGetKeyboard(IConsole *console, IKeyboard **keyboard)
1197 {
1198 return console->vtbl->GetKeyboard(console, keyboard);
1199 }
1200
1201 static nsresult
_progressWaitForCompletion(IProgress * progress,PRInt32 timeout)1202 _progressWaitForCompletion(IProgress *progress, PRInt32 timeout)
1203 {
1204 return progress->vtbl->WaitForCompletion(progress, timeout);
1205 }
1206
1207 static nsresult
_progressGetResultCode(IProgress * progress,resultCodeUnion * resultCode)1208 _progressGetResultCode(IProgress *progress, resultCodeUnion *resultCode)
1209 {
1210 return progress->vtbl->GetResultCode(progress, &resultCode->resultCode);
1211 }
1212
1213 static nsresult
_progressGetCompleted(IProgress * progress,PRBool * completed)1214 _progressGetCompleted(IProgress *progress, PRBool *completed)
1215 {
1216 return progress->vtbl->GetCompleted(progress, completed);
1217 }
1218
1219 static nsresult
_systemPropertiesGetMaxGuestCPUCount(ISystemProperties * systemProperties,PRUint32 * maxCPUCount)1220 _systemPropertiesGetMaxGuestCPUCount(ISystemProperties *systemProperties, PRUint32 *maxCPUCount)
1221 {
1222 return systemProperties->vtbl->GetMaxGuestCPUCount(systemProperties, maxCPUCount);
1223 }
1224
1225 static nsresult
_systemPropertiesGetMaxBootPosition(ISystemProperties * systemProperties,PRUint32 * maxBootPosition)1226 _systemPropertiesGetMaxBootPosition(ISystemProperties *systemProperties, PRUint32 *maxBootPosition)
1227 {
1228 return systemProperties->vtbl->GetMaxBootPosition(systemProperties, maxBootPosition);
1229 }
1230
1231 static nsresult
_systemPropertiesGetMaxNetworkAdapters(ISystemProperties * systemProperties,PRUint32 chipset G_GNUC_UNUSED,PRUint32 * maxNetworkAdapters)1232 _systemPropertiesGetMaxNetworkAdapters(ISystemProperties *systemProperties, PRUint32 chipset G_GNUC_UNUSED,
1233 PRUint32 *maxNetworkAdapters)
1234 {
1235 return systemProperties->vtbl->GetMaxNetworkAdapters(systemProperties, chipset,
1236 maxNetworkAdapters);
1237 }
1238
1239 static nsresult
_systemPropertiesGetSerialPortCount(ISystemProperties * systemProperties,PRUint32 * SerialPortCount)1240 _systemPropertiesGetSerialPortCount(ISystemProperties *systemProperties, PRUint32 *SerialPortCount)
1241 {
1242 return systemProperties->vtbl->GetSerialPortCount(systemProperties, SerialPortCount);
1243 }
1244
1245 static nsresult
_systemPropertiesGetParallelPortCount(ISystemProperties * systemProperties,PRUint32 * ParallelPortCount)1246 _systemPropertiesGetParallelPortCount(ISystemProperties *systemProperties, PRUint32 *ParallelPortCount)
1247 {
1248 return systemProperties->vtbl->GetParallelPortCount(systemProperties, ParallelPortCount);
1249 }
1250
1251 static nsresult
_systemPropertiesGetMaxPortCountForStorageBus(ISystemProperties * systemProperties,PRUint32 bus,PRUint32 * maxPortCount)1252 _systemPropertiesGetMaxPortCountForStorageBus(ISystemProperties *systemProperties, PRUint32 bus,
1253 PRUint32 *maxPortCount)
1254 {
1255 return systemProperties->vtbl->GetMaxPortCountForStorageBus(systemProperties, bus, maxPortCount);
1256 }
1257
1258 static nsresult
_systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties * systemProperties,PRUint32 bus,PRUint32 * maxDevicesPerPort)1259 _systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties *systemProperties,
1260 PRUint32 bus, PRUint32 *maxDevicesPerPort)
1261 {
1262 return systemProperties->vtbl->GetMaxDevicesPerPortForStorageBus(systemProperties,
1263 bus, maxDevicesPerPort);
1264 }
1265
1266 static nsresult
_systemPropertiesGetMaxGuestRAM(ISystemProperties * systemProperties,PRUint32 * maxGuestRAM)1267 _systemPropertiesGetMaxGuestRAM(ISystemProperties *systemProperties, PRUint32 *maxGuestRAM)
1268 {
1269 return systemProperties->vtbl->GetMaxGuestRAM(systemProperties, maxGuestRAM);
1270 }
1271
1272 static nsresult
_biosSettingsGetACPIEnabled(IBIOSSettings * bios,PRBool * ACPIEnabled)1273 _biosSettingsGetACPIEnabled(IBIOSSettings *bios, PRBool *ACPIEnabled)
1274 {
1275 return bios->vtbl->GetACPIEnabled(bios, ACPIEnabled);
1276 }
1277
1278 static nsresult
_biosSettingsSetACPIEnabled(IBIOSSettings * bios,PRBool ACPIEnabled)1279 _biosSettingsSetACPIEnabled(IBIOSSettings *bios, PRBool ACPIEnabled)
1280 {
1281 return bios->vtbl->SetACPIEnabled(bios, ACPIEnabled);
1282 }
1283
1284 static nsresult
_biosSettingsGetIOAPICEnabled(IBIOSSettings * bios,PRBool * IOAPICEnabled)1285 _biosSettingsGetIOAPICEnabled(IBIOSSettings *bios, PRBool *IOAPICEnabled)
1286 {
1287 return bios->vtbl->GetIOAPICEnabled(bios, IOAPICEnabled);
1288 }
1289
1290 static nsresult
_biosSettingsSetIOAPICEnabled(IBIOSSettings * bios,PRBool IOAPICEnabled)1291 _biosSettingsSetIOAPICEnabled(IBIOSSettings *bios, PRBool IOAPICEnabled)
1292 {
1293 return bios->vtbl->SetIOAPICEnabled(bios, IOAPICEnabled);
1294 }
1295
1296 static nsresult
_audioAdapterGetEnabled(IAudioAdapter * audioAdapter,PRBool * enabled)1297 _audioAdapterGetEnabled(IAudioAdapter *audioAdapter, PRBool *enabled)
1298 {
1299 return audioAdapter->vtbl->GetEnabled(audioAdapter, enabled);
1300 }
1301
1302 static nsresult
_audioAdapterSetEnabled(IAudioAdapter * audioAdapter,PRBool enabled)1303 _audioAdapterSetEnabled(IAudioAdapter *audioAdapter, PRBool enabled)
1304 {
1305 return audioAdapter->vtbl->SetEnabled(audioAdapter, enabled);
1306 }
1307
1308 static nsresult
_audioAdapterGetAudioController(IAudioAdapter * audioAdapter,PRUint32 * audioController)1309 _audioAdapterGetAudioController(IAudioAdapter *audioAdapter, PRUint32 *audioController)
1310 {
1311 return audioAdapter->vtbl->GetAudioController(audioAdapter, audioController);
1312 }
1313
1314 static nsresult
_audioAdapterSetAudioController(IAudioAdapter * audioAdapter,PRUint32 audioController)1315 _audioAdapterSetAudioController(IAudioAdapter *audioAdapter, PRUint32 audioController)
1316 {
1317 return audioAdapter->vtbl->SetAudioController(audioAdapter, audioController);
1318 }
1319
1320 static nsresult
_networkAdapterGetAttachmentType(INetworkAdapter * adapter,PRUint32 * attachmentType)1321 _networkAdapterGetAttachmentType(INetworkAdapter *adapter, PRUint32 *attachmentType)
1322 {
1323 return adapter->vtbl->GetAttachmentType(adapter, attachmentType);
1324 }
1325
1326 static nsresult
_networkAdapterGetEnabled(INetworkAdapter * adapter,PRBool * enabled)1327 _networkAdapterGetEnabled(INetworkAdapter *adapter, PRBool *enabled)
1328 {
1329 return adapter->vtbl->GetEnabled(adapter, enabled);
1330 }
1331
1332 static nsresult
_networkAdapterSetEnabled(INetworkAdapter * adapter,PRBool enabled)1333 _networkAdapterSetEnabled(INetworkAdapter *adapter, PRBool enabled)
1334 {
1335 return adapter->vtbl->SetEnabled(adapter, enabled);
1336 }
1337
1338 static nsresult
_networkAdapterGetAdapterType(INetworkAdapter * adapter,PRUint32 * adapterType)1339 _networkAdapterGetAdapterType(INetworkAdapter *adapter, PRUint32 *adapterType)
1340 {
1341 return adapter->vtbl->GetAdapterType(adapter, adapterType);
1342 }
1343
1344 static nsresult
_networkAdapterSetAdapterType(INetworkAdapter * adapter,PRUint32 adapterType)1345 _networkAdapterSetAdapterType(INetworkAdapter *adapter, PRUint32 adapterType)
1346 {
1347 return adapter->vtbl->SetAdapterType(adapter, adapterType);
1348 }
1349
1350 static nsresult
_networkAdapterGetInternalNetwork(INetworkAdapter * adapter,PRUnichar ** internalNetwork)1351 _networkAdapterGetInternalNetwork(INetworkAdapter *adapter, PRUnichar **internalNetwork)
1352 {
1353 return adapter->vtbl->GetInternalNetwork(adapter, internalNetwork);
1354 }
1355
1356 static nsresult
_networkAdapterSetInternalNetwork(INetworkAdapter * adapter,PRUnichar * internalNetwork)1357 _networkAdapterSetInternalNetwork(INetworkAdapter *adapter, PRUnichar *internalNetwork)
1358 {
1359 return adapter->vtbl->SetInternalNetwork(adapter, internalNetwork);
1360 }
1361
1362 static nsresult
_networkAdapterGetMACAddress(INetworkAdapter * adapter,PRUnichar ** MACAddress)1363 _networkAdapterGetMACAddress(INetworkAdapter *adapter, PRUnichar **MACAddress)
1364 {
1365 return adapter->vtbl->GetMACAddress(adapter, MACAddress);
1366 }
1367
1368 static nsresult
_networkAdapterSetMACAddress(INetworkAdapter * adapter,PRUnichar * MACAddress)1369 _networkAdapterSetMACAddress(INetworkAdapter *adapter, PRUnichar *MACAddress)
1370 {
1371 return adapter->vtbl->SetMACAddress(adapter, MACAddress);
1372 }
1373
1374 static nsresult
_networkAdapterGetBridgedInterface(INetworkAdapter * adapter,PRUnichar ** bridgedInterface)1375 _networkAdapterGetBridgedInterface(INetworkAdapter *adapter, PRUnichar **bridgedInterface)
1376 {
1377 return adapter->vtbl->GetBridgedInterface(adapter, bridgedInterface);
1378 }
1379
1380 static nsresult
_networkAdapterSetBridgedInterface(INetworkAdapter * adapter,PRUnichar * bridgedInterface)1381 _networkAdapterSetBridgedInterface(INetworkAdapter *adapter, PRUnichar *bridgedInterface)
1382 {
1383 return adapter->vtbl->SetBridgedInterface(adapter, bridgedInterface);
1384 }
1385
1386 static nsresult
_networkAdapterGetHostOnlyInterface(INetworkAdapter * adapter,PRUnichar ** hostOnlyInterface)1387 _networkAdapterGetHostOnlyInterface(INetworkAdapter *adapter, PRUnichar **hostOnlyInterface)
1388 {
1389 return adapter->vtbl->GetHostOnlyInterface(adapter, hostOnlyInterface);
1390 }
1391
1392 static nsresult
_networkAdapterSetHostOnlyInterface(INetworkAdapter * adapter,PRUnichar * hostOnlyInterface)1393 _networkAdapterSetHostOnlyInterface(INetworkAdapter *adapter, PRUnichar *hostOnlyInterface)
1394 {
1395 return adapter->vtbl->SetHostOnlyInterface(adapter, hostOnlyInterface);
1396 }
1397
1398 static nsresult
_networkAdapterAttachToBridgedInterface(INetworkAdapter * adapter)1399 _networkAdapterAttachToBridgedInterface(INetworkAdapter *adapter)
1400 {
1401 return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_Bridged);
1402 }
1403
1404 static nsresult
_networkAdapterAttachToInternalNetwork(INetworkAdapter * adapter)1405 _networkAdapterAttachToInternalNetwork(INetworkAdapter *adapter)
1406 {
1407 return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_Internal);
1408 }
1409
1410 static nsresult
_networkAdapterAttachToHostOnlyInterface(INetworkAdapter * adapter)1411 _networkAdapterAttachToHostOnlyInterface(INetworkAdapter *adapter)
1412 {
1413 return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_HostOnly);
1414 }
1415
1416 static nsresult
_networkAdapterAttachToNAT(INetworkAdapter * adapter)1417 _networkAdapterAttachToNAT(INetworkAdapter *adapter)
1418 {
1419 return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_NAT);
1420 }
1421
1422 static nsresult
_serialPortGetEnabled(ISerialPort * port,PRBool * enabled)1423 _serialPortGetEnabled(ISerialPort *port, PRBool *enabled)
1424 {
1425 return port->vtbl->GetEnabled(port, enabled);
1426 }
1427
1428 static nsresult
_serialPortSetEnabled(ISerialPort * port,PRBool enabled)1429 _serialPortSetEnabled(ISerialPort *port, PRBool enabled)
1430 {
1431 return port->vtbl->SetEnabled(port, enabled);
1432 }
1433
1434 static nsresult
_serialPortGetPath(ISerialPort * port,PRUnichar ** path)1435 _serialPortGetPath(ISerialPort *port, PRUnichar **path)
1436 {
1437 return port->vtbl->GetPath(port, path);
1438 }
1439
1440 static nsresult
_serialPortSetPath(ISerialPort * port,PRUnichar * path)1441 _serialPortSetPath(ISerialPort *port, PRUnichar *path)
1442 {
1443 return port->vtbl->SetPath(port, path);
1444 }
1445
1446 static nsresult
_serialPortGetIRQ(ISerialPort * port,PRUint32 * IRQ)1447 _serialPortGetIRQ(ISerialPort *port, PRUint32 *IRQ)
1448 {
1449 return port->vtbl->GetIRQ(port, IRQ);
1450 }
1451
1452 static nsresult
_serialPortSetIRQ(ISerialPort * port,PRUint32 IRQ)1453 _serialPortSetIRQ(ISerialPort *port, PRUint32 IRQ)
1454 {
1455 return port->vtbl->SetIRQ(port, IRQ);
1456 }
1457
1458 static nsresult
_serialPortGetIOBase(ISerialPort * port,PRUint32 * IOBase)1459 _serialPortGetIOBase(ISerialPort *port, PRUint32 *IOBase)
1460 {
1461 return port->vtbl->GetIOBase(port, IOBase);
1462 }
1463
1464 static nsresult
_serialPortSetIOBase(ISerialPort * port,PRUint32 IOBase)1465 _serialPortSetIOBase(ISerialPort *port, PRUint32 IOBase)
1466 {
1467 return port->vtbl->SetIOBase(port, IOBase);
1468 }
1469
1470 static nsresult
_serialPortGetHostMode(ISerialPort * port,PRUint32 * hostMode)1471 _serialPortGetHostMode(ISerialPort *port, PRUint32 *hostMode)
1472 {
1473 return port->vtbl->GetHostMode(port, hostMode);
1474 }
1475
1476 static nsresult
_serialPortSetHostMode(ISerialPort * port,PRUint32 hostMode)1477 _serialPortSetHostMode(ISerialPort *port, PRUint32 hostMode)
1478 {
1479 return port->vtbl->SetHostMode(port, hostMode);
1480 }
1481
1482 static nsresult
_parallelPortGetEnabled(IParallelPort * port,PRBool * enabled)1483 _parallelPortGetEnabled(IParallelPort *port, PRBool *enabled)
1484 {
1485 return port->vtbl->GetEnabled(port, enabled);
1486 }
1487
1488 static nsresult
_parallelPortSetEnabled(IParallelPort * port,PRBool enabled)1489 _parallelPortSetEnabled(IParallelPort *port, PRBool enabled)
1490 {
1491 return port->vtbl->SetEnabled(port, enabled);
1492 }
1493
1494 static nsresult
_parallelPortGetPath(IParallelPort * port,PRUnichar ** path)1495 _parallelPortGetPath(IParallelPort *port, PRUnichar **path)
1496 {
1497 return port->vtbl->GetPath(port, path);
1498 }
1499
1500 static nsresult
_parallelPortSetPath(IParallelPort * port,PRUnichar * path)1501 _parallelPortSetPath(IParallelPort *port, PRUnichar *path)
1502 {
1503 return port->vtbl->SetPath(port, path);
1504 }
1505
1506 static nsresult
_parallelPortGetIRQ(IParallelPort * port,PRUint32 * IRQ)1507 _parallelPortGetIRQ(IParallelPort *port, PRUint32 *IRQ)
1508 {
1509 return port->vtbl->GetIRQ(port, IRQ);
1510 }
1511
1512 static nsresult
_parallelPortSetIRQ(IParallelPort * port,PRUint32 IRQ)1513 _parallelPortSetIRQ(IParallelPort *port, PRUint32 IRQ)
1514 {
1515 return port->vtbl->SetIRQ(port, IRQ);
1516 }
1517
1518 static nsresult
_parallelPortGetIOBase(IParallelPort * port,PRUint32 * IOBase)1519 _parallelPortGetIOBase(IParallelPort *port, PRUint32 *IOBase)
1520 {
1521 return port->vtbl->GetIOBase(port, IOBase);
1522 }
1523
1524 static nsresult
_parallelPortSetIOBase(IParallelPort * port,PRUint32 IOBase)1525 _parallelPortSetIOBase(IParallelPort *port, PRUint32 IOBase)
1526 {
1527 return port->vtbl->SetIOBase(port, IOBase);
1528 }
1529
1530 static nsresult
_vrdeServerGetEnabled(IVRDEServer * VRDEServer,PRBool * enabled)1531 _vrdeServerGetEnabled(IVRDEServer *VRDEServer, PRBool *enabled)
1532 {
1533 return VRDEServer->vtbl->GetEnabled(VRDEServer, enabled);
1534 }
1535
1536 static nsresult
_vrdeServerSetEnabled(IVRDEServer * VRDEServer,PRBool enabled)1537 _vrdeServerSetEnabled(IVRDEServer *VRDEServer, PRBool enabled)
1538 {
1539 return VRDEServer->vtbl->SetEnabled(VRDEServer, enabled);
1540 }
1541
1542 static nsresult
_vrdeServerGetPorts(struct _vboxDriver * data,IVRDEServer * VRDEServer,IMachine * machine,virDomainGraphicsDef * graphics)1543 _vrdeServerGetPorts(struct _vboxDriver *data, IVRDEServer *VRDEServer,
1544 IMachine *machine, virDomainGraphicsDef *graphics)
1545 {
1546 nsresult rc;
1547 PRUnichar *VRDEPortsKey = NULL;
1548 PRUnichar *VRDEPortsValue = NULL;
1549 PRInt32 port = -1;
1550 ssize_t nmatches = 0;
1551 g_auto(GStrv) matches = NULL;
1552 char *portUtf8 = NULL;
1553
1554 /* get active (effective) port - available only when VM is running and has
1555 * the VBOX extensions installed (without extensions RDP server
1556 * functionality is disabled)
1557 */
1558 port = vboxGetActiveVRDEServerPort(data->vboxSession, machine);
1559
1560 if (port > 0)
1561 graphics->data.rdp.port = port;
1562
1563 /* get the port (or port range) set in VM properties, this info will
1564 * be used to determine whether to set autoport flag
1565 */
1566 VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
1567 rc = VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDEPortsKey,
1568 &VRDEPortsValue);
1569
1570 if (NS_FAILED(rc)) {
1571 virReportError(VIR_ERR_INTERNAL_ERROR,
1572 _("Failed to read RDP port value, rc=%08x"),
1573 (unsigned) rc);
1574 goto cleanup;
1575 }
1576
1577 VBOX_UTF16_TO_UTF8(VRDEPortsValue, &portUtf8);
1578
1579 if (portUtf8) {
1580 /* does the string contain digits only */
1581 nmatches = virStringSearch(portUtf8, "(^[[:digit:]]+$)", 1, &matches);
1582
1583 /* the port property is not numeric, then it must be a port range or
1584 * port list or combination of the two, either way it's an autoport
1585 */
1586 if (nmatches != 1)
1587 graphics->data.rdp.autoport = true;
1588
1589 /* no active port available, e.g. VM is powered off, try to get it from
1590 * the property string
1591 */
1592 if (port < 0) {
1593 if (nmatches == 1 && virStrToLong_i(portUtf8, NULL, 10, &port) == 0)
1594 graphics->data.rdp.port = port;
1595 }
1596 }
1597
1598 cleanup:
1599 VBOX_UTF8_FREE(portUtf8);
1600 VBOX_UTF16_FREE(VRDEPortsValue);
1601 VBOX_UTF16_FREE(VRDEPortsKey);
1602
1603 return rc;
1604 }
1605
1606 static nsresult
_vrdeServerSetPorts(struct _vboxDriver * data,IVRDEServer * VRDEServer,virDomainGraphicsDef * graphics)1607 _vrdeServerSetPorts(struct _vboxDriver *data, IVRDEServer *VRDEServer,
1608 virDomainGraphicsDef *graphics)
1609 {
1610 nsresult rc = 0;
1611 PRUnichar *VRDEPortsKey = NULL;
1612 PRUnichar *VRDEPortsValue = NULL;
1613
1614 VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
1615
1616 if (graphics->data.rdp.autoport)
1617 VBOX_UTF8_TO_UTF16(VBOX_RDP_AUTOPORT_RANGE, &VRDEPortsValue);
1618 else
1619 VRDEPortsValue = PRUnicharFromInt(data->pFuncs,
1620 graphics->data.rdp.port);
1621
1622 rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, VRDEPortsKey,
1623 VRDEPortsValue);
1624 VBOX_UTF16_FREE(VRDEPortsKey);
1625 VBOX_UTF16_FREE(VRDEPortsValue);
1626
1627 return rc;
1628 }
1629
1630 static nsresult
_vrdeServerGetReuseSingleConnection(IVRDEServer * VRDEServer,PRBool * enabled)1631 _vrdeServerGetReuseSingleConnection(IVRDEServer *VRDEServer, PRBool *enabled)
1632 {
1633 return VRDEServer->vtbl->GetReuseSingleConnection(VRDEServer, enabled);
1634 }
1635
1636 static nsresult
_vrdeServerSetReuseSingleConnection(IVRDEServer * VRDEServer,PRBool enabled)1637 _vrdeServerSetReuseSingleConnection(IVRDEServer *VRDEServer, PRBool enabled)
1638 {
1639 return VRDEServer->vtbl->SetReuseSingleConnection(VRDEServer, enabled);
1640 }
1641
1642 static nsresult
_vrdeServerGetAllowMultiConnection(IVRDEServer * VRDEServer,PRBool * enabled)1643 _vrdeServerGetAllowMultiConnection(IVRDEServer *VRDEServer, PRBool *enabled)
1644 {
1645 return VRDEServer->vtbl->GetAllowMultiConnection(VRDEServer, enabled);
1646 }
1647
1648 static nsresult
_vrdeServerSetAllowMultiConnection(IVRDEServer * VRDEServer,PRBool enabled)1649 _vrdeServerSetAllowMultiConnection(IVRDEServer *VRDEServer, PRBool enabled)
1650 {
1651 return VRDEServer->vtbl->SetAllowMultiConnection(VRDEServer, enabled);
1652 }
1653
1654 static nsresult
_vrdeServerGetNetAddress(struct _vboxDriver * data G_GNUC_UNUSED,IVRDEServer * VRDEServer,PRUnichar ** netAddress)1655 _vrdeServerGetNetAddress(struct _vboxDriver *data G_GNUC_UNUSED,
1656 IVRDEServer *VRDEServer, PRUnichar **netAddress)
1657 {
1658 PRUnichar *VRDENetAddressKey = NULL;
1659 nsresult rc;
1660
1661 VBOX_UTF8_TO_UTF16("TCP/Address", &VRDENetAddressKey);
1662 rc = VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDENetAddressKey, netAddress);
1663 VBOX_UTF16_FREE(VRDENetAddressKey);
1664
1665 return rc;
1666 }
1667
1668 static nsresult
_vrdeServerSetNetAddress(struct _vboxDriver * data G_GNUC_UNUSED,IVRDEServer * VRDEServer,PRUnichar * netAddress)1669 _vrdeServerSetNetAddress(struct _vboxDriver *data G_GNUC_UNUSED,
1670 IVRDEServer *VRDEServer, PRUnichar *netAddress)
1671 {
1672 PRUnichar *netAddressKey = NULL;
1673 nsresult rc;
1674
1675 VBOX_UTF8_TO_UTF16("TCP/Address", &netAddressKey);
1676 rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, netAddressKey,
1677 netAddress);
1678 VBOX_UTF16_FREE(netAddressKey);
1679
1680 return rc;
1681 }
1682
1683 static nsresult
_usbCommonEnable(IUSBCommon * USBCommon G_GNUC_UNUSED)1684 _usbCommonEnable(IUSBCommon *USBCommon G_GNUC_UNUSED)
1685 {
1686 /* We don't need to set usb enabled for vbox 4.3 and later */
1687 return 0;
1688 }
1689
1690 static nsresult
_usbCommonGetEnabled(IUSBCommon * USBCommon G_GNUC_UNUSED,PRBool * enabled)1691 _usbCommonGetEnabled(IUSBCommon *USBCommon G_GNUC_UNUSED, PRBool *enabled)
1692 {
1693 *enabled = true;
1694 return 0;
1695 }
1696
1697 static nsresult
_usbCommonCreateDeviceFilter(IUSBCommon * USBCommon,PRUnichar * name,IUSBDeviceFilter ** filter)1698 _usbCommonCreateDeviceFilter(IUSBCommon *USBCommon, PRUnichar *name,
1699 IUSBDeviceFilter **filter)
1700 {
1701 return USBCommon->vtbl->CreateDeviceFilter(USBCommon, name, filter);
1702 }
1703
1704 static nsresult
_usbCommonInsertDeviceFilter(IUSBCommon * USBCommon,PRUint32 position,IUSBDeviceFilter * filter)1705 _usbCommonInsertDeviceFilter(IUSBCommon *USBCommon, PRUint32 position,
1706 IUSBDeviceFilter *filter)
1707 {
1708 return USBCommon->vtbl->InsertDeviceFilter(USBCommon, position, filter);
1709 }
1710
1711 static nsresult
_usbDeviceFilterGetProductId(IUSBDeviceFilter * USBDeviceFilter,PRUnichar ** productId)1712 _usbDeviceFilterGetProductId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar **productId)
1713 {
1714 return USBDeviceFilter->vtbl->GetProductId(USBDeviceFilter, productId);
1715 }
1716
1717 static nsresult
_usbDeviceFilterSetProductId(IUSBDeviceFilter * USBDeviceFilter,PRUnichar * productId)1718 _usbDeviceFilterSetProductId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar *productId)
1719 {
1720 return USBDeviceFilter->vtbl->SetProductId(USBDeviceFilter, productId);
1721 }
1722
1723 static nsresult
_usbDeviceFilterGetActive(IUSBDeviceFilter * USBDeviceFilter,PRBool * active)1724 _usbDeviceFilterGetActive(IUSBDeviceFilter *USBDeviceFilter, PRBool *active)
1725 {
1726 return USBDeviceFilter->vtbl->GetActive(USBDeviceFilter, active);
1727 }
1728
1729 static nsresult
_usbDeviceFilterSetActive(IUSBDeviceFilter * USBDeviceFilter,PRBool active)1730 _usbDeviceFilterSetActive(IUSBDeviceFilter *USBDeviceFilter, PRBool active)
1731 {
1732 return USBDeviceFilter->vtbl->SetActive(USBDeviceFilter, active);
1733 }
1734
1735 static nsresult
_usbDeviceFilterGetVendorId(IUSBDeviceFilter * USBDeviceFilter,PRUnichar ** vendorId)1736 _usbDeviceFilterGetVendorId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar **vendorId)
1737 {
1738 return USBDeviceFilter->vtbl->GetVendorId(USBDeviceFilter, vendorId);
1739 }
1740
1741 static nsresult
_usbDeviceFilterSetVendorId(IUSBDeviceFilter * USBDeviceFilter,PRUnichar * vendorId)1742 _usbDeviceFilterSetVendorId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar *vendorId)
1743 {
1744 return USBDeviceFilter->vtbl->SetVendorId(USBDeviceFilter, vendorId);
1745 }
1746
_mediumGetId(IMedium * medium,vboxIID * iid)1747 static nsresult _mediumGetId(IMedium *medium, vboxIID *iid)
1748 {
1749 return medium->vtbl->GetId(medium, &iid->value);
1750 }
1751
_mediumGetLocation(IMedium * medium,PRUnichar ** location)1752 static nsresult _mediumGetLocation(IMedium *medium, PRUnichar **location)
1753 {
1754 return medium->vtbl->GetLocation(medium, location);
1755 }
1756
_mediumGetState(IMedium * medium,PRUint32 * state)1757 static nsresult _mediumGetState(IMedium *medium, PRUint32 *state)
1758 {
1759 return medium->vtbl->GetState(medium, state);
1760 }
1761
_mediumGetName(IMedium * medium,PRUnichar ** name)1762 static nsresult _mediumGetName(IMedium *medium, PRUnichar **name)
1763 {
1764 return medium->vtbl->GetName(medium, name);
1765 }
1766
_mediumGetSize(IMedium * medium,PRUint64 * uSize)1767 static nsresult _mediumGetSize(IMedium *medium, PRUint64 *uSize)
1768 {
1769 nsresult rc;
1770 PRInt64 Size;
1771
1772 rc = medium->vtbl->GetSize(medium, &Size);
1773 *uSize = Size;
1774
1775 return rc;
1776 }
1777
_mediumGetReadOnly(IMedium * medium G_GNUC_UNUSED,PRBool * readOnly G_GNUC_UNUSED)1778 static nsresult _mediumGetReadOnly(IMedium *medium G_GNUC_UNUSED,
1779 PRBool *readOnly G_GNUC_UNUSED)
1780 {
1781 return medium->vtbl->GetReadOnly(medium, readOnly);
1782 }
1783
_mediumGetParent(IMedium * medium,IMedium ** parent)1784 static nsresult _mediumGetParent(IMedium *medium,
1785 IMedium **parent)
1786 {
1787 return medium->vtbl->GetParent(medium, parent);
1788 }
1789
_mediumGetChildren(IMedium * medium,PRUint32 * childrenSize,IMedium *** children)1790 static nsresult _mediumGetChildren(IMedium *medium,
1791 PRUint32 *childrenSize,
1792 IMedium ***children)
1793 {
1794 return medium->vtbl->GetChildren(medium, childrenSize, children);
1795 }
1796
_mediumGetFormat(IMedium * medium,PRUnichar ** format)1797 static nsresult _mediumGetFormat(IMedium *medium,
1798 PRUnichar **format)
1799 {
1800 return medium->vtbl->GetFormat(medium, format);
1801 }
1802
_mediumDeleteStorage(IMedium * medium,IProgress ** progress)1803 static nsresult _mediumDeleteStorage(IMedium *medium,
1804 IProgress **progress)
1805 {
1806 return medium->vtbl->DeleteStorage(medium, progress);
1807 }
1808
_mediumRelease(IMedium * medium)1809 static nsresult _mediumRelease(IMedium *medium)
1810 {
1811 return medium->vtbl->nsisupports.Release((nsISupports *)medium);
1812 }
_mediumClose(IMedium * medium)1813 static nsresult _mediumClose(IMedium *medium)
1814 {
1815 return medium->vtbl->Close(medium);
1816 }
1817
_mediumSetType(IMedium * medium G_GNUC_UNUSED,PRUint32 type G_GNUC_UNUSED)1818 static nsresult _mediumSetType(IMedium *medium G_GNUC_UNUSED,
1819 PRUint32 type G_GNUC_UNUSED)
1820 {
1821 return medium->vtbl->SetType(medium, type);
1822 }
1823
1824 static nsresult
_mediumCreateDiffStorage(IMedium * medium G_GNUC_UNUSED,IMedium * target G_GNUC_UNUSED,PRUint32 variantSize G_GNUC_UNUSED,PRUint32 * variant G_GNUC_UNUSED,IProgress ** progress G_GNUC_UNUSED)1825 _mediumCreateDiffStorage(IMedium *medium G_GNUC_UNUSED,
1826 IMedium *target G_GNUC_UNUSED,
1827 PRUint32 variantSize G_GNUC_UNUSED,
1828 PRUint32 *variant G_GNUC_UNUSED,
1829 IProgress **progress G_GNUC_UNUSED)
1830 {
1831 return medium->vtbl->CreateDiffStorage(medium, target, variantSize, variant, progress);
1832 }
1833
1834 static nsresult
_mediumCreateBaseStorage(IMedium * medium,PRUint64 logicalSize,PRUint32 variant,IProgress ** progress)1835 _mediumCreateBaseStorage(IMedium *medium, PRUint64 logicalSize,
1836 PRUint32 variant, IProgress **progress)
1837 {
1838 return medium->vtbl->CreateBaseStorage(medium, logicalSize, 1, &variant, progress);
1839 }
1840
1841 static nsresult
_mediumGetLogicalSize(IMedium * medium,PRUint64 * uLogicalSize)1842 _mediumGetLogicalSize(IMedium *medium, PRUint64 *uLogicalSize)
1843 {
1844 nsresult rc;
1845 PRInt64 logicalSize;
1846
1847 rc = medium->vtbl->GetLogicalSize(medium, &logicalSize);
1848 *uLogicalSize = logicalSize;
1849
1850 return rc;
1851 }
1852
1853 static nsresult
_mediumAttachmentGetMedium(IMediumAttachment * mediumAttachment,IMedium ** medium)1854 _mediumAttachmentGetMedium(IMediumAttachment *mediumAttachment,
1855 IMedium **medium)
1856 {
1857 return mediumAttachment->vtbl->GetMedium(mediumAttachment, medium);
1858 }
1859
1860 static nsresult
_mediumAttachmentGetController(IMediumAttachment * mediumAttachment,PRUnichar ** controller)1861 _mediumAttachmentGetController(IMediumAttachment *mediumAttachment,
1862 PRUnichar **controller)
1863 {
1864 return mediumAttachment->vtbl->GetController(mediumAttachment, controller);
1865 }
1866
1867 static nsresult
_mediumAttachmentGetType(IMediumAttachment * mediumAttachment G_GNUC_UNUSED,PRUint32 * type G_GNUC_UNUSED)1868 _mediumAttachmentGetType(IMediumAttachment *mediumAttachment G_GNUC_UNUSED,
1869 PRUint32 *type G_GNUC_UNUSED)
1870 {
1871 return mediumAttachment->vtbl->GetType(mediumAttachment, type);
1872 }
1873
1874 static nsresult
_mediumAttachmentGetPort(IMediumAttachment * mediumAttachment,PRInt32 * port)1875 _mediumAttachmentGetPort(IMediumAttachment *mediumAttachment, PRInt32 *port)
1876 {
1877 return mediumAttachment->vtbl->GetPort(mediumAttachment, port);
1878 }
1879
1880 static nsresult
_mediumAttachmentGetDevice(IMediumAttachment * mediumAttachment,PRInt32 * device)1881 _mediumAttachmentGetDevice(IMediumAttachment *mediumAttachment, PRInt32 *device)
1882 {
1883 return mediumAttachment->vtbl->GetDevice(mediumAttachment, device);
1884 }
1885
1886 static nsresult
_storageControllerGetBus(IStorageController * storageController,PRUint32 * bus)1887 _storageControllerGetBus(IStorageController *storageController, PRUint32 *bus)
1888 {
1889 return storageController->vtbl->GetBus(storageController, bus);
1890 }
1891
1892 static nsresult
_storageControllerGetControllerType(IStorageController * storageController,PRUint32 * controllerType)1893 _storageControllerGetControllerType(IStorageController *storageController, PRUint32 *controllerType)
1894 {
1895 return storageController->vtbl->GetControllerType(storageController, controllerType);
1896 }
1897
1898 static nsresult
_storageControllerSetControllerType(IStorageController * storageController,PRUint32 controllerType)1899 _storageControllerSetControllerType(IStorageController *storageController, PRUint32 controllerType)
1900 {
1901 return storageController->vtbl->SetControllerType(storageController, controllerType);
1902 }
1903
1904 static nsresult
_sharedFolderGetHostPath(ISharedFolder * sharedFolder,PRUnichar ** hostPath)1905 _sharedFolderGetHostPath(ISharedFolder *sharedFolder, PRUnichar **hostPath)
1906 {
1907 return sharedFolder->vtbl->GetHostPath(sharedFolder, hostPath);
1908 }
1909
1910 static nsresult
_sharedFolderGetName(ISharedFolder * sharedFolder,PRUnichar ** name)1911 _sharedFolderGetName(ISharedFolder *sharedFolder, PRUnichar **name)
1912 {
1913 return sharedFolder->vtbl->GetName(sharedFolder, name);
1914 }
1915
1916 static nsresult
_sharedFolderGetWritable(ISharedFolder * sharedFolder,PRBool * writable)1917 _sharedFolderGetWritable(ISharedFolder *sharedFolder, PRBool *writable)
1918 {
1919 return sharedFolder->vtbl->GetWritable(sharedFolder, writable);
1920 }
1921
1922 static nsresult
_snapshotGetName(ISnapshot * snapshot,PRUnichar ** name)1923 _snapshotGetName(ISnapshot *snapshot, PRUnichar **name)
1924 {
1925 return snapshot->vtbl->GetName(snapshot, name);
1926 }
1927
1928 static nsresult
_snapshotGetId(ISnapshot * snapshot,vboxIID * iid)1929 _snapshotGetId(ISnapshot *snapshot, vboxIID *iid)
1930 {
1931 return snapshot->vtbl->GetId(snapshot, &iid->value);
1932 }
1933
1934 static nsresult
_snapshotGetMachine(ISnapshot * snapshot,IMachine ** machine)1935 _snapshotGetMachine(ISnapshot *snapshot, IMachine **machine)
1936 {
1937 return snapshot->vtbl->GetMachine(snapshot, machine);
1938 }
1939
1940 static nsresult
_snapshotGetDescription(ISnapshot * snapshot,PRUnichar ** description)1941 _snapshotGetDescription(ISnapshot *snapshot, PRUnichar **description)
1942 {
1943 return snapshot->vtbl->GetDescription(snapshot, description);
1944 }
1945
1946 static nsresult
_snapshotGetTimeStamp(ISnapshot * snapshot,PRInt64 * timeStamp)1947 _snapshotGetTimeStamp(ISnapshot *snapshot, PRInt64 *timeStamp)
1948 {
1949 return snapshot->vtbl->GetTimeStamp(snapshot, timeStamp);
1950 }
1951
1952 static nsresult
_snapshotGetParent(ISnapshot * snapshot,ISnapshot ** parent)1953 _snapshotGetParent(ISnapshot *snapshot, ISnapshot **parent)
1954 {
1955 return snapshot->vtbl->GetParent(snapshot, parent);
1956 }
1957
1958 static nsresult
_snapshotGetOnline(ISnapshot * snapshot,PRBool * online)1959 _snapshotGetOnline(ISnapshot *snapshot, PRBool *online)
1960 {
1961 return snapshot->vtbl->GetOnline(snapshot, online);
1962 }
1963
1964 static nsresult
_displayGetScreenResolution(IDisplay * display G_GNUC_UNUSED,PRUint32 screenId G_GNUC_UNUSED,PRUint32 * width G_GNUC_UNUSED,PRUint32 * height G_GNUC_UNUSED,PRUint32 * bitsPerPixel G_GNUC_UNUSED,PRInt32 * xOrigin G_GNUC_UNUSED,PRInt32 * yOrigin G_GNUC_UNUSED)1965 _displayGetScreenResolution(IDisplay *display G_GNUC_UNUSED,
1966 PRUint32 screenId G_GNUC_UNUSED,
1967 PRUint32 *width G_GNUC_UNUSED,
1968 PRUint32 *height G_GNUC_UNUSED,
1969 PRUint32 *bitsPerPixel G_GNUC_UNUSED,
1970 PRInt32 *xOrigin G_GNUC_UNUSED,
1971 PRInt32 *yOrigin G_GNUC_UNUSED)
1972 {
1973 PRUint32 gms;
1974
1975 return display->vtbl->GetScreenResolution(display, screenId, width,
1976 height, bitsPerPixel,
1977 xOrigin, yOrigin, &gms);
1978 }
1979
1980 static nsresult
_displayTakeScreenShotPNGToArray(IDisplay * display,PRUint32 screenId,PRUint32 width,PRUint32 height,PRUint32 * screenDataSize,PRUint8 ** screenData)1981 _displayTakeScreenShotPNGToArray(IDisplay *display, PRUint32 screenId,
1982 PRUint32 width, PRUint32 height,
1983 PRUint32 *screenDataSize,
1984 PRUint8** screenData)
1985 {
1986 return display->vtbl->TakeScreenShotToArray(display, screenId, width,
1987 height, BitmapFormat_PNG,
1988 screenDataSize, screenData);
1989 }
1990
1991 static nsresult
_hostFindHostNetworkInterfaceById(IHost * host,vboxIID * iid,IHostNetworkInterface ** networkInterface)1992 _hostFindHostNetworkInterfaceById(IHost *host, vboxIID *iid,
1993 IHostNetworkInterface **networkInterface)
1994 {
1995 return host->vtbl->FindHostNetworkInterfaceById(host, iid->value,
1996 networkInterface);
1997 }
1998
1999 static nsresult
_hostFindHostNetworkInterfaceByName(IHost * host,PRUnichar * name,IHostNetworkInterface ** networkInterface)2000 _hostFindHostNetworkInterfaceByName(IHost *host, PRUnichar *name,
2001 IHostNetworkInterface **networkInterface)
2002 {
2003 return host->vtbl->FindHostNetworkInterfaceByName(host, name,
2004 networkInterface);
2005 }
2006
2007 static nsresult
_hostCreateHostOnlyNetworkInterface(struct _vboxDriver * data G_GNUC_UNUSED,IHost * host,char * name G_GNUC_UNUSED,IHostNetworkInterface ** networkInterface)2008 _hostCreateHostOnlyNetworkInterface(struct _vboxDriver *data G_GNUC_UNUSED,
2009 IHost *host, char *name G_GNUC_UNUSED,
2010 IHostNetworkInterface **networkInterface)
2011 {
2012 nsresult rc = -1;
2013 IProgress *progress = NULL;
2014
2015 host->vtbl->CreateHostOnlyNetworkInterface(host, networkInterface,
2016 &progress);
2017
2018 if (progress) {
2019 rc = progress->vtbl->WaitForCompletion(progress, -1);
2020 VBOX_RELEASE(progress);
2021 }
2022
2023 return rc;
2024 }
2025
2026 static nsresult
_hostRemoveHostOnlyNetworkInterface(IHost * host G_GNUC_UNUSED,vboxIID * iid G_GNUC_UNUSED,IProgress ** progress G_GNUC_UNUSED)2027 _hostRemoveHostOnlyNetworkInterface(IHost *host G_GNUC_UNUSED,
2028 vboxIID *iid G_GNUC_UNUSED,
2029 IProgress **progress G_GNUC_UNUSED)
2030 {
2031 return host->vtbl->RemoveHostOnlyNetworkInterface(host, iid->value, progress);
2032 }
2033
2034 static nsresult
_hnInterfaceGetInterfaceType(IHostNetworkInterface * hni,PRUint32 * interfaceType)2035 _hnInterfaceGetInterfaceType(IHostNetworkInterface *hni, PRUint32 *interfaceType)
2036 {
2037 return hni->vtbl->GetInterfaceType(hni, interfaceType);
2038 }
2039
2040 static nsresult
_hnInterfaceGetStatus(IHostNetworkInterface * hni,PRUint32 * status)2041 _hnInterfaceGetStatus(IHostNetworkInterface *hni, PRUint32 *status)
2042 {
2043 return hni->vtbl->GetStatus(hni, status);
2044 }
2045
2046 static nsresult
_hnInterfaceGetName(IHostNetworkInterface * hni,PRUnichar ** name)2047 _hnInterfaceGetName(IHostNetworkInterface *hni, PRUnichar **name)
2048 {
2049 return hni->vtbl->GetName(hni, name);
2050 }
2051
2052 static nsresult
_hnInterfaceGetId(IHostNetworkInterface * hni,vboxIID * iid)2053 _hnInterfaceGetId(IHostNetworkInterface *hni, vboxIID *iid)
2054 {
2055 return hni->vtbl->GetId(hni, &iid->value);
2056 }
2057
2058 static nsresult
_hnInterfaceGetHardwareAddress(IHostNetworkInterface * hni,PRUnichar ** hardwareAddress)2059 _hnInterfaceGetHardwareAddress(IHostNetworkInterface *hni, PRUnichar **hardwareAddress)
2060 {
2061 return hni->vtbl->GetHardwareAddress(hni, hardwareAddress);
2062 }
2063
2064 static nsresult
_hnInterfaceGetIPAddress(IHostNetworkInterface * hni,PRUnichar ** IPAddress)2065 _hnInterfaceGetIPAddress(IHostNetworkInterface *hni, PRUnichar **IPAddress)
2066 {
2067 return hni->vtbl->GetIPAddress(hni, IPAddress);
2068 }
2069
2070 static nsresult
_hnInterfaceGetNetworkMask(IHostNetworkInterface * hni,PRUnichar ** networkMask)2071 _hnInterfaceGetNetworkMask(IHostNetworkInterface *hni, PRUnichar **networkMask)
2072 {
2073 return hni->vtbl->GetNetworkMask(hni, networkMask);
2074 }
2075
2076 static nsresult
_hnInterfaceEnableStaticIPConfig(IHostNetworkInterface * hni,PRUnichar * IPAddress,PRUnichar * networkMask)2077 _hnInterfaceEnableStaticIPConfig(IHostNetworkInterface *hni, PRUnichar *IPAddress,
2078 PRUnichar *networkMask)
2079 {
2080 return hni->vtbl->EnableStaticIPConfig(hni, IPAddress, networkMask);
2081 }
2082
2083 static nsresult
_hnInterfaceEnableDynamicIPConfig(IHostNetworkInterface * hni)2084 _hnInterfaceEnableDynamicIPConfig(IHostNetworkInterface *hni)
2085 {
2086 return hni->vtbl->EnableDynamicIPConfig(hni);
2087 }
2088
2089 static nsresult
_hnInterfaceDHCPRediscover(IHostNetworkInterface * hni)2090 _hnInterfaceDHCPRediscover(IHostNetworkInterface *hni)
2091 {
2092 return hni->vtbl->DHCPRediscover(hni);
2093 }
2094
2095 static nsresult
_dhcpServerGetIPAddress(IDHCPServer * dhcpServer,PRUnichar ** IPAddress)2096 _dhcpServerGetIPAddress(IDHCPServer *dhcpServer, PRUnichar **IPAddress)
2097 {
2098 return dhcpServer->vtbl->GetIPAddress(dhcpServer, IPAddress);
2099 }
2100
2101 static nsresult
_dhcpServerGetNetworkMask(IDHCPServer * dhcpServer,PRUnichar ** networkMask)2102 _dhcpServerGetNetworkMask(IDHCPServer *dhcpServer, PRUnichar **networkMask)
2103 {
2104 return dhcpServer->vtbl->GetNetworkMask(dhcpServer, networkMask);
2105 }
2106
2107 static nsresult
_dhcpServerGetLowerIP(IDHCPServer * dhcpServer,PRUnichar ** lowerIP)2108 _dhcpServerGetLowerIP(IDHCPServer *dhcpServer, PRUnichar **lowerIP)
2109 {
2110 return dhcpServer->vtbl->GetLowerIP(dhcpServer, lowerIP);
2111 }
2112
2113 static nsresult
_dhcpServerGetUpperIP(IDHCPServer * dhcpServer,PRUnichar ** upperIP)2114 _dhcpServerGetUpperIP(IDHCPServer *dhcpServer, PRUnichar **upperIP)
2115 {
2116 return dhcpServer->vtbl->GetUpperIP(dhcpServer, upperIP);
2117 }
2118
2119 static nsresult
_dhcpServerSetEnabled(IDHCPServer * dhcpServer,PRBool enabled)2120 _dhcpServerSetEnabled(IDHCPServer *dhcpServer, PRBool enabled)
2121 {
2122 return dhcpServer->vtbl->SetEnabled(dhcpServer, enabled);
2123 }
2124
2125 static nsresult
_dhcpServerSetConfiguration(IDHCPServer * dhcpServer,PRUnichar * IPAddress,PRUnichar * networkMask,PRUnichar * FromIPAddress,PRUnichar * ToIPAddress)2126 _dhcpServerSetConfiguration(IDHCPServer *dhcpServer, PRUnichar *IPAddress,
2127 PRUnichar *networkMask, PRUnichar *FromIPAddress,
2128 PRUnichar *ToIPAddress)
2129 {
2130 return dhcpServer->vtbl->SetConfiguration(dhcpServer, IPAddress,
2131 networkMask, FromIPAddress,
2132 ToIPAddress);
2133 }
2134
2135 static nsresult
_dhcpServerStart(IDHCPServer * dhcpServer,PRUnichar * networkName G_GNUC_UNUSED,PRUnichar * trunkName,PRUnichar * trunkType)2136 _dhcpServerStart(IDHCPServer *dhcpServer, PRUnichar *networkName G_GNUC_UNUSED,
2137 PRUnichar *trunkName, PRUnichar *trunkType)
2138 {
2139 #if VBOX_API_VERSION >= 6001000
2140 return dhcpServer->vtbl->Start(dhcpServer,
2141 trunkName, trunkType);
2142 #else
2143 return dhcpServer->vtbl->Start(dhcpServer, networkName,
2144 trunkName, trunkType);
2145 #endif
2146 }
2147
2148 static nsresult
_dhcpServerStop(IDHCPServer * dhcpServer)2149 _dhcpServerStop(IDHCPServer *dhcpServer)
2150 {
2151 return dhcpServer->vtbl->Stop(dhcpServer);
2152 }
2153
2154 static nsresult
_keyboardPutScancode(IKeyboard * keyboard,PRInt32 scancode)2155 _keyboardPutScancode(IKeyboard *keyboard, PRInt32 scancode)
2156 {
2157 return keyboard->vtbl->PutScancode(keyboard, scancode);
2158 }
2159
2160 static nsresult
_keyboardPutScancodes(IKeyboard * keyboard,PRUint32 scancodesSize,PRInt32 * scanCodes,PRUint32 * codesStored)2161 _keyboardPutScancodes(IKeyboard *keyboard, PRUint32 scancodesSize,
2162 PRInt32 *scanCodes, PRUint32 *codesStored)
2163 {
2164 return keyboard->vtbl->PutScancodes(keyboard, scancodesSize, scanCodes,
2165 codesStored);
2166 }
2167
_machineStateOnline(PRUint32 state)2168 static bool _machineStateOnline(PRUint32 state)
2169 {
2170 return ((state >= MachineState_FirstOnline) &&
2171 (state <= MachineState_LastOnline));
2172 }
2173
_machineStateInactive(PRUint32 state)2174 static bool _machineStateInactive(PRUint32 state)
2175 {
2176 return ((state < MachineState_FirstOnline) ||
2177 (state > MachineState_LastOnline));
2178 }
2179
_machineStateNotStart(PRUint32 state)2180 static bool _machineStateNotStart(PRUint32 state)
2181 {
2182 return ((state == MachineState_PoweredOff) ||
2183 (state == MachineState_Saved) ||
2184 (state == MachineState_Aborted));
2185 }
2186
_machineStateRunning(PRUint32 state)2187 static bool _machineStateRunning(PRUint32 state)
2188 {
2189 return state == MachineState_Running;
2190 }
2191
_machineStatePaused(PRUint32 state)2192 static bool _machineStatePaused(PRUint32 state)
2193 {
2194 return state == MachineState_Paused;
2195 }
2196
_machineStatePoweredOff(PRUint32 state)2197 static bool _machineStatePoweredOff(PRUint32 state)
2198 {
2199 return state == MachineState_PoweredOff;
2200 }
2201
2202 static vboxUniformedPFN _UPFN = {
2203 .Initialize = _pfnInitialize,
2204 .Uninitialize = _pfnUninitialize,
2205 .ComUnallocMem = _pfnComUnallocMem,
2206 .Utf16Free = _pfnUtf16Free,
2207 .Utf8Free = _pfnUtf8Free,
2208 .Utf16ToUtf8 = _pfnUtf16ToUtf8,
2209 .Utf8ToUtf16 = _pfnUtf8ToUtf16,
2210 };
2211
2212 static vboxUniformedIID _UIID = {
2213 .vboxIIDInitialize = _vboxIIDInitialize,
2214 .vboxIIDUnalloc = _vboxIIDUnalloc,
2215 .vboxIIDToUUID = _vboxIIDToUUID,
2216 .vboxIIDFromUUID = _vboxIIDFromUUID,
2217 .vboxIIDIsEqual = _vboxIIDIsEqual,
2218 .vboxIIDFromArrayItem = _vboxIIDFromArrayItem,
2219 .vboxIIDToUtf8 = _vboxIIDToUtf8,
2220 .DEBUGIID = _DEBUGIID,
2221 };
2222
2223 static vboxUniformedArray _UArray = {
2224 .vboxArrayGet = vboxArrayGet,
2225 .vboxArrayGetWithIIDArg = _vboxArrayGetWithIIDArg,
2226 .vboxArrayRelease = vboxArrayRelease,
2227 .vboxArrayUnalloc = vboxArrayUnalloc,
2228 .handleGetMachines = _handleGetMachines,
2229 .handleGetHardDisks = _handleGetHardDisks,
2230 .handleUSBGetDeviceFilters = _handleUSBGetDeviceFilters,
2231 .handleMachineGetStorageControllers = _handleMachineGetStorageControllers,
2232 .handleMachineGetMediumAttachments = _handleMachineGetMediumAttachments,
2233 .handleMachineGetSharedFolders = _handleMachineGetSharedFolders,
2234 .handleSnapshotGetChildren = _handleSnapshotGetChildren,
2235 .handleMediumGetChildren = _handleMediumGetChildren,
2236 .handleMediumGetSnapshotIds = _handleMediumGetSnapshotIds,
2237 .handleMediumGetMachineIds = _handleMediumGetMachineIds,
2238 .handleHostGetNetworkInterfaces = _handleHostGetNetworkInterfaces,
2239 };
2240
2241 static vboxUniformednsISupports _nsUISupports = {
2242 .Release = _nsisupportsRelease,
2243 .AddRef = _nsisupportsAddRef,
2244 };
2245
2246 static vboxUniformedIVirtualBox _UIVirtualBox = {
2247 .GetVersion = _virtualboxGetVersion,
2248 .GetMachine = _virtualboxGetMachine,
2249 .OpenMachine = _virtualboxOpenMachine,
2250 .GetSystemProperties = _virtualboxGetSystemProperties,
2251 .GetHost = _virtualboxGetHost,
2252 .CreateMachine = _virtualboxCreateMachine,
2253 .CreateHardDisk = _virtualboxCreateHardDisk,
2254 .RegisterMachine = _virtualboxRegisterMachine,
2255 .FindHardDisk = _virtualboxFindHardDisk,
2256 .OpenMedium = _virtualboxOpenMedium,
2257 .GetHardDiskByIID = _virtualboxGetHardDiskByIID,
2258 .FindDHCPServerByNetworkName = _virtualboxFindDHCPServerByNetworkName,
2259 .CreateDHCPServer = _virtualboxCreateDHCPServer,
2260 .RemoveDHCPServer = _virtualboxRemoveDHCPServer,
2261 };
2262
2263 static vboxUniformedIMachine _UIMachine = {
2264 .AddStorageController = _machineAddStorageController,
2265 .GetStorageControllerByName = _machineGetStorageControllerByName,
2266 .AttachDevice = _machineAttachDevice,
2267 .CreateSharedFolder = _machineCreateSharedFolder,
2268 .RemoveSharedFolder = _machineRemoveSharedFolder,
2269 .LaunchVMProcess = _machineLaunchVMProcess,
2270 .Unregister = _machineUnregister,
2271 .FindSnapshot = _machineFindSnapshot,
2272 .DetachDevice = _machineDetachDevice,
2273 .GetAccessible = _machineGetAccessible,
2274 .GetState = _machineGetState,
2275 .GetName = _machineGetName,
2276 .GetId = _machineGetId,
2277 .GetBIOSSettings = _machineGetBIOSSettings,
2278 .GetAudioAdapter = _machineGetAudioAdapter,
2279 .GetNetworkAdapter = _machineGetNetworkAdapter,
2280 .GetChipsetType = _machineGetChipsetType,
2281 .GetSerialPort = _machineGetSerialPort,
2282 .GetParallelPort = _machineGetParallelPort,
2283 .GetVRDEServer = _machineGetVRDEServer,
2284 .GetUSBCommon = _machineGetUSBCommon,
2285 .GetCurrentSnapshot = _machineGetCurrentSnapshot,
2286 .GetSettingsFilePath = _machineGetSettingsFilePath,
2287 .GetCPUCount = _machineGetCPUCount,
2288 .SetCPUCount = _machineSetCPUCount,
2289 .GetMemorySize = _machineGetMemorySize,
2290 .SetMemorySize = _machineSetMemorySize,
2291 .GetCPUProperty = _machineGetCPUProperty,
2292 .SetCPUProperty = _machineSetCPUProperty,
2293 .GetBootOrder = _machineGetBootOrder,
2294 .SetBootOrder = _machineSetBootOrder,
2295 .GetVRAMSize = _machineGetVRAMSize,
2296 .SetVRAMSize = _machineSetVRAMSize,
2297 .GetMonitorCount = _machineGetMonitorCount,
2298 .SetMonitorCount = _machineSetMonitorCount,
2299 .GetAccelerate3DEnabled = _machineGetAccelerate3DEnabled,
2300 .SetAccelerate3DEnabled = _machineSetAccelerate3DEnabled,
2301 .GetAccelerate2DVideoEnabled = _machineGetAccelerate2DVideoEnabled,
2302 .SetAccelerate2DVideoEnabled = _machineSetAccelerate2DVideoEnabled,
2303 .GetExtraData = _machineGetExtraData,
2304 .SetExtraData = _machineSetExtraData,
2305 .GetSnapshotCount = _machineGetSnapshotCount,
2306 .SaveSettings = _machineSaveSettings,
2307 };
2308
2309 static vboxUniformedISession _UISession = {
2310 .Open = _sessionOpen,
2311 .OpenExisting = _sessionOpenExisting,
2312 .GetConsole = _sessionGetConsole,
2313 .GetMachine = _sessionGetMachine,
2314 .Close = _sessionClose,
2315 };
2316
2317 static vboxUniformedIConsole _UIConsole = {
2318 .SaveState = _consoleSaveState,
2319 .Pause = _consolePause,
2320 .Resume = _consoleResume,
2321 .PowerButton = _consolePowerButton,
2322 .PowerDown = _consolePowerDown,
2323 .Reset = _consoleReset,
2324 .TakeSnapshot = _consoleTakeSnapshot,
2325 .DeleteSnapshot = _consoleDeleteSnapshot,
2326 .GetDisplay = _consoleGetDisplay,
2327 .GetKeyboard = _consoleGetKeyboard,
2328 };
2329
2330 static vboxUniformedIProgress _UIProgress = {
2331 .WaitForCompletion = _progressWaitForCompletion,
2332 .GetResultCode = _progressGetResultCode,
2333 .GetCompleted = _progressGetCompleted,
2334 };
2335
2336 static vboxUniformedISystemProperties _UISystemProperties = {
2337 .GetMaxGuestCPUCount = _systemPropertiesGetMaxGuestCPUCount,
2338 .GetMaxBootPosition = _systemPropertiesGetMaxBootPosition,
2339 .GetMaxNetworkAdapters = _systemPropertiesGetMaxNetworkAdapters,
2340 .GetSerialPortCount = _systemPropertiesGetSerialPortCount,
2341 .GetParallelPortCount = _systemPropertiesGetParallelPortCount,
2342 .GetMaxPortCountForStorageBus = _systemPropertiesGetMaxPortCountForStorageBus,
2343 .GetMaxDevicesPerPortForStorageBus = _systemPropertiesGetMaxDevicesPerPortForStorageBus,
2344 .GetMaxGuestRAM = _systemPropertiesGetMaxGuestRAM,
2345 };
2346
2347 static vboxUniformedIBIOSSettings _UIBIOSSettings = {
2348 .GetACPIEnabled = _biosSettingsGetACPIEnabled,
2349 .SetACPIEnabled = _biosSettingsSetACPIEnabled,
2350 .GetIOAPICEnabled = _biosSettingsGetIOAPICEnabled,
2351 .SetIOAPICEnabled = _biosSettingsSetIOAPICEnabled,
2352 };
2353
2354 static vboxUniformedIAudioAdapter _UIAudioAdapter = {
2355 .GetEnabled = _audioAdapterGetEnabled,
2356 .SetEnabled = _audioAdapterSetEnabled,
2357 .GetAudioController = _audioAdapterGetAudioController,
2358 .SetAudioController = _audioAdapterSetAudioController,
2359 };
2360
2361 static vboxUniformedINetworkAdapter _UINetworkAdapter = {
2362 .GetAttachmentType = _networkAdapterGetAttachmentType,
2363 .GetEnabled = _networkAdapterGetEnabled,
2364 .SetEnabled = _networkAdapterSetEnabled,
2365 .GetAdapterType = _networkAdapterGetAdapterType,
2366 .SetAdapterType = _networkAdapterSetAdapterType,
2367 .GetBridgedInterface = _networkAdapterGetBridgedInterface,
2368 .SetBridgedInterface = _networkAdapterSetBridgedInterface,
2369 .GetInternalNetwork = _networkAdapterGetInternalNetwork,
2370 .SetInternalNetwork = _networkAdapterSetInternalNetwork,
2371 .GetHostOnlyInterface = _networkAdapterGetHostOnlyInterface,
2372 .SetHostOnlyInterface = _networkAdapterSetHostOnlyInterface,
2373 .GetMACAddress = _networkAdapterGetMACAddress,
2374 .SetMACAddress = _networkAdapterSetMACAddress,
2375 .AttachToBridgedInterface = _networkAdapterAttachToBridgedInterface,
2376 .AttachToInternalNetwork = _networkAdapterAttachToInternalNetwork,
2377 .AttachToHostOnlyInterface = _networkAdapterAttachToHostOnlyInterface,
2378 .AttachToNAT = _networkAdapterAttachToNAT,
2379 };
2380
2381 static vboxUniformedISerialPort _UISerialPort = {
2382 .GetEnabled = _serialPortGetEnabled,
2383 .SetEnabled = _serialPortSetEnabled,
2384 .GetPath = _serialPortGetPath,
2385 .SetPath = _serialPortSetPath,
2386 .GetIRQ = _serialPortGetIRQ,
2387 .SetIRQ = _serialPortSetIRQ,
2388 .GetIOBase = _serialPortGetIOBase,
2389 .SetIOBase = _serialPortSetIOBase,
2390 .GetHostMode = _serialPortGetHostMode,
2391 .SetHostMode = _serialPortSetHostMode,
2392 };
2393
2394 static vboxUniformedIParallelPort _UIParallelPort = {
2395 .GetEnabled = _parallelPortGetEnabled,
2396 .SetEnabled = _parallelPortSetEnabled,
2397 .GetPath = _parallelPortGetPath,
2398 .SetPath = _parallelPortSetPath,
2399 .GetIRQ = _parallelPortGetIRQ,
2400 .SetIRQ = _parallelPortSetIRQ,
2401 .GetIOBase = _parallelPortGetIOBase,
2402 .SetIOBase = _parallelPortSetIOBase,
2403 };
2404
2405 static vboxUniformedIVRDEServer _UIVRDEServer = {
2406 .GetEnabled = _vrdeServerGetEnabled,
2407 .SetEnabled = _vrdeServerSetEnabled,
2408 .GetPorts = _vrdeServerGetPorts,
2409 .SetPorts = _vrdeServerSetPorts,
2410 .GetReuseSingleConnection = _vrdeServerGetReuseSingleConnection,
2411 .SetReuseSingleConnection = _vrdeServerSetReuseSingleConnection,
2412 .GetAllowMultiConnection = _vrdeServerGetAllowMultiConnection,
2413 .SetAllowMultiConnection = _vrdeServerSetAllowMultiConnection,
2414 .GetNetAddress = _vrdeServerGetNetAddress,
2415 .SetNetAddress = _vrdeServerSetNetAddress,
2416 };
2417
2418 static vboxUniformedIUSBCommon _UIUSBCommon = {
2419 .Enable = _usbCommonEnable,
2420 .GetEnabled = _usbCommonGetEnabled,
2421 .CreateDeviceFilter = _usbCommonCreateDeviceFilter,
2422 .InsertDeviceFilter = _usbCommonInsertDeviceFilter,
2423 };
2424
2425 static vboxUniformedIUSBDeviceFilter _UIUSBDeviceFilter = {
2426 .GetProductId = _usbDeviceFilterGetProductId,
2427 .SetProductId = _usbDeviceFilterSetProductId,
2428 .GetActive = _usbDeviceFilterGetActive,
2429 .SetActive = _usbDeviceFilterSetActive,
2430 .GetVendorId = _usbDeviceFilterGetVendorId,
2431 .SetVendorId = _usbDeviceFilterSetVendorId,
2432 };
2433
2434 static vboxUniformedIMedium _UIMedium = {
2435 .GetId = _mediumGetId,
2436 .GetLocation = _mediumGetLocation,
2437 .GetState = _mediumGetState,
2438 .GetName = _mediumGetName,
2439 .GetSize = _mediumGetSize,
2440 .GetReadOnly = _mediumGetReadOnly,
2441 .GetParent = _mediumGetParent,
2442 .GetChildren = _mediumGetChildren,
2443 .GetFormat = _mediumGetFormat,
2444 .DeleteStorage = _mediumDeleteStorage,
2445 .Release = _mediumRelease,
2446 .Close = _mediumClose,
2447 .SetType = _mediumSetType,
2448 .CreateDiffStorage = _mediumCreateDiffStorage,
2449 .CreateBaseStorage = _mediumCreateBaseStorage,
2450 .GetLogicalSize = _mediumGetLogicalSize,
2451 };
2452
2453 static vboxUniformedIMediumAttachment _UIMediumAttachment = {
2454 .GetMedium = _mediumAttachmentGetMedium,
2455 .GetController = _mediumAttachmentGetController,
2456 .GetType = _mediumAttachmentGetType,
2457 .GetPort = _mediumAttachmentGetPort,
2458 .GetDevice = _mediumAttachmentGetDevice,
2459 };
2460
2461 static vboxUniformedIStorageController _UIStorageController = {
2462 .GetBus = _storageControllerGetBus,
2463 .GetControllerType = _storageControllerGetControllerType,
2464 .SetControllerType = _storageControllerSetControllerType,
2465 };
2466
2467 static vboxUniformedISharedFolder _UISharedFolder = {
2468 .GetHostPath = _sharedFolderGetHostPath,
2469 .GetName = _sharedFolderGetName,
2470 .GetWritable = _sharedFolderGetWritable,
2471 };
2472
2473 static vboxUniformedISnapshot _UISnapshot = {
2474 .GetName = _snapshotGetName,
2475 .GetId = _snapshotGetId,
2476 .GetMachine = _snapshotGetMachine,
2477 .GetDescription = _snapshotGetDescription,
2478 .GetTimeStamp = _snapshotGetTimeStamp,
2479 .GetParent = _snapshotGetParent,
2480 .GetOnline = _snapshotGetOnline,
2481 };
2482
2483 static vboxUniformedIDisplay _UIDisplay = {
2484 .GetScreenResolution = _displayGetScreenResolution,
2485 .TakeScreenShotPNGToArray = _displayTakeScreenShotPNGToArray,
2486 };
2487
2488 static vboxUniformedIHost _UIHost = {
2489 .FindHostNetworkInterfaceById = _hostFindHostNetworkInterfaceById,
2490 .FindHostNetworkInterfaceByName = _hostFindHostNetworkInterfaceByName,
2491 .CreateHostOnlyNetworkInterface = _hostCreateHostOnlyNetworkInterface,
2492 .RemoveHostOnlyNetworkInterface = _hostRemoveHostOnlyNetworkInterface,
2493 };
2494
2495 static vboxUniformedIHNInterface _UIHNInterface = {
2496 .GetInterfaceType = _hnInterfaceGetInterfaceType,
2497 .GetStatus = _hnInterfaceGetStatus,
2498 .GetName = _hnInterfaceGetName,
2499 .GetId = _hnInterfaceGetId,
2500 .GetHardwareAddress = _hnInterfaceGetHardwareAddress,
2501 .GetIPAddress = _hnInterfaceGetIPAddress,
2502 .GetNetworkMask = _hnInterfaceGetNetworkMask,
2503 .EnableStaticIPConfig = _hnInterfaceEnableStaticIPConfig,
2504 .EnableDynamicIPConfig = _hnInterfaceEnableDynamicIPConfig,
2505 .DHCPRediscover = _hnInterfaceDHCPRediscover,
2506 };
2507
2508 static vboxUniformedIDHCPServer _UIDHCPServer = {
2509 .GetIPAddress = _dhcpServerGetIPAddress,
2510 .GetNetworkMask = _dhcpServerGetNetworkMask,
2511 .GetLowerIP = _dhcpServerGetLowerIP,
2512 .GetUpperIP = _dhcpServerGetUpperIP,
2513 .SetEnabled = _dhcpServerSetEnabled,
2514 .SetConfiguration = _dhcpServerSetConfiguration,
2515 .Start = _dhcpServerStart,
2516 .Stop = _dhcpServerStop,
2517 };
2518
2519 static vboxUniformedIKeyboard _UIKeyboard = {
2520 .PutScancode = _keyboardPutScancode,
2521 .PutScancodes = _keyboardPutScancodes,
2522 };
2523
2524 static uniformedMachineStateChecker _machineStateChecker = {
2525 .Online = _machineStateOnline,
2526 .Inactive = _machineStateInactive,
2527 .NotStart = _machineStateNotStart,
2528 .Running = _machineStateRunning,
2529 .Paused = _machineStatePaused,
2530 .PoweredOff = _machineStatePoweredOff,
2531 };
2532
NAME(InstallUniformedAPI)2533 void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
2534 {
2535 pVBoxAPI->APIVersion = VBOX_API_VERSION;
2536 pVBoxAPI->XPCOMCVersion = VBOX_XPCOMC_VERSION;
2537 pVBoxAPI->unregisterMachine = _unregisterMachine;
2538 pVBoxAPI->deleteConfig = _deleteConfig;
2539 pVBoxAPI->vboxConvertState = _vboxConvertState;
2540 pVBoxAPI->snapshotRestore = _vboxDomainSnapshotRestore;
2541 pVBoxAPI->UPFN = _UPFN;
2542 pVBoxAPI->UIID = _UIID;
2543 pVBoxAPI->UArray = _UArray;
2544 pVBoxAPI->nsUISupports = _nsUISupports;
2545 pVBoxAPI->UIVirtualBox = _UIVirtualBox;
2546 pVBoxAPI->UIMachine = _UIMachine;
2547 pVBoxAPI->UISession = _UISession;
2548 pVBoxAPI->UIConsole = _UIConsole;
2549 pVBoxAPI->UIProgress = _UIProgress;
2550 pVBoxAPI->UISystemProperties = _UISystemProperties;
2551 pVBoxAPI->UIBIOSSettings = _UIBIOSSettings;
2552 pVBoxAPI->UIAudioAdapter = _UIAudioAdapter;
2553 pVBoxAPI->UINetworkAdapter = _UINetworkAdapter;
2554 pVBoxAPI->UISerialPort = _UISerialPort;
2555 pVBoxAPI->UIParallelPort = _UIParallelPort;
2556 pVBoxAPI->UIVRDEServer = _UIVRDEServer;
2557 pVBoxAPI->UIUSBCommon = _UIUSBCommon;
2558 pVBoxAPI->UIUSBDeviceFilter = _UIUSBDeviceFilter;
2559 pVBoxAPI->UIMedium = _UIMedium;
2560 pVBoxAPI->UIMediumAttachment = _UIMediumAttachment;
2561 pVBoxAPI->UIStorageController = _UIStorageController;
2562 pVBoxAPI->UISharedFolder = _UISharedFolder;
2563 pVBoxAPI->UISnapshot = _UISnapshot;
2564 pVBoxAPI->UIDisplay = _UIDisplay;
2565 pVBoxAPI->UIHost = _UIHost;
2566 pVBoxAPI->UIHNInterface = _UIHNInterface;
2567 pVBoxAPI->UIDHCPServer = _UIDHCPServer;
2568 pVBoxAPI->UIKeyboard = _UIKeyboard;
2569 pVBoxAPI->machineStateChecker = _machineStateChecker;
2570
2571 pVBoxAPI->chipsetType = 1;
2572
2573 pVBoxAPI->vboxSnapshotRedefine = 1;
2574 }
2575