summaryrefslogtreecommitdiff
path: root/src/VBox/Main/src-server/MediumAttachmentImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Main/src-server/MediumAttachmentImpl.cpp')
-rw-r--r--src/VBox/Main/src-server/MediumAttachmentImpl.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/VBox/Main/src-server/MediumAttachmentImpl.cpp b/src/VBox/Main/src-server/MediumAttachmentImpl.cpp
index 8fb9ab84b..0ad663de4 100644
--- a/src/VBox/Main/src-server/MediumAttachmentImpl.cpp
+++ b/src/VBox/Main/src-server/MediumAttachmentImpl.cpp
@@ -64,8 +64,8 @@ struct BackupableMediumAttachmentData
struct MediumAttachment::Data
{
- Data()
- : pMachine(NULL),
+ Data(Machine * const aMachine = NULL)
+ : pMachine(aMachine),
fIsEjected(false)
{ }
@@ -165,6 +165,36 @@ HRESULT MediumAttachment::init(Machine *aParent,
}
/**
+ * Initializes the medium attachment object given another guest object
+ * (a kind of copy constructor). This object makes a private copy of data
+ * of the original object passed as an argument.
+ */
+HRESULT MediumAttachment::initCopy(Machine *aParent, MediumAttachment *aThat)
+{
+ LogFlowThisFunc(("aParent=%p, aThat=%p\n", aParent, aThat));
+
+ ComAssertRet(aParent && aThat, E_INVALIDARG);
+
+ /* Enclose the state transition NotReady->InInit->Ready */
+ AutoInitSpan autoInitSpan(this);
+ AssertReturn(autoInitSpan.isOk(), E_FAIL);
+
+ m = new Data(aParent);
+ /* m->pPeer is left null */
+
+ AutoCaller thatCaller(aThat);
+ AssertComRCReturnRC(thatCaller.rc());
+
+ AutoReadLock thatlock(aThat COMMA_LOCKVAL_SRC_POS);
+ m->bd.attachCopy(aThat->m->bd);
+
+ /* Confirm a successful initialization */
+ autoInitSpan.setSucceeded();
+
+ return S_OK;
+}
+
+/**
* Uninitializes the instance.
* Called from FinalRelease().
*/