Changeset 33698 in vbox for trunk/src/VBox
- Timestamp:
- Nov 2, 2010 4:03:29 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r33621 r33698 258 258 } 259 259 260 Utf8Str convertNetworkAttachmentTypeToString(NetworkAttachmentType_T type) 261 { 262 Utf8Str strType; 263 switch (type) 264 { 265 case NetworkAttachmentType_NAT: strType = "NAT"; break; 266 case NetworkAttachmentType_Bridged: strType = "Bridged"; break; 267 case NetworkAttachmentType_Internal: strType = "Internal"; break; 268 case NetworkAttachmentType_HostOnly: strType = "HostOnly"; break; 269 case NetworkAttachmentType_VDE: strType = "VDE"; break; 270 case NetworkAttachmentType_Null: strType = "Null"; break; 271 } 272 return strType; 273 } 274 260 275 //////////////////////////////////////////////////////////////////////////////// 261 276 // -
trunk/src/VBox/Main/ApplianceImplExport.cpp
r33661 r33698 472 472 if (fEnabled) 473 473 { 474 Utf8Str strAttachmentType;475 476 474 rc = pNetworkAdapter->COMGETTER(AdapterType)(&adapterType); 477 475 if (FAILED(rc)) throw rc; … … 480 478 if (FAILED(rc)) throw rc; 481 479 482 switch (attachmentType) 483 { 484 case NetworkAttachmentType_Null: 485 strAttachmentType = "Null"; 486 break; 487 488 case NetworkAttachmentType_NAT: 489 strAttachmentType = "NAT"; 490 break; 491 492 case NetworkAttachmentType_Bridged: 493 strAttachmentType = "Bridged"; 494 break; 495 496 case NetworkAttachmentType_Internal: 497 strAttachmentType = "Internal"; 498 break; 499 500 case NetworkAttachmentType_HostOnly: 501 strAttachmentType = "HostOnly"; 502 break; 503 } 504 480 Utf8Str strAttachmentType = convertNetworkAttachmentTypeToString(attachmentType); 505 481 pNewDesc->addEntry(VirtualSystemDescriptionType_NetworkAdapter, 506 482 "", // ref -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r33665 r33698 165 165 /* Guest OS type */ 166 166 Utf8Str strOsTypeVBox; 167 Utf8Str strCIMOSType = Utf8StrFmt("%RI32", (uint32_t)vsysThis.cimos); 168 convertCIMOSType2VBoxOSType(strOsTypeVBox, vsysThis.cimos, vsysThis.strCimosDesc); 167 Utf8Str strCIMOSType = Utf8StrFmt("%RU32", (uint32_t)vsysThis.cimos); 169 168 /* If there is a vbox.xml, we always prefer the ostype settings 170 169 * from there, cause OVF doesn't know all types VBox know. */ 171 if (vsysThis.pelmVboxMachine) 170 if ( vsysThis.pelmVboxMachine 171 && pNewDesc->m->pConfig->machineUserData.strOsType.isNotEmpty()) 172 172 strOsTypeVBox = pNewDesc->m->pConfig->machineUserData.strOsType; 173 else 174 convertCIMOSType2VBoxOSType(strOsTypeVBox, vsysThis.cimos, vsysThis.strCimosDesc); 173 175 pNewDesc->addEntry(VirtualSystemDescriptionType_OS, 174 176 "", … … 177 179 178 180 /* VM name */ 179 /* If the there isn't any name specified create a default one out of 180 * the OS type */ 181 Utf8Str nameVBox = vsysThis.strName; 181 Utf8Str nameVBox; 182 /* If there is a vbox.xml, we always prefer the setting from there. */ 183 if ( vsysThis.pelmVboxMachine 184 && pNewDesc->m->pConfig->machineUserData.strName.isNotEmpty()) 185 nameVBox = pNewDesc->m->pConfig->machineUserData.strName; 186 else 187 nameVBox = vsysThis.strName; 188 /* If the there isn't any name specified create a default one out 189 * of the OS type */ 182 190 if (nameVBox.isEmpty()) 183 191 nameVBox = strOsTypeVBox; … … 252 260 253 261 /* CPU count */ 254 ULONG cpuCountVBox = vsysThis.cCPUs; 262 ULONG cpuCountVBox; 263 /* If there is a vbox.xml, we always prefer the setting from there. */ 264 if ( vsysThis.pelmVboxMachine 265 && pNewDesc->m->pConfig->hardwareMachine.cCPUs) 266 cpuCountVBox = pNewDesc->m->pConfig->hardwareMachine.cCPUs; 267 else 268 cpuCountVBox = vsysThis.cCPUs; 255 269 /* Check for the constraints */ 256 270 if (cpuCountVBox > SchemaDefs::MaxCPUCount) … … 264 278 pNewDesc->addEntry(VirtualSystemDescriptionType_CPU, 265 279 "", 266 Utf8StrFmt("%R I32", (uint32_t)vsysThis.cCPUs),267 Utf8StrFmt("%R I32", (uint32_t)cpuCountVBox));280 Utf8StrFmt("%RU32", (uint32_t)vsysThis.cCPUs), 281 Utf8StrFmt("%RU32", (uint32_t)cpuCountVBox)); 268 282 269 283 /* RAM */ 270 uint64_t ullMemSizeVBox = vsysThis.ullMemorySize / _1M; 284 uint64_t ullMemSizeVBox; 285 /* If there is a vbox.xml, we always prefer the setting from there. */ 286 if ( vsysThis.pelmVboxMachine 287 && pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB) 288 ullMemSizeVBox = pNewDesc->m->pConfig->hardwareMachine.ulMemorySizeMB; 289 else 290 ullMemSizeVBox = vsysThis.ullMemorySize / _1M; 271 291 /* Check for the constraints */ 272 292 if ( ullMemSizeVBox != 0 … … 291 311 pNewDesc->addEntry(VirtualSystemDescriptionType_Memory, 292 312 "", 293 Utf8StrFmt("%R I64", (uint64_t)vsysThis.ullMemorySize),294 Utf8StrFmt("%R I64", (uint64_t)ullMemSizeVBox));313 Utf8StrFmt("%RU64", (uint64_t)vsysThis.ullMemorySize), 314 Utf8StrFmt("%RU64", (uint64_t)ullMemSizeVBox)); 295 315 296 316 /* Audio */ 297 if (!vsysThis.strSoundCardType.isEmpty()) 298 /* Currently we set the AC97 always. 299 @todo: figure out the hardware which could be possible */ 317 Utf8Str strSoundCard; 318 Utf8Str strSoundCardOrig; 319 /* If there is a vbox.xml, we always prefer the setting from there. */ 320 if ( vsysThis.pelmVboxMachine 321 && pNewDesc->m->pConfig->hardwareMachine.audioAdapter.fEnabled) 322 strSoundCard = Utf8StrFmt("%RU32", (uint32_t)pNewDesc->m->pConfig->hardwareMachine.audioAdapter.controllerType); 323 else if (vsysThis.strSoundCardType.isNotEmpty()) 324 { 325 /* Set the AC97 always for the simple OVF case. 326 * @todo: figure out the hardware which could be possible */ 327 strSoundCard = Utf8StrFmt("%RU32", (uint32_t)AudioControllerType_AC97); 328 strSoundCardOrig = vsysThis.strSoundCardType; 329 } 330 if (strSoundCard.isNotEmpty()) 300 331 pNewDesc->addEntry(VirtualSystemDescriptionType_SoundCard, 301 332 "", 302 vsysThis.strSoundCardType,303 Utf8StrFmt("%RI32", (uint32_t)AudioControllerType_AC97));333 strSoundCardOrig, 334 strSoundCard); 304 335 305 336 #ifdef VBOX_WITH_USB 306 337 /* USB Controller */ 307 if (vsysThis.fHasUsbController) 338 /* If there is a vbox.xml, we always prefer the setting from there. */ 339 if ( ( vsysThis.pelmVboxMachine 340 && pNewDesc->m->pConfig->hardwareMachine.usbController.fEnabled) 341 || vsysThis.fHasUsbController) 308 342 pNewDesc->addEntry(VirtualSystemDescriptionType_USBController, "", "", ""); 309 343 #endif /* VBOX_WITH_USB */ 310 344 311 345 /* Network Controller */ 312 size_t cEthernetAdapters = vsysThis.llEthernetAdapters.size(); 313 if (cEthernetAdapters > 0) 346 /* If there is a vbox.xml, we always prefer the setting from there. */ 347 if (vsysThis.pelmVboxMachine) 348 { 349 const settings::NetworkAdaptersList &llNetworkAdapters = pNewDesc->m->pConfig->hardwareMachine.llNetworkAdapters; 350 /* Check for the constrains */ 351 if (llNetworkAdapters.size() > SchemaDefs::NetworkAdapterCount) 352 addWarning(tr("The virtual system \"%s\" claims support for %zu network adapters, but VirtualBox has support for max %u network adapter only."), 353 vsysThis.strName.c_str(), llNetworkAdapters.size(), SchemaDefs::NetworkAdapterCount); 354 /* Iterate through all network adapters. */ 355 settings::NetworkAdaptersList::const_iterator it1; 356 size_t a = 0; 357 for (it1 = llNetworkAdapters.begin(); 358 it1 != llNetworkAdapters.end() && a < SchemaDefs::NetworkAdapterCount; 359 ++it1, ++a) 360 { 361 if (it1->fEnabled) 362 { 363 Utf8Str strMode = convertNetworkAttachmentTypeToString(it1->mode); 364 pNewDesc->addEntry(VirtualSystemDescriptionType_NetworkAdapter, 365 "", // ref 366 strMode, // orig 367 Utf8StrFmt("%RU32", (uint32_t)it1->type), // conf 368 0, 369 Utf8StrFmt("slot=%RU32;type=%s", it1->ulSlot, strMode.c_str())); // extra conf 370 } 371 } 372 } 373 /* else we use the ovf configuration. */ 374 else if (size_t cEthernetAdapters = vsysThis.llEthernetAdapters.size() > 0) 314 375 { 315 376 /* Check for the constrains */ … … 339 400 && (strNetwork.compare("Internal", Utf8Str::CaseInsensitive)) 340 401 && (strNetwork.compare("HostOnly", Utf8Str::CaseInsensitive)) 402 && (strNetwork.compare("VDE", Utf8Str::CaseInsensitive)) 341 403 ) 342 404 strNetwork = "Bridged"; // VMware assumes this is the default apparently … … 380 442 "", // ref 381 443 ea.strNetworkName, // orig 382 Utf8StrFmt("%R I32", (uint32_t)nwAdapterVBox), // conf444 Utf8StrFmt("%RU32", (uint32_t)nwAdapterVBox), // conf 383 445 0, 384 446 Utf8StrFmt("type=%s", strNetwork.c_str())); // extra conf … … 386 448 } 387 449 450 /* If there is a vbox.xml, we always prefer the setting from there. */ 451 bool fFloppy = false; 452 bool fDVD = false; 453 if (vsysThis.pelmVboxMachine) 454 { 455 settings::StorageControllersList &llControllers = pNewDesc->m->pConfig->storageMachine.llStorageControllers; 456 settings::StorageControllersList::iterator it3; 457 for (it3 = llControllers.begin(); 458 it3 != llControllers.end(); 459 ++it3) 460 { 461 settings::AttachedDevicesList &llAttachments = it3->llAttachedDevices; 462 settings::AttachedDevicesList::iterator it4; 463 for (it4 = llAttachments.begin(); 464 it4 != llAttachments.end(); 465 ++it4) 466 { 467 fDVD |= it4->deviceType == DeviceType_DVD; 468 fFloppy |= it4->deviceType == DeviceType_Floppy; 469 if (fFloppy && fDVD) 470 break; 471 } 472 if (fFloppy && fDVD) 473 break; 474 } 475 } 476 else 477 { 478 fFloppy = vsysThis.fHasFloppyDrive; 479 fDVD = vsysThis.fHasCdromDrive; 480 } 388 481 /* Floppy Drive */ 389 if ( vsysThis.fHasFloppyDrive)482 if (fFloppy) 390 483 pNewDesc->addEntry(VirtualSystemDescriptionType_Floppy, "", "", ""); 391 392 484 /* CD Drive */ 393 if ( vsysThis.fHasCdromDrive)485 if (fDVD) 394 486 pNewDesc->addEntry(VirtualSystemDescriptionType_CDROM, "", "", ""); 395 487 … … 515 607 Utf8Str strTargetPath = Utf8Str(strMachineFolder) 516 608 .append(RTPATH_DELIMITER) 517 .append(di.strHref); ;609 .append(di.strHref); 518 610 searchUniqueDiskImageFilePath(strTargetPath); 519 611 … … 1939 2031 1940 2032 // default is NAT; change to "bridged" if extra conf says so 1941 if ( !pvsys->strExtraConfigCurrent.compare("type=Bridged", Utf8Str::CaseInsensitive))2033 if (pvsys->strExtraConfigCurrent.endsWith("type=Bridged", Utf8Str::CaseInsensitive)) 1942 2034 { 1943 2035 /* Attach to the right interface */ … … 1972 2064 } 1973 2065 /* Next test for host only interfaces */ 1974 else if ( !pvsys->strExtraConfigCurrent.compare("type=HostOnly", Utf8Str::CaseInsensitive))2066 else if (pvsys->strExtraConfigCurrent.endsWith("type=HostOnly", Utf8Str::CaseInsensitive)) 1975 2067 { 1976 2068 /* Attach to the right interface */ … … 2004 2096 } 2005 2097 } 2098 /* Next test for internal interfaces */ 2099 else if (pvsys->strExtraConfigCurrent.endsWith("type=Internal", Utf8Str::CaseInsensitive)) 2100 { 2101 /* Attach to the right interface */ 2102 rc = pNetworkAdapter->AttachToInternalNetwork(); 2103 if (FAILED(rc)) throw rc; 2104 } 2105 /* Next test for VDE interfaces */ 2106 else if (pvsys->strExtraConfigCurrent.endsWith("type=VDE", Utf8Str::CaseInsensitive)) 2107 { 2108 /* Attach to the right interface */ 2109 rc = pNetworkAdapter->AttachToVDE(); 2110 if (FAILED(rc)) throw rc; 2111 } 2006 2112 } 2007 2113 } … … 2374 2480 */ 2375 2481 2482 /* OS Type */ 2376 2483 config.machineUserData.strOsType = stack.strOsTypeVBox; 2484 /* Description */ 2377 2485 config.machineUserData.strDescription = stack.strDescription; 2378 2486 /* CPU count & extented attributes */ 2379 2487 config.hardwareMachine.cCPUs = stack.cCPUs; 2380 config.hardwareMachine.ulMemorySizeMB = stack.ulMemorySizeMB;2381 2488 if (stack.fForceIOAPIC) 2382 2489 config.hardwareMachine.fHardwareVirt = true; 2383 2490 if (stack.fForceIOAPIC) 2384 2491 config.hardwareMachine.biosSettings.fIOAPICEnabled = true; 2492 /* RAM size */ 2493 config.hardwareMachine.ulMemorySizeMB = stack.ulMemorySizeMB; 2385 2494 2386 2495 /* … … 2389 2498 <const name="HardDiskControllerSCSI" value="16" /> 2390 2499 <const name="HardDiskControllerSAS" value="17" /> 2391 <const name="HardDiskImage" value="18" />2392 <const name="Floppy" value="19" />2393 <const name="CDROM" value="20" />2394 <const name="NetworkAdapter" value="21" />2395 2500 */ 2396 2501 2397 2502 #ifdef VBOX_WITH_USB 2398 / / disable USB if user disabled USB2503 /* USB controller */ 2399 2504 config.hardwareMachine.usbController.fEnabled = stack.fUSBEnabled; 2400 2505 #endif 2401 2402 // audio adapter: only config is turning it off presently 2403 if (stack.strAudioAdapter.isEmpty()) 2506 /* Audio adapter */ 2507 if (stack.strAudioAdapter.isNotEmpty()) 2508 { 2509 config.hardwareMachine.audioAdapter.fEnabled = true; 2510 config.hardwareMachine.audioAdapter.controllerType = stack.strAudioAdapter.toUInt32(); 2511 } 2512 else 2404 2513 config.hardwareMachine.audioAdapter.fEnabled = false; 2514 /* Network adapter */ 2515 settings::NetworkAdaptersList &llNetworkAdapters = config.hardwareMachine.llNetworkAdapters; 2516 /* First disable all network cards, they will be enabled below again. */ 2517 settings::NetworkAdaptersList::iterator it1; 2518 for (it1 = llNetworkAdapters.begin(); it1 != llNetworkAdapters.end(); ++it1) 2519 it1->fEnabled = false; 2520 /* Now iterate over all network entries. */ 2521 std::list<VirtualSystemDescriptionEntry*> avsdeNWs = vsdescThis->findByType(VirtualSystemDescriptionType_NetworkAdapter); 2522 if (avsdeNWs.size() > 0) 2523 { 2524 /* Iterate through all network adapter entries and search for the 2525 * corrosponding one in the machine config. If one is found, configure 2526 * it based on the user settings. */ 2527 list<VirtualSystemDescriptionEntry*>::const_iterator itNW; 2528 for (itNW = avsdeNWs.begin(); 2529 itNW != avsdeNWs.end(); 2530 ++itNW) 2531 { 2532 VirtualSystemDescriptionEntry *vsdeNW = *itNW; 2533 if ( vsdeNW->strExtraConfigCurrent.startsWith("slot=", Utf8Str::CaseInsensitive) 2534 && vsdeNW->strExtraConfigCurrent.length() > 6) 2535 { 2536 uint32_t iSlot = vsdeNW->strExtraConfigCurrent.substr(5, 1).toUInt32(); 2537 /* Iterate through all network adapters in the machine config. */ 2538 for (it1 = llNetworkAdapters.begin(); 2539 it1 != llNetworkAdapters.end(); 2540 ++it1) 2541 { 2542 /* Compare the slots. */ 2543 if (it1->ulSlot == iSlot) 2544 { 2545 it1->fEnabled = true; 2546 it1->type = vsdeNW->strVboxCurrent.toUInt32(); 2547 break; 2548 } 2549 } 2550 } 2551 } 2552 } 2553 2554 /* Floppy controller */ 2555 bool fFloppy = vsdescThis->findByType(VirtualSystemDescriptionType_Floppy).size() > 0; 2556 /* DVD controller */ 2557 bool fDVD = vsdescThis->findByType(VirtualSystemDescriptionType_CDROM).size() > 0; 2558 /* Iterate over all storage controller check the attachments and remove 2559 * them when necessary. */ 2560 settings::StorageControllersList &llControllers = config.storageMachine.llStorageControllers; 2561 settings::StorageControllersList::iterator it3; 2562 for (it3 = llControllers.begin(); 2563 it3 != llControllers.end(); 2564 ++it3) 2565 { 2566 settings::AttachedDevicesList &llAttachments = it3->llAttachedDevices; 2567 settings::AttachedDevicesList::iterator it4; 2568 for (it4 = llAttachments.begin(); 2569 it4 != llAttachments.end(); 2570 ++it4) 2571 { 2572 if ( ( !fDVD 2573 && it4->deviceType == DeviceType_DVD) 2574 || 2575 ( !fFloppy 2576 && it4->deviceType == DeviceType_Floppy)) 2577 llAttachments.erase(it4++); 2578 } 2579 } 2580 2405 2581 2406 2582 /* … … 2421 2597 { 2422 2598 case StorageBus_SATA: 2423 break; 2424 2599 break; 2425 2600 case StorageBus_SCSI: 2426 break; 2427 2601 break; 2428 2602 case StorageBus_IDE: 2429 break; 2430 2603 break; 2431 2604 case StorageBus_SAS: 2432 break;2605 break; 2433 2606 } 2434 2607 … … 2616 2789 throw setError(VBOX_E_FILE_ERROR, tr("CPU count missing")); 2617 2790 2618 const Utf8Str &cpuVBox = vsdeCPU.front()->strVboxCurrent; 2619 stack.cCPUs = (uint32_t)RTStrToUInt64(cpuVBox.c_str()); 2791 stack.cCPUs = vsdeCPU.front()->strVboxCurrent.toUInt32(); 2620 2792 // We need HWVirt & IO-APIC if more than one CPU is requested 2621 2793 if (stack.cCPUs > 1) … … 2629 2801 if (vsdeRAM.size() != 1) 2630 2802 throw setError(VBOX_E_FILE_ERROR, tr("RAM size missing")); 2631 const Utf8Str &memoryVBox = vsdeRAM.front()->strVboxCurrent; 2632 stack.ulMemorySizeMB = (uint32_t)RTStrToUInt64(memoryVBox.c_str()); 2803 stack.ulMemorySizeMB = vsdeRAM.front()->strVboxCurrent.toUInt64(); 2633 2804 2634 2805 #ifdef VBOX_WITH_USB -
trunk/src/VBox/Main/include/ApplianceImplPrivate.h
r33651 r33698 221 221 ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVbox); 222 222 223 Utf8Str convertNetworkAttachmentTypeToString(NetworkAttachmentType_T type); 224 223 225 typedef struct RTSHA1STORAGE 224 226 {
Note:
See TracChangeset
for help on using the changeset viewer.