HostImpl.cpp revision 6d7c636aa41c6723d6d427826c0974050c3a8e31
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * VirtualBox COM class implementation
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Copyright (C) 2006-2007 innotek GmbH
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * available from http://www.virtualbox.org. This file is free software;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * you can redistribute it and/or modify it under the terms of the GNU
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * General Public License (GPL) as published by the Free Software
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync/* bird: This is a hack to work around conflicts between these linux kernel headers
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * and the GLIBC tcpip headers. They have different declarations of the 4
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * standard byte order functions. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// # include <libhal.h>
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// /* These are defined by libhal.h and by VBox header files. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// # undef TRUE
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// # undef FALSE
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* RT_OS_LINUX */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* RT_OS_SOLARIS */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* RT_OS_WINDOWS */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// constructor / destructor
6ef855ecf2121f708685307839f1262e0db1a024vboxsync/////////////////////////////////////////////////////////////////////////////
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// public initializer/uninitializer for internal purposes only
6ef855ecf2121f708685307839f1262e0db1a024vboxsync/////////////////////////////////////////////////////////////////////////////
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Initializes the host object.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM result indicator
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param parent handle of our parent object
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#if defined (RT_OS_DARWIN) && defined (VBOX_WITH_USB)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService = new USBProxyServiceDarwin (this);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#elif defined (RT_OS_LINUX) && defined (VBOX_WITH_USB)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService = new USBProxyServiceLinux (this);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#elif defined (RT_OS_OS2) && defined (VBOX_WITH_USB)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#elif defined (RT_OS_SOLARIS) && defined (VBOX_WITH_USB)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService = new USBProxyServiceSolaris (this);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#elif defined (RT_OS_WINDOWS) && defined (VBOX_WITH_USB)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService = new USBProxyServiceWin32 (this);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /** @todo handle !mUSBProxySerivce->isActive() and mUSBProxyService->getLastError()
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * and somehow report or whatever that the proxy failed to startup.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Also, there might be init order issues... */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Uninitializes the host object and sets the ready flag to FALSE.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Called either from FinalRelease() or by the parent when it gets destroyed.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* wait for USB proxy service to terminate before we uninit all USB
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * devices */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogFlowThisFunc (("Stopping USB proxy service...\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogFlowThisFunc (("Done stopping USB proxy service.\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* uninit all USB device filters still referenced by clients */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// IHost properties
6ef855ecf2121f708685307839f1262e0db1a024vboxsync/////////////////////////////////////////////////////////////////////////////
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns a list of host DVD drives.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param drives address of result pointer
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(DVDDrives) (IHostDVDDriveCollection **drives)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync while (*p);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // Not all Solaris versions ship with libhal.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // So use a fallback approach similar to Linux.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync cdromDrive = strtok(cdromEnv, ":"); /** @todo use strtok_r. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // this might work on Solaris version older than Nevada.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // check the mounted drives
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (!getDVDInfoFromHal(list)) /* Playing with #defines in this way is nasty, I know. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* USE_LIBHAL defined */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // On Linux without hal, the situation is much more complex. We will take a
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // heuristical approach and also allow the user to specify a list of host
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // CDROMs using an environment variable.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // The general strategy is to try some known device names and see of they
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // exist. At last, we'll enumerate the /etc/fstab file (luckily there's an
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // API to parse it) for CDROM devices. Ok, let's start!
6ef855ecf2121f708685307839f1262e0db1a024vboxsync cdromDrive = strtok(cdromEnv, ":"); /** @todo use strtok_r */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // this is a good guess usually
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // check the mounted drives
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // check the drives that can be mounted
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* PORTME */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns a list of host floppy drives.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param drives address of result pointer
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(FloppyDrives) (IHostFloppyDriveCollection **drives)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync while (*p);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (!getFloppyInfoFromHal(list)) /* Playing with #defines in this way is nasty, I know. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* USE_LIBHAL defined */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // As with the CDROMs, on Linux we have to take a multi-level approach
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // involving parsing the mount tables. As this is not bulletproof, we'll
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // give the user the chance to override the detection by an environment
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // variable and skip the detection.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync char *floppyEnv = strdupa(RTEnvGet("VBOX_FLOPPY"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // check if this is an acceptable device
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // we assume that a floppy is always /dev/fd[x] with x from 0 to 7
6ef855ecf2121f708685307839f1262e0db1a024vboxsync for (int i = 0; i <= 7; i++)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* PORTME */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync bool ret = false;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}", 0, KEY_READ, &hNetcard);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync return false;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync while(true)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegEnumKeyExA(hNetcard, i, szEnumName, &len, NULL, NULL, NULL, NULL);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegOpenKeyExA(hNetcard, szEnumName, 0, KEY_READ, &hNetCardGUID);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegQueryValueExA(hNetCardGUID, "NetCfgInstanceId", NULL, &dwKeyType, (LPBYTE)szNetCfgInstanceId, &len);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (status == ERROR_SUCCESS && dwKeyType == REG_SZ)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegQueryValueExA(hNetCardGUID, "ProductName", NULL, &dwKeyType, (LPBYTE)szNetProductName, &len);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegQueryValueExA(hNetCardGUID, "ProviderName", NULL, &dwKeyType, (LPBYTE)szNetProviderName, &len);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync && !strcmp(szNetProductName, "VirtualBox TAP Adapter")
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns a list of host network interfaces.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param drives address of result pointer
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(NetworkInterfaces) (IHostNetworkInterfaceCollection **networkInterfaces)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync std::list <ComObjPtr <HostNetworkInterface> > list;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync static const char *NetworkKey = "SYSTEM\\CurrentControlSet\\Control\\Network\\"
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "{4D36E972-E325-11CE-BFC1-08002BE10318}";
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, NetworkKey, 0, KEY_READ, &hCtrlNet);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync return setError (E_FAIL, tr("Could not open registry key \"%s\""), NetworkKey);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync for (int i = 0;; ++ i)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegEnumKeyExA (hCtrlNet, i, szNetworkGUID, &len, NULL, NULL, NULL, NULL);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync RTStrPrintf (szNetworkConnection, sizeof (szNetworkConnection),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegOpenKeyExA (hCtrlNet, szNetworkConnection, 0, KEY_READ, &hConnection);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegQueryValueExW (hConnection, TEXT("Name"), NULL,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (status == ERROR_SUCCESS && dwKeyType == REG_SZ)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync size_t uniLen = (len + sizeof (OLECHAR) - 1) / sizeof (OLECHAR);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync status = RegQueryValueExW (hConnection, TEXT("Name"), NULL,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync RTLogPrintf("Connection name %ls\n", name.mutableRaw());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* put a trailing zero, just in case (see MSDN) */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* create a new object and add it to the list */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* remove the curly bracket at the end */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (SUCCEEDED (iface->init (name, Guid (szNetworkGUID + 1))))
6ef855ecf2121f708685307839f1262e0db1a024vboxsync ComObjPtr <HostNetworkInterfaceCollection> collection;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* RT_OS_WINDOWS */
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(USBDevices)(IHostUSBDeviceCollection **aUSBDevices)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Note: The GUI depends on this method returning E_NOTIMPL with no
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * extended error info to indicate that USB is simply not available
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * (w/o treting it as a failure), for example, as in OSE */
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(USBDeviceFilters) (IHostUSBDeviceFilterCollection **aUSBDeviceFilters)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync ComObjPtr <HostUSBDeviceFilterCollection> collection;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Note: The GUI depends on this method returning E_NOTIMPL with no
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * extended error info to indicate that USB is simply not available
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * (w/o treting it as a failure), for example, as in OSE */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns the number of installed logical processors
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param count address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(ProcessorCount)(ULONG *count)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns the (approximate) speed of the host CPU in MHz
441579693f771e49eb05f2bd20c316232155675bvboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param speed address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(ProcessorSpeed)(ULONG *speed)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /** @todo Add a runtime function for this which uses GIP. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns a description string for the host CPU
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param description address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(ProcessorDescription)(BSTR *description)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /** @todo */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns the amount of installed system memory in megabytes
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param size address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(MemorySize)(ULONG *size)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /** @todo */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns the current system memory free space in megabytes
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param available address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(MemoryAvailable)(ULONG *available)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /** @todo */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns the name string of the host operating system
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param os address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(OperatingSystem)(BSTR *os)
383d5bd7b4b12176fbba2defc6c162e5b84e8ac0vboxsync /** @todo */
383d5bd7b4b12176fbba2defc6c162e5b84e8ac0vboxsync * Returns the version string of the host operating system
939e2ecb812c6402abcc63e7d615c5444acfd02evboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param os address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(OSVersion)(BSTR *version)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /** @todo */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns the current host time in milliseconds since 1970-01-01 UTC.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns COM status code
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @param time address of result variable
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::COMGETTER(UTCTime)(LONG64 *aUTCTime)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// IHost methods
6ef855ecf2121f708685307839f1262e0db1a024vboxsync////////////////////////////////////////////////////////////////////////////////
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Returns TRUE if the Windows version is 6.0 or greater (i.e. it's Vista and
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * later OSes) and it has the UAC (User Account Control) feature enabled.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync info.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogFlowFunc (("dwMajorVersion=%d, dwMinorVersion=%d\n",
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* we are interested only in Vista (and newer versions...). In all
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * earlier versions UAC is not present. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* the default EnableLUA value is 1 (Enabled) */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Assert (rc == ERROR_SUCCESS || rc == ERROR_PATH_NOT_FOUND);
441579693f771e49eb05f2bd20c316232155675bvboxsync rc = RegQueryValueExA (hKey, "EnableLUA", NULL, NULL,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Assert (rc == ERROR_SUCCESS || rc == ERROR_FILE_NOT_FOUND);
441579693f771e49eb05f2bd20c316232155675bvboxsync LogFlowFunc (("rc=%d, dwEnableLUA=%d\n", rc, dwEnableLUA));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* for SVCHlpMsg::CreateHostNetworkInterface */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* for SVCHlpMsg::RemoveHostNetworkInterface */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* first check whether an interface with the given name already exists */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync rc = COMGETTER(NetworkInterfaces) (coll.asOutParam());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (SUCCEEDED (coll->FindByName (aName, iface.asOutParam())))
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("Host network interface '%ls' already exists"), aName);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* create a progress object */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync rc = progress->init (mParent, static_cast <IHost *> (this),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* create a new uninitialized host interface object */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* create the networkInterfaceHelperClient() argument */
441579693f771e49eb05f2bd20c316232155675bvboxsync d->msgCode = SVCHlpMsg::CreateHostNetworkInterface;
441579693f771e49eb05f2bd20c316232155675bvboxsync static_cast <void *> (d.get()),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* d is now owned by networkInterfaceHelperClient(), so release it */
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncHost::RemoveHostNetworkInterface (INPTR GUIDPARAM aId,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* first check whether an interface with the given name already exists */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync rc = COMGETTER(NetworkInterfaces) (coll.asOutParam());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (FAILED (coll->FindById (aId, iface.asOutParam())))
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("Host network interface with UUID {%Vuuid} does not exist"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* return the object to be removed to the caller */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* create a progress object */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync rc = progress->init (mParent, static_cast <IHost *> (this),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* create the networkInterfaceHelperClient() argument */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync d->msgCode = SVCHlpMsg::RemoveHostNetworkInterface;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync static_cast <void *> (d.get()),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* d is now owned by networkInterfaceHelperClient(), so release it */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* RT_OS_WINDOWS */
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::CreateUSBDeviceFilter (INPTR BSTR aName, IHostUSBDeviceFilter **aFilter)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Note: The GUI depends on this method returning E_NOTIMPL with no
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * extended error info to indicate that USB is simply not available
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * (w/o treting it as a failure), for example, as in OSE */
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::InsertUSBDeviceFilter (ULONG aPosition, IHostUSBDeviceFilter *aFilter)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync ComObjPtr <HostUSBDeviceFilter> filter = getDependentChild (aFilter);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("The given USB device filter is not created within "
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "this VirtualBox instance"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("The given USB device filter is already in the list"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* iterate to the position... */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync USBDeviceFilterList::iterator it = mUSBDeviceFilters.begin();
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* ...and insert */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* notify the proxy (only when the filter is active) */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (mUSBProxyService->isActive() && filter->data().mActive)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (aFilter));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter->id() = mUSBProxyService->insertFilter (&filter->data().mUSBFilter);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* save the global settings */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Note: The GUI depends on this method returning E_NOTIMPL with no
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * extended error info to indicate that USB is simply not available
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * (w/o treting it as a failure), for example, as in OSE */
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncSTDMETHODIMP Host::RemoveUSBDeviceFilter (ULONG aPosition, IHostUSBDeviceFilter **aFilter)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("Invalid position: %lu (must be in range [0, %lu])"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* iterate to the position... */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync USBDeviceFilterList::iterator it = mUSBDeviceFilters.begin();
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* ...get an element from there... */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* ...and remove */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* notify the proxy (only when the filter is active) */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (mUSBProxyService->isActive() && filter->data().mActive)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* save the global settings */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Note: The GUI depends on this method returning E_NOTIMPL with no
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * extended error info to indicate that USB is simply not available
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * (w/o treting it as a failure), for example, as in OSE */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// public methods only for internal purposes
6ef855ecf2121f708685307839f1262e0db1a024vboxsync////////////////////////////////////////////////////////////////////////////////
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Called by setter methods of all USB device filters.
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncHRESULT Host::onUSBDeviceFilterChange (HostUSBDeviceFilter *aFilter,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // insert/remove the filter from the proxy
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (aFilter));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync aFilter->id() = mUSBProxyService->insertFilter (&aFilter->data().mUSBFilter);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // update the filter in the proxy
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (aFilter));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync aFilter->id() = mUSBProxyService->insertFilter (&aFilter->data().mUSBFilter);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // save the global settings... yeah, on every single filter property change
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncHRESULT Host::loadSettings (const settings::Key &aGlobal)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync using namespace settings;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Key::List filters = aGlobal.key ("USBDeviceFilters").keys ("DeviceFilter");
6ef855ecf2121f708685307839f1262e0db1a024vboxsync for (Key::List::const_iterator it = filters.begin();
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Bstr manufacturer = (*it).stringValue ("manufacturer");
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Bstr serialNumber = (*it).stringValue ("serialNumber");
6ef855ecf2121f708685307839f1262e0db1a024vboxsync const char *actionStr = (*it).stringValue ("action");
6ef855ecf2121f708685307839f1262e0db1a024vboxsync AssertMsgFailed (("Invalid action: '%s'\n", actionStr));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* error info is set by init() when appropriate */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* notify the proxy (only when the filter is active) */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync HostUSBDeviceFilter *flt = filterObj; /* resolve ambiguity */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mUSBProxyService->insertFilter (ComPtr <IUSBDeviceFilter> (flt));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync flt->id() = mUSBProxyService->insertFilter (&filterObj->data().mUSBFilter);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync using namespace settings;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* first, delete the entry */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Key filters = aGlobal.findKey ("USBDeviceFilters");
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* then, recreate it */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync USBDeviceFilterList::const_iterator it = mUSBDeviceFilters.begin();
6ef855ecf2121f708685307839f1262e0db1a024vboxsync const HostUSBDeviceFilter::Data &data = (*it)->data();
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* all are optional */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter.setValue <Bstr> ("vendorId", data.mVendorId.string());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter.setValue <Bstr> ("productId", data.mProductId.string());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter.setValue <Bstr> ("revision", data.mRevision.string());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter.setValue <Bstr> ("manufacturer", data.mManufacturer.string());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter.setValue <Bstr> ("product", data.mProduct.string());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter.setValue <Bstr> ("serialNumber", data.mSerialNumber.string());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync filter.setValue <Bstr> ("port", data.mPort.string());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* action is mandatory */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync AssertMsgFailed (("Invalid action: %d\n", data.mAction));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#else /* VBOX_WITH_USBFILTER */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* all are optional */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync (*it)->COMGETTER (Manufacturer) (str.asOutParam());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync (*it)->COMGETTER (SerialNumber) (str.asOutParam());
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* action is mandatory */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync AssertMsgFailed (("Invalid action: %d\n", action));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync#endif /* VBOX_WITH_USBFILTER */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Requests the USB proxy service to capture the given host USB device.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * When the request is completed,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * IInternalSessionControl::onUSBDeviceAttach() will be called on the given
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * machine object.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Called by Console from the VM process (throug IInternalMachineControl).
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Must return extended error info in case of errors.
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncHRESULT Host::captureUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("USB device with UUID {%Vuuid} is not currently attached to the host"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("USB device '%s' with UUID {%Vuuid} is busy (waiting for a pending "
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "state change). Please try later"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (device->state() == USBDeviceState_NotSupported)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("USB device '%s' with UUID {%Vuuid} cannot be accessed by guest "
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "computers"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("USB device '%s' with UUID {%Vuuid} is being exclusively used by the "
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "host computer"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Machine::name() requires a read lock */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("USB device '%s' with UUID {%Vuuid} is already captured by the virtual "
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "machine '%ls'"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* try to capture the device */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Notification from the VM process that it is going to detach (\a aDone = false)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * or that is has just detach (\a aDone = true) the given USB device.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * When \a aDone = false we only inform the USB Proxy about what the vm is
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * up to so it doesn't get confused and create a new USB host device object
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * (a Darwin issue).
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * When \a aDone = true we replay all filters against the given USB device
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * excluding filters of the machine the device is currently marked as
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * captured by.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * When the \a aDone = true request is completed,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * IInternalSessionControl::onUSBDeviceDetach() will be called on the given
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * machine object.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Called by Console from the VM process (throug IInternalMachineControl).
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncHRESULT Host::detachUSBDevice (SessionMachine *aMachine, INPTR GUIDPARAM aId, BOOL aDone)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogFlowThisFunc (("aMachine=%p, aId={%Vuuid}\n", aMachine, Guid (aId).raw()));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogFlowThisFunc (("id={%Vuuid} state=%d isStatePending=%RTbool pendingState=%d aDone=%RTbool\n",
6ef855ecf2121f708685307839f1262e0db1a024vboxsync device->id().raw(), device->state(), device->isStatePending(),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("USB device '%s' with UUID {%Vuuid} is busy (waiting for a pending "
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "state change). Please try later"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* If an async detach operation is still pending (darwin), postpone
6ef855ecf2121f708685307839f1262e0db1a024vboxsync the setHeld() + the re-applying of filters until it is completed.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync We indicate this by moving to the '*Filters' state variant. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (device->pendingStateEx() == HostUSBDevice::kDetachingPendingAttach)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync device->setLogicalReconnect (HostUSBDevice::kDetachingPendingAttachFilters);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync else if (device->pendingStateEx() == HostUSBDevice::kDetachingPendingDetach)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync device->setLogicalReconnect (HostUSBDevice::kDetachingPendingDetachFilters);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Assert (device->pendingStateEx() == HostUSBDevice::kNothingPending);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync tr ("USB device '%s' with UUID {%Vuuid} is busy (waiting for a pending "
6ef855ecf2121f708685307839f1262e0db1a024vboxsync "state change). Please try later"),
6ef855ecf2121f708685307839f1262e0db1a024vboxsync ComAssertRet (device->machine() == aMachine, E_FAIL);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* re-apply filters on the device before giving it back to the host */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Asks the USB proxy service to capture all currently available USB devices
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * that match filters of the given machine.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * When the request is completed,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * IInternalSessionControl::onUSBDeviceDetach() will be called on the given
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * machine object per every captured USB device.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Called by Console from the VM process (through IInternalMachineControl)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * upon VM startup.
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @note Locks this object for reading (@todo for writing now, until switched
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * to the new locking scheme).
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncHRESULT Host::autoCaptureUSBDevices (SessionMachine *aMachine)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync for (USBDeviceList::iterator it = mUSBDevices.begin();
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* skip pending devices */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Replays all filters against all USB devices currently marked as captured
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * by the given machine (excluding this machine's filters).
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Called by Console from the VM process (throug IInternalMachineControl)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * upon normal VM termination or by SessionMachine::uninit() upon abnormal
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * VM termination (from under the Machine/SessionMachine lock).
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @note Locks this object for reading (@todo for writing now, until switched
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * to the new locking scheme).
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncHRESULT Host::detachAllUSBDevices (SessionMachine *aMachine, BOOL aDone)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync Assert (device->state() == USBDeviceState_Captured);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* re-apply filters on the device before giving it back to the
6ef855ecf2121f708685307839f1262e0db1a024vboxsync HRESULT rc = applyAllUSBFilters (device, aMachine);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync else if (device->pendingStateEx() == HostUSBDevice::kNothingPending)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// private methods
6ef855ecf2121f708685307839f1262e0db1a024vboxsync////////////////////////////////////////////////////////////////////////////////
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Helper function to query the hal subsystem for information about DVD drives attached to the
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns true if information was successfully obtained, false otherwise
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @retval list drives found will be attached to this list
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncbool Host::getDVDInfoFromHal(std::list <ComObjPtr <HostDVDDrive> > &list)
6182bafa91061adf250994da3e1cf8b7e91751f0vboxsync bool halSuccess = false;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync return false;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync DBusConnection *dbusConnection = gDBusBusGet(DBUS_BUS_SYSTEM, &dbusError);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (gLibHalCtxSetDBusConnection (halContext, dbusConnection))
6ef855ecf2121f708685307839f1262e0db1a024vboxsync char **halDevices = gLibHalFindDeviceStringMatch(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Hal is installed and working, so if no devices are reported, assume
6ef855ecf2121f708685307839f1262e0db1a024vboxsync that there are none. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync for (int i = 0; i < numDevices; i++)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync char *devNode = gLibHalDeviceGetPropertyString(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* The CD/DVD ioctls work only for raw device nodes. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// if (validateDevice(devNode, true))
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* We do not check the error here, as this field may
6ef855ecf2121f708685307839f1262e0db1a024vboxsync not even exist. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync vendor = gLibHalDeviceGetPropertyString(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync product = gLibHalDeviceGetPropertyString(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to get property \"info.product\" for device %s. dbus error: %s (%s)\n",
6ef855ecf2121f708685307839f1262e0db1a024vboxsync halDevices[i], dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// LogRel(("Host::COMGETTER(DVDDrives): failed to validate the block device %s as a DVD drive\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to get property \"block.device\" for device %s. dbus error: %s (%s)\n",
6ef855ecf2121f708685307839f1262e0db1a024vboxsync halDevices[i], dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to get devices with capability \"storage.cdrom\". dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (!gLibHalCtxShutdown(halContext, &dbusError)) /* what now? */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to shutdown the libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to initialise libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to set libhal connection to dbus.\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to get a libhal context - out of memory?\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(DVDDrives): failed to connect to dbus. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Helper function to query the hal subsystem for information about floppy drives attached to the
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @returns true if information was successfully obtained, false otherwise
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * @retval list drives found will be attached to this list
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncbool Host::getFloppyInfoFromHal(std::list <ComObjPtr <HostFloppyDrive> > &list)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync bool halSuccess = false;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync return false;
6ef855ecf2121f708685307839f1262e0db1a024vboxsync DBusConnection *dbusConnection = gDBusBusGet(DBUS_BUS_SYSTEM, &dbusError);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (gLibHalCtxSetDBusConnection (halContext, dbusConnection))
6ef855ecf2121f708685307839f1262e0db1a024vboxsync char **halDevices = gLibHalFindDeviceStringMatch(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* Hal is installed and working, so if no devices are reported, assume
6ef855ecf2121f708685307839f1262e0db1a024vboxsync that there are none. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync for (int i = 0; i < numDevices; i++)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync char *driveType = gLibHalDeviceGetPropertyString(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* An error occurred. The attribute "storage.drive_type"
6ef855ecf2121f708685307839f1262e0db1a024vboxsync probably didn't exist. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync char *devNode = gLibHalDeviceGetPropertyString(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// if (validateDevice(devNode, false))
6ef855ecf2121f708685307839f1262e0db1a024vboxsync /* We do not check the error here, as this field may
6ef855ecf2121f708685307839f1262e0db1a024vboxsync not even exist. */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync vendor = gLibHalDeviceGetPropertyString(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync product = gLibHalDeviceGetPropertyString(halContext,
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to get property \"info.product\" for device %s. dbus error: %s (%s)\n",
6ef855ecf2121f708685307839f1262e0db1a024vboxsync halDevices[i], dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync// LogRel(("Host::COMGETTER(FloppyDrives): failed to validate the block device %s as a floppy drive\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to get property \"block.device\" for device %s. dbus error: %s (%s)\n",
6ef855ecf2121f708685307839f1262e0db1a024vboxsync halDevices[i], dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to get devices with capability \"storage.cdrom\". dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync if (!gLibHalCtxShutdown(halContext, &dbusError)) /* what now? */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to shutdown the libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to initialise libhal context. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to set libhal connection to dbus.\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to get a libhal context - out of memory?\n"));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync LogRel(("Host::COMGETTER(FloppyDrives): failed to connect to dbus. dbus error: %s (%s)\n", dbusError.name, dbusError.message));
6ef855ecf2121f708685307839f1262e0db1a024vboxsync# endif /* VBOX_USE_HAL defined */
6ef855ecf2121f708685307839f1262e0db1a024vboxsync * Helper function to parse the given mount file and add found entries
6ef855ecf2121f708685307839f1262e0db1a024vboxsyncvoid Host::parseMountTable(char *mountTable, std::list <ComObjPtr <HostDVDDrive> > &list)
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mnt_type = (char*)malloc(strlen(mntent->mnt_type) + 1);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync mnt_dev = (char*)malloc(strlen(mntent->mnt_fsname) + 1);
6ef855ecf2121f708685307839f1262e0db1a024vboxsync // supermount fs case
152e1e373e38dea3d8cfe8bc06c7d3050cb130e2vboxsync // use strstr here to cover things fs types like "udf,iso9660"
152e1e373e38dea3d8cfe8bc06c7d3050cb130e2vboxsync /** @todo check whether we've already got the drive in our list! */
if (mntFile)
bool retValue = false;
if (!deviceNode)
if (isCDROM)
int fileHandle;
if (fileHandle >= 0)
#ifdef RT_OS_LINUX
retValue = true;
retValue = true;
return retValue;
return S_OK;
return S_OK;
#ifndef VBOX_WITH_USBFILTER
return S_OK;
size_t i = 0;
return S_OK;
if (hasMatch)
return hasMatch;
++ it;
AssertFailed();
#ifdef VBOX_WITH_USB
CHECK_READY();
return S_OK;
return E_NOTIMPL;
#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;