Index: trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp	(revision 65919)
+++ trunk/src/VBox/Main/src-server/MediumAttachmentImpl.cpp	(revision 66046)
@@ -167,5 +167,4 @@
 
     ComAssertRet(aParent && aThat, E_INVALIDARG);
-    Assert(!aParent->i_isSnapshotMachine());
 
     /* Enclose the state transition NotReady->InInit->Ready */
Index: trunk/src/VBox/Main/src-server/SnapshotImpl.cpp
===================================================================
--- trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 65919)
+++ trunk/src/VBox/Main/src-server/SnapshotImpl.cpp	(revision 66046)
@@ -999,7 +999,7 @@
      * same as Machine's data) */
     mUserData.share(pMachine->mUserData);
-    /* make a private copy of all other data (recent changes from SessionMachine) */
+
+    /* make a private copy of all other data */
     mHWData.attachCopy(aSessionMachine->mHWData);
-    mMediaData.attachCopy(aSessionMachine->mMediaData);
 
     /* SSData is always unique for SnapshotMachine */
@@ -1009,30 +1009,54 @@
     HRESULT rc = S_OK;
 
+    /* Create copies of all attachments (mMediaData after attaching a copy
+     * contains just references to original objects). Additionally associate
+     * media with the snapshot (Machine::uninitDataAndChildObjects() will
+     * deassociate at destruction). */
+    mMediaData.allocate();
+    for (MediaData::AttachmentList::const_iterator
+         it = aSessionMachine->mMediaData->mAttachments.begin();
+         it != aSessionMachine->mMediaData->mAttachments.end();
+         ++it)
+    {
+        ComObjPtr<MediumAttachment> pAtt;
+        pAtt.createObject();
+        rc = pAtt->initCopy(this, *it);
+        if (FAILED(rc)) return rc;
+        mMediaData->mAttachments.push_back(pAtt);
+
+        Medium *pMedium = pAtt->i_getMedium();
+        if (pMedium) // can be NULL for non-harddisk
+        {
+            rc = pMedium->i_addBackReference(mData->mUuid, mSnapshotId);
+            AssertComRC(rc);
+        }
+    }
+
     /* create copies of all shared folders (mHWData after attaching a copy
      * contains just references to original objects) */
-    for (HWData::SharedFolderList::iterator it = mHWData->mSharedFolders.begin();
+    for (HWData::SharedFolderList::iterator
+         it = mHWData->mSharedFolders.begin();
          it != mHWData->mSharedFolders.end();
          ++it)
     {
-        ComObjPtr<SharedFolder> folder;
-        folder.createObject();
-        rc = folder->initCopy(this, *it);
+        ComObjPtr<SharedFolder> pFolder;
+        pFolder.createObject();
+        rc = pFolder->initCopy(this, *it);
         if (FAILED(rc)) return rc;
-        *it = folder;
-    }
-
-    /* associate hard disks with the snapshot
-     * (Machine::uninitDataAndChildObjects() will deassociate at destruction) */
-    for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin();
-         it != mMediaData->mAttachments.end();
+        *it = pFolder;
+    }
+
+    /* create copies of all PCI device assignments (mHWData after attaching
+     * a copy contains just references to original objects) */
+    for (HWData::PCIDeviceAssignmentList::iterator
+         it = mHWData->mPCIDeviceAssignments.begin();
+         it != mHWData->mPCIDeviceAssignments.end();
          ++it)
     {
-        MediumAttachment *pAtt = *it;
-        Medium *pMedium = pAtt->i_getMedium();
-        if (pMedium) // can be NULL for non-harddisk
-        {
-            rc = pMedium->i_addBackReference(mData->mUuid, mSnapshotId);
-            AssertComRC(rc);
-        }
+        ComObjPtr<PCIDeviceAttachment> pDev;
+        pDev.createObject();
+        rc = pDev->initCopy(this, *it);
+        if (FAILED(rc)) return rc;
+        *it = pDev;
     }
 
@@ -1047,5 +1071,6 @@
         ComObjPtr<StorageController> ctrl;
         ctrl.createObject();
-        ctrl->initCopy(this, *it);
+        rc = ctrl->initCopy(this, *it);
+        if (FAILED(rc)) return rc;
         mStorageControllers->push_back(ctrl);
     }
@@ -1054,11 +1079,14 @@
 
     unconst(mBIOSSettings).createObject();
-    mBIOSSettings->initCopy(this, pMachine->mBIOSSettings);
+    rc = mBIOSSettings->initCopy(this, pMachine->mBIOSSettings);
+    if (FAILED(rc)) return rc;
 
     unconst(mVRDEServer).createObject();
-    mVRDEServer->initCopy(this, pMachine->mVRDEServer);
+    rc = mVRDEServer->initCopy(this, pMachine->mVRDEServer);
+    if (FAILED(rc)) return rc;
 
     unconst(mAudioAdapter).createObject();
-    mAudioAdapter->initCopy(this, pMachine->mAudioAdapter);
+    rc = mAudioAdapter->initCopy(this, pMachine->mAudioAdapter);
+    if (FAILED(rc)) return rc;
 
     /* create copies of all USB controllers (mUSBControllerData
@@ -1072,10 +1100,12 @@
         ComObjPtr<USBController> ctrl;
         ctrl.createObject();
-        ctrl->initCopy(this, *it);
+        rc = ctrl->initCopy(this, *it);
+        if (FAILED(rc)) return rc;
         mUSBControllers->push_back(ctrl);
     }
 
     unconst(mUSBDeviceFilters).createObject();
-    mUSBDeviceFilters->initCopy(this, pMachine->mUSBDeviceFilters);
+    rc = mUSBDeviceFilters->initCopy(this, pMachine->mUSBDeviceFilters);
+    if (FAILED(rc)) return rc;
 
     mNetworkAdapters.resize(pMachine->mNetworkAdapters.size());
@@ -1083,5 +1113,6 @@
     {
         unconst(mNetworkAdapters[slot]).createObject();
-        mNetworkAdapters[slot]->initCopy(this, pMachine->mNetworkAdapters[slot]);
+        rc = mNetworkAdapters[slot]->initCopy(this, pMachine->mNetworkAdapters[slot]);
+        if (FAILED(rc)) return rc;
     }
 
@@ -1089,5 +1120,6 @@
     {
         unconst(mSerialPorts[slot]).createObject();
-        mSerialPorts[slot]->initCopy(this, pMachine->mSerialPorts[slot]);
+        rc = mSerialPorts[slot]->initCopy(this, pMachine->mSerialPorts[slot]);
+        if (FAILED(rc)) return rc;
     }
 
@@ -1095,9 +1127,11 @@
     {
         unconst(mParallelPorts[slot]).createObject();
-        mParallelPorts[slot]->initCopy(this, pMachine->mParallelPorts[slot]);
+        rc = mParallelPorts[slot]->initCopy(this, pMachine->mParallelPorts[slot]);
+        if (FAILED(rc)) return rc;
     }
 
     unconst(mBandwidthControl).createObject();
-    mBandwidthControl->initCopy(this, pMachine->mBandwidthControl);
+    rc = mBandwidthControl->initCopy(this, pMachine->mBandwidthControl);
+    if (FAILED(rc)) return rc;
 
     /* Confirm a successful initialization when it's the case */
