2009-04-17 16:09:07 +00:00
|
|
|
/** @file vbox_tmpl.c
|
|
|
|
* Template File to support multiple versions of VirtualBox
|
|
|
|
* at runtime :).
|
|
|
|
*
|
|
|
|
* IMPORTANT:
|
|
|
|
* Please dont include this file in the src/Makefile.am, it
|
|
|
|
* is automatically include by other files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
event: make deregister return value match docs
Ever since their introduction (commit 1509b80 in v0.5.0 for
virConnectDomainEventRegister, commit 4445723 in v0.8.0 for
virConnectDomainEventDeregisterAny), the event deregistration
functions have been documented as returning 0 on success;
likewise for older registration (only the newer RegisterAny
must return a non-zero callbackID). And now that we are
adding virConnectNetworkEventDeregisterAny for v1.2.1, it
should have the same semantics.
Fortunately, all of the stateful drivers have been obeying
the docs and returning 0, thanks to the way the remote_driver
tracks things (in fact, the RPC wire protocol is unable to
send a return value for DomainEventRegisterAny, at least not
without adding a new RPC number). Well, except for vbox,
which was always failing deregistration, due to failure to
set the return value to anything besides its initial -1.
But for local drivers, such as test:///default, we've been
returning non-zero numbers; worse, the non-zero numbers have
differed over time. For example, in Fedora 12 (libvirt 0.8.2),
calling Register twice would return 0 and 1 [the callbackID
generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
it returns 1 and 2 [the number of callbacks registered for
that event type]. Since we have changed the behavior over
time, and since it differs by local vs. remote, we can safely
argue that no one could have been reasonably relying on any
particular behavior, so we might as well obey the docs, as well
as prepare callers that might deal with older clients to not be
surprised if the docs are not strictly followed.
For consistency, this patch fixes the code for all drivers,
even though it only makes an impact for vbox and for local
drivers. By fixing all drivers, future copy and paste from
a remote driver to a local driver is less likely to
reintroduce the bug.
Finally, update the testsuite to gain some coverage of the
issue for local drivers, including the first test of old-style
domain event registration via function pointer instead of
event id.
* src/libvirt.c (virConnectDomainEventRegister)
(virConnectDomainEventDeregister)
(virConnectDomainEventDeregisterAny): Clarify docs.
* src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
(libxlConnectDomainEventDeregister)
(libxlConnectDomainEventDeregisterAny): Match documentation.
* src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
(lxcConnectDomainEventDeregister)
(lxcConnectDomainEventDeregisterAny): Likewise.
* src/test/test_driver.c (testConnectDomainEventRegister)
(testConnectDomainEventDeregister)
(testConnectDomainEventDeregisterAny)
(testConnectNetworkEventDeregisterAny): Likewise.
* src/uml/uml_driver.c (umlConnectDomainEventRegister)
(umlConnectDomainEventDeregister)
(umlConnectDomainEventDeregisterAny): Likewise.
* src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
(vboxConnectDomainEventDeregister)
(vboxConnectDomainEventDeregisterAny): Likewise.
* src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
(xenUnifiedConnectDomainEventDeregister)
(xenUnifiedConnectDomainEventDeregisterAny): Likewise.
* src/network/bridge_driver.c
(networkConnectNetworkEventDeregisterAny): Likewise.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-03 21:21:17 +00:00
|
|
|
* Copyright (C) 2010-2014 Red Hat, Inc.
|
2009-04-17 16:09:07 +00:00
|
|
|
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of a free software library; you can redistribute
|
|
|
|
* it and/or modify it under the terms of the GNU Lesser General
|
|
|
|
* Public License version 2.1 as published by the Free Software
|
2013-05-15 20:30:23 +00:00
|
|
|
* Foundation and shipped in the "COPYING.LESSER" file with this library.
|
2009-04-17 16:09:07 +00:00
|
|
|
* The library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY of any kind.
|
|
|
|
*
|
|
|
|
* Sun LGPL Disclaimer: For the avoidance of doubt, except that if
|
|
|
|
* any license choice other than GPL or LGPL is available it will
|
|
|
|
* apply instead, Sun elects to use only the Lesser General Public
|
|
|
|
* License version 2.1 (LGPLv2) at this time for any software where
|
|
|
|
* a choice of LGPL license versions is made available with the
|
|
|
|
* language indicating that LGPLv2 or any later version may be used,
|
|
|
|
* or where a choice of which version of the LGPL is applied is
|
|
|
|
* otherwise unspecified.
|
|
|
|
*
|
|
|
|
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
|
|
|
* Clara, CA 95054 USA or visit http://www.sun.com if you need
|
|
|
|
* additional information or have any questions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2010-12-14 22:07:57 +00:00
|
|
|
#include <unistd.h>
|
2011-04-01 13:34:23 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
2009-04-17 16:09:07 +00:00
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
#include "datatypes.h"
|
|
|
|
#include "domain_conf.h"
|
2009-07-24 16:12:16 +00:00
|
|
|
#include "domain_event.h"
|
2012-12-12 18:06:53 +00:00
|
|
|
#include "viralloc.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2013-04-03 10:36:23 +00:00
|
|
|
#include "virstring.h"
|
2014-05-19 12:47:30 +00:00
|
|
|
#include "virutil.h"
|
2009-04-17 16:09:07 +00:00
|
|
|
|
|
|
|
/* This one changes from version to version. */
|
2020-04-17 11:03:50 +00:00
|
|
|
#if VBOX_API_VERSION == 5002000
|
2017-11-07 22:36:34 +00:00
|
|
|
# include "vbox_CAPI_v5_2.h"
|
2020-04-17 10:57:54 +00:00
|
|
|
#elif VBOX_API_VERSION == 6000000
|
|
|
|
# include "vbox_CAPI_v6_0.h"
|
2020-04-17 10:57:54 +00:00
|
|
|
#elif VBOX_API_VERSION == 6001000
|
|
|
|
# include "vbox_CAPI_v6_1.h"
|
2009-07-24 16:12:16 +00:00
|
|
|
#else
|
2020-04-17 10:57:54 +00:00
|
|
|
# error "Unsupported VBOX_API_VERSION"
|
2009-04-17 16:09:07 +00:00
|
|
|
#endif
|
|
|
|
|
2009-05-06 13:51:19 +00:00
|
|
|
/* Include this *last* or we'll get the wrong vbox_CAPI_*.h. */
|
2020-04-17 11:12:09 +00:00
|
|
|
#include "vbox_XPCOMCGlue.h"
|
2014-08-11 10:06:19 +00:00
|
|
|
|
|
|
|
typedef IUSBDeviceFilters IUSBCommon;
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
|
2014-08-11 10:06:04 +00:00
|
|
|
#include "vbox_uniformed_api.h"
|
2009-05-06 13:51:19 +00:00
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
#define VIR_FROM_THIS VIR_FROM_VBOX
|
2014-02-28 12:16:17 +00:00
|
|
|
|
|
|
|
VIR_LOG_INIT("vbox.vbox_tmpl");
|
|
|
|
|
2014-08-11 10:06:04 +00:00
|
|
|
#define vboxUnsupported() \
|
|
|
|
VIR_WARN("No %s in current vbox version %d.", __FUNCTION__, VBOX_API_VERSION);
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define VBOX_UTF16_FREE(arg) \
|
|
|
|
do { \
|
|
|
|
if (arg) { \
|
|
|
|
data->pFuncs->pfnUtf16Free(arg); \
|
|
|
|
(arg) = NULL; \
|
|
|
|
} \
|
2013-01-24 00:34:48 +00:00
|
|
|
} while (0)
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define VBOX_UTF8_FREE(arg) \
|
|
|
|
do { \
|
|
|
|
if (arg) { \
|
|
|
|
data->pFuncs->pfnUtf8Free(arg); \
|
|
|
|
(arg) = NULL; \
|
|
|
|
} \
|
2013-01-24 00:34:48 +00:00
|
|
|
} while (0)
|
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
#define VBOX_UTF16_TO_UTF8(arg1, arg2) data->pFuncs->pfnUtf16ToUtf8(arg1, arg2)
|
|
|
|
#define VBOX_UTF8_TO_UTF16(arg1, arg2) data->pFuncs->pfnUtf8ToUtf16(arg1, arg2)
|
|
|
|
|
2017-11-03 12:09:47 +00:00
|
|
|
#define VBOX_RELEASE(arg) \
|
|
|
|
do { \
|
|
|
|
if (arg) { \
|
|
|
|
(arg)->vtbl->nsisupports.Release((nsISupports *)(arg)); \
|
|
|
|
(arg) = NULL; \
|
|
|
|
} \
|
2010-12-27 22:35:30 +00:00
|
|
|
} while (0)
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2016-12-29 20:34:24 +00:00
|
|
|
#define VBOX_MEDIUM_RELEASE(arg) VBOX_RELEASE(arg)
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2009-07-24 16:12:16 +00:00
|
|
|
#define DEBUGPRUnichar(msg, strUtf16) \
|
|
|
|
if (strUtf16) {\
|
|
|
|
char *strUtf8 = NULL;\
|
|
|
|
\
|
2016-11-23 19:01:11 +00:00
|
|
|
data->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8);\
|
2009-07-24 16:12:16 +00:00
|
|
|
if (strUtf8) {\
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("%s: %s", msg, strUtf8);\
|
2016-11-23 19:01:11 +00:00
|
|
|
data->pFuncs->pfnUtf8Free(strUtf8);\
|
2009-07-24 16:12:16 +00:00
|
|
|
}\
|
|
|
|
}
|
|
|
|
|
|
|
|
#define DEBUGUUID(msg, iid) \
|
|
|
|
{\
|
2014-08-11 10:06:06 +00:00
|
|
|
VIR_DEBUG("%s: {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", msg,\
|
2009-07-24 16:12:16 +00:00
|
|
|
(unsigned)(iid)->m0,\
|
|
|
|
(unsigned)(iid)->m1,\
|
|
|
|
(unsigned)(iid)->m2,\
|
|
|
|
(unsigned)(iid)->m3[0],\
|
|
|
|
(unsigned)(iid)->m3[1],\
|
|
|
|
(unsigned)(iid)->m3[2],\
|
|
|
|
(unsigned)(iid)->m3[3],\
|
|
|
|
(unsigned)(iid)->m3[4],\
|
|
|
|
(unsigned)(iid)->m3[5],\
|
|
|
|
(unsigned)(iid)->m3[6],\
|
|
|
|
(unsigned)(iid)->m3[7]);\
|
|
|
|
}\
|
|
|
|
|
2016-12-29 20:34:24 +00:00
|
|
|
#define VBOX_IID_INITIALIZER { NULL, true }
|
2010-12-23 16:25:56 +00:00
|
|
|
|
2017-10-24 21:09:16 +00:00
|
|
|
/* default RDP port range to use for auto-port setting */
|
|
|
|
#define VBOX_RDP_AUTOPORT_RANGE "3389-3689"
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDUnalloc(vboxDriverPtr data, vboxIID *iid)
|
2010-12-23 16:25:56 +00:00
|
|
|
{
|
2014-11-13 14:21:37 +00:00
|
|
|
if (iid->value != NULL && iid->owner)
|
2010-12-23 16:25:56 +00:00
|
|
|
data->pFuncs->pfnUtf16Free(iid->value);
|
|
|
|
|
|
|
|
iid->value = NULL;
|
|
|
|
iid->owner = true;
|
2009-07-24 16:12:16 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDToUUID(vboxDriverPtr data, vboxIID *iid,
|
|
|
|
unsigned char *uuid)
|
2010-12-23 16:25:56 +00:00
|
|
|
{
|
|
|
|
char *utf8 = NULL;
|
|
|
|
|
|
|
|
data->pFuncs->pfnUtf16ToUtf8(iid->value, &utf8);
|
|
|
|
|
2011-10-12 23:24:52 +00:00
|
|
|
ignore_value(virUUIDParse(utf8, uuid));
|
2010-12-23 16:25:56 +00:00
|
|
|
|
|
|
|
data->pFuncs->pfnUtf8Free(utf8);
|
2009-07-24 16:12:16 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDFromUUID(vboxDriverPtr data, vboxIID *iid,
|
|
|
|
const unsigned char *uuid)
|
2010-12-23 16:25:56 +00:00
|
|
|
{
|
|
|
|
char utf8[VIR_UUID_STRING_BUFLEN];
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDUnalloc(data, iid);
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
virUUIDFormat(uuid, utf8);
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
data->pFuncs->pfnUtf8ToUtf16(utf8, &iid->value);
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static bool
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDIsEqual(vboxDriverPtr data, vboxIID *iid1,
|
|
|
|
vboxIID *iid2)
|
2010-12-23 16:25:56 +00:00
|
|
|
{
|
|
|
|
unsigned char uuid1[VIR_UUID_BUFLEN];
|
|
|
|
unsigned char uuid2[VIR_UUID_BUFLEN];
|
2009-09-04 14:28:52 +00:00
|
|
|
|
|
|
|
/* Note: we can't directly compare the utf8 strings here
|
2011-10-10 20:02:06 +00:00
|
|
|
* cause the two UUID's may have separators as space or '-'
|
2009-09-04 14:28:52 +00:00
|
|
|
* or mixture of both and we don't want to fail here by
|
|
|
|
* using direct string comparison. Here virUUIDParse() takes
|
2010-12-23 16:25:56 +00:00
|
|
|
* care of these cases. */
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDToUUID(data, iid1, uuid1);
|
|
|
|
_vboxIIDToUUID(data, iid2, uuid2);
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
return memcmp(uuid1, uuid2, VIR_UUID_BUFLEN) == 0;
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDFromArrayItem(vboxDriverPtr data, vboxIID *iid,
|
|
|
|
vboxArray *array, int idx)
|
2010-12-23 16:25:56 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDUnalloc(data, iid);
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
iid->value = array->items[idx];
|
|
|
|
iid->owner = false;
|
2009-09-04 14:28:52 +00:00
|
|
|
}
|
|
|
|
|
2016-12-29 20:34:32 +00:00
|
|
|
#define vboxIIDUnalloc(iid) _vboxIIDUnalloc(data, iid)
|
|
|
|
#define vboxIIDToUUID(iid, uuid) _vboxIIDToUUID(data, iid, uuid)
|
|
|
|
#define vboxIIDFromUUID(iid, uuid) _vboxIIDFromUUID(data, iid, uuid)
|
|
|
|
#define vboxIIDIsEqual(iid1, iid2) _vboxIIDIsEqual(data, iid1, iid2)
|
2016-12-29 20:34:24 +00:00
|
|
|
#define vboxIIDFromArrayItem(iid, array, idx) \
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxIIDFromArrayItem(data, iid, array, idx)
|
2016-12-29 20:34:24 +00:00
|
|
|
#define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
|
2009-12-04 13:49:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts int to Utf-16 string
|
|
|
|
*/
|
2016-11-23 19:01:11 +00:00
|
|
|
static PRUnichar *PRUnicharFromInt(PCVBOXXPCOM pFuncs, int n) {
|
2009-12-04 13:49:45 +00:00
|
|
|
PRUnichar *strUtf16 = NULL;
|
|
|
|
char s[24];
|
|
|
|
|
2019-11-13 13:53:42 +00:00
|
|
|
g_snprintf(s, sizeof(s), "%d", n);
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2016-11-23 19:01:11 +00:00
|
|
|
pFuncs->pfnUtf8ToUtf16(s, &strUtf16);
|
2009-12-04 13:49:45 +00:00
|
|
|
|
|
|
|
return strUtf16;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:36 +00:00
|
|
|
static virDomainState _vboxConvertState(PRUint32 state)
|
2014-03-18 08:18:32 +00:00
|
|
|
{
|
2013-10-14 16:19:41 +00:00
|
|
|
switch (state) {
|
|
|
|
case MachineState_Running:
|
|
|
|
return VIR_DOMAIN_RUNNING;
|
|
|
|
case MachineState_Stuck:
|
|
|
|
return VIR_DOMAIN_BLOCKED;
|
|
|
|
case MachineState_Paused:
|
|
|
|
return VIR_DOMAIN_PAUSED;
|
|
|
|
case MachineState_Stopping:
|
|
|
|
return VIR_DOMAIN_SHUTDOWN;
|
|
|
|
case MachineState_PoweredOff:
|
2013-10-14 16:19:42 +00:00
|
|
|
case MachineState_Saved:
|
2013-10-14 16:19:41 +00:00
|
|
|
return VIR_DOMAIN_SHUTOFF;
|
|
|
|
case MachineState_Aborted:
|
|
|
|
return VIR_DOMAIN_CRASHED;
|
|
|
|
case MachineState_Null:
|
|
|
|
default:
|
|
|
|
return VIR_DOMAIN_NOSTATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-24 21:09:17 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
vboxGetActiveVRDEServerPort(ISession *session, IMachine *machine)
|
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
PRInt32 port = -1;
|
|
|
|
IVRDEServerInfo *vrdeInfo = NULL;
|
|
|
|
IConsole *console = NULL;
|
|
|
|
|
|
|
|
rc = machine->vtbl->LockMachine(machine, session, LockType_Shared);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
VIR_WARN("Could not obtain shared lock on VBox VM, rc=%08x", rc);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = session->vtbl->GetConsole(session, &console);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
VIR_WARN("Could not get VBox session console, rc=%08x", rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* it may be null if VM is not running */
|
|
|
|
if (!console)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rc = console->vtbl->GetVRDEServerInfo(console, &vrdeInfo);
|
|
|
|
|
|
|
|
if (NS_FAILED(rc) || !vrdeInfo) {
|
|
|
|
VIR_WARN("Could not get VBox VM VRDEServerInfo, rc=%08x", rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = vrdeInfo->vtbl->GetPort(vrdeInfo, &port);
|
|
|
|
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
VIR_WARN("Could not read port from VRDEServerInfo, rc=%08x", rc);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VBOX_RELEASE(console);
|
|
|
|
VBOX_RELEASE(vrdeInfo);
|
|
|
|
session->vtbl->UnlockMachine(session);
|
|
|
|
|
|
|
|
return port;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-26 12:40:34 +00:00
|
|
|
static int
|
2014-08-11 10:07:03 +00:00
|
|
|
_vboxDomainSnapshotRestore(virDomainPtr dom,
|
2010-03-26 12:40:34 +00:00
|
|
|
IMachine *machine,
|
|
|
|
ISnapshot *snapshot)
|
|
|
|
{
|
2016-11-23 19:01:11 +00:00
|
|
|
vboxDriverPtr data = dom->conn->privateData;
|
2010-03-26 12:40:34 +00:00
|
|
|
IProgress *progress = NULL;
|
|
|
|
PRUint32 state;
|
|
|
|
nsresult rc;
|
|
|
|
PRInt32 result;
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIID domiid = VBOX_IID_INITIALIZER;
|
2014-10-24 01:46:36 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!data->vboxObj)
|
|
|
|
return ret;
|
2010-03-26 12:40:34 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
rc = machine->vtbl->GetId(machine, &domiid.value);
|
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("could not get domain UUID"));
|
2010-03-26 12:40:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = machine->vtbl->GetState(machine, &state);
|
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("could not get domain state"));
|
2010-03-26 12:40:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state >= MachineState_FirstOnline
|
|
|
|
&& state <= MachineState_LastOnline) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID,
|
|
|
|
_("domain %s is already running"), dom->name);
|
2010-03-26 12:40:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2017-10-24 21:09:15 +00:00
|
|
|
rc = machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write);
|
2010-03-26 12:40:34 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not open VirtualBox session with domain %s"),
|
|
|
|
dom->name);
|
2010-03-26 12:40:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2016-06-19 11:54:23 +00:00
|
|
|
rc = machine->vtbl->RestoreSnapshot(machine, snapshot, &progress);
|
|
|
|
|
2010-03-26 12:40:34 +00:00
|
|
|
if (NS_FAILED(rc) || !progress) {
|
|
|
|
if (rc == VBOX_E_INVALID_VM_STATE) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
|
|
|
_("cannot restore domain snapshot for running domain"));
|
2010-03-26 12:40:34 +00:00
|
|
|
} else {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not restore snapshot for domain %s"),
|
|
|
|
dom->name);
|
2010-03-26 12:40:34 +00:00
|
|
|
}
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
progress->vtbl->WaitForCompletion(progress, -1);
|
|
|
|
progress->vtbl->GetResultCode(progress, &result);
|
|
|
|
if (NS_FAILED(result)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not restore snapshot for domain %s"), dom->name);
|
2010-03-26 12:40:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
|
2014-03-25 06:54:41 +00:00
|
|
|
cleanup:
|
2010-03-26 12:40:34 +00:00
|
|
|
VBOX_RELEASE(progress);
|
2017-10-24 21:09:15 +00:00
|
|
|
data->vboxSession->vtbl->UnlockMachine(data->vboxSession);
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIIDUnalloc(&domiid);
|
2010-03-26 12:40:34 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-12-29 20:34:24 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_unregisterMachine(vboxDriverPtr data, vboxIID *iid, IMachine **machine)
|
2014-08-11 10:06:50 +00:00
|
|
|
{
|
|
|
|
nsresult rc;
|
2016-12-29 20:34:24 +00:00
|
|
|
vboxArray media = VBOX_ARRAY_INITIALIZER;
|
2017-10-24 19:35:25 +00:00
|
|
|
size_t i;
|
|
|
|
|
2016-12-29 20:34:32 +00:00
|
|
|
rc = data->vboxObj->vtbl->FindMachine(data->vboxObj, iid->value, machine);
|
2016-12-29 20:34:24 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
|
|
|
_("no domain with matching uuid"));
|
|
|
|
return rc;
|
|
|
|
}
|
2014-08-11 10:06:50 +00:00
|
|
|
|
2016-12-29 20:34:24 +00:00
|
|
|
rc = vboxArrayGetWithUintArg(&media, *machine, (*machine)->vtbl->Unregister,
|
2017-10-24 19:35:25 +00:00
|
|
|
CleanupMode_DetachAllReturnHardDisksOnly);
|
|
|
|
|
|
|
|
if (NS_FAILED(rc))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
/* close each medium attached to VM to remove from media registry */
|
|
|
|
for (i = 0; i < media.count; i++) {
|
|
|
|
IMedium *medium = media.items[i];
|
|
|
|
|
|
|
|
if (!medium)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* it's ok to ignore failure here - e.g. it may be used by another VM */
|
|
|
|
ignore_value(medium->vtbl->Close(medium));
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
2016-12-29 20:34:24 +00:00
|
|
|
vboxArrayUnalloc(&media);
|
|
|
|
return rc;
|
|
|
|
}
|
2014-08-11 10:06:50 +00:00
|
|
|
|
2016-12-29 20:34:24 +00:00
|
|
|
static void
|
|
|
|
_deleteConfig(IMachine *machine)
|
|
|
|
{
|
|
|
|
IProgress *progress = NULL;
|
2014-08-11 10:06:50 +00:00
|
|
|
|
2016-12-29 20:34:24 +00:00
|
|
|
/* The IMachine Delete method takes an array of IMedium items to be
|
|
|
|
* deleted along with the virtual machine. We just want to pass an
|
|
|
|
* empty array. But instead of adding a full vboxArraySetWithReturn to
|
|
|
|
* the glue layer (in order to handle the required signature of the
|
|
|
|
* Delete method) we use a local solution here. */
|
|
|
|
#ifdef WIN32
|
|
|
|
SAFEARRAY *safeArray = NULL;
|
|
|
|
typedef HRESULT __stdcall (*IMachine_Delete)(IMachine *self,
|
|
|
|
SAFEARRAY **media,
|
|
|
|
IProgress **progress);
|
2014-08-11 10:06:50 +00:00
|
|
|
|
2016-12-29 20:34:24 +00:00
|
|
|
((IMachine_Delete)machine->vtbl->DeleteConfig)(machine, &safeArray, &progress);
|
|
|
|
#else
|
|
|
|
/* XPCOM doesn't like NULL as an array, even when the array size is 0.
|
|
|
|
* Instead pass it a dummy array to avoid passing NULL. */
|
|
|
|
IMedium *array[] = { NULL };
|
|
|
|
machine->vtbl->DeleteConfig(machine, 0, array, &progress);
|
|
|
|
#endif
|
|
|
|
if (progress != NULL) {
|
|
|
|
progress->vtbl->WaitForCompletion(progress, -1);
|
|
|
|
VBOX_RELEASE(progress);
|
|
|
|
}
|
2014-08-11 10:06:50 +00:00
|
|
|
}
|
|
|
|
|
2016-11-23 19:01:10 +00:00
|
|
|
static int _pfnInitialize(vboxDriverPtr driver)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2019-04-12 10:51:09 +00:00
|
|
|
nsresult rc;
|
|
|
|
|
2016-11-23 19:01:10 +00:00
|
|
|
if (!(driver->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION)))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
rc = driver->pFuncs->pfnClientInitialize(IVIRTUALBOXCLIENT_IID_STR,
|
|
|
|
&driver->vboxClient);
|
|
|
|
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
driver->vboxClient->vtbl->GetVirtualBox(driver->vboxClient, &driver->vboxObj);
|
|
|
|
driver->vboxClient->vtbl->GetSession(driver->vboxClient, &driver->vboxSession);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _pfnUninitialize(vboxDriverPtr data)
|
|
|
|
{
|
|
|
|
if (data->pFuncs) {
|
|
|
|
VBOX_RELEASE(data->vboxObj);
|
|
|
|
VBOX_RELEASE(data->vboxSession);
|
|
|
|
VBOX_RELEASE(data->vboxClient);
|
|
|
|
|
|
|
|
data->pFuncs->pfnClientUninitialize();
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
}
|
2009-05-15 14:00:50 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _pfnComUnallocMem(PCVBOXXPCOM pFuncs, void *pv)
|
2011-04-01 13:34:23 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
pFuncs->pfnComUnallocMem(pv);
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _pfnUtf16Free(PCVBOXXPCOM pFuncs, PRUnichar *pwszString)
|
|
|
|
{
|
|
|
|
pFuncs->pfnUtf16Free(pwszString);
|
|
|
|
}
|
2011-07-06 23:06:11 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _pfnUtf8Free(PCVBOXXPCOM pFuncs, char *pszString)
|
|
|
|
{
|
|
|
|
pFuncs->pfnUtf8Free(pszString);
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static int _pfnUtf16ToUtf8(PCVBOXXPCOM pFuncs, const PRUnichar *pwszString, char **ppszString)
|
|
|
|
{
|
|
|
|
return pFuncs->pfnUtf16ToUtf8(pwszString, ppszString);
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static int _pfnUtf8ToUtf16(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar **ppwszString)
|
|
|
|
{
|
|
|
|
return pFuncs->pfnUtf8ToUtf16(pszString, ppwszString);
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2016-12-29 20:34:32 +00:00
|
|
|
static void _vboxIIDInitialize(vboxIID *iid)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
memset(iid, 0, sizeof(vboxIID));
|
|
|
|
iid->owner = true;
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2016-12-29 20:34:32 +00:00
|
|
|
static void _DEBUGIID(vboxDriverPtr data, const char *msg, vboxIID *iid)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
DEBUGPRUnichar(msg, iid->value);
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static void
|
2019-10-14 12:45:33 +00:00
|
|
|
_vboxIIDToUtf8(vboxDriverPtr data G_GNUC_UNUSED,
|
|
|
|
vboxIID *iid G_GNUC_UNUSED,
|
|
|
|
char **utf8 G_GNUC_UNUSED)
|
2014-08-11 10:06:52 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
data->pFuncs->pfnUtf16ToUtf8(iid->value, utf8);
|
2014-08-11 10:06:52 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_vboxArrayGetWithIIDArg(vboxArray *array, void *self, void *getter, vboxIID *iid)
|
2014-08-11 10:06:54 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return vboxArrayGetWithPtrArg(array, self, getter, iid->value);
|
2014-08-11 10:06:54 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void* _handleGetMachines(IVirtualBox *vboxObj)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->GetMachines;
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
vbox: Rewrite vboxStoragePoolNumOfVolumes
We use typedef IMedium IHardDisk to make IHardDisk hierachy from
IMedium (Actually it did on vbox 2.2 and 3.0's C++ API).
So when calling
VBOX_MEDIUM_FUNC_ARG*(IHardDisk, func, args)
we can directly replace it to
gVBoxAPI.UIMedium.func(IHardDisk, args)
When dealing with this two types, we get some rules from it's
hierachy relationship.
When using IHardDisk and IMedium as input, we can't transfer a
IMedium to IHardDisk. Like:
gVBoxAPI.UIHardDisk.func(IHardDisk *hardDisk, args)
Here, we can't put a *IMedium as a argument.
When using IHardDisk and IMedium as output, we can't transfer a
IHardDisk to IMedium. Like:
gVBoxAPI.UIMachine.GetMedium(IMedium **out)
Here, we can't put a **IHardDisk as a argument. If this case
do happen, we either change the API to GetHardDisk or write a
new one.
2014-10-24 01:46:39 +00:00
|
|
|
static void* _handleGetHardDisks(IVirtualBox *vboxObj)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->GetHardDisks;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static void* _handleUSBGetDeviceFilters(IUSBCommon *USBCommon)
|
|
|
|
{
|
|
|
|
return USBCommon->vtbl->GetDeviceFilters;
|
|
|
|
}
|
|
|
|
|
2017-10-24 19:35:31 +00:00
|
|
|
static void* _handleMachineGetStorageControllers(IMachine *machine)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetStorageControllers;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static void* _handleMachineGetMediumAttachments(IMachine *machine)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetMediumAttachments;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* _handleMachineGetSharedFolders(IMachine *machine)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetSharedFolders;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static void* _handleSnapshotGetChildren(ISnapshot *snapshot)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetChildren;
|
|
|
|
}
|
|
|
|
|
2019-10-14 12:45:33 +00:00
|
|
|
static void* _handleMediumGetChildren(IMedium *medium G_GNUC_UNUSED)
|
2014-08-11 10:06:54 +00:00
|
|
|
{
|
|
|
|
return medium->vtbl->GetChildren;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* _handleMediumGetSnapshotIds(IMedium *medium)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetSnapshotIds;
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:48 +00:00
|
|
|
static void* _handleMediumGetMachineIds(IMedium *medium)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetMachineIds;
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:28 +00:00
|
|
|
static void* _handleHostGetNetworkInterfaces(IHost *host)
|
|
|
|
{
|
|
|
|
return host->vtbl->GetNetworkInterfaces;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult _nsisupportsRelease(nsISupports *nsi)
|
|
|
|
{
|
|
|
|
return nsi->vtbl->Release(nsi);
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static nsresult _nsisupportsAddRef(nsISupports *nsi)
|
|
|
|
{
|
|
|
|
return nsi->vtbl->AddRef(nsi);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxGetVersion(IVirtualBox *vboxObj, PRUnichar **versionUtf16)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->GetVersion(vboxObj, versionUtf16);
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_virtualboxGetMachine(IVirtualBox *vboxObj, vboxIID *iid, IMachine **machine)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return vboxObj->vtbl->FindMachine(vboxObj, iid->value, machine);
|
2011-04-01 13:34:23 +00:00
|
|
|
}
|
2014-08-11 10:06:19 +00:00
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxOpenMachine(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->OpenMachine(vboxObj, settingsFile, machine);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxGetSystemProperties(IVirtualBox *vboxObj, ISystemProperties **systemProperties)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->GetSystemProperties(vboxObj, systemProperties);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-10-02 03:30:28 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxGetHost(IVirtualBox *vboxObj, IHost **host)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->GetHost(vboxObj, host);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_virtualboxCreateMachine(vboxDriverPtr data, virDomainDefPtr def, IMachine **machine, char *uuidstr G_GNUC_UNUSED)
|
2012-06-05 12:12:21 +00:00
|
|
|
{
|
|
|
|
vboxIID iid = VBOX_IID_INITIALIZER;
|
2014-08-11 10:06:19 +00:00
|
|
|
PRUnichar *machineNameUtf16 = NULL;
|
2019-10-22 13:26:14 +00:00
|
|
|
char *createFlags = NULL;
|
|
|
|
PRUnichar *createFlagsUtf16 = NULL;
|
2016-03-05 11:59:45 +00:00
|
|
|
nsresult rc = -1;
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16);
|
|
|
|
vboxIIDFromUUID(&iid, def->uuid);
|
2019-10-22 13:26:14 +00:00
|
|
|
createFlags = g_strdup_printf("UUID=%s,forceOverwrite=0", uuidstr);
|
|
|
|
VBOX_UTF8_TO_UTF16(createFlags, &createFlagsUtf16);
|
|
|
|
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
|
|
|
|
NULL,
|
|
|
|
machineNameUtf16,
|
|
|
|
0,
|
|
|
|
nsnull,
|
|
|
|
nsnull,
|
|
|
|
createFlagsUtf16,
|
|
|
|
machine);
|
|
|
|
VIR_FREE(createFlags);
|
2014-08-11 10:06:19 +00:00
|
|
|
VBOX_UTF16_FREE(machineNameUtf16);
|
|
|
|
vboxIIDUnalloc(&iid);
|
|
|
|
return rc;
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
2014-10-24 01:46:45 +00:00
|
|
|
_virtualboxCreateHardDisk(IVirtualBox *vboxObj, PRUnichar *format,
|
2016-12-29 20:34:26 +00:00
|
|
|
PRUnichar *location, IMedium **medium)
|
2014-08-11 10:06:52 +00:00
|
|
|
{
|
2019-04-12 10:51:09 +00:00
|
|
|
/* This function will create a IMedium object.
|
2014-10-24 01:46:45 +00:00
|
|
|
*/
|
2017-10-24 19:35:24 +00:00
|
|
|
return vboxObj->vtbl->CreateMedium(vboxObj, format, location,
|
|
|
|
AccessMode_ReadWrite,
|
|
|
|
DeviceType_HardDisk, medium);
|
2014-08-11 10:06:52 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxRegisterMachine(IVirtualBox *vboxObj, IMachine *machine)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->RegisterMachine(vboxObj, machine);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2017-10-24 19:35:24 +00:00
|
|
|
_virtualboxFindHardDisk(IVirtualBox *vboxObj,
|
|
|
|
PRUnichar *location,
|
|
|
|
PRUint32 deviceType,
|
2019-10-14 12:45:33 +00:00
|
|
|
PRUint32 accessMode G_GNUC_UNUSED,
|
2016-12-29 20:34:26 +00:00
|
|
|
IMedium **medium)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2017-10-24 19:35:24 +00:00
|
|
|
return vboxObj->vtbl->OpenMedium(vboxObj, location, deviceType, accessMode,
|
|
|
|
PR_FALSE, medium);
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2017-10-24 19:35:24 +00:00
|
|
|
_virtualboxOpenMedium(IVirtualBox *vboxObj,
|
|
|
|
PRUnichar *location,
|
|
|
|
PRUint32 deviceType,
|
|
|
|
PRUint32 accessMode,
|
|
|
|
IMedium **medium)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2017-10-24 19:35:24 +00:00
|
|
|
return vboxObj->vtbl->OpenMedium(vboxObj, location, deviceType, accessMode,
|
|
|
|
false, medium);
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-10-24 01:46:42 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIID *iid, IMedium **medium)
|
2014-10-24 01:46:42 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return vboxObj->vtbl->OpenMedium(vboxObj, iid->value, DeviceType_HardDisk,
|
2016-12-29 20:34:26 +00:00
|
|
|
AccessMode_ReadWrite, PR_FALSE, medium);
|
2014-10-24 01:46:42 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:34 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxFindDHCPServerByNetworkName(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->FindDHCPServerByNetworkName(vboxObj, name, server);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_virtualboxCreateDHCPServer(IVirtualBox *vboxObj, PRUnichar *name, IDHCPServer **server)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->CreateDHCPServer(vboxObj, name, server);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:35 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxRemoveDHCPServer(IVirtualBox *vboxObj, IDHCPServer *server)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->RemoveDHCPServer(vboxObj, server);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineAddStorageController(IMachine *machine, PRUnichar *name,
|
|
|
|
PRUint32 connectionType,
|
|
|
|
IStorageController **controller)
|
|
|
|
{
|
|
|
|
return machine->vtbl->AddStorageController(machine, name, connectionType,
|
|
|
|
controller);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetStorageControllerByName(IMachine *machine, PRUnichar *name,
|
|
|
|
IStorageController **storageController)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetStorageControllerByName(machine, name,
|
|
|
|
storageController);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2017-10-24 19:35:24 +00:00
|
|
|
_machineAttachDevice(IMachine *machine,
|
|
|
|
PRUnichar *name,
|
|
|
|
PRInt32 controllerPort,
|
|
|
|
PRInt32 device,
|
|
|
|
PRUint32 type,
|
|
|
|
IMedium * medium)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
|
|
|
return machine->vtbl->AttachDevice(machine, name, controllerPort,
|
|
|
|
device, type, medium);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineCreateSharedFolder(IMachine *machine, PRUnichar *name,
|
|
|
|
PRUnichar *hostPath, PRBool writable,
|
2019-10-14 12:45:33 +00:00
|
|
|
PRBool automount G_GNUC_UNUSED)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6000000
|
|
|
|
return machine->vtbl->CreateSharedFolder(machine, name, hostPath,
|
|
|
|
writable, automount, NULL);
|
|
|
|
#else
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->CreateSharedFolder(machine, name, hostPath,
|
|
|
|
writable, automount);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:50 +00:00
|
|
|
static nsresult
|
|
|
|
_machineRemoveSharedFolder(IMachine *machine, PRUnichar *name)
|
|
|
|
{
|
|
|
|
return machine->vtbl->RemoveSharedFolder(machine, name);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:20 +00:00
|
|
|
static nsresult
|
2016-11-23 19:01:11 +00:00
|
|
|
_machineLaunchVMProcess(vboxDriverPtr data,
|
2019-10-14 12:45:33 +00:00
|
|
|
IMachine *machine G_GNUC_UNUSED,
|
|
|
|
vboxIID *iid G_GNUC_UNUSED,
|
2014-08-11 10:06:20 +00:00
|
|
|
PRUnichar *sessionType, PRUnichar *env,
|
|
|
|
IProgress **progress)
|
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
PRUnichar *envlist[] = { env };
|
|
|
|
return machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
|
|
|
|
sessionType, 1, envlist, progress);
|
|
|
|
#else
|
2014-08-11 10:06:20 +00:00
|
|
|
return machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
|
|
|
|
sessionType, env, progress);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:20 +00:00
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_machineUnregister(IMachine *machine G_GNUC_UNUSED,
|
|
|
|
PRUint32 cleanupMode G_GNUC_UNUSED,
|
|
|
|
PRUint32 *aMediaSize G_GNUC_UNUSED,
|
|
|
|
IMedium ***aMedia G_GNUC_UNUSED)
|
2014-08-11 10:06:52 +00:00
|
|
|
{
|
|
|
|
return machine->vtbl->Unregister(machine, cleanupMode, aMediaSize, aMedia);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_machineFindSnapshot(IMachine *machine, vboxIID *iid, ISnapshot **snapshot)
|
2014-08-11 10:06:54 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return machine->vtbl->FindSnapshot(machine, iid->value, snapshot);
|
2014-08-11 10:06:54 +00:00
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:48 +00:00
|
|
|
static nsresult
|
|
|
|
_machineDetachDevice(IMachine *machine, PRUnichar *name,
|
|
|
|
PRInt32 controllerPort, PRInt32 device)
|
|
|
|
{
|
|
|
|
return machine->vtbl->DetachDevice(machine, name, controllerPort, device);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetAccessible(IMachine *machine, PRBool *isAccessible)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetAccessible(machine, isAccessible);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetState(IMachine *machine, PRUint32 *state)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetState(machine, state);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetName(IMachine *machine, PRUnichar **name)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetName(machine, name);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_machineGetId(IMachine *machine, vboxIID *iid)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return machine->vtbl->GetId(machine, &iid->value);
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetBIOSSettings(IMachine *machine, IBIOSSettings **bios)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetBIOSSettings(machine, bios);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetAudioAdapter(IMachine *machine, IAudioAdapter **audioadapter)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetAudioAdapter(machine, audioadapter);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetNetworkAdapter(IMachine *machine, PRUint32 slot, INetworkAdapter **adapter)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetNetworkAdapter(machine, slot, adapter);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_machineGetChipsetType(IMachine *machine G_GNUC_UNUSED, PRUint32 *chipsetType G_GNUC_UNUSED)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
|
|
|
return machine->vtbl->GetChipsetType(machine, chipsetType);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetSerialPort(IMachine *machine, PRUint32 slot, ISerialPort **port)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetSerialPort(machine, slot, port);
|
2012-06-05 12:12:21 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetParallelPort(IMachine *machine, PRUint32 slot, IParallelPort **port)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetParallelPort(machine, slot, port);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:30 +00:00
|
|
|
_machineGetVRDEServer(IMachine *machine, IVRDEServer **VRDEServer)
|
2013-04-26 17:21:58 +00:00
|
|
|
{
|
2016-12-29 20:34:30 +00:00
|
|
|
return machine->vtbl->GetVRDEServer(machine, VRDEServer);
|
2013-04-26 17:21:58 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetUSBCommon(IMachine *machine, IUSBCommon **USBCommon)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetUSBDeviceFilters(machine, USBCommon);
|
|
|
|
}
|
2013-04-26 17:21:58 +00:00
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetCurrentSnapshot(IMachine *machine, ISnapshot **currentSnapshot)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetCurrentSnapshot(machine, currentSnapshot);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_machineGetSettingsFilePath(IMachine *machine, PRUnichar **settingsFilePath)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetSettingsFilePath(machine, settingsFilePath);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:36 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetCPUCount(IMachine *machine, PRUint32 *CPUCount)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetCPUCount(machine, CPUCount);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetCPUCount(IMachine *machine, PRUint32 CPUCount)
|
2013-04-26 17:21:58 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetCPUCount(machine, CPUCount);
|
2013-04-26 17:21:58 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:36 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetMemorySize(IMachine *machine, PRUint32 *memorySize)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetMemorySize(machine, memorySize);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetMemorySize(IMachine *machine, PRUint32 memorySize)
|
|
|
|
{
|
|
|
|
return machine->vtbl->SetMemorySize(machine, memorySize);
|
|
|
|
}
|
2013-04-26 17:21:58 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_machineGetCPUProperty(IMachine *machine, PRUint32 property G_GNUC_UNUSED, PRBool *value)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
|
|
|
return machine->vtbl->GetCPUProperty(machine, property, value);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_machineSetCPUProperty(IMachine *machine, PRUint32 property G_GNUC_UNUSED, PRBool value)
|
2013-04-26 17:21:58 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetCPUProperty(machine, property, value);
|
2013-04-26 17:21:58 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetBootOrder(IMachine *machine, PRUint32 position, PRUint32 *device)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetBootOrder(machine, position, device);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetBootOrder(IMachine *machine, PRUint32 position, PRUint32 device)
|
|
|
|
{
|
|
|
|
return machine->vtbl->SetBootOrder(machine, position, device);
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetVRAMSize(IMachine *machine, PRUint32 *VRAMSize)
|
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->GetVRAMSize(ga, VRAMSize);
|
|
|
|
#else
|
2014-08-11 10:06:42 +00:00
|
|
|
return machine->vtbl->GetVRAMSize(machine, VRAMSize);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetVRAMSize(IMachine *machine, PRUint32 VRAMSize)
|
2014-06-10 14:16:44 +00:00
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->SetVRAMSize(ga, VRAMSize);
|
|
|
|
#else
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetVRAMSize(machine, VRAMSize);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2014-06-10 14:16:44 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetMonitorCount(IMachine *machine, PRUint32 *monitorCount)
|
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->GetMonitorCount(ga, monitorCount);
|
|
|
|
#else
|
2014-08-11 10:06:42 +00:00
|
|
|
return machine->vtbl->GetMonitorCount(machine, monitorCount);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetMonitorCount(IMachine *machine, PRUint32 monitorCount)
|
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->SetMonitorCount(ga, monitorCount);
|
|
|
|
#else
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetMonitorCount(machine, monitorCount);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-06-10 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetAccelerate3DEnabled(IMachine *machine, PRBool *accelerate3DEnabled)
|
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->GetAccelerate3DEnabled(ga, accelerate3DEnabled);
|
|
|
|
#else
|
2014-08-11 10:06:42 +00:00
|
|
|
return machine->vtbl->GetAccelerate3DEnabled(machine, accelerate3DEnabled);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetAccelerate3DEnabled(IMachine *machine, PRBool accelerate3DEnabled)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->SetAccelerate3DEnabled(ga, accelerate3DEnabled);
|
|
|
|
#else
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetAccelerate3DEnabled(machine, accelerate3DEnabled);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:29 +00:00
|
|
|
_machineGetAccelerate2DVideoEnabled(IMachine *machine,
|
|
|
|
PRBool *accelerate2DVideoEnabled)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->GetAccelerate2DVideoEnabled(ga, accelerate2DVideoEnabled);
|
|
|
|
#else
|
2014-08-11 10:06:42 +00:00
|
|
|
return machine->vtbl->GetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:29 +00:00
|
|
|
_machineSetAccelerate2DVideoEnabled(IMachine *machine,
|
|
|
|
PRBool accelerate2DVideoEnabled)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
IGraphicsAdapter *ga;
|
|
|
|
nsresult ret;
|
|
|
|
ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
|
|
|
|
if (NS_FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
return ga->vtbl->SetAccelerate2DVideoEnabled(ga, accelerate2DVideoEnabled);
|
|
|
|
#else
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:20 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetExtraData(IMachine *machine, PRUnichar *key, PRUnichar **value)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetExtraData(machine, key, value);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetExtraData(IMachine *machine, PRUnichar *key, PRUnichar *value)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetExtraData(machine, key, value);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetSnapshotCount(IMachine *machine, PRUint32 *snapshotCount)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetSnapshotCount(machine, snapshotCount);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSaveSettings(IMachine *machine)
|
|
|
|
{
|
|
|
|
return machine->vtbl->SaveSettings(machine);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_sessionOpen(vboxDriverPtr data, vboxIID *iid G_GNUC_UNUSED, IMachine *machine)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
|
|
|
return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_sessionOpenExisting(vboxDriverPtr data, vboxIID *iid G_GNUC_UNUSED, IMachine *machine)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
|
|
|
return machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Shared);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_sessionClose(ISession *session)
|
|
|
|
{
|
|
|
|
return session->vtbl->UnlockMachine(session);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_sessionGetConsole(ISession *session, IConsole **console)
|
|
|
|
{
|
|
|
|
return session->vtbl->GetConsole(session, console);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_sessionGetMachine(ISession *session, IMachine **machine)
|
|
|
|
{
|
|
|
|
return session->vtbl->GetMachine(session, machine);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_consoleSaveState(IConsole *console, IProgress **progress)
|
|
|
|
{
|
2016-06-19 11:54:23 +00:00
|
|
|
IMachine *machine;
|
|
|
|
nsresult rc;
|
|
|
|
|
|
|
|
rc = console->vtbl->GetMachine(console, &machine);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rc))
|
|
|
|
rc = machine->vtbl->SaveState(machine, progress);
|
|
|
|
else
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unable to get machine from console. (error %d)"), rc);
|
|
|
|
|
|
|
|
return rc;
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:27 +00:00
|
|
|
static nsresult
|
|
|
|
_consolePause(IConsole *console)
|
|
|
|
{
|
|
|
|
return console->vtbl->Pause(console);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:28 +00:00
|
|
|
static nsresult
|
|
|
|
_consoleResume(IConsole *console)
|
|
|
|
{
|
|
|
|
return console->vtbl->Resume(console);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:29 +00:00
|
|
|
static nsresult
|
|
|
|
_consolePowerButton(IConsole *console)
|
|
|
|
{
|
|
|
|
return console->vtbl->PowerButton(console);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:32 +00:00
|
|
|
static nsresult
|
|
|
|
_consolePowerDown(IConsole *console)
|
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
IProgress *progress = NULL;
|
|
|
|
rc = console->vtbl->PowerDown(console, &progress);
|
|
|
|
if (progress) {
|
|
|
|
rc = progress->vtbl->WaitForCompletion(progress, -1);
|
|
|
|
VBOX_RELEASE(progress);
|
|
|
|
}
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-08-11 10:06:32 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:31 +00:00
|
|
|
static nsresult
|
|
|
|
_consoleReset(IConsole *console)
|
|
|
|
{
|
|
|
|
return console->vtbl->Reset(console);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
|
|
|
_consoleTakeSnapshot(IConsole *console, PRUnichar *name,
|
|
|
|
PRUnichar *description, IProgress **progress)
|
|
|
|
{
|
2016-06-19 11:54:23 +00:00
|
|
|
IMachine *machine;
|
|
|
|
nsresult rc;
|
|
|
|
PRUnichar *id = NULL;
|
2020-01-24 20:30:04 +00:00
|
|
|
bool bpause = true; /* NO live snapshot */
|
2016-06-19 11:54:23 +00:00
|
|
|
|
|
|
|
rc = console->vtbl->GetMachine(console, &machine);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rc))
|
|
|
|
rc = machine->vtbl->TakeSnapshot(machine, name, description, bpause, &id, progress);
|
|
|
|
else
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unable to get machine from console. (error %d)"), rc);
|
|
|
|
|
|
|
|
VBOX_RELEASE(machine);
|
|
|
|
return rc;
|
2014-08-11 10:06:52 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:07:04 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_consoleDeleteSnapshot(IConsole *console, vboxIID *iid, IProgress **progress)
|
2014-08-11 10:07:04 +00:00
|
|
|
{
|
2016-06-19 11:54:23 +00:00
|
|
|
IMachine *machine;
|
|
|
|
nsresult rc;
|
|
|
|
|
|
|
|
rc = console->vtbl->GetMachine(console, &machine);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rc))
|
2016-12-29 20:34:32 +00:00
|
|
|
rc = machine->vtbl->DeleteSnapshot(machine, iid->value, progress);
|
2016-06-19 11:54:23 +00:00
|
|
|
else
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("unable to get machine from console. (error %d)"), rc);
|
|
|
|
|
|
|
|
VBOX_RELEASE(machine);
|
|
|
|
|
|
|
|
return rc;
|
2014-08-11 10:07:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:07:05 +00:00
|
|
|
static nsresult
|
|
|
|
_consoleGetDisplay(IConsole *console, IDisplay **display)
|
|
|
|
{
|
|
|
|
return console->vtbl->GetDisplay(console, display);
|
|
|
|
}
|
|
|
|
|
2015-04-07 15:37:35 +00:00
|
|
|
static nsresult
|
|
|
|
_consoleGetKeyboard(IConsole *console, IKeyboard **keyboard)
|
|
|
|
{
|
|
|
|
return console->vtbl->GetKeyboard(console, keyboard);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_progressWaitForCompletion(IProgress *progress, PRInt32 timeout)
|
|
|
|
{
|
|
|
|
return progress->vtbl->WaitForCompletion(progress, timeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_progressGetResultCode(IProgress *progress, resultCodeUnion *resultCode)
|
|
|
|
{
|
|
|
|
return progress->vtbl->GetResultCode(progress, &resultCode->resultCode);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:20 +00:00
|
|
|
static nsresult
|
|
|
|
_progressGetCompleted(IProgress *progress, PRBool *completed)
|
|
|
|
{
|
|
|
|
return progress->vtbl->GetCompleted(progress, completed);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_systemPropertiesGetMaxGuestCPUCount(ISystemProperties *systemProperties, PRUint32 *maxCPUCount)
|
|
|
|
{
|
|
|
|
return systemProperties->vtbl->GetMaxGuestCPUCount(systemProperties, maxCPUCount);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_systemPropertiesGetMaxBootPosition(ISystemProperties *systemProperties, PRUint32 *maxBootPosition)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return systemProperties->vtbl->GetMaxBootPosition(systemProperties, maxBootPosition);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_systemPropertiesGetMaxNetworkAdapters(ISystemProperties *systemProperties, PRUint32 chipset G_GNUC_UNUSED,
|
2014-08-11 10:06:19 +00:00
|
|
|
PRUint32 *maxNetworkAdapters)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2018-09-13 08:55:20 +00:00
|
|
|
return systemProperties->vtbl->GetMaxNetworkAdapters(systemProperties, chipset,
|
|
|
|
maxNetworkAdapters);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_systemPropertiesGetSerialPortCount(ISystemProperties *systemProperties, PRUint32 *SerialPortCount)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return systemProperties->vtbl->GetSerialPortCount(systemProperties, SerialPortCount);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_systemPropertiesGetParallelPortCount(ISystemProperties *systemProperties, PRUint32 *ParallelPortCount)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return systemProperties->vtbl->GetParallelPortCount(systemProperties, ParallelPortCount);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_systemPropertiesGetMaxPortCountForStorageBus(ISystemProperties *systemProperties, PRUint32 bus,
|
|
|
|
PRUint32 *maxPortCount)
|
|
|
|
{
|
|
|
|
return systemProperties->vtbl->GetMaxPortCountForStorageBus(systemProperties, bus, maxPortCount);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties *systemProperties,
|
|
|
|
PRUint32 bus, PRUint32 *maxDevicesPerPort)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return systemProperties->vtbl->GetMaxDevicesPerPortForStorageBus(systemProperties,
|
|
|
|
bus, maxDevicesPerPort);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:36 +00:00
|
|
|
static nsresult
|
|
|
|
_systemPropertiesGetMaxGuestRAM(ISystemProperties *systemProperties, PRUint32 *maxGuestRAM)
|
|
|
|
{
|
|
|
|
return systemProperties->vtbl->GetMaxGuestRAM(systemProperties, maxGuestRAM);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_biosSettingsGetACPIEnabled(IBIOSSettings *bios, PRBool *ACPIEnabled)
|
|
|
|
{
|
|
|
|
return bios->vtbl->GetACPIEnabled(bios, ACPIEnabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_biosSettingsSetACPIEnabled(IBIOSSettings *bios, PRBool ACPIEnabled)
|
|
|
|
{
|
|
|
|
return bios->vtbl->SetACPIEnabled(bios, ACPIEnabled);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_biosSettingsGetIOAPICEnabled(IBIOSSettings *bios, PRBool *IOAPICEnabled)
|
|
|
|
{
|
|
|
|
return bios->vtbl->GetIOAPICEnabled(bios, IOAPICEnabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_biosSettingsSetIOAPICEnabled(IBIOSSettings *bios, PRBool IOAPICEnabled)
|
|
|
|
{
|
|
|
|
return bios->vtbl->SetIOAPICEnabled(bios, IOAPICEnabled);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_audioAdapterGetEnabled(IAudioAdapter *audioAdapter, PRBool *enabled)
|
|
|
|
{
|
|
|
|
return audioAdapter->vtbl->GetEnabled(audioAdapter, enabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_audioAdapterSetEnabled(IAudioAdapter *audioAdapter, PRBool enabled)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return audioAdapter->vtbl->SetEnabled(audioAdapter, enabled);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_audioAdapterGetAudioController(IAudioAdapter *audioAdapter, PRUint32 *audioController)
|
|
|
|
{
|
|
|
|
return audioAdapter->vtbl->GetAudioController(audioAdapter, audioController);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_audioAdapterSetAudioController(IAudioAdapter *audioAdapter, PRUint32 audioController)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return audioAdapter->vtbl->SetAudioController(audioAdapter, audioController);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetAttachmentType(INetworkAdapter *adapter, PRUint32 *attachmentType)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetAttachmentType(adapter, attachmentType);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetEnabled(INetworkAdapter *adapter, PRBool *enabled)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetEnabled(adapter, enabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterSetEnabled(INetworkAdapter *adapter, PRBool enabled)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetEnabled(adapter, enabled);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetAdapterType(INetworkAdapter *adapter, PRUint32 *adapterType)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetAdapterType(adapter, adapterType);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterSetAdapterType(INetworkAdapter *adapter, PRUint32 adapterType)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetAdapterType(adapter, adapterType);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetInternalNetwork(INetworkAdapter *adapter, PRUnichar **internalNetwork)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetInternalNetwork(adapter, internalNetwork);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterSetInternalNetwork(INetworkAdapter *adapter, PRUnichar *internalNetwork)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetInternalNetwork(adapter, internalNetwork);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetMACAddress(INetworkAdapter *adapter, PRUnichar **MACAddress)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetMACAddress(adapter, MACAddress);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterSetMACAddress(INetworkAdapter *adapter, PRUnichar *MACAddress)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetMACAddress(adapter, MACAddress);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetBridgedInterface(INetworkAdapter *adapter, PRUnichar **bridgedInterface)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetBridgedInterface(adapter, bridgedInterface);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterSetBridgedInterface(INetworkAdapter *adapter, PRUnichar *bridgedInterface)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetBridgedInterface(adapter, bridgedInterface);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetHostOnlyInterface(INetworkAdapter *adapter, PRUnichar **hostOnlyInterface)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetHostOnlyInterface(adapter, hostOnlyInterface);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:04 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_networkAdapterSetHostOnlyInterface(INetworkAdapter *adapter, PRUnichar *hostOnlyInterface)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetHostOnlyInterface(adapter, hostOnlyInterface);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterAttachToBridgedInterface(INetworkAdapter *adapter)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_Bridged);
|
|
|
|
}
|
2014-08-11 10:06:06 +00:00
|
|
|
|
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_networkAdapterAttachToInternalNetwork(INetworkAdapter *adapter)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_Internal);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterAttachToHostOnlyInterface(INetworkAdapter *adapter)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_HostOnly);
|
|
|
|
}
|
2014-08-11 10:06:06 +00:00
|
|
|
|
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_networkAdapterAttachToNAT(INetworkAdapter *adapter)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetAttachmentType(adapter, NetworkAttachmentType_NAT);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_serialPortGetEnabled(ISerialPort *port, PRBool *enabled)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetEnabled(port, enabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:12 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_serialPortSetEnabled(ISerialPort *port, PRBool enabled)
|
2014-08-11 10:06:12 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetEnabled(port, enabled);
|
2014-08-11 10:06:12 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_serialPortGetPath(ISerialPort *port, PRUnichar **path)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetPath(port, path);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:14 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_serialPortSetPath(ISerialPort *port, PRUnichar *path)
|
2014-08-11 10:06:14 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetPath(port, path);
|
2014-08-11 10:06:14 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_serialPortGetIRQ(ISerialPort *port, PRUint32 *IRQ)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetIRQ(port, IRQ);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:14 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_serialPortSetIRQ(ISerialPort *port, PRUint32 IRQ)
|
2014-08-11 10:06:14 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetIRQ(port, IRQ);
|
2014-08-11 10:06:14 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_serialPortGetIOBase(ISerialPort *port, PRUint32 *IOBase)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetIOBase(port, IOBase);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:16 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_serialPortSetIOBase(ISerialPort *port, PRUint32 IOBase)
|
2014-08-11 10:06:16 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetIOBase(port, IOBase);
|
2014-08-11 10:06:16 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_serialPortGetHostMode(ISerialPort *port, PRUint32 *hostMode)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetHostMode(port, hostMode);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:16 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_serialPortSetHostMode(ISerialPort *port, PRUint32 hostMode)
|
2014-08-11 10:06:16 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetHostMode(port, hostMode);
|
2014-08-11 10:06:16 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_parallelPortGetEnabled(IParallelPort *port, PRBool *enabled)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetEnabled(port, enabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:18 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_parallelPortSetEnabled(IParallelPort *port, PRBool enabled)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetEnabled(port, enabled);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_parallelPortGetPath(IParallelPort *port, PRUnichar **path)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetPath(port, path);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:18 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_parallelPortSetPath(IParallelPort *port, PRUnichar *path)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetPath(port, path);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_parallelPortGetIRQ(IParallelPort *port, PRUint32 *IRQ)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetIRQ(port, IRQ);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_parallelPortSetIRQ(IParallelPort *port, PRUint32 IRQ)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetIRQ(port, IRQ);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_parallelPortGetIOBase(IParallelPort *port, PRUint32 *IOBase)
|
|
|
|
{
|
|
|
|
return port->vtbl->GetIOBase(port, IOBase);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_parallelPortSetIOBase(IParallelPort *port, PRUint32 IOBase)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return port->vtbl->SetIOBase(port, IOBase);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:30 +00:00
|
|
|
_vrdeServerGetEnabled(IVRDEServer *VRDEServer, PRBool *enabled)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
2016-12-29 20:34:30 +00:00
|
|
|
return VRDEServer->vtbl->GetEnabled(VRDEServer, enabled);
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:30 +00:00
|
|
|
_vrdeServerSetEnabled(IVRDEServer *VRDEServer, PRBool enabled)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2016-12-29 20:34:30 +00:00
|
|
|
return VRDEServer->vtbl->SetEnabled(VRDEServer, enabled);
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2014-08-11 10:06:06 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2017-10-24 21:09:17 +00:00
|
|
|
_vrdeServerGetPorts(vboxDriverPtr data, IVRDEServer *VRDEServer,
|
|
|
|
IMachine *machine, virDomainGraphicsDefPtr graphics)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
PRUnichar *VRDEPortsKey = NULL;
|
|
|
|
PRUnichar *VRDEPortsValue = NULL;
|
2017-10-24 21:09:17 +00:00
|
|
|
PRInt32 port = -1;
|
|
|
|
ssize_t nmatches = 0;
|
|
|
|
char **matches = NULL;
|
|
|
|
char *portUtf8 = NULL;
|
|
|
|
|
|
|
|
/* get active (effective) port - available only when VM is running and has
|
2020-07-09 04:42:21 +00:00
|
|
|
* the VBOX extensions installed (without extensions RDP server
|
2017-10-24 21:09:17 +00:00
|
|
|
* functionality is disabled)
|
|
|
|
*/
|
|
|
|
port = vboxGetActiveVRDEServerPort(data->vboxSession, machine);
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2017-10-24 21:09:17 +00:00
|
|
|
if (port > 0)
|
|
|
|
graphics->data.rdp.port = port;
|
|
|
|
|
|
|
|
/* get the port (or port range) set in VM properties, this info will
|
|
|
|
* be used to determine whether to set autoport flag
|
|
|
|
*/
|
2014-08-11 10:06:42 +00:00
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
|
2017-10-24 21:09:17 +00:00
|
|
|
rc = VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDEPortsKey,
|
|
|
|
&VRDEPortsValue);
|
|
|
|
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Failed to read RDP port value, rc=%08x"),
|
|
|
|
(unsigned) rc);
|
|
|
|
goto cleanup;
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2017-10-24 21:09:17 +00:00
|
|
|
VBOX_UTF16_TO_UTF8(VRDEPortsValue, &portUtf8);
|
|
|
|
|
|
|
|
if (portUtf8) {
|
|
|
|
/* does the string contain digits only */
|
|
|
|
nmatches = virStringSearch(portUtf8, "(^[[:digit:]]+$)", 1, &matches);
|
|
|
|
|
|
|
|
/* the port property is not numeric, then it must be a port range or
|
|
|
|
* port list or combination of the two, either way it's an autoport
|
|
|
|
*/
|
|
|
|
if (nmatches != 1)
|
|
|
|
graphics->data.rdp.autoport = true;
|
|
|
|
|
|
|
|
/* no active port available, e.g. VM is powered off, try to get it from
|
|
|
|
* the property string
|
|
|
|
*/
|
|
|
|
if (port < 0) {
|
|
|
|
if (nmatches == 1 && virStrToLong_i(portUtf8, NULL, 10, &port) == 0)
|
|
|
|
graphics->data.rdp.port = port;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup:
|
2020-08-02 17:36:03 +00:00
|
|
|
g_strfreev(matches);
|
2017-10-24 21:09:17 +00:00
|
|
|
VBOX_UTF8_FREE(portUtf8);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsValue);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsKey);
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:18 +00:00
|
|
|
static nsresult
|
2017-10-24 21:09:16 +00:00
|
|
|
_vrdeServerSetPorts(vboxDriverPtr data, IVRDEServer *VRDEServer,
|
|
|
|
virDomainGraphicsDefPtr graphics)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
nsresult rc = 0;
|
|
|
|
PRUnichar *VRDEPortsKey = NULL;
|
|
|
|
PRUnichar *VRDEPortsValue = NULL;
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
|
2017-10-24 21:09:16 +00:00
|
|
|
|
|
|
|
if (graphics->data.rdp.autoport)
|
|
|
|
VBOX_UTF8_TO_UTF16(VBOX_RDP_AUTOPORT_RANGE, &VRDEPortsValue);
|
|
|
|
else
|
|
|
|
VRDEPortsValue = PRUnicharFromInt(data->pFuncs,
|
|
|
|
graphics->data.rdp.port);
|
|
|
|
|
2016-12-29 20:34:30 +00:00
|
|
|
rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, VRDEPortsKey,
|
2014-08-11 10:06:19 +00:00
|
|
|
VRDEPortsValue);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsKey);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsValue);
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
return rc;
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:30 +00:00
|
|
|
_vrdeServerGetReuseSingleConnection(IVRDEServer *VRDEServer, PRBool *enabled)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
2016-12-29 20:34:30 +00:00
|
|
|
return VRDEServer->vtbl->GetReuseSingleConnection(VRDEServer, enabled);
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:30 +00:00
|
|
|
_vrdeServerSetReuseSingleConnection(IVRDEServer *VRDEServer, PRBool enabled)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2016-12-29 20:34:30 +00:00
|
|
|
return VRDEServer->vtbl->SetReuseSingleConnection(VRDEServer, enabled);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:30 +00:00
|
|
|
_vrdeServerGetAllowMultiConnection(IVRDEServer *VRDEServer, PRBool *enabled)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
2016-12-29 20:34:30 +00:00
|
|
|
return VRDEServer->vtbl->GetAllowMultiConnection(VRDEServer, enabled);
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:30 +00:00
|
|
|
_vrdeServerSetAllowMultiConnection(IVRDEServer *VRDEServer, PRBool enabled)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2016-12-29 20:34:30 +00:00
|
|
|
return VRDEServer->vtbl->SetAllowMultiConnection(VRDEServer, enabled);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_vrdeServerGetNetAddress(vboxDriverPtr data G_GNUC_UNUSED,
|
2016-12-29 20:34:30 +00:00
|
|
|
IVRDEServer *VRDEServer, PRUnichar **netAddress)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
|
|
|
PRUnichar *VRDENetAddressKey = NULL;
|
|
|
|
nsresult rc;
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Address", &VRDENetAddressKey);
|
2016-12-29 20:34:30 +00:00
|
|
|
rc = VRDEServer->vtbl->GetVRDEProperty(VRDEServer, VRDENetAddressKey, netAddress);
|
2014-08-11 10:06:42 +00:00
|
|
|
VBOX_UTF16_FREE(VRDENetAddressKey);
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_vrdeServerSetNetAddress(vboxDriverPtr data G_GNUC_UNUSED,
|
2016-12-29 20:34:30 +00:00
|
|
|
IVRDEServer *VRDEServer, PRUnichar *netAddress)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
|
|
|
PRUnichar *netAddressKey = NULL;
|
|
|
|
nsresult rc;
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Address", &netAddressKey);
|
2016-12-29 20:34:30 +00:00
|
|
|
rc = VRDEServer->vtbl->SetVRDEProperty(VRDEServer, netAddressKey,
|
2014-08-11 10:06:19 +00:00
|
|
|
netAddress);
|
|
|
|
VBOX_UTF16_FREE(netAddressKey);
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2014-08-11 10:06:06 +00:00
|
|
|
|
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_usbCommonEnable(IUSBCommon *USBCommon G_GNUC_UNUSED)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
/* We don't need to set usb enabled for vbox 4.3 and later */
|
2019-04-12 10:51:09 +00:00
|
|
|
return 0;
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_usbCommonGetEnabled(IUSBCommon *USBCommon G_GNUC_UNUSED, PRBool *enabled)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
|
|
|
*enabled = true;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:18 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_usbCommonCreateDeviceFilter(IUSBCommon *USBCommon, PRUnichar *name,
|
|
|
|
IUSBDeviceFilter **filter)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return USBCommon->vtbl->CreateDeviceFilter(USBCommon, name, filter);
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_usbCommonInsertDeviceFilter(IUSBCommon *USBCommon, PRUint32 position,
|
|
|
|
IUSBDeviceFilter *filter)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return USBCommon->vtbl->InsertDeviceFilter(USBCommon, position, filter);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_usbDeviceFilterGetProductId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar **productId)
|
|
|
|
{
|
|
|
|
return USBDeviceFilter->vtbl->GetProductId(USBDeviceFilter, productId);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_usbDeviceFilterSetProductId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar *productId)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return USBDeviceFilter->vtbl->SetProductId(USBDeviceFilter, productId);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_usbDeviceFilterGetActive(IUSBDeviceFilter *USBDeviceFilter, PRBool *active)
|
|
|
|
{
|
|
|
|
return USBDeviceFilter->vtbl->GetActive(USBDeviceFilter, active);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_usbDeviceFilterSetActive(IUSBDeviceFilter *USBDeviceFilter, PRBool active)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return USBDeviceFilter->vtbl->SetActive(USBDeviceFilter, active);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_usbDeviceFilterGetVendorId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar **vendorId)
|
|
|
|
{
|
|
|
|
return USBDeviceFilter->vtbl->GetVendorId(USBDeviceFilter, vendorId);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:12 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_usbDeviceFilterSetVendorId(IUSBDeviceFilter *USBDeviceFilter, PRUnichar *vendorId)
|
2014-08-11 10:06:12 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return USBDeviceFilter->vtbl->SetVendorId(USBDeviceFilter, vendorId);
|
|
|
|
}
|
|
|
|
|
2016-12-29 20:34:32 +00:00
|
|
|
static nsresult _mediumGetId(IMedium *medium, vboxIID *iid)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return medium->vtbl->GetId(medium, &iid->value);
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult _mediumGetLocation(IMedium *medium, PRUnichar **location)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetLocation(medium, location);
|
|
|
|
}
|
|
|
|
|
vbox: Rewrite vboxStoragePoolNumOfVolumes
We use typedef IMedium IHardDisk to make IHardDisk hierachy from
IMedium (Actually it did on vbox 2.2 and 3.0's C++ API).
So when calling
VBOX_MEDIUM_FUNC_ARG*(IHardDisk, func, args)
we can directly replace it to
gVBoxAPI.UIMedium.func(IHardDisk, args)
When dealing with this two types, we get some rules from it's
hierachy relationship.
When using IHardDisk and IMedium as input, we can't transfer a
IMedium to IHardDisk. Like:
gVBoxAPI.UIHardDisk.func(IHardDisk *hardDisk, args)
Here, we can't put a *IMedium as a argument.
When using IHardDisk and IMedium as output, we can't transfer a
IHardDisk to IMedium. Like:
gVBoxAPI.UIMachine.GetMedium(IMedium **out)
Here, we can't put a **IHardDisk as a argument. If this case
do happen, we either change the API to GetHardDisk or write a
new one.
2014-10-24 01:46:39 +00:00
|
|
|
static nsresult _mediumGetState(IMedium *medium, PRUint32 *state)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetState(medium, state);
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:40 +00:00
|
|
|
static nsresult _mediumGetName(IMedium *medium, PRUnichar **name)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetName(medium, name);
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:49 +00:00
|
|
|
static nsresult _mediumGetSize(IMedium *medium, PRUint64 *uSize)
|
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
PRInt64 Size;
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-10-24 01:46:49 +00:00
|
|
|
rc = medium->vtbl->GetSize(medium, &Size);
|
|
|
|
*uSize = Size;
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-10-24 01:46:49 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2019-10-14 12:45:33 +00:00
|
|
|
static nsresult _mediumGetReadOnly(IMedium *medium G_GNUC_UNUSED,
|
|
|
|
PRBool *readOnly G_GNUC_UNUSED)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
|
|
|
return medium->vtbl->GetReadOnly(medium, readOnly);
|
2014-08-11 10:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumGetParent(IMedium *medium,
|
|
|
|
IMedium **parent)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetParent(medium, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumGetChildren(IMedium *medium,
|
|
|
|
PRUint32 *childrenSize,
|
|
|
|
IMedium ***children)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetChildren(medium, childrenSize, children);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumGetFormat(IMedium *medium,
|
|
|
|
PRUnichar **format)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetFormat(medium, format);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumDeleteStorage(IMedium *medium,
|
|
|
|
IProgress **progress)
|
|
|
|
{
|
|
|
|
return medium->vtbl->DeleteStorage(medium, progress);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult _mediumRelease(IMedium *medium)
|
|
|
|
{
|
|
|
|
return medium->vtbl->nsisupports.Release((nsISupports *)medium);
|
|
|
|
}
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult _mediumClose(IMedium *medium)
|
|
|
|
{
|
|
|
|
return medium->vtbl->Close(medium);
|
|
|
|
}
|
2014-08-11 10:06:19 +00:00
|
|
|
|
2019-10-14 12:45:33 +00:00
|
|
|
static nsresult _mediumSetType(IMedium *medium G_GNUC_UNUSED,
|
|
|
|
PRUint32 type G_GNUC_UNUSED)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
|
|
|
return medium->vtbl->SetType(medium, type);
|
2014-08-11 10:06:12 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_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)
|
2014-08-11 10:06:52 +00:00
|
|
|
{
|
|
|
|
return medium->vtbl->CreateDiffStorage(medium, target, variantSize, variant, progress);
|
|
|
|
}
|
|
|
|
|
2016-12-29 20:34:26 +00:00
|
|
|
static nsresult
|
|
|
|
_mediumCreateBaseStorage(IMedium *medium, PRUint64 logicalSize,
|
|
|
|
PRUint32 variant, IProgress **progress)
|
|
|
|
{
|
|
|
|
return medium->vtbl->CreateBaseStorage(medium, logicalSize, 1, &variant, progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_mediumGetLogicalSize(IMedium *medium, PRUint64 *uLogicalSize)
|
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
PRInt64 logicalSize;
|
|
|
|
|
|
|
|
rc = medium->vtbl->GetLogicalSize(medium, &logicalSize);
|
|
|
|
*uLogicalSize = logicalSize;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2014-10-24 01:46:47 +00:00
|
|
|
_mediumAttachmentGetMedium(IMediumAttachment *mediumAttachment,
|
2016-12-29 20:34:26 +00:00
|
|
|
IMedium **medium)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
2016-12-29 20:34:26 +00:00
|
|
|
return mediumAttachment->vtbl->GetMedium(mediumAttachment, medium);
|
2014-08-11 10:06:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_mediumAttachmentGetController(IMediumAttachment *mediumAttachment,
|
|
|
|
PRUnichar **controller)
|
|
|
|
{
|
|
|
|
return mediumAttachment->vtbl->GetController(mediumAttachment, controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_mediumAttachmentGetType(IMediumAttachment *mediumAttachment G_GNUC_UNUSED,
|
|
|
|
PRUint32 *type G_GNUC_UNUSED)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
|
|
|
return mediumAttachment->vtbl->GetType(mediumAttachment, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_mediumAttachmentGetPort(IMediumAttachment *mediumAttachment, PRInt32 *port)
|
|
|
|
{
|
|
|
|
return mediumAttachment->vtbl->GetPort(mediumAttachment, port);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_mediumAttachmentGetDevice(IMediumAttachment *mediumAttachment, PRInt32 *device)
|
|
|
|
{
|
|
|
|
return mediumAttachment->vtbl->GetDevice(mediumAttachment, device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_storageControllerGetBus(IStorageController *storageController, PRUint32 *bus)
|
|
|
|
{
|
|
|
|
return storageController->vtbl->GetBus(storageController, bus);
|
|
|
|
}
|
|
|
|
|
2017-10-24 19:35:31 +00:00
|
|
|
static nsresult
|
|
|
|
_storageControllerGetControllerType(IStorageController *storageController, PRUint32 *controllerType)
|
|
|
|
{
|
|
|
|
return storageController->vtbl->GetControllerType(storageController, controllerType);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_storageControllerSetControllerType(IStorageController *storageController, PRUint32 controllerType)
|
|
|
|
{
|
|
|
|
return storageController->vtbl->SetControllerType(storageController, controllerType);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_sharedFolderGetHostPath(ISharedFolder *sharedFolder, PRUnichar **hostPath)
|
|
|
|
{
|
|
|
|
return sharedFolder->vtbl->GetHostPath(sharedFolder, hostPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_sharedFolderGetName(ISharedFolder *sharedFolder, PRUnichar **name)
|
|
|
|
{
|
|
|
|
return sharedFolder->vtbl->GetName(sharedFolder, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_sharedFolderGetWritable(ISharedFolder *sharedFolder, PRBool *writable)
|
|
|
|
{
|
|
|
|
return sharedFolder->vtbl->GetWritable(sharedFolder, writable);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static nsresult
|
|
|
|
_snapshotGetName(ISnapshot *snapshot, PRUnichar **name)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetName(snapshot, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_snapshotGetId(ISnapshot *snapshot, vboxIID *iid)
|
2014-08-11 10:06:54 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return snapshot->vtbl->GetId(snapshot, &iid->value);
|
2014-08-11 10:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_snapshotGetMachine(ISnapshot *snapshot, IMachine **machine)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetMachine(snapshot, machine);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_snapshotGetDescription(ISnapshot *snapshot, PRUnichar **description)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetDescription(snapshot, description);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_snapshotGetTimeStamp(ISnapshot *snapshot, PRInt64 *timeStamp)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetTimeStamp(snapshot, timeStamp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_snapshotGetParent(ISnapshot *snapshot, ISnapshot **parent)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetParent(snapshot, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_snapshotGetOnline(ISnapshot *snapshot, PRBool *online)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetOnline(snapshot, online);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:07:05 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_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)
|
2014-08-11 10:07:05 +00:00
|
|
|
{
|
2016-06-19 11:54:23 +00:00
|
|
|
PRUint32 gms;
|
|
|
|
|
|
|
|
return display->vtbl->GetScreenResolution(display, screenId, width,
|
|
|
|
height, bitsPerPixel,
|
|
|
|
xOrigin, yOrigin, &gms);
|
2014-08-11 10:07:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2016-12-29 20:34:31 +00:00
|
|
|
_displayTakeScreenShotPNGToArray(IDisplay *display, PRUint32 screenId,
|
|
|
|
PRUint32 width, PRUint32 height,
|
|
|
|
PRUint32 *screenDataSize,
|
|
|
|
PRUint8** screenData)
|
|
|
|
{
|
|
|
|
return display->vtbl->TakeScreenShotToArray(display, screenId, width,
|
|
|
|
height, BitmapFormat_PNG,
|
|
|
|
screenDataSize, screenData);
|
2014-08-11 10:07:05 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:32 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_hostFindHostNetworkInterfaceById(IHost *host, vboxIID *iid,
|
2014-10-02 03:30:32 +00:00
|
|
|
IHostNetworkInterface **networkInterface)
|
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return host->vtbl->FindHostNetworkInterfaceById(host, iid->value,
|
2014-10-02 03:30:32 +00:00
|
|
|
networkInterface);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:33 +00:00
|
|
|
static nsresult
|
|
|
|
_hostFindHostNetworkInterfaceByName(IHost *host, PRUnichar *name,
|
|
|
|
IHostNetworkInterface **networkInterface)
|
|
|
|
{
|
|
|
|
return host->vtbl->FindHostNetworkInterfaceByName(host, name,
|
|
|
|
networkInterface);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:34 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_hostCreateHostOnlyNetworkInterface(vboxDriverPtr data G_GNUC_UNUSED,
|
|
|
|
IHost *host, char *name G_GNUC_UNUSED,
|
2014-10-02 03:30:34 +00:00
|
|
|
IHostNetworkInterface **networkInterface)
|
|
|
|
{
|
|
|
|
nsresult rc = -1;
|
|
|
|
IProgress *progress = NULL;
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-10-02 03:30:34 +00:00
|
|
|
host->vtbl->CreateHostOnlyNetworkInterface(host, networkInterface,
|
|
|
|
&progress);
|
|
|
|
|
|
|
|
if (progress) {
|
|
|
|
rc = progress->vtbl->WaitForCompletion(progress, -1);
|
|
|
|
VBOX_RELEASE(progress);
|
|
|
|
}
|
2016-12-29 20:34:24 +00:00
|
|
|
|
2014-10-02 03:30:34 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:35 +00:00
|
|
|
static nsresult
|
2019-10-14 12:45:33 +00:00
|
|
|
_hostRemoveHostOnlyNetworkInterface(IHost *host G_GNUC_UNUSED,
|
|
|
|
vboxIID *iid G_GNUC_UNUSED,
|
|
|
|
IProgress **progress G_GNUC_UNUSED)
|
2014-10-02 03:30:35 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return host->vtbl->RemoveHostOnlyNetworkInterface(host, iid->value, progress);
|
2014-10-02 03:30:35 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:28 +00:00
|
|
|
static nsresult
|
|
|
|
_hnInterfaceGetInterfaceType(IHostNetworkInterface *hni, PRUint32 *interfaceType)
|
|
|
|
{
|
|
|
|
return hni->vtbl->GetInterfaceType(hni, interfaceType);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_hnInterfaceGetStatus(IHostNetworkInterface *hni, PRUint32 *status)
|
|
|
|
{
|
|
|
|
return hni->vtbl->GetStatus(hni, status);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:29 +00:00
|
|
|
static nsresult
|
|
|
|
_hnInterfaceGetName(IHostNetworkInterface *hni, PRUnichar **name)
|
|
|
|
{
|
|
|
|
return hni->vtbl->GetName(hni, name);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:33 +00:00
|
|
|
static nsresult
|
2016-12-29 20:34:32 +00:00
|
|
|
_hnInterfaceGetId(IHostNetworkInterface *hni, vboxIID *iid)
|
2014-10-02 03:30:33 +00:00
|
|
|
{
|
2016-12-29 20:34:32 +00:00
|
|
|
return hni->vtbl->GetId(hni, &iid->value);
|
2014-10-02 03:30:33 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:37 +00:00
|
|
|
static nsresult
|
|
|
|
_hnInterfaceGetHardwareAddress(IHostNetworkInterface *hni, PRUnichar **hardwareAddress)
|
|
|
|
{
|
|
|
|
return hni->vtbl->GetHardwareAddress(hni, hardwareAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_hnInterfaceGetIPAddress(IHostNetworkInterface *hni, PRUnichar **IPAddress)
|
|
|
|
{
|
|
|
|
return hni->vtbl->GetIPAddress(hni, IPAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_hnInterfaceGetNetworkMask(IHostNetworkInterface *hni, PRUnichar **networkMask)
|
|
|
|
{
|
|
|
|
return hni->vtbl->GetNetworkMask(hni, networkMask);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:34 +00:00
|
|
|
static nsresult
|
|
|
|
_hnInterfaceEnableStaticIPConfig(IHostNetworkInterface *hni, PRUnichar *IPAddress,
|
|
|
|
PRUnichar *networkMask)
|
|
|
|
{
|
|
|
|
return hni->vtbl->EnableStaticIPConfig(hni, IPAddress, networkMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_hnInterfaceEnableDynamicIPConfig(IHostNetworkInterface *hni)
|
|
|
|
{
|
|
|
|
return hni->vtbl->EnableDynamicIPConfig(hni);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_hnInterfaceDHCPRediscover(IHostNetworkInterface *hni)
|
|
|
|
{
|
|
|
|
return hni->vtbl->DHCPRediscover(hni);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:37 +00:00
|
|
|
static nsresult
|
|
|
|
_dhcpServerGetIPAddress(IDHCPServer *dhcpServer, PRUnichar **IPAddress)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->GetIPAddress(dhcpServer, IPAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_dhcpServerGetNetworkMask(IDHCPServer *dhcpServer, PRUnichar **networkMask)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->GetNetworkMask(dhcpServer, networkMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_dhcpServerGetLowerIP(IDHCPServer *dhcpServer, PRUnichar **lowerIP)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->GetLowerIP(dhcpServer, lowerIP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_dhcpServerGetUpperIP(IDHCPServer *dhcpServer, PRUnichar **upperIP)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->GetUpperIP(dhcpServer, upperIP);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:34 +00:00
|
|
|
static nsresult
|
|
|
|
_dhcpServerSetEnabled(IDHCPServer *dhcpServer, PRBool enabled)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->SetEnabled(dhcpServer, enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_dhcpServerSetConfiguration(IDHCPServer *dhcpServer, PRUnichar *IPAddress,
|
|
|
|
PRUnichar *networkMask, PRUnichar *FromIPAddress,
|
|
|
|
PRUnichar *ToIPAddress)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->SetConfiguration(dhcpServer, IPAddress,
|
|
|
|
networkMask, FromIPAddress,
|
|
|
|
ToIPAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2020-04-17 10:57:54 +00:00
|
|
|
_dhcpServerStart(IDHCPServer *dhcpServer, PRUnichar *networkName G_GNUC_UNUSED,
|
2014-10-02 03:30:34 +00:00
|
|
|
PRUnichar *trunkName, PRUnichar *trunkType)
|
|
|
|
{
|
2020-04-17 10:57:54 +00:00
|
|
|
#if VBOX_API_VERSION >= 6001000
|
|
|
|
return dhcpServer->vtbl->Start(dhcpServer,
|
|
|
|
trunkName, trunkType);
|
|
|
|
#else
|
2014-10-02 03:30:34 +00:00
|
|
|
return dhcpServer->vtbl->Start(dhcpServer, networkName,
|
|
|
|
trunkName, trunkType);
|
2020-04-17 10:57:54 +00:00
|
|
|
#endif
|
2014-10-02 03:30:34 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:35 +00:00
|
|
|
static nsresult
|
|
|
|
_dhcpServerStop(IDHCPServer *dhcpServer)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->Stop(dhcpServer);
|
|
|
|
}
|
|
|
|
|
2015-04-07 15:37:35 +00:00
|
|
|
static nsresult
|
|
|
|
_keyboardPutScancode(IKeyboard *keyboard, PRInt32 scancode)
|
|
|
|
{
|
|
|
|
return keyboard->vtbl->PutScancode(keyboard, scancode);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_keyboardPutScancodes(IKeyboard *keyboard, PRUint32 scancodesSize,
|
|
|
|
PRInt32 *scanCodes, PRUint32 *codesStored)
|
|
|
|
{
|
|
|
|
return keyboard->vtbl->PutScancodes(keyboard, scancodesSize, scanCodes,
|
|
|
|
codesStored);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:14 +00:00
|
|
|
static bool _machineStateOnline(PRUint32 state)
|
|
|
|
{
|
|
|
|
return ((state >= MachineState_FirstOnline) &&
|
|
|
|
(state <= MachineState_LastOnline));
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:44 +00:00
|
|
|
static bool _machineStateInactive(PRUint32 state)
|
|
|
|
{
|
2014-11-19 08:53:15 +00:00
|
|
|
return ((state < MachineState_FirstOnline) ||
|
|
|
|
(state > MachineState_LastOnline));
|
2014-08-11 10:06:44 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:20 +00:00
|
|
|
static bool _machineStateNotStart(PRUint32 state)
|
|
|
|
{
|
|
|
|
return ((state == MachineState_PoweredOff) ||
|
|
|
|
(state == MachineState_Saved) ||
|
|
|
|
(state == MachineState_Aborted));
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:27 +00:00
|
|
|
static bool _machineStateRunning(PRUint32 state)
|
|
|
|
{
|
|
|
|
return state == MachineState_Running;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:28 +00:00
|
|
|
static bool _machineStatePaused(PRUint32 state)
|
|
|
|
{
|
|
|
|
return state == MachineState_Paused;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:29 +00:00
|
|
|
static bool _machineStatePoweredOff(PRUint32 state)
|
|
|
|
{
|
|
|
|
return state == MachineState_PoweredOff;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:04 +00:00
|
|
|
static vboxUniformedPFN _UPFN = {
|
|
|
|
.Initialize = _pfnInitialize,
|
|
|
|
.Uninitialize = _pfnUninitialize,
|
|
|
|
.ComUnallocMem = _pfnComUnallocMem,
|
|
|
|
.Utf16Free = _pfnUtf16Free,
|
|
|
|
.Utf8Free = _pfnUtf8Free,
|
|
|
|
.Utf16ToUtf8 = _pfnUtf16ToUtf8,
|
|
|
|
.Utf8ToUtf16 = _pfnUtf8ToUtf16,
|
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static vboxUniformedIID _UIID = {
|
|
|
|
.vboxIIDInitialize = _vboxIIDInitialize,
|
|
|
|
.vboxIIDUnalloc = _vboxIIDUnalloc,
|
|
|
|
.vboxIIDToUUID = _vboxIIDToUUID,
|
|
|
|
.vboxIIDFromUUID = _vboxIIDFromUUID,
|
|
|
|
.vboxIIDIsEqual = _vboxIIDIsEqual,
|
|
|
|
.vboxIIDFromArrayItem = _vboxIIDFromArrayItem,
|
2014-08-11 10:06:52 +00:00
|
|
|
.vboxIIDToUtf8 = _vboxIIDToUtf8,
|
2014-08-11 10:06:06 +00:00
|
|
|
.DEBUGIID = _DEBUGIID,
|
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:14 +00:00
|
|
|
static vboxUniformedArray _UArray = {
|
|
|
|
.vboxArrayGet = vboxArrayGet,
|
2014-08-11 10:06:54 +00:00
|
|
|
.vboxArrayGetWithIIDArg = _vboxArrayGetWithIIDArg,
|
2014-08-11 10:06:14 +00:00
|
|
|
.vboxArrayRelease = vboxArrayRelease,
|
2014-10-24 01:46:48 +00:00
|
|
|
.vboxArrayUnalloc = vboxArrayUnalloc,
|
2014-08-11 10:06:14 +00:00
|
|
|
.handleGetMachines = _handleGetMachines,
|
vbox: Rewrite vboxStoragePoolNumOfVolumes
We use typedef IMedium IHardDisk to make IHardDisk hierachy from
IMedium (Actually it did on vbox 2.2 and 3.0's C++ API).
So when calling
VBOX_MEDIUM_FUNC_ARG*(IHardDisk, func, args)
we can directly replace it to
gVBoxAPI.UIMedium.func(IHardDisk, args)
When dealing with this two types, we get some rules from it's
hierachy relationship.
When using IHardDisk and IMedium as input, we can't transfer a
IMedium to IHardDisk. Like:
gVBoxAPI.UIHardDisk.func(IHardDisk *hardDisk, args)
Here, we can't put a *IMedium as a argument.
When using IHardDisk and IMedium as output, we can't transfer a
IHardDisk to IMedium. Like:
gVBoxAPI.UIMachine.GetMedium(IMedium **out)
Here, we can't put a **IHardDisk as a argument. If this case
do happen, we either change the API to GetHardDisk or write a
new one.
2014-10-24 01:46:39 +00:00
|
|
|
.handleGetHardDisks = _handleGetHardDisks,
|
2014-08-11 10:06:42 +00:00
|
|
|
.handleUSBGetDeviceFilters = _handleUSBGetDeviceFilters,
|
2017-10-24 19:35:31 +00:00
|
|
|
.handleMachineGetStorageControllers = _handleMachineGetStorageControllers,
|
2014-08-11 10:06:42 +00:00
|
|
|
.handleMachineGetMediumAttachments = _handleMachineGetMediumAttachments,
|
|
|
|
.handleMachineGetSharedFolders = _handleMachineGetSharedFolders,
|
2014-08-11 10:06:54 +00:00
|
|
|
.handleSnapshotGetChildren = _handleSnapshotGetChildren,
|
|
|
|
.handleMediumGetChildren = _handleMediumGetChildren,
|
|
|
|
.handleMediumGetSnapshotIds = _handleMediumGetSnapshotIds,
|
2014-10-24 01:46:48 +00:00
|
|
|
.handleMediumGetMachineIds = _handleMediumGetMachineIds,
|
2014-10-02 03:30:28 +00:00
|
|
|
.handleHostGetNetworkInterfaces = _handleHostGetNetworkInterfaces,
|
2014-08-11 10:06:14 +00:00
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static vboxUniformednsISupports _nsUISupports = {
|
|
|
|
.Release = _nsisupportsRelease,
|
2014-08-11 10:06:54 +00:00
|
|
|
.AddRef = _nsisupportsAddRef,
|
2014-08-11 10:06:06 +00:00
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:04 +00:00
|
|
|
static vboxUniformedIVirtualBox _UIVirtualBox = {
|
|
|
|
.GetVersion = _virtualboxGetVersion,
|
2014-08-11 10:06:06 +00:00
|
|
|
.GetMachine = _virtualboxGetMachine,
|
2014-08-11 10:06:52 +00:00
|
|
|
.OpenMachine = _virtualboxOpenMachine,
|
2014-08-11 10:06:12 +00:00
|
|
|
.GetSystemProperties = _virtualboxGetSystemProperties,
|
2014-10-02 03:30:28 +00:00
|
|
|
.GetHost = _virtualboxGetHost,
|
2014-08-11 10:06:19 +00:00
|
|
|
.CreateMachine = _virtualboxCreateMachine,
|
2014-10-24 01:46:45 +00:00
|
|
|
.CreateHardDisk = _virtualboxCreateHardDisk,
|
2014-08-11 10:06:19 +00:00
|
|
|
.RegisterMachine = _virtualboxRegisterMachine,
|
2014-10-24 01:46:43 +00:00
|
|
|
.FindHardDisk = _virtualboxFindHardDisk,
|
2014-08-11 10:06:19 +00:00
|
|
|
.OpenMedium = _virtualboxOpenMedium,
|
2014-10-24 01:46:42 +00:00
|
|
|
.GetHardDiskByIID = _virtualboxGetHardDiskByIID,
|
2014-10-02 03:30:34 +00:00
|
|
|
.FindDHCPServerByNetworkName = _virtualboxFindDHCPServerByNetworkName,
|
|
|
|
.CreateDHCPServer = _virtualboxCreateDHCPServer,
|
2014-10-02 03:30:35 +00:00
|
|
|
.RemoveDHCPServer = _virtualboxRemoveDHCPServer,
|
2014-08-11 10:06:06 +00:00
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:14 +00:00
|
|
|
static vboxUniformedIMachine _UIMachine = {
|
2014-08-11 10:06:19 +00:00
|
|
|
.AddStorageController = _machineAddStorageController,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetStorageControllerByName = _machineGetStorageControllerByName,
|
2014-08-11 10:06:19 +00:00
|
|
|
.AttachDevice = _machineAttachDevice,
|
|
|
|
.CreateSharedFolder = _machineCreateSharedFolder,
|
2014-08-11 10:06:50 +00:00
|
|
|
.RemoveSharedFolder = _machineRemoveSharedFolder,
|
2014-08-11 10:06:20 +00:00
|
|
|
.LaunchVMProcess = _machineLaunchVMProcess,
|
2014-08-11 10:06:52 +00:00
|
|
|
.Unregister = _machineUnregister,
|
2014-08-11 10:06:54 +00:00
|
|
|
.FindSnapshot = _machineFindSnapshot,
|
2014-10-24 01:46:48 +00:00
|
|
|
.DetachDevice = _machineDetachDevice,
|
2014-08-11 10:06:14 +00:00
|
|
|
.GetAccessible = _machineGetAccessible,
|
|
|
|
.GetState = _machineGetState,
|
2014-08-11 10:06:16 +00:00
|
|
|
.GetName = _machineGetName,
|
|
|
|
.GetId = _machineGetId,
|
2014-08-11 10:06:19 +00:00
|
|
|
.GetBIOSSettings = _machineGetBIOSSettings,
|
|
|
|
.GetAudioAdapter = _machineGetAudioAdapter,
|
|
|
|
.GetNetworkAdapter = _machineGetNetworkAdapter,
|
|
|
|
.GetChipsetType = _machineGetChipsetType,
|
|
|
|
.GetSerialPort = _machineGetSerialPort,
|
|
|
|
.GetParallelPort = _machineGetParallelPort,
|
2016-12-29 20:34:30 +00:00
|
|
|
.GetVRDEServer = _machineGetVRDEServer,
|
2014-08-11 10:06:19 +00:00
|
|
|
.GetUSBCommon = _machineGetUSBCommon,
|
2014-08-11 10:06:52 +00:00
|
|
|
.GetCurrentSnapshot = _machineGetCurrentSnapshot,
|
|
|
|
.GetSettingsFilePath = _machineGetSettingsFilePath,
|
2014-08-11 10:06:36 +00:00
|
|
|
.GetCPUCount = _machineGetCPUCount,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetCPUCount = _machineSetCPUCount,
|
2014-08-11 10:06:36 +00:00
|
|
|
.GetMemorySize = _machineGetMemorySize,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetMemorySize = _machineSetMemorySize,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetCPUProperty = _machineGetCPUProperty,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetCPUProperty = _machineSetCPUProperty,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetBootOrder = _machineGetBootOrder,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetBootOrder = _machineSetBootOrder,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetVRAMSize = _machineGetVRAMSize,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetVRAMSize = _machineSetVRAMSize,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetMonitorCount = _machineGetMonitorCount,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetMonitorCount = _machineSetMonitorCount,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetAccelerate3DEnabled = _machineGetAccelerate3DEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetAccelerate3DEnabled = _machineSetAccelerate3DEnabled,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetAccelerate2DVideoEnabled = _machineGetAccelerate2DVideoEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetAccelerate2DVideoEnabled = _machineSetAccelerate2DVideoEnabled,
|
2014-08-11 10:06:20 +00:00
|
|
|
.GetExtraData = _machineGetExtraData,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetExtraData = _machineSetExtraData,
|
2014-08-11 10:06:54 +00:00
|
|
|
.GetSnapshotCount = _machineGetSnapshotCount,
|
2014-08-11 10:06:18 +00:00
|
|
|
.SaveSettings = _machineSaveSettings,
|
2014-08-11 10:06:14 +00:00
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static vboxUniformedISession _UISession = {
|
2014-08-11 10:06:18 +00:00
|
|
|
.Open = _sessionOpen,
|
2014-08-11 10:06:06 +00:00
|
|
|
.OpenExisting = _sessionOpenExisting,
|
|
|
|
.GetConsole = _sessionGetConsole,
|
2014-08-11 10:06:18 +00:00
|
|
|
.GetMachine = _sessionGetMachine,
|
2014-08-11 10:06:06 +00:00
|
|
|
.Close = _sessionClose,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIConsole _UIConsole = {
|
|
|
|
.SaveState = _consoleSaveState,
|
2014-08-11 10:06:27 +00:00
|
|
|
.Pause = _consolePause,
|
2014-08-11 10:06:28 +00:00
|
|
|
.Resume = _consoleResume,
|
2014-08-11 10:06:29 +00:00
|
|
|
.PowerButton = _consolePowerButton,
|
2014-08-11 10:06:32 +00:00
|
|
|
.PowerDown = _consolePowerDown,
|
2014-08-11 10:06:31 +00:00
|
|
|
.Reset = _consoleReset,
|
2014-08-11 10:06:52 +00:00
|
|
|
.TakeSnapshot = _consoleTakeSnapshot,
|
2014-08-11 10:07:04 +00:00
|
|
|
.DeleteSnapshot = _consoleDeleteSnapshot,
|
2014-08-11 10:07:05 +00:00
|
|
|
.GetDisplay = _consoleGetDisplay,
|
2015-04-07 15:37:35 +00:00
|
|
|
.GetKeyboard = _consoleGetKeyboard,
|
2014-08-11 10:06:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIProgress _UIProgress = {
|
|
|
|
.WaitForCompletion = _progressWaitForCompletion,
|
|
|
|
.GetResultCode = _progressGetResultCode,
|
2014-08-11 10:06:20 +00:00
|
|
|
.GetCompleted = _progressGetCompleted,
|
2014-08-11 10:06:04 +00:00
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:12 +00:00
|
|
|
static vboxUniformedISystemProperties _UISystemProperties = {
|
|
|
|
.GetMaxGuestCPUCount = _systemPropertiesGetMaxGuestCPUCount,
|
2014-08-11 10:06:19 +00:00
|
|
|
.GetMaxBootPosition = _systemPropertiesGetMaxBootPosition,
|
|
|
|
.GetMaxNetworkAdapters = _systemPropertiesGetMaxNetworkAdapters,
|
|
|
|
.GetSerialPortCount = _systemPropertiesGetSerialPortCount,
|
|
|
|
.GetParallelPortCount = _systemPropertiesGetParallelPortCount,
|
|
|
|
.GetMaxPortCountForStorageBus = _systemPropertiesGetMaxPortCountForStorageBus,
|
|
|
|
.GetMaxDevicesPerPortForStorageBus = _systemPropertiesGetMaxDevicesPerPortForStorageBus,
|
2014-08-11 10:06:36 +00:00
|
|
|
.GetMaxGuestRAM = _systemPropertiesGetMaxGuestRAM,
|
2014-08-11 10:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIBIOSSettings _UIBIOSSettings = {
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetACPIEnabled = _biosSettingsGetACPIEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetACPIEnabled = _biosSettingsSetACPIEnabled,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetIOAPICEnabled = _biosSettingsGetIOAPICEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetIOAPICEnabled = _biosSettingsSetIOAPICEnabled,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIAudioAdapter _UIAudioAdapter = {
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetEnabled = _audioAdapterGetEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetEnabled = _audioAdapterSetEnabled,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetAudioController = _audioAdapterGetAudioController,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetAudioController = _audioAdapterSetAudioController,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedINetworkAdapter _UINetworkAdapter = {
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetAttachmentType = _networkAdapterGetAttachmentType,
|
|
|
|
.GetEnabled = _networkAdapterGetEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetEnabled = _networkAdapterSetEnabled,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetAdapterType = _networkAdapterGetAdapterType,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetAdapterType = _networkAdapterSetAdapterType,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetBridgedInterface = _networkAdapterGetBridgedInterface,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetBridgedInterface = _networkAdapterSetBridgedInterface,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetInternalNetwork = _networkAdapterGetInternalNetwork,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetInternalNetwork = _networkAdapterSetInternalNetwork,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetHostOnlyInterface = _networkAdapterGetHostOnlyInterface,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetHostOnlyInterface = _networkAdapterSetHostOnlyInterface,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetMACAddress = _networkAdapterGetMACAddress,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetMACAddress = _networkAdapterSetMACAddress,
|
|
|
|
.AttachToBridgedInterface = _networkAdapterAttachToBridgedInterface,
|
|
|
|
.AttachToInternalNetwork = _networkAdapterAttachToInternalNetwork,
|
|
|
|
.AttachToHostOnlyInterface = _networkAdapterAttachToHostOnlyInterface,
|
|
|
|
.AttachToNAT = _networkAdapterAttachToNAT,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedISerialPort _UISerialPort = {
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetEnabled = _serialPortGetEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetEnabled = _serialPortSetEnabled,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetPath = _serialPortGetPath,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetPath = _serialPortSetPath,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetIRQ = _serialPortGetIRQ,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetIRQ = _serialPortSetIRQ,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetIOBase = _serialPortGetIOBase,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetIOBase = _serialPortSetIOBase,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetHostMode = _serialPortGetHostMode,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetHostMode = _serialPortSetHostMode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIParallelPort _UIParallelPort = {
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetEnabled = _parallelPortGetEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetEnabled = _parallelPortSetEnabled,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetPath = _parallelPortGetPath,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetPath = _parallelPortSetPath,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetIRQ = _parallelPortGetIRQ,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetIRQ = _parallelPortSetIRQ,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetIOBase = _parallelPortGetIOBase,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetIOBase = _parallelPortSetIOBase,
|
|
|
|
};
|
|
|
|
|
2016-12-29 20:34:30 +00:00
|
|
|
static vboxUniformedIVRDEServer _UIVRDEServer = {
|
|
|
|
.GetEnabled = _vrdeServerGetEnabled,
|
|
|
|
.SetEnabled = _vrdeServerSetEnabled,
|
|
|
|
.GetPorts = _vrdeServerGetPorts,
|
|
|
|
.SetPorts = _vrdeServerSetPorts,
|
|
|
|
.GetReuseSingleConnection = _vrdeServerGetReuseSingleConnection,
|
|
|
|
.SetReuseSingleConnection = _vrdeServerSetReuseSingleConnection,
|
|
|
|
.GetAllowMultiConnection = _vrdeServerGetAllowMultiConnection,
|
|
|
|
.SetAllowMultiConnection = _vrdeServerSetAllowMultiConnection,
|
|
|
|
.GetNetAddress = _vrdeServerGetNetAddress,
|
|
|
|
.SetNetAddress = _vrdeServerSetNetAddress,
|
2014-08-11 10:06:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIUSBCommon _UIUSBCommon = {
|
|
|
|
.Enable = _usbCommonEnable,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetEnabled = _usbCommonGetEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.CreateDeviceFilter = _usbCommonCreateDeviceFilter,
|
|
|
|
.InsertDeviceFilter = _usbCommonInsertDeviceFilter,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIUSBDeviceFilter _UIUSBDeviceFilter = {
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetProductId = _usbDeviceFilterGetProductId,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetProductId = _usbDeviceFilterSetProductId,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetActive = _usbDeviceFilterGetActive,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetActive = _usbDeviceFilterSetActive,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetVendorId = _usbDeviceFilterGetVendorId,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetVendorId = _usbDeviceFilterSetVendorId,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIMedium _UIMedium = {
|
|
|
|
.GetId = _mediumGetId,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetLocation = _mediumGetLocation,
|
vbox: Rewrite vboxStoragePoolNumOfVolumes
We use typedef IMedium IHardDisk to make IHardDisk hierachy from
IMedium (Actually it did on vbox 2.2 and 3.0's C++ API).
So when calling
VBOX_MEDIUM_FUNC_ARG*(IHardDisk, func, args)
we can directly replace it to
gVBoxAPI.UIMedium.func(IHardDisk, args)
When dealing with this two types, we get some rules from it's
hierachy relationship.
When using IHardDisk and IMedium as input, we can't transfer a
IMedium to IHardDisk. Like:
gVBoxAPI.UIHardDisk.func(IHardDisk *hardDisk, args)
Here, we can't put a *IMedium as a argument.
When using IHardDisk and IMedium as output, we can't transfer a
IHardDisk to IMedium. Like:
gVBoxAPI.UIMachine.GetMedium(IMedium **out)
Here, we can't put a **IHardDisk as a argument. If this case
do happen, we either change the API to GetHardDisk or write a
new one.
2014-10-24 01:46:39 +00:00
|
|
|
.GetState = _mediumGetState,
|
2014-10-24 01:46:40 +00:00
|
|
|
.GetName = _mediumGetName,
|
2014-10-24 01:46:49 +00:00
|
|
|
.GetSize = _mediumGetSize,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetReadOnly = _mediumGetReadOnly,
|
2014-08-11 10:06:52 +00:00
|
|
|
.GetParent = _mediumGetParent,
|
|
|
|
.GetChildren = _mediumGetChildren,
|
|
|
|
.GetFormat = _mediumGetFormat,
|
|
|
|
.DeleteStorage = _mediumDeleteStorage,
|
2014-08-11 10:06:19 +00:00
|
|
|
.Release = _mediumRelease,
|
2014-08-11 10:06:52 +00:00
|
|
|
.Close = _mediumClose,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetType = _mediumSetType,
|
2014-08-11 10:06:52 +00:00
|
|
|
.CreateDiffStorage = _mediumCreateDiffStorage,
|
2016-12-29 20:34:26 +00:00
|
|
|
.CreateBaseStorage = _mediumCreateBaseStorage,
|
|
|
|
.GetLogicalSize = _mediumGetLogicalSize,
|
2014-08-11 10:06:12 +00:00
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static vboxUniformedIMediumAttachment _UIMediumAttachment = {
|
|
|
|
.GetMedium = _mediumAttachmentGetMedium,
|
|
|
|
.GetController = _mediumAttachmentGetController,
|
|
|
|
.GetType = _mediumAttachmentGetType,
|
|
|
|
.GetPort = _mediumAttachmentGetPort,
|
|
|
|
.GetDevice = _mediumAttachmentGetDevice,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIStorageController _UIStorageController = {
|
|
|
|
.GetBus = _storageControllerGetBus,
|
2017-10-24 19:35:31 +00:00
|
|
|
.GetControllerType = _storageControllerGetControllerType,
|
|
|
|
.SetControllerType = _storageControllerSetControllerType,
|
2014-08-11 10:06:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedISharedFolder _UISharedFolder = {
|
|
|
|
.GetHostPath = _sharedFolderGetHostPath,
|
|
|
|
.GetName = _sharedFolderGetName,
|
|
|
|
.GetWritable = _sharedFolderGetWritable,
|
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static vboxUniformedISnapshot _UISnapshot = {
|
|
|
|
.GetName = _snapshotGetName,
|
|
|
|
.GetId = _snapshotGetId,
|
|
|
|
.GetMachine = _snapshotGetMachine,
|
|
|
|
.GetDescription = _snapshotGetDescription,
|
|
|
|
.GetTimeStamp = _snapshotGetTimeStamp,
|
|
|
|
.GetParent = _snapshotGetParent,
|
|
|
|
.GetOnline = _snapshotGetOnline,
|
|
|
|
};
|
|
|
|
|
2014-08-11 10:07:05 +00:00
|
|
|
static vboxUniformedIDisplay _UIDisplay = {
|
|
|
|
.GetScreenResolution = _displayGetScreenResolution,
|
|
|
|
.TakeScreenShotPNGToArray = _displayTakeScreenShotPNGToArray,
|
|
|
|
};
|
|
|
|
|
2014-10-02 03:30:32 +00:00
|
|
|
static vboxUniformedIHost _UIHost = {
|
|
|
|
.FindHostNetworkInterfaceById = _hostFindHostNetworkInterfaceById,
|
2014-10-02 03:30:33 +00:00
|
|
|
.FindHostNetworkInterfaceByName = _hostFindHostNetworkInterfaceByName,
|
2014-10-02 03:30:34 +00:00
|
|
|
.CreateHostOnlyNetworkInterface = _hostCreateHostOnlyNetworkInterface,
|
2014-10-02 03:30:35 +00:00
|
|
|
.RemoveHostOnlyNetworkInterface = _hostRemoveHostOnlyNetworkInterface,
|
2014-10-02 03:30:32 +00:00
|
|
|
};
|
|
|
|
|
2014-10-02 03:30:28 +00:00
|
|
|
static vboxUniformedIHNInterface _UIHNInterface = {
|
|
|
|
.GetInterfaceType = _hnInterfaceGetInterfaceType,
|
|
|
|
.GetStatus = _hnInterfaceGetStatus,
|
2014-10-02 03:30:29 +00:00
|
|
|
.GetName = _hnInterfaceGetName,
|
2014-10-02 03:30:33 +00:00
|
|
|
.GetId = _hnInterfaceGetId,
|
2014-10-02 03:30:37 +00:00
|
|
|
.GetHardwareAddress = _hnInterfaceGetHardwareAddress,
|
|
|
|
.GetIPAddress = _hnInterfaceGetIPAddress,
|
|
|
|
.GetNetworkMask = _hnInterfaceGetNetworkMask,
|
2014-10-02 03:30:34 +00:00
|
|
|
.EnableStaticIPConfig = _hnInterfaceEnableStaticIPConfig,
|
|
|
|
.EnableDynamicIPConfig = _hnInterfaceEnableDynamicIPConfig,
|
|
|
|
.DHCPRediscover = _hnInterfaceDHCPRediscover,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIDHCPServer _UIDHCPServer = {
|
2014-10-02 03:30:37 +00:00
|
|
|
.GetIPAddress = _dhcpServerGetIPAddress,
|
|
|
|
.GetNetworkMask = _dhcpServerGetNetworkMask,
|
|
|
|
.GetLowerIP = _dhcpServerGetLowerIP,
|
|
|
|
.GetUpperIP = _dhcpServerGetUpperIP,
|
2014-10-02 03:30:34 +00:00
|
|
|
.SetEnabled = _dhcpServerSetEnabled,
|
|
|
|
.SetConfiguration = _dhcpServerSetConfiguration,
|
|
|
|
.Start = _dhcpServerStart,
|
2014-10-02 03:30:35 +00:00
|
|
|
.Stop = _dhcpServerStop,
|
2014-10-02 03:30:28 +00:00
|
|
|
};
|
|
|
|
|
2015-04-07 15:37:35 +00:00
|
|
|
static vboxUniformedIKeyboard _UIKeyboard = {
|
|
|
|
.PutScancode = _keyboardPutScancode,
|
|
|
|
.PutScancodes = _keyboardPutScancodes,
|
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:14 +00:00
|
|
|
static uniformedMachineStateChecker _machineStateChecker = {
|
|
|
|
.Online = _machineStateOnline,
|
2014-08-11 10:06:44 +00:00
|
|
|
.Inactive = _machineStateInactive,
|
2014-08-11 10:06:20 +00:00
|
|
|
.NotStart = _machineStateNotStart,
|
2014-08-11 10:06:27 +00:00
|
|
|
.Running = _machineStateRunning,
|
2014-08-11 10:06:28 +00:00
|
|
|
.Paused = _machineStatePaused,
|
2014-08-11 10:06:29 +00:00
|
|
|
.PoweredOff = _machineStatePoweredOff,
|
2014-08-11 10:06:14 +00:00
|
|
|
};
|
|
|
|
|
2014-08-11 10:06:04 +00:00
|
|
|
void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
|
|
|
|
{
|
|
|
|
pVBoxAPI->APIVersion = VBOX_API_VERSION;
|
|
|
|
pVBoxAPI->XPCOMCVersion = VBOX_XPCOMC_VERSION;
|
2014-08-11 10:06:18 +00:00
|
|
|
pVBoxAPI->unregisterMachine = _unregisterMachine;
|
|
|
|
pVBoxAPI->deleteConfig = _deleteConfig;
|
2014-08-11 10:06:36 +00:00
|
|
|
pVBoxAPI->vboxConvertState = _vboxConvertState;
|
2014-08-11 10:07:03 +00:00
|
|
|
pVBoxAPI->snapshotRestore = _vboxDomainSnapshotRestore;
|
2014-08-11 10:06:04 +00:00
|
|
|
pVBoxAPI->UPFN = _UPFN;
|
2014-08-11 10:06:06 +00:00
|
|
|
pVBoxAPI->UIID = _UIID;
|
2014-08-11 10:06:14 +00:00
|
|
|
pVBoxAPI->UArray = _UArray;
|
2014-08-11 10:06:06 +00:00
|
|
|
pVBoxAPI->nsUISupports = _nsUISupports;
|
2014-08-11 10:06:04 +00:00
|
|
|
pVBoxAPI->UIVirtualBox = _UIVirtualBox;
|
2014-08-11 10:06:14 +00:00
|
|
|
pVBoxAPI->UIMachine = _UIMachine;
|
2014-08-11 10:06:06 +00:00
|
|
|
pVBoxAPI->UISession = _UISession;
|
|
|
|
pVBoxAPI->UIConsole = _UIConsole;
|
|
|
|
pVBoxAPI->UIProgress = _UIProgress;
|
2014-08-11 10:06:12 +00:00
|
|
|
pVBoxAPI->UISystemProperties = _UISystemProperties;
|
2014-08-11 10:06:19 +00:00
|
|
|
pVBoxAPI->UIBIOSSettings = _UIBIOSSettings;
|
|
|
|
pVBoxAPI->UIAudioAdapter = _UIAudioAdapter;
|
|
|
|
pVBoxAPI->UINetworkAdapter = _UINetworkAdapter;
|
|
|
|
pVBoxAPI->UISerialPort = _UISerialPort;
|
|
|
|
pVBoxAPI->UIParallelPort = _UIParallelPort;
|
2016-12-29 20:34:30 +00:00
|
|
|
pVBoxAPI->UIVRDEServer = _UIVRDEServer;
|
2014-08-11 10:06:19 +00:00
|
|
|
pVBoxAPI->UIUSBCommon = _UIUSBCommon;
|
|
|
|
pVBoxAPI->UIUSBDeviceFilter = _UIUSBDeviceFilter;
|
|
|
|
pVBoxAPI->UIMedium = _UIMedium;
|
2014-08-11 10:06:42 +00:00
|
|
|
pVBoxAPI->UIMediumAttachment = _UIMediumAttachment;
|
|
|
|
pVBoxAPI->UIStorageController = _UIStorageController;
|
|
|
|
pVBoxAPI->UISharedFolder = _UISharedFolder;
|
2014-08-11 10:06:54 +00:00
|
|
|
pVBoxAPI->UISnapshot = _UISnapshot;
|
2014-08-11 10:07:05 +00:00
|
|
|
pVBoxAPI->UIDisplay = _UIDisplay;
|
2014-10-02 03:30:32 +00:00
|
|
|
pVBoxAPI->UIHost = _UIHost;
|
2014-10-02 03:30:28 +00:00
|
|
|
pVBoxAPI->UIHNInterface = _UIHNInterface;
|
2014-10-02 03:30:34 +00:00
|
|
|
pVBoxAPI->UIDHCPServer = _UIDHCPServer;
|
2015-04-07 15:37:35 +00:00
|
|
|
pVBoxAPI->UIKeyboard = _UIKeyboard;
|
2014-08-11 10:06:14 +00:00
|
|
|
pVBoxAPI->machineStateChecker = _machineStateChecker;
|
2014-08-11 10:06:04 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
pVBoxAPI->chipsetType = 1;
|
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
pVBoxAPI->vboxSnapshotRedefine = 1;
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|