Changeset 45482 in vbox for trunk/src/VBox/Main
- Timestamp:
- Apr 11, 2013 11:11:42 AM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r45426 r45482 19928 19928 name="IGuestSessionEvent" extends="IEvent" 19929 19929 uuid="b9acd33f-647d-45ac-8fe9-f49b3183ba37" 19930 wsmap="managed" id="GuestSessionEvent"19930 wsmap="managed" 19931 19931 > 19932 19932 <desc>Base abstract interface for all guest session events.</desc> … … 19984 19984 <interface 19985 19985 name="IGuestProcessEvent" extends="IGuestSessionEvent" 19986 uuid=" ee4be6e7-76c5-4517-a623-d4b1957d4ea4"19987 wsmap="managed" id="GuestProcessEvent"19986 uuid="2405f0e5-6588-40a3-9b0a-68c05ba52c4b" 19987 wsmap="managed" 19988 19988 > 19989 19989 <desc>Base abstract interface for all guest process events.</desc> … … 20042 20042 20043 20043 <interface 20044 name="IGuestProcessInputNotifyEvent" extends="IGuestProcessEvent" 20045 uuid="b3d6bb71-0392-4971-a908-f71c931995fd" 20044 name="IGuestProcessIOEvent" extends="IGuestProcessEvent" 20045 uuid="9ea9227c-e9bb-49b3-bfc7-c5171e93ef38" 20046 wsmap="managed" 20047 > 20048 <desc> 20049 Base abstract interface for all guest process input/output (IO) events. 20050 </desc> 20051 20052 <attribute name="handle" type="unsigned long" readonly="yes"> 20053 <desc> 20054 TODO 20055 </desc> 20056 </attribute> 20057 20058 <attribute name="processed" type="unsigned long" readonly="yes"> 20059 <desc> 20060 TODO 20061 </desc> 20062 </attribute> 20063 20064 </interface> 20065 20066 <interface 20067 name="IGuestProcessInputNotifyEvent" extends="IGuestProcessIOEvent" 20068 uuid="0de887f2-b7db-4616-aac6-cfb94d89ba78" 20046 20069 wsmap="managed" autogen="VBoxEvent" id="OnGuestProcessInputNotify" 20047 20070 > … … 20056 20079 </attribute> 20057 20080 20058 <attribute name="handle" type="unsigned long" readonly="yes">20059 <desc>20060 TODO20061 </desc>20062 </attribute>20063 20064 <attribute name="processed" type="unsigned long" readonly="yes">20065 <desc>20066 TODO20067 </desc>20068 </attribute>20069 20070 20081 </interface> 20071 20082 20072 20083 <interface 20073 name="IGuestProcessOutputEvent" extends="IGuestProcess Event"20074 uuid=" a13533b9-4aba-4937-836e-81325859c9d8"20084 name="IGuestProcessOutputEvent" extends="IGuestProcessIOEvent" 20085 uuid="d3d5f1ee-bcb2-4905-a7ab-cc85448a742b" 20075 20086 wsmap="managed" autogen="VBoxEvent" id="OnGuestProcessOutput" 20076 20087 > … … 20079 20090 </desc> 20080 20091 20081 <attribute name="handle" type="unsigned long" readonly="yes">20082 <desc>20083 TODO20084 </desc>20085 </attribute>20086 20087 20092 <attribute name="data" type="octet" safearray="yes" readonly="yes"> 20088 20093 <desc> … … 20095 20100 <interface 20096 20101 name="IGuestFileEvent" extends="IGuestSessionEvent" 20097 uuid=" 912f748f-d2f9-4fea-84d2-d36a017cc5f8"20098 wsmap="managed" id="GuestFileEvent"20102 uuid="c8adb7b0-057d-4391-b928-f14b06b710c5" 20103 wsmap="managed" 20099 20104 > 20100 20105 <desc>Base abstract interface for all guest file events.</desc> … … 20153 20158 name="IGuestFileIOEvent" extends="IGuestFileEvent" 20154 20159 uuid="b5191a7c-9536-4ef8-820e-3b0e17e5bbc8" 20155 wsmap="managed" id="OnGuestFileIO"20160 wsmap="managed" 20156 20161 > 20157 20162 <desc> 20158 TODO20163 Base abstract interface for all guest file input/output (IO) events. 20159 20164 </desc> 20160 20165 -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r45426 r45482 78 78 static Utf8Str guestErrorToString(int guestRc); 79 79 bool isReady(void); 80 int readData(uint32_t uHandle, uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, size_t *pcbRead, int *pGuestRc);80 int readData(uint32_t uHandle, uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbRead, int *pGuestRc); 81 81 static HRESULT setErrorExternal(VirtualBoxBase *pInterface, int guestRc); 82 82 int startProcess(int *pGuestRc); … … 84 84 int terminateProcess(int *pGuestRc); 85 85 int waitFor(uint32_t fWaitFlags, ULONG uTimeoutMS, ProcessWaitResult_T &waitResult, int *pGuestRc); 86 int waitForInputNotify(uint32_t uHandle, uint32_t uTimeoutMS, ProcessInputStatus_T *pInputStatus, size_t *pcbProcessed); 87 int waitForOutput(uint32_t uHandle, uint32_t uTimeoutMS, void* pvData, size_t cbData, size_t* pcbRead); 86 int waitForEvents(uint32_t uTimeoutMS, ComSafeArrayIn(VBoxEventType_T, pEvents), VBoxEventType_T *pType, IEvent **ppEvent); 87 int waitForInputNotify(uint32_t uHandle, uint32_t uTimeoutMS, ProcessInputStatus_T *pInputStatus, uint32_t *pcbProcessed); 88 int waitForOutput(uint32_t uHandle, uint32_t uTimeoutMS, void* pvData, size_t cbData, uint32_t *pcbRead); 88 89 int waitForStatusChange(uint32_t fWaitFlags, uint32_t uTimeoutMS, ProcessStatus_T *pProcessStatus, int *pGuestRc); 89 90 int writeData(uint32_t uHandle, uint32_t uFlags, void *pvData, size_t cbData, uint32_t uTimeoutMS, uint32_t *puWritten, int *pGuestRc); -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r45434 r45482 770 770 arrEventTypes.push_back(VBoxEventType_OnGuestFileStateChanged); 771 771 hr = mEventSource->RegisterListener(pListener, ComSafeArrayAsInParam(arrEventTypes), 772 TRUE /* Passive listener */);772 FALSE /* Passive listener */); 773 773 } 774 774 else … … 847 847 } 848 848 } 849 else850 vrc = VERR_COM_UNEXPECTED;851 849 852 850 } while (!fSignalled); -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r45426 r45482 593 593 { 594 594 fireGuestProcessInputNotifyEvent(mEventSource, mSession, this, 595 mData.mPID, inputStatus, 0 /* StdIn */, dataCb.uProcessed);595 mData.mPID, 0 /* StdIn */, dataCb.uProcessed, inputStatus); 596 596 } 597 597 … … 739 739 740 740 fireGuestProcessOutputEvent(mEventSource, mSession, this, 741 mData.mPID, dataCb.uHandle, ComSafeArrayAsInParam(data));741 mData.mPID, dataCb.uHandle, dataCb.cbData, ComSafeArrayAsInParam(data)); 742 742 743 743 LogFlowFuncLeaveRC(vrc); … … 746 746 747 747 int GuestProcess::readData(uint32_t uHandle, uint32_t uSize, uint32_t uTimeoutMS, 748 void *pvData, size_t cbData, size_t *pcbRead, int *pGuestRc)748 void *pvData, size_t cbData, uint32_t *pcbRead, int *pGuestRc) 749 749 { 750 750 LogFlowThisFunc(("uPID=%RU32, uHandle=%RU32, uSize=%RU32, uTimeoutMS=%RU32, pvData=%p, cbData=%RU32, pGuestRc=%p\n", … … 1245 1245 } 1246 1246 1247 int GuestProcess::waitForInputNotify(uint32_t uHandle, uint32_t uTimeoutMS, 1248 ProcessInputStatus_T *pInputStatus, size_t *pcbProcessed) 1249 { 1247 int GuestProcess::waitForEvents(uint32_t uTimeoutMS, ComSafeArrayIn(VBoxEventType_T, pEvents), 1248 VBoxEventType_T *pType, IEvent **ppEvent) 1249 { 1250 AssertPtrReturn(pType, VERR_INVALID_POINTER); 1251 AssertPtrReturn(ppEvent, VERR_INVALID_POINTER); 1252 1250 1253 int vrc; 1251 1254 1252 1255 /** @todo Parameter validation. */ 1256 1257 com::SafeArray <VBoxEventType_T> arrEventTypes(ComSafeArrayInArg(pEvents)); 1253 1258 1254 1259 ComPtr<IEventListener> pListener; 1255 1260 HRESULT hr = mEventSource->CreateListener(pListener.asOutParam()); 1256 1261 if (SUCCEEDED(hr)) 1257 { 1258 com::SafeArray <VBoxEventType_T> eventTypes(1); 1259 eventTypes.push_back(VBoxEventType_OnGuestProcessInputNotify); 1260 hr = mEventSource->RegisterListener(pListener, ComSafeArrayAsInParam(eventTypes), false); 1261 } 1262 hr = mEventSource->RegisterListener(pListener, ComSafeArrayAsInParam(arrEventTypes), 1263 FALSE /* Passive listener */); 1262 1264 else 1263 1265 vrc = VERR_COM_UNEXPECTED; … … 1265 1267 if (SUCCEEDED(hr)) 1266 1268 { 1267 LogFlowThisFunc(("Waiting for guest process input notify event (timeout=%RU32ms, handle=%RU32) ...\n",1268 uTimeoutMS, uHandle));1269 LogFlowThisFunc(("Waiting for guest file event(s) (timeout=%RU32ms, %zu events) ...\n", 1270 uTimeoutMS, arrEventTypes.size())); 1269 1271 1270 1272 vrc = VINF_SUCCESS; … … 1285 1287 } 1286 1288 1287 ComPtr<IEvent> p Event;1288 hr = mEventSource->GetEvent(pListener, cMsWait, p Event.asOutParam());1289 ComPtr<IEvent> pThisEvent; 1290 hr = mEventSource->GetEvent(pListener, cMsWait, pThisEvent.asOutParam()); 1289 1291 if ( SUCCEEDED(hr) 1290 && !p Event.isNull())1292 && !pThisEvent.isNull()) 1291 1293 { 1292 VBoxEventType_T aType;1293 hr = p Event->COMGETTER(Type)(&aType);1294 VBoxEventType_T type; 1295 hr = pThisEvent->COMGETTER(Type)(&type); 1294 1296 ComAssertComRC(hr); 1295 switch (aType) 1297 1298 for (size_t i = 0; i < arrEventTypes.size() && !fSignalled; i++) 1296 1299 { 1297 case VBoxEventType_OnGuestProcessInputNotify:1300 if (type == arrEventTypes[i]) 1298 1301 { 1299 ComPtr<IGuestProcessInputNotifyEvent> pOutputEvent = pEvent; 1300 Assert(!pOutputEvent.isNull()); 1301 1302 ComPtr<IGuestSession> pSession; 1303 pOutputEvent->COMGETTER(Session)(pSession.asOutParam()); 1304 Assert(!pSession.isNull()); 1305 ULONG uSessionID; 1306 hr = pSession->COMGETTER(Id)(&uSessionID); 1307 ComAssertComRC(hr); 1308 if (uSessionID != mSession->getId()) 1309 continue; /* Only the session this process runs in is of interest. */ 1310 1311 ULONG uPID; 1312 hr = pOutputEvent->COMGETTER(Pid)(&uPID); 1313 ComAssertComRC(hr); 1314 if (uPID != mData.mPID) 1315 continue; /* Only the this process is of interest. */ 1316 1317 ULONG uHandleEvent; 1318 hr = pOutputEvent->COMGETTER(Handle)(&uHandleEvent); 1319 ComAssertComRC(hr); 1320 1321 LogFlowThisFunc(("Got output event for process PID=%RU32, handle=%RU32 (session ID=%RU32)\n", 1322 mData.mPID, uHandleEvent, mSession->getId())); 1323 1324 bool fSignal = uHandleEvent == uHandle; 1325 if (!fSignal) 1326 continue; 1327 1328 ProcessInputStatus_T inputStatus; 1329 hr = pOutputEvent->COMGETTER(Status)(&inputStatus); 1330 ComAssertComRC(hr); 1331 1332 ULONG uProcessed; 1333 hr = pOutputEvent->COMGETTER(Processed)(&uProcessed); 1334 ComAssertComRC(hr); 1335 1336 if (pInputStatus) 1337 *pInputStatus = inputStatus; 1338 if (pcbProcessed) 1339 *pcbProcessed = uProcessed; 1340 1341 LogFlowThisFunc(("Input notify event for process PID=%RU32 (session ID=%RU32): %zubytes read\n", 1342 uPID, mSession->getId(), uProcessed)); 1343 1344 fSignalled = true; 1345 break; 1302 switch (type) 1303 { 1304 case VBoxEventType_OnGuestProcessStateChanged: 1305 case VBoxEventType_OnGuestProcessInputNotify: 1306 case VBoxEventType_OnGuestProcessOutput: 1307 { 1308 ComPtr<IGuestProcessEvent> pFileEvent = pThisEvent; 1309 Assert(!pFileEvent.isNull()); 1310 1311 ComPtr<IGuestProcess> pProcess; 1312 pFileEvent->COMGETTER(Process)(pProcess.asOutParam()); 1313 Assert(!pProcess.isNull()); 1314 1315 fSignalled = (pProcess == this); 1316 break; 1317 } 1318 1319 default: 1320 AssertMsgFailed(("Unhandled event %ld\n", type)); 1321 break; 1322 } 1323 1324 if (fSignalled) 1325 { 1326 if (pType) 1327 *pType = type; 1328 if (ppEvent) 1329 pThisEvent.queryInterfaceTo(ppEvent); 1330 if ( type == VBoxEventType_OnGuestProcessStateChanged 1331 && RT_SUCCESS(vrc)) 1332 vrc = VWRN_GSTCTL_OBJECTSTATE_CHANGED; 1333 break; 1334 } 1346 1335 } 1347 1348 default:1349 AssertMsgFailed(("Unhandled event type %ld\n", aType));1350 break;1351 1336 } 1352 1337 } … … 1360 1345 } 1361 1346 1362 mEventSource->UnregisterListener(pListener); 1347 hr = mEventSource->UnregisterListener(pListener); 1348 ComAssertComRC(hr); 1363 1349 } 1364 1350 else … … 1369 1355 } 1370 1356 1357 int GuestProcess::waitForInputNotify(uint32_t uHandle, uint32_t uTimeoutMS, 1358 ProcessInputStatus_T *pInputStatus, uint32_t *pcbProcessed) 1359 { 1360 VBoxEventType_T evtType; 1361 ComPtr<IEvent> pEvent; 1362 com::SafeArray<VBoxEventType_T> eventTypes; 1363 eventTypes.push_back(VBoxEventType_OnGuestProcessInputNotify); 1364 int vrc = waitForEvents(uTimeoutMS, ComSafeArrayAsInParam(eventTypes), 1365 &evtType, pEvent.asOutParam()); 1366 if (vrc == VINF_SUCCESS) /* Can also return VWRN_GSTCTL_OBJECTSTATE_CHANGED. */ 1367 { 1368 Assert(evtType == VBoxEventType_OnGuestProcessInputNotify); 1369 ComPtr<IGuestProcessInputNotifyEvent> pProcessEvent = pEvent; 1370 Assert(!pProcessEvent.isNull()); 1371 1372 if (pInputStatus) 1373 { 1374 HRESULT hr2 = pProcessEvent->COMGETTER(Status)(pInputStatus); 1375 ComAssertComRC(hr2); 1376 } 1377 if (pcbProcessed) 1378 { 1379 HRESULT hr2 = pProcessEvent->COMGETTER(Processed)((ULONG*)pcbProcessed); 1380 ComAssertComRC(hr2); 1381 } 1382 } 1383 1384 LogFlowFuncLeaveRC(vrc); 1385 return vrc; 1386 } 1387 1371 1388 int GuestProcess::waitForOutput(uint32_t uHandle, uint32_t uTimeoutMS, 1372 void *pvData, size_t cbData, size_t *pcbRead) 1373 { 1374 int vrc; 1375 1376 /** @todo Parameter validation. */ 1377 1378 ComPtr<IEventListener> pListener; 1379 HRESULT hr = mEventSource->CreateListener(pListener.asOutParam()); 1380 if (SUCCEEDED(hr)) 1381 { 1382 com::SafeArray <VBoxEventType_T> eventTypes(1); 1389 void *pvData, size_t cbData, uint32_t *pcbRead) 1390 { 1391 VBoxEventType_T evtType; 1392 ComPtr<IEvent> pEvent; 1393 com::SafeArray<VBoxEventType_T> eventTypes; 1394 1395 int vrc = VINF_SUCCESS; 1396 1397 try 1398 { 1383 1399 eventTypes.push_back(VBoxEventType_OnGuestProcessOutput); 1384 hr = mEventSource->RegisterListener(pListener, ComSafeArrayAsInParam(eventTypes), false); 1385 } 1386 else 1387 vrc = VERR_COM_UNEXPECTED; 1388 1389 if (SUCCEEDED(hr)) 1390 { 1391 LogFlowThisFunc(("Waiting for guest process output event (timeout=%RU32ms, handle=%RU32) ...\n", 1392 uTimeoutMS, uHandle)); 1393 1394 vrc = VINF_SUCCESS; 1395 1396 uint64_t u64Started = RTTimeMilliTS(); 1397 bool fSignalled = false; 1398 do 1399 { 1400 unsigned cMsWait; 1401 if (uTimeoutMS == RT_INDEFINITE_WAIT) 1402 cMsWait = 1000; 1403 else 1400 } 1401 catch (std::bad_alloc) 1402 { 1403 vrc = VERR_NO_MEMORY; 1404 } 1405 1406 if (RT_FAILURE(vrc)) 1407 return vrc; 1408 1409 do 1410 { 1411 vrc = waitForEvents(uTimeoutMS, ComSafeArrayAsInParam(eventTypes), 1412 &evtType, pEvent.asOutParam()); 1413 if (vrc == VINF_SUCCESS) /* Can also return VWRN_GSTCTL_OBJECTSTATE_CHANGED. */ 1414 { 1415 Assert(evtType == VBoxEventType_OnGuestProcessOutput); 1416 ComPtr<IGuestProcessOutputEvent> pProcessEvent = pEvent; 1417 Assert(!pProcessEvent.isNull()); 1418 1419 ULONG uHandleEvent; 1420 HRESULT hr = pProcessEvent->COMGETTER(Handle)(&uHandleEvent); 1421 if (uHandleEvent == uHandle) 1404 1422 { 1405 uint64_t cMsElapsed = RTTimeMilliTS() - u64Started; 1406 if (cMsElapsed >= uTimeoutMS) 1407 break; /* timed out */ 1408 cMsWait = RT_MIN(1000, uTimeoutMS - (uint32_t)cMsElapsed); 1423 if (pvData) 1424 { 1425 com::SafeArray <BYTE> data; 1426 hr = pProcessEvent->COMGETTER(Data)(ComSafeArrayAsOutParam(data)); 1427 ComAssertComRC(hr); 1428 size_t cbRead = data.size(); 1429 if ( cbRead 1430 && cbRead <= cbData) 1431 { 1432 memcpy(pvData, data.raw(), data.size()); 1433 } 1434 else 1435 vrc = VERR_BUFFER_OVERFLOW; 1436 } 1437 if (pcbRead) 1438 { 1439 hr = pProcessEvent->COMGETTER(Processed)((ULONG*)pcbRead); 1440 ComAssertComRC(hr); 1441 } 1442 1443 break; 1409 1444 } 1410 1411 ComPtr<IEvent> pEvent; 1412 hr = mEventSource->GetEvent(pListener, cMsWait, pEvent.asOutParam()); 1413 if ( SUCCEEDED(hr) 1414 && !pEvent.isNull()) 1415 { 1416 VBoxEventType_T aType; 1417 hr = pEvent->COMGETTER(Type)(&aType); 1418 ComAssertComRC(hr); 1419 switch (aType) 1420 { 1421 case VBoxEventType_OnGuestProcessOutput: 1422 { 1423 ComPtr<IGuestProcessOutputEvent> pOutputEvent = pEvent; 1424 Assert(!pOutputEvent.isNull()); 1425 1426 ComPtr<IGuestSession> pSession; 1427 pOutputEvent->COMGETTER(Session)(pSession.asOutParam()); 1428 Assert(!pSession.isNull()); 1429 ULONG uSessionID; 1430 hr = pSession->COMGETTER(Id)(&uSessionID); 1431 ComAssertComRC(hr); 1432 if (uSessionID != mSession->getId()) 1433 continue; /* Only the session this process runs in is of interest. */ 1434 1435 ULONG uPID; 1436 hr = pOutputEvent->COMGETTER(Pid)(&uPID); 1437 ComAssertComRC(hr); 1438 if (uPID != mData.mPID) 1439 continue; /* Only the this process is of interest. */ 1440 1441 ULONG uHandleEvent; 1442 hr = pOutputEvent->COMGETTER(Handle)(&uHandleEvent); 1443 ComAssertComRC(hr); 1444 1445 LogFlowThisFunc(("Got output event for process PID=%RU32, handle=%RU32 (session ID=%RU32): %ld\n", 1446 mData.mPID, uHandleEvent, mSession->getId())); 1447 1448 bool fSignal = uHandleEvent == uHandle; 1449 if (!fSignal) 1450 continue; 1451 1452 com::SafeArray <BYTE> data; 1453 hr = pOutputEvent->COMGETTER(Data)(ComSafeArrayAsOutParam(data)); 1454 ComAssertComRC(hr); 1455 1456 size_t cbRead = data.size(); 1457 1458 if (pvData) 1459 { 1460 if (cbRead < cbData) 1461 cbData = cbRead; 1462 memcpy(pvData, data.raw(), cbData); 1463 } 1464 1465 if (pcbRead) 1466 *pcbRead = cbRead; 1467 1468 LogFlowThisFunc(("Output event for process PID=%RU32 (session ID=%RU32): %zubytes read\n", 1469 uPID, mSession->getId(), cbRead)); 1470 1471 fSignalled = true; 1472 break; 1473 } 1474 1475 default: 1476 AssertMsgFailed(("Unhandled event type %ld\n", aType)); 1477 break; 1478 } 1479 } 1480 1481 } while (!fSignalled); 1482 1483 if ( RT_SUCCESS(vrc) 1484 && !fSignalled) 1485 { 1486 vrc = VERR_TIMEOUT; 1487 } 1488 1489 mEventSource->UnregisterListener(pListener); 1490 } 1491 else 1492 vrc = VERR_COM_UNEXPECTED; 1445 } 1446 1447 } while (RT_SUCCESS(vrc)); 1493 1448 1494 1449 LogFlowFuncLeaveRC(vrc); … … 1499 1454 ProcessStatus_T *pProcessStatus, int *pGuestRc) 1500 1455 { 1501 int vrc; 1502 1503 ComPtr<IEventListener> pListener; 1504 HRESULT hr = mEventSource->CreateListener(pListener.asOutParam()); 1505 if (SUCCEEDED(hr)) 1506 { 1507 com::SafeArray <VBoxEventType_T> eventTypes(1); 1508 eventTypes.push_back(VBoxEventType_OnGuestProcessStateChanged); 1509 hr = mEventSource->RegisterListener(pListener, ComSafeArrayAsInParam(eventTypes), false); 1510 } 1511 else 1512 vrc = VERR_COM_UNEXPECTED; 1513 1514 if (SUCCEEDED(hr)) 1515 { 1516 LogFlowThisFunc(("Waiting for guest process state changed event (timeout=%RU32ms, flags=%x) ...\n", 1517 uTimeoutMS, fWaitFlags)); 1518 1519 vrc = VINF_SUCCESS; 1520 1521 uint64_t u64Started = RTTimeMilliTS(); 1522 bool fSignalled = false; 1523 do 1524 { 1525 unsigned cMsWait; 1526 if (uTimeoutMS == RT_INDEFINITE_WAIT) 1527 cMsWait = 1000; 1528 else 1529 { 1530 uint64_t cMsElapsed = RTTimeMilliTS() - u64Started; 1531 if (cMsElapsed >= uTimeoutMS) 1532 break; /* timed out */ 1533 cMsWait = RT_MIN(1000, uTimeoutMS - (uint32_t)cMsElapsed); 1534 } 1535 1536 ComPtr<IEvent> pEvent; 1537 hr = mEventSource->GetEvent(pListener, cMsWait, pEvent.asOutParam()); 1538 if ( SUCCEEDED(hr) 1539 && !pEvent.isNull()) 1540 { 1541 VBoxEventType_T aType; 1542 hr = pEvent->COMGETTER(Type)(&aType); 1543 ComAssertComRC(hr); 1544 switch (aType) 1545 { 1546 case VBoxEventType_OnGuestProcessStateChanged: 1547 { 1548 ComPtr<IGuestProcessStateChangedEvent> pChangedEvent = pEvent; 1549 Assert(!pChangedEvent.isNull()); 1550 1551 ComPtr<IGuestSession> pSession; 1552 pChangedEvent->COMGETTER(Session)(pSession.asOutParam()); 1553 Assert(!pSession.isNull()); 1554 ULONG uSessionID; 1555 hr = pSession->COMGETTER(Id)(&uSessionID); 1556 ComAssertComRC(hr); 1557 if (uSessionID != mSession->getId()) 1558 continue; /* Only the session this process runs in is of interest. */ 1559 1560 ULONG uPID; 1561 hr = pChangedEvent->COMGETTER(Pid)(&uPID); 1562 ComAssertComRC(hr); 1563 if (uPID != mData.mPID) 1564 continue; /* Only the this process is of interest. */ 1565 1566 ProcessStatus_T processStatus; 1567 pChangedEvent->COMGETTER(Status)(&processStatus); 1568 if (pProcessStatus) 1569 *pProcessStatus = processStatus; 1570 1571 LogFlowThisFunc(("Got status changed event for process PID=%RU32 (session ID=%RU32): %ld\n", 1572 mData.mPID, mSession->getId(), processStatus)); 1573 1574 bool fSignal = false; 1575 if (fWaitFlags) 1576 { 1577 switch (processStatus) 1578 { 1579 case ProcessStatus_Started: 1580 fSignal = (fWaitFlags & ProcessWaitForFlag_Start); 1581 break; 1582 1583 default: 1584 fSignal = true; 1585 break; 1586 } 1587 } 1588 else 1589 fSignal = true; 1590 1591 if (!fSignal) 1592 continue; 1593 1594 ComPtr<IGuestErrorInfo> errorInfo; 1595 hr = pChangedEvent->COMGETTER(Error)(errorInfo.asOutParam()); 1596 ComAssertComRC(hr); 1597 1598 LONG lGuestRc; 1599 hr = errorInfo->COMGETTER(Result)(&lGuestRc); 1600 ComAssertComRC(hr); 1601 if (RT_FAILURE((int)lGuestRc)) 1602 vrc = VERR_GSTCTL_GUEST_ERROR; 1603 if (pGuestRc) 1604 *pGuestRc = (int)lGuestRc; 1605 1606 LogFlowThisFunc(("Status changed event for process PID=%RU32 (session ID=%RU32): %ld (%Rrc)\n", 1607 uPID, mSession->getId(), processStatus, 1608 RT_SUCCESS((int)lGuestRc) ? VINF_SUCCESS : (int)lGuestRc)); 1609 1610 fSignalled = true; 1611 break; 1612 } 1613 1614 default: 1615 AssertMsgFailed(("Unhandled event type %ld\n", aType)); 1616 break; 1617 } 1618 } 1619 1620 } while (!fSignalled); 1621 1622 if ( RT_SUCCESS(vrc) 1623 && !fSignalled) 1624 { 1625 vrc = VERR_TIMEOUT; 1626 } 1627 1628 mEventSource->UnregisterListener(pListener); 1629 } 1630 else 1631 vrc = VERR_COM_UNEXPECTED; 1456 /* All pointers are optional. */ 1457 1458 VBoxEventType_T evtType; 1459 ComPtr<IEvent> pEvent; 1460 com::SafeArray<VBoxEventType_T> eventTypes(1); 1461 eventTypes.push_back(VBoxEventType_OnGuestProcessStateChanged); 1462 int vrc = waitForEvents(uTimeoutMS, ComSafeArrayAsInParam(eventTypes), 1463 &evtType, pEvent.asOutParam()); 1464 if (RT_SUCCESS(vrc)) /* Includes VWRN_GSTCTL_OBJECTSTATE_CHANGED. */ 1465 { 1466 Assert(evtType == VBoxEventType_OnGuestProcessStateChanged); 1467 ComPtr<IGuestProcessStateChangedEvent> pProcessEvent = pEvent; 1468 Assert(!pProcessEvent.isNull()); 1469 1470 HRESULT hr; 1471 if (pProcessStatus) 1472 { 1473 hr = pProcessEvent->COMGETTER(Status)(pProcessStatus); 1474 ComAssertComRC(hr); 1475 } 1476 1477 ComPtr<IGuestErrorInfo> errorInfo; 1478 hr = pProcessEvent->COMGETTER(Error)(errorInfo.asOutParam()); 1479 ComAssertComRC(hr); 1480 1481 LONG lGuestRc; 1482 hr = errorInfo->COMGETTER(Result)(&lGuestRc); 1483 ComAssertComRC(hr); 1484 if (RT_FAILURE((int)lGuestRc)) 1485 vrc = VERR_GSTCTL_GUEST_ERROR; 1486 1487 if (pGuestRc) 1488 *pGuestRc = (int)lGuestRc; 1489 } 1632 1490 1633 1491 LogFlowFuncLeaveRC(vrc); … … 1675 1533 1676 1534 ProcessInputStatus_T inputStatus; 1677 size_t cbProcessed;1535 uint32_t cbProcessed; 1678 1536 vrc = waitForInputNotify(uHandle, uTimeoutMS, &inputStatus, &cbProcessed); 1679 1537 if (RT_SUCCESS(vrc)) … … 1711 1569 HRESULT hr = S_OK; 1712 1570 1713 size_t cbRead; int guestRc;1571 uint32_t cbRead; int guestRc; 1714 1572 int vrc = readData(aHandle, aToRead, aTimeoutMS, data.raw(), aToRead, &cbRead, &guestRc); 1715 1573 if (RT_SUCCESS(vrc)) … … 2079 1937 2080 1938 BYTE byBuf[_64K]; 2081 size_t cbRead;1939 uint32_t cbRead; 2082 1940 2083 1941 bool fHandleStdOut = false; -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r45078 r45482 695 695 RTThreadSleep(1); /* Optional, don't check rc. */ 696 696 697 size_t cbRead;697 uint32_t cbRead; 698 698 rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf), 699 699 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
Note:
See TracChangeset
for help on using the changeset viewer.