Index: trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 36614)
+++ trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 36615)
@@ -6946,5 +6946,5 @@
   <interface
     name="IHost" extends="$unknown"
-    uuid="35b004f4-7806-4009-bfa8-d1308adba7e5"
+    uuid="dab4a2b8-c735-4f08-94fc-9bec84182e2f"
     wsmap="managed"
     >
@@ -7377,4 +7377,13 @@
       <param name="device" type="IHostUSBDevice" dir="return">
         <desc>Found USB device object.</desc>
+      </param>
+    </method>
+
+    <method name="generateMACAddress">
+      <desc>
+        Generates a valid Ethernet MAC address, 12 hexadecimal characters.
+      </desc>
+      <param name="address" type="wstring" dir="return">
+        <desc>New Ethernet MAC address.</desc>
       </param>
     </method>
Index: trunk/src/VBox/Main/include/HostImpl.h
===================================================================
--- trunk/src/VBox/Main/include/HostImpl.h	(revision 36614)
+++ trunk/src/VBox/Main/include/HostImpl.h	(revision 36615)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2009 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -57,9 +57,9 @@
 
     // IHost properties
-    STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut (IMedium *, drives));
-    STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut (IMedium *, drives));
-    STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut (IHostUSBDevice *, aUSBDevices));
-    STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut (IHostUSBDeviceFilter *, aUSBDeviceFilters));
-    STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
+    STDMETHOD(COMGETTER(DVDDrives))(ComSafeArrayOut(IMedium *, drives));
+    STDMETHOD(COMGETTER(FloppyDrives))(ComSafeArrayOut(IMedium *, drives));
+    STDMETHOD(COMGETTER(USBDevices))(ComSafeArrayOut(IHostUSBDevice *, aUSBDevices));
+    STDMETHOD(COMGETTER(USBDeviceFilters))(ComSafeArrayOut(IHostUSBDeviceFilter *, aUSBDeviceFilters));
+    STDMETHOD(COMGETTER(NetworkInterfaces))(ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));
     STDMETHOD(COMGETTER(ProcessorCount))(ULONG *count);
     STDMETHOD(COMGETTER(ProcessorOnlineCount))(ULONG *count);
@@ -67,5 +67,5 @@
     STDMETHOD(GetProcessorSpeed)(ULONG cpuId, ULONG *speed);
     STDMETHOD(GetProcessorDescription)(ULONG cpuId, BSTR *description);
-    STDMETHOD(GetProcessorFeature) (ProcessorFeature_T feature, BOOL *supported);
+    STDMETHOD(GetProcessorFeature)(ProcessorFeature_T feature, BOOL *supported);
     STDMETHOD(GetProcessorCPUIDLeaf)(ULONG aCpuId, ULONG aLeaf, ULONG aSubLeaf, ULONG *aValEAX, ULONG *aValEBX, ULONG *aValECX, ULONG *aValEDX);
     STDMETHOD(COMGETTER(MemorySize))(ULONG *size);
@@ -77,18 +77,19 @@
 
     // IHost methods
