HostImpl.cpp revision f650118f144626d9f84baace12426f962f41a252
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox COM class implementation: Host
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
af062818b47340eef15700d2f0211576ba3506eevboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync * additional information or have any questions.
af062818b47340eef15700d2f0211576ba3506eevboxsync/* bird: This is a hack to work around conflicts between these linux kernel headers
af062818b47340eef15700d2f0211576ba3506eevboxsync * and the GLIBC tcpip headers. They have different declarations of the 4
af062818b47340eef15700d2f0211576ba3506eevboxsync * standard byte order functions. */
af062818b47340eef15700d2f0211576ba3506eevboxsync// # include <libhal.h>
af062818b47340eef15700d2f0211576ba3506eevboxsync// /* These are defined by libhal.h and by VBox header files. */
af062818b47340eef15700d2f0211576ba3506eevboxsync// # undef TRUE
af062818b47340eef15700d2f0211576ba3506eevboxsync// # undef FALSE
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif /* RT_OS_LINUX */
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif /* RT_OS_SOLARIS */
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif /* RT_OS_WINDOWS */
#ifdef RT_OS_SOLARIS
# include <Netcfgn.h>
#include <stdio.h>
#include <algorithm>
return S_OK;
if (isReady())
uninit();
// public initializer/uninitializer for internal purposes only
#ifdef VBOX_WITH_USB
# if defined (RT_OS_DARWIN)
#ifdef VBOX_WITH_RESOURCE_USAGE_API
#if defined (RT_OS_WINDOWS)
setReady(true);
return S_OK;
#ifdef VBOX_WITH_RESOURCE_USAGE_API
#ifdef VBOX_WITH_USB
delete mUSBProxyService;
delete mHostPowerService;
#ifdef VBOX_WITH_USB
if (!drives)
return E_POINTER;
CHECK_READY();
#if defined(RT_OS_WINDOWS)
driveName[0] = *p;
delete[] hostDrives;
# ifdef VBOX_USE_LIBHAL
char *cdromDrive;
while (cdromDrive)
#ifdef VBOX_USE_LIBHAL
char *cdromDrive;
while (cdromDrive)
while (cur)
return S_OK;
if (!drives)
return E_POINTER;
CHECK_READY();
#ifdef RT_OS_WINDOWS
driveName[0] = *p;
delete[] hostDrives;
#ifdef VBOX_USE_LIBHAL
char *floppyDrive;
while (floppyDrive)
return S_OK;
#ifdef RT_OS_WINDOWS
bool ret = false;
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}", 0, KEY_READ, &hNetcard);
status = RegQueryValueExA(hNetCardGUID, "NetCfgInstanceId", NULL, &dwKeyType, (LPBYTE)szNetCfgInstanceId, &len);
szNetProductName[0] = 0;
status = RegQueryValueExA(hNetCardGUID, "ProductName", NULL, &dwKeyType, (LPBYTE)szNetProductName, &len);
szNetProviderName[0] = 0;
status = RegQueryValueExA(hNetCardGUID, "ProviderName", NULL, &dwKeyType, (LPBYTE)szNetProviderName, &len);
ret = true;
return ret;
#ifdef RT_OS_SOLARIS
static void vboxSolarisAddHostIface(char *pszIface, int Instance, PCRTMAC pMac, void *pvHostNetworkInterfaceList)
std::list<ComObjPtr <HostNetworkInterface> > *pList = (std::list<ComObjPtr <HostNetworkInterface> > *)pvHostNetworkInterfaceList;
if (pMac)
static boolean_t vboxSolarisAddLinkHostIface(const char *pszIface, void *pvHostNetworkInterfaceList)
if (pszColon)
int cbInstance = 0;
cbInstance++;
pszEnd--;
return _B_FALSE;
static bool vboxSolarisSortNICList(const ComObjPtr <HostNetworkInterface> Iface1, const ComObjPtr <HostNetworkInterface> Iface2)
static bool vboxSolarisSameNIC(const ComObjPtr <HostNetworkInterface> Iface1, const ComObjPtr <HostNetworkInterface> Iface2)
# ifdef VBOX_SOLARIS_NSL_RESOLVED
static int vboxSolarisAddPhysHostIface(di_node_t Node, di_minor_t Minor, void *pvHostNetworkInterfaceList)
return DI_WALK_CONTINUE;
return DI_WALK_CONTINUE;
return DI_WALK_CONTINUE;
if(punk)
if ( lpszLockedBy )
(void**)&pnc );
if ( fGetWriteLock )
if ( pncLock )
return hr;
return hr;
static int vboxNetWinAddComponent(std::list <ComObjPtr <HostNetworkInterface> > * pPist, INetCfgComponent * pncc)
Assert(0);
return rc;
ppencbp );
return hr;
&ulCount );
return hr;
return hr;
&ulCount );
return hr;
&ulCount );
return hr;
&ulCount );
return hr;
STDMETHODIMP Host::COMGETTER(NetworkInterfaces) (IHostNetworkInterfaceCollection **networkInterfaces)
if (!networkInterfaces)
return E_POINTER;
CHECK_READY();
# if defined(RT_OS_DARWIN)
while (pEtherNICs)
# 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 */
return S_OK;
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
if (!aUSBDevices)
return E_POINTER;
CHECK_READY();
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
if (!aUSBDeviceFilters)
return E_POINTER;
CHECK_READY();
return rc;
return E_NOTIMPL;
if (!count)
return E_POINTER;
CHECK_READY();
return S_OK;
if (!count)
return E_POINTER;
CHECK_READY();
return S_OK;
if (!speed)
return E_POINTER;
CHECK_READY();
return S_OK;
if (!description)
return E_POINTER;
CHECK_READY();
return E_NOTIMPL;
if (!size)
return E_POINTER;
CHECK_READY();
return E_NOTIMPL;
if (!available)
return E_POINTER;
CHECK_READY();
return E_NOTIMPL;
if (!os)
return E_POINTER;
CHECK_READY();
return E_NOTIMPL;
if (!version)
return E_POINTER;
CHECK_READY();
return E_NOTIMPL;
if (!aUTCTime)
return E_POINTER;
CHECK_READY();
return S_OK;
#ifdef RT_OS_WINDOWS
return FALSE;
if (!aName)
return E_INVALIDARG;
if (!aHostNetworkInterface)
return E_POINTER;
if (!aProgress)
return E_POINTER;
CHECK_READY();
d (new NetworkInterfaceHelperClientData());
static_cast <void *> (d.get()),
progress);
d.release();
return rc;
if (!aHostNetworkInterface)
return E_POINTER;
if (!aProgress)
return E_POINTER;
CHECK_READY();
d (new NetworkInterfaceHelperClientData());
static_cast <void *> (d.get()),
progress);
d.release();
return rc;
#ifdef VBOX_WITH_USB
if (!aFilter)
return E_POINTER;
return E_INVALIDARG;
CHECK_READY();
return S_OK;
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
if (!aFilter)
return E_INVALIDARG;
CHECK_READY();
if (!filter)
return E_NOTIMPL;
#ifdef VBOX_WITH_USB
if (!aFilter)
return E_POINTER;
CHECK_READY();
return E_NOTIMPL;
using namespace settings;
CHECK_READY();
#ifdef VBOX_WITH_USB
action);
return rc;
using namespace settings;
CHECK_READY();
#ifdef VBOX_WITH_USB
++ it;
return S_OK;
#ifdef VBOX_WITH_USB
CHECK_READY();
if (aActiveChanged)
return S_OK;
void Host::getUSBFilters(Host::USBDeviceFilterList *aGlobalFilters, VirtualBox::SessionMachineVector *aMachines)
# ifdef VBOX_USE_LIBHAL
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;
#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
CHECK_READY();
return S_OK;
#ifdef RT_OS_WINDOWS
/* The original source of the VBoxTAP adapter creation/destruction code has the following copyright */
return E_INVALIDARG;
&pidl);
if (pShellFolder)
return hr;
return E_FAIL;
return E_FAIL;
return E_FAIL;
return status;
return S_OK;
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
while (TRUE)
if (!ret)
index++;
sizeof (detailBuf),
NULL))
TCHAR * t;
index ++;
if (!found)
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
if (ok)
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
KEY_READ);
GetLastError()));
if (destroyList)
return vrc;
SetErrBreak ((
SetErrBreak ((
SetErrBreak ((
if (hkeyConnection)
if (hkeyNetwork)
while (TRUE)
if (!ok)
index++;
NULL,
NULL,
&size);
if (!ok)
index++;
NULL,
size,
NULL);
if (!ok)
index++;
index++;
if (deviceHwid)
if (found)
index++;
GetLastError()));
if (!ok)
GetLastError()));
if (!ok)
GetLastError()));
return vrc;
return S_OK;
switch (d->msgCode)
bool endLoop = false;
while (!endLoop)
switch (reply)
endLoop = true;
endLoop = true;
endLoop = true;
bool endLoop = false;
while (!endLoop)
switch (reply)
endLoop = true;
endLoop = true;
endLoop = true;
if (aVrc)
return rc;
switch (aMsgCode)
return vrc;
#ifdef VBOX_WITH_RESOURCE_USAGE_API