Changeset 24579 in vbox for trunk/src/VBox/Main
- Timestamp:
- Nov 11, 2009 1:50:27 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ConsoleImpl.cpp
r24558 r24579 2696 2696 2697 2697 2698 const char *Console::controllerTypeToDev(StorageControllerType_T enmCtrlType) 2698 /* static */ 2699 const char *Console::convertControllerTypeToDev(StorageControllerType_T enmCtrlType) 2699 2700 { 2700 2701 switch (enmCtrlType) … … 2792 2793 rc = ctrl->COMGETTER(ControllerType)(&enmCtrlType); 2793 2794 AssertComRC(rc); 2794 pszDevice = con trollerTypeToDev(enmCtrlType);2795 pszDevice = convertControllerTypeToDev(enmCtrlType); 2795 2796 2796 2797 /** @todo support multiple instances of a controller */ … … 7000 7001 7001 7002 /** 7002 * Reconfigures a VDI.7003 * Reconfigures a medium attachment (part of taking an online snapshot). 7003 7004 * 7004 7005 * @param pVM The VM handle. 7005 7006 * @param lInstance The instance of the controller. 7006 7007 * @param enmController The type of the controller. 7007 * @param hda The harddisk attachment. 7008 * @param enmBus The storage bus type of the controller. 7009 * @param aMediumAtt The medium attachment. 7008 7010 * @param phrc Where to store com error - only valid if we return VERR_GENERAL_FAILURE. 7009 7011 * @return VBox status code. 7010 7012 */ 7011 static DECLCALLBACK(int) reconfigureHardDisks(PVM pVM, ULONG lInstance, 7012 StorageControllerType_T enmController, 7013 IMediumAttachment *hda, 7014 HRESULT *phrc) 7015 { 7016 LogFlowFunc(("pVM=%p hda=%p phrc=%p\n", pVM, hda, phrc)); 7013 static DECLCALLBACK(int) reconfigureMedium(PVM pVM, ULONG lInstance, 7014 StorageControllerType_T enmController, 7015 StorageBus_T enmBus, 7016 IMediumAttachment *aMediumAtt, 7017 HRESULT *phrc) 7018 { 7019 LogFlowFunc(("pVM=%p aMediumAtt=%p phrc=%p\n", pVM, aMediumAtt, phrc)); 7017 7020 7018 7021 int rc; … … 7024 7027 7025 7028 /* 7026 * Figure out which IDE device this is.7029 * Figure out medium and other attachment details. 7027 7030 */ 7028 ComPtr<IMedium> hardDisk;7029 hrc = hda->COMGETTER(Medium)(hardDisk.asOutParam());H();7031 ComPtr<IMedium> medium; 7032 hrc = aMediumAtt->COMGETTER(Medium)(medium.asOutParam()); H(); 7030 7033 LONG lDev; 7031 hrc = hda->COMGETTER(Device)(&lDev);H();7034 hrc = aMediumAtt->COMGETTER(Device)(&lDev); H(); 7032 7035 LONG lPort; 7033 hrc = hda->COMGETTER(Port)(&lPort); H(); 7034 7035 int iLUN; 7036 const char *pcszDevice = NULL; 7037 bool fSCSI = false; 7038 7039 switch (enmController) 7040 { 7041 case StorageControllerType_PIIX3: 7042 case StorageControllerType_PIIX4: 7043 case StorageControllerType_ICH6: 7044 { 7045 if (lPort >= 2 || lPort < 0) 7046 { 7047 AssertMsgFailed(("invalid controller channel number: %d\n", lPort)); 7048 return VERR_GENERAL_FAILURE; 7049 } 7050 7051 if (lDev >= 2 || lDev < 0) 7052 { 7053 AssertMsgFailed(("invalid controller device number: %d\n", lDev)); 7054 return VERR_GENERAL_FAILURE; 7055 } 7056 7057 iLUN = 2*lPort + lDev; 7058 pcszDevice = "piix3ide"; 7059 break; 7060 } 7061 case StorageControllerType_IntelAhci: 7062 { 7063 iLUN = lPort; 7064 pcszDevice = "ahci"; 7065 break; 7066 } 7067 case StorageControllerType_BusLogic: 7068 { 7069 iLUN = lPort; 7070 pcszDevice = "buslogic"; 7071 fSCSI = true; 7072 break; 7073 } 7074 case StorageControllerType_LsiLogic: 7075 { 7076 iLUN = lPort; 7077 pcszDevice = "lsilogicscsi"; 7078 fSCSI = true; 7079 break; 7080 } 7081 default: 7082 { 7083 AssertMsgFailed(("invalid disk controller type: %d\n", enmController)); 7084 return VERR_GENERAL_FAILURE; 7085 } 7086 } 7036 hrc = aMediumAtt->COMGETTER(Port)(&lPort); H(); 7037 DeviceType_T lType; 7038 hrc = aMediumAtt->COMGETTER(Type)(&lType); H(); 7039 7040 unsigned iLUN; 7041 const char *pcszDevice = Console::convertControllerTypeToDev(enmController); 7042 AssertMsgReturn(pcszDevice, ("invalid disk controller type: %d\n", enmController), VERR_GENERAL_FAILURE); 7043 hrc = Console::convertBusPortDeviceToLun(enmBus, lPort, lDev, iLUN); H(); 7044 7045 /* Ignore attachments other than hard disks, since at the moment they are 7046 * not subject to snapshotting in general. */ 7047 if (lType != DeviceType_HardDisk || medium.isNull()) 7048 return VINF_SUCCESS; 7087 7049 7088 7050 /** @todo this should be unified with the relevant part of … … 7091 7053 /* 7092 7054 * Is there an existing LUN? If not create it. 7093 * We ASSUME that this will NEVER collide with the DVD.7094 7055 */ 7095 7056 PCFGMNODE pCfg; … … 7097 7058 7098 7059 /* SCSI has an extra driver between the device and the block driver. */ 7099 if ( fSCSI)7100 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#% d/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN);7060 if (enmBus == StorageBus_SCSI) 7061 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/AttachedDriver/", pcszDevice, lInstance, iLUN); 7101 7062 else 7102 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#% d/AttachedDriver/", pcszDevice, lInstance, iLUN);7063 pLunL1 = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%u/LUN#%u/AttachedDriver/", pcszDevice, lInstance, iLUN); 7103 7064 7104 7065 if (!pLunL1) … … 7108 7069 7109 7070 PCFGMNODE pLunL0; 7110 rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#% d", iLUN); RC_CHECK();7111 7112 if ( fSCSI)7071 rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%u", iLUN); RC_CHECK(); 7072 7073 if (enmBus == StorageBus_SCSI) 7113 7074 { 7114 7075 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); … … 7155 7116 * Create the driver configuration. 7156 7117 */ 7157 hrc = hardDisk->COMGETTER(Location)(bstr.asOutParam());H();7158 LogFlowFunc(("LUN#% d: leaf location '%ls'\n", iLUN, bstr.raw()));7118 hrc = medium->COMGETTER(Location)(bstr.asOutParam()); H(); 7119 LogFlowFunc(("LUN#%u: leaf location '%ls'\n", iLUN, bstr.raw())); 7159 7120 rc = CFGMR3InsertString(pCfg, "Path", Utf8Str(bstr).c_str()); RC_CHECK(); 7160 hrc = hardDisk->COMGETTER(Format)(bstr.asOutParam());H();7161 LogFlowFunc(("LUN#% d: leaf format '%ls'\n", iLUN, bstr.raw()));7121 hrc = medium->COMGETTER(Format)(bstr.asOutParam()); H(); 7122 LogFlowFunc(("LUN#%u: leaf format '%ls'\n", iLUN, bstr.raw())); 7162 7123 rc = CFGMR3InsertString(pCfg, "Format", Utf8Str(bstr).c_str()); RC_CHECK(); 7163 7124 … … 7166 7127 SafeArray<BSTR> names; 7167 7128 SafeArray<BSTR> values; 7168 hrc = hardDisk->GetProperties(NULL,7169 7170 ComSafeArrayAsOutParam(values));H();7129 hrc = medium->GetProperties(NULL, 7130 ComSafeArrayAsOutParam(names), 7131 ComSafeArrayAsOutParam(values)); H(); 7171 7132 7172 7133 if (names.size() != 0) … … 7189 7150 7190 7151 /* Create an inversed tree of parents. */ 7191 ComPtr<IMedium> parent HardDisk = hardDisk;7152 ComPtr<IMedium> parentMedium = medium; 7192 7153 for (PCFGMNODE pParent = pCfg;;) 7193 7154 { 7194 hrc = parent HardDisk->COMGETTER(Parent)(hardDisk.asOutParam());H();7195 if ( hardDisk.isNull())7155 hrc = parentMedium->COMGETTER(Parent)(medium.asOutParam()); H(); 7156 if (medium.isNull()) 7196 7157 break; 7197 7158 7198 7159 PCFGMNODE pCur; 7199 7160 rc = CFGMR3InsertNode(pParent, "Parent", &pCur); RC_CHECK(); 7200 hrc = hardDisk->COMGETTER(Location)(bstr.asOutParam());H();7161 hrc = medium->COMGETTER(Location)(bstr.asOutParam()); H(); 7201 7162 rc = CFGMR3InsertString(pCur, "Path", Utf8Str(bstr).c_str()); RC_CHECK(); 7202 7163 7203 hrc = hardDisk->COMGETTER(Format)(bstr.asOutParam());H();7164 hrc = medium->COMGETTER(Format)(bstr.asOutParam()); H(); 7204 7165 rc = CFGMR3InsertString(pCur, "Format", Utf8Str(bstr).c_str()); RC_CHECK(); 7205 7166 … … 7207 7168 SafeArray<BSTR> names; 7208 7169 SafeArray<BSTR> values; 7209 hrc = hardDisk->GetProperties(NULL,7210 7211 ComSafeArrayAsOutParam(values));H();7170 hrc = medium->GetProperties(NULL, 7171 ComSafeArrayAsOutParam(names), 7172 ComSafeArrayAsOutParam(values)); H(); 7212 7173 7213 7174 if (names.size() != 0) … … 7229 7190 } 7230 7191 7231 7232 7192 /* Custom code: put marker to not use host IP stack to driver 7233 7193 * configuration node. Simplifies life of DrvVD a bit. */ … … 7240 7200 /* next */ 7241 7201 pParent = pCur; 7242 parent HardDisk = hardDisk;7202 parentMedium = medium; 7243 7203 } 7244 7204 … … 7337 7297 LogFlowFunc(("Reattaching new differencing hard disks...\n")); 7338 7298 7339 pTask->mProgress->SetNextOperation(Bstr(tr("Reconfiguring hard disks")),7299 pTask->mProgress->SetNextOperation(Bstr(tr("Reconfiguring medium attachments")), 7340 7300 1); // operation weight, same as computed when setting up progress object 7341 7301 … … 7352 7312 ULONG lInstance; 7353 7313 StorageControllerType_T enmController; 7314 StorageBus_T enmBus; 7354 7315 7355 7316 /* … … 7359 7320 */ 7360 7321 rc = atts[i]->COMGETTER(Controller)(&controllerName); 7361 if (FAILED(rc)) 7362 break; 7322 if (FAILED(rc)) throw rc; 7363 7323 7364 7324 rc = that->mMachine->GetStorageControllerByName(controllerName, controller.asOutParam()); … … 7366 7326 7367 7327 rc = controller->COMGETTER(ControllerType)(&enmController); 7328 if (FAILED(rc)) throw rc; 7368 7329 rc = controller->COMGETTER(Instance)(&lInstance); 7330 if (FAILED(rc)) throw rc; 7331 rc = controller->COMGETTER(Bus)(&enmBus); 7332 if (FAILED(rc)) throw rc; 7369 7333 7370 7334 /* 7371 * don't leave the lock since reconfigure HardDisksisn't going7335 * don't leave the lock since reconfigureMedium isn't going 7372 7336 * to access Console. 7373 7337 */ 7374 7338 int vrc = VMR3ReqCallWait(that->mpVM, 7375 7339 VMCPUID_ANY, 7376 (PFNRT)reconfigure HardDisks,7377 5,7340 (PFNRT)reconfigureMedium, 7341 6, 7378 7342 that->mpVM, 7379 7343 lInstance, 7380 7344 enmController, 7345 enmBus, 7381 7346 atts[i], 7382 7347 &rc); … … 7384 7349 throw setError(E_FAIL, Console::tr("%Rrc"), vrc); 7385 7350 if (FAILED(rc)) throw rc; 7386 break;7387 if (FAILED(rc))7388 break;7389 7351 } 7390 7352 } -
trunk/src/VBox/Main/ConsoleImpl2.cpp
r24546 r24579 809 809 810 810 /* /Devices/<ctrldev>/ */ 811 const char *pszCtrlDev = pConsole->con trollerTypeToDev(enmCtrlType);811 const char *pszCtrlDev = pConsole->convertControllerTypeToDev(enmCtrlType); 812 812 pDev = aCtrlNodes[enmCtrlType]; 813 813 if (!pDev) … … 825 825 rc = CFGMR3InsertNode(pCtlInst, "Config", &pCfg); RC_CHECK(); 826 826 827 bool fSCSI = false;828 827 switch (enmCtrlType) 829 828 { … … 834 833 afPciDeviceNo[20] = true; 835 834 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK(); 836 fSCSI = true;837 835 838 836 /* Attach the status driver */ … … 852 850 afPciDeviceNo[21] = true; 853 851 rc = CFGMR3InsertInteger(pCtlInst, "PCIFunctionNo", 0); RC_CHECK(); 854 fSCSI = true;855 852 856 853 /* Attach the status driver */ … … 961 958 } 962 959 963 /* Attach the hard disks. */960 /* Attach the media to the storage controllers. */ 964 961 com::SafeIfaceArray<IMediumAttachment> atts; 965 962 hrc = pMachine->GetMediumAttachmentsOfController(controllerName, … … 982 979 983 980 /* SCSI has a another driver between device and block. */ 984 if ( fSCSI)981 if (enmBus == StorageBus_SCSI) 985 982 { 986 983 rc = CFGMR3InsertString(pLunL0, "Driver", "SCSI"); RC_CHECK(); -
trunk/src/VBox/Main/include/ConsoleImpl.h
r24493 r24579 223 223 } 224 224 225 static const char *convertControllerTypeToDev(StorageControllerType_T enmCtrlType); 226 static HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun); 227 225 228 // for VirtualBoxSupportErrorInfoImpl 226 229 static const wchar_t *getComponentName() { return L"Console"; } … … 443 446 const char *pszFormat, bool fPassthrough, 444 447 bool fForce); 445 const char *controllerTypeToDev(StorageControllerType_T enmCtrlType);446 HRESULT convertBusPortDeviceToLun(StorageBus_T enmBus, LONG port, LONG device, unsigned &uLun);447 448 HRESULT doMediumChange(IMediumAttachment *aMediumAttachment, bool fForce); 448 449
Note:
See TracChangeset
for help on using the changeset viewer.