2009-04-17 16:09:07 +00:00
|
|
|
/** @file vbox_driver.c
|
|
|
|
* Core driver methods for managing VirtualBox VM's
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2014-03-18 08:18:32 +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-01-15 09:35:41 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2009-04-17 16:09:07 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
|
|
|
#include "datatypes.h"
|
2012-12-12 17:59:27 +00:00
|
|
|
#include "virlog.h"
|
2009-04-17 16:09:07 +00:00
|
|
|
#include "vbox_driver.h"
|
2010-12-14 22:07:57 +00:00
|
|
|
#include "vbox_glue.h"
|
2012-12-13 18:21:53 +00:00
|
|
|
#include "virerror.h"
|
2014-08-11 10:06:04 +00:00
|
|
|
#include "domain_event.h"
|
|
|
|
#include "domain_conf.h"
|
|
|
|
|
2014-10-02 03:30:25 +00:00
|
|
|
#include "vbox_get_driver.h"
|
2009-04-17 16:09:07 +00:00
|
|
|
|
|
|
|
#define VIR_FROM_THIS VIR_FROM_VBOX
|
|
|
|
|
2014-02-28 12:16:17 +00:00
|
|
|
VIR_LOG_INIT("vbox.vbox_driver");
|
2009-04-17 16:09:07 +00:00
|
|
|
|
2017-07-26 19:31:47 +00:00
|
|
|
#if defined(VBOX_DRIVER)
|
2014-08-11 10:06:04 +00:00
|
|
|
static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
|
2019-10-14 12:45:33 +00:00
|
|
|
virConnectAuthPtr auth G_GNUC_UNUSED,
|
|
|
|
virConfPtr conf G_GNUC_UNUSED,
|
2014-08-11 10:06:04 +00:00
|
|
|
unsigned int flags)
|
2011-07-06 23:06:11 +00:00
|
|
|
{
|
2013-10-09 11:13:45 +00:00
|
|
|
uid_t uid = geteuid();
|
2009-05-12 15:35:18 +00:00
|
|
|
|
2011-07-06 23:06:11 +00:00
|
|
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
|
|
|
|
2019-09-26 14:56:46 +00:00
|
|
|
if (!virConnectValidateURIPath(conn->uri->path, "vbox", uid == 0))
|
|
|
|
return VIR_DRV_OPEN_ERROR;
|
2009-05-12 15:35:18 +00:00
|
|
|
|
2012-07-18 12:06:29 +00:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
|
_("unable to initialize VirtualBox driver API"));
|
2009-05-12 15:35:18 +00:00
|
|
|
return VIR_DRV_OPEN_ERROR;
|
|
|
|
}
|
|
|
|
|
2014-10-16 09:25:59 +00:00
|
|
|
static virHypervisorDriver vboxDriverDummy = {
|
2009-05-12 15:35:18 +00:00
|
|
|
"VBOX",
|
2014-08-20 16:17:07 +00:00
|
|
|
.connectOpen = dummyConnectOpen, /* 0.6.3 */
|
2009-05-12 15:35:18 +00:00
|
|
|
};
|
2014-10-02 03:30:25 +00:00
|
|
|
|
2018-03-28 09:53:31 +00:00
|
|
|
static virConnectDriver vboxConnectDriver = {
|
|
|
|
.localOnly = true,
|
2018-03-27 14:51:45 +00:00
|
|
|
.uriSchemes = (const char *[]){ "vbox", NULL },
|
2018-03-28 09:53:31 +00:00
|
|
|
.hypervisorDriver = NULL,
|
|
|
|
};
|
2015-01-20 16:16:26 +00:00
|
|
|
|
2014-10-02 03:30:25 +00:00
|
|
|
int vboxRegister(void)
|
|
|
|
{
|
|
|
|
uint32_t uVersion;
|
|
|
|
|
|
|
|
if (VBoxCGlueInit(&uVersion) == 0)
|
2015-01-20 16:16:26 +00:00
|
|
|
vboxConnectDriver.hypervisorDriver = vboxGetHypervisorDriver(uVersion);
|
2014-10-02 03:30:25 +00:00
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
if (vboxConnectDriver.hypervisorDriver) {
|
|
|
|
vboxConnectDriver.networkDriver = vboxGetNetworkDriver(uVersion);
|
|
|
|
vboxConnectDriver.storageDriver = vboxGetStorageDriver(uVersion);
|
|
|
|
} else {
|
|
|
|
vboxConnectDriver.hypervisorDriver = &vboxDriverDummy;
|
|
|
|
}
|
2014-10-02 03:30:25 +00:00
|
|
|
|
2015-01-20 16:16:26 +00:00
|
|
|
if (virRegisterConnectDriver(&vboxConnectDriver,
|
|
|
|
false) < 0)
|
2014-10-02 03:30:25 +00:00
|
|
|
return -1;
|
2016-11-23 19:01:10 +00:00
|
|
|
|
2014-10-02 03:30:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|