Changeset 28625 in vbox
- Timestamp:
- Apr 23, 2010 7:57:16 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60476
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r28557 r28625 65 65 " <path to program> [--arguments \"<arguments>\"] [--environment \"<NAME=VALUE NAME=VALUE>\"]\n" 66 66 " [--flags <flags>] [--timeout <msec>] [--username <name> [--password <password>]]\n" 67 " [--verbose] [--wait-for exit ]\n"67 " [--verbose] [--wait-for exit,stdout,stderr||]\n" 68 68 "\n"); 69 69 } -
trunk/src/VBox/HostServices/GuestControl/service.cpp
r28557 r28625 531 531 int rc = VINF_SUCCESS; 532 532 533 HostCmd newCmd;534 rc = paramBufferAllocate(&newCmd.parmBuf, eFunction, cParms, paParms);535 if (RT_SUCCESS(rc))536 {537 mHostCmds.push_back(newCmd);538 539 /* Limit list size by deleting oldest element. */540 if (mHostCmds.size() > 256) /** @todo Use a define! */541 mHostCmds.pop_front();542 }543 544 533 /* Some lazy guests to wake up which can process this command right now? */ 545 534 if (!mGuestWaiters.empty()) 546 535 { 547 GuestCall curCall = mGuestWaiters.front(); 548 rc = notifyGuest(&curCall, eFunction, cParms, paParms); 549 mGuestWaiters.pop_front(); 550 } 536 HostCmd newCmd; 537 rc = paramBufferAllocate(&newCmd.parmBuf, eFunction, cParms, paParms); 538 if (RT_SUCCESS(rc)) 539 { 540 mHostCmds.push_back(newCmd); 541 542 /* Limit list size by deleting oldest element. */ 543 if (mHostCmds.size() > 256) /** @todo Use a define! */ 544 mHostCmds.pop_front(); 545 546 GuestCall curCall = mGuestWaiters.front(); 547 rc = notifyGuest(&curCall, eFunction, cParms, paParms); 548 mGuestWaiters.pop_front(); 549 } 550 } 551 else /* No guest waiting, don't bother ... */ 552 rc = VERR_TIMEOUT; 551 553 return rc; 552 554 } -
trunk/src/VBox/Main/GuestImpl.cpp
r28571 r28625 111 111 112 112 #ifdef VBOX_WITH_GUEST_CONTROL 113 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 114 113 115 /* Clean up callback data. */ 114 116 CallbackListIter it; … … 508 510 int rc = VINF_SUCCESS; 509 511 512 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 513 510 514 AssertPtr(pData); 511 515 CallbackListIter it = getCtrlCallbackContextByID(pData->hdr.u32ContextID); … … 580 584 int rc = VINF_SUCCESS; 581 585 586 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 587 582 588 AssertPtr(pData); 583 589 CallbackListIter it = getCtrlCallbackContextByID(pData->hdr.u32ContextID); … … 600 606 pCBData->cbData = pData->cbData; 601 607 } 602 603 608 ASMAtomicWriteBool(&it->bCalled, true); 604 609 } … … 611 616 Guest::CallbackListIter Guest::getCtrlCallbackContextByID(uint32_t u32ContextID) 612 617 { 618 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 619 613 620 /** @todo Maybe use a map instead of list for fast context lookup. */ 614 621 CallbackListIter it; … … 623 630 Guest::CallbackListIter Guest::getCtrlCallbackContextByPID(uint32_t u32PID) 624 631 { 632 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 633 625 634 /** @todo Maybe use a map instead of list for fast context lookup. */ 626 635 CallbackListIter it; … … 637 646 { 638 647 LogFlowFuncEnter(); 648 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 639 649 if (it->cbData) 640 650 { … … 650 660 } 651 661 } 652 mCallbackList.erase(it);653 662 LogFlowFuncLeave(); 654 663 } … … 657 666 * to the callback list. A callback is identified by a unique context ID which is used 658 667 * to identify a callback from the guest side. */ 659 uint32_t Guest::addCtrlCallbackContext(void *pvData, uint32_t cbData, Progress *pProgress)668 uint32_t Guest::addCtrlCallbackContext(void *pvData, uint32_t cbData, Progress *pProgress) 660 669 { 661 670 LogFlowFuncEnter(); 662 671 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 663 672 uint32_t uNewContext = ASMAtomicIncU32(&mNextContextID); 664 673 if (uNewContext == UINT32_MAX) … … 674 683 mCallbackList.push_back(context); 675 684 if (mCallbackList.size() > 256) /* Don't let the container size get too big! */ 676 removeCtrlCallbackContext(mCallbackList.begin()); 685 { 686 Guest::CallbackListIter it = mCallbackList.begin(); 687 removeCtrlCallbackContext(it); 688 mCallbackList.erase(it); 689 } 677 690 678 691 LogFlowFuncLeave(); … … 704 717 AutoCaller autoCaller(this); 705 718 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 706 707 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);708 719 709 720 /* … … 733 744 char **papszArgv = NULL; 734 745 uint32_t uNumArgs = 0; 735 if (aArguments > 0)746 if (aArguments > 0) 736 747 { 737 748 com::SafeArray<IN_BSTR> args(ComSafeArrayInArg(aArguments)); … … 800 811 paParms[i++].setUInt32(aTimeoutMS); 801 812 813 /* Make sure mParent is valid, so set a read lock in this scope. */ 814 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 815 802 816 /* Forward the information to the VMM device. */ 803 817 AssertPtr(mParent); … … 809 823 i, paParms); 810 824 } 825 else 826 vrc = VERR_INVALID_VM_HANDLE; 811 827 RTMemFree(pvEnv); 812 828 } … … 823 839 */ 824 840 CallbackListIter it = getCtrlCallbackContextByID(uContextID); 825 uint64_t u64Started = RTTimeMilliTS(); 826 do 841 if (it != mCallbackList.end()) 827 842 { 828 unsigned cMsWait; 829 if (aTimeoutMS == RT_INDEFINITE_WAIT) 830 cMsWait = 1000; 831 else 843 uint64_t u64Started = RTTimeMilliTS(); 844 do 832 845 { 833 uint64_t cMsElapsed = RTTimeMilliTS() - u64Started; 834 if (cMsElapsed >= aTimeoutMS) 835 break; /* timed out */ 836 cMsWait = RT_MIN(1000, aTimeoutMS - (uint32_t)cMsElapsed); 837 } 838 RTThreadSleep(100); 839 } while (it != mCallbackList.end() && !it->bCalled); 846 unsigned cMsWait; 847 if (aTimeoutMS == RT_INDEFINITE_WAIT) 848 cMsWait = 1000; 849 else 850 { 851 uint64_t cMsElapsed = RTTimeMilliTS() - u64Started; 852 if (cMsElapsed >= aTimeoutMS) 853 break; /* Timed out. */ 854 cMsWait = RT_MIN(1000, aTimeoutMS - (uint32_t)cMsElapsed); 855 } 856 RTThreadSleep(100); 857 } while (!it->bCalled); 858 } 859 860 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 840 861 841 862 /* Did we get some status? */ … … 862 883 else /* If callback not called within time ... well, that's a timeout! */ 863 884 vrc = VERR_TIMEOUT; 885 886 alock.release(); 864 887 865 888 /* … … 903 926 else 904 927 { 905 /* HGCM call went wrong. */ 906 rc = setError(E_UNEXPECTED, 907 tr("The service call failed with error %Rrc"), vrc); 928 if (vrc == VERR_INVALID_VM_HANDLE) 929 { 930 rc = setError(VBOX_E_VM_ERROR, 931 tr("VMM device is not available (is the VM running?)")); 932 } 933 else if (vrc == VERR_TIMEOUT) 934 { 935 rc = setError(VBOX_E_VM_ERROR, 936 tr("The guest execution service is not ready")); 937 } 938 else /* HGCM call went wrong. */ 939 { 940 rc = setError(E_UNEXPECTED, 941 tr("The service call failed with error %Rrc"), vrc); 942 } 908 943 } 909 944
Note:
See TracChangeset
for help on using the changeset viewer.