summaryrefslogtreecommitdiff
path: root/src/VBox/Main/src-server/HostImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Main/src-server/HostImpl.cpp')
-rw-r--r--src/VBox/Main/src-server/HostImpl.cpp49
1 files changed, 38 insertions, 11 deletions
diff --git a/src/VBox/Main/src-server/HostImpl.cpp b/src/VBox/Main/src-server/HostImpl.cpp
index a2994f520..a14ca898a 100644
--- a/src/VBox/Main/src-server/HostImpl.cpp
+++ b/src/VBox/Main/src-server/HostImpl.cpp
@@ -1,10 +1,10 @@
-/* $Id: HostImpl.cpp $ */
+/* $Id: HostImpl.cpp 37955 2011-07-14 12:23:02Z vboxsync $ */
/** @file
* VirtualBox COM class implementation: Host
*/
/*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -51,7 +51,7 @@
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT)
-# include <VBox/WinNetConfig.h>
+# include <VBox/VBoxNetCfg-win.h>
#endif /* #if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_NETFLT) */
#ifdef RT_OS_LINUX
@@ -150,11 +150,11 @@ extern bool is3DAccelerationSupported();
#undef GS
#include <VBox/usb.h>
-#include <VBox/x86.h>
#include <VBox/vmm/hwacc_svm.h>
#include <VBox/err.h>
#include <VBox/settings.h>
#include <VBox/sup.h>
+#include <iprt/x86.h>
#include "VBox/com/MultiResult.h"
@@ -224,12 +224,13 @@ struct Host::Data
HRESULT Host::FinalConstruct()
{
- return S_OK;
+ return BaseFinalConstruct();
}
void Host::FinalRelease()
{
uninit();
+ BaseFinalRelease();
}
/**
@@ -392,8 +393,8 @@ HRESULT Host::init(VirtualBox *aParent)
ComPtr<IHostNetworkInterface> hif;
ComPtr<IProgress> progress;
- int r = NetIfCreateHostOnlyNetworkInterface(m->pParent,
- hif.asOutParam(),
+ int r = NetIfCreateHostOnlyNetworkInterface(m->pParent,
+ hif.asOutParam(),
progress.asOutParam(),
it->c_str());
if (RT_FAILURE(r))
@@ -1512,6 +1513,16 @@ STDMETHODIMP Host::FindUSBDeviceById(IN_BSTR aId,
#endif /* !VBOX_WITH_USB */
}
+STDMETHODIMP Host::GenerateMACAddress(BSTR *aAddress)
+{
+ CheckComArgOutPointerValid(aAddress);
+ // no locking required
+ Utf8Str mac;
+ generateMACAddress(mac);
+ Bstr(mac).cloneTo(aAddress);
+ return S_OK;
+}
+
// public methods only for internal purposes
////////////////////////////////////////////////////////////////////////////////
@@ -1648,8 +1659,9 @@ HRESULT Host::getDrives(DeviceType_T mediumType,
// list was built, and this was a subsequent call: then compare the old and the new lists
// remove drives from the cached list which are no longer present
- MediaList::iterator itCached = pllCached->begin();
- while (itCached != pllCached->end())
+ for (MediaList::iterator itCached = pllCached->begin();
+ itCached != pllCached->end();
+ /*nothing */)
{
Medium *pCached = *itCached;
const Utf8Str strLocationCached = pCached->getLocationFull();
@@ -1680,7 +1692,7 @@ HRESULT Host::getDrives(DeviceType_T mediumType,
Medium *pNew = *itNew;
const Utf8Str strLocationNew = pNew->getLocationFull();
bool fFound = false;
- for (itCached = pllCached->begin();
+ for (MediaList::iterator itCached = pllCached->begin();
itCached != pllCached->end();
++itCached)
{
@@ -2795,7 +2807,7 @@ void Host::registerMetrics(PerformanceCollector *aCollector)
ramUsageUsed,
ramUsageFree);
aCollector->registerBaseMetric (ramUsage);
- pm::BaseMetric *ramVmm = new pm::HostRamVmm(hal, objptr,
+ pm::BaseMetric *ramVmm = new pm::HostRamVmm(aCollector->getGuestManager(), objptr,
ramVMMUsed,
ramVMMFree,
ramVMMBallooned,
@@ -2897,6 +2909,21 @@ void Host::unregisterMetrics (PerformanceCollector *aCollector)
aCollector->unregisterBaseMetricsFor(this);
}
+
+/* static */
+void Host::generateMACAddress(Utf8Str &mac)
+{
+ /*
+ * Our strategy is as follows: the first three bytes are our fixed
+ * vendor ID (080027). The remaining 3 bytes will be taken from the
+ * start of a GUID. This is a fairly safe algorithm.
+ */
+ Guid guid;
+ guid.create();
+ mac = Utf8StrFmt("080027%02X%02X%02X",
+ guid.raw()->au8[0], guid.raw()->au8[1], guid.raw()->au8[2]);
+}
+
#endif /* VBOX_WITH_RESOURCE_USAGE_API */
/* vi: set tabstop=4 shiftwidth=4 expandtab: */