Changeset 31456 in vbox
- Timestamp:
- Aug 8, 2010 1:46:41 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxHDD.h
r31185 r31456 1141 1141 1142 1142 /** 1143 * Receive data from a socket - not blocking. 1144 * 1145 * @return iprt status code. 1146 * @param Sock Socket descriptor. 1147 * @param pvBuffer Where to put the data we read. 1148 * @param cbBuffer Read buffer size. 1149 * @param pcbRead Number of bytes read. 1150 */ 1151 DECLR3CALLBACKMEMBER(int, pfnReadNB, (VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead)); 1152 1153 /** 1154 * Send data to a socket - not blocking. 1155 * 1156 * @return iprt status code. 1157 * @param Sock Socket descriptor. 1158 * @param pvBuffer Buffer to write data to socket. 1159 * @param cbBuffer How much to write. 1160 * @param pcbWritten Number of bytes written. 1161 */ 1162 DECLR3CALLBACKMEMBER(int, pfnWriteNB, (VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer, size_t *pcbWritten)); 1163 1164 /** 1165 * Send data from scatter/gather buffer to a socket - not blocking. 1166 * 1167 * @return iprt status code. 1168 * @param Sock Socket descriptor. 1169 * @param pSgBuf Scatter/gather buffer to write data to socket. 1170 * @param pcbWritten Number of bytes written. 1171 */ 1172 DECLR3CALLBACKMEMBER(int, pfnSgWriteNB, (VDSOCKET Sock, PRTSGBUF pSgBuf, size_t *pcbWritten)); 1173 1174 /** 1143 1175 * Flush socket write buffers. 1144 1176 * … … 1182 1214 * @retval VERR_INTERRUPTED if the thread was woken up by a pfnPoke call. 1183 1215 * @param Sock Socket descriptor. 1216 * @param fEvents Mask of events to wait for. 1184 1217 * @param pfEvents Where to store the received events. 1185 1218 * @param cMillies Number of milliseconds to wait for the socket. 1186 1219 * Use RT_INDEFINITE_WAIT to wait for ever. 1187 1220 */ 1188 DECLR3CALLBACKMEMBER(int, pfnSelectOneEx, (VDSOCKET Sock, uint32_t *pfEvents, RTMSINTERVAL cMillies)); 1221 DECLR3CALLBACKMEMBER(int, pfnSelectOneEx, (VDSOCKET Sock, uint32_t fEvents, 1222 uint32_t *pfEvents, RTMSINTERVAL cMillies)); 1189 1223 1190 1224 /** -
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r31186 r31456 910 910 911 911 /** @copydoc VDINTERFACETCPNET::pfnSelectOneEx */ 912 static DECLCALLBACK(int) drvvdINIPSelectOneEx(VDSOCKET Sock, uint32_t *pfEvents, RTMSINTERVAL cMillies)912 static DECLCALLBACK(int) drvvdINIPSelectOneEx(VDSOCKET Sock, uint32_t fEvents, uint32_t *pfEvents, RTMSINTERVAL cMillies) 913 913 { 914 914 AssertMsgFailed(("Not supported!\n")); … … 947 947 /** Flag whether the thread is waiting in the select call. */ 948 948 volatile bool fWaiting; 949 /** Old event mask. */ 950 uint32_t fEventsOld; 949 951 } VDSOCKETINT, *PVDSOCKETINT; 950 952 … … 1050 1052 if (pSockInt->hPollSet != NIL_RTPOLLSET) 1051 1053 { 1054 pSockInt->fEventsOld = RTPOLL_EVT_READ | RTPOLL_EVT_WRITE | RTPOLL_EVT_ERROR; 1055 1052 1056 rc = RTPollSetAddSocket(pSockInt->hPollSet, pSockInt->hSocket, 1053 RTPOLL_EVT_READ | /*RTPOLL_EVT_WRITE |*/ RTPOLL_EVT_ERROR, 1054 VDSOCKET_POLL_ID_SOCKET); 1057 pSockInt->fEventsOld, VDSOCKET_POLL_ID_SOCKET); 1055 1058 1056 1059 if (RT_SUCCESS(rc)) … … 1122 1125 } 1123 1126 1127 /** @copydoc VDINTERFACETCPNET::pfnReadNB */ 1128 static DECLCALLBACK(int) drvvdTcpReadNB(VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead) 1129 { 1130 PVDSOCKETINT pSockInt = (PVDSOCKETINT)Sock; 1131 1132 return RTTcpReadNB(pSockInt->hSocket, pvBuffer, cbBuffer, pcbRead); 1133 } 1134 1135 /** @copydoc VDINTERFACETCPNET::pfnWriteNB */ 1136 static DECLCALLBACK(int) drvvdTcpWriteNB(VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer, size_t *pcbWritten) 1137 { 1138 PVDSOCKETINT pSockInt = (PVDSOCKETINT)Sock; 1139 1140 return RTTcpWriteNB(pSockInt->hSocket, pvBuffer, cbBuffer, pcbWritten); 1141 } 1142 1143 /** @copydoc VDINTERFACETCPNET::pfnSgWriteNB */ 1144 static DECLCALLBACK(int) drvvdTcpSgWriteNB(VDSOCKET Sock, PRTSGBUF pSgBuf, size_t *pcbWritten) 1145 { 1146 PVDSOCKETINT pSockInt = (PVDSOCKETINT)Sock; 1147 1148 return RTTcpSgWriteNB(pSockInt->hSocket, pSgBuf, pcbWritten); 1149 } 1150 1124 1151 /** @copydoc VDINTERFACETCPNET::pfnFlush */ 1125 1152 static DECLCALLBACK(int) drvvdTcpFlush(VDSOCKET Sock) … … 1155 1182 1156 1183 /** @copydoc VDINTERFACETCPNET::pfnSelectOneEx */ 1157 static DECLCALLBACK(int) drvvdTcpSelectOneEx(VDSOCKET Sock, uint32_t *pfEvents, RTMSINTERVAL cMillies) 1184 static DECLCALLBACK(int) drvvdTcpSelectOneEx(VDSOCKET Sock, uint32_t fEvents, 1185 uint32_t *pfEvents, RTMSINTERVAL cMillies) 1158 1186 { 1159 1187 int rc = VINF_SUCCESS; 1160 1188 uint32_t id = 0; 1161 uint32_t fEvents = 0;1189 uint32_t fEventsRecv = 0; 1162 1190 PVDSOCKETINT pSockInt = (PVDSOCKETINT)Sock; 1163 1191 1164 1192 *pfEvents = 0; 1193 1194 if (pSockInt->fEventsOld != fEvents) 1195 { 1196 uint32_t fPollEvents = 0; 1197 1198 if (fEvents & VD_INTERFACETCPNET_EVT_READ) 1199 fPollEvents |= RTPOLL_EVT_READ; 1200 if (fEvents & VD_INTERFACETCPNET_EVT_WRITE) 1201 fPollEvents |= RTPOLL_EVT_WRITE; 1202 if (fEvents & VD_INTERFACETCPNET_EVT_ERROR) 1203 fPollEvents |= RTPOLL_EVT_ERROR; 1204 1205 rc = RTPollSetEventsChange(pSockInt->hPollSet, VDSOCKET_POLL_ID_SOCKET, fPollEvents); 1206 if (RT_FAILURE(rc)) 1207 return rc; 1208 1209 pSockInt->fEventsOld = fEvents; 1210 } 1165 1211 1166 1212 ASMAtomicXchgBool(&pSockInt->fWaiting, true); … … 1171 1217 } 1172 1218 1173 rc = RTPoll(pSockInt->hPollSet, cMillies, &fEvents , &id);1219 rc = RTPoll(pSockInt->hPollSet, cMillies, &fEventsRecv, &id); 1174 1220 Assert(RT_SUCCESS(rc) || rc == VERR_TIMEOUT); 1175 1221 … … 1180 1226 if (id == VDSOCKET_POLL_ID_SOCKET) 1181 1227 { 1182 fEvents &= RTPOLL_EVT_VALID_MASK;1183 1184 if (fEvents & RTPOLL_EVT_READ)1228 fEventsRecv &= RTPOLL_EVT_VALID_MASK; 1229 1230 if (fEventsRecv & RTPOLL_EVT_READ) 1185 1231 *pfEvents |= VD_INTERFACETCPNET_EVT_READ; 1186 if (fEvents & RTPOLL_EVT_WRITE)1232 if (fEventsRecv & RTPOLL_EVT_WRITE) 1187 1233 *pfEvents |= VD_INTERFACETCPNET_EVT_WRITE; 1188 if (fEvents & RTPOLL_EVT_ERROR)1234 if (fEventsRecv & RTPOLL_EVT_ERROR) 1189 1235 *pfEvents |= VD_INTERFACETCPNET_EVT_ERROR; 1190 1236 } … … 1838 1884 pThis->VDITcpNetCallbacks.pfnWrite = drvvdTcpWrite; 1839 1885 pThis->VDITcpNetCallbacks.pfnSgWrite = drvvdTcpSgWrite; 1886 pThis->VDITcpNetCallbacks.pfnReadNB = drvvdTcpReadNB; 1887 pThis->VDITcpNetCallbacks.pfnWriteNB = drvvdTcpWriteNB; 1888 pThis->VDITcpNetCallbacks.pfnSgWriteNB = drvvdTcpSgWriteNB; 1840 1889 pThis->VDITcpNetCallbacks.pfnFlush = drvvdTcpFlush; 1841 1890 pThis->VDITcpNetCallbacks.pfnSetSendCoalescing = drvvdTcpSetSendCoalescing; -
trunk/src/VBox/Devices/Storage/ISCSIHDDCore.cpp
r31243 r31456 476 476 /** Config interface callback table. */ 477 477 PVDINTERFACECONFIG pInterfaceConfigCallbacks; 478 /** I/O interface. */ 479 PVDINTERFACE pInterfaceIo; 480 /** I/O interface callback table. */ 481 PVDINTERFACEIO pInterfaceIoCallbacks; 478 482 /** Image open flags. */ 479 483 unsigned uOpenFlags; … … 540 544 /** Flag whether extended select is supported. */ 541 545 bool fExtendedSelectSupported; 546 /** Padding used for aligning the PDUs. */ 547 uint8_t aPadding[4]; 548 /** Socket events to poll for. */ 549 uint32_t fPollEvents; 542 550 } ISCSIIMAGE, *PISCSIIMAGE; 543 551 … … 588 596 static int iscsiSendPDU(PISCSIIMAGE pImage, PISCSIREQ paReq, uint32_t cnReq, uint32_t uFlags); 589 597 static int iscsiRecvPDU(PISCSIIMAGE pImage, uint32_t itt, PISCSIRES paRes, uint32_t cnRes, bool fSelect); 590 static int drvISCSIValidatePDU(PISCSIRES paRes, uint32_t cnRes);598 static int iscsiValidatePDU(PISCSIRES paRes, uint32_t cnRes); 591 599 static int iscsiTextAddKeyValue(uint8_t *pbBuf, size_t cbBuf, size_t *pcbBufCurr, const char *pcszKey, const char *pcszValue, size_t cbValue); 592 600 static int iscsiTextGetKeyValue(const uint8_t *pbBuf, size_t cbBuf, const char *pcszKey, const char **ppcszValue); … … 1881 1889 /* Check whether the received PDU is valid, and update the internal state of 1882 1890 * the iSCSI connection/session. */ 1883 rc = drvISCSIValidatePDU(&aResBuf, 1);1891 rc = iscsiValidatePDU(&aResBuf, 1); 1884 1892 if (RT_FAILURE(rc)) 1885 1893 continue; … … 2002 2010 * @param cnRes Number of valid iSCSI response sections in the array. 2003 2011 */ 2004 static int drvISCSIValidatePDU(PISCSIRES paRes, uint32_t cnRes)2012 static int iscsiValidatePDU(PISCSIRES paRes, uint32_t cnRes) 2005 2013 { 2006 2014 const uint32_t *pcrgResBHS; … … 2373 2381 * Internal. - Wrapper around the extended select callback of the net interface. 2374 2382 */ 2375 DECLINLINE(int) iscsiIoThreadWait(PISCSIIMAGE pImage, RTMSINTERVAL cMillies, uint32_t *pfEvents)2376 { 2377 return pImage->pInterfaceNetCallbacks->pfnSelectOneEx(pImage->Socket, pfEvents, cMillies);2383 DECLINLINE(int) iscsiIoThreadWait(PISCSIIMAGE pImage, RTMSINTERVAL cMillies, uint32_t fEvents, uint32_t *pfEvents) 2384 { 2385 return pImage->pInterfaceNetCallbacks->pfnSelectOneEx(pImage->Socket, fEvents, pfEvents, cMillies); 2378 2386 } 2379 2387 … … 2472 2480 PISCSIIMAGE pImage = (PISCSIIMAGE)pvUser; 2473 2481 2482 /* Initialise the initial event mask. */ 2483 pImage->fPollEvents = VD_INTERFACETCPNET_EVT_READ | VD_INTERFACETCPNET_EVT_ERROR; 2484 2474 2485 while (pImage->fRunning) 2475 2486 { … … 2478 2489 2479 2490 /* Wait for work or for data from the target. */ 2480 rc = iscsiIoThreadWait(pImage, RT_INDEFINITE_WAIT, &fEvents);2491 rc = iscsiIoThreadWait(pImage, RT_INDEFINITE_WAIT, pImage->fPollEvents, &fEvents); 2481 2492 if (rc == VERR_INTERRUPTED) 2482 2493 { … … 2764 2775 rc = iscsiError(pImage, VERR_VD_ISCSI_UNKNOWN_INTERFACE, 2765 2776 RT_SRC_POS, N_("iSCSI: configuration interface missing")); 2777 goto out; 2778 } 2779 2780 /* Get I/O interface. */ 2781 pImage->pInterfaceIo = VDInterfaceGet(pImage->pVDIfsImage, VDINTERFACETYPE_IO); 2782 if (pImage->pInterfaceIo) 2783 pImage->pInterfaceIoCallbacks = VDGetInterfaceIO(pImage->pInterfaceIo); 2784 else 2785 { 2786 rc = iscsiError(pImage, VERR_VD_ISCSI_UNKNOWN_INTERFACE, 2787 RT_SRC_POS, N_("iSCSI: I/O interface missing")); 2766 2788 goto out; 2767 2789 } … … 4197 4219 4198 4220 return rc; 4221 } 4222 4223 static bool iscsiIsAsyncIOSupported(void *pvBackendData) 4224 { 4225 return false; 4226 } 4227 4228 static int iscsiAsyncRead(void *pvBackendData, uint64_t uOffset, size_t cbRead, 4229 PVDIOCTX pIoCtx, size_t *pcbActuallyRead) 4230 { 4231 PISCSIIMAGE pImage = (PISCSIIMAGE)pvBackendData; 4232 int rc = VERR_NOT_SUPPORTED; 4233 4234 LogFlowFunc(("pBackendData=%p uOffset=%#llx pIoCtx=%#p cbRead=%u pcbActuallyRead=%p\n", 4235 pvBackendData, uOffset, pIoCtx, cbRead, pcbActuallyRead)); 4236 4237 if (uOffset + cbRead > pImage->cbSize) 4238 return VERR_INVALID_PARAMETER; 4239 4240 LogFlowFunc(("returns rc=%Rrc\n", rc)); 4241 return rc; 4242 } 4243 4244 static int iscsiAsyncWrite(void *pvBackendData, uint64_t uOffset, size_t cbWrite, 4245 PVDIOCTX pIoCtx, 4246 size_t *pcbWriteProcess, size_t *pcbPreRead, 4247 size_t *pcbPostRead, unsigned fWrite) 4248 { 4249 PISCSIIMAGE pImage = (PISCSIIMAGE)pvBackendData; 4250 int rc = VERR_NOT_SUPPORTED; 4251 4252 LogFlowFunc(("pBackendData=%p uOffset=%llu pIoCtx=%#p cbWrite=%u pcbWriteProcess=%p pcbPreRead=%p pcbPostRead=%p fWrite=%u\n", 4253 pvBackendData, uOffset, pIoCtx, cbWrite, pcbWriteProcess, pcbPreRead, pcbPostRead, fWrite)); 4254 4255 AssertPtr(pImage); 4256 Assert(uOffset % 512 == 0); 4257 Assert(cbWrite % 512 == 0); 4258 4259 if (uOffset + cbWrite > pImage->cbSize) 4260 return VERR_INVALID_PARAMETER; 4261 4262 return rc; 4263 } 4264 4265 static int iscsiAsyncFlush(void *pvBackendData, PVDIOCTX pIoCtx) 4266 { 4267 PISCSIIMAGE pImage = (PISCSIIMAGE)pvBackendData; 4268 4269 return VERR_NOT_SUPPORTED; 4199 4270 } 4200 4271 … … 4283 4354 iscsiSetParentFilename, 4284 4355 /* pfnIsAsyncIOSupported */ 4285 NULL,4356 iscsiIsAsyncIOSupported, 4286 4357 /* pfnAsyncRead */ 4287 NULL,4358 iscsiAsyncRead, 4288 4359 /* pfnAsyncWrite */ 4289 NULL,4360 iscsiAsyncWrite, 4290 4361 /* pfnAsyncFlush */ 4291 NULL,4362 iscsiAsyncFlush, 4292 4363 /* pfnComposeLocation */ 4293 4364 iscsiComposeLocation,
Note:
See TracChangeset
for help on using the changeset viewer.