Index: /trunk/src/VBox/Main/include/MachineImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MachineImpl.h	(revision 56819)
+++ /trunk/src/VBox/Main/include/MachineImpl.h	(revision 56820)
@@ -594,4 +594,7 @@
                                          bool aSetError = false);
 
+    HRESULT i_getMediumAttachmentsOfController(const Utf8Str &aName,
+                                               MediaData::AttachmentList &aAttachments);
+
     HRESULT i_getUSBControllerByName(const Utf8Str &aName,
                                      ComObjPtr<USBController> &aUSBController,
@@ -650,7 +653,4 @@
                                  bool aSetError = false);
 
-    HRESULT i_getMediumAttachmentsOfController(const Utf8Str &aName,
-                                               MediaData::AttachmentList &aAttachments);
-
     ULONG   i_getUSBControllerCountByType(USBControllerType_T enmType);
 
@@ -687,5 +687,5 @@
 
     MediumAttachment* i_findAttachment(const MediaData::AttachmentList &ll,
-                                       IN_BSTR aControllerName,
+                                       const Utf8Str &aControllerName,
                                        LONG aControllerPort,
                                        LONG aDevice);
Index: /trunk/src/VBox/Main/include/MediumAttachmentImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/MediumAttachmentImpl.h	(revision 56819)
+++ /trunk/src/VBox/Main/include/MediumAttachmentImpl.h	(revision 56820)
@@ -6,5 +6,5 @@
 
 /*
- * Copyright (C) 2006-2013 Oracle Corporation
+ * Copyright (C) 2006-2015 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -35,5 +35,5 @@
     HRESULT init(Machine *aParent,
                  Medium *aMedium,
-                 const Bstr &aControllerName,
+                 const Utf8Str &aControllerName,
                  LONG aPort,
                  LONG aDevice,
@@ -59,5 +59,5 @@
 
     const ComObjPtr<Medium>& i_getMedium() const;
-    const Bstr i_getControllerName() const;
+    const Utf8Str &i_getControllerName() const;
     LONG i_getPort() const;
     LONG i_getDevice() const;
@@ -70,5 +70,8 @@
     bool i_getHotPluggable() const;
 
-    bool i_matches(CBSTR aControllerName, LONG aPort, LONG aDevice);
+    bool i_matches(const Utf8Str &aControllerName, LONG aPort, LONG aDevice);
+
+    /** Must be called from under this object's write lock. */
+    void i_updateName(const Utf8Str &aName);
 
     /** Must be called from under this object's write lock. */
Index: /trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 56819)
+++ /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 56820)
@@ -9580,5 +9580,5 @@
         AutoReadLock attLock(pAtt COMMA_LOCKVAL_SRC_POS);
 
-        if (pAtt->i_getControllerName() == Bstr(aName).raw())
+        if (pAtt->i_getControllerName() == aName)
             atts.push_back(pAtt);
     }
@@ -11067,5 +11067,5 @@
  */
 MediumAttachment* Machine::i_findAttachment(const MediaData::AttachmentList &ll,
-                                            IN_BSTR aControllerName,
+                                            const Utf8Str &aControllerName,
                                             LONG aControllerPort,
                                             LONG aDevice)
Index: /trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp	(revision 56819)
+++ /trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp	(revision 56820)
@@ -53,5 +53,5 @@
      * to the old, uninitialized instance. Changing this requires
      * substantial changes to MediumImpl.cpp. */
-    const Bstr          bstrControllerName;
+    const Utf8Str       strControllerName;
     /* Same counts for the assigned bandwidth group */
     Utf8Str             strBandwidthGroup;
