Index: /trunk/src/VBox/Main/ConsoleImpl2.cpp
===================================================================
--- /trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 31286)
+++ /trunk/src/VBox/Main/ConsoleImpl2.cpp	(revision 31287)
@@ -769,12 +769,4 @@
         InsertConfigInteger(pPDMAcFile, "CacheSize", ioCacheSize * _1M);
 
-        /* Maximum I/O bandwidth */
-        ULONG ioBandwidthMax = 0;
-        hrc = pMachine->COMGETTER(IoBandwidthMax)(&ioBandwidthMax);                         H();
-        if (ioBandwidthMax != 0)
-        {
-            InsertConfigInteger(pPDMAcFile, "VMTransferPerSecMax", ioBandwidthMax * _1M);
-        }
-
         /*
          * Devices
Index: /trunk/src/VBox/Main/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31286)
+++ /trunk/src/VBox/Main/MachineImpl.cpp	(revision 31287)
@@ -213,5 +213,7 @@
     mIoCacheEnabled = true;
     mIoCacheSize    = 5; /* 5MB */
-    mIoBandwidthMax = 0; /* Unlimited */
+
+    /* Maximum CPU priority by default. */
+    mCpuPriority = 100;
 }
 
@@ -1279,4 +1281,46 @@
     return S_OK;
 }
+
+STDMETHODIMP Machine::COMGETTER(CPUPriority)(ULONG *aPriority)
+{
+    if (!aPriority)
+        return E_POINTER;
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    *aPriority = mHWData->mCpuPriority;
+
+    return S_OK;
+}
+
+STDMETHODIMP Machine::COMSETTER(CPUPriority)(ULONG aPriority)
+{
+    /* check priority limits */
+    if (    aPriority < 1
+         || aPriority > 100
+       )
+        return setError(E_INVALIDARG,
+                        tr("Invalid CPU priority: %lu (must be in range [%lu, %lu])"),
+                        aPriority, 1, 100);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    /* Todo: must always allow changes. */
+    HRESULT rc = checkStateDependency(MutableStateDep);
+    if (FAILED(rc)) return rc;
+
+    setModified(IsModified_MachineData);
+    mHWData.backup();
+    mHWData->mCpuPriority = aPriority;
+
+    return S_OK;
+}
+
 
 STDMETHODIMP Machine::COMGETTER(CPUHotPlugEnabled)(BOOL *enabled)
@@ -2647,34 +2691,4 @@
 }
 
