- Timestamp:
- May 7, 2010 3:49:10 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r28977 r29224 3280 3280 * @thread EMT 3281 3281 */ 3282 DECLCALLBACK(int) Console::changeRemovableMedium(Console *p This,3282 DECLCALLBACK(int) Console::changeRemovableMedium(Console *pConsole, 3283 3283 const char *pcszDevice, 3284 3284 unsigned uInstance, … … 3288 3288 bool fForce) 3289 3289 { 3290 LogFlowFunc(("p This=%p uInstance=%u pszDevice=%p:{%s} enmBus=%u, aMediumAtt=%p, fForce=%d\n",3291 p This, uInstance, pcszDevice, enmBus, fForce));3292 3293 AssertReturn(p This, VERR_INVALID_PARAMETER);3294 3295 AutoCaller autoCaller(p This);3290 LogFlowFunc(("pConsole=%p uInstance=%u pszDevice=%p:{%s} enmBus=%u, aMediumAtt=%p, fForce=%d\n", 3291 pConsole, uInstance, pcszDevice, enmBus, fForce)); 3292 3293 AssertReturn(pConsole, VERR_INVALID_PARAMETER); 3294 3295 AutoCaller autoCaller(pConsole); 3296 3296 AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED); 3297 3297 3298 PVM pVM = p This->mpVM;3298 PVM pVM = pConsole->mpVM; 3299 3299 3300 3300 /* … … 3313 3313 LogFlowFunc(("Suspending the VM...\n")); 3314 3314 /* disable the callback to prevent Console-level state change */ 3315 p This->mVMStateChangeCallbackDisabled = true;3315 pConsole->mVMStateChangeCallbackDisabled = true; 3316 3316 int rc = VMR3Suspend(pVM); 3317 p This->mVMStateChangeCallbackDisabled = false;3317 pConsole->mVMStateChangeCallbackDisabled = false; 3318 3318 AssertRCReturn(rc, rc); 3319 3319 fResume = true; … … 3343 3343 int rcRet = VINF_SUCCESS; 3344 3344 3345 rcRet = Console::configMediumAttachment(pCtlInst, pcszDevice, uInstance, 3346 enmBus, enmIoBackend, 3347 false /* fSetupMerge */, 3348 0 /* uMergeSource */, 3349 0 /* uMergeTarget */, 3350 aMediumAtt, pThis->mMachineState, 3351 NULL /* phrc */, 3352 true /* fAttachDetach */, 3353 fForce /* fForceUnmount */, 3354 pVM, NULL /* paLedDevType */); 3345 rcRet = pConsole->configMediumAttachment(pCtlInst, 3346 pcszDevice, 3347 uInstance, 3348 enmBus, 3349 enmIoBackend, 3350 false /* fSetupMerge */, 3351 0 /* uMergeSource */, 3352 0 /* uMergeTarget */, 3353 aMediumAtt, 3354 pConsole->mMachineState, 3355 NULL /* phrc */, 3356 true /* fAttachDetach */, 3357 fForce /* fForceUnmount */, 3358 pVM, 3359 NULL /* paLedDevType */); 3355 3360 /** @todo this dumps everything attached to this device instance, which 3356 3361 * is more than necessary. Dumping the changed LUN would be enough. */ … … 3364 3369 LogFlowFunc(("Resuming the VM...\n")); 3365 3370 /* disable the callback to prevent Console-level state change */ 3366 p This->mVMStateChangeCallbackDisabled = true;3371 pConsole->mVMStateChangeCallbackDisabled = true; 3367 3372 rc = VMR3Resume(pVM); 3368 p This->mVMStateChangeCallbackDisabled = false;3373 pConsole->mVMStateChangeCallbackDisabled = false; 3369 3374 AssertRC(rc); 3370 3375 if (RT_FAILURE(rc)) 3371 3376 { 3372 3377 /* too bad, we failed. try to sync the console state with the VMM state */ 3373 vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, p This);3378 vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, pConsole); 3374 3379 } 3375 3380 /// @todo (r=dmik) if we failed with drive mount, then the VMR3Resume … … 7548 7553 */ 7549 7554 /* static */ 7550 DECLCALLBACK(int) Console::reconfigureMediumAttachment(PVM pVM, 7555 DECLCALLBACK(int) Console::reconfigureMediumAttachment(Console *pConsole, 7556 PVM pVM, 7551 7557 const char *pcszDevice, 7552 7558 unsigned uInstance, … … 7582 7588 7583 7589 /* Update the device instance configuration. */ 7584 rc = Console::configMediumAttachment(pCtlInst, pcszDevice, uInstance, 7585 enmBus, enmIoBackend, 7586 fSetupMerge, uMergeSource, 7587 uMergeTarget, aMediumAtt, 7588 aMachineState, phrc, 7590 rc = pConsole->configMediumAttachment(pCtlInst, 7591 pcszDevice, 7592 uInstance, 7593 enmBus, 7594 enmIoBackend, 7595 fSetupMerge, 7596 uMergeSource, 7597 uMergeTarget, 7598 aMediumAtt, 7599 aMachineState, 7600 phrc, 7589 7601 true /* fAttachDetach */, 7590 false /* fForceUnmount */, pVM, 7602 false /* fForceUnmount */, 7603 pVM, 7591 7604 NULL /* paLedDevType */); 7592 7605 /** @todo this dumps everything attached to this device instance, which -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r29218 r29224 1237 1237 for (size_t j = 0; j < atts.size(); ++j) 1238 1238 { 1239 rc = Console::configMediumAttachment(pCtlInst, pszCtrlDev, 1240 ulInstance, enmBus, enmIoBackend, 1241 false /* fSetupMerge */, 1242 0 /* uMergeSource */, 1243 0 /* uMergeTarget */, 1244 atts[j], 1245 pConsole->mMachineState, 1246 NULL /* phrc */, 1247 false /* fAttachDetach */, 1248 false /* fForceUnmount */, 1249 NULL /* pVM */, 1250 paLedDevType); RC_CHECK(); 1239 rc = pConsole->configMediumAttachment(pCtlInst, 1240 pszCtrlDev, 1241 ulInstance, 1242 enmBus, 1243 enmIoBackend, 1244 false /* fSetupMerge */, 1245 0 /* uMergeSource */, 1246 0 /* uMergeTarget */, 1247 atts[j], 1248 pConsole->mMachineState, 1249 NULL /* phrc */, 1250 false /* fAttachDetach */, 1251 false /* fForceUnmount */, 1252 NULL /* pVM */, 1253 paLedDevType); RC_CHECK(); 1251 1254 } 1252 1255 H(); … … 2249 2252 2250 2253 /* static */ 2251 int Console::configMediumAttachment(PCFGMNODE pCtlInst, const char *pcszDevice, 2252 unsigned uInstance, StorageBus_T enmBus, 2254 int Console::configMediumAttachment(PCFGMNODE pCtlInst, 2255 const char *pcszDevice, 2256 unsigned uInstance, 2257 StorageBus_T enmBus, 2253 2258 IoBackendType_T enmIoBackend, 2254 bool fSetupMerge, unsigned uMergeSource, 2259 bool fSetupMerge, 2260 unsigned uMergeSource, 2255 2261 unsigned uMergeTarget, 2256 2262 IMediumAttachment *pMediumAtt, 2257 2263 MachineState_T aMachineState, 2258 HRESULT *phrc, bool fAttachDetach, 2259 bool fForceUnmount, PVM pVM, 2264 HRESULT *phrc, 2265 bool fAttachDetach, 2266 bool fForceUnmount, 2267 PVM pVM, 2260 2268 DeviceType_T *paLedDevType) 2261 2269 { … … 2335 2343 BOOL fPassthrough; 2336 2344 hrc = pMediumAtt->COMGETTER(Passthrough)(&fPassthrough); H(); 2337 rc = Console::configMedium(pLunL0, !!fPassthrough, lType, 2338 enmIoBackend, fSetupMerge, uMergeSource, 2339 uMergeTarget, pMedium, aMachineState, 2345 rc = Console::configMedium(pLunL0, 2346 !!fPassthrough, 2347 lType, 2348 enmIoBackend, 2349 fSetupMerge, 2350 uMergeSource, 2351 uMergeTarget, 2352 pMedium, 2353 aMachineState, 2340 2354 phrc); RC_CHECK(); 2341 2355 … … 2361 2375 } 2362 2376 2363 int Console::configMedium(PCFGMNODE pLunL0, bool fPassthrough, 2364 DeviceType_T enmType, IoBackendType_T enmIoBackend, 2365 bool fSetupMerge, unsigned uMergeSource, 2366 unsigned uMergeTarget, IMedium *pMedium, 2367 MachineState_T aMachineState, HRESULT *phrc) 2377 int Console::configMedium(PCFGMNODE pLunL0, 2378 bool fPassthrough, 2379 DeviceType_T enmType, 2380 IoBackendType_T enmIoBackend, 2381 bool fSetupMerge, 2382 unsigned uMergeSource, 2383 unsigned uMergeTarget, 2384 IMedium *pMedium, 2385 MachineState_T aMachineState, 2386 HRESULT *phrc) 2368 2387 { 2369 2388 int rc = VINF_SUCCESS; … … 2426 2445 rc = CFGMR3InsertString(pCfg, "Type", "HardDisk"); RC_CHECK(); 2427 2446 rc = CFGMR3InsertInteger(pCfg, "Mountable", 0); RC_CHECK(); 2447 } 2448 2449 if ( pMedium 2450 && enmType == DeviceType_DVD) 2451 { 2452 // if this medium represents an ISO image and this image is inaccessible, 2453 // the ignore it instead of causing a failure; this can happen when we 2454 // restore a VM state and the ISO has disappeared, e.g. because the Guest 2455 // Additions were mounted and the user upgraded VirtualBox. Previously 2456 // we failed on startup, but that's not good because the only way out then 2457 // would be to discard the VM state... 2458 MediumState_T mediumState; 2459 rc = pMedium->RefreshState(&mediumState); 2460 RC_CHECK(); 2461 if (mediumState == MediumState_Inaccessible) 2462 { 2463 Bstr loc; 2464 rc = pMedium->COMGETTER(Location)(loc.asOutParam()); 2465 if (FAILED(rc)) return rc; 2466 2467 setVMRuntimeErrorCallbackF(mpVM, 2468 this, 2469 0, 2470 "DvdOrFloppyImageInaccessible", 2471 "The medium '%ls' is inaccessible and is being ignored. You may want to fix the media attachments in the virtual machine settings", 2472 loc.raw()); 2473 pMedium = NULL; 2474 } 2428 2475 } 2429 2476 -
trunk/src/VBox/Main/MachineImpl.cpp
r29218 r29224 2770 2770 2771 2771 ComObjPtr<Medium> medium; 2772 2772 2773 switch (aType) 2773 2774 { … … 3061 3062 /* Apply the normal locking logic to the entire chain. */ 3062 3063 MediumLockList *pMediumLockList(new MediumLockList()); 3063 rc = diff->createMediumLockList(true, medium, *pMediumLockList); 3064 rc = diff->createMediumLockList(true, /* fFailIfInaccessible */ 3065 true /* fMediumWritable -- really? @todo r=dj*/ , 3066 medium, 3067 *pMediumLockList); 3064 3068 if (FAILED(rc)) return rc; 3065 3069 rc = pMediumLockList->Lock(); … … 8189 8193 8190 8194 MediumLockList *pMediumLockList(new MediumLockList()); 8191 rc = pMedium->createMediumLockList(false, NULL, 8195 rc = pMedium->createMediumLockList(true, /* fFailIfInaccessible */ 8196 false, 8197 NULL, 8192 8198 *pMediumLockList); 8193 8199 if (FAILED(rc)) … … 10803 10809 if (pMedium != NULL) 10804 10810 { 10805 mrc = pMedium->createMediumLockList(devType != DeviceType_DVD, 10806 NULL, *pMediumLockList); 10811 bool fIsReadOnlyImage = ( devType == DeviceType_DVD 10812 || devType == DeviceType_Floppy); 10813 mrc = pMedium->createMediumLockList(!fIsReadOnlyImage /* fFailIfInaccessible */, 10814 fIsReadOnlyImage, /* fReadOnly */ 10815 NULL, 10816 *pMediumLockList); 10807 10817 if (FAILED(mrc)) 10808 10818 { -
trunk/src/VBox/Main/MediumImpl.cpp
r29211 r29224 2201 2201 /* Apply the normal locking logic to the entire chain. */ 2202 2202 MediumLockList *pMediumLockList(new MediumLockList()); 2203 HRESULT rc = diff->createMediumLockList(true, this, *pMediumLockList); 2203 HRESULT rc = diff->createMediumLockList(true /* fFailIfInaccessible */, 2204 true /* fMediumWritable */, 2205 this, 2206 *pMediumLockList); 2204 2207 if (FAILED(rc)) 2205 2208 { … … 2289 2292 /* Build the source lock list. */ 2290 2293 MediumLockList *pSourceMediumLockList(new MediumLockList()); 2291 rc = createMediumLockList(false, NULL, 2294 rc = createMediumLockList(true /* fFailIfInaccessible */, 2295 false /* fMediumWritable */, 2296 NULL, 2292 2297 *pSourceMediumLockList); 2293 2298 if (FAILED(rc)) … … 2299 2304 /* Build the target lock list (including the to-be parent chain). */ 2300 2305 MediumLockList *pTargetMediumLockList(new MediumLockList()); 2301 rc = pTarget->createMediumLockList(true, pParent, 2306 rc = pTarget->createMediumLockList(true /* fFailIfInaccessible */, 2307 true /* fMediumWritable */, 2308 pParent, 2302 2309 *pTargetMediumLockList); 2303 2310 if (FAILED(rc)) … … 2387 2394 /* Build the medium lock list. */ 2388 2395 MediumLockList *pMediumLockList(new MediumLockList()); 2389 rc = createMediumLockList(true, NULL, 2396 rc = createMediumLockList(true /* fFailIfInaccessible */ , 2397 true /* fMediumWritable */, 2398 NULL, 2390 2399 *pMediumLockList); 2391 2400 if (FAILED(rc)) … … 2480 2489 /* Build the medium lock list. */ 2481 2490 MediumLockList *pMediumLockList(new MediumLockList()); 2482 rc = createMediumLockList(true, NULL, 2491 rc = createMediumLockList(true /* fFailIfInaccessible */, 2492 true /* fMediumWritable */, 2493 NULL, 2483 2494 *pMediumLockList); 2484 2495 if (FAILED(rc)) … … 3104 3115 * @param mediumLockList Where to store the resulting list. 3105 3116 */ 3106 HRESULT Medium::createMediumLockList(bool fMediumWritable, 3117 HRESULT Medium::createMediumLockList(bool fFailIfInaccessible, 3118 bool fMediumWritable, 3107 3119 Medium *pToBeParent, 3108 3120 MediumLockList &mediumLockList) … … 3141 3153 if (mediumState == MediumState_Inaccessible) 3142 3154 { 3155 // ignore inaccessible ISO images and silently return S_OK, 3156 // otherwise VM startup (esp. restore) may fail without good reason 3157 if (!fFailIfInaccessible) 3158 return S_OK; 3159 3160 // otherwise report an error 3143 3161 Bstr error; 3144 3162 rc = pMedium->COMGETTER(LastAccessError)(error.asOutParam()); 3145 if (FAILED(rc)) return rc;3146 3147 Bstr loc;3148 rc = pMedium->COMGETTER(Location)(loc.asOutParam());3149 3163 if (FAILED(rc)) return rc; 3150 3164 … … 3896 3910 /* Build the medium lock list. */ 3897 3911 MediumLockList *pMediumLockList(new MediumLockList()); 3898 rc = createMediumLockList(true, NULL, 3912 rc = createMediumLockList(true /* fFailIfInaccessible */, 3913 true /* fMediumWritable */, 3914 NULL, 3899 3915 *pMediumLockList); 3900 3916 if (FAILED(rc)) … … 4282 4298 aMediumLockList = new MediumLockList(); 4283 4299 if (fMergeForward) 4284 rc = pTarget->createMediumLockList(true, NULL, *aMediumLockList); 4300 rc = pTarget->createMediumLockList(true /* fFailIfInaccessible */, 4301 true /* fMediumWritable */, 4302 NULL, 4303 *aMediumLockList); 4285 4304 else 4286 rc = createMediumLockList(false, NULL, *aMediumLockList); 4305 rc = createMediumLockList(true /* fFailIfInaccessible */, 4306 false /* fMediumWritable */, 4307 NULL, 4308 *aMediumLockList); 4287 4309 if (FAILED(rc)) 4288 4310 throw rc; … … 4985 5007 { 4986 5008 MediumLockList mediumLockList; 4987 HRESULT rc = createMediumLockList(false, this, mediumLockList); 5009 HRESULT rc = createMediumLockList(true /* fFailIfInaccessible */, 5010 false /* fMediumWritable */, 5011 this, 5012 mediumLockList); 4988 5013 AssertComRCReturnRC(rc); 4989 5014 -
trunk/src/VBox/Main/include/ConsoleImpl.h
r28959 r29224 438 438 static DECLCALLBACK(int) configConstructor(PVM pVM, void *pvConsole); 439 439 440 static int configMediumAttachment(PCFGMNODE pCtlInst, 441 const char *pcszDevice, 442 unsigned uInstance, 443 StorageBus_T enmBus, 444 IoBackendType_T enmIoBackend, 445 bool fSetupMerge, unsigned uMergeSource, 446 unsigned uMergeTarget, 447 IMediumAttachment *pMediumAtt, 448 MachineState_T aMachineState, 449 HRESULT *phrc, bool fAttachDetach, 450 bool fForceUnmount, PVM pVM, 451 DeviceType_T *paLedDevType); 452 static int configMedium(PCFGMNODE pLunL0, bool fPassthrough, 453 DeviceType_T enmType, IoBackendType_T enmIoBackend, 454 bool fSetupMerge, unsigned uMergeSource, 455 unsigned uMergeTarget, IMedium *pMedium, 456 MachineState_T aMachineState, HRESULT *phrc); 457 static DECLCALLBACK(int) reconfigureMediumAttachment(PVM pVM, 440 int configMediumAttachment(PCFGMNODE pCtlInst, 441 const char *pcszDevice, 442 unsigned uInstance, 443 StorageBus_T enmBus, 444 IoBackendType_T enmIoBackend, 445 bool fSetupMerge, 446 unsigned uMergeSource, 447 unsigned uMergeTarget, 448 IMediumAttachment *pMediumAtt, 449 MachineState_T aMachineState, 450 HRESULT *phrc, 451 bool fAttachDetach, 452 bool fForceUnmount, 453 PVM pVM, 454 DeviceType_T *paLedDevType); 455 int configMedium(PCFGMNODE pLunL0, 456 bool fPassthrough, 457 DeviceType_T enmType, 458 IoBackendType_T enmIoBackend, 459 bool fSetupMerge, 460 unsigned uMergeSource, 461 unsigned uMergeTarget, 462 IMedium *pMedium, 463 MachineState_T aMachineState, 464 HRESULT *phrc); 465 static DECLCALLBACK(int) reconfigureMediumAttachment(Console *pConsole, 466 PVM pVM, 458 467 const char *pcszDevice, 459 468 unsigned uInstance, -
trunk/src/VBox/Main/include/MediumImpl.h
r29028 r29224 188 188 HRESULT compareLocationTo(const char *aLocation, int &aResult); 189 189 190 HRESULT createMediumLockList(bool fMediumWritable, Medium *pToBeParent, MediumLockList &mediumLockList); 190 HRESULT createMediumLockList(bool fFailIfInaccessible, 191 bool fMediumWritable, 192 Medium *pToBeParent, 193 MediumLockList &mediumLockList); 191 194 192 195 HRESULT createDiffStorage(ComObjPtr<Medium> &aTarget,
Note:
See TracChangeset
for help on using the changeset viewer.