@@ -118,5 +118,5 @@
 HRESULT MediumAttachment::init(Machine *aParent,
                                Medium *aMedium,
-                               const Bstr &aControllerName,
+                               const Utf8Str &aControllerName,
                                LONG aPort,
                                LONG aDevice,
@@ -131,5 +131,5 @@
 {
     LogFlowThisFuncEnter();
-    LogFlowThisFunc(("aParent=%p aMedium=%p aControllerName=%ls aPort=%d aDevice=%d aType=%d aImplicit=%d aPassthrough=%d aTempEject=%d aNonRotational=%d aDiscard=%d aHotPluggable=%d strBandwithGroup=%s\n", aParent, aMedium, aControllerName.raw(), aPort, aDevice, aType, aImplicit, aPassthrough, aTempEject, aNonRotational, aDiscard, aHotPluggable, strBandwidthGroup.c_str()));
+    LogFlowThisFunc(("aParent=%p aMedium=%p aControllerName=%s aPort=%d aDevice=%d aType=%d aImplicit=%d aPassthrough=%d aTempEject=%d aNonRotational=%d aDiscard=%d aHotPluggable=%d strBandwithGroup=%s\n", aParent, aMedium, aControllerName.c_str(), aPort, aDevice, aType, aImplicit, aPassthrough, aTempEject, aNonRotational, aDiscard, aHotPluggable, strBandwidthGroup.c_str()));
 
     if (aType == DeviceType_HardDisk)
@@ -147,5 +147,5 @@
     m->bd->pMedium = aMedium;
     unconst(m->bd->strBandwidthGroup) = strBandwidthGroup;
-    unconst(m->bd->bstrControllerName) = aControllerName;
+    unconst(m->bd->strControllerName) = aControllerName;
     unconst(m->bd->lPort)   = aPort;
     unconst(m->bd->lDevice) = aDevice;
@@ -250,5 +250,5 @@
 
     /* m->controller is constant during life time, no need to lock */
-    aController = Utf8Str(m->bd->bstrControllerName);
+    aController = Utf8Str(m->bd->strControllerName);
 
     LogFlowThisFuncLeave();
@@ -442,7 +442,7 @@
 }
 
-const Bstr MediumAttachment::i_getControllerName() const
-{
-    return m->bd->bstrControllerName;
+const Utf8Str &MediumAttachment::i_getControllerName() const
+{
+    return m->bd->strControllerName;
 }
 
@@ -497,9 +497,18 @@
 }
 
-bool MediumAttachment::i_matches(CBSTR aControllerName, LONG aPort, LONG aDevice)
-{
-    return (    aControllerName == m->bd->bstrControllerName
+bool MediumAttachment::i_matches(const Utf8Str &aControllerName, LONG aPort, LONG aDevice)
+{
+    return (    aControllerName == m->bd->strControllerName
              && aPort == m->bd->lPort
              && aDevice == m->bd->lDevice);
+}
+
+/** Must be called from under this object's write lock. */
+void MediumAttachment::i_updateName(const Utf8Str &aName)
+{
+    Assert(isWriteLockOnCurrentThread());
+
+    m->bd.backup();
+    unconst(m->bd->strControllerName) = aName;
 }
 
Index: /trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 56819)
+++ /trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 56820)
@@ -2689,5 +2689,5 @@
                 pOnlineMediumAttachment =
                     i_findAttachment(mMediaData->mAttachments,
-                                     pAttach->i_getControllerName().raw(),
+                                     pAttach->i_getControllerName(),
                                      pAttach->i_getPort(),
                                      pAttach->i_getDevice());
Index: /trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp	(revision 56819)
+++ /trunk/src/VBox/Main/src-server/StorageControllerImpl.cpp	(revision 56820)
@@ -234,5 +234,5 @@
 
         unconst(aThat->m->pPeer) = this;
-        m->bd.attach (aThat->m->bd);
+        m->bd.attach(aThat->m->bd);
     }
     else
@@ -241,5 +241,5 @@
 
         AutoReadLock thatLock(aThat COMMA_LOCKVAL_SRC_POS);
-        m->bd.share (aThat->m->bd);
+        m->bd.share(aThat->m->bd);
     }
 
@@ -331,4 +331,17 @@
                             aName.c_str());
 
+        Machine::MediaData::AttachmentList atts;
+        rc = m->pParent->i_getMediumAttachmentsOfController(m->bd->strName, atts);
+        for (Machine::MediaData::AttachmentList::const_iterator it = atts.begin();
+             it != atts.end();
+             ++it)
+        {
+            IMediumAttachment *iA = *it;
+            MediumAttachment *pAttach = static_cast<MediumAttachment *>(iA);
+            AutoWriteLock attlock(pAttach COMMA_LOCKVAL_SRC_POS);
+            pAttach->i_updateName(aName);
+        }
+
+
         m->bd.backup();
         m->bd->strName = aName;
@@ -419,5 +432,5 @@
     if (!SUCCEEDED(rc))
         return setError(rc,
-                        tr ("Invalid controller type %d"),
+                        tr("Invalid controller type %d"),
                         aControllerType);
 
@@ -730,9 +743,9 @@
     /* sanity */
     AutoCaller autoCaller(this);
-    AssertComRCReturnVoid (autoCaller.rc());
+    AssertComRCReturnVoid(autoCaller.rc());
 
     /* sanity too */
-    AutoCaller peerCaller (m->pPeer);
-    AssertComRCReturnVoid (peerCaller.rc());
+    AutoCaller peerCaller(m->pPeer);
+    AssertComRCReturnVoid(peerCaller.rc());
 
     /* lock both for writing since we modify both (m->pPeer is "master" so locked
@@ -746,5 +759,5 @@
         {
             // attach new data to the peer and reshare it
-            m->pPeer->m->bd.attach (m->bd);
+            m->pPeer->m->bd.attach(m->bd);
         }
     }
@@ -762,9 +775,9 @@
     /* sanity */
     AutoCaller autoCaller(this);
-    AssertComRCReturnVoid (autoCaller.rc());
+    AssertComRCReturnVoid(autoCaller.rc());
 
     /* sanity too */
-    AutoCaller peerCaller (m->pPeer);
-    AssertComRCReturnVoid (peerCaller.rc());
+    AutoCaller peerCaller(m->pPeer);
+    AssertComRCReturnVoid(peerCaller.rc());
 
     /* peer is not modified, lock it for reading (m->pPeer is "master" so locked
