Changeset 17669 in vbox for trunk/src/VBox/Main/ConsoleImpl.cpp
- Timestamp:
- Mar 11, 2009 9:56:29 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r17651 r17669 3310 3310 3311 3311 /** 3312 * Called by IInternalSessionControl::OnStorageControllerChange(). 3313 * 3314 * @note Locks this object for writing. 3315 */ 3316 HRESULT Console::onStorageControllerChange () 3317 { 3318 LogFlowThisFunc (("\n")); 3319 3320 AutoCaller autoCaller (this); 3321 AssertComRCReturnRC (autoCaller.rc()); 3322 3323 AutoWriteLock alock (this); 3324 3325 /* Don't do anything if the VM isn't running */ 3326 if (!mpVM) 3327 return S_OK; 3328 3329 HRESULT rc = S_OK; 3330 3331 /* protect mpVM */ 3332 AutoVMCaller autoVMCaller (this); 3333 CheckComRCReturnRC (autoVMCaller.rc()); 3334 3335 /* nothing to do so far */ 3336 3337 /* notify console callbacks on success */ 3338 if (SUCCEEDED (rc)) 3339 { 3340 CallbackList::iterator it = mCallbacks.begin(); 3341 while (it != mCallbacks.end()) 3342 (*it++)->OnStorageControllerChange (); 3343 } 3344 3345 LogFlowThisFunc (("Leaving rc=%#x\n", rc)); 3346 return rc; 3347 } 3348 3349 /** 3312 3350 * Called by IInternalSessionControl::OnVRDPServerChange(). 3313 3351 * … … 6544 6582 * Reconfigures a VDI. 6545 6583 * 6546 * @param pVM The VM handle. 6547 * @param hda The harddisk attachment. 6548 * @param phrc Where to store com error - only valid if we return VERR_GENERAL_FAILURE. 6584 * @param pVM The VM handle. 6585 * @param lInstance The instance of the controller. 6586 * @param enmController The type of the controller. 6587 * @param hda The harddisk attachment. 6588 * @param phrc Where to store com error - only valid if we return VERR_GENERAL_FAILURE. 6549 6589 * @return VBox status code. 6550 6590 */ 6551 static DECLCALLBACK(int) reconfigureHardDisks(PVM pVM, IHardDiskAttachment *hda, 6591 static DECLCALLBACK(int) reconfigureHardDisks(PVM pVM, ULONG lInstance, 6592 StorageControllerType_T enmController, 6593 IHardDiskAttachment *hda, 6552 6594 HRESULT *phrc) 6553 6595 { … … 6566 6608 ComPtr<IHardDisk> hardDisk; 6567 6609 hrc = hda->COMGETTER(HardDisk)(hardDisk.asOutParam()); H(); 6568 StorageBus_T enmBus;6569 hrc = hda->COMGETTER(Bus)(&enmBus); H();6570 6610 LONG lDev; 6571 6611 hrc = hda->COMGETTER(Device)(&lDev); H(); 6572 LONG l Channel;6573 hrc = hda->COMGETTER( Channel)(&lChannel);H();6612 LONG lPort; 6613 hrc = hda->COMGETTER(Port)(&lPort); H(); 6574 6614 6575 6615 int iLUN; 6576 6616 const char *pcszDevice = NULL; 6577 6578 switch (enmBus) 6579 { 6580 case StorageBus_IDE: 6581 { 6582 if (lChannel >= 2 || lChannel < 0) 6617 bool fSCSI = false; 6618 6619 switch (enmController) 6620 { 6621 case StorageControllerType_PIIX3: 6622 case StorageControllerType_PIIX4: 6623 case StorageControllerType_ICH6: 6624 { 6625 if (lPort >= 2 || lPort < 0) 6583 6626 { 6584 AssertMsgFailed(("invalid controller channel number: %d\n", l Channel));6627 AssertMsgFailed(("invalid controller channel number: %d\n", lPort)); 6585 6628 return VERR_GENERAL_FAILURE; 6586 6629 } … … 6592 6635 } 6593 6636 6594 iLUN = 2*l Channel+ lDev;6637 iLUN = 2*lPort + lDev; 6595 6638 pcszDevice = "piix3ide"; 6596 6639 break; 6597 6640 } 6598 case Storage Bus_SATA:6599 { 6600 iLUN = l Channel;6641 case StorageControllerType_IntelAhci: 6642 { 6643 iLUN = lPort; 6601 6644 pcszDevice = "ahci"; 6602 6645 break; 6603 6646 } 6647 case StorageControllerType_BusLogic: 6648 { 6649 iLUN = lPort; 6650 pcszDevice = "buslogic"; 6651 fSCSI = true; 6652 break; 6653 } 6654 case StorageControllerType_LsiLogic: 6655 { 6656 iLUN = lPort; 6657 pcszDevice = "lsilogicscsi"; 6658 fSCSI = true; 6659 break; 6660 } 6604 6661 default: 6605 6662 { 6606 AssertMsgFailed(("invalid disk controller type: %d\n", enm Bus));6663 AssertMsgFailed(("invalid disk controller type: %d\n", enmController)); 6607 6664 return VERR_GENERAL_FAILURE; 6608 6665 } … … 6620 6677 PCFGMNODE pLunL2; 6621 6678 6622 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/0/LUN#%d/AttachedDriver/", pcszDevice, iLUN); 6679 /* SCSI has an extra driver between the device and the block driver. */ 6680 if (fSCSI) 6681 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%d/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN); 6682 else 6683 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%d/AttachedDriver/", pcszDevice, lInstance, iLUN); 6623 6684 6624 6685 if (!pLunL1) 6625 6686 { 6626 PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/ 0/", pcszDevice);6687 PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/", pcszDevice, lInstance); 6627 6688 AssertReturn(pInst, VERR_INTERNAL_ERROR); 6628 6689 6629 6690 PCFGMNODE pLunL0; 6630 6691 rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%d", iLUN); RC_CHECK(); 6692 6693 if (fSCSI) 6694 { 6695 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); 6696 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); 6697 6698 rc = CFGMR3InsertNode(pLunL0, "AttachedDriver", &pLunL0); RC_CHECK(); 6699 } 6700 6631 6701 rc = CFGMR3InsertString(pLunL0, "Driver", "Block"); RC_CHECK(); 6632 6702 rc = CFGMR3InsertNode(pLunL0, "Config", &pCfg); RC_CHECK(); … … 6859 6929 { 6860 6930 PVMREQ pReq; 6931 ComPtr<IStorageController> controller; 6932 BSTR controllerName; 6933 ULONG lInstance; 6934 StorageControllerType_T enmController; 6935 6936 /* 6937 * We can't pass a storage controller object directly 6938 * (g++ complains about not being able to pass non POD types through '...') 6939 * so we have to query needed values here and pass them. 6940 */ 6941 rc = atts[i]->COMGETTER(Controller)(&controllerName); 6942 if (FAILED (rc)) 6943 break; 6944 6945 rc = that->mMachine->GetStorageControllerByName(controllerName, controller.asOutParam()); 6946 if (FAILED (rc)) 6947 break; 6948 6949 rc = controller->COMGETTER(ControllerType)(&enmController); 6950 rc = controller->COMGETTER(Instance)(&lInstance); 6861 6951 /* 6862 6952 * don't leave the lock since reconfigureHardDisks isn't going … … 6864 6954 */ 6865 6955 int vrc = VMR3ReqCall (that->mpVM, VMREQDEST_ANY, &pReq, RT_INDEFINITE_WAIT, 6866 (PFNRT)reconfigureHardDisks, 3, that->mpVM,6867 atts [i], &rc);6956 (PFNRT)reconfigureHardDisks, 5, that->mpVM, lInstance, 6957 enmController, atts [i], &rc); 6868 6958 if (VBOX_SUCCESS (rc)) 6869 6959 rc = pReq->iStatus;
Note:
See TracChangeset
for help on using the changeset viewer.