-STDMETHODIMP Machine::COMGETTER(IoBandwidthMax)(ULONG *aIoBandwidthMax)
-{
-    CheckComArgOutPointerValid(aIoBandwidthMax);
-
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    *aIoBandwidthMax = mHWData->mIoBandwidthMax;
-
-    return S_OK;
-}
-
-STDMETHODIMP Machine::COMSETTER(IoBandwidthMax)(ULONG  aIoBandwidthMax)
-{
-    AutoCaller autoCaller(this);
-    if (FAILED(autoCaller.rc())) return autoCaller.rc();
-
-    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
-
-    HRESULT rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc;
-
-    setModified(IsModified_MachineData);
-    mHWData.backup();
-    mHWData->mIoBandwidthMax = aIoBandwidthMax;
-
-    return S_OK;
-}
 
 /**
@@ -6853,6 +6867,7 @@
         mHWData->mSyntheticCpu                = data.fSyntheticCpu;
 
-        mHWData->mCPUCount          = data.cCPUs;
-        mHWData->mCPUHotPlugEnabled = data.fCpuHotPlug;
+        mHWData->mCPUCount                    = data.cCPUs;
+        mHWData->mCPUHotPlugEnabled           = data.fCpuHotPlug;
+        mHWData->mCpuPriority                 = data.ulCpuPriority;
 
         // cpu
@@ -7009,5 +7024,4 @@
         mHWData->mIoCacheEnabled = data.ioSettings.fIoCacheEnabled;
         mHWData->mIoCacheSize = data.ioSettings.ulIoCacheSize;
-        mHWData->mIoBandwidthMax = data.ioSettings.ulIoBandwidthMax;
 
 #ifdef VBOX_WITH_GUEST_PROPS
@@ -7945,6 +7959,7 @@
         }
 
-        data.cCPUs       = mHWData->mCPUCount;
-        data.fCpuHotPlug = !!mHWData->mCPUHotPlugEnabled;
+        data.cCPUs         = mHWData->mCPUCount;
+        data.fCpuHotPlug   = !!mHWData->mCPUHotPlugEnabled;
+        data.ulCpuPriority = mHWData->mCpuPriority;
 
         data.llCpus.clear();
@@ -8074,5 +8089,4 @@
         data.ioSettings.fIoCacheEnabled = !!mHWData->mIoCacheEnabled;
         data.ioSettings.ulIoCacheSize = mHWData->mIoCacheSize;
-        data.ioSettings.ulIoBandwidthMax = mHWData->mIoBandwidthMax;
 
         // guest properties
Index: /trunk/src/VBox/Main/MediumAttachmentImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/MediumAttachmentImpl.cpp	(revision 31286)
+++ /trunk/src/VBox/Main/MediumAttachmentImpl.cpp	(revision 31287)
@@ -52,6 +52,7 @@
     const LONG          lDevice;
     const DeviceType_T  type;
-    bool                fPassthrough : 1;
-    bool                fImplicit : 1;
+    bool                fPassthrough;
+    bool                fImplicit;
+    ULONG               mBandwidthLimit;
 };
 
@@ -132,4 +133,7 @@
     m->bd->fImplicit = false;
 
+    /* Default is no limit. */
+    m->bd->mBandwidthLimit = 0;
+
     /* Confirm a successful initialization when it's the case */
     autoInitSpan.setSucceeded();
@@ -272,4 +276,36 @@
 }
 
+STDMETHODIMP MediumAttachment::COMGETTER(BandwidthLimit) (ULONG *aLimit)
+{
+    CheckComArgOutPointerValid(aLimit);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    *aLimit = m->bd->mBandwidthLimit;
+    return S_OK;
+}
+
+STDMETHODIMP MediumAttachment::COMSETTER(BandwidthLimit) (ULONG aLimit)
+{
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    /* the machine doesn't need to be mutable */
+
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    if (aLimit != m->bd->mBandwidthLimit)
+    {
+        m->bd.backup();
+        m->bd->mBandwidthLimit = aLimit;
+
+        /* todo: not all storage attachments will support this. */
+    }
+    return S_OK;
+}
+
 /**
  *  @note Locks this object for writing.
Index: /trunk/src/VBox/Main/NetworkAdapterImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/NetworkAdapterImpl.cpp	(revision 31286)
+++ /trunk/src/VBox/Main/NetworkAdapterImpl.cpp	(revision 31287)
@@ -84,4 +84,7 @@
     /* initialize data */
     mData->mSlot = aSlot;
+
+    /* Default limit is not capped/unlimited. */
+    mData->mBandwidthLimit = 0;
 
     /* default to Am79C973 */
@@ -749,4 +752,45 @@
 }
 
