Changeset 6633 in vbox
- Timestamp:
- Jan 30, 2008 9:40:33 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VM.cpp
r6475 r6633 214 214 pVM->vm.s.ppAtErrorNext = &pVM->vm.s.pAtError; 215 215 pVM->vm.s.ppAtRuntimeErrorNext = &pVM->vm.s.pAtRuntimeError; 216 pVM->vm.s.enmHaltMethod = VMHALTMETHOD_1; 216 217 rc = RTSemEventCreate(&pVM->vm.s.EventSemWait); 217 AssertRCReturn(rc, rc); 218 219 /* 220 * Initialize STAM. 221 */ 222 rc = STAMR3Init(pVM); 223 if (VBOX_SUCCESS(rc)) 218 if (RT_SUCCESS(rc)) 224 219 { 225 220 /* 226 * Create the EMT thread, it will start up and wait for requests to process.221 * Initialize STAM. 227 222 */ 228 VMEMULATIONTHREADARGS Args; 229 Args.pVM = pVM; 230 rc = RTThreadCreate(&pVM->ThreadEMT, vmR3EmulationThread, &Args, _1M, 231 RTTHREADTYPE_EMULATION, RTTHREADFLAGS_WAITABLE, "EMT"); 223 rc = STAMR3Init(pVM); 232 224 if (VBOX_SUCCESS(rc)) 233 225 { 234 226 /* 235 * Issue a VM Create request and wait for it to complete.227 * Create the EMT thread, it will start up and wait for requests to process. 236 228 */ 237 PVMREQ pReq; 238 rc = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3Create, 5, 239 pVM, pfnVMAtError, pvUserVM, pfnCFGMConstructor, pvUserCFGM); 229 VMEMULATIONTHREADARGS Args; 230 Args.pVM = pVM; 231 rc = RTThreadCreate(&pVM->ThreadEMT, vmR3EmulationThread, &Args, _1M, 232 RTTHREADTYPE_EMULATION, RTTHREADFLAGS_WAITABLE, "EMT"); 240 233 if (VBOX_SUCCESS(rc)) 241 234 { 242 rc = pReq->iStatus; 243 VMR3ReqFree(pReq); 235 /* 236 * Issue a VM Create request and wait for it to complete. 237 */ 238 PVMREQ pReq; 239 rc = VMR3ReqCall(pVM, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3Create, 5, 240 pVM, pfnVMAtError, pvUserVM, pfnCFGMConstructor, pvUserCFGM); 244 241 if (VBOX_SUCCESS(rc)) 245 242 { 246 *ppVM = pVM; 247 LogFlow(("VMR3Create: returns VINF_SUCCESS *ppVM=%p\n", pVM)); 248 return VINF_SUCCESS; 243 rc = pReq->iStatus; 244 VMR3ReqFree(pReq); 245 if (VBOX_SUCCESS(rc)) 246 { 247 *ppVM = pVM; 248 LogFlow(("VMR3Create: returns VINF_SUCCESS *ppVM=%p\n", pVM)); 249 return VINF_SUCCESS; 250 } 251 252 NoDmik(AssertMsgFailed(("vmR3Create failed rc=%Vrc\n", rc))); 249 253 } 250 251 NoDmik(AssertMsgFailed(("vmR3Create failed rc=%Vrc\n", rc))); 254 else 255 AssertMsgFailed(("VMR3ReqCall failed rc=%Vrc\n", rc)); 256 257 /* 258 * An error occurred during VM creation. Set the error message directly 259 * using the initial callback, as the callback list doesn't exist yet. 260 */ 261 const char *pszError = NULL; 262 switch (rc) 263 { 264 case VERR_VMX_IN_VMX_ROOT_MODE: 265 #ifdef RT_OS_LINUX 266 pszError = N_("VirtualBox can't operate in VMX root mode. " 267 "Please disable the KVM kernel extension, recompile your kernel and reboot"); 268 #else 269 pszError = N_("VirtualBox can't operate in VMX root mode"); 270 #endif 271 break; 272 default: 273 /* XXX check if there was already an error message set! */ 274 pszError = N_("Unknown error creating VM"); 275 NoDmik(AssertMsgFailed(("Add error message for rc=%d (%Vrc)\n", rc, rc))); 276 } 277 if (pszError) 278 vmR3CallVMAtError(pfnVMAtError, pvUserVM, rc, RT_SRC_POS, pszError, rc); 279 280 /* Forcefully terminate the emulation thread. */ 281 VM_FF_SET(pVM, VM_FF_TERMINATE); 282 VMR3NotifyFF(pVM, false); 283 RTThreadWait(pVM->ThreadEMT, 1000, NULL); 252 284 } 253 else 254 AssertMsgFailed(("VMR3ReqCall failed rc=%Vrc\n", rc)); 255 256 /* 257 * An error occurred during VM creation. Set the error message directly 258 * using the initial callback, as the callback list doesn't exist yet. 259 */ 260 const char *pszError = NULL; 261 switch (rc) 262 { 263 case VERR_VMX_IN_VMX_ROOT_MODE: 264 #ifdef RT_OS_LINUX 265 pszError = N_("VirtualBox can't operate in VMX root mode. " 266 "Please disable the KVM kernel extension, recompile your kernel and reboot"); 267 #else 268 pszError = N_("VirtualBox can't operate in VMX root mode"); 269 #endif 270 break; 271 default: 272 /* XXX check if there was already an error message set! */ 273 pszError = N_("Unknown error creating VM"); 274 NoDmik(AssertMsgFailed(("Add error message for rc=%d (%Vrc)\n", rc, rc))); 275 } 276 if (pszError) 277 vmR3CallVMAtError(pfnVMAtError, pvUserVM, rc, RT_SRC_POS, pszError, rc); 278 279 /* Forcefully terminate the emulation thread. */ 280 VM_FF_SET(pVM, VM_FF_TERMINATE); 281 VMR3NotifyFF(pVM, false); 282 RTThreadWait(pVM->ThreadEMT, 1000, NULL); 285 286 int rc2 = STAMR3Term(pVM); 287 AssertRC(rc2); 283 288 } 284 289 285 int rc2 = STAMR3Term(pVM); 286 AssertRC(rc2); 290 RTSemEventDestroy(pVM->vm.s.EventSemWait); 287 291 } 288 289 292 /* cleanup the heap. */ 290 293 int rc2 = MMR3Term(pVM); … … 463 466 { 464 467 /* 465 * Set the state and link into the global list.468 * Now we can safely set the VM halt method to default. 466 469 */ 467 vmR3SetState(pVM, VMSTATE_CREATED); 468 pVM->pNext = g_pVMsHead; 469 g_pVMsHead = pVM; 470 return VINF_SUCCESS; 470 rc = vmR3SetHaltMethod(pVM, VMHALTMETHOD_DEFAULT); 471 if (RT_SUCCESS(rc)) 472 { 473 /* 474 * Set the state and link into the global list. 475 */ 476 vmR3SetState(pVM, VMSTATE_CREATED); 477 pVM->pNext = g_pVMsHead; 478 g_pVMsHead = pVM; 479 return VINF_SUCCESS; 480 } 471 481 } 472 482 #ifdef VBOX_WITH_DEBUGGER … … 505 515 * Init all R3 components, the order here might be important. 506 516 */ 507 rc = vmR3SetHaltMethod(pVM, VMHALTMETHOD_DEFAULT);508 AssertRCReturn(rc, rc);509 510 517 rc = MMR3Init(pVM); 511 518 if (VBOX_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.