Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 78260)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 78261)
@@ -21095,4 +21095,10 @@
 
       </desc>
+      <param name="machineId" type="uuid" mod="string" dir="in">
+        <desc>The id of the machine containing the storage controller.</desc>
+      </param>
+      <param name="controllerName" type="wstring" dir="in">
+        <desc>The name of the storage controller.</desc>
+      </param>
     </method>
 
@@ -24233,13 +24239,22 @@
   <interface
     name="IStorageControllerChangedEvent" extends="IEvent"
-    uuid="715212BF-DA59-426E-8230-3831FAA52C56"
+    uuid="6BB335CC-1C58-440C-BB7B-3A1397284C7B"
     wsmap="managed" autogen="VBoxEvent" id="OnStorageControllerChanged"
     >
     <desc>
       Notification when a
-      <link to="IMachine::mediumAttachments">medium attachment</link>
+      <link to="IMachine::storageControllers">storage controllers</link>
       changes.
     </desc>
-    <attribute name="midlDoesNotLikeEmptyInterfaces" readonly="yes" type="boolean"/>
+    <attribute name="machinId" type="uuid" mod="string" readonly="yes">
+      <desc>
+        The id of the machine containing the storage controller.
+      </desc>
+    </attribute>
+    <attribute name="controllerName" type="wstring" readonly="yes">
+      <desc>
+        The name of the storage controller.
+      </desc>
+    </attribute>
   </interface>
 
Index: /trunk/src/VBox/Main/include/ConsoleImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 78260)
+++ /trunk/src/VBox/Main/include/ConsoleImpl.h	(revision 78261)
@@ -179,5 +179,5 @@
     HRESULT i_onSerialPortChange(ISerialPort *aSerialPort);
     HRESULT i_onParallelPortChange(IParallelPort *aParallelPort);
-    HRESULT i_onStorageControllerChange();
+    HRESULT i_onStorageControllerChange(const com::Guid& aMachineId, const com::Utf8Str& aControllerName);
     HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
     HRESULT i_onCPUChange(ULONG aCPU, BOOL aRemove);
Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 78260)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 78261)
@@ -519,5 +519,5 @@
     virtual HRESULT i_onVRDEServerChange(BOOL /* aRestart */) { return S_OK; }
     virtual HRESULT i_onUSBControllerChange() { return S_OK; }
-    virtual HRESULT i_onStorageControllerChange() { return S_OK; }
+    virtual HRESULT i_onStorageControllerChange(const com::Guid & /* aMachineId */, const com::Utf8Str & /* aControllerName */) { return S_OK; }
     virtual HRESULT i_onCPUChange(ULONG /* aCPU */, BOOL /* aRemove */) { return S_OK; }
     virtual HRESULT i_onCPUExecutionCapChange(ULONG /* aExecutionCap */) { return S_OK; }
@@ -1326,5 +1326,5 @@
                                       NATProtocol_T aProto, IN_BSTR aHostIp, LONG aHostPort,
                                       IN_BSTR aGuestIp, LONG aGuestPort);
-    HRESULT i_onStorageControllerChange();
+    HRESULT i_onStorageControllerChange(const com::Guid &aMachineId, const com::Utf8Str &aControllerName);
     HRESULT i_onMediumChange(IMediumAttachment *aMediumAttachment, BOOL aForce);
     HRESULT i_onVMProcessPriorityChange(VMProcPriority_T aPriority);
Index: /trunk/src/VBox/Main/include/SessionImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/SessionImpl.h	(revision 78260)
+++ /trunk/src/VBox/Main/include/SessionImpl.h	(revision 78261)
@@ -93,5 +93,5 @@
     HRESULT onSerialPortChange(const ComPtr<ISerialPort> &aSerialPort);
     HRESULT onParallelPortChange(const ComPtr<IParallelPort> &aParallelPort);
-    HRESULT onStorageControllerChange();
+    HRESULT onStorageControllerChange(const Guid &aMachineId, const com::Utf8Str& aControllerName);
     HRESULT onMediumChange(const ComPtr<IMediumAttachment> &aMediumAttachment,
                            BOOL aForce);
Index: /trunk/src/VBox/Main/include/VirtualBoxImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 78260)
+++ /trunk/src/VBox/Main/include/VirtualBoxImpl.h	(revision 78261)
@@ -156,4 +156,5 @@
     void i_onMediumConfigChanged(IMedium *aMedium);
     void i_onMediumChanged(IMediumAttachment* aMediumAttachment);