+STDMETHODIMP NetworkAdapter::COMGETTER(BandwidthLimit) (ULONG *aLimit)
+{
+    CheckComArgOutPointerValid(aLimit);
+
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    *aLimit = mData->mBandwidthLimit;
+    return S_OK;
+}
+
+STDMETHODIMP NetworkAdapter::COMSETTER(BandwidthLimit) (ULONG aLimit)
+{
+    AutoCaller autoCaller(this);
+    if (FAILED(autoCaller.rc())) return autoCaller.rc();
+
+    /* the machine doesn't need to be mutable */
+
+    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
+
+    if (aLimit != mData->mBandwidthLimit)
+    {
+        mData.backup();
+        mData->mBandwidthLimit = aLimit;
+
+        m_fModified = true;
+        // leave the lock before informing callbacks
+        alock.release();
+
+        AutoWriteLock mlock(mParent COMMA_LOCKVAL_SRC_POS);       // mParent is const, no need to lock
+        mParent->setModified(Machine::IsModified_NetworkAdapters);
+        mlock.release();
+
+        /* No change in CFGM logic => changeAdapter=FALSE. */
+        mParent->onNetworkAdapterChange(this, FALSE);
+    }
+    return S_OK;
+}
+
 STDMETHODIMP NetworkAdapter::COMGETTER(TraceEnabled) (BOOL *aEnabled)
 {
@@ -1218,4 +1262,6 @@
     /* boot priority (defaults to 0, i.e. lowest) */
     mData->mBootPriority = data.ulBootPriority;
+    /* Bandwidth limit in Mbps. */
+    mData->mBandwidthLimit = data.ulBandwidthLimit;
 
     switch (data.mode)
@@ -1300,4 +1346,6 @@
 
     data.ulBootPriority = mData->mBootPriority;
+
+    data.ulBandwidthLimit = mData->mBandwidthLimit;
 
     data.type = mData->mAdapterType;
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 31286)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 31287)
@@ -3638,5 +3638,5 @@
   <interface
      name="IMachine" extends="$unknown"
-     uuid="de8f0b23-f285-4779-acf4-08eddda7ec75"
+     uuid="e2d8679e-b144-41d9-9dfa-bbe2fd0ab2d1"
      wsmap="managed"
      >
@@ -3835,5 +3835,13 @@
     </attribute>
 
-    <attribute name="memorySize" type="unsigned long">
+    <attribute name="CPUPriority" type="unsigned long">
+       <desc>
+         Priority of the virtual CPUs. Means to limit the number of CPU cycles
+         a guest can use. The unit is percentage of host CPU cycles per second.
+         The valid range is 1 - 100. 100 (the default) implies no limit. 
+       </desc>
+    </attribute>
+
+      <attribute name="memorySize" type="unsigned long">
       <desc>System memory size in megabytes.</desc>
     </attribute>
@@ -4191,11 +4199,4 @@
     </attribute>
 
-    <attribute name="ioBandwidthMax" type="unsigned long">
-      <desc>
-        The maximum number of MB the VM is allowed to transfer per second.
-        0 means unlimited bandwidth.
-      </desc>
-    </attribute>
-
     <method name="lockMachine">
       <desc>
@@ -8529,5 +8530,5 @@
   <interface
     name="IMediumAttachment" extends="$unknown"
-    uuid="e58eb3eb-8627-428b-bdf8-34487c848de5"
+    uuid="c29452cc-ca72-404b-9261-cfc514f1e412"
     wsmap="struct"
   >
@@ -8580,4 +8581,11 @@
     <attribute name="passthrough" type="boolean" readonly="yes">
       <desc>Pass I/O requests through to a device on the host.</desc>
+    </attribute>
+
+    <attribute name="bandwidthLimit" type="unsigned long">
+      <desc>
+         Maximum throughput allowed for this medium attachment, in units of 1 mbps.
+         A zero value means uncapped/unlimited.
+      </desc>
     </attribute>
 
@@ -11077,5 +11085,5 @@
   <interface
      name="INetworkAdapter" extends="$unknown"
-     uuid="5bdb9df8-a5e1-4322-a139-b7a4a734c790"
+     uuid="9bf58a46-c3f7-4f31-80fa-dde9a5dc0b7b"
      wsmap="managed"
      >
@@ -11192,5 +11200,12 @@
     </attribute>
 
-    <method name="attachToNAT">
+    <attribute name="bandwidthLimit" type="unsigned long">
+      <desc>
+        Maximum throughput allowed for this network adapter, in units of 1 mbps.
+        A zero value means uncapped/unlimited.
+      </desc>
+    </attribute>
+
+      <method name="attachToNAT">
       <desc>
         Attach the network adapter to the Network Address Translation (NAT) interface.
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 31286)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 31287)
@@ -271,4 +271,5 @@
         ULONG                mCPUCount;
         BOOL                 mCPUHotPlugEnabled;
