HostImpl.cpp revision cc04399629ac806e92deeb3006dc1d507a608901
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * VirtualBox COM class implementation: Host
772269936494ffaddd0750ba9e28e805ba81398cvboxsync * Copyright (C) 2006-2010 Oracle Corporation
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * available from http://www.virtualbox.org. This file is free software;
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * you can redistribute it and/or modify it under the terms of the GNU
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * General Public License (GPL) as published by the Free Software
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#endif // VBOX_WITH_USB
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync#endif /* VBOX_WITH_RESOURCE_USAGE_API */
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
376e7522b2055ec5f2834c8e52dfefbee1c5ea8bvboxsync#endif /* #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT) */
#ifdef RT_OS_SOLARIS
# include <fcntl.h>
# include <unistd.h>
# include <stropts.h>
# include <errno.h>
# include <limits.h>
# include <stdio.h>
# ifdef VBOX_SOLARIS_NSL_RESOLVED
# include <libdevinfo.h>
# ifdef VBOX_USE_LIBHAL
# include "vbox-libhal.h"
# include "solaris/DynLoadLibSolaris.h"
#ifdef RT_OS_WINDOWS
# define _WIN32_DCOM
# include <windows.h>
# include <shellapi.h>
# define INITGUID
# include <guiddef.h>
# include <devguid.h>
# include <objbase.h>
//# include <setupapi.h>
# include <shlobj.h>
# include <cfgmgr32.h>
#ifdef RT_OS_DARWIN
#ifdef VBOX_WITH_CROGL
extern bool is3DAccelerationSupported();
#ifdef RT_OS_SOLARIS
#ifdef VBOX_WITH_HOSTNETIF_API
# include "netif.h"
/* XXX Solaris: definitions in /usr/include/sys/regset.h clash with hwacc_svm.h */
#include <stdio.h>
#include <algorithm>
Data()
#ifdef VBOX_WITH_USB
#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->fVTSupported = false;
m->fLongModeSupported = false;
m->fPAESupported = false;
m->fNestedPagingSupported = false;
if (ASMHasCpuId())
m->fVTSupported = true;
m->fVTSupported = true;
m->fNestedPagingSupported = true;
if (m->fVTSupported)
m->fNestedPagingSupported = 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;
return rc;
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)))
# 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 E_NOTIMPL;
return S_OK;
return S_OK;
switch (aFeature)
case ProcessorFeature_PAE:
return S_OK;
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;
#if defined(RT_OS_WINDOWS)
driveName[0] = *p;
delete[] hostDrives;
# ifdef VBOX_USE_LIBHAL
if (cdromEnv)
while (cdromDrive)
while (cur)
return rc;
#ifdef RT_OS_WINDOWS
driveName[0] = *p;
delete[] hostDrives;
return rc;
#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