+    void i_onStorageControllerChanged(const Guid &aMachineId, const com::Utf8Str &aControllerName);
     void i_onStorageDeviceChanged(IMediumAttachment* aStorageDevice, const BOOL fRemoved, const BOOL fSilent);
     void i_onMachineStateChange(const Guid &aId, MachineState_T aState);
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 78260)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 78261)
@@ -5246,5 +5246,5 @@
  * Called by IInternalSessionControl::OnStorageControllerChange().
  */
-HRESULT Console::i_onStorageControllerChange()
+HRESULT Console::i_onStorageControllerChange(const Guid &aMachineId, const Utf8Str &aControllerName)
 {
     LogFlowThisFunc(("\n"));
@@ -5253,5 +5253,5 @@
     AssertComRCReturnRC(autoCaller.rc());
 
-    fireStorageControllerChangedEvent(mEventSource);
+    fireStorageControllerChangedEvent(mEventSource, Bstr(aMachineId.toString()).raw(), Bstr(aControllerName).raw());
 
     LogFlowThisFunc(("Leaving rc=%#x\n", S_OK));
Index: /trunk/src/VBox/Main/src-client/SessionImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 78260)
+++ /trunk/src/VBox/Main/src-client/SessionImpl.cpp	(revision 78261)
@@ -640,16 +640,18 @@
 }
 
-HRESULT Session::onStorageControllerChange()
-{
-    LogFlowThisFunc(("\n"));
-
-    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
-    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
-    AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
-#ifndef VBOX_COM_INPROC_API_CLIENT
-    AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
-
-    return mConsole->i_onStorageControllerChange();
-#else
+HRESULT Session::onStorageControllerChange(const Guid &aMachineId, const Utf8Str &aControllerName)
+{
+    LogFlowThisFunc(("\n"));
+
+    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
+    AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE);
+    AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE);
+#ifndef VBOX_COM_INPROC_API_CLIENT
+    AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE);
+
+    return mConsole->i_onStorageControllerChange(aMachineId, aControllerName);
+#else
+    NOREF(aMachineId);
+    NOREF(aControllerName);
     return S_OK;
 #endif
Index: /trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 78260)
+++ /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 78261)
@@ -4178,6 +4178,11 @@
     mParent->i_saveModifiedRegistries();
 
-    if (aM)
-        mParent->i_onMediumConfigChanged(aM);
+    if (SUCCEEDED(rc))
+    {
+        if (fIndirect && medium != aM)
+            mParent->i_onMediumConfigChanged(medium);
+        mParent->i_onStorageDeviceChanged(attachment, FALSE, fSilent);
+    }
+
     return rc;
 }
@@ -4263,4 +4268,7 @@
     mParent->i_saveModifiedRegistries();
 
+    if (SUCCEEDED(rc))
+        mParent->i_onStorageDeviceChanged(pAttach, TRUE, fSilent);
+
     return rc;
 }
@@ -4334,4 +4342,6 @@
     alock.release();
     rc = i_onStorageDeviceChange(pAttach, FALSE /* aRemove */, FALSE /* aSilent */);
+    if (SUCCEEDED(rc))
+        mParent->i_onStorageDeviceChanged(pAttach, FALSE, FALSE);
 
     return rc;
@@ -6043,5 +6053,5 @@
     /* inform the direct session if any */
     alock.release();
-    i_onStorageControllerChange();
+    i_onStorageControllerChange(i_getId(), aName);
 
     return S_OK;
@@ -6130,5 +6140,5 @@
         /* inform the direct session if any */
         alock.release();
-        i_onStorageControllerChange();
+        i_onStorageControllerChange(i_getId(), aName);
     }
 
@@ -6183,5 +6193,5 @@
     /* inform the direct session if any */
     alock.release();
-    i_onStorageControllerChange();
+    i_onStorageControllerChange(i_getId(), aName);
 
     return S_OK;
@@ -11841,5 +11851,14 @@
 
         if (flModifications & IsModified_Storage)
-            that->i_onStorageControllerChange();
+        {
+            for (StorageControllerList::const_iterator
+                 it = mStorageControllers->begin();
+                 it != mStorageControllers->end();
+                 ++it)
+            {
+                that->i_onStorageControllerChange(that->i_getId(), (*it)->i_getName());
+            }
+        }
+
 
 #if 0
@@ -14024,5 +14043,5 @@
  *  @note Locks this object for reading.
  */
-HRESULT SessionMachine::i_onStorageControllerChange()
+HRESULT SessionMachine::i_onStorageControllerChange(const Guid &aMachineId, const Utf8Str &aControllerName)
 {
     LogFlowThisFunc(("\n"));
@@ -14038,9 +14057,11 @@
     }
 
+    mParent->i_onStorageControllerChanged(aMachineId, aControllerName);
+
     /* ignore notifications sent after #OnSessionEnd() is called */
     if (!directControl)
         return S_OK;
 