+        ULONG                mCpuPriority;
         BOOL                 mAccelerate3DEnabled;
         BOOL                 mHpetEnabled;
@@ -296,5 +297,4 @@
         BOOL                 mIoCacheEnabled;
         ULONG                mIoCacheSize;
-        ULONG                mIoBandwidthMax;
     };
 
@@ -392,4 +392,6 @@
     STDMETHOD(COMGETTER(CPUHotPlugEnabled))(BOOL *enabled);
     STDMETHOD(COMSETTER(CPUHotPlugEnabled))(BOOL enabled);
+    STDMETHOD(COMGETTER(CPUPriority))(ULONG *aPriority);
+    STDMETHOD(COMSETTER(CPUPriority))(ULONG aPriority);
     STDMETHOD(COMGETTER(HpetEnabled))(BOOL *enabled);
     STDMETHOD(COMSETTER(HpetEnabled))(BOOL enabled);
@@ -451,6 +453,4 @@
     STDMETHOD(COMGETTER(IoCacheSize)) (ULONG *aIoCacheSize);
     STDMETHOD(COMSETTER(IoCacheSize)) (ULONG  aIoCacheSize);
-    STDMETHOD(COMGETTER(IoBandwidthMax)) (ULONG *aIoBandwidthMax);
-    STDMETHOD(COMSETTER(IoBandwidthMax)) (ULONG  aIoBandwidthMax);
 
     // IMachine methods
Index: /trunk/src/VBox/Main/include/MediumAttachmentImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MediumAttachmentImpl.h	(revision 31286)
+++ /trunk/src/VBox/Main/include/MediumAttachmentImpl.h	(revision 31287)
@@ -61,4 +61,6 @@
     STDMETHOD(COMGETTER(Type))(DeviceType_T *aType);
     STDMETHOD(COMGETTER(Passthrough))(BOOL *aPassthrough);
+    STDMETHOD(COMGETTER(BandwidthLimit))(ULONG *aLimit);
+    STDMETHOD(COMSETTER(BandwidthLimit))(ULONG aLimit);
 
     // public internal methods
Index: /trunk/src/VBox/Main/include/NetworkAdapterImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/NetworkAdapterImpl.h	(revision 31286)
+++ /trunk/src/VBox/Main/include/NetworkAdapterImpl.h	(revision 31287)
@@ -69,4 +69,5 @@
         Bstr mNATNetwork;
         ULONG mBootPriority;
+        ULONG mBandwidthLimit;
     };
 
@@ -122,4 +123,6 @@
     STDMETHOD(COMGETTER(BootPriority)) (ULONG *aBootPriority);
     STDMETHOD(COMSETTER(BootPriority)) (ULONG aBootPriority);
+    STDMETHOD(COMGETTER(BandwidthLimit)) (ULONG *aLimit);
+    STDMETHOD(COMSETTER(BandwidthLimit)) (ULONG aLimit);
 
     // INetworkAdapter methods
Index: /trunk/src/VBox/Main/xml/Settings.cpp
===================================================================
--- /trunk/src/VBox/Main/xml/Settings.cpp	(revision 31286)
+++ /trunk/src/VBox/Main/xml/Settings.cpp	(revision 31287)
@@ -1489,4 +1489,5 @@
           fCpuHotPlug(false),
           fHpetEnabled(false),
+          ulCpuPriority(100),
           ulMemorySizeMB((uint32_t)-1),
           ulVRAMSizeMB(8),
@@ -1533,4 +1534,5 @@
                   && (cCPUs                     == h.cCPUs)
                   && (fCpuHotPlug               == h.fCpuHotPlug)
+                  && (ulCpuPriority             == h.ulCpuPriority)
                   && (fHpetEnabled              == h.fHpetEnabled)
                   && (llCpus                    == h.llCpus)
@@ -1642,5 +1644,4 @@
     fIoCacheEnabled  = true;
     ulIoCacheSize    = 5;
