- Timestamp:
- Apr 12, 2017 4:44:14 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
-
globals/UIMessageCenter.cpp (modified) (2 diffs)
-
globals/UIMessageCenter.h (modified) (1 diff)
-
settings/machine/UIMachineSettingsStorage.cpp (modified) (10 diffs)
-
settings/machine/UIMachineSettingsStorage.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r66508 r66543 61 61 # include "CSerialPort.h" 62 62 # include "CSharedFolder.h" 63 # include "CStorageController.h" 63 64 # include "CConsole.h" 64 65 # include "CMachine.h" … … 1294 1295 tr("Cannot save shared folder settings."), 1295 1296 formatErrorInfo(comFolder)); 1297 } 1298 1299 void UIMessageCenter::cannotSaveStorageSettings(const CMachine &comMachine, QWidget *pParent /* = 0 */) 1300 { 1301 error(pParent, MessageType_Error, 1302 tr("Cannot save storage settings."), 1303 formatErrorInfo(comMachine)); 1304 } 1305 1306 void UIMessageCenter::cannotSaveStorageControllerSettings(const CStorageController &comController, QWidget *pParent /* = 0 */) 1307 { 1308 error(pParent, MessageType_Error, 1309 tr("Cannot save storage controller settings."), 1310 formatErrorInfo(comController)); 1296 1311 } 1297 1312 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r66508 r66543 259 259 void cannotLoadFolderSettings(const CSharedFolder &comFolder, QWidget *pParent = 0); 260 260 void cannotSaveFolderSettings(const CSharedFolder &comFolder, QWidget *pParent = 0); 261 void cannotSaveStorageSettings(const CMachine &comMachine, QWidget *pParent = 0); 262 void cannotSaveStorageControllerSettings(const CStorageController &comController, QWidget *pParent = 0); 261 263 void cannotAttachDevice(const CMachine &machine, UIMediumType type, const QString &strLocation, const StorageSlot &storageSlot, QWidget *pParent = 0); 262 264 bool warnAboutIncorrectPort(QWidget *pParent = 0) const; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.cpp
r66541 r66543 2382 2382 UISettingsPageMachine::fetchData(data); 2383 2383 2384 /* Update storage data , updatefailing state: */2385 setFailed(! updateStorageData());2384 /* Update storage data and failing state: */ 2385 setFailed(!saveStorageData()); 2386 2386 2387 2387 /* Upload machine to data: */ … … 3961 3961 } 3962 3962 3963 bool UIMachineSettingsStorage:: updateStorageData()3963 bool UIMachineSettingsStorage::saveStorageData() 3964 3964 { 3965 3965 /* Prepare result: */ 3966 bool fSuccess = m_machine.isOk(); 3967 if (fSuccess) 3968 { 3969 /* Make sure machine is in valid mode & storage data was changed: */ 3970 if (isMachineInValidMode() && m_pCache->wasChanged()) 3971 { 3972 /* For each controller (removing step): */ 3973 for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex) 3974 { 3975 /* Get controller cache: */ 3976 const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex); 3977 3978 /* Remove controllers marked for 'remove' and 'update' (if they can't be updated): */ 3979 if (controllerCache.wasRemoved() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache))) 3980 fSuccess = removeStorageController(controllerCache); 3981 3982 else 3983 3984 /* Update controllers marked for 'update' (if they can be updated): */ 3985 if (controllerCache.wasUpdated() && isControllerCouldBeUpdated(controllerCache)) 3986 { 3987 /* For each attachment (removing step): */ 3988 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 3989 { 3990 /* Get attachment cache: */ 3991 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 3992 3993 /* Remove attachments marked for 'remove' and 'update' (if they can't be updated): */ 3994 if (attachmentCache.wasRemoved() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache))) 3995 fSuccess = removeStorageAttachment(controllerCache, attachmentCache); 3996 } 3997 } 3998 } 3999 4000 /* For each controller (creating step): */ 4001 for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex) 4002 { 4003 /* Get controller cache: */ 4004 const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex); 4005 4006 /* Create controllers marked for 'create' or 'update' (if they can't be updated): */ 4007 if (controllerCache.wasCreated() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache))) 4008 fSuccess = createStorageController(controllerCache); 4009 4010 else 4011 4012 /* Update controllers marked for 'update' (if they can be updated): */ 4013 if (controllerCache.wasUpdated() && isControllerCouldBeUpdated(controllerCache)) 4014 fSuccess = updateStorageController(controllerCache); 4015 } 3966 bool fSuccess = true; 3967 /* Save storage settings from the cache: */ 3968 if (fSuccess && isMachineInValidMode() && m_pCache->wasChanged()) 3969 { 3970 /* For each controller ('removing' step): */ 3971 // We need to separately remove controllers first because 3972 // there could be limited amount of controllers available. 3973 for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex) 3974 { 3975 /* Get controller cache: */ 3976 const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex); 3977 3978 /* Remove controller marked for 'remove' or 'update' (if it can't be updated): */ 3979 if (controllerCache.wasRemoved() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache))) 3980 fSuccess = removeStorageController(controllerCache); 3981 } 3982 3983 /* For each controller ('creating' step): */ 3984 for (int iControllerIndex = 0; fSuccess && iControllerIndex < m_pCache->childCount(); ++iControllerIndex) 3985 { 3986 /* Get controller cache: */ 3987 const UISettingsCacheMachineStorageController &controllerCache = m_pCache->child(iControllerIndex); 3988 3989 /* Create controller marked for 'create' or 'update' (if it can't be updated): */ 3990 if (controllerCache.wasCreated() || (controllerCache.wasUpdated() && !isControllerCouldBeUpdated(controllerCache))) 3991 fSuccess = createStorageController(controllerCache); 3992 3993 else 3994 3995 /* Update controller marked for 'update' (if it can be updated): */ 3996 if (controllerCache.wasUpdated() && isControllerCouldBeUpdated(controllerCache)) 3997 fSuccess = updateStorageController(controllerCache); 4016 3998 } 4017 3999 } … … 4023 4005 { 4024 4006 /* Prepare result: */ 4025 bool fSuccess = m_machine.isOk(); 4026 if (fSuccess) 4027 { 4028 /* Get storage controller data form cache: */ 4029 const UIDataSettingsMachineStorageController &controllerData = controllerCache.base(); 4030 4031 /* Get storage controller name: */ 4032 const QString strControllerName = controllerData.m_strControllerName; 4033 4034 /* Check that storage controller exists: */ 4035 const CStorageController &controller = m_machine.GetStorageControllerByName(strControllerName); 4036 /* Check that machine is OK: */ 4037 fSuccess = m_machine.isOk(); 4038 /* If controller exists: */ 4039 if (fSuccess && !controller.isNull()) 4040 { 4041 /*remove controller with all the attachments at one shot*/ 4042 m_machine.RemoveStorageController(strControllerName); 4043 /* Check that machine is OK: */ 4007 bool fSuccess = true; 4008 /* Remove controller: */ 4009 if (fSuccess && isMachineOffline()) 4010 { 4011 /* Get old controller data from the cache: */ 4012 const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base(); 4013 4014 /* Make sure controller really exists: */ 4015 const CStorageController &comController = m_machine.GetStorageControllerByName(oldControllerData.m_strControllerName); 4016 fSuccess = m_machine.isOk() && comController.isNotNull(); 4017 4018 /* Remove controller with all the attachments at one shot: */ 4019 if (fSuccess) 4020 { 4021 m_machine.RemoveStorageController(oldControllerData.m_strControllerName); 4044 4022 fSuccess = m_machine.isOk(); 4045 4023 } 4024 /* Show error message if necessary: */ 4025 if (!fSuccess) 4026 msgCenter().cannotSaveStorageSettings(m_machine, this); 4046 4027 } 4047 4028 /* Return result: */ … … 4052 4033 { 4053 4034 /* Prepare result: */ 4054 bool fSuccess = m_machine.isOk(); 4055 if (fSuccess) 4056 { 4057 /* Get controller data form cache: */ 4058 const UIDataSettingsMachineStorageController &controllerData = controllerCache.data(); 4059 4060 /* Get storage controller attributes: */ 4061 const QString strControllerName = controllerData.m_strControllerName; 4062 const KStorageBus enmControllerBus = controllerData.m_controllerBus; 4063 const KStorageControllerType enmControllerType = controllerData.m_controllerType; 4064 const bool fUseHostIOCache = controllerData.m_fUseHostIOCache; 4065 ULONG uPortCount = controllerData.m_uPortCount; 4066 4067 /* Check that storage controller doesn't exists: */ 4068 CStorageController controller = m_machine.GetStorageControllerByName(strControllerName); 4069 /* Check that machine is not OK: */ 4070 fSuccess = !m_machine.isOk(); 4071 /* If controller doesn't exists: */ 4072 if (fSuccess && controller.isNull()) 4073 { 4074 /* Create new storage controller: */ 4075 controller = m_machine.AddStorageController(strControllerName, enmControllerBus); 4076 /* Check that machine is OK: */ 4077 fSuccess = m_machine.isOk(); 4078 /* If controller exists: */ 4079 if (fSuccess && !controller.isNull()) 4035 bool fSuccess = true; 4036 /* Create controller: */ 4037 if (fSuccess && isMachineOffline()) 4038 { 4039 /* Get new controller data from the cache: */ 4040 const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data(); 4041 4042 /* Make sure controller doesn't exist: */ 4043 const CMachine comMachine(m_machine); 4044 CStorageController comController = comMachine.GetStorageControllerByName(newControllerData.m_strControllerName); 4045 fSuccess = !comMachine.isOk() && comController.isNull(); 4046 AssertReturn(fSuccess, false); 4047 4048 /* Create controller: */ 4049 if (fSuccess) 4050 { 4051 comController = m_machine.AddStorageController(newControllerData.m_strControllerName, newControllerData.m_controllerBus); 4052 fSuccess = m_machine.isOk() && comController.isNotNull(); 4053 } 4054 /* Show error message if necessary: */ 4055 if (!fSuccess) 4056 msgCenter().cannotSaveStorageSettings(m_machine, this); 4057 4058 /* Save controller type: */ 4059 if (fSuccess) 4060 { 4061 comController.SetControllerType(newControllerData.m_controllerType); 4062 fSuccess = comController.isOk(); 4063 } 4064 /* Save whether controller uses host IO cache: */ 4065 if (fSuccess) 4066 { 4067 comController.SetUseHostIOCache(newControllerData.m_fUseHostIOCache); 4068 fSuccess = comController.isOk(); 4069 } 4070 /* Save controller port number: */ 4071 if ( fSuccess 4072 && ( newControllerData.m_controllerBus == KStorageBus_SATA 4073 || newControllerData.m_controllerBus == KStorageBus_SAS 4074 || newControllerData.m_controllerBus == KStorageBus_PCIe)) 4075 { 4076 ULONG uNewPortCount = newControllerData.m_uPortCount; 4077 if (fSuccess) 4080 4078 { 4081 /* Set storage controller attributes: */ 4082 controller.SetControllerType(enmControllerType); 4083 controller.SetUseHostIOCache(fUseHostIOCache); 4084 if (enmControllerBus == KStorageBus_SATA || enmControllerBus == KStorageBus_SAS || enmControllerBus == KStorageBus_PCIe) 4085 { 4086 uPortCount = qMax(uPortCount, controller.GetMinPortCount()); 4087 uPortCount = qMin(uPortCount, controller.GetMaxPortCount()); 4088 controller.SetPortCount(uPortCount); 4089 } 4090 /* For each storage attachment: */ 4091 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 4092 { 4093 /* Get storage attachment cache: */ 4094 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 4095 4096 /* Create attachment if it was not just 'removed': */ 4097 if (!attachmentCache.wasRemoved()) 4098 fSuccess = createStorageAttachment(controllerCache, attachmentCache); 4099 } 4079 uNewPortCount = qMax(uNewPortCount, comController.GetMinPortCount()); 4080 fSuccess = comController.isOk(); 4100 4081 } 4082 if (fSuccess) 4083 { 4084 uNewPortCount = qMin(uNewPortCount, comController.GetMaxPortCount()); 4085 fSuccess = comController.isOk(); 4086 } 4087 if (fSuccess) 4088 { 4089 comController.SetPortCount(uNewPortCount); 4090 fSuccess = comController.isOk(); 4091 } 4092 } 4093 /* Show error message if necessary: */ 4094 if (!fSuccess) 4095 msgCenter().cannotSaveStorageControllerSettings(comController, this); 4096 4097 /* For each attachment: */ 4098 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 4099 { 4100 /* Get attachment cache: */ 4101 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 4102 4103 /* Create attachment if it was not 'removed': */ 4104 if (!attachmentCache.wasRemoved()) 4105 fSuccess = createStorageAttachment(controllerCache, attachmentCache); 4101 4106 } 4102 4107 } … … 4108 4113 { 4109 4114 /* Prepare result: */ 4110 bool fSuccess = m_machine.isOk(); 4115 bool fSuccess = true; 4116 /* Update controller: */ 4111 4117 if (fSuccess) 4112 4118 { 4113 /* Get controller data form cache: */ 4114 const UIDataSettingsMachineStorageController &controllerData = controllerCache.data(); 4115 4116 /* Get storage controller attributes: */ 4117 const QString strControllerName = controllerData.m_strControllerName; 4118 const KStorageBus enmControllerBus = controllerData.m_controllerBus; 4119 const KStorageControllerType enmControllerType = controllerData.m_controllerType; 4120 const bool fUseHostIOCache = controllerData.m_fUseHostIOCache; 4121 ULONG uPortCount = controllerData.m_uPortCount; 4122 4123 /* Check that controller exists: */ 4124 CStorageController controller = m_machine.GetStorageControllerByName(strControllerName); 4125 /* Check that machine is OK: */ 4126 fSuccess = m_machine.isOk(); 4127 /* If controller exists: */ 4128 if (fSuccess && !controller.isNull()) 4129 { 4130 /* Set storage controller attributes: */ 4131 controller.SetControllerType(enmControllerType); 4132 controller.SetUseHostIOCache(fUseHostIOCache); 4133 if (enmControllerBus == KStorageBus_SATA || enmControllerBus == KStorageBus_SAS) 4119 /* Get old controller data from the cache: */ 4120 const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base(); 4121 /* Get new controller data from the cache: */ 4122 const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data(); 4123 4124 /* Make sure controller really exists: */ 4125 CStorageController comController = m_machine.GetStorageControllerByName(oldControllerData.m_strControllerName); 4126 fSuccess = m_machine.isOk() && comController.isNotNull(); 4127 /* Show error message if necessary: */ 4128 if (!fSuccess) 4129 msgCenter().cannotSaveStorageSettings(m_machine, this); 4130 4131 /* Save controller type: */ 4132 if (fSuccess && newControllerData.m_controllerType != oldControllerData.m_controllerType) 4133 { 4134 comController.SetControllerType(newControllerData.m_controllerType); 4135 fSuccess = comController.isOk(); 4136 } 4137 /* Save whether controller uses IO cache: */ 4138 if (fSuccess && newControllerData.m_fUseHostIOCache != oldControllerData.m_fUseHostIOCache) 4139 { 4140 comController.SetUseHostIOCache(newControllerData.m_fUseHostIOCache); 4141 fSuccess = comController.isOk(); 4142 } 4143 /* Save controller port number: */ 4144 if ( fSuccess 4145 && newControllerData.m_uPortCount != oldControllerData.m_uPortCount 4146 && ( newControllerData.m_controllerBus == KStorageBus_SATA 4147 || newControllerData.m_controllerBus == KStorageBus_SAS 4148 || newControllerData.m_controllerBus == KStorageBus_PCIe)) 4149 { 4150 ULONG uNewPortCount = newControllerData.m_uPortCount; 4151 if (fSuccess) 4134 4152 { 4135 uPortCount = qMax(uPortCount, controller.GetMinPortCount()); 4136 uPortCount = qMin(uPortCount, controller.GetMaxPortCount()); 4137 controller.SetPortCount(uPortCount); 4153 uNewPortCount = qMax(uNewPortCount, comController.GetMinPortCount()); 4154 fSuccess = comController.isOk(); 4138 4155 } 4139 /* For each storage attachment: */ 4140 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 4156 if (fSuccess) 4141 4157 { 4142 /* Get storage attachment cache: */ 4143 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 4144 4145 /* Create attachments marked for 'create' and 'update' (if they can't be updated): */ 4146 if (attachmentCache.wasCreated() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache))) 4147 fSuccess = createStorageAttachment(controllerCache, attachmentCache); 4148 4149 else 4150 4151 /* Update attachments marked for 'update' (if they can be updated): */ 4152 if (attachmentCache.wasUpdated() && isAttachmentCouldBeUpdated(attachmentCache)) 4153 fSuccess = updateStorageAttachment(controllerCache, attachmentCache); 4158 uNewPortCount = qMin(uNewPortCount, comController.GetMaxPortCount()); 4159 fSuccess = comController.isOk(); 4154 4160 } 4161 if (fSuccess) 4162 { 4163 comController.SetPortCount(uNewPortCount); 4164 fSuccess = comController.isOk(); 4165 } 4166 } 4167 /* Show error message if necessary: */ 4168 if (!fSuccess) 4169 msgCenter().cannotSaveStorageControllerSettings(comController, this); 4170 4171 /* For each attachment ('removing' step): */ 4172 // We need to separately remove attachments first because 4173 // there could be limited amount of attachments available. 4174 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 4175 { 4176 /* Get attachment cache: */ 4177 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 4178 4179 /* Remove attachment marked for 'remove' or 'update' (if it can't be updated): */ 4180 if (attachmentCache.wasRemoved() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache))) 4181 fSuccess = removeStorageAttachment(controllerCache, attachmentCache); 4182 } 4183 4184 /* For each attachment ('creating' step): */ 4185 for (int iAttachmentIndex = 0; fSuccess && iAttachmentIndex < controllerCache.childCount(); ++iAttachmentIndex) 4186 { 4187 /* Get attachment cache: */ 4188 const UISettingsCacheMachineStorageAttachment &attachmentCache = controllerCache.child(iAttachmentIndex); 4189 4190 /* Create attachment marked for 'create' or 'update' (if it can't be updated): */ 4191 if (attachmentCache.wasCreated() || (attachmentCache.wasUpdated() && !isAttachmentCouldBeUpdated(attachmentCache))) 4192 fSuccess = createStorageAttachment(controllerCache, attachmentCache); 4193 4194 else 4195 4196 /* Update attachment marked for 'update' (if it can be updated): */ 4197 if (attachmentCache.wasUpdated() && isAttachmentCouldBeUpdated(attachmentCache)) 4198 fSuccess = updateStorageAttachment(controllerCache, attachmentCache); 4155 4199 } 4156 4200 } … … 4163 4207 { 4164 4208 /* Prepare result: */ 4165 bool fSuccess = m_machine.isOk(); 4209 bool fSuccess = true; 4210 /* Remove attachment: */ 4166 4211 if (fSuccess) 4167 4212 { 4168 /* Get old storage controller data from the cache: */ 4169 const UIDataSettingsMachineStorageController &controllerData = controllerCache.base(); 4170 /* Get old storage attachment data from the cache: */ 4171 const UIDataSettingsMachineStorageAttachment &attachmentData = attachmentCache.base(); 4172 4173 /* Get storage controller attributes: */ 4174 const QString strControllerName = controllerData.m_strControllerName; 4175 /* Get storage attachment attributes: */ 4176 const int iAttachmentPort = attachmentData.m_iAttachmentPort; 4177 const int iAttachmentDevice = attachmentData.m_iAttachmentDevice; 4178 4179 /* Check that storage attachment exists: */ 4180 const CMediumAttachment &attachment = m_machine.GetMediumAttachment(strControllerName, iAttachmentPort, iAttachmentDevice); 4181 /* Check that machine is OK: */ 4182 fSuccess = m_machine.isOk(); 4183 /* If attachment exists: */ 4184 if (fSuccess && !attachment.isNull()) 4185 { 4186 /* Remove storage attachment: */ 4187 m_machine.DetachDevice(strControllerName, iAttachmentPort, iAttachmentDevice); 4188 /* Check that machine is OK: */ 4213 /* Get old controller data from the cache: */ 4214 const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base(); 4215 /* Get old attachment data from the cache: */ 4216 const UIDataSettingsMachineStorageAttachment &oldAttachmentData = attachmentCache.base(); 4217 4218 /* Make sure attachment really exists: */ 4219 const CMediumAttachment &comAttachment = m_machine.GetMediumAttachment(oldControllerData.m_strControllerName, 4220 oldAttachmentData.m_iAttachmentPort, 4221 oldAttachmentData.m_iAttachmentDevice); 4222 fSuccess = m_machine.isOk() && comAttachment.isNotNull(); 4223 4224 /* Remove attachment: */ 4225 if (fSuccess) 4226 { 4227 m_machine.DetachDevice(oldControllerData.m_strControllerName, 4228 oldAttachmentData.m_iAttachmentPort, 4229 oldAttachmentData.m_iAttachmentDevice); 4189 4230 fSuccess = m_machine.isOk(); 4190 4231 } 4232 /* Show error message if necessary: */ 4233 if (!fSuccess) 4234 msgCenter().cannotSaveStorageSettings(m_machine, this); 4191 4235 } 4192 4236 /* Return result: */ … … 4198 4242 { 4199 4243 /* Prepare result: */ 4200 bool fSuccess = m_machine.isOk(); 4244 bool fSuccess = true; 4245 /* Create attachment: */ 4201 4246 if (fSuccess) 4202 4247 { 4203 /* Get new storage controller data from the cache: */ 4204 const UIDataSettingsMachineStorageController &controllerData = controllerCache.data(); 4205 /* Get new storage attachment data from the cache: */ 4206 const UIDataSettingsMachineStorageAttachment &attachmentData = attachmentCache.data(); 4207 4208 /* Get storage controller attributes: */ 4209 const QString strControllerName = controllerData.m_strControllerName; 4210 const KStorageBus enmControllerBus = controllerData.m_controllerBus; 4211 /* Get storage attachment attributes: */ 4212 const int iAttachmentPort = attachmentData.m_iAttachmentPort; 4213 const int iAttachmentDevice = attachmentData.m_iAttachmentDevice; 4214 const KDeviceType enmAttachmentDeviceType = attachmentData.m_attachmentType; 4215 const QString strAttachmentMediumId = attachmentData.m_strAttachmentMediumId; 4216 const bool fAttachmentPassthrough = attachmentData.m_fAttachmentPassthrough; 4217 const bool fAttachmentTempEject = attachmentData.m_fAttachmentTempEject; 4218 const bool fAttachmentNonRotational = attachmentData.m_fAttachmentNonRotational; 4219 const bool fAttachmentHotPluggable = attachmentData.m_fAttachmentHotPluggable; 4220 /* Get GUI medium object: */ 4221 const UIMedium vboxMedium = vboxGlobal().medium(strAttachmentMediumId); 4222 /* Get COM medium object: */ 4223 const CMedium comMedium = vboxMedium.medium(); 4224 4225 /* Check that storage attachment doesn't exists: */ 4226 const CMediumAttachment &attachment = m_machine.GetMediumAttachment(strControllerName, iAttachmentPort, iAttachmentDevice); 4227 /* Check that machine is not OK: */ 4228 fSuccess = !m_machine.isOk(); 4229 /* If attachment doesn't exists: */ 4230 if (fSuccess && attachment.isNull()) 4231 { 4232 /* Create storage attachment: */ 4233 m_machine.AttachDevice(strControllerName, iAttachmentPort, iAttachmentDevice, enmAttachmentDeviceType, comMedium); 4234 /* Check that machine is OK: */ 4248 /* Get new controller data from the cache: */ 4249 const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data(); 4250 /* Get new attachment data from the cache: */ 4251 const UIDataSettingsMachineStorageAttachment &newAttachmentData = attachmentCache.data(); 4252 4253 /* Make sure attachment doesn't exist: */ 4254 const CMachine comMachine(m_machine); 4255 const CMediumAttachment &comAttachment = comMachine.GetMediumAttachment(newControllerData.m_strControllerName, 4256 newAttachmentData.m_iAttachmentPort, 4257 newAttachmentData.m_iAttachmentDevice); 4258 fSuccess = !comMachine.isOk() && comAttachment.isNull(); 4259 AssertReturn(fSuccess, false); 4260 4261 /* Create attachment: */ 4262 if (fSuccess) 4263 { 4264 const UIMedium vboxMedium = vboxGlobal().medium(newAttachmentData.m_strAttachmentMediumId); 4265 const CMedium comMedium = vboxMedium.medium(); 4266 m_machine.AttachDevice(newControllerData.m_strControllerName, 4267 newAttachmentData.m_iAttachmentPort, 4268 newAttachmentData.m_iAttachmentDevice, 4269 newAttachmentData.m_attachmentType, 4270 comMedium); 4235 4271 fSuccess = m_machine.isOk(); 4272 } 4273 if (newAttachmentData.m_attachmentType == KDeviceType_DVD) 4274 { 4275 /* Save whether this is a passthrough device: */ 4276 if (fSuccess && isMachineOffline()) 4277 { 4278 m_machine.PassthroughDevice(newControllerData.m_strControllerName, 4279 newAttachmentData.m_iAttachmentPort, 4280 newAttachmentData.m_iAttachmentDevice, 4281 newAttachmentData.m_fAttachmentPassthrough); 4282 fSuccess = m_machine.isOk(); 4283 } 4284 /* Save whether this is a live cd device: */ 4236 4285 if (fSuccess) 4237 4286 { 4238 if (enmAttachmentDeviceType == KDeviceType_DVD) 4239 { 4240 if (fSuccess && isMachineOffline()) 4241 { 4242 m_machine.PassthroughDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentPassthrough); 4243 /* Check that machine is OK: */ 4244 fSuccess = m_machine.isOk(); 4245 } 4246 if (fSuccess && isMachineInValidMode()) 4247 { 4248 m_machine.TemporaryEjectDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentTempEject); 4249 /* Check that machine is OK: */ 4250 fSuccess = m_machine.isOk(); 4251 } 4252 } 4253 else if (enmAttachmentDeviceType == KDeviceType_HardDisk) 4254 { 4255 if (fSuccess && isMachineOffline()) 4256 { 4257 m_machine.NonRotationalDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentNonRotational); 4258 /* Check that machine is OK: */ 4259 fSuccess = m_machine.isOk(); 4260 } 4261 } 4262 if ((enmControllerBus == KStorageBus_SATA) || (enmControllerBus == KStorageBus_USB)) 4263 { 4264 if (fSuccess && isMachineOffline()) 4265 { 4266 m_machine.SetHotPluggableForDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentHotPluggable); 4267 /* Check that machine is OK: */ 4268 fSuccess = m_machine.isOk(); 4269 } 4270 } 4287 m_machine.TemporaryEjectDevice(newControllerData.m_strControllerName, 4288 newAttachmentData.m_iAttachmentPort, 4289 newAttachmentData.m_iAttachmentDevice, 4290 newAttachmentData.m_fAttachmentTempEject); 4291 fSuccess = m_machine.isOk(); 4271 4292 } 4272 else 4293 } 4294 else if (newAttachmentData.m_attachmentType == KDeviceType_HardDisk) 4295 { 4296 /* Save whether this is a ssd device: */ 4297 if (fSuccess && isMachineOffline()) 4273 4298 { 4274 /* Show error message: */ 4275 msgCenter().cannotAttachDevice(m_machine, mediumTypeToLocal(enmAttachmentDeviceType), 4276 vboxMedium.location(), 4277 StorageSlot(enmControllerBus, iAttachmentPort, iAttachmentDevice), this); 4299 m_machine.NonRotationalDevice(newControllerData.m_strControllerName, 4300 newAttachmentData.m_iAttachmentPort, 4301 newAttachmentData.m_iAttachmentDevice, 4302 newAttachmentData.m_fAttachmentNonRotational); 4303 fSuccess = m_machine.isOk(); 4278 4304 } 4279 4305 } 4306 if (newControllerData.m_controllerBus == KStorageBus_SATA || newControllerData.m_controllerBus == KStorageBus_USB) 4307 { 4308 /* Save whether this device is hot-pluggable: */ 4309 if (fSuccess && isMachineOffline()) 4310 { 4311 m_machine.SetHotPluggableForDevice(newControllerData.m_strControllerName, 4312 newAttachmentData.m_iAttachmentPort, 4313 newAttachmentData.m_iAttachmentDevice, 4314 newAttachmentData.m_fAttachmentHotPluggable); 4315 fSuccess = m_machine.isOk(); 4316 } 4317 } 4318 /* Show error message if necessary: */ 4319 if (!fSuccess) 4320 msgCenter().cannotSaveStorageSettings(m_machine, this); 4280 4321 } 4281 4322 /* Return result: */ … … 4287 4328 { 4288 4329 /* Prepare result: */ 4289 bool fSuccess = m_machine.isOk(); 4330 bool fSuccess = true; 4331 /* Update attachment: */ 4290 4332 if (fSuccess) 4291 4333 { 4292 /* Get new storage controller data from the cache: */ 4293 const UIDataSettingsMachineStorageController &controllerData = controllerCache.data(); 4294 /* Get new storage attachment data from the cache: */ 4295 const UIDataSettingsMachineStorageAttachment &attachmentData = attachmentCache.data(); 4296 4297 /* Get storage controller attributes: */ 4298 const QString strControllerName = controllerData.m_strControllerName; 4299 const KStorageBus enmControllerBus = controllerData.m_controllerBus; 4300 /* Get storage attachment attributes: */ 4301 const int iAttachmentPort = attachmentData.m_iAttachmentPort; 4302 const int iAttachmentDevice = attachmentData.m_iAttachmentDevice; 4303 const QString strAttachmentMediumId = attachmentData.m_strAttachmentMediumId; 4304 const bool fAttachmentPassthrough = attachmentData.m_fAttachmentPassthrough; 4305 const bool fAttachmentTempEject = attachmentData.m_fAttachmentTempEject; 4306 const bool fAttachmentNonRotational = attachmentData.m_fAttachmentNonRotational; 4307 const bool fAttachmentHotPluggable = attachmentData.m_fAttachmentHotPluggable; 4308 const KDeviceType enmAttachmentDeviceType = attachmentData.m_attachmentType; 4309 4310 /* Check that storage attachment exists: */ 4311 const CMediumAttachment attachment = m_machine.GetMediumAttachment(strControllerName, iAttachmentPort, iAttachmentDevice); 4312 /* Check that machine is OK: */ 4313 fSuccess = m_machine.isOk(); 4314 /* If attachment exists: */ 4315 if (fSuccess && !attachment.isNull()) 4316 { 4317 /* Get GUI medium object: */ 4318 const UIMedium vboxMedium = vboxGlobal().medium(strAttachmentMediumId); 4319 /* Get COM medium object: */ 4334 /* Get new controller data from the cache: */ 4335 const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data(); 4336 /* Get new attachment data from the cache: */ 4337 const UIDataSettingsMachineStorageAttachment &newAttachmentData = attachmentCache.data(); 4338 4339 /* Make sure attachment really exists: */ 4340 const CMediumAttachment &comAttachment = m_machine.GetMediumAttachment(newControllerData.m_strControllerName, 4341 newAttachmentData.m_iAttachmentPort, 4342 newAttachmentData.m_iAttachmentDevice); 4343 fSuccess = m_machine.isOk() && comAttachment.isNotNull(); 4344 /* Show error message if necessary: */ 4345 if (!fSuccess) 4346 msgCenter().cannotSaveStorageSettings(m_machine, this); 4347 4348 /* Remount attachment: */ 4349 if (fSuccess) 4350 { 4351 const UIMedium vboxMedium = vboxGlobal().medium(newAttachmentData.m_strAttachmentMediumId); 4320 4352 const CMedium comMedium = vboxMedium.medium(); 4321 /* Remount storage attachment: */ 4322 m_machine.MountMedium(strControllerName, iAttachmentPort, iAttachmentDevice, comMedium, true /* force? */); 4323 /* Check that machine is OK: */ 4353 m_machine.MountMedium(newControllerData.m_strControllerName, 4354 newAttachmentData.m_iAttachmentPort, 4355 newAttachmentData.m_iAttachmentDevice, 4356 comMedium, 4357 true /* force? */); 4324 4358 fSuccess = m_machine.isOk(); 4359 } 4360 if (newAttachmentData.m_attachmentType == KDeviceType_DVD) 4361 { 4362 /* Save whether this is a passthrough device: */ 4363 if (fSuccess && isMachineOffline()) 4364 { 4365 m_machine.PassthroughDevice(newControllerData.m_strControllerName, 4366 newAttachmentData.m_iAttachmentPort, 4367 newAttachmentData.m_iAttachmentDevice, 4368 newAttachmentData.m_fAttachmentPassthrough); 4369 fSuccess = m_machine.isOk(); 4370 } 4371 /* Save whether this is a live cd device: */ 4325 4372 if (fSuccess) 4326 4373 { 4327 if (enmAttachmentDeviceType == KDeviceType_DVD) 4328 { 4329 if (fSuccess && isMachineOffline()) 4330 { 4331 m_machine.PassthroughDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentPassthrough); 4332 /* Check that machine is OK: */ 4333 fSuccess = m_machine.isOk(); 4334 } 4335 if (fSuccess && isMachineInValidMode()) 4336 { 4337 m_machine.TemporaryEjectDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentTempEject); 4338 /* Check that machine is OK: */ 4339 fSuccess = m_machine.isOk(); 4340 } 4341 } 4342 else if (enmAttachmentDeviceType == KDeviceType_HardDisk) 4343 { 4344 if (fSuccess && isMachineOffline()) 4345 { 4346 m_machine.NonRotationalDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentNonRotational); 4347 /* Check that machine is OK: */ 4348 fSuccess = m_machine.isOk(); 4349 } 4350 } 4351 if ((enmControllerBus == KStorageBus_SATA) || (enmControllerBus == KStorageBus_USB)) 4352 { 4353 if (fSuccess && isMachineOffline()) 4354 { 4355 m_machine.SetHotPluggableForDevice(strControllerName, iAttachmentPort, iAttachmentDevice, fAttachmentHotPluggable); 4356 /* Check that machine is OK: */ 4357 fSuccess = m_machine.isOk(); 4358 } 4359 } 4374 m_machine.TemporaryEjectDevice(newControllerData.m_strControllerName, 4375 newAttachmentData.m_iAttachmentPort, 4376 newAttachmentData.m_iAttachmentDevice, 4377 newAttachmentData.m_fAttachmentTempEject); 4378 fSuccess = m_machine.isOk(); 4360 4379 } 4361 else 4380 } 4381 else if (newAttachmentData.m_attachmentType == KDeviceType_HardDisk) 4382 { 4383 /* Save whether this is a ssd device: */ 4384 if (fSuccess && isMachineOffline()) 4362 4385 { 4363 /* Show error message: */ 4364 msgCenter().cannotAttachDevice(m_machine, mediumTypeToLocal(enmAttachmentDeviceType), 4365 vboxMedium.location(), 4366 StorageSlot(enmControllerBus, iAttachmentPort, iAttachmentDevice), this); 4386 m_machine.NonRotationalDevice(newControllerData.m_strControllerName, 4387 newAttachmentData.m_iAttachmentPort, 4388 newAttachmentData.m_iAttachmentDevice, 4389 newAttachmentData.m_fAttachmentNonRotational); 4390 fSuccess = m_machine.isOk(); 4367 4391 } 4368 4392 } 4393 if (newControllerData.m_controllerBus == KStorageBus_SATA || newControllerData.m_controllerBus == KStorageBus_USB) 4394 { 4395 /* Save whether this device is hot-pluggable: */ 4396 if (fSuccess && isMachineOffline()) 4397 { 4398 m_machine.SetHotPluggableForDevice(newControllerData.m_strControllerName, 4399 newAttachmentData.m_iAttachmentPort, 4400 newAttachmentData.m_iAttachmentDevice, 4401 newAttachmentData.m_fAttachmentHotPluggable); 4402 fSuccess = m_machine.isOk(); 4403 } 4404 } 4405 /* Show error message if necessary: */ 4406 if (!fSuccess) 4407 msgCenter().cannotSaveStorageSettings(m_machine, this); 4369 4408 } 4370 4409 /* Return result: */ … … 4374 4413 bool UIMachineSettingsStorage::isControllerCouldBeUpdated(const UISettingsCacheMachineStorageController &controllerCache) const 4375 4414 { 4376 /* IController interface doesn't allows to change 'name' and 'bus' attributes. 4377 * But those attributes could be changed in GUI directly or indirectly. 4415 /* IController interface doesn't allow to change 'bus' attribute but allows 4416 * to change 'name' attribute which can conflict with another one controller. 4417 * Both those attributes could be changed in GUI directly or indirectly. 4378 4418 * For such cases we have to recreate IController instance, 4379 4419 * for other cases we will update controller attributes only. */ 4380 4420 const UIDataSettingsMachineStorageController &oldControllerData = controllerCache.base(); 4381 4421 const UIDataSettingsMachineStorageController &newControllerData = controllerCache.data(); 4382 return newControllerData.m_controllerBus == oldControllerData.m_controllerBus && 4383 newControllerData.m_strControllerName == oldControllerData.m_strControllerName; 4422 return true 4423 && (newControllerData.m_strControllerName == oldControllerData.m_strControllerName) 4424 && (newControllerData.m_controllerBus == oldControllerData.m_controllerBus) 4425 ; 4384 4426 } 4385 4427 … … 4392 4434 const UIDataSettingsMachineStorageAttachment &oldAttachmentData = attachmentCache.base(); 4393 4435 const UIDataSettingsMachineStorageAttachment &newAttachmentData = attachmentCache.data(); 4394 const KDeviceType enmInitialAttachmentDeviceType = oldAttachmentData.m_attachmentType; 4395 const KDeviceType enmCurrentAttachmentDeviceType = newAttachmentData.m_attachmentType; 4396 const LONG iInitialAttachmentDevice = oldAttachmentData.m_iAttachmentDevice; 4397 const LONG iCurrentAttachmentDevice = newAttachmentData.m_iAttachmentDevice; 4398 const LONG iInitialAttachmentPort = oldAttachmentData.m_iAttachmentPort; 4399 const LONG iCurrentAttachmentPort = newAttachmentData.m_iAttachmentPort; 4400 return (enmCurrentAttachmentDeviceType == enmInitialAttachmentDeviceType) && 4401 (iCurrentAttachmentDevice == iInitialAttachmentDevice) && 4402 (iCurrentAttachmentPort == iInitialAttachmentPort) && 4403 (enmCurrentAttachmentDeviceType == KDeviceType_Floppy || enmCurrentAttachmentDeviceType == KDeviceType_DVD); 4436 return true 4437 && (newAttachmentData.m_attachmentType == oldAttachmentData.m_attachmentType) 4438 && (newAttachmentData.m_iAttachmentPort == oldAttachmentData.m_iAttachmentPort) 4439 && (newAttachmentData.m_iAttachmentDevice == oldAttachmentData.m_iAttachmentDevice) 4440 && (newAttachmentData.m_attachmentType == KDeviceType_Floppy || newAttachmentData.m_attachmentType == KDeviceType_DVD) 4441 ; 4404 4442 } 4405 4443 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsStorage.h
r66541 r66543 768 768 void addRecentMediumActions(QMenu *pOpenMediumMenu, UIMediumType enmRecentMediumType); 769 769 770 /** Updates existing storage data from the cache. */771 bool updateStorageData();770 /** Saves existing storage data from the cache. */ 771 bool saveStorageData(); 772 772 /** Removes existing storage controller described by the @a controllerCache. */ 773 773 bool removeStorageController(const UISettingsCacheMachineStorageController &controllerCache);
Note:
See TracChangeset
for help on using the changeset viewer.

