~ubuntu-branches/ubuntu/natty/virtualbox-ose/natty-updates

« back to all changes in this revision

Viewing changes to src/VBox/Main/MachineImpl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-03-11 17:16:37 UTC
  • mfrom: (0.3.4 upstream) (0.4.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100311171637-43z64ia3ccpj8vqn
Tags: 3.1.4-dfsg-2ubuntu1
* Merge from Debian unstable (LP: #528561), remaining changes:
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
  - Replace *-source packages with transitional packages for *-dkms
* Fix crash in vboxvideo_drm with kernel 2.6.33 / backported drm code
  (LP: #535297)
* Add a list of linux-headers packages to the apport hook
* Update debian/patches/u02-lp-integration.dpatch with a
  DEP-3 compliant header
* Add ${misc:Depends} to virtualbox-ose-source and virtualbox-ose-guest-source
  Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
    mAccelerate2DVideoEnabled = false;
163
163
    mMonitorCount = 1;
164
164
    mHWVirtExEnabled = true;
165
 
    mHWVirtExNestedPagingEnabled = false;
166
 
    mHWVirtExVPIDEnabled = false;
 
165
    mHWVirtExNestedPagingEnabled = true;
 
166
    mHWVirtExVPIDEnabled = true;
167
167
#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS)
168
168
    mHWVirtExExclusive = false;
169
169
#else
633
633
    LogFlowThisFunc(("initFailed()=%d\n", autoUninitSpan.initFailed()));
634
634
    LogFlowThisFunc(("mRegistered=%d\n", mData->mRegistered));
635
635
 
636
 
    /* Enter this object lock because there may be a SessionMachine instance
637
 
     * somewhere around, that shares our data and lock but doesn't use our
638
 
     * addCaller()/removeCaller(), and it may be also accessing the same data
639
 
     * members. mParent lock is necessary as well because of
640
 
     * SessionMachine::uninit(), etc.
641
 
     */
642
 
    AutoMultiWriteLock2 alock (mParent, this);
 
636
    AutoMultiWriteLock2 alock(mParent, this);
643
637
 
644
638
    if (!mData->mSession.mMachine.isNull())
645
639
    {
655
649
         * after we return from this method (it expects the Machine instance is
656
650
         * still valid). We'll call it ourselves below.
657
651
         */
658
 
        LogWarningThisFunc(("Session machine is not NULL (%p), "
659
 
                             "the direct session is still open!\n",
660
 
                             (SessionMachine *) mData->mSession.mMachine));
 
652
        LogWarningThisFunc(("Session machine is not NULL (%p), the direct session is still open!\n",
 
653
                            (SessionMachine*)mData->mSession.mMachine));
661
654
 
662
 
        if (Global::IsOnlineOrTransient (mData->mMachineState))
 
655
        if (Global::IsOnlineOrTransient(mData->mMachineState))
663
656
        {
664
657
            LogWarningThisFunc(("Setting state to Aborted!\n"));
665
658
            /* set machine state using SessionMachine reimplementation */
666
 
            static_cast <Machine *> (mData->mSession.mMachine)
667
 
                ->setMachineState (MachineState_Aborted);
 
659
            static_cast<Machine*>(mData->mSession.mMachine)->setMachineState (MachineState_Aborted);
668
660
        }
669
661
 
670
662
        /*
673
665
         */
674
666
        mData->mSession.mMachine->uninit();
675
667
        /* SessionMachine::uninit() must set mSession.mMachine to null */
676
 
        Assert (mData->mSession.mMachine.isNull());
 
668
        Assert(mData->mSession.mMachine.isNull());
677
669
    }
678
670
 
679
671
    /* the lock is no more necessary (SessionMachine is uninitialized) */
3295
3287
    AutoReadLock alock(this);
3296
3288
 
3297
3289
    Guid uuid(aId);
 
3290
    /* Todo: fix this properly by perhaps introducing an isValid method for the Guid class */
 
3291
    if (    (aId)
 
3292
        &&  (*aId != '\0')      // an empty Bstr means "get root snapshot", so don't fail on that
 
3293
        &&  (uuid.isEmpty()))
 
3294
    {
 
3295
        RTUUID uuidTemp;
 
3296
        /* Either it's a null UUID or the conversion failed. (null uuid has a special meaning in findSnapshot) */
 
3297
        if (RT_FAILURE(RTUuidFromUtf16(&uuidTemp, aId)))
 
3298
            return setError(E_FAIL,
 
3299
                            tr("Could not find a snapshot with UUID {%ls}"),
 
3300
                            aId);
 
3301
    }
 
3302
 
3298
3303
    ComObjPtr<Snapshot> snapshot;
3299
3304
 
3300
3305
    HRESULT rc = findSnapshot(uuid, snapshot, true /* aSetError */);
4018
4023
                    }
4019
4024
                    else
4020
4025
                    {
4021
 
                        if (cbBlock != 0)
 
4026
                        /* displaySSMSaveScreenshot did not write any data, if
 
4027
                         * cbBlock was == 2 * sizeof (uint32_t).
 
4028
                         */
 
4029
                        if (cbBlock > 2 * sizeof (uint32_t))
4022
4030
                        {
4023
4031
                            rc = SSMR3Skip(pSSM, cbBlock);
4024
4032
                            AssertRCBreak(rc);
4835
4843
 
4836
4844
    ComAssertRet (!mData->mSession.mDirectControl.isNull(), E_FAIL);
4837
4845
 
4838
 
    /*
4839
 
     *  Get the console from the direct session (note that we don't leave the
4840
 
     *  lock here because GetRemoteConsole must not call us back).
4841
 
     */
4842
 
    ComPtr<IConsole> console;
4843
 
    HRESULT rc = mData->mSession.mDirectControl->
4844
 
                     GetRemoteConsole (console.asOutParam());
4845
 
    if (FAILED (rc))
4846
 
    {
4847
 
        /* The failure may occur w/o any error info (from RPC), so provide one */
4848
 
        return setError (VBOX_E_VM_ERROR,
4849
 
            tr ("Failed to get a console object from the direct session (%Rrc)"), rc);
4850
 
    }
4851
 
 
4852
 
    ComAssertRet (!console.isNull(), E_FAIL);
4853
 
 
4854
 
    ComObjPtr<SessionMachine> sessionMachine = mData->mSession.mMachine;
4855
 
    AssertReturn(!sessionMachine.isNull(), E_FAIL);
 
4846
    // copy member variables before leaving lock
 
4847
    ComPtr<IInternalSessionControl> pDirectControl = mData->mSession.mDirectControl;
 
4848
    ComObjPtr<SessionMachine> pSessionMachine = mData->mSession.mMachine;
 
4849
    AssertReturn(!pSessionMachine.isNull(), E_FAIL);
4856
4850
 
4857
4851
    /*
4858
4852
     *  Leave the lock before calling the client process. It's safe here
4862
4856
     */
4863
4857
    alock.leave();
4864
4858
 
 
4859
    // get the console from the direct session (this is a remote call)
 
4860
    ComPtr<IConsole> pConsole;
 
4861
    LogFlowThisFunc(("Calling GetRemoteConsole()...\n"));
 
4862
    HRESULT rc = pDirectControl->GetRemoteConsole(pConsole.asOutParam());
 
4863
    LogFlowThisFunc(("GetRemoteConsole() returned %08X\n", rc));
 
4864
    if (FAILED (rc))
 
4865
        /* The failure may occur w/o any error info (from RPC), so provide one */
 
4866
        return setError (VBOX_E_VM_ERROR,
 
4867
            tr ("Failed to get a console object from the direct session (%Rrc)"), rc);
 
4868
 
 
4869
    ComAssertRet(!pConsole.isNull(), E_FAIL);
 
4870
 
4865
4871
    /* attach the remote session to the machine */
4866
4872
    LogFlowThisFunc(("Calling AssignRemoteMachine()...\n"));
4867
 
    rc = aControl->AssignRemoteMachine (sessionMachine, console);
 
4873
    rc = aControl->AssignRemoteMachine(pSessionMachine, pConsole);
4868
4874
    LogFlowThisFunc(("AssignRemoteMachine() returned %08X\n", rc));
4869
4875
 
4870
4876
    /* The failure may occur w/o any error info (from RPC), so provide one */
4886
4892
    }
4887
4893
 
4888
4894
    /* store the control in the list */
4889
 
    mData->mSession.mRemoteControls.push_back (aControl);
 
4895
    mData->mSession.mRemoteControls.push_back(aControl);
4890
4896
 
4891
4897
    LogFlowThisFuncLeave();
4892
4898
    return S_OK;
5538
5544
 
5539
5545
    if (mType == IsMachine)
5540
5546
    {
5541
 
        /* reset some important fields of mData */
 
5547
        // clean up the snapshots list (Snapshot::uninit() will handle the snapshot's children recursively)
 
5548
        if (mData->mFirstSnapshot)
 
5549
        {
 
5550
            mData->mFirstSnapshot->uninit();
 
5551
            mData->mFirstSnapshot.setNull();
 
5552
        }
 
5553
 
5542
5554
        mData->mCurrentSnapshot.setNull();
5543
 
        mData->mFirstSnapshot.setNull();
5544
5555
    }
5545
5556
 
5546
5557
    /* free data structures (the essential mData structure is not freed here
9699
9710
 *  Returns @c true if this machine's USB controller reports it has a matching
9700
9711
 *  filter for the given USB device and @c false otherwise.
9701
9712
 *
9702
 
 *  @note Locks this object for reading.
 
9713
 *  @note Caller must have requested machine write lock.
9703
9714
 */
9704
9715
bool SessionMachine::hasMatchingUSBFilter (const ComObjPtr<HostUSBDevice> &aDevice, ULONG *aMaskedIfs)
9705
9716
{
9709
9720
    if (!autoCaller.isOk())
9710
9721
        return false;
9711
9722
 
9712
 
    AutoReadLock alock(this);
 
9723
    AssertReturn(isWriteLockOnCurrentThread(), false);
9713
9724
 
9714
9725
#ifdef VBOX_WITH_USB
9715
9726
    switch (mData->mMachineState)