-    STDMETHOD(CreateHostOnlyNetworkInterface) (IHostNetworkInterface **aHostNetworkInterface,
-                                               IProgress **aProgress);
-    STDMETHOD(RemoveHostOnlyNetworkInterface) (IN_BSTR aId, IProgress **aProgress);
-    STDMETHOD(CreateUSBDeviceFilter) (IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
-    STDMETHOD(InsertUSBDeviceFilter) (ULONG aPosition, IHostUSBDeviceFilter *aFilter);
-    STDMETHOD(RemoveUSBDeviceFilter) (ULONG aPosition);
+    STDMETHOD(CreateHostOnlyNetworkInterface)(IHostNetworkInterface **aHostNetworkInterface,
+                                              IProgress **aProgress);
+    STDMETHOD(RemoveHostOnlyNetworkInterface)(IN_BSTR aId, IProgress **aProgress);
+    STDMETHOD(CreateUSBDeviceFilter)(IN_BSTR aName, IHostUSBDeviceFilter **aFilter);
+    STDMETHOD(InsertUSBDeviceFilter)(ULONG aPosition, IHostUSBDeviceFilter *aFilter);
+    STDMETHOD(RemoveUSBDeviceFilter)(ULONG aPosition);
 
-    STDMETHOD(FindHostDVDDrive) (IN_BSTR aName, IMedium **aDrive);
-    STDMETHOD(FindHostFloppyDrive) (IN_BSTR aName, IMedium **aDrive);
-    STDMETHOD(FindHostNetworkInterfaceByName) (IN_BSTR aName, IHostNetworkInterface **networkInterface);
-    STDMETHOD(FindHostNetworkInterfaceById) (IN_BSTR id, IHostNetworkInterface **networkInterface);
-    STDMETHOD(FindHostNetworkInterfacesOfType) (HostNetworkInterfaceType_T type, ComSafeArrayOut (IHostNetworkInterface *, aNetworkInterfaces));
-    STDMETHOD(FindUSBDeviceByAddress) (IN_BSTR aAddress, IHostUSBDevice **aDevice);
-    STDMETHOD(FindUSBDeviceById) (IN_BSTR aId, IHostUSBDevice **aDevice);
+    STDMETHOD(FindHostDVDDrive)(IN_BSTR aName, IMedium **aDrive);
+    STDMETHOD(FindHostFloppyDrive)(IN_BSTR aName, IMedium **aDrive);
+    STDMETHOD(FindHostNetworkInterfaceByName)(IN_BSTR aName, IHostNetworkInterface **networkInterface);
+    STDMETHOD(FindHostNetworkInterfaceById)(IN_BSTR id, IHostNetworkInterface **networkInterface);
+    STDMETHOD(FindHostNetworkInterfacesOfType)(HostNetworkInterfaceType_T type, ComSafeArrayOut(IHostNetworkInterface *, aNetworkInterfaces));
+    STDMETHOD(FindUSBDeviceByAddress)(IN_BSTR aAddress, IHostUSBDevice **aDevice);
+    STDMETHOD(FindUSBDeviceById)(IN_BSTR aId, IHostUSBDevice **aDevice);
+    STDMETHOD(GenerateMACAddress)(BSTR *aAddress);
 
     // public methods only for internal purposes
@@ -125,4 +126,6 @@
 #endif /* !VBOX_WITH_USB */
 
+    static void generateMACAddress(Utf8Str &mac);
+
 private:
 
@@ -143,6 +146,6 @@
 
 #ifdef VBOX_WITH_RESOURCE_USAGE_API
-    void registerMetrics (PerformanceCollector *aCollector);
-    void unregisterMetrics (PerformanceCollector *aCollector);
+    void registerMetrics(PerformanceCollector *aCollector);
+    void unregisterMetrics(PerformanceCollector *aCollector);
 #endif /* VBOX_WITH_RESOURCE_USAGE_API */
 
Index: trunk/src/VBox/Main/src-server/HostImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/HostImpl.cpp	(revision 36614)
+++ trunk/src/VBox/Main/src-server/HostImpl.cpp	(revision 36615)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -1511,4 +1511,14 @@
     return E_NOTIMPL;
 #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;
 }
 
@@ -2796,5 +2806,5 @@
                                                     ramUsageFree);
     aCollector->registerBaseMetric (ramUsage);
-    pm::BaseMetric *ramVmm = new pm::HostRamVmm(aCollector->getGuestManager(), objptr, 
+    pm::BaseMetric *ramVmm = new pm::HostRamVmm(aCollector->getGuestManager(), objptr,
                                                 ramVMMUsed,
                                                 ramVMMFree,
@@ -2898,4 +2908,19 @@
 }
 
+
+/* 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 */
 
Index: trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp	(revision 36614)
+++ trunk/src/VBox/Main/src-server/NetworkAdapterImpl.cpp	(revision 36615)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2010 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -22,4 +22,5 @@
 #include "MachineImpl.h"
 #include "GuestOSTypeImpl.h"
+#include "HostImpl.h"
 
 #include <iprt/string.h>
@@ -1265,5 +1266,5 @@
         if (FAILED(rc)) return rc;
     }
-    
+
     // leave the lock before attaching
     alock.release();
@@ -1573,16 +1574,8 @@
 void NetworkAdapter::generateMACAddress()
 {
-    /*
-     * 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.
-     */
-    char strMAC[13];
-    Guid guid;
-    guid.create();
-    RTStrPrintf (strMAC, sizeof(strMAC), "080027%02X%02X%02X",
-                 guid.raw()->au8[0], guid.raw()->au8[1], guid.raw()->au8[2]);
-    LogFlowThisFunc(("generated MAC: '%s'\n", strMAC));
-    mData->mMACAddress = strMAC;
+    Utf8Str mac;
+    Host::generateMACAddress(mac);
+    LogFlowThisFunc(("generated MAC: '%s'\n", mac.c_str()));
+    mData->mMACAddress = mac;
 }
 
