Changeset 42382 in vbox for trunk/src/VBox/Main
- Timestamp:
- Jul 25, 2012 9:35:56 AM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r42354 r42382 961 961 <enum 962 962 name="LockType" 963 uuid="1 38b53f8-db4b-47c5-b32b-4ef52f769413"963 uuid="168a6a8e-12fd-4878-a1f9-38a750a56089" 964 964 > 965 965 <desc> … … 971 971 <const name="Shared" value="1"> 972 972 <desc>Request only a shared read lock for remote-controlling the machine.</desc> 973 </const> 974 <const name="VM" value="3"> 975 <desc>Lock the machine for writing, and create objects necessary for 976 running a VM in this process.</desc> 973 977 </const> 974 978 </enum> … … 16396 16400 </desc> 16397 16401 <param name="machine" type="IMachine" dir="in"/> 16402 <param name="lockType" type="LockType" dir="in"/> 16398 16403 </method> 16399 16404 -
trunk/src/VBox/Main/include/ConsoleImpl.h
r42261 r42382 114 114 115 115 // public initializers/uninitializers for internal purposes only 116 HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl );116 HRESULT init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType); 117 117 void uninit(); 118 118 -
trunk/src/VBox/Main/include/SessionImpl.h
r42261 r42382 81 81 STDMETHOD(GetPID)(ULONG *aPid); 82 82 STDMETHOD(GetRemoteConsole)(IConsole **aConsole); 83 STDMETHOD(AssignMachine)(IMachine *aMachine );83 STDMETHOD(AssignMachine)(IMachine *aMachine, LockType_T aLockType); 84 84 STDMETHOD(AssignRemoteMachine)(IMachine *aMachine, IConsole *aConsole); 85 85 STDMETHOD(UpdateMachineState)(MachineState_T aMachineState); -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r42261 r42382 434 434 ///////////////////////////////////////////////////////////////////////////// 435 435 436 HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl )436 HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl, LockType_T aLockType) 437 437 { 438 438 AssertReturn(aMachine && aControl, E_INVALIDARG); … … 450 450 unconst(mControl) = aControl; 451 451 452 /* Cache essential properties and objects */452 /* Cache essential properties and objects, and create child objects */ 453 453 454 454 rc = mMachine->COMGETTER(State)(&mMachineState); 455 455 AssertComRCReturnRC(rc); 456 456 457 rc = mMachine->COMGETTER(VRDEServer)(unconst(mVRDEServer).asOutParam()); 458 AssertComRCReturnRC(rc); 459 460 /* Create associated child COM objects */ 457 #ifdef VBOX_WITH_EXTPACK 458 unconst(mptrExtPackManager).createObject(); 459 rc = mptrExtPackManager->initExtPackManager(NULL, VBOXEXTPACKCTX_VM_PROCESS); 460 AssertComRCReturnRC(rc); 461 #endif 461 462 462 463 // Event source may be needed by other children … … 465 466 AssertComRCReturnRC(rc); 466 467 467 unconst(mGuest).createObject();468 rc = mGuest->init(this);469 AssertComRCReturnRC(rc);470 471 unconst(mKeyboard).createObject();472 rc = mKeyboard->init(this);473 AssertComRCReturnRC(rc);474 475 unconst(mMouse).createObject();476 rc = mMouse->init(this);477 AssertComRCReturnRC(rc);478 479 unconst(mDisplay).createObject();480 rc = mDisplay->init(this);481 AssertComRCReturnRC(rc);482 483 unconst(mVRDEServerInfo).createObject();484 rc = mVRDEServerInfo->init(this);485 AssertComRCReturnRC(rc);486 487 #ifdef VBOX_WITH_EXTPACK488 unconst(mptrExtPackManager).createObject();489 rc = mptrExtPackManager->initExtPackManager(NULL, VBOXEXTPACKCTX_VM_PROCESS);490 AssertComRCReturnRC(rc);491 #endif492 493 /* Grab global and machine shared folder lists */494 495 rc = fetchSharedFolders(true /* aGlobal */);496 AssertComRCReturnRC(rc);497 rc = fetchSharedFolders(false /* aGlobal */);498 AssertComRCReturnRC(rc);499 500 /* Create other child objects */501 502 unconst(mConsoleVRDPServer) = new ConsoleVRDPServer(this);503 AssertReturn(mConsoleVRDPServer, E_FAIL);504 505 468 mcAudioRefs = 0; 506 469 mcVRDPClients = 0; … … 508 471 mcGuestCredentialsProvided = false; 509 472 510 /* Figure out size of meAttachmentType vector */ 511 ComPtr<IVirtualBox> pVirtualBox; 512 rc = aMachine->COMGETTER(Parent)(pVirtualBox.asOutParam()); 513 AssertComRC(rc); 514 ComPtr<ISystemProperties> pSystemProperties; 515 if (pVirtualBox) 516 pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam()); 517 ChipsetType_T chipsetType = ChipsetType_PIIX3; 518 aMachine->COMGETTER(ChipsetType)(&chipsetType); 519 ULONG maxNetworkAdapters = 0; 520 if (pSystemProperties) 521 pSystemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters); 522 meAttachmentType.resize(maxNetworkAdapters); 523 for (ULONG slot = 0; slot < maxNetworkAdapters; ++slot) 524 meAttachmentType[slot] = NetworkAttachmentType_Null; 525 526 527 // VirtualBox 4.0: We no longer initialize the VMMDev instance here, 528 // which starts the HGCM thread. Instead, this is now done in the 529 // power-up thread when a VM is actually being powered up to avoid 530 // having HGCM threads all over the place every time a session is 531 // opened, even if that session will not run a VM. 532 // unconst(m_pVMMDev) = new VMMDev(this); 533 // AssertReturn(mVMMDev, E_FAIL); 534 535 unconst(mAudioSniffer) = new AudioSniffer(this); 536 AssertReturn(mAudioSniffer, E_FAIL); 473 /* Now the VM specific parts */ 474 if (aLockType == LockType_VM) 475 { 476 rc = mMachine->COMGETTER(VRDEServer)(unconst(mVRDEServer).asOutParam()); 477 AssertComRCReturnRC(rc); 478 479 unconst(mGuest).createObject(); 480 rc = mGuest->init(this); 481 AssertComRCReturnRC(rc); 482 483 unconst(mKeyboard).createObject(); 484 rc = mKeyboard->init(this); 485 AssertComRCReturnRC(rc); 486 487 unconst(mMouse).createObject(); 488 rc = mMouse->init(this); 489 AssertComRCReturnRC(rc); 490 491 unconst(mDisplay).createObject(); 492 rc = mDisplay->init(this); 493 AssertComRCReturnRC(rc); 494 495 unconst(mVRDEServerInfo).createObject(); 496 rc = mVRDEServerInfo->init(this); 497 AssertComRCReturnRC(rc); 498 499 /* Grab global and machine shared folder lists */ 500 501 rc = fetchSharedFolders(true /* aGlobal */); 502 AssertComRCReturnRC(rc); 503 rc = fetchSharedFolders(false /* aGlobal */); 504 AssertComRCReturnRC(rc); 505 506 /* Create other child objects */ 507 508 unconst(mConsoleVRDPServer) = new ConsoleVRDPServer(this); 509 AssertReturn(mConsoleVRDPServer, E_FAIL); 510 511 /* Figure out size of meAttachmentType vector */ 512 ComPtr<IVirtualBox> pVirtualBox; 513 rc = aMachine->COMGETTER(Parent)(pVirtualBox.asOutParam()); 514 AssertComRC(rc); 515 ComPtr<ISystemProperties> pSystemProperties; 516 if (pVirtualBox) 517 pVirtualBox->COMGETTER(SystemProperties)(pSystemProperties.asOutParam()); 518 ChipsetType_T chipsetType = ChipsetType_PIIX3; 519 aMachine->COMGETTER(ChipsetType)(&chipsetType); 520 ULONG maxNetworkAdapters = 0; 521 if (pSystemProperties) 522 pSystemProperties->GetMaxNetworkAdapters(chipsetType, &maxNetworkAdapters); 523 meAttachmentType.resize(maxNetworkAdapters); 524 for (ULONG slot = 0; slot < maxNetworkAdapters; ++slot) 525 meAttachmentType[slot] = NetworkAttachmentType_Null; 526 527 // VirtualBox 4.0: We no longer initialize the VMMDev instance here, 528 // which starts the HGCM thread. Instead, this is now done in the 529 // power-up thread when a VM is actually being powered up to avoid 530 // having HGCM threads all over the place every time a session is 531 // opened, even if that session will not run a VM. 532 // unconst(m_pVMMDev) = new VMMDev(this); 533 // AssertReturn(mVMMDev, E_FAIL); 534 535 unconst(mAudioSniffer) = new AudioSniffer(this); 536 AssertReturn(mAudioSniffer, E_FAIL); 537 537 #ifdef VBOX_WITH_USB_VIDEO 538 unconst(mUsbWebcamInterface) = new UsbWebcamInterface(this);539 AssertReturn(mUsbWebcamInterface, E_FAIL);538 unconst(mUsbWebcamInterface) = new UsbWebcamInterface(this); 539 AssertReturn(mUsbWebcamInterface, E_FAIL); 540 540 #endif 541 541 #ifdef VBOX_WITH_USB_CARDREADER 542 unconst(mUsbCardReader) = new UsbCardReader(this);543 AssertReturn(mUsbCardReader, E_FAIL);542 unconst(mUsbCardReader) = new UsbCardReader(this); 543 AssertReturn(mUsbCardReader, E_FAIL); 544 544 #endif 545 545 546 /* VirtualBox events registration. */547 {548 ComPtr<IEventSource> pES;549 rc = pVirtualBox->COMGETTER(EventSource)(pES.asOutParam());550 AssertComRC(rc);551 ComObjPtr<VmEventListenerImpl> aVmListener;552 aVmListener.createObject();553 aVmListener->init(new VmEventListener(), this);554 mVmListener = aVmListener;555 com::SafeArray<VBoxEventType_T> eventTypes;556 eventTypes.push_back(VBoxEventType_OnNATRedirect);557 eventTypes.push_back(VBoxEventType_OnHostPciDevicePlug);558 rc = pES->RegisterListener(aVmListener, ComSafeArrayAsInParam(eventTypes), true);559 AssertComRC(rc);560 }561 546 /* VirtualBox events registration. */ 547 { 548 ComPtr<IEventSource> pES; 549 rc = pVirtualBox->COMGETTER(EventSource)(pES.asOutParam()); 550 AssertComRC(rc); 551 ComObjPtr<VmEventListenerImpl> aVmListener; 552 aVmListener.createObject(); 553 aVmListener->init(new VmEventListener(), this); 554 mVmListener = aVmListener; 555 com::SafeArray<VBoxEventType_T> eventTypes; 556 eventTypes.push_back(VBoxEventType_OnNATRedirect); 557 eventTypes.push_back(VBoxEventType_OnHostPciDevicePlug); 558 rc = pES->RegisterListener(aVmListener, ComSafeArrayAsInParam(eventTypes), true); 559 AssertComRC(rc); 560 } 561 } 562 562 563 563 /* Confirm a successful initialization when it's the case */ -
trunk/src/VBox/Main/src-client/SessionImpl.cpp
r42261 r42382 300 300 } 301 301 302 STDMETHODIMP Session::AssignMachine(IMachine *aMachine )302 STDMETHODIMP Session::AssignMachine(IMachine *aMachine, LockType_T aLockType) 303 303 { 304 304 LogFlowThisFuncEnter(); … … 337 337 AssertComRCReturn(rc, rc); 338 338 339 rc = mConsole->init(aMachine, mControl );339 rc = mConsole->init(aMachine, mControl, aLockType); 340 340 AssertComRCReturn(rc, rc); 341 341 … … 358 358 /* some cleanup */ 359 359 mControl.setNull(); 360 mConsole->uninit(); 361 mConsole.setNull(); 360 if (!mConsole.isNull()) 361 { 362 mConsole->uninit(); 363 mConsole.setNull(); 364 } 362 365 } 363 366 … … 531 534 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 532 535 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 536 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 533 537 534 538 return mConsole->onNetworkAdapterChange(networkAdapter, changeAdapter); … … 545 549 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 546 550 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 551 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 547 552 548 553 return mConsole->onSerialPortChange(serialPort); … … 559 564 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 560 565 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 566 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 561 567 562 568 return mConsole->onParallelPortChange(parallelPort); … … 573 579 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 574 580 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 581 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 575 582 576 583 return mConsole->onStorageControllerChange(); … … 587 594 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 588 595 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 596 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 589 597 590 598 return mConsole->onMediumChange(aMediumAttachment, aForce); … … 601 609 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 602 610 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 611 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 603 612 604 613 return mConsole->onCPUChange(aCPU, aRemove); … … 615 624 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 616 625 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 626 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 617 627 618 628 return mConsole->onCPUExecutionCapChange(aExecutionCap); … … 629 639 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 630 640 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 641 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 631 642 632 643 return mConsole->onVRDEServerChange(aRestart); … … 643 654 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 644 655 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 656 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 645 657 646 658 return mConsole->onUSBControllerChange(); … … 657 669 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 658 670 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 671 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 659 672 660 673 return mConsole->onSharedFolderChange(aGlobal); … … 671 684 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 672 685 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 686 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 673 687 674 688 return mConsole->onClipboardModeChange(aClipboardMode); … … 701 715 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 702 716 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 717 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 703 718 704 719 return mConsole->onUSBDeviceAttach(aDevice, aError, aMaskedIfs); … … 716 731 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 717 732 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 733 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 718 734 719 735 return mConsole->onUSBDeviceDetach(aId, aError); … … 728 744 729 745 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 746 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 730 747 731 748 if (mState != SessionState_Locked) … … 753 770 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 754 771 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 772 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 755 773 756 774 return mConsole->onBandwidthGroupChange(aBandwidthGroup); … … 767 785 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 768 786 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 787 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 769 788 770 789 return mConsole->onStorageDeviceChange(aMediumAttachment, aRemove); … … 796 815 if (aIsSetter && (aFlags != NULL) && !VALID_PTR(aFlags)) 797 816 return E_INVALIDARG; 817 818 /* If this session is not in a VM process fend off the call. The caller 819 * handles this correctly, by doing the operation in VBoxSVC. */ 820 if (!mConsole) 821 return E_ACCESSDENIED; 822 798 823 if (!aIsSetter) 799 824 return mConsole->getGuestProperty(aName, aRetValue, aRetTimestamp, aRetFlags); … … 830 855 if (ComSafeArrayOutIsNull(aFlags)) 831 856 return E_POINTER; 857 858 /* If this session is not in a VM process fend off the call. The caller 859 * handles this correctly, by doing the operation in VBoxSVC. */ 860 if (!mConsole) 861 return E_ACCESSDENIED; 862 832 863 return mConsole->enumerateGuestProperties(aPatterns, 833 864 ComSafeArrayOutArg(aNames), … … 856 887 Global::stringifySessionState(mState)); 857 888 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 889 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 858 890 CheckComArgNotNull(aMediumAttachment); 859 891 CheckComArgSafeArrayNotNull(aChildrenToReparent); … … 874 906 AssertReturn(mState == SessionState_Locked, VBOX_E_INVALID_VM_STATE); 875 907 AssertReturn(mType == SessionType_WriteLock, VBOX_E_INVALID_OBJECT_STATE); 908 AssertReturn(mConsole, VBOX_E_INVALID_OBJECT_STATE); 876 909 877 910 mConsole->enableVMMStatistics(aEnable); … … 940 973 if (mType == SessionType_WriteLock) 941 974 { 942 mConsole->uninit(); 943 mConsole.setNull(); 975 if (!mConsole.isNull()) 976 { 977 mConsole->uninit(); 978 mConsole.setNull(); 979 } 944 980 } 945 981 else -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r42261 r42382 3304 3304 3305 3305 LogFlowThisFunc(("Calling AssignMachine()...\n")); 3306 rc = pSessionControl->AssignMachine(sessionMachine );3306 rc = pSessionControl->AssignMachine(sessionMachine, lockType); 3307 3307 LogFlowThisFunc(("AssignMachine() returned %08X\n", rc)); 3308 3308 … … 3419 3419 { 3420 3420 /* 3421 * tell the client watcher thread to update the set of3422 * machines that have open sessions3423 */3421 * tell the client watcher thread to update the set of 3422 * machines that have open sessions 3423 */ 3424 3424 mParent->updateClientWatcher(); 3425 3425 … … 7239 7239 /* inform the session that it will be a remote one */ 7240 7240 LogFlowThisFunc(("Calling AssignMachine (NULL)...\n")); 7241 HRESULT rc = aControl->AssignMachine(NULL );7241 HRESULT rc = aControl->AssignMachine(NULL, LockType_Write); 7242 7242 LogFlowThisFunc(("AssignMachine (NULL) returned %08X\n", rc)); 7243 7243
Note:
See TracChangeset
for help on using the changeset viewer.