mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-26 18:41:17 +00:00
integration of the VirtualBox support
* configure.in include/libvirt/virterror.h src/Makefile.am src/domain_conf.[ch] src/driver.h src/virterror.c src/vbox/README src/vbox/vbox_CAPI_v2_2.h src/vbox/vbox_V2_2.c src/vbox/vbox_XPCOMCGlue.[ch] src/vbox/vbox_driver.[ch] src/vbox/vbox_tmpl.c: integration of the VirtualBox support patches by Pritesh Kothari Daniel
This commit is contained in:
parent
81e6a22192
commit
10d1650843
@ -1,3 +1,12 @@
|
||||
Fri Apr 17 18:05:52 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* configure.in include/libvirt/virterror.h src/Makefile.am
|
||||
src/domain_conf.[ch] src/driver.h src/virterror.c src/vbox/README
|
||||
src/vbox/vbox_CAPI_v2_2.h src/vbox/vbox_V2_2.c
|
||||
src/vbox/vbox_XPCOMCGlue.[ch] src/vbox/vbox_driver.[ch]
|
||||
src/vbox/vbox_tmpl.c: integration of the VirtualBox support
|
||||
patches by Pritesh Kothari
|
||||
|
||||
Fri Apr 17 17:32:16 CEST 2009 Daniel Veillard <veillard@redhat.com>
|
||||
|
||||
* src/libvirt.c: fix the doc of virNodeGetFreeMemory to say bytes
|
||||
|
@ -182,6 +182,8 @@ AC_ARG_WITH([uml],
|
||||
[ --with-uml add UML support (on)],[],[with_uml=yes])
|
||||
AC_ARG_WITH([openvz],
|
||||
[ --with-openvz add OpenVZ support (on)],[],[with_openvz=yes])
|
||||
AC_ARG_WITH([vbox],
|
||||
[ --with-vbox add VirtualBox support (on)],[],[with_vbox=yes])
|
||||
AC_ARG_WITH([lxc],
|
||||
[ --with-lxc add Linux Container support (on)],[],[with_lxc=yes])
|
||||
AC_ARG_WITH([test],
|
||||
@ -277,6 +279,11 @@ if test "$with_openvz" = "yes"; then
|
||||
fi
|
||||
AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
|
||||
|
||||
if test "x$with_vbox" = "xyes"; then
|
||||
AC_DEFINE_UNQUOTED([WITH_VBOX], 1, [whether VirtualBox driver is enabled])
|
||||
fi
|
||||
AM_CONDITIONAL([WITH_VBOX], [test "$with_vbox" = "yes"])
|
||||
|
||||
if test "$with_libvirtd" = "no" ; then
|
||||
with_lxc=no
|
||||
fi
|
||||
@ -1362,6 +1369,7 @@ AC_MSG_NOTICE([ Proxy: $with_xen_proxy])
|
||||
AC_MSG_NOTICE([ QEMU: $with_qemu])
|
||||
AC_MSG_NOTICE([ UML: $with_uml])
|
||||
AC_MSG_NOTICE([ OpenVZ: $with_openvz])
|
||||
AC_MSG_NOTICE([ VBox: $with_vbox])
|
||||
AC_MSG_NOTICE([ LXC: $with_lxc])
|
||||
AC_MSG_NOTICE([ Test: $with_test])
|
||||
AC_MSG_NOTICE([ Remote: $with_remote])
|
||||
|
@ -62,6 +62,7 @@ typedef enum {
|
||||
VIR_FROM_NODEDEV, /* Error from node device monitor */
|
||||
VIR_FROM_XEN_INOTIFY, /* Error from xen inotify layer */
|
||||
VIR_FROM_SECURITY, /* Error from security framework */
|
||||
VIR_FROM_VBOX, /* Error from VirtualBox driver */
|
||||
} virErrorDomain;
|
||||
|
||||
|
||||
|
@ -129,6 +129,11 @@ OPENVZ_DRIVER_SOURCES = \
|
||||
openvz_conf.c openvz_conf.h \
|
||||
openvz_driver.c openvz_driver.h
|
||||
|
||||
VBOX_DRIVER_SOURCES = \
|
||||
vbox/vbox_XPCOMCGlue.c vbox/vbox_XPCOMCGlue.h \
|
||||
vbox/vbox_driver.c vbox/vbox_driver.h \
|
||||
vbox/vbox_V2_2.c
|
||||
|
||||
QEMU_DRIVER_SOURCES = \
|
||||
qemu_conf.c qemu_conf.h \
|
||||
qemu_driver.c qemu_driver.h
|
||||
@ -271,6 +276,19 @@ endif
|
||||
libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
|
||||
endif
|
||||
|
||||
if WITH_VBOX
|
||||
if WITH_DRIVER_MODULES
|
||||
mod_LTLIBRARIES += libvirt_driver_vbox.la
|
||||
else
|
||||
noinst_LTLIBRARIES += libvirt_driver_vbox.la
|
||||
libvirt_la_LIBADD += libvirt_driver_vbox.la
|
||||
endif
|
||||
if WITH_DRIVER_MODULES
|
||||
libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version
|
||||
endif
|
||||
libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES)
|
||||
endif
|
||||
|
||||
if WITH_QEMU
|
||||
if WITH_DRIVER_MODULES
|
||||
mod_LTLIBRARIES += libvirt_driver_qemu.la
|
||||
@ -410,6 +428,7 @@ EXTRA_DIST += \
|
||||
$(LXC_DRIVER_SOURCES) \
|
||||
$(UML_DRIVER_SOURCES) \
|
||||
$(OPENVZ_DRIVER_SOURCES) \
|
||||
$(VBOX_DRIVER_SOURCES) \
|
||||
$(NETWORK_DRIVER_SOURCES) \
|
||||
$(STORAGE_DRIVER_SOURCES) \
|
||||
$(STORAGE_DRIVER_FS_SOURCES) \
|
||||
|
@ -54,7 +54,8 @@ VIR_ENUM_IMPL(virDomainVirt, VIR_DOMAIN_VIRT_LAST,
|
||||
"ldom",
|
||||
"test",
|
||||
"vmware",
|
||||
"hyperv")
|
||||
"hyperv",
|
||||
"vbox")
|
||||
|
||||
VIR_ENUM_IMPL(virDomainBoot, VIR_DOMAIN_BOOT_LAST,
|
||||
"fd",
|
||||
|
@ -48,6 +48,7 @@ enum virDomainVirtType {
|
||||
VIR_DOMAIN_VIRT_TEST,
|
||||
VIR_DOMAIN_VIRT_VMWARE,
|
||||
VIR_DOMAIN_VIRT_HYPERV,
|
||||
VIR_DOMAIN_VIRT_VBOX,
|
||||
|
||||
VIR_DOMAIN_VIRT_LAST,
|
||||
};
|
||||
|
@ -20,6 +20,7 @@ typedef enum {
|
||||
VIR_DRV_OPENVZ = 5,
|
||||
VIR_DRV_LXC = 6,
|
||||
VIR_DRV_UML = 7,
|
||||
VIR_DRV_VBOX = 8,
|
||||
} virDrvNo;
|
||||
|
||||
|
||||
|
@ -55,6 +55,9 @@
|
||||
#ifdef WITH_OPENVZ
|
||||
#include "openvz_driver.h"
|
||||
#endif
|
||||
#ifdef WITH_VBOX
|
||||
#include "vbox/vbox_driver.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
@ -306,6 +309,7 @@ virInitialize(void)
|
||||
virDriverLoadModule("test");
|
||||
virDriverLoadModule("xen");
|
||||
virDriverLoadModule("openvz");
|
||||
virDriverLoadModule("vbox");
|
||||
virDriverLoadModule("remote");
|
||||
#else
|
||||
#ifdef WITH_TEST
|
||||
@ -317,6 +321,9 @@ virInitialize(void)
|
||||
#ifdef WITH_OPENVZ
|
||||
if (openvzRegister() == -1) return -1;
|
||||
#endif
|
||||
#ifdef WITH_VBOX
|
||||
if (vboxRegister() == -1) return -1;
|
||||
#endif
|
||||
#ifdef WITH_REMOTE
|
||||
if (remoteRegister () == -1) return -1;
|
||||
#endif
|
||||
@ -830,6 +837,10 @@ virGetVersion(unsigned long *libVer, const char *type,
|
||||
if (STRCASEEQ(type, "OpenVZ"))
|
||||
*typeVer = LIBVIR_VERSION_NUMBER;
|
||||
#endif
|
||||
#if WITH_VBOX
|
||||
if (STRCASEEQ(type, "VBox"))
|
||||
*typeVer = LIBVIR_VERSION_NUMBER;
|
||||
#endif
|
||||
#if WITH_UML
|
||||
if (STRCASEEQ(type, "UML"))
|
||||
*typeVer = LIBVIR_VERSION_NUMBER;
|
||||
|
33
src/vbox/README
Normal file
33
src/vbox/README
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
Explanation about the how multi-version support
|
||||
for VirtualBox libvirt driver is implemented.
|
||||
|
||||
Since VirtualBox adds multiple new features for each release, it is but
|
||||
natural that the C API which VirtualBox exposes is volatile across
|
||||
versions and thus needs a good mechanism to handle multiple versions
|
||||
during runtime. The solution was something like this:
|
||||
|
||||
Firstly the file structure is as below:
|
||||
|
||||
vbox_CAPI_v2_2.h
|
||||
vbox_XPCOMCGlue.h
|
||||
vbox_XPCOMCGlue.c
|
||||
These files are C API/glue code files directly taken from the
|
||||
VirtualBox OSE source and is needed for C API to work as expected.
|
||||
|
||||
vbox_driver.h
|
||||
vbox_driver.c
|
||||
These files have the main logic for registering the virtualbox driver
|
||||
with libvirt.
|
||||
|
||||
vbox_V2_2.c
|
||||
The file which has version dependent changes and includes the template
|
||||
file for given below for all of its functionality.
|
||||
|
||||
vbox_tmpl.c
|
||||
The file where all the real driver implementation code exists.
|
||||
|
||||
Now there would be a vbox_V*.c file (for eg: vbox_V2_2.c for V2.2) for
|
||||
each major virtualbox version which would do some preprocessor magic
|
||||
and include the template file (vbox_tmpl.c) in it for the functionality
|
||||
it offers.
|
4837
src/vbox/vbox_CAPI_v2_2.h
Normal file
4837
src/vbox/vbox_CAPI_v2_2.h
Normal file
File diff suppressed because it is too large
Load Diff
37
src/vbox/vbox_V2_2.c
Normal file
37
src/vbox/vbox_V2_2.c
Normal file
@ -0,0 +1,37 @@
|
||||
/** @file vbox_V2_2.c
|
||||
* C file to include support for multiple versions of VirtualBox
|
||||
* at runtime.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* Foundation and shipped in the "COPYING" file with this library.
|
||||
* 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>
|
||||
|
||||
/** The API Version */
|
||||
#define VBOX_API_VERSION 2002
|
||||
/** Version specific prefix. */
|
||||
#define NAME(name) vbox22##name
|
||||
|
||||
#include "vbox_tmpl.c"
|
205
src/vbox/vbox_XPCOMCGlue.c
Normal file
205
src/vbox/vbox_XPCOMCGlue.c
Normal file
@ -0,0 +1,205 @@
|
||||
/** @file vbox_XPCOMCGlue.c
|
||||
* Glue code for dynamically linking to VBoxXPCOMC.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* Foundation and shipped in the "COPYING" file with this library.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Header Files *
|
||||
*******************************************************************************/
|
||||
#ifdef LIBVIRT_VERSION
|
||||
# include <config.h>
|
||||
#endif /* LIBVIRT_VERSION */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "vbox_XPCOMCGlue.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Defined Constants And Macros *
|
||||
*******************************************************************************/
|
||||
#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || defined(__FreeBSD__)
|
||||
# define DYNLIB_NAME "VBoxXPCOMC.so"
|
||||
#elif defined(__APPLE__)
|
||||
# define DYNLIB_NAME "VBoxXPCOMC.dylib"
|
||||
#elif defined(_MSC_VER) || defined(__OS2__)
|
||||
# define DYNLIB_NAME "VBoxXPCOMC.dll"
|
||||
#else
|
||||
# error "Port me"
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Global Variables *
|
||||
*******************************************************************************/
|
||||
/** The dlopen handle for VBoxXPCOMC. */
|
||||
void *g_hVBoxXPCOMC = NULL;
|
||||
/** The last load error. */
|
||||
PCVBOXXPCOM g_pVBoxFuncs = NULL;
|
||||
/** Pointer to VBoxGetXPCOMCFunctions for the loaded VBoxXPCOMC so/dylib/dll. */
|
||||
PFNVBOXGETXPCOMCFUNCTIONS g_pfnGetFunctions = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Try load VBoxXPCOMC.so/dylib/dll from the specified location and resolve all
|
||||
* the symbols we need.
|
||||
*
|
||||
* @returns 0 on success, -1 on failure.
|
||||
* @param pszHome The director where to try load VBoxXPCOMC from. Can be NULL.
|
||||
* @param fSetAppHome Whether to set the VBOX_APP_HOME env.var. or not (boolean).
|
||||
*/
|
||||
static int tryLoadOne(const char *pszHome, int fSetAppHome)
|
||||
{
|
||||
size_t cchHome = pszHome ? strlen(pszHome) : 0;
|
||||
size_t cbBufNeeded;
|
||||
char szBuf[4096];
|
||||
int rc = -1;
|
||||
|
||||
/*
|
||||
* Construct the full name.
|
||||
*/
|
||||
cbBufNeeded = cchHome + sizeof("/" DYNLIB_NAME);
|
||||
if (cbBufNeeded > sizeof(szBuf))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (cchHome)
|
||||
{
|
||||
memcpy(szBuf, pszHome, cchHome);
|
||||
szBuf[cchHome] = '/';
|
||||
cchHome++;
|
||||
}
|
||||
memcpy(&szBuf[cchHome], DYNLIB_NAME, sizeof(DYNLIB_NAME));
|
||||
|
||||
/*
|
||||
* Try load it by that name, setting the VBOX_APP_HOME first (for now).
|
||||
* Then resolve and call the function table getter.
|
||||
*/
|
||||
if (fSetAppHome)
|
||||
{
|
||||
if (pszHome)
|
||||
setenv("VBOX_APP_HOME", pszHome, 1 /* always override */);
|
||||
else
|
||||
unsetenv("VBOX_APP_HOME");
|
||||
}
|
||||
g_hVBoxXPCOMC = dlopen(szBuf, RTLD_NOW | RTLD_LOCAL);
|
||||
if (g_hVBoxXPCOMC)
|
||||
{
|
||||
PFNVBOXGETXPCOMCFUNCTIONS pfnGetFunctions;
|
||||
pfnGetFunctions = (PFNVBOXGETXPCOMCFUNCTIONS)
|
||||
dlsym(g_hVBoxXPCOMC, VBOX_GET_XPCOMC_FUNCTIONS_SYMBOL_NAME);
|
||||
if (pfnGetFunctions)
|
||||
{
|
||||
g_pVBoxFuncs = pfnGetFunctions(VBOX_XPCOMC_VERSION);
|
||||
if (g_pVBoxFuncs)
|
||||
{
|
||||
g_pfnGetFunctions = pfnGetFunctions;
|
||||
rc = 0;
|
||||
}
|
||||
}
|
||||
if (rc != 0)
|
||||
{
|
||||
dlclose(g_hVBoxXPCOMC);
|
||||
g_hVBoxXPCOMC = NULL;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tries to locate and load VBoxXPCOMC.so/dylib/dll, resolving all the related
|
||||
* function pointers.
|
||||
*
|
||||
* @returns 0 on success, -1 on failure.
|
||||
*
|
||||
* @remark This should be considered moved into a separate glue library since
|
||||
* its its going to be pretty much the same for any user of VBoxXPCOMC
|
||||
* and it will just cause trouble to have duplicate versions of this
|
||||
* source code all around the place.
|
||||
*/
|
||||
int VBoxCGlueInit(void)
|
||||
{
|
||||
/*
|
||||
* If the user specifies the location, try only that.
|
||||
*/
|
||||
const char *pszHome = getenv("VBOX_APP_HOME");
|
||||
if (pszHome)
|
||||
return tryLoadOne(pszHome, 0);
|
||||
|
||||
/*
|
||||
* Try the known standard locations.
|
||||
*/
|
||||
#if defined(__gnu__linux__) || defined(__linux__)
|
||||
if (tryLoadOne("/opt/VirtualBox", 1) == 0)
|
||||
return 0;
|
||||
if (tryLoadOne("/usr/lib/virtualbox", 1) == 0)
|
||||
return 0;
|
||||
#elif defined(__sun__)
|
||||
if (tryLoadOne("/opt/VirtualBox/amd64", 1) == 0)
|
||||
return 0;
|
||||
if (tryLoadOne("/opt/VirtualBox/i386", 1) == 0)
|
||||
return 0;
|
||||
#elif defined(__APPLE__)
|
||||
if (tryLoadOne("/Application/VirtualBox.app/Contents/MacOS", 1) == 0)
|
||||
return 0;
|
||||
#elif defined(__FreeBSD__)
|
||||
if (tryLoadOne("/usr/local/lib/virtualbox", 1) == 0)
|
||||
return 0;
|
||||
#else
|
||||
# error "port me"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Finally try the dynamic linker search path.
|
||||
*/
|
||||
if (tryLoadOne(NULL, 1) == 0)
|
||||
return 0;
|
||||
|
||||
/* No luck, return failure. */
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Terminate the C glue library.
|
||||
*/
|
||||
void VBoxCGlueTerm(void)
|
||||
{
|
||||
if (g_hVBoxXPCOMC)
|
||||
{
|
||||
#if 0 /* VBoxRT.so doesn't like being reloaded. See @bugref{3725}. */
|
||||
dlclose(g_hVBoxXPCOMC);
|
||||
#endif
|
||||
g_hVBoxXPCOMC = NULL;
|
||||
}
|
||||
g_pVBoxFuncs = NULL;
|
||||
g_pfnGetFunctions = NULL;
|
||||
}
|
||||
|
57
src/vbox/vbox_XPCOMCGlue.h
Normal file
57
src/vbox/vbox_XPCOMCGlue.h
Normal file
@ -0,0 +1,57 @@
|
||||
/** @file vbox_XPCOMCGlue.h
|
||||
* Glue for dynamically linking with VBoxXPCOMC.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* Foundation and shipped in the "COPYING" file with this library.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ___VBoxXPCOMC_cglue_h
|
||||
#define ___VBoxXPCOMC_cglue_h
|
||||
|
||||
#include "vbox_CAPI_v2_2.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** The dlopen handle for VBoxXPCOMC. */
|
||||
extern void *g_hVBoxXPCOMC;
|
||||
/** The last load error. */
|
||||
extern char g_szVBoxErrMsg[256];
|
||||
/** Pointer to the VBoxXPCOMC function table. */
|
||||
extern PCVBOXXPCOM g_pVBoxFuncs;
|
||||
/** Pointer to VBoxGetXPCOMCFunctions for the loaded VBoxXPCOMC so/dylib/dll. */
|
||||
extern PFNVBOXGETXPCOMCFUNCTIONS g_pfnGetFunctions;
|
||||
|
||||
|
||||
int VBoxCGlueInit(void);
|
||||
void VBoxCGlueTerm(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
106
src/vbox/vbox_driver.c
Normal file
106
src/vbox/vbox_driver.c
Normal file
@ -0,0 +1,106 @@
|
||||
/** @file vbox_driver.c
|
||||
* Core driver methods for managing VirtualBox VM's
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* Foundation and shipped in the "COPYING" file with this library.
|
||||
* 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>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include "datatypes.h"
|
||||
#include "logging.h"
|
||||
#include "vbox_driver.h"
|
||||
#include "vbox_XPCOMCGlue.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_VBOX
|
||||
|
||||
|
||||
extern virDriver vbox22Driver;
|
||||
extern virDriver vbox25Driver;
|
||||
|
||||
int errorval = 0;
|
||||
|
||||
int vboxRegister(void) {
|
||||
virDriver *driver;
|
||||
uint32_t uVersion = 0;
|
||||
uint32_t major = 0;
|
||||
uint32_t minor = 0;
|
||||
uint32_t intVer = 0;
|
||||
uint32_t build = 0;
|
||||
|
||||
if (VBoxCGlueInit() != 0)
|
||||
errorval = -1;
|
||||
|
||||
if (errorval != -1) {
|
||||
|
||||
uVersion = g_pVBoxFuncs->pfnGetVersion();
|
||||
|
||||
major = uVersion / 1000000;
|
||||
intVer = uVersion % 1000000;
|
||||
minor = intVer / 1000;
|
||||
build = intVer % 1000;
|
||||
|
||||
DEBUG("VBoxCGlueInit worked for version: %d.%d.%d", major, minor, build);
|
||||
} else {
|
||||
DEBUG("VBoxCGlueInit failed: %d.%d.%d, errorval=%d", major, minor, build, errorval);
|
||||
}
|
||||
/* select driver implementation based on version.
|
||||
* here returning -1 as initially thought is not
|
||||
* possible as that doesn't even allow libvirt to
|
||||
* load and thus drop to safe version which is
|
||||
* v2.2, but dont return -1 unless until it is
|
||||
* really bad like can't register the driver
|
||||
* itself using virRegisterDriver()
|
||||
*/
|
||||
if (errorval == -1) {
|
||||
/* If initialization fails then always drop
|
||||
* back to the intial version i.e V2.2
|
||||
*/
|
||||
driver = &vbox22Driver;
|
||||
} else if ( ((major == 2) && (minor == 1) && (build > 51)) ||
|
||||
((major == 2) && (minor == 2)) ) {
|
||||
/* currently the OSE edition is still stuck at 2.1.52
|
||||
* while the beta is at 2.2 so check for both currently*/
|
||||
driver = &vbox22Driver;
|
||||
} else {
|
||||
/* Always drop to some default if none of the above
|
||||
* cases are matched, else virRegisterDriver() will fail
|
||||
* and cause the whole of libvirt to be non-operative.
|
||||
*/
|
||||
driver = &vbox22Driver;
|
||||
}
|
||||
/** @todo r=bird:
|
||||
* 1. What about if (uVersion > 2001051 && uVersion <= 2002999)
|
||||
* instead of the complicated stuff above?
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if (virRegisterDriver(driver) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
36
src/vbox/vbox_driver.h
Normal file
36
src/vbox/vbox_driver.h
Normal file
@ -0,0 +1,36 @@
|
||||
/** @file vbox_driver.h
|
||||
* Core driver methods for managing VirtualBox VM's
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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
|
||||
* Foundation and shipped in the "COPYING" file with this library.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef VBOX_DRIVER_H
|
||||
#define VBOX_DRIVER_H
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
int vboxRegister(void);
|
||||
|
||||
#endif
|
3668
src/vbox/vbox_tmpl.c
Normal file
3668
src/vbox/vbox_tmpl.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -153,6 +153,8 @@ static const char *virErrorDomainName(virErrorDomain domain) {
|
||||
break;
|
||||
case VIR_FROM_SECURITY:
|
||||
dom = "Security Labeling ";
|
||||
case VIR_FROM_VBOX:
|
||||
dom = "VBOX ";
|
||||
break;
|
||||
}
|
||||
return(dom);
|
||||
|
Loading…
Reference in New Issue
Block a user