-    return directControl->OnStorageControllerChange();
+    return directControl->OnStorageControllerChange(Bstr(aMachineId.toString()).raw(), Bstr(aControllerName).raw());
 }
 
@@ -14321,6 +14342,4 @@
             directControl = mData->mSession.mDirectControl;
     }
-
-    mParent->i_onStorageDeviceChanged(aAttachment, aRemove, aSilent);
 
     /* ignore notifications sent after #OnSessionEnd() is called */
Index: /trunk/src/VBox/Main/src-server/MediumImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 78260)
+++ /trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 78261)
@@ -2382,10 +2382,9 @@
     Guid uId = i_getId();
     DeviceType_T devType = i_getDeviceType();
-    bool wasCreated = m->state != MediumState_NotCreated;
     MultiResult mrc = i_close(aAutoCaller);
 
     pVirtualBox->i_saveModifiedRegistries();
 
-    if (SUCCEEDED(mrc) && wasCreated)
+    if (SUCCEEDED(mrc))
         pVirtualBox->i_onMediumRegistered(uId, devType, FALSE);
 
@@ -8453,6 +8452,4 @@
             m->pVirtualBox->i_saveModifiedRegistries();
         }
-        if (task.NotifyAboutChanges())
-            m->pVirtualBox->i_onMediumRegistered(m->id, m->devType, TRUE);
     }
     else
@@ -8465,4 +8462,7 @@
             unconst(m->id).clear();
     }
+
+    if (task.NotifyAboutChanges() && SUCCEEDED(rc))
+        m->pVirtualBox->i_onMediumConfigChanged(this);
 
     return rc;
@@ -8691,8 +8691,5 @@
 
     if (task.NotifyAboutChanges() && SUCCEEDED(mrc))
-    {
-        m->pVirtualBox->i_onMediumRegistered(pTarget->i_getId(), pTarget->i_getDeviceType(), TRUE);
         m->pVirtualBox->i_onMediumConfigChanged(this);
-    }
 
     return mrc;
Index: /trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp	(revision 78260)
+++ /trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp	(revision 78261)
@@ -334,5 +334,5 @@
         alock.release();
 
-        m->pParent->i_onStorageControllerChange();
+        m->pParent->i_onStorageControllerChange(m->pParent->i_getId(), aName);
     }
 
@@ -435,5 +435,5 @@
         mlock.release();
 
-        m->pParent->i_onStorageControllerChange();
+        m->pParent->i_onStorageControllerChange(m->pParent->i_getId(), m->bd->strName);
     }
 
@@ -576,5 +576,5 @@
         mlock.release();
 
-        m->pParent->i_onStorageControllerChange();
+        m->pParent->i_onStorageControllerChange(m->pParent->i_getId(), m->bd->strName);
     }
 
@@ -609,5 +609,5 @@
         mlock.release();
 
-        m->pParent->i_onStorageControllerChange();
+        m->pParent->i_onStorageControllerChange(m->pParent->i_getId(), m->bd->strName);
     }
 
@@ -642,5 +642,5 @@
         mlock.release();
 
-        m->pParent->i_onStorageControllerChange();
+        m->pParent->i_onStorageControllerChange(m->pParent->i_getId(), m->bd->strName);
     }
 
Index: /trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 78260)
+++ /trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp	(revision 78261)
@@ -3020,4 +3020,30 @@
 }
 
+/** Event for onStorageControllerChanged() */
+struct StorageControllerChangedEventStruct : public VirtualBox::CallbackEvent
+{
+    StorageControllerChangedEventStruct(VirtualBox *aVB, const Guid &aMachineId,
+                                        const com::Utf8Str &aControllerName)
+        : CallbackEvent(aVB, VBoxEventType_OnStorageControllerChanged)
+        , mMachineId(aMachineId.toUtf16()), mControllerName(aControllerName)
+    {}
+
+    virtual HRESULT prepareEventDesc(IEventSource *aSource, VBoxEventDesc &aEvDesc)
+    {
+        return aEvDesc.init(aSource, VBoxEventType_OnStorageControllerChanged, mMachineId.raw(), mControllerName.raw());
+    }
+
+    Bstr mMachineId;
+    Bstr mControllerName;
+};
+
+/**
+ *  @note Doesn't lock any object.
+ */
+void VirtualBox::i_onStorageControllerChanged(const Guid &aMachineId, const com::Utf8Str &aControllerName)
+{
+    i_postEvent(new StorageControllerChangedEventStruct(this, aMachineId, aControllerName));
+}
+
 /** Event for onStorageDeviceChanged() */
 struct StorageDeviceChangedEventStruct : public VirtualBox::CallbackEvent
