- Timestamp:
- Jul 8, 2021 10:30:48 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 145589
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.cpp
r90085 r90090 110 110 bool UIWizardNewVM::createVM() 111 111 { 112 // /* Get VBox object: */ 113 // CVirtualBox vbox = uiCommon().virtualBox(); 114 115 // /* OS type: */ 116 // CGuestOSType type = field("type").value<CGuestOSType>(); 117 // QString strTypeId = type.GetId(); 118 119 // /* Create virtual machine: */ 120 // if (m_machine.isNull()) 121 // { 122 // QVector<QString> groups; 123 // if (!m_strMachineGroup.isEmpty()) 124 // groups << m_strMachineGroup; 125 // m_machine = vbox.CreateMachine(field("machineFilePath").toString(), 126 // field("name").toString(), 127 // groups, strTypeId, QString()); 128 // if (!vbox.isOk()) 129 // { 130 // msgCenter().cannotCreateMachine(vbox, this); 131 // return false; 132 // } 133 134 // /* The First RUN Wizard is to be shown: 135 // * 1. if we don't attach any virtual hard-drive 136 // * 2. or attach a new (empty) one. 137 // * 3. and if the unattended install is not enabled 138 // * 4. User did not select an ISO image file 139 // * Usually we are assigning extra-data values through UIExtraDataManager, 140 // * but in that special case VM was not registered yet, so UIExtraDataManager is unaware of it: */ 141 // if (ISOFilePath().isEmpty() && 142 // !isUnattendedEnabled() && 143 // !m_virtualDisk.isNull()) 144 // m_machine.SetExtraData(GUI_FirstRun, "yes"); 145 // } 146 147 // #if 0 148 // /* Configure the newly created vm here in GUI by several calls to API: */ 149 // configureVM(strTypeId, type); 150 // #else 151 // /* The newer and less tested way of configuring vms: */ 152 // m_machine.ApplyDefaults(QString()); 153 // /* Apply user preferences again. IMachine::applyDefaults may have overwritten the user setting: */ 154 // m_machine.SetMemorySize(field("baseMemory").toUInt()); 155 // int iVPUCount = qMax((unsigned)1, field("VCPUCount").toUInt()); 156 // m_machine.SetCPUCount(iVPUCount); 157 // /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */ 158 // CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter(); 159 // comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(strTypeId) / _1M))); 160 // /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */ 161 // if (iVPUCount > 1) 162 // m_machine.GetBIOSSettings().SetIOAPICEnabled(true); 163 164 // /* Set recommended firmware type: */ 165 // m_machine.SetFirmwareType(getBoolFieldValue("EFIEnabled") ? KFirmwareType_EFI : KFirmwareType_BIOS); 166 // #endif 167 168 // /* Register the VM prior to attaching hard disks: */ 169 // vbox.RegisterMachine(m_machine); 170 // if (!vbox.isOk()) 171 // { 172 // msgCenter().cannotRegisterMachine(vbox, m_machine.GetName(), this); 173 // return false; 174 // } 175 // return attachDefaultDevices(type); 176 return true; 112 CVirtualBox vbox = uiCommon().virtualBox(); 113 QString strTypeId = m_comGuestOSType.GetId(); 114 115 /* Create virtual machine: */ 116 if (m_machine.isNull()) 117 { 118 QVector<QString> groups; 119 if (!m_strMachineGroup.isEmpty()) 120 groups << m_strMachineGroup; 121 m_machine = vbox.CreateMachine(m_strMachineFilePath, 122 m_strMachineBaseName, 123 groups, strTypeId, QString()); 124 if (!vbox.isOk()) 125 { 126 msgCenter().cannotCreateMachine(vbox, this); 127 return false; 128 } 129 130 /* The First RUN Wizard is to be shown: 131 * 1. if we don't attach any virtual hard-drive 132 * 2. or attach a new (empty) one. 133 * 3. and if the unattended install is not enabled 134 * 4. User did not select an ISO image file 135 * Usually we are assigning extra-data values through UIExtraDataManager, 136 * but in that special case VM was not registered yet, so UIExtraDataManager is unaware of it: */ 137 if (ISOFilePath().isEmpty() && 138 !isUnattendedEnabled() && 139 !m_virtualDisk.isNull()) 140 m_machine.SetExtraData(GUI_FirstRun, "yes"); 141 } 142 143 #if 0 144 /* Configure the newly created vm here in GUI by several calls to API: */ 145 configureVM(strTypeId, m_comGuestOSType); 146 #else 147 /* The newer and less tested way of configuring vms: */ 148 m_machine.ApplyDefaults(QString()); 149 /* Apply user preferences again. IMachine::applyDefaults may have overwritten the user setting: */ 150 m_machine.SetMemorySize(m_iMemorySize); 151 int iVPUCount = qMax(1, m_iCPUCount); 152 m_machine.SetCPUCount(iVPUCount); 153 /* Correct the VRAM size since API does not take fullscreen memory requirements into account: */ 154 CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter(); 155 comGraphics.SetVRAMSize(qMax(comGraphics.GetVRAMSize(), (ULONG)(UICommon::requiredVideoMemory(strTypeId) / _1M))); 156 /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */ 157 if (iVPUCount > 1) 158 m_machine.GetBIOSSettings().SetIOAPICEnabled(true); 159 160 /* Set recommended firmware type: */ 161 m_machine.SetFirmwareType(m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS); 162 #endif 163 164 /* Register the VM prior to attaching hard disks: */ 165 vbox.RegisterMachine(m_machine); 166 if (!vbox.isOk()) 167 { 168 msgCenter().cannotRegisterMachine(vbox, m_machine.GetName(), this); 169 return false; 170 } 171 return attachDefaultDevices(); 177 172 } 178 173 … … 257 252 Q_UNUSED(strGuestTypeId); 258 253 Q_UNUSED(comGuestType); 259 // /* Get graphics adapter: */ 260 // CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter(); 261 262 // /* RAM size: */ 263 // m_machine.SetMemorySize(field("baseMemory").toInt()); 264 265 // /* VCPU count: */ 266 // int iVPUCount = qMax((unsigned)1, field("VCPUCount").toUInt()); 267 // m_machine.SetCPUCount(iVPUCount); 268 269 // /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */ 270 // if (iVPUCount > 1) 271 // m_machine.GetBIOSSettings().SetIOAPICEnabled(true); 272 273 // /* Graphics Controller type: */ 274 // comGraphics.SetGraphicsControllerType(comGuestType.GetRecommendedGraphicsController()); 275 276 // /* VRAM size - select maximum between recommended and minimum for fullscreen: */ 277 // comGraphics.SetVRAMSize(qMax(comGuestType.GetRecommendedVRAM(), (ULONG)(UICommon::requiredVideoMemory(strGuestTypeId) / _1M))); 278 279 // /* Selecting recommended chipset type: */ 280 // m_machine.SetChipsetType(comGuestType.GetRecommendedChipset()); 281 282 // /* Selecting recommended Audio Controller: */ 283 // m_machine.GetAudioAdapter().SetAudioController(comGuestType.GetRecommendedAudioController()); 284 // /* And the Audio Codec: */ 285 // m_machine.GetAudioAdapter().SetAudioCodec(comGuestType.GetRecommendedAudioCodec()); 286 // /* Enabling audio by default: */ 287 // m_machine.GetAudioAdapter().SetEnabled(true); 288 // m_machine.GetAudioAdapter().SetEnabledOut(true); 289 290 // /* Enable the OHCI and EHCI controller by default for new VMs. (new in 2.2): */ 291 // CUSBDeviceFilters usbDeviceFilters = m_machine.GetUSBDeviceFilters(); 292 // bool fOhciEnabled = false; 293 // if (!usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB3() && m_machine.GetUSBProxyAvailable()) 294 // { 295 // /* USB 3.0 is only available if the proper ExtPack is installed: */ 296 // CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager(); 297 // if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName)) 298 // { 299 // m_machine.AddUSBController("XHCI", KUSBControllerType_XHCI); 300 // /* xHCI includes OHCI */ 301 // fOhciEnabled = true; 302 // } 303 // } 304 // if ( !fOhciEnabled 305 // && !usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB() && m_machine.GetUSBProxyAvailable()) 306 // { 307 // m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI); 308 // fOhciEnabled = true; 309 // /* USB 2.0 is only available if the proper ExtPack is installed. 310 // * Note. Configuring EHCI here and providing messages about 311 // * the missing extpack isn't exactly clean, but it is a 312 // * necessary evil to patch over legacy compatability issues 313 // * introduced by the new distribution model. */ 314 // CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager(); 315 // if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName)) 316 // m_machine.AddUSBController("EHCI", KUSBControllerType_EHCI); 317 // } 318 319 // /* Create a floppy controller if recommended: */ 320 // QString strFloppyName = getNextControllerName(KStorageBus_Floppy); 321 // if (comGuestType.GetRecommendedFloppy()) 322 // { 323 // m_machine.AddStorageController(strFloppyName, KStorageBus_Floppy); 324 // CStorageController flpCtr = m_machine.GetStorageControllerByName(strFloppyName); 325 // flpCtr.SetControllerType(KStorageControllerType_I82078); 326 // } 327 328 // /* Create recommended DVD storage controller: */ 329 // KStorageBus strDVDBus = comGuestType.GetRecommendedDVDStorageBus(); 330 // QString strDVDName = getNextControllerName(strDVDBus); 331 // m_machine.AddStorageController(strDVDName, strDVDBus); 332 333 // /* Set recommended DVD storage controller type: */ 334 // CStorageController dvdCtr = m_machine.GetStorageControllerByName(strDVDName); 335 // KStorageControllerType dvdStorageControllerType = comGuestType.GetRecommendedDVDStorageController(); 336 // dvdCtr.SetControllerType(dvdStorageControllerType); 337 338 // /* Create recommended HD storage controller if it's not the same as the DVD controller: */ 339 // KStorageBus ctrHDBus = comGuestType.GetRecommendedHDStorageBus(); 340 // KStorageControllerType hdStorageControllerType = comGuestType.GetRecommendedHDStorageController(); 341 // CStorageController hdCtr; 342 // QString strHDName; 343 // if (ctrHDBus != strDVDBus || hdStorageControllerType != dvdStorageControllerType) 344 // { 345 // strHDName = getNextControllerName(ctrHDBus); 346 // m_machine.AddStorageController(strHDName, ctrHDBus); 347 // hdCtr = m_machine.GetStorageControllerByName(strHDName); 348 // hdCtr.SetControllerType(hdStorageControllerType); 349 // } 350 // else 351 // { 352 // /* The HD controller is the same as DVD: */ 353 // hdCtr = dvdCtr; 354 // strHDName = strDVDName; 355 // } 356 357 // /* Limit the AHCI port count if it's used because windows has trouble with 358 // too many ports and other guest (OS X in particular) may take extra long 359 // to boot: */ 360 // if (hdStorageControllerType == KStorageControllerType_IntelAhci) 361 // hdCtr.SetPortCount(1 + (dvdStorageControllerType == KStorageControllerType_IntelAhci)); 362 // else if (dvdStorageControllerType == KStorageControllerType_IntelAhci) 363 // dvdCtr.SetPortCount(1); 364 365 // /* Turn on PAE, if recommended: */ 366 // m_machine.SetCPUProperty(KCPUPropertyType_PAE, comGuestType.GetRecommendedPAE()); 367 368 // /* Set the recommended triple fault behavior: */ 369 // m_machine.SetCPUProperty(KCPUPropertyType_TripleFaultReset, comGuestType.GetRecommendedTFReset()); 370 371 // /* Set recommended firmware type: */ 372 // m_machine.SetFirmwareType(getBoolFieldValue("EFIEnabled") ? KFirmwareType_EFI : KFirmwareType_BIOS); 373 374 // /* Set recommended human interface device types: */ 375 // if (comGuestType.GetRecommendedUSBHID()) 376 // { 377 // m_machine.SetKeyboardHIDType(KKeyboardHIDType_USBKeyboard); 378 // m_machine.SetPointingHIDType(KPointingHIDType_USBMouse); 379 // if (!fOhciEnabled && !usbDeviceFilters.isNull()) 380 // m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI); 381 // } 382 383 // if (comGuestType.GetRecommendedUSBTablet()) 384 // { 385 // m_machine.SetPointingHIDType(KPointingHIDType_USBTablet); 386 // if (!fOhciEnabled && !usbDeviceFilters.isNull()) 387 // m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI); 388 // } 389 390 // /* Set HPET flag: */ 391 // m_machine.SetHPETEnabled(comGuestType.GetRecommendedHPET()); 392 393 // /* Set UTC flags: */ 394 // m_machine.SetRTCUseUTC(comGuestType.GetRecommendedRTCUseUTC()); 395 396 // /* Set graphic bits: */ 397 // if (comGuestType.GetRecommended2DVideoAcceleration()) 398 // comGraphics.SetAccelerate2DVideoEnabled(comGuestType.GetRecommended2DVideoAcceleration()); 399 400 // if (comGuestType.GetRecommended3DAcceleration()) 401 // comGraphics.SetAccelerate3DEnabled(comGuestType.GetRecommended3DAcceleration()); 402 } 403 404 bool UIWizardNewVM::attachDefaultDevices(const CGuestOSType &comGuestType) 405 { 406 Q_UNUSED(comGuestType); 254 /* Get graphics adapter: */ 255 CGraphicsAdapter comGraphics = m_machine.GetGraphicsAdapter(); 256 257 /* RAM size: */ 258 m_machine.SetMemorySize(m_iMemorySize); 259 260 /* VCPU count: */ 261 int iVPUCount = qMax(1, m_iCPUCount); 262 m_machine.SetCPUCount(iVPUCount); 263 264 /* Enabled I/O APIC explicitly in we have more than 1 VCPU: */ 265 if (iVPUCount > 1) 266 m_machine.GetBIOSSettings().SetIOAPICEnabled(true); 267 268 /* Graphics Controller type: */ 269 comGraphics.SetGraphicsControllerType(comGuestType.GetRecommendedGraphicsController()); 270 271 /* VRAM size - select maximum between recommended and minimum for fullscreen: */ 272 comGraphics.SetVRAMSize(qMax(comGuestType.GetRecommendedVRAM(), (ULONG)(UICommon::requiredVideoMemory(strGuestTypeId) / _1M))); 273 274 /* Selecting recommended chipset type: */ 275 m_machine.SetChipsetType(comGuestType.GetRecommendedChipset()); 276 277 /* Selecting recommended Audio Controller: */ 278 m_machine.GetAudioAdapter().SetAudioController(comGuestType.GetRecommendedAudioController()); 279 /* And the Audio Codec: */ 280 m_machine.GetAudioAdapter().SetAudioCodec(comGuestType.GetRecommendedAudioCodec()); 281 /* Enabling audio by default: */ 282 m_machine.GetAudioAdapter().SetEnabled(true); 283 m_machine.GetAudioAdapter().SetEnabledOut(true); 284 285 /* Enable the OHCI and EHCI controller by default for new VMs. (new in 2.2): */ 286 CUSBDeviceFilters usbDeviceFilters = m_machine.GetUSBDeviceFilters(); 287 bool fOhciEnabled = false; 288 if (!usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB3() && m_machine.GetUSBProxyAvailable()) 289 { 290 /* USB 3.0 is only available if the proper ExtPack is installed: */ 291 CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager(); 292 if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName)) 293 { 294 m_machine.AddUSBController("XHCI", KUSBControllerType_XHCI); 295 /* xHCI includes OHCI */ 296 fOhciEnabled = true; 297 } 298 } 299 if ( !fOhciEnabled 300 && !usbDeviceFilters.isNull() && comGuestType.GetRecommendedUSB() && m_machine.GetUSBProxyAvailable()) 301 { 302 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI); 303 fOhciEnabled = true; 304 /* USB 2.0 is only available if the proper ExtPack is installed. 305 * Note. Configuring EHCI here and providing messages about 306 * the missing extpack isn't exactly clean, but it is a 307 * necessary evil to patch over legacy compatability issues 308 * introduced by the new distribution model. */ 309 CExtPackManager extPackManager = uiCommon().virtualBox().GetExtensionPackManager(); 310 if (extPackManager.isNull() || extPackManager.IsExtPackUsable(GUI_ExtPackName)) 311 m_machine.AddUSBController("EHCI", KUSBControllerType_EHCI); 312 } 313 314 /* Create a floppy controller if recommended: */ 315 QString strFloppyName = getNextControllerName(KStorageBus_Floppy); 316 if (comGuestType.GetRecommendedFloppy()) 317 { 318 m_machine.AddStorageController(strFloppyName, KStorageBus_Floppy); 319 CStorageController flpCtr = m_machine.GetStorageControllerByName(strFloppyName); 320 flpCtr.SetControllerType(KStorageControllerType_I82078); 321 } 322 323 /* Create recommended DVD storage controller: */ 324 KStorageBus strDVDBus = comGuestType.GetRecommendedDVDStorageBus(); 325 QString strDVDName = getNextControllerName(strDVDBus); 326 m_machine.AddStorageController(strDVDName, strDVDBus); 327 328 /* Set recommended DVD storage controller type: */ 329 CStorageController dvdCtr = m_machine.GetStorageControllerByName(strDVDName); 330 KStorageControllerType dvdStorageControllerType = comGuestType.GetRecommendedDVDStorageController(); 331 dvdCtr.SetControllerType(dvdStorageControllerType); 332 333 /* Create recommended HD storage controller if it's not the same as the DVD controller: */ 334 KStorageBus ctrHDBus = comGuestType.GetRecommendedHDStorageBus(); 335 KStorageControllerType hdStorageControllerType = comGuestType.GetRecommendedHDStorageController(); 336 CStorageController hdCtr; 337 QString strHDName; 338 if (ctrHDBus != strDVDBus || hdStorageControllerType != dvdStorageControllerType) 339 { 340 strHDName = getNextControllerName(ctrHDBus); 341 m_machine.AddStorageController(strHDName, ctrHDBus); 342 hdCtr = m_machine.GetStorageControllerByName(strHDName); 343 hdCtr.SetControllerType(hdStorageControllerType); 344 } 345 else 346 { 347 /* The HD controller is the same as DVD: */ 348 hdCtr = dvdCtr; 349 strHDName = strDVDName; 350 } 351 352 /* Limit the AHCI port count if it's used because windows has trouble with 353 too many ports and other guest (OS X in particular) may take extra long 354 to boot: */ 355 if (hdStorageControllerType == KStorageControllerType_IntelAhci) 356 hdCtr.SetPortCount(1 + (dvdStorageControllerType == KStorageControllerType_IntelAhci)); 357 else if (dvdStorageControllerType == KStorageControllerType_IntelAhci) 358 dvdCtr.SetPortCount(1); 359 360 /* Turn on PAE, if recommended: */ 361 m_machine.SetCPUProperty(KCPUPropertyType_PAE, comGuestType.GetRecommendedPAE()); 362 363 /* Set the recommended triple fault behavior: */ 364 m_machine.SetCPUProperty(KCPUPropertyType_TripleFaultReset, comGuestType.GetRecommendedTFReset()); 365 366 /* Set recommended firmware type: */ 367 m_machine.SetFirmwareType(m_fEFIEnabled ? KFirmwareType_EFI : KFirmwareType_BIOS); 368 369 /* Set recommended human interface device types: */ 370 if (comGuestType.GetRecommendedUSBHID()) 371 { 372 m_machine.SetKeyboardHIDType(KKeyboardHIDType_USBKeyboard); 373 m_machine.SetPointingHIDType(KPointingHIDType_USBMouse); 374 if (!fOhciEnabled && !usbDeviceFilters.isNull()) 375 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI); 376 } 377 378 if (comGuestType.GetRecommendedUSBTablet()) 379 { 380 m_machine.SetPointingHIDType(KPointingHIDType_USBTablet); 381 if (!fOhciEnabled && !usbDeviceFilters.isNull()) 382 m_machine.AddUSBController("OHCI", KUSBControllerType_OHCI); 383 } 384 385 /* Set HPET flag: */ 386 m_machine.SetHPETEnabled(comGuestType.GetRecommendedHPET()); 387 388 /* Set UTC flags: */ 389 m_machine.SetRTCUseUTC(comGuestType.GetRecommendedRTCUseUTC()); 390 391 /* Set graphic bits: */ 392 if (comGuestType.GetRecommended2DVideoAcceleration()) 393 comGraphics.SetAccelerate2DVideoEnabled(comGuestType.GetRecommended2DVideoAcceleration()); 394 395 if (comGuestType.GetRecommended3DAcceleration()) 396 comGraphics.SetAccelerate3DEnabled(comGuestType.GetRecommended3DAcceleration()); 397 } 398 399 bool UIWizardNewVM::attachDefaultDevices() 400 { 401 bool success = false; 402 QUuid uMachineId = m_machine.GetId(); 403 CSession session = uiCommon().openSession(uMachineId); 404 if (!session.isNull()) 405 { 406 CMachine machine = session.GetMachine(); 407 if (!m_virtualDisk.isNull()) 408 { 409 KStorageBus enmHDDBus = m_comGuestOSType.GetRecommendedHDStorageBus(); 410 CStorageController comHDDController = m_machine.GetStorageControllerByInstance(enmHDDBus, 0); 411 if (!comHDDController.isNull()) 412 { 413 machine.AttachDevice(comHDDController.GetName(), 0, 0, KDeviceType_HardDisk, m_virtualDisk); 414 if (!machine.isOk()) 415 msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, m_strMediumPath, 416 StorageSlot(enmHDDBus, 0, 0), this); 417 } 418 } 419 420 /* Attach optical drive: */ 421 KStorageBus enmDVDBus = m_comGuestOSType.GetRecommendedDVDStorageBus(); 422 CStorageController comDVDController = m_machine.GetStorageControllerByInstance(enmDVDBus, 0); 423 if (!comDVDController.isNull()) 424 { 425 CMedium opticalDisk; 426 QString strISOFilePath = ISOFilePath(); 427 if (!strISOFilePath.isEmpty() && !isUnattendedEnabled()) 428 { 429 CVirtualBox vbox = uiCommon().virtualBox(); 430 opticalDisk = 431 vbox.OpenMedium(strISOFilePath, KDeviceType_DVD, KAccessMode_ReadWrite, false); 432 if (!vbox.isOk()) 433 msgCenter().cannotOpenMedium(vbox, strISOFilePath, this); 434 } 435 machine.AttachDevice(comDVDController.GetName(), 1, 0, KDeviceType_DVD, opticalDisk); 436 if (!machine.isOk()) 437 msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(), 438 StorageSlot(enmDVDBus, 1, 0), this); 439 } 440 441 /* Attach an empty floppy drive if recommended */ 442 if (m_comGuestOSType.GetRecommendedFloppy()) { 443 CStorageController comFloppyController = m_machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0); 444 if (!comFloppyController.isNull()) 445 { 446 machine.AttachDevice(comFloppyController.GetName(), 0, 0, KDeviceType_Floppy, CMedium()); 447 if (!machine.isOk()) 448 msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_Floppy, QString(), 449 StorageSlot(KStorageBus_Floppy, 0, 0), this); 450 } 451 } 452 453 if (machine.isOk()) 454 { 455 machine.SaveSettings(); 456 if (machine.isOk()) 457 success = true; 458 else 459 msgCenter().cannotSaveMachineSettings(machine, this); 460 } 461 462 session.UnlockMachine(); 463 } 464 if (!success) 465 { 466 CVirtualBox vbox = uiCommon().virtualBox(); 467 /* Unregister on failure */ 468 QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly); /// @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below 469 if (vbox.isOk()) 470 { 471 CProgress progress = m_machine.DeleteConfig(aMedia); 472 progress.WaitForCompletion(-1); /// @todo do this nicely with a progress dialog, this can delete lots of files 473 } 474 return false; 475 } 476 477 /* Ensure we don't try to delete a newly created virtual hard drive on success: */ 478 if (!m_virtualDisk.isNull()) 479 m_virtualDisk.detach(); 480 407 481 return true; 408 // bool success = false;409 // QUuid uMachineId = m_machine.GetId();410 // CSession session = uiCommon().openSession(uMachineId);411 // if (!session.isNull())412 // {413 // CMachine machine = session.GetMachine();414 // if (!m_virtualDisk.isNull())415 // {416 // KStorageBus enmHDDBus = comGuestType.GetRecommendedHDStorageBus();417 // CStorageController comHDDController = m_machine.GetStorageControllerByInstance(enmHDDBus, 0);418 // if (!comHDDController.isNull())419 // {420 // machine.AttachDevice(comHDDController.GetName(), 0, 0, KDeviceType_HardDisk, m_virtualDisk);421 // if (!machine.isOk())422 // msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_HardDisk, field("mediumPath").toString(),423 // StorageSlot(enmHDDBus, 0, 0), this);424 // }425 // }426 427 // /* Attach optical drive: */428 // KStorageBus enmDVDBus = comGuestType.GetRecommendedDVDStorageBus();429 // CStorageController comDVDController = m_machine.GetStorageControllerByInstance(enmDVDBus, 0);430 // if (!comDVDController.isNull())431 // {432 // CMedium opticalDisk;433 // QString strISOFilePath = ISOFilePath();434 // if (!strISOFilePath.isEmpty() && !getBoolFieldValue("isUnattendedEnabled"))435 // {436 // CVirtualBox vbox = uiCommon().virtualBox();437 // opticalDisk =438 // vbox.OpenMedium(strISOFilePath, KDeviceType_DVD, KAccessMode_ReadWrite, false);439 // if (!vbox.isOk())440 // msgCenter().cannotOpenMedium(vbox, strISOFilePath, this);441 // }442 // machine.AttachDevice(comDVDController.GetName(), 1, 0, KDeviceType_DVD, opticalDisk);443 // if (!machine.isOk())444 // msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_DVD, QString(),445 // StorageSlot(enmDVDBus, 1, 0), this);446 // }447 448 // /* Attach an empty floppy drive if recommended */449 // if (comGuestType.GetRecommendedFloppy()) {450 // CStorageController comFloppyController = m_machine.GetStorageControllerByInstance(KStorageBus_Floppy, 0);451 // if (!comFloppyController.isNull())452 // {453 // machine.AttachDevice(comFloppyController.GetName(), 0, 0, KDeviceType_Floppy, CMedium());454 // if (!machine.isOk())455 // msgCenter().cannotAttachDevice(machine, UIMediumDeviceType_Floppy, QString(),456 // StorageSlot(KStorageBus_Floppy, 0, 0), this);457 // }458 // }459 460 // if (machine.isOk())461 // {462 // machine.SaveSettings();463 // if (machine.isOk())464 // success = true;465 // else466 // msgCenter().cannotSaveMachineSettings(machine, this);467 // }468 469 // session.UnlockMachine();470 // }471 // if (!success)472 // {473 // CVirtualBox vbox = uiCommon().virtualBox();474 // /* Unregister on failure */475 // QVector<CMedium> aMedia = m_machine.Unregister(KCleanupMode_UnregisterOnly); /// @todo replace with DetachAllReturnHardDisksOnly once a progress dialog is in place below476 // if (vbox.isOk())477 // {478 // CProgress progress = m_machine.DeleteConfig(aMedia);479 // progress.WaitForCompletion(-1); /// @todo do this nicely with a progress dialog, this can delete lots of files480 // }481 // return false;482 // }483 484 // /* Ensure we don't try to delete a newly created virtual hard drive on success: */485 // if (!m_virtualDisk.isNull())486 // m_virtualDisk.detach();487 488 // return true;489 482 } 490 483 -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVM.h
r90085 r90090 78 78 bool isGuestOSTypeWindows() const; 79 79 80 bool createVM(); 81 bool createVirtualDisk(); 82 void deleteVirtualDisk(); 83 84 80 85 CMedium &virtualDisk(); 81 86 void setVirtualDisk(const CMedium &medium); … … 157 162 /** Populates pages. */ 158 163 virtual void populatePages() /* final override */; 159 160 bool createVM();161 bool createVirtualDisk();162 void deleteVirtualDisk();163 164 164 void configureVM(const QString &strGuestTypeId, const CGuestOSType &comGuestType); 165 bool attachDefaultDevices( const CGuestOSType &comGuestType);165 bool attachDefaultDevices(); 166 166 167 167 private slots: -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/newvm/UIWizardNewVMDiskPageBasic.cpp
r90085 r90090 432 432 if (pWizard) 433 433 { 434 // if (selectedDiskSource()== SelectedDiskSource_New)435 //{436 ///* Try to create the hard drive:*/437 //fResult = pWizard->createVirtualDisk();438 ///*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */439 //if (!fResult)440 //return fResult;441 //}442 443 //fResult = pWizard->createVM();444 ///* Try to delete the hard disk: */445 //if (!fResult)446 //pWizard->deleteVirtualDisk();434 if (m_enmSelectedDiskSource == SelectedDiskSource_New) 435 { 436 /* Try to create the hard drive:*/ 437 fResult = pWizard->createVirtualDisk(); 438 /*Don't show any error message here since UIWizardNewVM::createVirtualDisk already does so: */ 439 if (!fResult) 440 return fResult; 441 } 442 443 fResult = pWizard->createVM(); 444 /* Try to delete the hard disk: */ 445 if (!fResult) 446 pWizard->deleteVirtualDisk(); 447 447 } 448 448 // endProcessing();
Note:
See TracChangeset
for help on using the changeset viewer.