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. */
|
2013-12-24 09:39:38 +00:00
|
|
|
#if VBOX_API_VERSION == 2002000
|
2009-04-17 16:09:07 +00:00
|
|
|
# include "vbox_CAPI_v2_2.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 3000000
|
2009-07-24 16:12:16 +00:00
|
|
|
# include "vbox_CAPI_v3_0.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 3001000
|
2009-12-04 13:49:45 +00:00
|
|
|
# include "vbox_CAPI_v3_1.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 3002000
|
2010-05-26 11:54:16 +00:00
|
|
|
# include "vbox_CAPI_v3_2.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 4000000
|
2010-12-27 22:35:30 +00:00
|
|
|
# include "vbox_CAPI_v4_0.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 4001000
|
2011-10-29 19:26:57 +00:00
|
|
|
# include "vbox_CAPI_v4_1.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 4002000
|
2012-10-02 09:00:54 +00:00
|
|
|
# include "vbox_CAPI_v4_2.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 4002020
|
|
|
|
# include "vbox_CAPI_v4_2_20.h"
|
|
|
|
#elif VBOX_API_VERSION == 4003000
|
2013-11-21 14:41:07 +00:00
|
|
|
# include "vbox_CAPI_v4_3.h"
|
2013-12-24 09:39:38 +00:00
|
|
|
#elif VBOX_API_VERSION == 4003004
|
|
|
|
# include "vbox_CAPI_v4_3_4.h"
|
2009-07-24 16:12:16 +00:00
|
|
|
#else
|
|
|
|
# error "Unsupport 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. */
|
2010-12-14 22:07:57 +00:00
|
|
|
#include "vbox_glue.h"
|
2014-08-11 10:06:19 +00:00
|
|
|
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
typedef IVRDPServer IVRDxServer;
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
typedef IVRDEServer IVRDxServer;
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
|
|
|
|
#if VBOX_API_VERSION < 4003000
|
|
|
|
typedef IUSBController IUSBCommon;
|
|
|
|
#else /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
typedef IUSBDeviceFilters IUSBCommon;
|
|
|
|
#endif /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
typedef IHardDiskAttachment IMediumAttachment;
|
2014-10-24 01:46:42 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
typedef IMedium IHardDisk;
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
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);
|
|
|
|
|
2013-01-24 00:34:48 +00:00
|
|
|
#define VBOX_UTF16_FREE(arg) \
|
|
|
|
do { \
|
|
|
|
if (arg) { \
|
|
|
|
data->pFuncs->pfnUtf16Free(arg); \
|
|
|
|
(arg) = NULL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define VBOX_UTF8_FREE(arg) \
|
|
|
|
do { \
|
|
|
|
if (arg) { \
|
|
|
|
data->pFuncs->pfnUtf8Free(arg); \
|
|
|
|
(arg) = NULL; \
|
|
|
|
} \
|
|
|
|
} 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)
|
|
|
|
|
2010-12-27 22:35:30 +00:00
|
|
|
#define VBOX_RELEASE(arg) \
|
|
|
|
do { \
|
|
|
|
if (arg) { \
|
|
|
|
(arg)->vtbl->nsisupports.Release((nsISupports *)(arg)); \
|
|
|
|
(arg) = NULL; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#if VBOX_API_VERSION < 3001000
|
2010-03-09 18:22:22 +00:00
|
|
|
# define VBOX_MEDIUM_RELEASE(arg) \
|
2012-10-17 09:23:12 +00:00
|
|
|
if (arg)\
|
2009-12-04 13:49:45 +00:00
|
|
|
(arg)->vtbl->imedium.nsisupports.Release((nsISupports *)(arg))
|
2013-12-24 09:39:38 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
2010-03-09 18:22:22 +00:00
|
|
|
# define VBOX_MEDIUM_RELEASE(arg) VBOX_RELEASE(arg)
|
2013-12-24 09:39:38 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
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;\
|
|
|
|
\
|
|
|
|
g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8);\
|
|
|
|
if (strUtf8) {\
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("%s: %s", msg, strUtf8);\
|
2009-07-24 16:12:16 +00:00
|
|
|
g_pVBoxGlobalData->pFuncs->pfnUtf8Free(strUtf8);\
|
|
|
|
}\
|
|
|
|
}
|
|
|
|
|
|
|
|
#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]);\
|
|
|
|
}\
|
|
|
|
|
2014-08-11 10:06:04 +00:00
|
|
|
#if VBOX_API_VERSION > 2002000
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2009-07-24 16:12:16 +00:00
|
|
|
/* g_pVBoxGlobalData has to be global variable,
|
|
|
|
* there is no other way to make the callbacks
|
|
|
|
* work other then having g_pVBoxGlobalData as
|
|
|
|
* global, because the functions namely AddRef,
|
|
|
|
* Release, etc consider it as global and you
|
|
|
|
* can't change the function definition as it
|
|
|
|
* is XPCOM nsISupport::* function and it expects
|
|
|
|
* them that way
|
|
|
|
*/
|
|
|
|
|
2014-10-28 18:38:04 +00:00
|
|
|
static vboxGlobalData *g_pVBoxGlobalData;
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#endif /* !(VBOX_API_VERSION == 2002000) */
|
2009-05-06 13:51:19 +00:00
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#if VBOX_API_VERSION < 4000000
|
2010-12-27 22:35:30 +00:00
|
|
|
|
|
|
|
# define VBOX_SESSION_OPEN(/* in */ iid_value, /* unused */ machine) \
|
|
|
|
data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, iid_value)
|
|
|
|
|
|
|
|
# define VBOX_SESSION_CLOSE() \
|
|
|
|
data->vboxSession->vtbl->Close(data->vboxSession)
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
2010-12-27 22:35:30 +00:00
|
|
|
|
|
|
|
# define VBOX_SESSION_OPEN(/* unused */ iid_value, /* in */ machine) \
|
|
|
|
machine->vtbl->LockMachine(machine, data->vboxSession, LockType_Write)
|
|
|
|
|
|
|
|
# define VBOX_SESSION_CLOSE() \
|
|
|
|
data->vboxSession->vtbl->UnlockMachine(data->vboxSession)
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
2010-12-27 22:35:30 +00:00
|
|
|
|
2014-08-11 10:06:13 +00:00
|
|
|
#if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000
|
|
|
|
/* Since vboxConnectGetCapabilities has been rewritten,
|
|
|
|
* vboxDriverLock and vboxDriverUnlock only be used in code for
|
|
|
|
* 3.x release. */
|
|
|
|
|
2014-03-18 08:18:32 +00:00
|
|
|
static void vboxDriverLock(vboxGlobalData *data)
|
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
virMutexLock(&data->lock);
|
|
|
|
}
|
|
|
|
|
2014-03-18 08:18:32 +00:00
|
|
|
static void vboxDriverUnlock(vboxGlobalData *data)
|
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
virMutexUnlock(&data->lock);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:13 +00:00
|
|
|
#endif
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#if VBOX_API_VERSION == 2002000
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-03-18 08:18:32 +00:00
|
|
|
static void nsIDtoChar(unsigned char *uuid, const nsID *iid)
|
|
|
|
{
|
2009-04-17 16:09:07 +00:00
|
|
|
char uuidstrsrc[VIR_UUID_STRING_BUFLEN];
|
|
|
|
char uuidstrdst[VIR_UUID_STRING_BUFLEN];
|
|
|
|
unsigned char uuidinterim[VIR_UUID_BUFLEN];
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2009-04-17 16:09:07 +00:00
|
|
|
|
|
|
|
memcpy(uuidinterim, iid, VIR_UUID_BUFLEN);
|
|
|
|
virUUIDFormat(uuidinterim, uuidstrsrc);
|
|
|
|
|
|
|
|
uuidstrdst[0] = uuidstrsrc[6];
|
|
|
|
uuidstrdst[1] = uuidstrsrc[7];
|
|
|
|
uuidstrdst[2] = uuidstrsrc[4];
|
|
|
|
uuidstrdst[3] = uuidstrsrc[5];
|
|
|
|
uuidstrdst[4] = uuidstrsrc[2];
|
|
|
|
uuidstrdst[5] = uuidstrsrc[3];
|
|
|
|
uuidstrdst[6] = uuidstrsrc[0];
|
|
|
|
uuidstrdst[7] = uuidstrsrc[1];
|
|
|
|
|
|
|
|
uuidstrdst[8] = uuidstrsrc[8];
|
|
|
|
|
|
|
|
uuidstrdst[9] = uuidstrsrc[11];
|
|
|
|
uuidstrdst[10] = uuidstrsrc[12];
|
|
|
|
uuidstrdst[11] = uuidstrsrc[9];
|
|
|
|
uuidstrdst[12] = uuidstrsrc[10];
|
|
|
|
|
|
|
|
uuidstrdst[13] = uuidstrsrc[13];
|
|
|
|
|
|
|
|
uuidstrdst[14] = uuidstrsrc[16];
|
|
|
|
uuidstrdst[15] = uuidstrsrc[17];
|
|
|
|
uuidstrdst[16] = uuidstrsrc[14];
|
|
|
|
uuidstrdst[17] = uuidstrsrc[15];
|
|
|
|
|
2014-11-13 14:21:37 +00:00
|
|
|
for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++)
|
2009-04-17 16:09:07 +00:00
|
|
|
uuidstrdst[i] = uuidstrsrc[i];
|
|
|
|
|
|
|
|
uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0';
|
2011-10-12 23:24:52 +00:00
|
|
|
ignore_value(virUUIDParse(uuidstrdst, uuid));
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 08:18:32 +00:00
|
|
|
static void nsIDFromChar(nsID *iid, const unsigned char *uuid)
|
|
|
|
{
|
2009-04-17 16:09:07 +00:00
|
|
|
char uuidstrsrc[VIR_UUID_STRING_BUFLEN];
|
|
|
|
char uuidstrdst[VIR_UUID_STRING_BUFLEN];
|
|
|
|
unsigned char uuidinterim[VIR_UUID_BUFLEN];
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2009-04-17 16:09:07 +00:00
|
|
|
|
|
|
|
virUUIDFormat(uuid, uuidstrsrc);
|
|
|
|
|
|
|
|
uuidstrdst[0] = uuidstrsrc[6];
|
|
|
|
uuidstrdst[1] = uuidstrsrc[7];
|
|
|
|
uuidstrdst[2] = uuidstrsrc[4];
|
|
|
|
uuidstrdst[3] = uuidstrsrc[5];
|
|
|
|
uuidstrdst[4] = uuidstrsrc[2];
|
|
|
|
uuidstrdst[5] = uuidstrsrc[3];
|
|
|
|
uuidstrdst[6] = uuidstrsrc[0];
|
|
|
|
uuidstrdst[7] = uuidstrsrc[1];
|
|
|
|
|
|
|
|
uuidstrdst[8] = uuidstrsrc[8];
|
|
|
|
|
|
|
|
uuidstrdst[9] = uuidstrsrc[11];
|
|
|
|
uuidstrdst[10] = uuidstrsrc[12];
|
|
|
|
uuidstrdst[11] = uuidstrsrc[9];
|
|
|
|
uuidstrdst[12] = uuidstrsrc[10];
|
|
|
|
|
|
|
|
uuidstrdst[13] = uuidstrsrc[13];
|
|
|
|
|
|
|
|
uuidstrdst[14] = uuidstrsrc[16];
|
|
|
|
uuidstrdst[15] = uuidstrsrc[17];
|
|
|
|
uuidstrdst[16] = uuidstrsrc[14];
|
|
|
|
uuidstrdst[17] = uuidstrsrc[15];
|
|
|
|
|
2014-11-13 14:21:37 +00:00
|
|
|
for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++)
|
2009-04-17 16:09:07 +00:00
|
|
|
uuidstrdst[i] = uuidstrsrc[i];
|
|
|
|
|
|
|
|
uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0';
|
2011-10-12 23:24:52 +00:00
|
|
|
ignore_value(virUUIDParse(uuidstrdst, uuidinterim));
|
2009-04-17 16:09:07 +00:00
|
|
|
memcpy(iid, uuidinterim, VIR_UUID_BUFLEN);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
# ifdef WIN32
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
typedef struct _vboxIID_v2_x_WIN32 vboxIID;
|
|
|
|
typedef struct _vboxIID_v2_x_WIN32 vboxIID_v2_x_WIN32;
|
|
|
|
|
|
|
|
# define VBOX_IID_INITIALIZER { { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } }
|
2014-08-11 10:06:06 +00:00
|
|
|
# define IID_MEMBER(name) (iidu->vboxIID_v2_x_WIN32.name)
|
2010-12-23 16:25:56 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
vboxIIDUnalloc_v2_x_WIN32(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
vboxIID_v2_x_WIN32 *iid ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* Nothing to free */
|
2009-09-04 14:28:52 +00:00
|
|
|
}
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDUnalloc(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
vboxIIDUnion *iid ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* Nothing to free */
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDToUUID_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid, unsigned char *uuid)
|
|
|
|
{
|
|
|
|
nsIDtoChar(uuid, (nsID *)&iid->value);
|
|
|
|
}
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDToUUID(vboxGlobalData *data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu, unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDToUUID_v2_x_WIN32(&iidu->vboxIID_v2_x_WIN32, uuid);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDFromUUID_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDUnalloc_v2_x_WIN32(data, iid);
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
nsIDFromChar((nsID *)&iid->value, uuid);
|
2009-09-04 14:28:52 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDFromUUID(vboxGlobalData *data, vboxIIDUnion *iidu,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDFromUUID_v2_x_WIN32(data, &iidu->vboxIID_v2_x_WIN32, uuid);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static bool
|
|
|
|
vboxIIDIsEqual_v2_x_WIN32(vboxIID_v2_x_WIN32 *iid1, vboxIID_v2_x_WIN32 *iid2)
|
|
|
|
{
|
2012-03-29 09:52:04 +00:00
|
|
|
return memcmp(&iid1->value, &iid2->value, sizeof(GUID)) == 0;
|
2010-12-23 16:25:56 +00:00
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static bool
|
|
|
|
_vboxIIDIsEqual(vboxGlobalData *data ATTRIBUTE_UNUSED, vboxIIDUnion *iidu1, vboxIIDUnion *iidu2)
|
|
|
|
{
|
|
|
|
return vboxIIDIsEqual_v2_x_WIN32(&iidu1->vboxIID_v2_x_WIN32, &iidu2->vboxIID_v2_x_WIN32);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDFromArrayItem_v2_x_WIN32(vboxGlobalData *data, vboxIID_v2_x_WIN32 *iid,
|
|
|
|
vboxArray *array, int idx)
|
|
|
|
{
|
|
|
|
GUID *items = (GUID *)array->items;
|
|
|
|
|
|
|
|
vboxIIDUnalloc_v2_x_WIN32(data, iid);
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memcpy(&iid->value, &items[idx], sizeof(GUID));
|
2010-12-23 16:25:56 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu,
|
|
|
|
vboxArray *array, int idx)
|
|
|
|
{
|
|
|
|
vboxIIDFromArrayItem_v2_x_WIN32(data, &iidu->vboxIID_v2_x_WIN32, array, idx);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x_WIN32(data, iid)
|
|
|
|
# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x_WIN32(iid, uuid)
|
|
|
|
# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x_WIN32(data, iid, uuid)
|
|
|
|
# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x_WIN32(iid1, iid2)
|
|
|
|
# define vboxIIDFromArrayItem(iid, array, idx) \
|
|
|
|
vboxIIDFromArrayItem_v2_x_WIN32(data, iid, array, idx)
|
|
|
|
# define DEBUGIID(msg, iid) DEBUGUUID(msg, (nsID *)&(iid))
|
|
|
|
|
|
|
|
# else /* !WIN32 */
|
|
|
|
|
|
|
|
typedef struct _vboxIID_v2_x vboxIID;
|
|
|
|
typedef struct _vboxIID_v2_x vboxIID_v2_x;
|
|
|
|
|
|
|
|
# define VBOX_IID_INITIALIZER { NULL, { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } } }
|
2014-08-11 10:06:06 +00:00
|
|
|
# define IID_MEMBER(name) (iidu->vboxIID_v2_x.name)
|
2010-12-23 16:25:56 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid)
|
|
|
|
{
|
2014-11-13 14:21:37 +00:00
|
|
|
if (iid->value == NULL)
|
2009-09-04 14:28:52 +00:00
|
|
|
return;
|
|
|
|
|
2014-11-13 14:21:37 +00:00
|
|
|
if (iid->value != &iid->backing)
|
2010-12-23 16:25:56 +00:00
|
|
|
data->pFuncs->pfnComUnallocMem(iid->value);
|
|
|
|
|
|
|
|
iid->value = NULL;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDUnalloc(vboxGlobalData *data, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
vboxIIDUnalloc_v2_x(data, &iidu->vboxIID_v2_x);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDToUUID_v2_x(vboxIID_v2_x *iid, unsigned char *uuid)
|
|
|
|
{
|
|
|
|
nsIDtoChar(uuid, iid->value);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDToUUID(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
vboxIIDUnion *iidu, unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDToUUID_v2_x(&iidu->vboxIID_v2_x, uuid);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDFromUUID_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDUnalloc_v2_x(data, iid);
|
|
|
|
|
|
|
|
iid->value = &iid->backing;
|
|
|
|
|
2013-01-24 00:34:47 +00:00
|
|
|
sa_assert(iid->value);
|
2010-12-23 16:25:56 +00:00
|
|
|
nsIDFromChar(iid->value, uuid);
|
2009-09-04 14:28:52 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDFromUUID(vboxGlobalData *data, vboxIIDUnion *iidu,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDFromUUID_v2_x(data, &iidu->vboxIID_v2_x, uuid);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static bool
|
|
|
|
vboxIIDIsEqual_v2_x(vboxIID_v2_x *iid1, vboxIID_v2_x *iid2)
|
|
|
|
{
|
2012-03-29 09:52:04 +00:00
|
|
|
return memcmp(iid1->value, iid2->value, sizeof(nsID)) == 0;
|
2010-12-23 16:25:56 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static bool
|
|
|
|
_vboxIIDIsEqual(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
vboxIIDUnion *iidu1, vboxIIDUnion *iidu2)
|
|
|
|
{
|
|
|
|
return vboxIIDIsEqual_v2_x(&iidu1->vboxIID_v2_x, &iidu2->vboxIID_v2_x);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDFromArrayItem_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid,
|
|
|
|
vboxArray *array, int idx)
|
|
|
|
{
|
|
|
|
vboxIIDUnalloc_v2_x(data, iid);
|
|
|
|
|
|
|
|
iid->value = &iid->backing;
|
|
|
|
|
2012-03-29 09:52:04 +00:00
|
|
|
memcpy(iid->value, array->items[idx], sizeof(nsID));
|
2010-12-23 16:25:56 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu,
|
|
|
|
vboxArray *array, int idx)
|
|
|
|
{
|
|
|
|
vboxIIDFromArrayItem_v2_x(data, &iidu->vboxIID_v2_x, array, idx);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v2_x(data, iid)
|
|
|
|
# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v2_x(iid, uuid)
|
|
|
|
# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v2_x(data, iid, uuid)
|
|
|
|
# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v2_x(iid1, iid2)
|
|
|
|
# define vboxIIDFromArrayItem(iid, array, idx) \
|
|
|
|
vboxIIDFromArrayItem_v2_x(data, iid, array, idx)
|
|
|
|
# define DEBUGIID(msg, iid) DEBUGUUID(msg, iid)
|
|
|
|
|
|
|
|
# endif /* !WIN32 */
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#else /* VBOX_API_VERSION != 2002000 */
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
typedef struct _vboxIID_v3_x vboxIID;
|
|
|
|
typedef struct _vboxIID_v3_x vboxIID_v3_x;
|
|
|
|
|
|
|
|
# define VBOX_IID_INITIALIZER { NULL, true }
|
2014-08-11 10:06:06 +00:00
|
|
|
# define IID_MEMBER(name) (iidu->vboxIID_v3_x.name)
|
2010-12-23 16:25:56 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid)
|
|
|
|
{
|
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
|
|
|
|
_vboxIIDUnalloc(vboxGlobalData *data, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
vboxIIDUnalloc_v3_x(data, &iidu->vboxIID_v3_x);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDToUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
|
|
|
|
unsigned char *uuid)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
_vboxIIDToUUID(vboxGlobalData *data, vboxIIDUnion *iidu,
|
|
|
|
unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDToUUID_v3_x(data, &iidu->vboxIID_v3_x, uuid);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDFromUUID_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
char utf8[VIR_UUID_STRING_BUFLEN];
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIIDUnalloc_v3_x(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
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDFromUUID(vboxGlobalData *data, vboxIIDUnion *iidu,
|
|
|
|
const unsigned char *uuid)
|
|
|
|
{
|
|
|
|
vboxIIDFromUUID_v3_x(data, &iidu->vboxIID_v3_x, uuid);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static bool
|
|
|
|
vboxIIDIsEqual_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid1,
|
|
|
|
vboxIID_v3_x *iid2)
|
|
|
|
{
|
|
|
|
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. */
|
|
|
|
vboxIIDToUUID_v3_x(data, iid1, uuid1);
|
|
|
|
vboxIIDToUUID_v3_x(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
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static bool
|
|
|
|
_vboxIIDIsEqual(vboxGlobalData *data, vboxIIDUnion *iidu1,
|
|
|
|
vboxIIDUnion *iidu2)
|
|
|
|
{
|
|
|
|
return vboxIIDIsEqual_v3_x(data, &iidu1->vboxIID_v3_x, &iidu2->vboxIID_v3_x);
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
static void
|
|
|
|
vboxIIDFromArrayItem_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid,
|
|
|
|
vboxArray *array, int idx)
|
|
|
|
{
|
|
|
|
vboxIIDUnalloc_v3_x(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
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDFromArrayItem(vboxGlobalData *data, vboxIIDUnion *iidu,
|
|
|
|
vboxArray *array, int idx)
|
|
|
|
{
|
|
|
|
vboxIIDFromArrayItem_v3_x(data, &iidu->vboxIID_v3_x, array, idx);
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
# define vboxIIDUnalloc(iid) vboxIIDUnalloc_v3_x(data, iid)
|
|
|
|
# define vboxIIDToUUID(iid, uuid) vboxIIDToUUID_v3_x(data, iid, uuid)
|
|
|
|
# define vboxIIDFromUUID(iid, uuid) vboxIIDFromUUID_v3_x(data, iid, uuid)
|
|
|
|
# define vboxIIDIsEqual(iid1, iid2) vboxIIDIsEqual_v3_x(data, iid1, iid2)
|
|
|
|
# define vboxIIDFromArrayItem(iid, array, idx) \
|
|
|
|
vboxIIDFromArrayItem_v3_x(data, iid, array, idx)
|
|
|
|
# define DEBUGIID(msg, strUtf16) DEBUGPRUnichar(msg, strUtf16)
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#endif /* !(VBOX_API_VERSION == 2002000) */
|
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
/**
|
|
|
|
* function to get the StorageBus, Port number
|
|
|
|
* and Device number for the given devicename
|
|
|
|
* e.g: hda has StorageBus = IDE, port = 0,
|
|
|
|
* device = 0
|
|
|
|
*
|
|
|
|
* @returns true on Success, false on failure.
|
|
|
|
* @param deviceName Input device name
|
|
|
|
* @param aMaxPortPerInst Input array of max port per device instance
|
|
|
|
* @param aMaxSlotPerPort Input array of max slot per device port
|
|
|
|
* @param storageBus Input storage bus type
|
|
|
|
* @param deviceInst Output device instance number
|
|
|
|
* @param devicePort Output port number
|
|
|
|
* @param deviceSlot Output slot number
|
|
|
|
*
|
|
|
|
*/
|
2014-08-11 10:06:43 +00:00
|
|
|
#if VBOX_API_VERSION >= 3001000
|
2014-08-11 10:06:19 +00:00
|
|
|
# if VBOX_API_VERSION < 4000000
|
|
|
|
/* Only 3.x will use this function. */
|
2009-12-04 13:49:45 +00:00
|
|
|
static bool vboxGetDeviceDetails(const char *deviceName,
|
|
|
|
PRUint32 *aMaxPortPerInst,
|
|
|
|
PRUint32 *aMaxSlotPerPort,
|
|
|
|
PRUint32 storageBus,
|
|
|
|
PRInt32 *deviceInst,
|
|
|
|
PRInt32 *devicePort,
|
|
|
|
PRInt32 *deviceSlot) {
|
|
|
|
int total = 0;
|
|
|
|
PRUint32 maxPortPerInst = 0;
|
|
|
|
PRUint32 maxSlotPerPort = 0;
|
|
|
|
|
2012-10-17 09:23:12 +00:00
|
|
|
if (!deviceName ||
|
|
|
|
!deviceInst ||
|
|
|
|
!devicePort ||
|
|
|
|
!deviceSlot ||
|
|
|
|
!aMaxPortPerInst ||
|
|
|
|
!aMaxSlotPerPort)
|
2009-12-04 13:49:45 +00:00
|
|
|
return false;
|
|
|
|
|
2012-10-17 09:23:12 +00:00
|
|
|
if ((storageBus < StorageBus_IDE) ||
|
|
|
|
(storageBus > StorageBus_Floppy))
|
2009-12-04 13:49:45 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
total = virDiskNameToIndex(deviceName);
|
|
|
|
|
|
|
|
maxPortPerInst = aMaxPortPerInst[storageBus];
|
|
|
|
maxSlotPerPort = aMaxSlotPerPort[storageBus];
|
|
|
|
|
2012-10-17 09:23:12 +00:00
|
|
|
if (!maxPortPerInst ||
|
|
|
|
!maxSlotPerPort ||
|
|
|
|
(total < 0))
|
2009-12-04 13:49:45 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
*deviceInst = total / (maxPortPerInst * maxSlotPerPort);
|
|
|
|
*devicePort = (total % (maxPortPerInst * maxSlotPerPort)) / maxSlotPerPort;
|
|
|
|
*deviceSlot = (total % (maxPortPerInst * maxSlotPerPort)) % maxSlotPerPort;
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("name=%s, total=%d, storageBus=%u, deviceInst=%d, "
|
2009-12-04 13:49:45 +00:00
|
|
|
"devicePort=%d deviceSlot=%d, maxPortPerInst=%u maxSlotPerPort=%u",
|
|
|
|
deviceName, total, storageBus, *deviceInst, *devicePort,
|
|
|
|
*deviceSlot, maxPortPerInst, maxSlotPerPort);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* function to get the values for max port per
|
|
|
|
* instance and max slots per port for the devices
|
|
|
|
*
|
|
|
|
* @returns true on Success, false on failure.
|
|
|
|
* @param vbox Input IVirtualBox pointer
|
|
|
|
* @param maxPortPerInst Output array of max port per instance
|
|
|
|
* @param maxSlotPerPort Output array of max slot per port
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
/* This function would not be used in 4.1 and later since
|
|
|
|
* vboxDomainSnapshotGetXMLDesc is written*/
|
2009-12-04 13:49:45 +00:00
|
|
|
static bool vboxGetMaxPortSlotValues(IVirtualBox *vbox,
|
|
|
|
PRUint32 *maxPortPerInst,
|
2014-03-18 08:18:32 +00:00
|
|
|
PRUint32 *maxSlotPerPort)
|
|
|
|
{
|
2009-12-04 13:49:45 +00:00
|
|
|
ISystemProperties *sysProps = NULL;
|
|
|
|
|
|
|
|
if (!vbox)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
vbox->vtbl->GetSystemProperties(vbox, &sysProps);
|
|
|
|
|
|
|
|
if (!sysProps)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps,
|
|
|
|
StorageBus_IDE,
|
|
|
|
&maxPortPerInst[StorageBus_IDE]);
|
|
|
|
sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps,
|
|
|
|
StorageBus_SATA,
|
|
|
|
&maxPortPerInst[StorageBus_SATA]);
|
|
|
|
sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps,
|
|
|
|
StorageBus_SCSI,
|
|
|
|
&maxPortPerInst[StorageBus_SCSI]);
|
|
|
|
sysProps->vtbl->GetMaxPortCountForStorageBus(sysProps,
|
|
|
|
StorageBus_Floppy,
|
|
|
|
&maxPortPerInst[StorageBus_Floppy]);
|
|
|
|
|
|
|
|
sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps,
|
|
|
|
StorageBus_IDE,
|
|
|
|
&maxSlotPerPort[StorageBus_IDE]);
|
|
|
|
sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps,
|
|
|
|
StorageBus_SATA,
|
|
|
|
&maxSlotPerPort[StorageBus_SATA]);
|
|
|
|
sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps,
|
|
|
|
StorageBus_SCSI,
|
|
|
|
&maxSlotPerPort[StorageBus_SCSI]);
|
|
|
|
sysProps->vtbl->GetMaxDevicesPerPortForStorageBus(sysProps,
|
|
|
|
StorageBus_Floppy,
|
|
|
|
&maxSlotPerPort[StorageBus_Floppy]);
|
|
|
|
|
|
|
|
VBOX_RELEASE(sysProps);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-11 10:06:54 +00:00
|
|
|
# endif /* VBOX_API_VERSION < 4000000 */
|
2009-12-04 13:49:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts Utf-16 string to int
|
|
|
|
*/
|
2014-03-18 08:18:32 +00:00
|
|
|
static int PRUnicharToInt(PRUnichar *strUtf16)
|
|
|
|
{
|
2009-12-04 13:49:45 +00:00
|
|
|
char *strUtf8 = NULL;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!strUtf16)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(strUtf16, &strUtf8);
|
|
|
|
if (!strUtf8)
|
|
|
|
return -1;
|
|
|
|
|
2010-03-30 14:27:20 +00:00
|
|
|
if (virStrToLong_i(strUtf8, NULL, 10, &ret) < 0)
|
|
|
|
ret = -1;
|
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
g_pVBoxGlobalData->pFuncs->pfnUtf8Free(strUtf8);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts int to Utf-16 string
|
|
|
|
*/
|
|
|
|
static PRUnichar *PRUnicharFromInt(int n) {
|
|
|
|
PRUnichar *strUtf16 = NULL;
|
|
|
|
char s[24];
|
|
|
|
|
|
|
|
snprintf(s, sizeof(s), "%d", n);
|
|
|
|
|
|
|
|
g_pVBoxGlobalData->pFuncs->pfnUtf8ToUtf16(s, &strUtf16);
|
|
|
|
|
|
|
|
return strUtf16;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
2009-07-24 16:12:16 +00:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#if VBOX_API_VERSION < 3001000
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
static void
|
2014-08-11 10:06:19 +00:00
|
|
|
_vboxAttachDrivesOld(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
2010-08-31 18:01:45 +00:00
|
|
|
{
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
size_t i;
|
2010-08-31 18:01:45 +00:00
|
|
|
nsresult rc;
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (def->ndisks == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < def->ndisks; i++) {
|
2014-03-18 21:12:57 +00:00
|
|
|
const char *src = virDomainDiskGetSource(def->disks[i]);
|
|
|
|
int type = virDomainDiskGetType(def->disks[i]);
|
|
|
|
int format = virDomainDiskGetFormat(def->disks[i]);
|
|
|
|
|
|
|
|
VIR_DEBUG("disk(%zu) type: %d", i, type);
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) device: %d", i, def->disks[i]->device);
|
|
|
|
VIR_DEBUG("disk(%zu) bus: %d", i, def->disks[i]->bus);
|
2014-03-18 21:12:57 +00:00
|
|
|
VIR_DEBUG("disk(%zu) src: %s", i, src);
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) dst: %s", i, def->disks[i]->dst);
|
2014-03-18 21:12:57 +00:00
|
|
|
VIR_DEBUG("disk(%zu) driverName: %s", i,
|
|
|
|
virDomainDiskGetDriver(def->disks[i]));
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) driverType: %s", i,
|
2014-03-18 21:12:57 +00:00
|
|
|
virStorageFileFormatTypeToString(format));
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) cachemode: %d", i, def->disks[i]->cachemode);
|
2014-06-24 13:15:55 +00:00
|
|
|
VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->src->readonly
|
2010-08-31 18:01:45 +00:00
|
|
|
? "True" : "False"));
|
2014-06-24 13:15:55 +00:00
|
|
|
VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->src->shared
|
2010-08-31 18:01:45 +00:00
|
|
|
? "True" : "False"));
|
|
|
|
|
|
|
|
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type == VIR_STORAGE_TYPE_FILE && src) {
|
2010-08-31 18:01:45 +00:00
|
|
|
IDVDDrive *dvdDrive = NULL;
|
|
|
|
/* Currently CDROM/DVD Drive is always IDE
|
|
|
|
* Secondary Master so neglecting the following
|
|
|
|
* parameters:
|
|
|
|
* def->disks[i]->bus
|
|
|
|
* def->disks[i]->dst
|
|
|
|
*/
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
machine->vtbl->GetDVDDrive(machine, &dvdDrive);
|
|
|
|
if (dvdDrive) {
|
|
|
|
IDVDImage *dvdImage = NULL;
|
|
|
|
PRUnichar *dvdfileUtf16 = NULL;
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIID dvduuid = VBOX_IID_INITIALIZER;
|
|
|
|
vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER;
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2014-03-18 21:12:57 +00:00
|
|
|
VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16);
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
data->vboxObj->vtbl->FindDVDImage(data->vboxObj,
|
|
|
|
dvdfileUtf16, &dvdImage);
|
|
|
|
if (!dvdImage) {
|
|
|
|
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
|
|
|
|
dvdfileUtf16,
|
2010-12-23 16:25:56 +00:00
|
|
|
dvdemptyuuid.value,
|
2010-08-31 18:01:45 +00:00
|
|
|
&dvdImage);
|
|
|
|
}
|
|
|
|
if (dvdImage) {
|
|
|
|
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage,
|
2010-12-23 16:25:56 +00:00
|
|
|
&dvduuid.value);
|
2010-08-31 18:01:45 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("can't get the uuid of the file to "
|
|
|
|
"be attached to cdrom: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else {
|
2010-12-23 16:25:56 +00:00
|
|
|
rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value);
|
2010-08-31 18:01:45 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not attach the file to cdrom: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else {
|
2010-12-23 16:25:56 +00:00
|
|
|
DEBUGIID("CD/DVDImage UUID:", dvduuid.value);
|
2009-12-04 13:49:45 +00:00
|
|
|
}
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
|
|
|
|
VBOX_MEDIUM_RELEASE(dvdImage);
|
2009-12-04 13:49:45 +00:00
|
|
|
}
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIIDUnalloc(&dvduuid);
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF16_FREE(dvdfileUtf16);
|
|
|
|
VBOX_RELEASE(dvdDrive);
|
|
|
|
}
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
} else if (type == VIR_STORAGE_TYPE_BLOCK) {
|
2010-08-31 18:01:45 +00:00
|
|
|
}
|
|
|
|
} else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type == VIR_STORAGE_TYPE_FILE && src) {
|
2010-08-31 18:01:45 +00:00
|
|
|
IHardDisk *hardDisk = NULL;
|
|
|
|
PRUnichar *hddfileUtf16 = NULL;
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIID hdduuid = VBOX_IID_INITIALIZER;
|
2010-08-31 18:01:45 +00:00
|
|
|
PRUnichar *hddEmpty = NULL;
|
|
|
|
/* Current Limitation: Harddisk can't be connected to
|
|
|
|
* Secondary Master as Secondary Master is always used
|
|
|
|
* for CD/DVD Drive, so don't connect the harddisk if it
|
|
|
|
* is requested to be connected to Secondary master
|
|
|
|
*/
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2014-03-18 21:12:57 +00:00
|
|
|
VBOX_UTF8_TO_UTF16(src, &hddfileUtf16);
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF8_TO_UTF16("", &hddEmpty);
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
data->vboxObj->vtbl->FindHardDisk(data->vboxObj, hddfileUtf16,
|
|
|
|
&hardDisk);
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (!hardDisk) {
|
2013-12-24 09:39:38 +00:00
|
|
|
# if VBOX_API_VERSION == 2002000
|
2010-08-31 18:01:45 +00:00
|
|
|
data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
|
|
|
|
hddfileUtf16,
|
|
|
|
AccessMode_ReadWrite,
|
|
|
|
&hardDisk);
|
2010-03-09 18:22:22 +00:00
|
|
|
# else
|
2010-08-31 18:01:45 +00:00
|
|
|
data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
|
|
|
|
hddfileUtf16,
|
|
|
|
AccessMode_ReadWrite,
|
|
|
|
0,
|
|
|
|
hddEmpty,
|
|
|
|
0,
|
|
|
|
hddEmpty,
|
|
|
|
&hardDisk);
|
2010-03-09 18:22:22 +00:00
|
|
|
# endif
|
2010-08-31 18:01:45 +00:00
|
|
|
}
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (hardDisk) {
|
|
|
|
rc = hardDisk->vtbl->imedium.GetId((IMedium *)hardDisk,
|
2010-12-23 16:25:56 +00:00
|
|
|
&hdduuid.value);
|
2010-08-31 18:01:45 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("can't get the uuid of the file to be "
|
|
|
|
"attached as harddisk: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else {
|
2014-06-24 13:15:55 +00:00
|
|
|
if (def->disks[i]->src->readonly) {
|
2010-08-31 18:01:45 +00:00
|
|
|
hardDisk->vtbl->SetType(hardDisk,
|
|
|
|
HardDiskType_Immutable);
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("setting harddisk to readonly");
|
2014-06-24 13:15:55 +00:00
|
|
|
} else if (!def->disks[i]->src->readonly) {
|
2010-08-31 18:01:45 +00:00
|
|
|
hardDisk->vtbl->SetType(hardDisk,
|
|
|
|
HardDiskType_Normal);
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("setting harddisk type to normal");
|
2010-08-31 18:01:45 +00:00
|
|
|
}
|
|
|
|
if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_IDE) {
|
|
|
|
if (STREQ(def->disks[i]->dst, "hdc")) {
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("Not connecting harddisk to hdc as hdc"
|
2010-08-31 18:01:45 +00:00
|
|
|
" is taken by CD/DVD Drive");
|
2009-12-04 13:49:45 +00:00
|
|
|
} else {
|
2010-08-31 18:01:45 +00:00
|
|
|
PRInt32 channel = 0;
|
|
|
|
PRInt32 device = 0;
|
|
|
|
PRUnichar *hddcnameUtf16 = NULL;
|
|
|
|
|
2013-05-03 12:50:19 +00:00
|
|
|
char *hddcname;
|
|
|
|
ignore_value(VIR_STRDUP(hddcname, "IDE"));
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF8_TO_UTF16(hddcname, &hddcnameUtf16);
|
|
|
|
VIR_FREE(hddcname);
|
|
|
|
|
|
|
|
if (STREQ(def->disks[i]->dst, "hda")) {
|
|
|
|
channel = 0;
|
|
|
|
device = 0;
|
|
|
|
} else if (STREQ(def->disks[i]->dst, "hdb")) {
|
|
|
|
channel = 0;
|
|
|
|
device = 1;
|
|
|
|
} else if (STREQ(def->disks[i]->dst, "hdd")) {
|
|
|
|
channel = 1;
|
|
|
|
device = 1;
|
2009-12-04 13:49:45 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
|
|
|
|
rc = machine->vtbl->AttachHardDisk(machine,
|
2010-12-23 16:25:56 +00:00
|
|
|
hdduuid.value,
|
2010-08-31 18:01:45 +00:00
|
|
|
hddcnameUtf16,
|
|
|
|
channel,
|
|
|
|
device);
|
|
|
|
VBOX_UTF16_FREE(hddcnameUtf16);
|
|
|
|
|
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not attach the file as "
|
|
|
|
"harddisk: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else {
|
2010-12-23 16:25:56 +00:00
|
|
|
DEBUGIID("Attached HDD with UUID", hdduuid.value);
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_MEDIUM_RELEASE(hardDisk);
|
|
|
|
}
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIIDUnalloc(&hdduuid);
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF16_FREE(hddEmpty);
|
|
|
|
VBOX_UTF16_FREE(hddfileUtf16);
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
} else if (type == VIR_STORAGE_TYPE_BLOCK) {
|
2010-08-31 18:01:45 +00:00
|
|
|
}
|
|
|
|
} else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type == VIR_STORAGE_TYPE_FILE && src) {
|
2010-08-31 18:01:45 +00:00
|
|
|
IFloppyDrive *floppyDrive;
|
|
|
|
machine->vtbl->GetFloppyDrive(machine, &floppyDrive);
|
|
|
|
if (floppyDrive) {
|
|
|
|
rc = floppyDrive->vtbl->SetEnabled(floppyDrive, 1);
|
|
|
|
if (NS_SUCCEEDED(rc)) {
|
|
|
|
IFloppyImage *floppyImage = NULL;
|
|
|
|
PRUnichar *fdfileUtf16 = NULL;
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIID fduuid = VBOX_IID_INITIALIZER;
|
|
|
|
vboxIID fdemptyuuid = VBOX_IID_INITIALIZER;
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2014-03-18 21:12:57 +00:00
|
|
|
VBOX_UTF8_TO_UTF16(src, &fdfileUtf16);
|
2010-08-31 18:01:45 +00:00
|
|
|
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
|
|
|
|
fdfileUtf16,
|
|
|
|
&floppyImage);
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (!floppyImage) {
|
|
|
|
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
|
|
|
|
fdfileUtf16,
|
2010-12-23 16:25:56 +00:00
|
|
|
fdemptyuuid.value,
|
2010-08-31 18:01:45 +00:00
|
|
|
&floppyImage);
|
|
|
|
}
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (floppyImage) {
|
|
|
|
rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage,
|
2010-12-23 16:25:56 +00:00
|
|
|
&fduuid.value);
|
2010-08-31 18:01:45 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("can't get the uuid of the file to "
|
|
|
|
"be attached to floppy drive: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else {
|
|
|
|
rc = floppyDrive->vtbl->MountImage(floppyDrive,
|
2010-12-23 16:25:56 +00:00
|
|
|
fduuid.value);
|
2010-08-31 18:01:45 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not attach the file to "
|
|
|
|
"floppy drive: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else {
|
2010-12-23 16:25:56 +00:00
|
|
|
DEBUGIID("floppyImage UUID", fduuid.value);
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_MEDIUM_RELEASE(floppyImage);
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIIDUnalloc(&fduuid);
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF16_FREE(fdfileUtf16);
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_RELEASE(floppyDrive);
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
} else if (type == VIR_STORAGE_TYPE_BLOCK) {
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
}
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#elif VBOX_API_VERSION < 4000000
|
|
|
|
|
|
|
|
static void
|
|
|
|
_vboxAttachDrivesOld(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
nsresult rc;
|
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
PRUint32 maxPortPerInst[StorageBus_Floppy + 1] = {};
|
|
|
|
PRUint32 maxSlotPerPort[StorageBus_Floppy + 1] = {};
|
|
|
|
PRUnichar *storageCtlName = NULL;
|
|
|
|
bool error = false;
|
|
|
|
|
|
|
|
/* get the max port/slots/etc for the given storage bus */
|
|
|
|
error = !vboxGetMaxPortSlotValues(data->vboxObj, maxPortPerInst,
|
|
|
|
maxSlotPerPort);
|
|
|
|
|
|
|
|
/* add a storage controller for the mediums to be attached */
|
|
|
|
/* this needs to change when multiple controller are supported for
|
|
|
|
* ver > 3.1 */
|
2009-12-04 13:49:45 +00:00
|
|
|
{
|
2010-08-31 18:01:45 +00:00
|
|
|
IStorageController *storageCtl = NULL;
|
|
|
|
PRUnichar *sName = NULL;
|
|
|
|
|
|
|
|
VBOX_UTF8_TO_UTF16("IDE Controller", &sName);
|
|
|
|
machine->vtbl->AddStorageController(machine,
|
|
|
|
sName,
|
|
|
|
StorageBus_IDE,
|
|
|
|
&storageCtl);
|
|
|
|
VBOX_UTF16_FREE(sName);
|
|
|
|
VBOX_RELEASE(storageCtl);
|
|
|
|
|
|
|
|
VBOX_UTF8_TO_UTF16("SATA Controller", &sName);
|
|
|
|
machine->vtbl->AddStorageController(machine,
|
|
|
|
sName,
|
|
|
|
StorageBus_SATA,
|
|
|
|
&storageCtl);
|
|
|
|
VBOX_UTF16_FREE(sName);
|
|
|
|
VBOX_RELEASE(storageCtl);
|
|
|
|
|
|
|
|
VBOX_UTF8_TO_UTF16("SCSI Controller", &sName);
|
|
|
|
machine->vtbl->AddStorageController(machine,
|
|
|
|
sName,
|
|
|
|
StorageBus_SCSI,
|
|
|
|
&storageCtl);
|
|
|
|
VBOX_UTF16_FREE(sName);
|
|
|
|
VBOX_RELEASE(storageCtl);
|
|
|
|
|
|
|
|
VBOX_UTF8_TO_UTF16("Floppy Controller", &sName);
|
|
|
|
machine->vtbl->AddStorageController(machine,
|
|
|
|
sName,
|
|
|
|
StorageBus_Floppy,
|
|
|
|
&storageCtl);
|
|
|
|
VBOX_UTF16_FREE(sName);
|
|
|
|
VBOX_RELEASE(storageCtl);
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
for (i = 0; i < def->ndisks && !error; i++) {
|
2014-03-18 21:12:57 +00:00
|
|
|
const char *src = virDomainDiskGetSource(def->disks[i]);
|
|
|
|
int type = virDomainDiskGetType(def->disks[i]);
|
|
|
|
int format = virDomainDiskGetFormat(def->disks[i]);
|
|
|
|
|
|
|
|
VIR_DEBUG("disk(%zu) type: %d", i, type);
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) device: %d", i, def->disks[i]->device);
|
|
|
|
VIR_DEBUG("disk(%zu) bus: %d", i, def->disks[i]->bus);
|
2014-03-18 21:12:57 +00:00
|
|
|
VIR_DEBUG("disk(%zu) src: %s", i, src);
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) dst: %s", i, def->disks[i]->dst);
|
2014-03-18 21:12:57 +00:00
|
|
|
VIR_DEBUG("disk(%zu) driverName: %s", i,
|
|
|
|
virDomainDiskGetDriver(def->disks[i]));
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) driverType: %s", i,
|
2014-03-18 21:12:57 +00:00
|
|
|
virStorageFileFormatTypeToString(format));
|
Convert 'int i' to 'size_t i' in src/vbox/ files
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-07-08 14:09:33 +00:00
|
|
|
VIR_DEBUG("disk(%zu) cachemode: %d", i, def->disks[i]->cachemode);
|
2014-06-24 13:15:55 +00:00
|
|
|
VIR_DEBUG("disk(%zu) readonly: %s", i, (def->disks[i]->src->readonly
|
2010-08-31 18:01:45 +00:00
|
|
|
? "True" : "False"));
|
2014-06-24 13:15:55 +00:00
|
|
|
VIR_DEBUG("disk(%zu) shared: %s", i, (def->disks[i]->src->shared
|
2010-08-31 18:01:45 +00:00
|
|
|
? "True" : "False"));
|
|
|
|
|
conf: move host disk type to util/
A continuation of the migration of disk details to virstoragefile.
This patch moves a single enum, but converting the name has quite
a bit of fallout.
* src/conf/domain_conf.h (virDomainDiskType): Move...
* src/util/virstoragefile.h (virStorageType): ...and rename.
* src/bhyve/bhyve_command.c (bhyveBuildDiskArgStr)
(virBhyveProcessBuildLoadCmd): Update clients.
* src/conf/domain_conf.c (virDomainDiskSourceDefParse)
(virDomainDiskDefParseXML, virDomainDiskSourceDefFormatInternal)
(virDomainDiskDefFormat, virDomainDiskGetActualType)
(virDomainDiskDefForeachPath, virDomainDiskSourceIsBlockType):
Likewise.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDiskDefFormat):
Likewise.
* src/esx/esx_driver.c (esxAutodetectSCSIControllerModel)
(esxDomainDefineXML): Likewise.
* src/locking/domain_lock.c (virDomainLockManagerAddDisk):
Likewise.
* src/lxc/lxc_controller.c
(virLXCControllerSetupLoopDeviceDisk)
(virLXCControllerSetupNBDDeviceDisk)
(virLXCControllerSetupLoopDevices, virLXCControllerSetupDisk):
Likewise.
* src/parallels/parallels_driver.c (parallelsGetHddInfo):
Likewise.
* src/phyp/phyp_driver.c (phypDiskType): Likewise.
* src/qemu/qemu_command.c (qemuGetDriveSourceString)
(qemuDomainDiskGetSourceString, qemuBuildDriveStr)
(qemuBuildCommandLine, qemuParseCommandLineDisk)
(qemuParseCommandLine): Likewise.
* src/qemu/qemu_conf.c (qemuCheckSharedDevice)
(qemuTranslateDiskSourcePool)
(qemuTranslateSnapshotDiskSourcePool): Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDetermineDiskChain): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo)
(qemuDomainSnapshotPrepareDiskExternalBackingInactive)
(qemuDomainSnapshotPrepareDiskExternalBackingActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayActive)
(qemuDomainSnapshotPrepareDiskExternalOverlayInactive)
(qemuDomainSnapshotPrepareDiskInternal)
(qemuDomainSnapshotPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.
* src/qemu/qemu_hotplug.c (qemuDomainChangeEjectableMedia):
Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsSafe): Likewise.
* src/security/security_apparmor.c
(AppArmorRestoreSecurityImageLabel)
(AppArmorSetSecurityImageLabel): Likewise.
* src/security/security_dac.c (virSecurityDACSetSecurityImageLabel)
(virSecurityDACRestoreSecurityImageLabelInt)
(virSecurityDACSetSecurityAllLabel): Likewise.
* src/security/security_selinux.c
(virSecuritySELinuxRestoreSecurityImageLabelInt)
(virSecuritySELinuxSetSecurityImageLabel)
(virSecuritySELinuxSetSecurityAllLabel): Likewise.
* src/storage/storage_backend.c (virStorageFileBackendForType):
Likewise.
* src/storage/storage_backend_fs.c (virStorageFileBackendFile)
(virStorageFileBackendBlock): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGluster): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc, vboxAttachDrives)
(vboxDomainAttachDeviceImpl, vboxDomainDetachDevice): Likewise.
* src/vmware/vmware_conf.c (vmwareVmxPath): Likewise.
* src/vmx/vmx.c (virVMXParseDisk, virVMXFormatDisk)
(virVMXFormatFloppy): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenParseSxpr)
(xenFormatSxprDisk): Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/securityselinuxlabeltest.c (testSELinuxLoadDef):
Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-03-27 21:57:49 +00:00
|
|
|
if (type == VIR_STORAGE_TYPE_FILE && src) {
|
2010-08-31 18:01:45 +00:00
|
|
|
IMedium *medium = NULL;
|
|
|
|
PRUnichar *mediumUUID = NULL;
|
|
|
|
PRUnichar *mediumFileUtf16 = NULL;
|
|
|
|
PRUint32 storageBus = StorageBus_Null;
|
|
|
|
PRUint32 deviceType = DeviceType_Null;
|
|
|
|
PRInt32 deviceInst = 0;
|
|
|
|
PRInt32 devicePort = 0;
|
|
|
|
PRInt32 deviceSlot = 0;
|
|
|
|
|
2014-03-18 21:12:57 +00:00
|
|
|
VBOX_UTF8_TO_UTF16(src, &mediumFileUtf16);
|
2010-08-31 18:01:45 +00:00
|
|
|
|
|
|
|
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
|
|
|
deviceType = DeviceType_HardDisk;
|
|
|
|
data->vboxObj->vtbl->FindHardDisk(data->vboxObj,
|
|
|
|
mediumFileUtf16, &medium);
|
|
|
|
} else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
|
|
|
deviceType = DeviceType_DVD;
|
|
|
|
data->vboxObj->vtbl->FindDVDImage(data->vboxObj,
|
|
|
|
mediumFileUtf16, &medium);
|
|
|
|
} else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
|
|
|
deviceType = DeviceType_Floppy;
|
|
|
|
data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
|
|
|
|
mediumFileUtf16, &medium);
|
|
|
|
} else {
|
|
|
|
VBOX_UTF16_FREE(mediumFileUtf16);
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (!medium) {
|
|
|
|
PRUnichar *mediumEmpty = NULL;
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF8_TO_UTF16("", &mediumEmpty);
|
2009-12-04 13:49:45 +00:00
|
|
|
|
|
|
|
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
2010-09-03 15:39:23 +00:00
|
|
|
rc = data->vboxObj->vtbl->OpenHardDisk(data->vboxObj,
|
|
|
|
mediumFileUtf16,
|
|
|
|
AccessMode_ReadWrite,
|
|
|
|
false,
|
|
|
|
mediumEmpty,
|
|
|
|
false,
|
|
|
|
mediumEmpty,
|
|
|
|
&medium);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else if (def->disks[i]->device ==
|
|
|
|
VIR_DOMAIN_DISK_DEVICE_CDROM) {
|
2010-09-03 15:39:23 +00:00
|
|
|
rc = data->vboxObj->vtbl->OpenDVDImage(data->vboxObj,
|
|
|
|
mediumFileUtf16,
|
|
|
|
mediumEmpty,
|
|
|
|
&medium);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else if (def->disks[i]->device ==
|
|
|
|
VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
|
2010-09-03 15:39:23 +00:00
|
|
|
rc = data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
|
|
|
|
mediumFileUtf16,
|
|
|
|
mediumEmpty,
|
|
|
|
&medium);
|
|
|
|
} else {
|
|
|
|
rc = 0;
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF16_FREE(mediumEmpty);
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (!medium) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("Failed to attach the following disk/dvd/floppy "
|
|
|
|
"to the machine: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_UTF16_FREE(mediumFileUtf16);
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
rc = medium->vtbl->GetId(medium, &mediumUUID);
|
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("can't get the uuid of the file to be attached "
|
|
|
|
"as harddisk/dvd/floppy: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
VBOX_RELEASE(medium);
|
|
|
|
VBOX_UTF16_FREE(mediumFileUtf16);
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
2014-06-24 13:15:55 +00:00
|
|
|
if (def->disks[i]->src->readonly) {
|
2010-08-31 18:01:45 +00:00
|
|
|
medium->vtbl->SetType(medium, MediumType_Immutable);
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("setting harddisk to immutable");
|
2014-06-24 13:15:55 +00:00
|
|
|
} else if (!def->disks[i]->src->readonly) {
|
2010-08-31 18:01:45 +00:00
|
|
|
medium->vtbl->SetType(medium, MediumType_Normal);
|
2011-05-09 09:24:09 +00:00
|
|
|
VIR_DEBUG("setting harddisk type to normal");
|
2009-12-04 13:49:45 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_IDE) {
|
|
|
|
VBOX_UTF8_TO_UTF16("IDE Controller", &storageCtlName);
|
|
|
|
storageBus = StorageBus_IDE;
|
|
|
|
} else if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_SATA) {
|
|
|
|
VBOX_UTF8_TO_UTF16("SATA Controller", &storageCtlName);
|
|
|
|
storageBus = StorageBus_SATA;
|
|
|
|
} else if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
|
|
|
|
VBOX_UTF8_TO_UTF16("SCSI Controller", &storageCtlName);
|
|
|
|
storageBus = StorageBus_SCSI;
|
|
|
|
} else if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_FDC) {
|
|
|
|
VBOX_UTF8_TO_UTF16("Floppy Controller", &storageCtlName);
|
|
|
|
storageBus = StorageBus_Floppy;
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2010-08-31 18:01:45 +00:00
|
|
|
/* get the device details i.e instance, port and slot */
|
|
|
|
if (!vboxGetDeviceDetails(def->disks[i]->dst,
|
|
|
|
maxPortPerInst,
|
|
|
|
maxSlotPerPort,
|
|
|
|
storageBus,
|
|
|
|
&deviceInst,
|
|
|
|
&devicePort,
|
|
|
|
&deviceSlot)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2012-09-12 16:54:42 +00:00
|
|
|
_("can't get the port/slot number of "
|
|
|
|
"harddisk/dvd/floppy to be attached: "
|
|
|
|
"%s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2009-12-04 13:49:45 +00:00
|
|
|
VBOX_RELEASE(medium);
|
|
|
|
VBOX_UTF16_FREE(mediumUUID);
|
|
|
|
VBOX_UTF16_FREE(mediumFileUtf16);
|
2010-08-31 18:01:45 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* attach the harddisk/dvd/Floppy to the storage controller */
|
|
|
|
rc = machine->vtbl->AttachDevice(machine,
|
|
|
|
storageCtlName,
|
|
|
|
devicePort,
|
|
|
|
deviceSlot,
|
|
|
|
deviceType,
|
|
|
|
mediumUUID);
|
|
|
|
|
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
2012-09-12 16:54:42 +00:00
|
|
|
_("could not attach the file as "
|
|
|
|
"harddisk/dvd/floppy: %s, rc=%08x"),
|
2014-03-18 21:12:57 +00:00
|
|
|
src, (unsigned)rc);
|
2010-08-31 18:01:45 +00:00
|
|
|
} else {
|
|
|
|
DEBUGIID("Attached HDD/DVD/Floppy with UUID", mediumUUID);
|
2009-04-17 16:09:07 +00:00
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
|
|
|
|
VBOX_RELEASE(medium);
|
|
|
|
VBOX_UTF16_FREE(mediumUUID);
|
|
|
|
VBOX_UTF16_FREE(mediumFileUtf16);
|
|
|
|
VBOX_UTF16_FREE(storageCtlName);
|
2009-12-04 13:49:45 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-31 18:01:45 +00:00
|
|
|
}
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
2010-08-31 18:01:45 +00:00
|
|
|
|
|
|
|
static void
|
2014-08-11 10:06:19 +00:00
|
|
|
_vboxAttachDrivesOld(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|
|
|
vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED)
|
2010-08-31 18:01:45 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
vboxUnsupported();
|
|
|
|
}
|
2011-10-29 19:26:57 +00:00
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
2010-08-31 18:01:45 +00:00
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#if VBOX_API_VERSION < 3001000
|
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)
|
|
|
|
{
|
2014-10-24 01:46:36 +00:00
|
|
|
vboxGlobalData *data = dom->conn->privateData;
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIID iid = VBOX_IID_INITIALIZER;
|
2010-03-26 12:40:34 +00:00
|
|
|
nsresult rc;
|
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 = snapshot->vtbl->GetId(snapshot, &iid.value);
|
|
|
|
if (NS_FAILED(rc)) {
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("could not get snapshot UUID"));
|
2010-03-26 12:40:34 +00:00
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2010-12-23 16:25:56 +00:00
|
|
|
rc = machine->vtbl->SetCurrentSnapshot(machine, iid.value);
|
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 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-12-23 16:25:56 +00:00
|
|
|
vboxIIDUnalloc(&iid);
|
2010-03-26 12:40:34 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
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)
|
|
|
|
{
|
2014-10-24 01:46:36 +00:00
|
|
|
vboxGlobalData *data = dom->conn->privateData;
|
2010-03-26 12:40:34 +00:00
|
|
|
IConsole *console = NULL;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-12-27 22:35:30 +00:00
|
|
|
rc = VBOX_SESSION_OPEN(domiid.value, machine);
|
2010-03-26 12:40:34 +00:00
|
|
|
if (NS_SUCCEEDED(rc))
|
|
|
|
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = console->vtbl->RestoreSnapshot(console, snapshot, &progress);
|
|
|
|
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);
|
|
|
|
VBOX_RELEASE(console);
|
2010-12-27 22:35:30 +00:00
|
|
|
VBOX_SESSION_CLOSE();
|
2010-12-23 16:25:56 +00:00
|
|
|
vboxIIDUnalloc(&domiid);
|
2010-03-26 12:40:34 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000
|
2009-07-24 16:12:16 +00:00
|
|
|
/* No Callback support for VirtualBox 2.2.* series */
|
2011-10-29 19:26:57 +00:00
|
|
|
/* No Callback support for VirtualBox 4.* series */
|
2014-08-11 10:07:08 +00:00
|
|
|
|
|
|
|
static void
|
2014-10-16 09:25:59 +00:00
|
|
|
_registerDomainEvent(virHypervisorDriverPtr driver)
|
2014-08-11 10:07:08 +00:00
|
|
|
{
|
|
|
|
driver->connectDomainEventRegister = NULL;
|
|
|
|
driver->connectDomainEventDeregister = NULL;
|
|
|
|
driver->connectDomainEventRegisterAny = NULL;
|
|
|
|
driver->connectDomainEventDeregisterAny = NULL;
|
|
|
|
}
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#else /* !(VBOX_API_VERSION == 2002000 || VBOX_API_VERSION >= 4000000) */
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
/* Functions needed for Callbacks */
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnMachineStateChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *machineId, PRUint32 state)
|
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
int event = 0;
|
|
|
|
int detail = 0;
|
|
|
|
|
|
|
|
vboxDriverLock(g_pVBoxGlobalData);
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p, State: %d", pThis, state);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
|
|
|
|
if (machineId) {
|
|
|
|
char *machineIdUtf8 = NULL;
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
|
|
|
|
|
|
g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8);
|
2011-10-12 23:24:52 +00:00
|
|
|
ignore_value(virUUIDParse(machineIdUtf8, uuid));
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
dom = vboxDomainLookupByUUID(g_pVBoxGlobalData->conn, uuid);
|
|
|
|
if (dom) {
|
2013-11-22 14:38:05 +00:00
|
|
|
virObjectEventPtr ev;
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
if (state == MachineState_Starting) {
|
|
|
|
event = VIR_DOMAIN_EVENT_STARTED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_STARTED_BOOTED;
|
|
|
|
} else if (state == MachineState_Restoring) {
|
|
|
|
event = VIR_DOMAIN_EVENT_STARTED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_STARTED_RESTORED;
|
|
|
|
} else if (state == MachineState_Paused) {
|
|
|
|
event = VIR_DOMAIN_EVENT_SUSPENDED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_SUSPENDED_PAUSED;
|
|
|
|
} else if (state == MachineState_Running) {
|
|
|
|
event = VIR_DOMAIN_EVENT_RESUMED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_RESUMED_UNPAUSED;
|
|
|
|
} else if (state == MachineState_PoweredOff) {
|
|
|
|
event = VIR_DOMAIN_EVENT_STOPPED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
|
|
|
|
} else if (state == MachineState_Stopping) {
|
|
|
|
event = VIR_DOMAIN_EVENT_STOPPED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_STOPPED_DESTROYED;
|
|
|
|
} else if (state == MachineState_Aborted) {
|
|
|
|
event = VIR_DOMAIN_EVENT_STOPPED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_STOPPED_CRASHED;
|
|
|
|
} else if (state == MachineState_Saving) {
|
|
|
|
event = VIR_DOMAIN_EVENT_STOPPED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_STOPPED_SAVED;
|
|
|
|
} else {
|
|
|
|
event = VIR_DOMAIN_EVENT_STOPPED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN;
|
|
|
|
}
|
|
|
|
|
2013-11-21 17:03:26 +00:00
|
|
|
ev = virDomainEventLifecycleNewFromDom(dom, event, detail);
|
2010-03-18 13:17:14 +00:00
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
if (ev)
|
2013-11-21 10:43:10 +00:00
|
|
|
virObjectEventStateQueue(g_pVBoxGlobalData->domainEvents, ev);
|
2009-07-24 16:12:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vboxDriverUnlock(g_pVBoxGlobalData);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnMachineDataChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *machineId)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnExtraDataCanChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *machineId, PRUnichar *key,
|
|
|
|
PRUnichar *value,
|
|
|
|
PRUnichar **error ATTRIBUTE_UNUSED,
|
2011-09-26 16:51:47 +00:00
|
|
|
PRBool *allowChange ATTRIBUTE_UNUSED)
|
2010-12-14 18:53:52 +00:00
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p, allowChange: %s", pThis, *allowChange ? "true" : "false");
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
DEBUGPRUnichar("key", key);
|
|
|
|
DEBUGPRUnichar("value", value);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnExtraDataChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *machineId,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *key, PRUnichar *value)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
DEBUGPRUnichar("key", key);
|
|
|
|
DEBUGPRUnichar("value", value);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
# if VBOX_API_VERSION < 3001000
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnMediaRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *mediaId,
|
|
|
|
PRUint32 mediaType ATTRIBUTE_UNUSED,
|
|
|
|
PRBool registered ATTRIBUTE_UNUSED)
|
2010-12-14 18:53:52 +00:00
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false");
|
|
|
|
VIR_DEBUG("mediaType: %d", mediaType);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("mediaId", mediaId);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-12-24 09:39:38 +00:00
|
|
|
# else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
# endif /* VBOX_API_VERSION >= 3001000 */
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *machineId, PRBool registered)
|
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
virDomainPtr dom = NULL;
|
|
|
|
int event = 0;
|
|
|
|
int detail = 0;
|
|
|
|
|
|
|
|
vboxDriverLock(g_pVBoxGlobalData);
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false");
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
|
|
|
|
if (machineId) {
|
|
|
|
char *machineIdUtf8 = NULL;
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
|
|
|
|
|
|
g_pVBoxGlobalData->pFuncs->pfnUtf16ToUtf8(machineId, &machineIdUtf8);
|
2011-10-12 23:24:52 +00:00
|
|
|
ignore_value(virUUIDParse(machineIdUtf8, uuid));
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
dom = vboxDomainLookupByUUID(g_pVBoxGlobalData->conn, uuid);
|
|
|
|
if (dom) {
|
2013-11-22 14:38:05 +00:00
|
|
|
virObjectEventPtr ev;
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
/* CURRENT LIMITATION: we never get the VIR_DOMAIN_EVENT_UNDEFINED
|
2012-10-11 16:31:20 +00:00
|
|
|
* event because the when the machine is de-registered the call
|
2009-07-24 16:12:16 +00:00
|
|
|
* to vboxDomainLookupByUUID fails and thus we don't get any
|
|
|
|
* dom pointer which is necessary (null dom pointer doesn't work)
|
|
|
|
* to show the VIR_DOMAIN_EVENT_UNDEFINED event
|
|
|
|
*/
|
|
|
|
if (registered) {
|
|
|
|
event = VIR_DOMAIN_EVENT_DEFINED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_DEFINED_ADDED;
|
|
|
|
} else {
|
|
|
|
event = VIR_DOMAIN_EVENT_UNDEFINED;
|
|
|
|
detail = VIR_DOMAIN_EVENT_UNDEFINED_REMOVED;
|
|
|
|
}
|
|
|
|
|
2013-11-21 17:03:26 +00:00
|
|
|
ev = virDomainEventLifecycleNewFromDom(dom, event, detail);
|
2010-03-18 13:17:14 +00:00
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
if (ev)
|
2013-11-21 10:43:10 +00:00
|
|
|
virObjectEventStateQueue(g_pVBoxGlobalData->domainEvents, ev);
|
2009-07-24 16:12:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vboxDriverUnlock(g_pVBoxGlobalData);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnSessionStateChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *machineId,
|
|
|
|
PRUint32 state ATTRIBUTE_UNUSED)
|
2010-12-14 18:53:52 +00:00
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p, state: %d", pThis, state);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnSnapshotTaken(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *machineId,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *snapshotId)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
DEBUGPRUnichar("snapshotId", snapshotId);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnSnapshotDiscarded(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *machineId,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *snapshotId)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
DEBUGPRUnichar("snapshotId", snapshotId);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnSnapshotChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *machineId,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *snapshotId)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
DEBUGPRUnichar("snapshotId", snapshotId);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackOnGuestPropertyChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
|
2010-12-14 18:53:52 +00:00
|
|
|
PRUnichar *machineId, PRUnichar *name,
|
|
|
|
PRUnichar *value, PRUnichar *flags)
|
|
|
|
{
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGPRUnichar("machineId", machineId);
|
|
|
|
DEBUGPRUnichar("name", name);
|
|
|
|
DEBUGPRUnichar("value", value);
|
|
|
|
DEBUGPRUnichar("flags", flags);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
2011-09-26 16:51:47 +00:00
|
|
|
vboxCallbackAddRef(nsISupports *pThis ATTRIBUTE_UNUSED)
|
2010-12-14 18:53:52 +00:00
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
nsresult c;
|
|
|
|
|
|
|
|
c = ++g_pVBoxGlobalData->vboxCallBackRefCount;
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("pThis: %p, vboxCallback AddRef: %d", pThis, c);
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
|
|
|
vboxCallbackRelease(nsISupports *pThis)
|
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
nsresult c;
|
|
|
|
|
|
|
|
c = --g_pVBoxGlobalData->vboxCallBackRefCount;
|
|
|
|
if (c == 0) {
|
|
|
|
/* delete object */
|
|
|
|
VIR_FREE(pThis->vtbl);
|
|
|
|
VIR_FREE(pThis);
|
|
|
|
}
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("pThis: %p, vboxCallback Release: %d", pThis, c);
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2010-12-14 18:53:52 +00:00
|
|
|
static nsresult PR_COM_METHOD
|
|
|
|
vboxCallbackQueryInterface(nsISupports *pThis, const nsID *iid, void **resultp)
|
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
IVirtualBoxCallback *that = (IVirtualBoxCallback *)pThis;
|
|
|
|
static const nsID ivirtualboxCallbackUUID = IVIRTUALBOXCALLBACK_IID;
|
|
|
|
static const nsID isupportIID = NS_ISUPPORTS_IID;
|
|
|
|
|
|
|
|
/* Match UUID for IVirtualBoxCallback class */
|
2012-10-17 09:23:12 +00:00
|
|
|
if (memcmp(iid, &ivirtualboxCallbackUUID, sizeof(nsID)) == 0 ||
|
|
|
|
memcmp(iid, &isupportIID, sizeof(nsID)) == 0) {
|
2009-07-24 16:12:16 +00:00
|
|
|
g_pVBoxGlobalData->vboxCallBackRefCount++;
|
|
|
|
*resultp = that;
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("pThis: %p, vboxCallback QueryInterface: %d", pThis, g_pVBoxGlobalData->vboxCallBackRefCount);
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-16 23:37:57 +00:00
|
|
|
VIR_DEBUG("pThis: %p, vboxCallback QueryInterface didn't find a matching interface", pThis);
|
2009-07-24 16:12:16 +00:00
|
|
|
DEBUGUUID("The UUID Callback Interface expects", iid);
|
|
|
|
DEBUGUUID("The UUID Callback Interface got", &ivirtualboxCallbackUUID);
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-04 18:19:08 +00:00
|
|
|
static IVirtualBoxCallback *vboxAllocCallbackObj(void) {
|
2009-07-24 16:12:16 +00:00
|
|
|
IVirtualBoxCallback *vboxCallback = NULL;
|
|
|
|
|
2010-02-15 19:09:55 +00:00
|
|
|
/* Allocate, Initialize and return a valid
|
2009-07-24 16:12:16 +00:00
|
|
|
* IVirtualBoxCallback object here
|
|
|
|
*/
|
|
|
|
if ((VIR_ALLOC(vboxCallback) < 0) || (VIR_ALLOC(vboxCallback->vtbl) < 0)) {
|
2010-02-15 19:09:55 +00:00
|
|
|
VIR_FREE(vboxCallback);
|
2009-07-24 16:12:16 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
vboxCallback->vtbl->nsisupports.AddRef = &vboxCallbackAddRef;
|
|
|
|
vboxCallback->vtbl->nsisupports.Release = &vboxCallbackRelease;
|
|
|
|
vboxCallback->vtbl->nsisupports.QueryInterface = &vboxCallbackQueryInterface;
|
|
|
|
vboxCallback->vtbl->OnMachineStateChange = &vboxCallbackOnMachineStateChange;
|
|
|
|
vboxCallback->vtbl->OnMachineDataChange = &vboxCallbackOnMachineDataChange;
|
|
|
|
vboxCallback->vtbl->OnExtraDataCanChange = &vboxCallbackOnExtraDataCanChange;
|
|
|
|
vboxCallback->vtbl->OnExtraDataChange = &vboxCallbackOnExtraDataChange;
|
2013-12-24 09:39:38 +00:00
|
|
|
# if VBOX_API_VERSION < 3001000
|
2009-07-24 16:12:16 +00:00
|
|
|
vboxCallback->vtbl->OnMediaRegistered = &vboxCallbackOnMediaRegistered;
|
2013-12-24 09:39:38 +00:00
|
|
|
# else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
# endif /* VBOX_API_VERSION >= 3001000 */
|
2009-07-24 16:12:16 +00:00
|
|
|
vboxCallback->vtbl->OnMachineRegistered = &vboxCallbackOnMachineRegistered;
|
|
|
|
vboxCallback->vtbl->OnSessionStateChange = &vboxCallbackOnSessionStateChange;
|
|
|
|
vboxCallback->vtbl->OnSnapshotTaken = &vboxCallbackOnSnapshotTaken;
|
2013-12-24 09:39:38 +00:00
|
|
|
# if VBOX_API_VERSION < 3002000
|
2009-07-24 16:12:16 +00:00
|
|
|
vboxCallback->vtbl->OnSnapshotDiscarded = &vboxCallbackOnSnapshotDiscarded;
|
2013-12-24 09:39:38 +00:00
|
|
|
# else /* VBOX_API_VERSION >= 3002000 */
|
2010-05-26 11:54:16 +00:00
|
|
|
vboxCallback->vtbl->OnSnapshotDeleted = &vboxCallbackOnSnapshotDiscarded;
|
2013-12-24 09:39:38 +00:00
|
|
|
# endif /* VBOX_API_VERSION >= 3002000 */
|
2009-07-24 16:12:16 +00:00
|
|
|
vboxCallback->vtbl->OnSnapshotChange = &vboxCallbackOnSnapshotChange;
|
|
|
|
vboxCallback->vtbl->OnGuestPropertyChange = &vboxCallbackOnGuestPropertyChange;
|
|
|
|
g_pVBoxGlobalData->vboxCallBackRefCount = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return vboxCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vboxReadCallback(int watch ATTRIBUTE_UNUSED,
|
|
|
|
int fd,
|
|
|
|
int events ATTRIBUTE_UNUSED,
|
2014-03-18 08:18:32 +00:00
|
|
|
void *opaque ATTRIBUTE_UNUSED)
|
|
|
|
{
|
2009-07-24 16:12:16 +00:00
|
|
|
if (fd >= 0) {
|
|
|
|
g_pVBoxGlobalData->vboxQueue->vtbl->ProcessPendingEvents(g_pVBoxGlobalData->vboxQueue);
|
|
|
|
} else {
|
|
|
|
nsresult rc;
|
|
|
|
PLEvent *pEvent = NULL;
|
|
|
|
|
|
|
|
rc = g_pVBoxGlobalData->vboxQueue->vtbl->WaitForEvent(g_pVBoxGlobalData->vboxQueue, &pEvent);
|
|
|
|
if (NS_SUCCEEDED(rc))
|
|
|
|
g_pVBoxGlobalData->vboxQueue->vtbl->HandleEvent(g_pVBoxGlobalData->vboxQueue, pEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static int
|
|
|
|
vboxConnectDomainEventRegister(virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback,
|
|
|
|
void *opaque,
|
|
|
|
virFreeCallback freecb)
|
|
|
|
{
|
2014-10-24 01:46:36 +00:00
|
|
|
vboxGlobalData *data = conn->privateData;
|
2009-07-24 16:12:16 +00:00
|
|
|
int vboxRet = -1;
|
2009-12-04 13:49:45 +00:00
|
|
|
nsresult rc;
|
2014-10-24 01:46:36 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!data->vboxObj)
|
|
|
|
return ret;
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
/* Locking has to be there as callbacks are not
|
|
|
|
* really fully thread safe
|
|
|
|
*/
|
|
|
|
vboxDriverLock(data);
|
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
if (data->vboxCallback == NULL) {
|
2010-02-04 18:19:08 +00:00
|
|
|
data->vboxCallback = vboxAllocCallbackObj();
|
2009-12-04 13:49:45 +00:00
|
|
|
if (data->vboxCallback != NULL) {
|
|
|
|
rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback);
|
2014-11-13 14:21:37 +00:00
|
|
|
if (NS_SUCCEEDED(rc))
|
2009-12-04 13:49:45 +00:00
|
|
|
vboxRet = 0;
|
2009-07-24 16:12:16 +00:00
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
} else {
|
|
|
|
vboxRet = 0;
|
|
|
|
}
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
/* Get the vbox file handle and add a event handle to it
|
|
|
|
* so that the events can be passed down to the user
|
|
|
|
*/
|
|
|
|
if (vboxRet == 0) {
|
|
|
|
if (data->fdWatch < 0) {
|
|
|
|
PRInt32 vboxFileHandle;
|
|
|
|
vboxFileHandle = data->vboxQueue->vtbl->GetEventQueueSelectFD(data->vboxQueue);
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, NULL, NULL);
|
|
|
|
}
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2009-12-04 13:49:45 +00:00
|
|
|
if (data->fdWatch >= 0) {
|
|
|
|
/* Once a callback is registered with virtualbox, use a list
|
|
|
|
* to store the callbacks registered with libvirt so that
|
|
|
|
* later you can iterate over them
|
|
|
|
*/
|
2009-07-24 16:12:16 +00:00
|
|
|
|
event: move event filtering to daemon (regression fix)
https://bugzilla.redhat.com/show_bug.cgi?id=1058839
Commit f9f56340 for CVE-2014-0028 almost had the right idea - we
need to check the ACL rules to filter which events to send. But
it overlooked one thing: the event dispatch queue is running in
the main loop thread, and therefore does not normally have a
current virIdentityPtr. But filter checks can be based on current
identity, so when libvirtd.conf contains access_drivers=["polkit"],
we ended up rejecting access for EVERY event due to failure to
look up the current identity, even if it should have been allowed.
Furthermore, even for events that are triggered by API calls, it
is important to remember that the point of events is that they can
be copied across multiple connections, which may have separate
identities and permissions. So even if events were dispatched
from a context where we have an identity, we must change to the
correct identity of the connection that will be receiving the
event, rather than basing a decision on the context that triggered
the event, when deciding whether to filter an event to a
particular connection.
If there were an easy way to get from virConnectPtr to the
appropriate virIdentityPtr, then object_event.c could adjust the
identity prior to checking whether to dispatch an event. But
setting up that back-reference is a bit invasive. Instead, it
is easier to delay the filtering check until lower down the
stack, at the point where we have direct access to the RPC
client object that owns an identity. As such, this patch ends
up reverting a large portion of the framework of commit f9f56340.
We also have to teach 'make check' to special-case the fact that
the event registration filtering is done at the point of dispatch,
rather than the point of registration. Note that even though we
don't actually use virConnectDomainEventRegisterCheckACL (because
the RegisterAny variant is sufficient), we still generate the
function for the purposes of documenting that the filtering
takes place.
Also note that I did not entirely delete the notion of a filter
from object_event.c; I still plan on using that for my upcoming
patch series for qemu monitor events in libvirt-qemu.so. In
other words, while this patch changes ACL filtering to live in
remote.c and therefore we have no current client of the filtering
in object_event.c, the notion of filtering in object_event.c is
still useful down the road.
* src/check-aclrules.pl: Exempt event registration from having to
pass checkACL filter down call stack.
* daemon/remote.c (remoteRelayDomainEventCheckACL)
(remoteRelayNetworkEventCheckACL): New functions.
(remoteRelay*Event*): Use new functions.
* src/conf/domain_event.h (virDomainEventStateRegister)
(virDomainEventStateRegisterID): Drop unused parameter.
* src/conf/network_event.h (virNetworkEventStateRegisterID):
Likewise.
* src/conf/domain_event.c (virDomainEventFilter): Delete unused
function.
* src/conf/network_event.c (virNetworkEventFilter): Likewise.
* src/libxl/libxl_driver.c: Adjust caller.
* src/lxc/lxc_driver.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/test/test_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_driver.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-28 21:50:02 +00:00
|
|
|
ret = virDomainEventStateRegister(conn, data->domainEvents,
|
2011-12-13 11:14:46 +00:00
|
|
|
callback, opaque, freecb);
|
2013-11-21 10:43:10 +00:00
|
|
|
VIR_DEBUG("virObjectEventStateRegister (ret = %d) (conn: %p, "
|
2011-12-13 11:14:46 +00:00
|
|
|
"callback: %p, opaque: %p, "
|
2012-10-17 09:23:12 +00:00
|
|
|
"freecb: %p)", ret, conn, callback,
|
2011-12-13 11:14:46 +00:00
|
|
|
opaque, freecb);
|
2009-07-24 16:12:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vboxDriverUnlock(data);
|
|
|
|
|
|
|
|
if (ret >= 0) {
|
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
|
|
|
return 0;
|
2009-07-24 16:12:16 +00:00
|
|
|
} else {
|
2014-11-13 14:21:37 +00:00
|
|
|
if (data->vboxObj && data->vboxCallback)
|
2009-07-24 16:12:16 +00:00
|
|
|
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static int
|
|
|
|
vboxConnectDomainEventDeregister(virConnectPtr conn,
|
|
|
|
virConnectDomainEventCallback callback)
|
|
|
|
{
|
2014-10-24 01:46:36 +00:00
|
|
|
vboxGlobalData *data = conn->privateData;
|
2011-12-13 10:39:17 +00:00
|
|
|
int cnt;
|
2014-10-24 01:46:36 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!data->vboxObj)
|
|
|
|
return ret;
|
2009-07-24 16:12:16 +00:00
|
|
|
|
|
|
|
/* Locking has to be there as callbacks are not
|
|
|
|
* really fully thread safe
|
|
|
|
*/
|
|
|
|
vboxDriverLock(data);
|
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
cnt = virDomainEventStateDeregister(conn, data->domainEvents,
|
|
|
|
callback);
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
if (data->vboxCallback && cnt == 0) {
|
|
|
|
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
|
|
|
|
VBOX_RELEASE(data->vboxCallback);
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
/* Remove the Event file handle on which we are listening as well */
|
|
|
|
virEventRemoveHandle(data->fdWatch);
|
|
|
|
data->fdWatch = -1;
|
2009-07-24 16:12:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vboxDriverUnlock(data);
|
|
|
|
|
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
|
|
|
if (cnt >= 0)
|
|
|
|
ret = 0;
|
|
|
|
|
2009-07-24 16:12:16 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-04-23 12:50:18 +00:00
|
|
|
static int vboxConnectDomainEventRegisterAny(virConnectPtr conn,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int eventID,
|
|
|
|
virConnectDomainEventGenericCallback callback,
|
|
|
|
void *opaque,
|
2014-03-18 08:18:32 +00:00
|
|
|
virFreeCallback freecb)
|
|
|
|
{
|
2014-10-24 01:46:36 +00:00
|
|
|
vboxGlobalData *data = conn->privateData;
|
2010-03-18 14:47:07 +00:00
|
|
|
int vboxRet = -1;
|
|
|
|
nsresult rc;
|
2014-10-24 01:46:36 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!data->vboxObj)
|
|
|
|
return ret;
|
2010-03-18 14:47:07 +00:00
|
|
|
|
|
|
|
/* Locking has to be there as callbacks are not
|
|
|
|
* really fully thread safe
|
|
|
|
*/
|
|
|
|
vboxDriverLock(data);
|
|
|
|
|
|
|
|
if (data->vboxCallback == NULL) {
|
|
|
|
data->vboxCallback = vboxAllocCallbackObj();
|
|
|
|
if (data->vboxCallback != NULL) {
|
|
|
|
rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback);
|
2014-11-13 14:21:37 +00:00
|
|
|
if (NS_SUCCEEDED(rc))
|
2010-03-18 14:47:07 +00:00
|
|
|
vboxRet = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
vboxRet = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the vbox file handle and add a event handle to it
|
|
|
|
* so that the events can be passed down to the user
|
|
|
|
*/
|
|
|
|
if (vboxRet == 0) {
|
|
|
|
if (data->fdWatch < 0) {
|
|
|
|
PRInt32 vboxFileHandle;
|
|
|
|
vboxFileHandle = data->vboxQueue->vtbl->GetEventQueueSelectFD(data->vboxQueue);
|
|
|
|
|
|
|
|
data->fdWatch = virEventAddHandle(vboxFileHandle, VIR_EVENT_HANDLE_READABLE, vboxReadCallback, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data->fdWatch >= 0) {
|
|
|
|
/* Once a callback is registered with virtualbox, use a list
|
|
|
|
* to store the callbacks registered with libvirt so that
|
|
|
|
* later you can iterate over them
|
|
|
|
*/
|
|
|
|
|
event: move event filtering to daemon (regression fix)
https://bugzilla.redhat.com/show_bug.cgi?id=1058839
Commit f9f56340 for CVE-2014-0028 almost had the right idea - we
need to check the ACL rules to filter which events to send. But
it overlooked one thing: the event dispatch queue is running in
the main loop thread, and therefore does not normally have a
current virIdentityPtr. But filter checks can be based on current
identity, so when libvirtd.conf contains access_drivers=["polkit"],
we ended up rejecting access for EVERY event due to failure to
look up the current identity, even if it should have been allowed.
Furthermore, even for events that are triggered by API calls, it
is important to remember that the point of events is that they can
be copied across multiple connections, which may have separate
identities and permissions. So even if events were dispatched
from a context where we have an identity, we must change to the
correct identity of the connection that will be receiving the
event, rather than basing a decision on the context that triggered
the event, when deciding whether to filter an event to a
particular connection.
If there were an easy way to get from virConnectPtr to the
appropriate virIdentityPtr, then object_event.c could adjust the
identity prior to checking whether to dispatch an event. But
setting up that back-reference is a bit invasive. Instead, it
is easier to delay the filtering check until lower down the
stack, at the point where we have direct access to the RPC
client object that owns an identity. As such, this patch ends
up reverting a large portion of the framework of commit f9f56340.
We also have to teach 'make check' to special-case the fact that
the event registration filtering is done at the point of dispatch,
rather than the point of registration. Note that even though we
don't actually use virConnectDomainEventRegisterCheckACL (because
the RegisterAny variant is sufficient), we still generate the
function for the purposes of documenting that the filtering
takes place.
Also note that I did not entirely delete the notion of a filter
from object_event.c; I still plan on using that for my upcoming
patch series for qemu monitor events in libvirt-qemu.so. In
other words, while this patch changes ACL filtering to live in
remote.c and therefore we have no current client of the filtering
in object_event.c, the notion of filtering in object_event.c is
still useful down the road.
* src/check-aclrules.pl: Exempt event registration from having to
pass checkACL filter down call stack.
* daemon/remote.c (remoteRelayDomainEventCheckACL)
(remoteRelayNetworkEventCheckACL): New functions.
(remoteRelay*Event*): Use new functions.
* src/conf/domain_event.h (virDomainEventStateRegister)
(virDomainEventStateRegisterID): Drop unused parameter.
* src/conf/network_event.h (virNetworkEventStateRegisterID):
Likewise.
* src/conf/domain_event.c (virDomainEventFilter): Delete unused
function.
* src/conf/network_event.c (virNetworkEventFilter): Likewise.
* src/libxl/libxl_driver.c: Adjust caller.
* src/lxc/lxc_driver.c: Likewise.
* src/network/bridge_driver.c: Likewise.
* src/qemu/qemu_driver.c: Likewise.
* src/remote/remote_driver.c: Likewise.
* src/test/test_driver.c: Likewise.
* src/uml/uml_driver.c: Likewise.
* src/vbox/vbox_tmpl.c: Likewise.
* src/xen/xen_driver.c: Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2014-01-28 21:50:02 +00:00
|
|
|
if (virDomainEventStateRegisterID(conn, data->domainEvents,
|
2011-12-13 11:14:46 +00:00
|
|
|
dom, eventID,
|
|
|
|
callback, opaque, freecb, &ret) < 0)
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
ret = -1;
|
2012-10-17 09:23:12 +00:00
|
|
|
VIR_DEBUG("virDomainEventStateRegisterID (ret = %d) (conn: %p, "
|
2011-12-13 11:14:46 +00:00
|
|
|
"callback: %p, opaque: %p, "
|
2012-10-17 09:23:12 +00:00
|
|
|
"freecb: %p)", ret, conn, callback,
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
opaque, freecb);
|
2010-03-18 14:47:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
vboxDriverUnlock(data);
|
|
|
|
|
|
|
|
if (ret >= 0) {
|
|
|
|
return ret;
|
|
|
|
} else {
|
2014-11-13 14:21:37 +00:00
|
|
|
if (data->vboxObj && data->vboxCallback)
|
2010-03-18 14:47:07 +00:00
|
|
|
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static int
|
|
|
|
vboxConnectDomainEventDeregisterAny(virConnectPtr conn,
|
|
|
|
int callbackID)
|
|
|
|
{
|
2014-10-24 01:46:36 +00:00
|
|
|
vboxGlobalData *data = conn->privateData;
|
2011-12-13 10:39:17 +00:00
|
|
|
int cnt;
|
2014-10-24 01:46:36 +00:00
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!data->vboxObj)
|
|
|
|
return ret;
|
2010-03-18 14:47:07 +00:00
|
|
|
|
|
|
|
/* Locking has to be there as callbacks are not
|
|
|
|
* really fully thread safe
|
|
|
|
*/
|
|
|
|
vboxDriverLock(data);
|
|
|
|
|
2013-11-21 10:43:10 +00:00
|
|
|
cnt = virObjectEventStateDeregisterID(conn, data->domainEvents,
|
Return count of callbacks when registering callbacks
When registering a callback for a particular event some callers
need to know how many callbacks already exist for that event.
While it is possible to ask for a count, this is not free from
race conditions when threaded. Thus the API for registering
callbacks should return the count of callbacks. Also rename
virDomainEventStateDeregisterAny to virDomainEventStateDeregisterID
* src/conf/domain_event.c, src/conf/domain_event.h,
src/libvirt_private.syms: Return count of callbacks when
registering callbacks
* src/libxl/libxl_driver.c, src/libxl/libxl_driver.c,
src/qemu/qemu_driver.c, src/remote/remote_driver.c,
src/remote/remote_driver.c, src/uml/uml_driver.c,
src/vbox/vbox_tmpl.c, src/xen/xen_driver.c: Update
for change in APIs
2011-12-13 23:38:54 +00:00
|
|
|
callbackID);
|
2010-03-18 14:47:07 +00:00
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
if (data->vboxCallback && cnt == 0) {
|
|
|
|
data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback);
|
|
|
|
VBOX_RELEASE(data->vboxCallback);
|
2010-03-18 14:47:07 +00:00
|
|
|
|
2011-12-13 10:39:17 +00:00
|
|
|
/* Remove the Event file handle on which we are listening as well */
|
|
|
|
virEventRemoveHandle(data->fdWatch);
|
|
|
|
data->fdWatch = -1;
|
2010-03-18 14:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vboxDriverUnlock(data);
|
|
|
|
|
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
|
|
|
if (cnt >= 0)
|
|
|
|
ret = 0;
|
|
|
|
|
2010-03-18 14:47:07 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:07:08 +00:00
|
|
|
static void
|
2014-10-16 09:25:59 +00:00
|
|
|
_registerDomainEvent(virHypervisorDriverPtr driver)
|
2014-08-11 10:07:08 +00:00
|
|
|
{
|
|
|
|
driver->connectDomainEventRegister = vboxConnectDomainEventRegister; /* 0.7.0 */
|
|
|
|
driver->connectDomainEventDeregister = vboxConnectDomainEventDeregister; /* 0.7.0 */
|
|
|
|
driver->connectDomainEventRegisterAny = vboxConnectDomainEventRegisterAny; /* 0.8.0 */
|
|
|
|
driver->connectDomainEventDeregisterAny = vboxConnectDomainEventDeregisterAny; /* 0.8.0 */
|
|
|
|
}
|
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#endif /* !(VBOX_API_VERSION == 2002000 || VBOX_API_VERSION >= 4000000) */
|
2009-07-24 16:12:16 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static int _pfnInitialize(vboxGlobalData *data)
|
|
|
|
{
|
|
|
|
data->pFuncs = g_pfnGetFunctions(VBOX_XPCOMC_VERSION);
|
|
|
|
if (data->pFuncs == NULL)
|
|
|
|
return -1;
|
|
|
|
#if VBOX_XPCOMC_VERSION == 0x00010000U
|
|
|
|
data->pFuncs->pfnComInitialize(&data->vboxObj, &data->vboxSession);
|
|
|
|
#else /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */
|
|
|
|
data->pFuncs->pfnComInitialize(IVIRTUALBOX_IID_STR, &data->vboxObj, ISESSION_IID_STR, &data->vboxSession);
|
|
|
|
#endif /* !(VBOX_XPCOMC_VERSION == 0x00010000U) */
|
|
|
|
return 0;
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static int
|
|
|
|
_initializeDomainEvent(vboxGlobalData *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000
|
|
|
|
/* No event queue functionality in 2.2.* and 4.* as of now */
|
|
|
|
vboxUnsupported();
|
|
|
|
#else /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */
|
|
|
|
/* Initialize the fWatch needed for Event Callbacks */
|
|
|
|
data->fdWatch = -1;
|
|
|
|
data->pFuncs->pfnGetEventQueue(&data->vboxQueue);
|
|
|
|
if (data->vboxQueue == NULL) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("nsIEventQueue object is null"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */
|
|
|
|
return 0;
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static
|
|
|
|
void _registerGlobalData(vboxGlobalData *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
vboxUnsupported();
|
|
|
|
#else /* VBOX_API_VERSION != 2002000 */
|
|
|
|
g_pVBoxGlobalData = data;
|
|
|
|
#endif /* VBOX_API_VERSION != 2002000 */
|
|
|
|
}
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#if VBOX_API_VERSION < 4000000
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
# if VBOX_API_VERSION < 3001000
|
|
|
|
static void
|
|
|
|
_detachDevices(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine, PRUnichar *hddcnameUtf16)
|
|
|
|
{
|
|
|
|
/* Disconnect all the drives if present */
|
|
|
|
machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 0, 0);
|
|
|
|
machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 0, 1);
|
|
|
|
machine->vtbl->DetachHardDisk(machine, hddcnameUtf16, 1, 1);
|
|
|
|
}
|
|
|
|
# else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
static void
|
|
|
|
_detachDevices(vboxGlobalData *data, IMachine *machine,
|
|
|
|
PRUnichar *hddcnameUtf16 ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* get all the controller first, then the attachments and
|
|
|
|
* remove them all so that the machine can be undefined
|
|
|
|
*/
|
|
|
|
vboxArray storageControllers = VBOX_ARRAY_INITIALIZER;
|
|
|
|
size_t i = 0, j = 0;
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
vboxArrayGet(&storageControllers, machine,
|
|
|
|
machine->vtbl->GetStorageControllers);
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
for (i = 0; i < storageControllers.count; i++) {
|
|
|
|
IStorageController *strCtl = storageControllers.items[i];
|
|
|
|
PRUnichar *strCtlName = NULL;
|
|
|
|
vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER;
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
if (!strCtl)
|
|
|
|
continue;
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
strCtl->vtbl->GetName(strCtl, &strCtlName);
|
|
|
|
vboxArrayGetWithPtrArg(&mediumAttachments, machine,
|
|
|
|
machine->vtbl->GetMediumAttachmentsOfController,
|
|
|
|
strCtlName);
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
for (j = 0; j < mediumAttachments.count; j++) {
|
|
|
|
IMediumAttachment *medAtt = mediumAttachments.items[j];
|
|
|
|
PRInt32 port = ~0U;
|
|
|
|
PRInt32 device = ~0U;
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
if (!medAtt)
|
|
|
|
continue;
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
medAtt->vtbl->GetPort(medAtt, &port);
|
|
|
|
medAtt->vtbl->GetDevice(medAtt, &device);
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
if ((port != ~0U) && (device != ~0U)) {
|
|
|
|
machine->vtbl->DetachDevice(machine,
|
|
|
|
strCtlName,
|
|
|
|
port,
|
|
|
|
device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
vboxArrayRelease(&storageControllers);
|
|
|
|
machine->vtbl->RemoveStorageController(machine, strCtlName);
|
|
|
|
VBOX_UTF16_FREE(strCtlName);
|
|
|
|
}
|
|
|
|
vboxArrayRelease(&storageControllers);
|
|
|
|
}
|
|
|
|
# endif /* VBOX_API_VERSION >= 3001000 */
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_unregisterMachine(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine **machine)
|
|
|
|
{
|
|
|
|
return data->vboxObj->vtbl->UnregisterMachine(data->vboxObj, IID_MEMBER(value), machine);
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void
|
|
|
|
_deleteConfig(IMachine *machine)
|
|
|
|
{
|
|
|
|
machine->vtbl->DeleteSettings(machine);
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void
|
|
|
|
_detachDevices(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *hddcnameUtf16 ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_unregisterMachine(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine **machine)
|
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
vboxArray media = VBOX_ARRAY_INITIALIZER;
|
2014-10-24 01:46:53 +00:00
|
|
|
rc = data->vboxObj->vtbl->FindMachine(data->vboxObj, IID_MEMBER(value), machine);
|
2014-08-11 10:06:19 +00:00
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_NO_DOMAIN, "%s",
|
|
|
|
_("no domain with matching uuid"));
|
|
|
|
return rc;
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
/* We're not interested in the array returned by the Unregister method,
|
|
|
|
* but in the side effect of unregistering the virtual machine. In order
|
|
|
|
* to call the Unregister method correctly we need to use the vboxArray
|
|
|
|
* wrapper here. */
|
|
|
|
rc = vboxArrayGetWithUintArg(&media, *machine, (*machine)->vtbl->Unregister,
|
|
|
|
CleanupMode_DetachAllReturnNone);
|
|
|
|
vboxArrayUnalloc(&media);
|
|
|
|
return rc;
|
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void
|
|
|
|
_deleteConfig(IMachine *machine)
|
|
|
|
{
|
|
|
|
IProgress *progress = NULL;
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +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);
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
# if VBOX_API_VERSION < 4003000
|
|
|
|
((IMachine_Delete)machine->vtbl->Delete)(machine, &safeArray, &progress);
|
|
|
|
# else
|
|
|
|
((IMachine_Delete)machine->vtbl->DeleteConfig)(machine, &safeArray, &progress);
|
|
|
|
# endif
|
|
|
|
# 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 };
|
|
|
|
# if VBOX_API_VERSION < 4003000
|
|
|
|
machine->vtbl->Delete(machine, 0, array, &progress);
|
|
|
|
# else
|
|
|
|
machine->vtbl->DeleteConfig(machine, 0, array, &progress);
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
if (progress != NULL) {
|
|
|
|
progress->vtbl->WaitForCompletion(progress, -1);
|
|
|
|
VBOX_RELEASE(progress);
|
2009-09-04 14:28:52 +00:00
|
|
|
}
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2009-09-04 14:28:52 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
2009-12-04 13:49:45 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dumpIDEHDDsOld(virDomainDefPtr def,
|
|
|
|
vboxGlobalData *data,
|
|
|
|
IMachine *machine)
|
|
|
|
{
|
|
|
|
PRInt32 hddNum = 0;
|
|
|
|
IHardDisk *hardDiskPM = NULL;
|
|
|
|
IHardDisk *hardDiskPS = NULL;
|
|
|
|
IHardDisk *hardDiskSS = NULL;
|
|
|
|
const char *hddBus = "IDE";
|
|
|
|
PRUnichar *hddBusUtf16 = NULL;
|
|
|
|
|
|
|
|
/* dump IDE hdds if present */
|
|
|
|
VBOX_UTF8_TO_UTF16(hddBus, &hddBusUtf16);
|
|
|
|
|
|
|
|
def->ndisks = 0;
|
|
|
|
machine->vtbl->GetHardDisk(machine, hddBusUtf16, 0, 0, &hardDiskPM);
|
|
|
|
if (hardDiskPM)
|
|
|
|
def->ndisks++;
|
|
|
|
|
|
|
|
machine->vtbl->GetHardDisk(machine, hddBusUtf16, 0, 1, &hardDiskPS);
|
|
|
|
if (hardDiskPS)
|
|
|
|
def->ndisks++;
|
|
|
|
|
|
|
|
machine->vtbl->GetHardDisk(machine, hddBusUtf16, 1, 1, &hardDiskSS);
|
|
|
|
if (hardDiskSS)
|
|
|
|
def->ndisks++;
|
|
|
|
|
|
|
|
VBOX_UTF16_FREE(hddBusUtf16);
|
|
|
|
|
|
|
|
if ((def->ndisks > 0) && (VIR_ALLOC_N(def->disks, def->ndisks) >= 0)) {
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < def->ndisks; i++) {
|
|
|
|
if ((def->disks[i] = virDomainDiskDefNew())) {
|
|
|
|
def->disks[i]->device = VIR_DOMAIN_DISK_DEVICE_DISK;
|
|
|
|
def->disks[i]->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
|
|
|
virDomainDiskSetType(def->disks[i],
|
|
|
|
VIR_STORAGE_TYPE_FILE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hardDiskPM) {
|
|
|
|
PRUnichar *hddlocationUtf16 = NULL;
|
|
|
|
char *hddlocation = NULL;
|
|
|
|
PRUint32 hddType = HardDiskType_Normal;
|
|
|
|
|
|
|
|
hardDiskPM->vtbl->imedium.GetLocation((IMedium *)hardDiskPM, &hddlocationUtf16);
|
|
|
|
VBOX_UTF16_TO_UTF8(hddlocationUtf16, &hddlocation);
|
|
|
|
|
|
|
|
hardDiskPM->vtbl->GetType(hardDiskPM, &hddType);
|
|
|
|
|
|
|
|
if (hddType == HardDiskType_Immutable)
|
|
|
|
def->disks[hddNum]->src->readonly = true;
|
|
|
|
ignore_value(virDomainDiskSetSource(def->disks[hddNum],
|
|
|
|
hddlocation));
|
|
|
|
ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hda"));
|
|
|
|
hddNum++;
|
|
|
|
|
|
|
|
VBOX_UTF8_FREE(hddlocation);
|
|
|
|
VBOX_UTF16_FREE(hddlocationUtf16);
|
|
|
|
VBOX_MEDIUM_RELEASE(hardDiskPM);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hardDiskPS) {
|
|
|
|
PRUnichar *hddlocationUtf16 = NULL;
|
|
|
|
char *hddlocation = NULL;
|
|
|
|
PRUint32 hddType = HardDiskType_Normal;
|
|
|
|
|
|
|
|
hardDiskPS->vtbl->imedium.GetLocation((IMedium *)hardDiskPS, &hddlocationUtf16);
|
|
|
|
VBOX_UTF16_TO_UTF8(hddlocationUtf16, &hddlocation);
|
|
|
|
|
|
|
|
hardDiskPS->vtbl->GetType(hardDiskPS, &hddType);
|
|
|
|
|
|
|
|
if (hddType == HardDiskType_Immutable)
|
|
|
|
def->disks[hddNum]->src->readonly = true;
|
|
|
|
ignore_value(virDomainDiskSetSource(def->disks[hddNum],
|
|
|
|
hddlocation));
|
|
|
|
ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hdb"));
|
|
|
|
hddNum++;
|
|
|
|
|
|
|
|
VBOX_UTF8_FREE(hddlocation);
|
|
|
|
VBOX_UTF16_FREE(hddlocationUtf16);
|
|
|
|
VBOX_MEDIUM_RELEASE(hardDiskPS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hardDiskSS) {
|
|
|
|
PRUnichar *hddlocationUtf16 = NULL;
|
|
|
|
char *hddlocation = NULL;
|
|
|
|
PRUint32 hddType = HardDiskType_Normal;
|
|
|
|
|
|
|
|
hardDiskSS->vtbl->imedium.GetLocation((IMedium *)hardDiskSS, &hddlocationUtf16);
|
|
|
|
VBOX_UTF16_TO_UTF8(hddlocationUtf16, &hddlocation);
|
|
|
|
|
|
|
|
hardDiskSS->vtbl->GetType(hardDiskSS, &hddType);
|
|
|
|
|
|
|
|
if (hddType == HardDiskType_Immutable)
|
|
|
|
def->disks[hddNum]->src->readonly = true;
|
|
|
|
ignore_value(virDomainDiskSetSource(def->disks[hddNum],
|
|
|
|
hddlocation));
|
|
|
|
ignore_value(VIR_STRDUP(def->disks[hddNum]->dst, "hdd"));
|
|
|
|
hddNum++;
|
|
|
|
|
|
|
|
VBOX_UTF8_FREE(hddlocation);
|
|
|
|
VBOX_UTF16_FREE(hddlocationUtf16);
|
|
|
|
VBOX_MEDIUM_RELEASE(hardDiskSS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dumpDVD(virDomainDefPtr def,
|
|
|
|
vboxGlobalData *data,
|
|
|
|
IMachine *machine)
|
|
|
|
{
|
|
|
|
IDVDDrive *dvdDrive = NULL;
|
|
|
|
IDVDImage *dvdImage = NULL;
|
|
|
|
PRUnichar *locationUtf16 = NULL;
|
|
|
|
char *location = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* dump CDROM/DVD if the drive is attached and has DVD/CD in it */
|
|
|
|
machine->vtbl->GetDVDDrive(machine, &dvdDrive);
|
|
|
|
if (!dvdDrive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PRUint32 state = DriveState_Null;
|
|
|
|
|
|
|
|
dvdDrive->vtbl->GetState(dvdDrive, &state);
|
|
|
|
if (state != DriveState_ImageMounted)
|
|
|
|
goto cleanupDVDDrive;
|
|
|
|
|
|
|
|
|
|
|
|
dvdDrive->vtbl->GetImage(dvdDrive, &dvdImage);
|
|
|
|
if (!dvdImage)
|
|
|
|
goto cleanupDVDDrive;
|
|
|
|
|
|
|
|
dvdImage->vtbl->imedium.GetLocation((IMedium *)dvdImage, &locationUtf16);
|
|
|
|
VBOX_UTF16_TO_UTF8(locationUtf16, &location);
|
|
|
|
|
|
|
|
def->ndisks++;
|
|
|
|
if (VIR_REALLOC_N(def->disks, def->ndisks) >= 0) {
|
|
|
|
if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew())) {
|
|
|
|
def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_CDROM;
|
|
|
|
def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_IDE;
|
|
|
|
virDomainDiskSetType(def->disks[def->ndisks - 1],
|
|
|
|
VIR_STORAGE_TYPE_FILE);
|
|
|
|
def->disks[def->ndisks - 1]->src->readonly = true;
|
|
|
|
ignore_value(virDomainDiskSetSource(def->disks[def->ndisks - 1], location));
|
|
|
|
ignore_value(VIR_STRDUP(def->disks[def->ndisks - 1]->dst, "hdc"));
|
|
|
|
def->ndisks--;
|
|
|
|
} else {
|
|
|
|
def->ndisks--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
def->ndisks--;
|
|
|
|
}
|
|
|
|
|
|
|
|
VBOX_UTF8_FREE(location);
|
|
|
|
VBOX_UTF16_FREE(locationUtf16);
|
|
|
|
VBOX_MEDIUM_RELEASE(dvdImage);
|
|
|
|
|
|
|
|
cleanupDVDDrive:
|
|
|
|
VBOX_RELEASE(dvdDrive);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:47 +00:00
|
|
|
static int
|
|
|
|
_attachDVD(vboxGlobalData *data, IMachine *machine, const char *src)
|
|
|
|
{
|
|
|
|
IDVDDrive *dvdDrive = NULL;
|
|
|
|
IDVDImage *dvdImage = NULL;
|
|
|
|
PRUnichar *dvdfileUtf16 = NULL;
|
|
|
|
vboxIID dvduuid = VBOX_IID_INITIALIZER;
|
|
|
|
vboxIID dvdemptyuuid = VBOX_IID_INITIALIZER;
|
|
|
|
nsresult rc;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
/* Currently CDROM/DVD Drive is always IDE
|
|
|
|
* Secondary Master so neglecting the following
|
|
|
|
* parameter dev->data.disk->bus
|
|
|
|
*/
|
|
|
|
machine->vtbl->GetDVDDrive(machine, &dvdDrive);
|
|
|
|
if (!dvdDrive)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16);
|
|
|
|
|
|
|
|
data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage);
|
2014-11-13 14:21:37 +00:00
|
|
|
if (!dvdImage)
|
2014-08-11 10:06:47 +00:00
|
|
|
data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage);
|
|
|
|
|
|
|
|
if (!dvdImage)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
rc = dvdImage->vtbl->imedium.GetId((IMedium *)dvdImage, &dvduuid.value);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("can't get the uuid of the file to "
|
|
|
|
"be attached to cdrom: %s, rc=%08x"),
|
|
|
|
src, (unsigned)rc);
|
|
|
|
} else {
|
|
|
|
/* unmount the previous mounted image */
|
|
|
|
dvdDrive->vtbl->Unmount(dvdDrive);
|
|
|
|
rc = dvdDrive->vtbl->MountImage(dvdDrive, dvduuid.value);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not attach the file to cdrom: %s, rc=%08x"),
|
|
|
|
src, (unsigned)rc);
|
|
|
|
} else {
|
|
|
|
ret = 0;
|
|
|
|
DEBUGIID("CD/DVD Image UUID:", dvduuid.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VBOX_MEDIUM_RELEASE(dvdImage);
|
|
|
|
cleanup:
|
|
|
|
vboxIIDUnalloc(&dvduuid);
|
|
|
|
VBOX_UTF16_FREE(dvdfileUtf16);
|
|
|
|
VBOX_RELEASE(dvdDrive);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:50 +00:00
|
|
|
static int
|
|
|
|
_detachDVD(IMachine *machine)
|
|
|
|
{
|
|
|
|
IDVDDrive *dvdDrive = NULL;
|
|
|
|
int ret = -1;
|
|
|
|
nsresult rc;
|
|
|
|
/* Currently CDROM/DVD Drive is always IDE
|
|
|
|
* Secondary Master so neglecting the following
|
|
|
|
* parameter dev->data.disk->bus
|
|
|
|
*/
|
|
|
|
machine->vtbl->GetDVDDrive(machine, &dvdDrive);
|
|
|
|
if (!dvdDrive)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
rc = dvdDrive->vtbl->Unmount(dvdDrive);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not de-attach the mounted ISO, rc=%08x"),
|
|
|
|
(unsigned)rc);
|
|
|
|
} else {
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
VBOX_RELEASE(dvdDrive);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static void
|
|
|
|
_dumpFloppy(virDomainDefPtr def,
|
|
|
|
vboxGlobalData *data,
|
|
|
|
IMachine *machine)
|
|
|
|
{
|
|
|
|
IFloppyDrive *floppyDrive = NULL;
|
|
|
|
IFloppyImage *floppyImage = NULL;
|
|
|
|
PRUnichar *locationUtf16 = NULL;
|
|
|
|
char *location = NULL;
|
|
|
|
PRBool enabled = PR_FALSE;
|
|
|
|
PRUint32 state = DriveState_Null;
|
|
|
|
|
|
|
|
/* dump Floppy if the drive is attached and has floppy in it */
|
|
|
|
machine->vtbl->GetFloppyDrive(machine, &floppyDrive);
|
|
|
|
if (!floppyDrive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
floppyDrive->vtbl->GetEnabled(floppyDrive, &enabled);
|
|
|
|
if (!enabled)
|
|
|
|
goto cleanupFloppyDrive;
|
|
|
|
|
|
|
|
|
|
|
|
floppyDrive->vtbl->GetState(floppyDrive, &state);
|
|
|
|
if (state != DriveState_ImageMounted)
|
|
|
|
goto cleanupFloppyDrive;
|
|
|
|
|
|
|
|
floppyDrive->vtbl->GetImage(floppyDrive, &floppyImage);
|
|
|
|
if (!floppyImage)
|
|
|
|
goto cleanupFloppyDrive;
|
|
|
|
|
|
|
|
floppyImage->vtbl->imedium.GetLocation((IMedium *)floppyImage, &locationUtf16);
|
|
|
|
VBOX_UTF16_TO_UTF8(locationUtf16, &location);
|
|
|
|
|
|
|
|
def->ndisks++;
|
|
|
|
if (VIR_REALLOC_N(def->disks, def->ndisks) >= 0) {
|
|
|
|
if ((def->disks[def->ndisks - 1] = virDomainDiskDefNew())) {
|
|
|
|
def->disks[def->ndisks - 1]->device = VIR_DOMAIN_DISK_DEVICE_FLOPPY;
|
|
|
|
def->disks[def->ndisks - 1]->bus = VIR_DOMAIN_DISK_BUS_FDC;
|
|
|
|
virDomainDiskSetType(def->disks[def->ndisks - 1],
|
|
|
|
VIR_STORAGE_TYPE_FILE);
|
|
|
|
def->disks[def->ndisks - 1]->src->readonly = false;
|
|
|
|
ignore_value(virDomainDiskSetSource(def->disks[def->ndisks - 1], location));
|
|
|
|
ignore_value(VIR_STRDUP(def->disks[def->ndisks - 1]->dst, "fda"));
|
|
|
|
def->ndisks--;
|
|
|
|
} else {
|
|
|
|
def->ndisks--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
def->ndisks--;
|
|
|
|
}
|
|
|
|
|
|
|
|
VBOX_UTF8_FREE(location);
|
|
|
|
VBOX_UTF16_FREE(locationUtf16);
|
|
|
|
VBOX_MEDIUM_RELEASE(floppyImage);
|
|
|
|
|
|
|
|
cleanupFloppyDrive:
|
|
|
|
VBOX_RELEASE(floppyDrive);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:47 +00:00
|
|
|
static int
|
|
|
|
_attachFloppy(vboxGlobalData *data, IMachine *machine, const char *src)
|
|
|
|
{
|
|
|
|
IFloppyDrive *floppyDrive;
|
|
|
|
IFloppyImage *floppyImage = NULL;
|
|
|
|
PRUnichar *fdfileUtf16 = NULL;
|
|
|
|
vboxIID fduuid = VBOX_IID_INITIALIZER;
|
|
|
|
vboxIID fdemptyuuid = VBOX_IID_INITIALIZER;
|
|
|
|
nsresult rc;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
machine->vtbl->GetFloppyDrive(machine, &floppyDrive);
|
|
|
|
if (!floppyDrive)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
rc = floppyDrive->vtbl->SetEnabled(floppyDrive, 1);
|
|
|
|
if (NS_FAILED(rc))
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
VBOX_UTF8_TO_UTF16(src, &fdfileUtf16);
|
|
|
|
rc = data->vboxObj->vtbl->FindFloppyImage(data->vboxObj,
|
|
|
|
fdfileUtf16,
|
|
|
|
&floppyImage);
|
|
|
|
|
|
|
|
if (!floppyImage) {
|
|
|
|
data->vboxObj->vtbl->OpenFloppyImage(data->vboxObj,
|
|
|
|
fdfileUtf16,
|
|
|
|
fdemptyuuid.value,
|
|
|
|
&floppyImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (floppyImage) {
|
|
|
|
rc = floppyImage->vtbl->imedium.GetId((IMedium *)floppyImage, &fduuid.value);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("can't get the uuid of the file to be "
|
|
|
|
"attached to floppy drive: %s, rc=%08x"),
|
|
|
|
src, (unsigned)rc);
|
|
|
|
} else {
|
|
|
|
rc = floppyDrive->vtbl->MountImage(floppyDrive, fduuid.value);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not attach the file to floppy drive: %s, rc=%08x"),
|
|
|
|
src, (unsigned)rc);
|
|
|
|
} else {
|
|
|
|
ret = 0;
|
|
|
|
DEBUGIID("attached floppy, UUID:", fduuid.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
VBOX_MEDIUM_RELEASE(floppyImage);
|
|
|
|
}
|
|
|
|
vboxIIDUnalloc(&fduuid);
|
|
|
|
VBOX_UTF16_FREE(fdfileUtf16);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
VBOX_RELEASE(floppyDrive);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:50 +00:00
|
|
|
static int
|
|
|
|
_detachFloppy(IMachine *machine)
|
|
|
|
{
|
|
|
|
IFloppyDrive *floppyDrive;
|
|
|
|
int ret = -1;
|
|
|
|
nsresult rc;
|
|
|
|
|
|
|
|
machine->vtbl->GetFloppyDrive(machine, &floppyDrive);
|
|
|
|
if (!floppyDrive)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
PRBool enabled = PR_FALSE;
|
|
|
|
|
|
|
|
floppyDrive->vtbl->GetEnabled(floppyDrive, &enabled);
|
|
|
|
if (enabled) {
|
|
|
|
rc = floppyDrive->vtbl->Unmount(floppyDrive);
|
|
|
|
if (NS_FAILED(rc)) {
|
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
|
_("could not attach the file "
|
|
|
|
"to floppy drive, rc=%08x"),
|
|
|
|
(unsigned)rc);
|
|
|
|
} else {
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* If you are here means floppy drive is already unmounted
|
|
|
|
* so don't flag error, just say everything is fine and quit
|
|
|
|
*/
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
VBOX_RELEASE(floppyDrive);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dumpIDEHDDsOld(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|
|
|
vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_dumpDVD(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|
|
|
vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:47 +00:00
|
|
|
static int
|
|
|
|
_attachDVD(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
const char *src ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:50 +00:00
|
|
|
static int
|
|
|
|
_detachDVD(IMachine *machine ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static void
|
|
|
|
_dumpFloppy(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|
|
|
vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:47 +00:00
|
|
|
static int
|
|
|
|
_attachFloppy(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
const char *src ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:50 +00:00
|
|
|
static int
|
|
|
|
_detachFloppy(IMachine *machine ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _pfnUninitialize(vboxGlobalData *data)
|
|
|
|
{
|
|
|
|
if (data->pFuncs)
|
|
|
|
data->pFuncs->pfnComUninitialize();
|
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
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#if VBOX_API_VERSION == 2002000
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _vboxIIDInitialize(vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
memset(iidu, 0, sizeof(vboxIIDUnion));
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _DEBUGIID(const char *msg, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
# ifdef WIN32
|
|
|
|
DEBUGUUID(msg, (nsID *)&IID_MEMBER(value));
|
|
|
|
# else /* !WIN32 */
|
|
|
|
DEBUGUUID(msg, IID_MEMBER(value));
|
|
|
|
# endif /* !WIN32 */
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#else /* VBOX_API_VERSION != 2002000 */
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _vboxIIDInitialize(vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
memset(iidu, 0, sizeof(vboxIIDUnion));
|
|
|
|
IID_MEMBER(owner) = true;
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static void _DEBUGIID(const char *msg, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
DEBUGPRUnichar(msg, IID_MEMBER(value));
|
|
|
|
}
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#endif /* VBOX_API_VERSION != 2002000 */
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static void
|
|
|
|
_vboxIIDToUtf8(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
vboxIIDUnion *iidu ATTRIBUTE_UNUSED,
|
|
|
|
char **utf8 ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
vboxUnsupported();
|
|
|
|
#else /* !(VBOX_API_VERSION == 2002000) */
|
|
|
|
data->pFuncs->pfnUtf16ToUtf8(IID_MEMBER(value), utf8);
|
|
|
|
#endif /* !(VBOX_API_VERSION == 2002000) */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static nsresult
|
|
|
|
_vboxArrayGetWithIIDArg(vboxArray *array, void *self, void *getter, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
return vboxArrayGetWithPtrArg(array, self, getter, IID_MEMBER(value));
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* _handleMachineGetMediumAttachments(IMachine *machine)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
return machine->vtbl->GetHardDiskAttachments;
|
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
return machine->vtbl->GetMediumAttachments;
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* _handleMediumGetChildren(IMedium *medium ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
return medium->vtbl->GetChildren;
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
#if VBOX_API_VERSION < 4000000
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxGetMachine(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->GetMachine(vboxObj, IID_MEMBER(value), machine);
|
|
|
|
}
|
2013-05-03 12:50:19 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
2011-04-01 13:34:23 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxGetMachine(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine)
|
|
|
|
{
|
|
|
|
return vboxObj->vtbl->FindMachine(vboxObj, IID_MEMBER(value), machine);
|
2011-04-01 13:34:23 +00:00
|
|
|
}
|
2014-08-11 10:06:19 +00:00
|
|
|
|
2013-12-24 09:39:38 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
2011-04-01 13:34:23 +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
|
|
|
|
_virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr ATTRIBUTE_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;
|
2012-06-05 12:12:21 +00:00
|
|
|
nsresult rc;
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
VBOX_UTF8_TO_UTF16(def->name, &machineNameUtf16);
|
|
|
|
vboxIIDFromUUID(&iid, def->uuid);
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3002000
|
|
|
|
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
|
|
|
|
machineNameUtf16,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
iid.value,
|
|
|
|
machine);
|
|
|
|
#elif VBOX_API_VERSION < 4000000 /* 3002000 <= VBOX_API_VERSION < 4000000 */
|
|
|
|
PRBool override = PR_FALSE;
|
|
|
|
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
|
|
|
|
machineNameUtf16,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
iid.value,
|
|
|
|
override,
|
|
|
|
machine);
|
|
|
|
#elif VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000
|
|
|
|
PRBool override = PR_FALSE;
|
|
|
|
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
|
|
|
|
NULL,
|
|
|
|
machineNameUtf16,
|
|
|
|
NULL,
|
|
|
|
iid.value,
|
|
|
|
override,
|
|
|
|
machine);
|
|
|
|
#else /* VBOX_API_VERSION >= 4002000 */
|
|
|
|
const char *flagsUUIDPrefix = "UUID=";
|
|
|
|
const char *flagsForceOverwrite = "forceOverwrite=0";
|
|
|
|
const char *flagsSeparator = ",";
|
|
|
|
char createFlags[strlen(flagsUUIDPrefix) + VIR_UUID_STRING_BUFLEN + strlen(flagsSeparator) + strlen(flagsForceOverwrite) + 1];
|
|
|
|
PRUnichar *createFlagsUtf16 = NULL;
|
|
|
|
|
|
|
|
snprintf(createFlags, sizeof(createFlags), "%s%s%s%s",
|
|
|
|
flagsUUIDPrefix,
|
|
|
|
uuidstr,
|
|
|
|
flagsSeparator,
|
|
|
|
flagsForceOverwrite
|
|
|
|
);
|
|
|
|
VBOX_UTF8_TO_UTF16(createFlags, &createFlagsUtf16);
|
|
|
|
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
|
|
|
|
NULL,
|
|
|
|
machineNameUtf16,
|
|
|
|
0,
|
|
|
|
nsnull,
|
|
|
|
nsnull,
|
|
|
|
createFlagsUtf16,
|
|
|
|
machine);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4002000 */
|
2012-06-05 12:12:21 +00:00
|
|
|
}
|
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,
|
|
|
|
PRUnichar *location, IHardDisk **hardDisk)
|
2014-08-11 10:06:52 +00:00
|
|
|
{
|
2014-10-24 01:46:45 +00:00
|
|
|
/* In vbox 2.2 and 3.0, this function will create a IHardDisk object.
|
|
|
|
* In vbox 3.1 and later, this function will create a IMedium object.
|
|
|
|
*/
|
|
|
|
return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, hardDisk);
|
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
|
2014-10-24 01:46:43 +00:00
|
|
|
_virtualboxFindHardDisk(IVirtualBox *vboxObj, PRUnichar *location,
|
|
|
|
PRUint32 deviceType ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 accessMode ATTRIBUTE_UNUSED,
|
|
|
|
IHardDisk **hardDisk)
|
2014-08-11 10:06:19 +00:00
|
|
|
{
|
2014-10-24 01:46:43 +00:00
|
|
|
/* In vbox 2.2 and 3.0, this function will create a IHardDisk object.
|
|
|
|
* In vbox 3.1 and later, this function will create a IMedium object.
|
|
|
|
*/
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return vboxObj->vtbl->FindHardDisk(vboxObj, location, hardDisk);
|
|
|
|
#elif VBOX_API_VERSION < 4002000
|
2014-08-11 10:06:19 +00:00
|
|
|
return vboxObj->vtbl->FindMedium(vboxObj, location,
|
2014-10-24 01:46:43 +00:00
|
|
|
deviceType, hardDisk);
|
|
|
|
#else /* VBOX_API_VERSION >= 4002000 */
|
2014-08-11 10:06:19 +00:00
|
|
|
return vboxObj->vtbl->OpenMedium(vboxObj, location,
|
2014-10-24 01:46:43 +00:00
|
|
|
deviceType, accessMode, PR_FALSE, hardDisk);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4002000 */
|
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
|
|
|
|
_virtualboxOpenMedium(IVirtualBox *vboxObj ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *location ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 deviceType ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 accessMode ATTRIBUTE_UNUSED,
|
|
|
|
IMedium **medium ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION == 4000000
|
|
|
|
return vboxObj->vtbl->OpenMedium(vboxObj,
|
|
|
|
location,
|
|
|
|
deviceType, accessMode,
|
|
|
|
medium);
|
|
|
|
#elif VBOX_API_VERSION >= 4001000
|
|
|
|
return vboxObj->vtbl->OpenMedium(vboxObj,
|
|
|
|
location,
|
|
|
|
deviceType, accessMode,
|
|
|
|
false,
|
|
|
|
medium);
|
|
|
|
#else
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-10-24 01:46:42 +00:00
|
|
|
static nsresult
|
|
|
|
_virtualboxGetHardDiskByIID(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IHardDisk **hardDisk)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return vboxObj->vtbl->GetHardDisk(vboxObj, IID_MEMBER(value), hardDisk);
|
|
|
|
#elif VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 4002000
|
|
|
|
return vboxObj->vtbl->FindMedium(vboxObj, IID_MEMBER(value), DeviceType_HardDisk,
|
|
|
|
hardDisk);
|
|
|
|
#else /* VBOX_API_VERSION >= 4002000 */
|
|
|
|
return vboxObj->vtbl->OpenMedium(vboxObj, IID_MEMBER(value), DeviceType_HardDisk,
|
|
|
|
AccessMode_ReadWrite, PR_FALSE, hardDisk);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4002000 */
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
_machineAttachDevice(IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *name ATTRIBUTE_UNUSED,
|
|
|
|
PRInt32 controllerPort ATTRIBUTE_UNUSED,
|
|
|
|
PRInt32 device ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 type ATTRIBUTE_UNUSED,
|
|
|
|
IMedium * medium ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION >= 4000000
|
|
|
|
return machine->vtbl->AttachDevice(machine, name, controllerPort,
|
|
|
|
device, type, medium);
|
|
|
|
#else /* VBOX_API_VERSION < 4000000 */
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#endif /* VBOX_API_VERSION < 4000000 */
|
|
|
|
}
|
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,
|
|
|
|
PRBool automount ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return machine->vtbl->CreateSharedFolder(machine, name, hostPath,
|
|
|
|
writable);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return machine->vtbl->CreateSharedFolder(machine, name, hostPath,
|
|
|
|
writable, automount);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
}
|
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
|
|
|
|
_machineLaunchVMProcess(vboxGlobalData *data,
|
|
|
|
IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
vboxIIDUnion *iidu ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar *sessionType, PRUnichar *env,
|
|
|
|
IProgress **progress)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return data->vboxObj->vtbl->OpenRemoteSession(data->vboxObj,
|
|
|
|
data->vboxSession,
|
|
|
|
IID_MEMBER(value),
|
|
|
|
sessionType,
|
|
|
|
env,
|
|
|
|
progress);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
|
|
|
|
sessionType, env, progress);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
}
|
2012-06-05 12:12:21 +00:00
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
|
|
|
_machineUnregister(IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 cleanupMode ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *aMediaSize ATTRIBUTE_UNUSED,
|
|
|
|
IMedium ***aMedia ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return machine->vtbl->Unregister(machine, cleanupMode, aMediaSize, aMedia);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:54 +00:00
|
|
|
static nsresult
|
|
|
|
_machineFindSnapshot(IMachine *machine, vboxIIDUnion *iidu, ISnapshot **snapshot)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return machine->vtbl->GetSnapshot(machine, IID_MEMBER(value), snapshot);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return machine->vtbl->FindSnapshot(machine, IID_MEMBER(value), snapshot);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:48 +00:00
|
|
|
static nsresult
|
|
|
|
_machineDetachDevice(IMachine *machine, PRUnichar *name,
|
|
|
|
PRInt32 controllerPort, PRInt32 device)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
return machine->vtbl->DetachHardDisk(machine, name, controllerPort, device);
|
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
return machine->vtbl->DetachDevice(machine, name, controllerPort, device);
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
_machineGetId(IMachine *machine, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetId(machine, &IID_MEMBER(value));
|
|
|
|
}
|
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
|
|
|
|
_machineGetChipsetType(IMachine *machine ATTRIBUTE_UNUSED, PRUint32 *chipsetType ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION >= 4001000
|
|
|
|
return machine->vtbl->GetChipsetType(machine, chipsetType);
|
|
|
|
#else /* VBOX_API_VERSION < 4001000 */
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#endif /* VBOX_API_VERSION < 4001000 */
|
|
|
|
}
|
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
|
|
|
|
_machineGetVRDxServer(IMachine *machine, IVRDxServer **VRDxServer)
|
2013-04-26 17:21:58 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return machine->vtbl->GetVRDPServer(machine, VRDxServer);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return machine->vtbl->GetVRDEServer(machine, VRDxServer);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
2013-04-26 17:21:58 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetUSBCommon(IMachine *machine, IUSBCommon **USBCommon)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4003000
|
|
|
|
return machine->vtbl->GetUSBController(machine, USBCommon);
|
|
|
|
#else
|
|
|
|
return machine->vtbl->GetUSBDeviceFilters(machine, USBCommon);
|
|
|
|
#endif
|
|
|
|
}
|
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
|
|
|
|
_machineGetCPUProperty(IMachine *machine, PRUint32 property ATTRIBUTE_UNUSED, PRBool *value)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
return machine->vtbl->GetPAEEnabled(machine, value);
|
|
|
|
#elif VBOX_API_VERSION == 3001000
|
|
|
|
return machine->vtbl->GetCpuProperty(machine, property, value);
|
|
|
|
#elif VBOX_API_VERSION >= 3002000
|
|
|
|
return machine->vtbl->GetCPUProperty(machine, property, value);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetCPUProperty(IMachine *machine, PRUint32 property ATTRIBUTE_UNUSED, PRBool value)
|
2013-04-26 17:21:58 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
return machine->vtbl->SetPAEEnabled(machine, value);
|
|
|
|
#elif VBOX_API_VERSION == 3001000
|
|
|
|
return machine->vtbl->SetCpuProperty(machine, property, value);
|
|
|
|
#elif VBOX_API_VERSION >= 3002000
|
|
|
|
return machine->vtbl->SetCPUProperty(machine, property, value);
|
|
|
|
#endif
|
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)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetVRAMSize(machine, VRAMSize);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetVRAMSize(IMachine *machine, PRUint32 VRAMSize)
|
2014-06-10 14:16:44 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetVRAMSize(machine, VRAMSize);
|
|
|
|
}
|
2014-06-10 14:16:44 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetMonitorCount(IMachine *machine, PRUint32 *monitorCount)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetMonitorCount(machine, monitorCount);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetMonitorCount(IMachine *machine, PRUint32 monitorCount)
|
|
|
|
{
|
|
|
|
return machine->vtbl->SetMonitorCount(machine, monitorCount);
|
2014-06-10 14:16:44 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetAccelerate3DEnabled(IMachine *machine, PRBool *accelerate3DEnabled)
|
|
|
|
{
|
|
|
|
return machine->vtbl->GetAccelerate3DEnabled(machine, accelerate3DEnabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetAccelerate3DEnabled(IMachine *machine, PRBool accelerate3DEnabled)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return machine->vtbl->SetAccelerate3DEnabled(machine, accelerate3DEnabled);
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_machineGetAccelerate2DVideoEnabled(IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
PRBool *accelerate2DVideoEnabled ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION >= 3001000
|
|
|
|
return machine->vtbl->GetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
|
|
|
|
#else /* VBOX_API_VERSION < 3001000 */
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#endif /* VBOX_API_VERSION < 3001000 */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_machineSetAccelerate2DVideoEnabled(IMachine *machine ATTRIBUTE_UNUSED,
|
|
|
|
PRBool accelerate2DVideoEnabled ATTRIBUTE_UNUSED)
|
2014-08-11 10:06:04 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
#if VBOX_API_VERSION >= 3001000
|
|
|
|
return machine->vtbl->SetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
|
|
|
|
#else /* VBOX_API_VERSION < 3001000 */
|
2014-08-11 10:06:04 +00:00
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
2014-08-11 10:06:19 +00:00
|
|
|
#endif /* VBOX_API_VERSION < 3001000 */
|
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:18 +00:00
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_sessionOpen(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return data->vboxObj->vtbl->OpenSession(data->vboxObj, data->vboxSession, IID_MEMBER(value));
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
2014-08-11 10:06:19 +00:00
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_sessionOpenExisting(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine *machine ATTRIBUTE_UNUSED)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return data->vboxObj->vtbl->OpenExistingSession(data->vboxObj, data->vboxSession, IID_MEMBER(value));
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_sessionClose(ISession *session)
|
|
|
|
{
|
|
|
|
return session->vtbl->Close(session);
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_sessionOpen(vboxGlobalData *data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
_sessionOpenExisting(vboxGlobalData *data, vboxIIDUnion *iidu ATTRIBUTE_UNUSED, IMachine *machine)
|
|
|
|
{
|
|
|
|
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
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
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)
|
|
|
|
{
|
|
|
|
return console->vtbl->SaveState(console, progress);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
rc = console->vtbl->PowerDown(console);
|
|
|
|
#else
|
|
|
|
IProgress *progress = NULL;
|
|
|
|
rc = console->vtbl->PowerDown(console, &progress);
|
|
|
|
if (progress) {
|
|
|
|
rc = progress->vtbl->WaitForCompletion(progress, -1);
|
|
|
|
VBOX_RELEASE(progress);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return console->vtbl->TakeSnapshot(console, name, description, progress);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:07:04 +00:00
|
|
|
static nsresult
|
|
|
|
_consoleDeleteSnapshot(IConsole *console, vboxIIDUnion *iidu, IProgress **progress)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
return console->vtbl->DiscardSnapshot(console, IID_MEMBER(value), progress);
|
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
return console->vtbl->DeleteSnapshot(console, IID_MEMBER(value), progress);
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:07:05 +00:00
|
|
|
static nsresult
|
|
|
|
_consoleGetDisplay(IConsole *console, IDisplay **display)
|
|
|
|
{
|
|
|
|
return console->vtbl->GetDisplay(console, display);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
return progress->vtbl->GetResultCode(progress, &resultCode->uResultCode);
|
|
|
|
#else /* VBOX_API_VERSION != 2002000 */
|
|
|
|
return progress->vtbl->GetResultCode(progress, &resultCode->resultCode);
|
|
|
|
#endif /* VBOX_API_VERSION != 2002000 */
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
_systemPropertiesGetMaxNetworkAdapters(ISystemProperties *systemProperties, PRUint32 chipset ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *maxNetworkAdapters)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
#if VBOX_API_VERSION < 4001000
|
|
|
|
return systemProperties->vtbl->GetNetworkAdapterCount(systemProperties,
|
|
|
|
maxNetworkAdapters);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return systemProperties->vtbl->GetMaxNetworkAdapters(systemProperties, chipset,
|
|
|
|
maxNetworkAdapters);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
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
|
|
|
#if VBOX_API_VERSION >= 3001000
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
#else /* VBOX_API_VERSION < 3001000 */
|
|
|
|
static nsresult
|
|
|
|
_systemPropertiesGetMaxPortCountForStorageBus(ISystemProperties *systemProperties ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 bus ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *maxPortCount ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
2014-08-11 10:06:18 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_systemPropertiesGetMaxDevicesPerPortForStorageBus(ISystemProperties *systemProperties ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 bus ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *maxDevicesPerPort ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
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:19 +00:00
|
|
|
#if VBOX_API_VERSION < 4001000
|
2014-08-11 10:06:06 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterGetBridgedInterface(INetworkAdapter *adapter, PRUnichar **hostInterface)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->GetHostInterface(adapter, hostInterface);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterSetBridgedInterface(INetworkAdapter *adapter, PRUnichar *hostInterface)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetHostInterface(adapter, hostInterface);
|
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->GetHostInterface(adapter, hostOnlyInterface);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterSetHostOnlyInterface(INetworkAdapter *adapter, PRUnichar *hostOnlyInterface)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->SetHostInterface(adapter, hostOnlyInterface);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterAttachToBridgedInterface(INetworkAdapter *adapter)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->AttachToBridgedInterface(adapter);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterAttachToInternalNetwork(INetworkAdapter *adapter)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->AttachToInternalNetwork(adapter);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterAttachToHostOnlyInterface(INetworkAdapter *adapter)
|
|
|
|
{
|
|
|
|
return adapter->vtbl->AttachToHostOnlyInterface(adapter);
|
|
|
|
}
|
2014-08-11 10:06:06 +00:00
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_networkAdapterAttachToNAT(INetworkAdapter *adapter)
|
2014-08-11 10:06:14 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return adapter->vtbl->AttachToNAT(adapter);
|
2014-08-11 10:06:14 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 4001000 */
|
|
|
|
|
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:19 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 4001000 */
|
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
|
|
|
|
_vrdxServerGetEnabled(IVRDxServer *VRDxServer, PRBool *enabled)
|
|
|
|
{
|
|
|
|
return VRDxServer->vtbl->GetEnabled(VRDxServer, enabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_vrdxServerSetEnabled(IVRDxServer *VRDxServer, PRBool enabled)
|
|
|
|
{
|
|
|
|
return VRDxServer->vtbl->SetEnabled(VRDxServer, enabled);
|
|
|
|
}
|
2014-08-11 10:06:06 +00:00
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_vrdxServerGetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics)
|
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
PRUint32 VRDPport = 0;
|
|
|
|
rc = VRDxServer->vtbl->GetPort(VRDxServer, &VRDPport);
|
|
|
|
if (VRDPport) {
|
|
|
|
graphics->data.rdp.port = VRDPport;
|
|
|
|
} else {
|
|
|
|
graphics->data.rdp.autoport = true;
|
|
|
|
}
|
|
|
|
#elif VBOX_API_VERSION < 4000000 /* 3001000 <= VBOX_API_VERSION < 4000000 */
|
|
|
|
PRUnichar *VRDPport = NULL;
|
|
|
|
rc = VRDxServer->vtbl->GetPorts(VRDxServer, &VRDPport);
|
|
|
|
if (VRDPport) {
|
|
|
|
/* even if vbox supports mutilpe ports, single port for now here */
|
|
|
|
graphics->data.rdp.port = PRUnicharToInt(VRDPport);
|
|
|
|
VBOX_UTF16_FREE(VRDPport);
|
|
|
|
} else {
|
|
|
|
graphics->data.rdp.autoport = true;
|
|
|
|
}
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
PRUnichar *VRDEPortsKey = NULL;
|
|
|
|
PRUnichar *VRDEPortsValue = NULL;
|
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
|
|
|
|
rc = VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDEPortsKey, &VRDEPortsValue);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsKey);
|
|
|
|
if (VRDEPortsValue) {
|
|
|
|
/* even if vbox supports mutilpe ports, single port for now here */
|
|
|
|
graphics->data.rdp.port = PRUnicharToInt(VRDEPortsValue);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsValue);
|
|
|
|
} else {
|
|
|
|
graphics->data.rdp.autoport = true;
|
|
|
|
}
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:18 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_vrdxServerSetPorts(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IVRDxServer *VRDxServer, virDomainGraphicsDefPtr graphics)
|
2014-08-11 10:06:18 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
nsresult rc = 0;
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
if (graphics->data.rdp.port) {
|
|
|
|
rc = VRDxServer->vtbl->SetPort(VRDxServer,
|
|
|
|
graphics->data.rdp.port);
|
|
|
|
VIR_DEBUG("VRDP Port changed to: %d",
|
|
|
|
graphics->data.rdp.port);
|
|
|
|
} else if (graphics->data.rdp.autoport) {
|
|
|
|
/* Setting the port to 0 will reset its value to
|
|
|
|
* the default one which is 3389 currently
|
|
|
|
*/
|
|
|
|
rc = VRDxServer->vtbl->SetPort(VRDxServer, 0);
|
|
|
|
VIR_DEBUG("VRDP Port changed to default, which is 3389 currently");
|
|
|
|
}
|
|
|
|
#elif VBOX_API_VERSION < 4000000 /* 3001000 <= VBOX_API_VERSION < 4000000 */
|
|
|
|
PRUnichar *portUtf16 = NULL;
|
|
|
|
portUtf16 = PRUnicharFromInt(graphics->data.rdp.port);
|
|
|
|
rc = VRDxServer->vtbl->SetPorts(VRDxServer, portUtf16);
|
|
|
|
VBOX_UTF16_FREE(portUtf16);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
PRUnichar *VRDEPortsKey = NULL;
|
|
|
|
PRUnichar *VRDEPortsValue = NULL;
|
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Ports", &VRDEPortsKey);
|
|
|
|
VRDEPortsValue = PRUnicharFromInt(graphics->data.rdp.port);
|
|
|
|
rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, VRDEPortsKey,
|
|
|
|
VRDEPortsValue);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsKey);
|
|
|
|
VBOX_UTF16_FREE(VRDEPortsValue);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return rc;
|
2014-08-11 10:06:18 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_vrdxServerGetReuseSingleConnection(IVRDxServer *VRDxServer, PRBool *enabled)
|
|
|
|
{
|
|
|
|
return VRDxServer->vtbl->GetReuseSingleConnection(VRDxServer, enabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_vrdxServerSetReuseSingleConnection(IVRDxServer *VRDxServer, PRBool enabled)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return VRDxServer->vtbl->SetReuseSingleConnection(VRDxServer, enabled);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_vrdxServerGetAllowMultiConnection(IVRDxServer *VRDxServer, PRBool *enabled)
|
|
|
|
{
|
|
|
|
return VRDxServer->vtbl->GetAllowMultiConnection(VRDxServer, enabled);
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_vrdxServerSetAllowMultiConnection(IVRDxServer *VRDxServer, PRBool enabled)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
return VRDxServer->vtbl->SetAllowMultiConnection(VRDxServer, enabled);
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_vrdxServerGetNetAddress(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IVRDxServer *VRDxServer, PRUnichar **netAddress)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION >= 4000000
|
|
|
|
PRUnichar *VRDENetAddressKey = NULL;
|
|
|
|
nsresult rc;
|
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Address", &VRDENetAddressKey);
|
|
|
|
rc = VRDxServer->vtbl->GetVRDEProperty(VRDxServer, VRDENetAddressKey, netAddress);
|
|
|
|
VBOX_UTF16_FREE(VRDENetAddressKey);
|
|
|
|
return rc;
|
|
|
|
#else /* VBOX_API_VERSION < 4000000 */
|
|
|
|
return VRDxServer->vtbl->GetNetAddress(VRDxServer, netAddress);
|
|
|
|
#endif /* VBOX_API_VERSION < 4000000 */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:19 +00:00
|
|
|
static nsresult
|
|
|
|
_vrdxServerSetNetAddress(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IVRDxServer *VRDxServer, PRUnichar *netAddress)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return VRDxServer->vtbl->SetNetAddress(VRDxServer,
|
|
|
|
netAddress);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
PRUnichar *netAddressKey = NULL;
|
|
|
|
nsresult rc;
|
|
|
|
VBOX_UTF8_TO_UTF16("TCP/Address", &netAddressKey);
|
|
|
|
rc = VRDxServer->vtbl->SetVRDEProperty(VRDxServer, netAddressKey,
|
|
|
|
netAddress);
|
|
|
|
VBOX_UTF16_FREE(netAddressKey);
|
|
|
|
return rc;
|
2014-08-11 10:06:06 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
2014-08-11 10:06:19 +00:00
|
|
|
}
|
2014-08-11 10:06:06 +00:00
|
|
|
|
|
|
|
static nsresult
|
2014-08-11 10:06:19 +00:00
|
|
|
_usbCommonEnable(IUSBCommon *USBCommon ATTRIBUTE_UNUSED)
|
2014-08-11 10:06:06 +00:00
|
|
|
{
|
2014-08-11 10:06:19 +00:00
|
|
|
nsresult rc = 0;
|
|
|
|
#if VBOX_API_VERSION < 4003000
|
|
|
|
USBCommon->vtbl->SetEnabled(USBCommon, 1);
|
|
|
|
# if VBOX_API_VERSION < 4002000
|
|
|
|
rc = USBCommon->vtbl->SetEnabledEhci(USBCommon, 1);
|
|
|
|
# else /* VBOX_API_VERSION >= 4002000 */
|
|
|
|
rc = USBCommon->vtbl->SetEnabledEHCI(USBCommon, 1);
|
|
|
|
# endif /* VBOX_API_VERSION >= 4002000 */
|
|
|
|
#endif /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
/* We don't need to set usb enabled for vbox 4.3 and later */
|
|
|
|
return rc;
|
2014-08-11 10:06:06 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
|
|
|
_usbCommonGetEnabled(IUSBCommon *USBCommon ATTRIBUTE_UNUSED, PRBool *enabled)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4003000
|
|
|
|
return USBCommon->vtbl->GetEnabled(USBCommon, enabled);
|
|
|
|
#else /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
*enabled = true;
|
|
|
|
return 0;
|
|
|
|
#endif /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumGetId(IMedium *medium, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
return medium->vtbl->GetId(medium, &IID_MEMBER(value));
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
return medium->vtbl->GetSize(medium, uSize);
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
nsresult rc;
|
|
|
|
PRInt64 Size;
|
|
|
|
rc = medium->vtbl->GetSize(medium, &Size);
|
|
|
|
*uSize = Size;
|
|
|
|
return rc;
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult _mediumGetReadOnly(IMedium *medium ATTRIBUTE_UNUSED,
|
|
|
|
PRBool *readOnly ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
return medium->vtbl->GetReadOnly(medium, readOnly);
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
|
|
|
|
static nsresult _mediumGetParent(IMedium *medium ATTRIBUTE_UNUSED,
|
|
|
|
IMedium **parent ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumGetChildren(IMedium *medium ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *childrenSize ATTRIBUTE_UNUSED,
|
|
|
|
IMedium ***children ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumGetFormat(IMedium *medium ATTRIBUTE_UNUSED,
|
|
|
|
PRUnichar **format ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult _mediumDeleteStorage(IMedium *medium ATTRIBUTE_UNUSED,
|
|
|
|
IProgress **progress ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
|
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
|
|
|
|
|
|
|
static nsresult _mediumSetType(IMedium *medium ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 type ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION > 3000000
|
|
|
|
return medium->vtbl->SetType(medium, type);
|
|
|
|
#else
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#endif
|
2014-08-11 10:06:12 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:52 +00:00
|
|
|
static nsresult
|
|
|
|
_mediumCreateDiffStorage(IMedium *medium ATTRIBUTE_UNUSED,
|
|
|
|
IMedium *target ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 variantSize ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *variant ATTRIBUTE_UNUSED,
|
|
|
|
IProgress **progress ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#elif VBOX_API_VERSION < 4003000
|
|
|
|
if (variantSize == 0)
|
|
|
|
return 0;
|
|
|
|
if (variantSize > 1)
|
|
|
|
VIR_WARN("Only one variant is avaible in current version");
|
|
|
|
return medium->vtbl->CreateDiffStorage(medium, target, variant[0], progress);
|
|
|
|
#else /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
return medium->vtbl->CreateDiffStorage(medium, target, variantSize, variant, progress);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
}
|
|
|
|
|
2014-08-11 10:06:42 +00:00
|
|
|
static nsresult
|
2014-10-24 01:46:47 +00:00
|
|
|
_mediumAttachmentGetMedium(IMediumAttachment *mediumAttachment,
|
|
|
|
IHardDisk **hardDisk)
|
2014-08-11 10:06:42 +00:00
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
2014-10-24 01:46:47 +00:00
|
|
|
return mediumAttachment->vtbl->GetHardDisk(mediumAttachment, hardDisk);
|
2014-08-11 10:06:42 +00:00
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
2014-10-24 01:46:47 +00:00
|
|
|
return mediumAttachment->vtbl->GetMedium(mediumAttachment, hardDisk);
|
2014-08-11 10:06:42 +00:00
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_mediumAttachmentGetController(IMediumAttachment *mediumAttachment,
|
|
|
|
PRUnichar **controller)
|
|
|
|
{
|
|
|
|
return mediumAttachment->vtbl->GetController(mediumAttachment, controller);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_mediumAttachmentGetType(IMediumAttachment *mediumAttachment ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *type ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3001000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#else /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
return mediumAttachment->vtbl->GetType(mediumAttachment, type);
|
|
|
|
#endif /* VBOX_API_VERSION >= 3001000 */
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
_snapshotGetId(ISnapshot *snapshot, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
return snapshot->vtbl->GetId(snapshot, &IID_MEMBER(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
_displayGetScreenResolution(IDisplay *display ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 screenId ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *width ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *height ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *bitsPerPixel ATTRIBUTE_UNUSED,
|
|
|
|
PRInt32 *xOrigin ATTRIBUTE_UNUSED,
|
|
|
|
PRInt32 *yOrigin ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 3002000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#elif VBOX_API_VERSION < 4003000
|
|
|
|
return display->vtbl->GetScreenResolution(display, screenId, width,
|
|
|
|
height, bitsPerPixel);
|
|
|
|
#else /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
return display->vtbl->GetScreenResolution(display, screenId, width,
|
|
|
|
height, bitsPerPixel,
|
|
|
|
xOrigin, yOrigin);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4003000 */
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_displayTakeScreenShotPNGToArray(IDisplay *display ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 screenId ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 width ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 height ATTRIBUTE_UNUSED,
|
|
|
|
PRUint32 *screenDataSize ATTRIBUTE_UNUSED,
|
|
|
|
PRUint8** screenData ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return display->vtbl->TakeScreenShotPNGToArray(display, screenId, width,
|
|
|
|
height, screenDataSize,
|
|
|
|
screenData);
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:32 +00:00
|
|
|
static nsresult
|
|
|
|
_hostFindHostNetworkInterfaceById(IHost *host, vboxIIDUnion *iidu,
|
|
|
|
IHostNetworkInterface **networkInterface)
|
|
|
|
{
|
|
|
|
return host->vtbl->FindHostNetworkInterfaceById(host, IID_MEMBER(value),
|
|
|
|
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
|
|
|
|
_hostCreateHostOnlyNetworkInterface(vboxGlobalData *data ATTRIBUTE_UNUSED,
|
|
|
|
IHost *host, char *name ATTRIBUTE_UNUSED,
|
|
|
|
IHostNetworkInterface **networkInterface)
|
|
|
|
{
|
|
|
|
nsresult rc = -1;
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
if (STREQ(name, "vboxnet0")) {
|
|
|
|
PRUint32 interfaceType = 0;
|
|
|
|
PRUnichar *networkInterfaceNameUtf16 = NULL;
|
|
|
|
|
|
|
|
VBOX_UTF8_TO_UTF16(name, &networkInterfaceNameUtf16);
|
|
|
|
host->vtbl->FindHostNetworkInterfaceByName(host, networkInterfaceNameUtf16, networkInterface);
|
|
|
|
|
|
|
|
(*networkInterface)->vtbl->GetInterfaceType(*networkInterface, &interfaceType);
|
|
|
|
if (interfaceType != HostNetworkInterfaceType_HostOnly) {
|
|
|
|
VBOX_RELEASE(*networkInterface);
|
|
|
|
*networkInterface = NULL;
|
|
|
|
} else {
|
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else /* VBOX_API_VERSION != 2002000 */
|
|
|
|
IProgress *progress = NULL;
|
|
|
|
host->vtbl->CreateHostOnlyNetworkInterface(host, networkInterface,
|
|
|
|
&progress);
|
|
|
|
|
|
|
|
if (progress) {
|
|
|
|
rc = progress->vtbl->WaitForCompletion(progress, -1);
|
|
|
|
VBOX_RELEASE(progress);
|
|
|
|
}
|
|
|
|
#endif /* VBOX_API_VERSION != 2002000 */
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:35 +00:00
|
|
|
static nsresult
|
|
|
|
_hostRemoveHostOnlyNetworkInterface(IHost *host ATTRIBUTE_UNUSED,
|
|
|
|
vboxIIDUnion *iidu ATTRIBUTE_UNUSED,
|
|
|
|
IProgress **progress ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
vboxUnsupported();
|
|
|
|
return 0;
|
|
|
|
#elif VBOX_API_VERSION == 3000000
|
|
|
|
nsresult rc;
|
|
|
|
IHostNetworkInterface *netInt = NULL;
|
|
|
|
rc = host->vtbl->RemoveHostOnlyNetworkInterface(host, IID_MEMBER(value), &netInt, progress);
|
|
|
|
VBOX_RELEASE(netInt);
|
|
|
|
return rc;
|
|
|
|
#else /* VBOX_API_VERSION > 3000000 */
|
|
|
|
return host->vtbl->RemoveHostOnlyNetworkInterface(host, IID_MEMBER(value), progress);
|
|
|
|
#endif /* VBOX_API_VERSION > 3000000 */
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
_hnInterfaceGetId(IHostNetworkInterface *hni, vboxIIDUnion *iidu)
|
|
|
|
{
|
|
|
|
return hni->vtbl->GetId(hni, &IID_MEMBER(value));
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4002000
|
|
|
|
return hni->vtbl->EnableStaticIpConfig(hni, IPAddress, networkMask);
|
|
|
|
#else
|
|
|
|
return hni->vtbl->EnableStaticIPConfig(hni, IPAddress, networkMask);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_hnInterfaceEnableDynamicIPConfig(IHostNetworkInterface *hni)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4002000
|
|
|
|
return hni->vtbl->EnableDynamicIpConfig(hni);
|
|
|
|
#else
|
|
|
|
return hni->vtbl->EnableDynamicIPConfig(hni);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
|
|
|
_hnInterfaceDHCPRediscover(IHostNetworkInterface *hni)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4002000
|
|
|
|
return hni->vtbl->DhcpRediscover(hni);
|
|
|
|
#else
|
|
|
|
return hni->vtbl->DHCPRediscover(hni);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
_dhcpServerStart(IDHCPServer *dhcpServer, PRUnichar *networkName,
|
|
|
|
PRUnichar *trunkName, PRUnichar *trunkType)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->Start(dhcpServer, networkName,
|
|
|
|
trunkName, trunkType);
|
|
|
|
}
|
|
|
|
|
2014-10-02 03:30:35 +00:00
|
|
|
static nsresult
|
|
|
|
_dhcpServerStop(IDHCPServer *dhcpServer)
|
|
|
|
{
|
|
|
|
return dhcpServer->vtbl->Stop(dhcpServer);
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:46 +00:00
|
|
|
static nsresult
|
|
|
|
_hardDiskCreateBaseStorage(IHardDisk *hardDisk, PRUint64 logicalSize,
|
|
|
|
PRUint32 variant, IProgress **progress)
|
|
|
|
{
|
|
|
|
#if VBOX_API_VERSION < 4003000
|
|
|
|
return hardDisk->vtbl->CreateBaseStorage(hardDisk, logicalSize, variant, progress);
|
|
|
|
#else
|
|
|
|
return hardDisk->vtbl->CreateBaseStorage(hardDisk, logicalSize, 1, &variant, progress);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:48 +00:00
|
|
|
static nsresult
|
|
|
|
_hardDiskDeleteStorage(IHardDisk *hardDisk, IProgress **progress)
|
|
|
|
{
|
|
|
|
return hardDisk->vtbl->DeleteStorage(hardDisk, progress);
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:49 +00:00
|
|
|
static nsresult
|
|
|
|
_hardDiskGetLogicalSizeInByte(IHardDisk *hardDisk, PRUint64 *uLogicalSize)
|
|
|
|
{
|
|
|
|
nsresult rc;
|
|
|
|
#if VBOX_API_VERSION < 4000000
|
|
|
|
rc = hardDisk->vtbl->GetLogicalSize(hardDisk, uLogicalSize);
|
|
|
|
*uLogicalSize *= 1024 * 1024; /* MB => Bytes */
|
|
|
|
#else /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
PRInt64 logicalSize;
|
|
|
|
rc = hardDisk->vtbl->GetLogicalSize(hardDisk, &logicalSize);
|
|
|
|
*uLogicalSize = logicalSize;
|
|
|
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2014-10-24 01:46:50 +00:00
|
|
|
static nsresult
|
|
|
|
_hardDiskGetFormat(IHardDisk *hardDisk, PRUnichar **format)
|
|
|
|
{
|
|
|
|
return hardDisk->vtbl->GetFormat(hardDisk, format);
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
.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,
|
|
|
|
.GetVRDxServer = _machineGetVRDxServer,
|
|
|
|
.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,
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
static vboxUniformedIVRDxServer _UIVRDxServer = {
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetEnabled = _vrdxServerGetEnabled,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetEnabled = _vrdxServerSetEnabled,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetPorts = _vrdxServerGetPorts,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetPorts = _vrdxServerSetPorts,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetReuseSingleConnection = _vrdxServerGetReuseSingleConnection,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetReuseSingleConnection = _vrdxServerSetReuseSingleConnection,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetAllowMultiConnection = _vrdxServerGetAllowMultiConnection,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetAllowMultiConnection = _vrdxServerSetAllowMultiConnection,
|
2014-08-11 10:06:42 +00:00
|
|
|
.GetNetAddress = _vrdxServerGetNetAddress,
|
2014-08-11 10:06:19 +00:00
|
|
|
.SetNetAddress = _vrdxServerSetNetAddress,
|
|
|
|
};
|
|
|
|
|
|
|
|
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,
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-10-24 01:46:46 +00:00
|
|
|
static vboxUniformedIHardDisk _UIHardDisk = {
|
|
|
|
.CreateBaseStorage = _hardDiskCreateBaseStorage,
|
2014-10-24 01:46:48 +00:00
|
|
|
.DeleteStorage = _hardDiskDeleteStorage,
|
2014-10-24 01:46:49 +00:00
|
|
|
.GetLogicalSizeInByte = _hardDiskGetLogicalSizeInByte,
|
2014-10-24 01:46:50 +00:00
|
|
|
.GetFormat = _hardDiskGetFormat,
|
2014-10-24 01:46:46 +00:00
|
|
|
};
|
|
|
|
|
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;
|
|
|
|
pVBoxAPI->initializeDomainEvent = _initializeDomainEvent;
|
|
|
|
pVBoxAPI->registerGlobalData = _registerGlobalData;
|
2014-08-11 10:06:18 +00:00
|
|
|
pVBoxAPI->detachDevices = _detachDevices;
|
|
|
|
pVBoxAPI->unregisterMachine = _unregisterMachine;
|
|
|
|
pVBoxAPI->deleteConfig = _deleteConfig;
|
2014-08-11 10:06:19 +00:00
|
|
|
pVBoxAPI->vboxAttachDrivesOld = _vboxAttachDrivesOld;
|
2014-08-11 10:06:36 +00:00
|
|
|
pVBoxAPI->vboxConvertState = _vboxConvertState;
|
2014-08-11 10:06:42 +00:00
|
|
|
pVBoxAPI->dumpIDEHDDsOld = _dumpIDEHDDsOld;
|
|
|
|
pVBoxAPI->dumpDVD = _dumpDVD;
|
2014-08-11 10:06:47 +00:00
|
|
|
pVBoxAPI->attachDVD = _attachDVD;
|
2014-08-11 10:06:50 +00:00
|
|
|
pVBoxAPI->detachDVD = _detachDVD;
|
2014-08-11 10:06:42 +00:00
|
|
|
pVBoxAPI->dumpFloppy = _dumpFloppy;
|
2014-08-11 10:06:47 +00:00
|
|
|
pVBoxAPI->attachFloppy = _attachFloppy;
|
2014-08-11 10:06:50 +00:00
|
|
|
pVBoxAPI->detachFloppy = _detachFloppy;
|
2014-08-11 10:07:03 +00:00
|
|
|
pVBoxAPI->snapshotRestore = _vboxDomainSnapshotRestore;
|
2014-08-11 10:07:08 +00:00
|
|
|
pVBoxAPI->registerDomainEvent = _registerDomainEvent;
|
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;
|
|
|
|
pVBoxAPI->UIVRDxServer = _UIVRDxServer;
|
|
|
|
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;
|
2014-10-24 01:46:46 +00:00
|
|
|
pVBoxAPI->UIHardDisk = _UIHardDisk;
|
2014-08-11 10:06:14 +00:00
|
|
|
pVBoxAPI->machineStateChecker = _machineStateChecker;
|
2014-08-11 10:06:04 +00:00
|
|
|
|
|
|
|
#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000
|
|
|
|
pVBoxAPI->domainEventCallbacks = 0;
|
|
|
|
#else /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */
|
|
|
|
pVBoxAPI->domainEventCallbacks = 1;
|
|
|
|
#endif /* VBOX_API_VERSION > 2002000 || VBOX_API_VERSION < 4000000 */
|
|
|
|
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
pVBoxAPI->hasStaticGlobalData = 0;
|
|
|
|
#else /* VBOX_API_VERSION > 2002000 */
|
|
|
|
pVBoxAPI->hasStaticGlobalData = 1;
|
|
|
|
#endif /* VBOX_API_VERSION > 2002000 */
|
|
|
|
|
2014-08-11 10:06:06 +00:00
|
|
|
#if VBOX_API_VERSION >= 4000000
|
|
|
|
/* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */
|
|
|
|
pVBoxAPI->getMachineForSession = 1;
|
2014-08-11 10:06:18 +00:00
|
|
|
pVBoxAPI->detachDevicesExplicitly = 0;
|
2014-08-11 10:06:19 +00:00
|
|
|
pVBoxAPI->vboxAttachDrivesUseOld = 0;
|
2014-08-11 10:07:05 +00:00
|
|
|
pVBoxAPI->supportScreenshot = 1;
|
2014-08-11 10:06:06 +00:00
|
|
|
#else /* VBOX_API_VERSION < 4000000 */
|
|
|
|
pVBoxAPI->getMachineForSession = 0;
|
2014-08-11 10:06:18 +00:00
|
|
|
pVBoxAPI->detachDevicesExplicitly = 1;
|
2014-08-11 10:06:19 +00:00
|
|
|
pVBoxAPI->vboxAttachDrivesUseOld = 1;
|
2014-08-11 10:07:05 +00:00
|
|
|
pVBoxAPI->supportScreenshot = 0;
|
2014-08-11 10:06:06 +00:00
|
|
|
#endif /* VBOX_API_VERSION < 4000000 */
|
2014-08-11 10:06:19 +00:00
|
|
|
|
|
|
|
#if VBOX_API_VERSION >= 4001000
|
|
|
|
pVBoxAPI->chipsetType = 1;
|
|
|
|
#else /* VBOX_API_VERSION < 4001000 */
|
|
|
|
pVBoxAPI->chipsetType = 0;
|
|
|
|
#endif /* VBOX_API_VERSION < 4001000 */
|
|
|
|
|
|
|
|
#if VBOX_API_VERSION >= 3001000
|
|
|
|
pVBoxAPI->accelerate2DVideo = 1;
|
2014-08-11 10:06:42 +00:00
|
|
|
pVBoxAPI->oldMediumInterface = 0;
|
2014-08-11 10:06:19 +00:00
|
|
|
#else /* VBOX_API_VERSION < 3001000 */
|
|
|
|
pVBoxAPI->accelerate2DVideo = 0;
|
2014-08-11 10:06:42 +00:00
|
|
|
pVBoxAPI->oldMediumInterface = 1;
|
2014-08-11 10:06:19 +00:00
|
|
|
#endif /* VBOX_API_VERSION < 3001000 */
|
2014-08-11 10:06:52 +00:00
|
|
|
|
|
|
|
#if VBOX_API_VERSION >= 4002000
|
|
|
|
pVBoxAPI->vboxSnapshotRedefine = 1;
|
|
|
|
#else /* VBOX_API_VERSION < 4002000 */
|
|
|
|
pVBoxAPI->vboxSnapshotRedefine = 0;
|
|
|
|
#endif /* VBOX_API_VERSION < 4002000 */
|
2014-10-02 03:30:35 +00:00
|
|
|
|
|
|
|
#if VBOX_API_VERSION == 2002000
|
|
|
|
pVBoxAPI->networkRemoveInterface = 0;
|
|
|
|
#else /* VBOX_API_VERSION > 2002000 */
|
|
|
|
pVBoxAPI->networkRemoveInterface = 1;
|
|
|
|
#endif /* VBOX_API_VERSION > 2002000 */
|
2014-08-11 10:06:04 +00:00
|
|
|
}
|