-    ulIoBandwidthMax = 0;
 }
 
@@ -1839,4 +1840,5 @@
         pelmAdapter->getAttributeValue("tracefile", nic.strTraceFile);
         pelmAdapter->getAttributeValue("bootPriority", nic.ulBootPriority);
+        pelmAdapter->getAttributeValue("bandwidthLimit", nic.ulBandwidthLimit);
 
         xml::ElementNodesList llNetworkModes;
@@ -2193,4 +2195,5 @@
 
             pelmHwChild->getAttributeValue("hotplug", hw.fCpuHotPlug);
+            pelmHwChild->getAttributeValue("priority", hw.ulCpuPriority);
 
             const xml::ElementNode *pelmCPUChild;
@@ -2540,8 +2543,4 @@
                 pelmIoChild->getAttributeValue("enabled", hw.ioSettings.fIoCacheEnabled);
                 pelmIoChild->getAttributeValue("size", hw.ioSettings.ulIoCacheSize);
-            }
-            if ((pelmIoChild = pelmHwChild->findChildElement("IoBandwidth")))
-            {
-                pelmIoChild->getAttributeValue("max", hw.ioSettings.ulIoBandwidthMax);
             }
         }
@@ -3107,4 +3106,6 @@
         pelmCPU->createChild("SyntheticCpu")->setAttribute("enabled", hw.fSyntheticCpu);
     pelmCPU->setAttribute("count", hw.cCPUs);
+    if (hw.ulCpuPriority != 100)
+        pelmCPU->setAttribute("priority", hw.ulCpuPriority);
 
     if (hw.fLargePages)
@@ -3386,4 +3387,6 @@
             pelmAdapter->setAttribute("tracefile", nic.strTraceFile);
         }
+        if (nic.ulBandwidthLimit)
+            pelmAdapter->setAttribute("bandwidthLimit", nic.ulBandwidthLimit);
 
         const char *pcszType;
@@ -3572,5 +3575,4 @@
         pelmIoCache->setAttribute("size", hw.ioSettings.ulIoCacheSize);
         pelmIoBandwidth = pelmIo->createChild("IoBandwidth");
-        pelmIoBandwidth->setAttribute("max", hw.ioSettings.ulIoBandwidthMax);
     }
 
@@ -4188,4 +4190,11 @@
              netit != hardwareMachine.llNetworkAdapters.end(); ++netit)
         {
+            if (netit->ulBandwidthLimit)
+            {
+                /* New in VirtualBox 3.3 */
+                m->sv = SettingsVersion_v1_11;
+                break;
+            }
+
             if (    netit->fEnabled
                  && netit->mode == NetworkAttachmentType_NAT
@@ -4219,14 +4228,13 @@
     }
     // VirtualBox 3.2: Check for non default I/O settings and bump the settings version.
-    if (m->sv < SettingsVersion_v1_10)
+    if (m->sv < SettingsVersion_v1_11)
     {
         if (   hardwareMachine.ioSettings.fIoCacheEnabled != true
-            || hardwareMachine.ioSettings.ulIoCacheSize != 5
-            || hardwareMachine.ioSettings.ulIoBandwidthMax != 0)
+            || hardwareMachine.ioSettings.ulIoCacheSize != 5)
             m->sv = SettingsVersion_v1_10;
     }
 
     // VirtualBox 3.2 adds support for VRDP video channel
-    if (    m->sv < SettingsVersion_v1_10
+    if (    m->sv < SettingsVersion_v1_11
         && (    hardwareMachine.vrdpSettings.fVideoChannel
            )
@@ -4240,4 +4248,11 @@
        )
         m->sv = SettingsVersion_v1_11;
+
+    // VirtualBox 3.3 adds support for CPU priority
+    if (    m->sv < SettingsVersion_v1_11
+        && (    hardwareMachine.ulCpuPriority != 100
+           )
+       )
+        m->sv = SettingsVersion_v1_10;
 }
 
