HostImpl.cpp revision 93e5cceaaa2a9f468c642b94dbf57f6f061bcfe6
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * VirtualBox COM class implementation: Host
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * available from http://www.virtualbox.org. This file is free software;
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * you can redistribute it and/or modify it under the terms of the GNU
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * General Public License (GPL) as published by the Free Software
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync * additional information or have any questions.
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync#endif // VBOX_WITH_USB
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync#endif /* VBOX_WITH_RESOURCE_USAGE_API */
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync#endif /* #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT) */
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync#endif /* RT_OS_LINUX */
4a4140b851e27d435a9c56675db3598b8490fea2vboxsync/* Dynamic loading of libhal on Solaris hosts */
4a4140b851e27d435a9c56675db3598b8490fea2vboxsync#endif /* RT_OS_SOLARIS */
3cc33d1e7558a0f4a04b59bfe914a24d0b9a2329vboxsync#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_DARWIN
#ifdef VBOX_WITH_CROGL
extern bool is3DAccelerationSupported();
#ifdef RT_OS_SOLARIS
#ifdef VBOX_WITH_HOSTNETIF_API
#include "netif.h"
#include <stdio.h>
#include <algorithm>
#ifdef VBOX_WITH_USB
return S_OK;
uninit();
m = new Data();
#ifdef VBOX_WITH_USB
# if defined (RT_OS_DARWIN)
#ifdef VBOX_WITH_RESOURCE_USAGE_API
#if defined (RT_OS_WINDOWS)
m->fVTxAMDVSupported = false;
m->fLongModeSupported = false;
m->fPAESupported = false;
if (ASMHasCpuId())
m->fVTxAMDVSupported = true;
m->fVTxAMDVSupported = true;
m->f3DAccelerationSupported = false;
#ifdef VBOX_WITH_CROGL
return S_OK;
#ifdef VBOX_WITH_RESOURCE_USAGE_API
#ifdef VBOX_WITH_USB
delete m->pUSBProxyService;
delete m->pHostPowerService;
#ifdef VBOX_WITH_USB
m = NULL;
#if defined(RT_OS_WINDOWS)
driveName[0] = *p;
delete[] hostDrives;
# ifdef VBOX_USE_LIBHAL
char *cdromDrive;
while (cdromDrive)
while (cur)
return rc;
#ifdef RT_OS_WINDOWS
driveName[0] = *p;
delete[] hostDrives;
return rc;
Assert(0);
return rc;
STDMETHODIMP Host::COMGETTER(NetworkInterfaces)(ComSafeArrayOut(IHostNetworkInterface*, aNetworkInterfaces))
return E_POINTER;
# ifdef VBOX_WITH_HOSTNETIF_API
if (rc)
# if defined(RT_OS_DARWIN)
while (pEtherNICs)
if (SUCCEEDED(IfObj->init(Bstr(pEtherNICs->szName), Guid(pEtherNICs->Uuid), HostNetworkInterfaceType_Bridged)))
# ifdef VBOX_SOLARIS_NSL_RESOLVED
if (VBoxSolarisLibDlpiFound())
if (Sock > 0)
if (!rc)
if (!rc)
if (!rc)
if (!rc)
# ifndef VBOX_WITH_NETFLT
&pNc,
&lpszApp );
# ifdef VBOX_NETFLT_ONDEMAND_BIND
/* for the protocol-based approach for now we just get all miniports the MS_TCPIP protocol binds to */
# ifndef VBOX_WITH_HARDENING
if(uComponentStatus == 0)
if (sock >= 0)
return S_OK;
#ifdef VBOX_WITH_USB
# ifndef RT_OS_WINDOWS
STDMETHODIMP Host::COMGETTER(USBDeviceFilters)(ComSafeArrayOut(IHostUSBDeviceFilter*, aUSBDeviceFilters))
#ifdef VBOX_WITH_USB
return rc;
# ifndef RT_OS_WINDOWS
return S_OK;
return S_OK;
return S_OK;
return S_OK;
switch (aFeature)
case ProcessorFeature_PAE:
return S_OK;
if (!hal)
return E_FAIL;
delete hal;
return rc;
if (!hal)
return E_FAIL;
delete hal;
return rc;
return S_OK;
return S_OK;
return S_OK;
return S_OK;
if (RT_SUCCESS(r))
return S_OK;
if (RT_SUCCESS(r))
return S_OK;
#ifdef VBOX_WITH_USB
return S_OK;
#ifdef VBOX_WITH_USB
++it)
#ifdef VBOX_WITH_USB
STDMETHODIMP Host::FindHostNetworkInterfaceByName(IN_BSTR name, IHostNetworkInterface **networkInterface)
#ifndef VBOX_WITH_HOSTNETIF_API
return E_NOTIMPL;
if (!name)
return E_INVALIDARG;
if (!networkInterface)
return E_POINTER;
return E_FAIL;
Bstr n;
if (n == name)
if (!found)
STDMETHODIMP Host::FindHostNetworkInterfaceById(IN_BSTR id, IHostNetworkInterface **networkInterface)
#ifndef VBOX_WITH_HOSTNETIF_API
return E_NOTIMPL;
return E_INVALIDARG;
if (!networkInterface)
return E_POINTER;
return E_FAIL;
Bstr g;
if (g == id)
if (!found)
return E_FAIL;
return hr;
if(t == type)
return S_OK;
#ifdef VBOX_WITH_USB
aAddress);
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
++it)
return rc;
#ifdef VBOX_WITH_USB
++it)
return S_OK;
#ifdef VBOX_WITH_USB
return m->pUSBProxyService;
return S_OK;
++it)
return S_OK;
return m->pParent;
if (aActiveChanged)
return S_OK;
bool halSuccess = false;
if (!gLibHalCheckPresence())
if (dbusConnection != 0)
if (halContext != 0)
int numDevices;
if (halDevices != 0)
halSuccess = true;
for (int i = 0; i < numDevices; i++)
#ifdef RT_OS_SOLARIS
if (devNode != 0)
if (product == 0)
LogRel(("Host::COMGETTER(DVDDrives): failed to get property \"info.product\" for device %s. dbus error: %s (%s)\n",
if (vendor != 0)
if (product != 0)
#ifndef RT_OS_SOLARIS
LogRel(("Host::COMGETTER(DVDDrives): failed to get property \"block.device\" for device %s. dbus error: %s (%s)\n",
LogRel(("Host::COMGETTER(DVDDrives): failed to get devices with capability \"storage.cdrom\". dbus error: %s (%s)\n", dbusError.name, dbusError.message));
LogRel(("Host::COMGETTER(DVDDrives): failed to shutdown the libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
LogRel(("Host::COMGETTER(DVDDrives): failed to initialise libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
LogRel(("Host::COMGETTER(DVDDrives): failed to connect to dbus. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
return halSuccess;
bool halSuccess = false;
if (!gLibHalCheckPresence())
if (dbusConnection != 0)
if (halContext != 0)
int numDevices;
if (halDevices != 0)
halSuccess = true;
for (int i = 0; i < numDevices; i++)
if (driveType != 0)
if (devNode != 0)
if (product == 0)
LogRel(("Host::COMGETTER(FloppyDrives): failed to get property \"info.product\" for device %s. dbus error: %s (%s)\n",
if (vendor != 0)
if (product != 0)
// LogRel(("Host::COMGETTER(FloppyDrives): failed to validate the block device %s as a floppy drive\n"));
LogRel(("Host::COMGETTER(FloppyDrives): failed to get property \"block.device\" for device %s. dbus error: %s (%s)\n",
LogRel(("Host::COMGETTER(FloppyDrives): failed to get devices with capability \"storage.cdrom\". dbus error: %s (%s)\n", dbusError.name, dbusError.message));
LogRel(("Host::COMGETTER(FloppyDrives): failed to shutdown the libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
LogRel(("Host::COMGETTER(FloppyDrives): failed to initialise libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
LogRel(("Host::COMGETTER(FloppyDrives): failed to connect to dbus. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
return halSuccess;
#if defined(RT_OS_SOLARIS)
#ifdef RT_OS_LINUX
if (mtab)
char *mnt_type;
char *mnt_dev;
char *tmp;
if (tmp)
if (mnt_type)
if (tmp)
if (tmp)
if (mnt_dev)
if (tmp)
if (mntFile)
bool retValue = false;
if (!deviceNode)
if (isCDROM)
int fileHandle;
if (fileHandle >= 0)
#ifdef RT_OS_LINUX
retValue = true;
retValue = true;
return retValue;
#ifdef VBOX_WITH_USB
#ifdef RT_OS_LINUX
# ifdef VBOX_WITH_DBUS
tr ("The USB Proxy Service could not be started, because neither the USB file system (usbfs) nor the hardware information service (hal) is available")
tr ("The USB Proxy Service could not be started, because the USB file system (usbfs) is not available")
return S_OK;
#ifdef VBOX_WITH_RESOURCE_USAGE_API