Changeset 107090 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Nov 21, 2024 3:44:25 PM (3 months ago)
- svn:sync-xref-src-repo-rev:
- 166048
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r106707 r107090 693 693 QApplication::translate("UIMessageCenter", "Storage controller failure ..."), 694 694 QApplication::translate("UIMessageCenter", "Failed to acquire storage controller parameter.") + 695 UIErrorString::formatErrorInfo(comStorageController)); 696 } 697 698 /* static */ 699 void UINotificationMessage::cannotChangeStorageControllerParameter(const CStorageController &comStorageController) 700 { 701 createMessage( 702 QApplication::translate("UIMessageCenter", "Storage controller failure ..."), 703 QApplication::translate("UIMessageCenter", "Failed to change storage controller parameter.") + 695 704 UIErrorString::formatErrorInfo(comStorageController)); 696 705 } -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r106312 r107090 307 307 * @param comStorageController Brings the object parameter get acquired from. */ 308 308 static void cannotAcquireStorageControllerParameter(const CStorageController &comStorageController); 309 /** Notifies about inability to change IStorageController parameter. 310 * @param comStorageController Brings the object parameter being changed for. */ 311 static void cannotChangeStorageControllerParameter(const CStorageController &comStorageController); 309 312 /** Notifies about inability to acquire IMediumAttachment parameter. 310 313 * @param comMediumAttachment Brings the object parameter get acquired from. */ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r107002 r107090 284 284 { 285 285 KStorageBus enmHDDBus = gpGlobalSession->guestOSTypeManager().getRecommendedHDStorageBus(m_guestOSTypeId); 286 CStorageController comHDDController = m _machine.GetStorageControllerByInstance(enmHDDBus, 0);286 CStorageController comHDDController = machine.GetStorageControllerByInstance(enmHDDBus, 0); 287 287 if (!comHDDController.isNull()) 288 288 { 289 machine.AttachDevice(comHDDController.GetName(), 0, 0, KDeviceType_HardDisk, m_virtualDisk); 289 LONG uPortNumber = portNumberForDevice(comHDDController); 290 machine.AttachDevice(comHDDController.GetName(), uPortNumber, 0, KDeviceType_HardDisk, m_virtualDisk); 290 291 if (!machine.isOk()) 291 292 UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, m_strMediumPath, 292 StorageSlot(enmHDDBus, 0, 0), notificationCenter());293 StorageSlot(enmHDDBus, uPortNumber, 0), notificationCenter()); 293 294 } 295 } 296 /* Save machine settings here because portNumberForDevice needs to inquiry port attachments of the controller: */ 297 if (machine.isOk()) 298 { 299 machine.SaveSettings(); 300 if (machine.isOk()) 301 success = true; 302 else 303 UINotificationMessage::cannotSaveMachineSettings(machine, notificationCenter()); 294 304 } 295 305 296 306 /* Attach optical drive: */ 297 307 KStorageBus enmDVDBus = gpGlobalSession->guestOSTypeManager().getRecommendedDVDStorageBus(m_guestOSTypeId); 298 CStorageController comDVDController = m _machine.GetStorageControllerByInstance(enmDVDBus, 0);308 CStorageController comDVDController = machine.GetStorageControllerByInstance(enmDVDBus, 0); 299 309 if (!comDVDController.isNull()) 300 310 { … … 309 319 UINotificationMessage::cannotOpenMedium(vbox, strISOFilePath, notificationCenter()); 310 320 } 311 machine.AttachDevice(comDVDController.GetName(), 1, 0, KDeviceType_DVD, opticalDisk); 321 LONG uPortNumber = portNumberForDevice(comDVDController); 322 machine.AttachDevice(comDVDController.GetName(), uPortNumber, 0, KDeviceType_DVD, opticalDisk); 312 323 if (!machine.isOk()) 313 324 UINotificationMessage::cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(), 314 325 StorageSlot(enmDVDBus, 1, 0), notificationCenter()); 315 326 } 327 /* Save machine settings here because portNumberForDevice needs to inquiry port attachments of the controller: */ 328 if (machine.isOk()) 329 { 330 machine.SaveSettings(); 331 if (machine.isOk()) 332 success = true; 333 else 334 UINotificationMessage::cannotSaveMachineSettings(machine, notificationCenter()); 335 } 316 336 317 337 /* Attach an empty floppy drive if recommended */ 318 338 if (gpGlobalSession->guestOSTypeManager().getRecommendedFloppy(m_guestOSTypeId)) 319 339 { 320 CStorageController comFloppyController = m _machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0);340 CStorageController comFloppyController = machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0); 321 341 if (!comFloppyController.isNull()) 322 342 { … … 830 850 return true; 831 851 } 852 853 LONG UIWizardNewVM::portNumberForDevice(CStorageController &comController) 854 { 855 QVector<CMediumAttachment> attachments = m_machine.GetMediumAttachmentsOfController(comController.GetName()); 856 QVector<LONG> attachmentPorts(attachments.size(), -1); 857 for (int i = 0; i < attachmentPorts.size(); ++i) 858 attachmentPorts[i] = attachments[i].GetPort(); 859 LONG portCount = comController.GetPortCount(); 860 /* Check if any of the ports in range [0, portCount) is unused. If so return it: */ 861 for (int i = 0; i < portCount; ++i) 862 { 863 if (!attachmentPorts.contains(i)) 864 return i; 865 } 866 867 868 if (!comController.isOk()) 869 { 870 UINotificationMessage::cannotAcquireStorageControllerParameter(comController); 871 return -1; 872 } 873 /* Check if we can increase the port count: */ 874 if (portCount + 1 >= (LONG)comController.GetMaxPortCount()) 875 { 876 UINotificationMessage::cannotChangeStorageControllerParameter(comController); 877 return -1; 878 } 879 comController.SetPortCount(portCount + 1); 880 if (!comController.isOk()) 881 { 882 UINotificationMessage::cannotChangeStorageControllerParameter(comController); 883 return -1; 884 } 885 /* Use the last port: */ 886 return comController.GetPortCount() - 1; 887 } -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
r106061 r107090 43 43 /* Forward declarations: */ 44 44 class UIActionPool; 45 class CStorageController; 45 46 46 47 enum SelectedDiskSource … … 188 189 void deleteVirtualDisk(); 189 190 bool checkUnattendedInstallError(const CUnattended &comUnattended) const; 191 LONG portNumberForDevice(CStorageController &comController); 190 192 /** @name Variables 191 193 * @{ */
Note:
See TracChangeset
for help on using the changeset viewer.