Changeset 22213 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 12, 2009 5:00:56 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Makefile.kmk
r22187 r22213 281 281 AutoLock.cpp \ 282 282 Matching.cpp \ 283 xml/Settings.cpp \ 283 284 VirtualBoxBase.cpp \ 284 285 VirtualBoxErrorInfoImpl.cpp \ … … 314 315 Version.cpp \ 315 316 HostPower.cpp \ 316 xml/Settings.cpp \317 317 $(if $(VBOX_WITH_VRDP),VRDPServerImpl.cpp,) \ 318 318 $(if $(VBOX_WITH_XPCOM),xpcom/server.cpp,) \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r22211 r22213 379 379 <!-- 2008-09-04: 2.0.0 released 380 380 2008-11-20: settings version 1.5 introduced 381 2008-12-17: 2.1.0 released --> 381 2008-12-17: 2.1.0 released 382 --> 382 383 </const> 383 384 <const name="v1_6" value="8"> 384 <desc> Intermediate settings version "1.6", understood by VirtualBox 2.2 and above.</desc>385 <desc>Settings version "1.6", written by VirtualBox 2.1.4 (at least).</desc> 385 386 <!-- 2008-12-17: 2.1.0 released 386 2008-12-19: settings version 1.6 introduced (is in 2.2 branch) 387 2009-04-08: 2.2.0 released --> 387 2008-12-19: settings version 1.6 introduced (is in 2.1 branch) 388 2009-04-08: 2.2.0 released 389 --> 388 390 </const> 389 391 <const name="v1_7" value="9"> -
trunk/src/VBox/Main/xml/Settings.cpp
r22198 r22213 128 128 const char *pcsz = m->strSettingsVersionFull.c_str(); 129 129 if ( (pcsz[0] == '1') 130 && (pcsz[1] == '.')131 && (pcsz[3] == '-')130 && (pcsz[1] == '.') 131 && (pcsz[3] == '-') 132 132 ) 133 133 { 134 if (pcsz[2] == '7') 134 if (pcsz[2] == '6') 135 m->sv = SettingsVersion_v1_6; 136 else if (pcsz[2] == '7') 135 137 m->sv = SettingsVersion_v1_7; 136 138 else if (pcsz[2] == '8') … … 371 373 m->pelmRoot->setAttribute("xmlns", VBOX_XML_NAMESPACE); 372 374 373 const char *pcszVersion = "1.7"; 375 // we always write at least version 1.7; we write 1.8 376 // if that was requested thru setRequiredSettingsVersion(). 377 // we make no attempt at writing earlier versions. 378 // Writing 1.6 would be messy for machine files because 379 // of the hard disk attachment changes which are not 380 // necessarily backwards compatible and we don't want to 381 // introduce complex logic to see whether they are. 382 const char *pcszVersion = NULL; 374 383 switch (m->sv) 375 384 { 376 385 case SettingsVersion_v1_8: 377 386 pcszVersion = "1.8"; 387 break; 388 389 default: 390 pcszVersion = "1.7"; 391 m->sv = SettingsVersion_v1_7; 378 392 break; 379 393 } … … 1089 1103 1090 1104 /** 1105 * Helper function to read attributes that are common to <SATAController> (pre-1.7) 1106 * and <StorageController>. 1107 * @param elmStorageController 1108 * @param strg 1109 */ 1110 void MachineConfigFile::readStorageControllerAttributes(const xml::ElementNode &elmStorageController, 1111 StorageController &sctl) 1112 { 1113 elmStorageController.getAttributeValue("PortCount", sctl.ulPortCount); 1114 elmStorageController.getAttributeValue("IDE0MasterEmulationPort", sctl.lIDE0MasterEmulationPort); 1115 elmStorageController.getAttributeValue("IDE0SlaveEmulationPort", sctl.lIDE0SlaveEmulationPort); 1116 elmStorageController.getAttributeValue("IDE1MasterEmulationPort", sctl.lIDE1MasterEmulationPort); 1117 elmStorageController.getAttributeValue("IDE1SlaveEmulationPort", sctl.lIDE1SlaveEmulationPort); 1118 } 1119 1120 /** 1091 1121 * Reads in a <Hardware> block and stores it in the given structure. Used 1092 1122 * both directly from readMachine and from readSnapshot, since snapshots 1093 1123 * have their own hardware sections. 1124 * 1125 * For legacy pre-1.7 settings we also need a storage structure because 1126 * the IDE and SATA controllers used to be defined under <Hardware>. 1127 * 1094 1128 * @param elmHardware 1095 1129 * @param hw 1096 1130 */ 1097 1131 void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, 1098 Hardware &hw) 1132 Hardware &hw, 1133 Storage &strg) 1099 1134 { 1100 1135 elmHardware.getAttributeValue("version", hw.strVersion); … … 1215 1250 if ((pelmBIOSChild = pelmHwChild->findChildElement("TimeOffset"))) 1216 1251 pelmBIOSChild->getAttributeValue("value", hw.biosSettings.llTimeOffset); 1252 1253 // legacy BIOS/IDEController (pre 1.7) 1254 if ( (m->sv < SettingsVersion_v1_7) 1255 && ((pelmBIOSChild = pelmHwChild->findChildElement("IDEController"))) 1256 ) 1257 { 1258 StorageController sctl; 1259 sctl.strName = "IDE"; 1260 sctl.storageBus = StorageBus_IDE; 1261 1262 Utf8Str strType; 1263 if (pelmBIOSChild->getAttributeValue("type", strType)) 1264 { 1265 if (strType == "PIIX3") 1266 sctl.controllerType = StorageControllerType_PIIX3; 1267 else if (strType == "PIIX4") 1268 sctl.controllerType = StorageControllerType_PIIX4; 1269 else if (strType == "ICH6") 1270 sctl.controllerType = StorageControllerType_ICH6; 1271 else 1272 throw ConfigFileError(this, N_("Invalid value %s for IDEController/type attribute"), strType.c_str()); 1273 } 1274 sctl.ulPortCount = 2; 1275 strg.llStorageControllers.push_back(sctl); 1276 } 1217 1277 } 1218 1278 else if (pelmHwChild->nameEquals("DVDDrive")) … … 1247 1307 readUSBDeviceFilters(*pelmHwChild, 1248 1308 hw.usbController.llDeviceFilters); 1309 } 1310 else if ( (m->sv < SettingsVersion_v1_7) 1311 && (pelmHwChild->nameEquals("SATAController")) 1312 ) 1313 { 1314 bool f; 1315 if ( (pelmHwChild->getAttributeValue("enabled", f)) 1316 && (f) 1317 ) 1318 { 1319 StorageController sctl; 1320 sctl.strName = "SATA"; 1321 sctl.storageBus = StorageBus_SATA; 1322 sctl.controllerType = StorageControllerType_IntelAhci; 1323 1324 readStorageControllerAttributes(*pelmHwChild, sctl); 1325 1326 strg.llStorageControllers.push_back(sctl); 1327 } 1249 1328 } 1250 1329 else if (pelmHwChild->nameEquals("Network")) … … 1338 1417 1339 1418 /** 1419 * This gets called instead of readStorageControllers() for legacy pre-1.7 settings 1420 * files which have a <HardDiskAttachments> node and storage controller settings 1421 * hidden in the <Hardware> settings. We set the StorageControllers fields just the 1422 * same, just from different sources. 1423 * @param elmHardware <Hardware> XML node. 1424 * @param elmHardDiskAttachments <HardDiskAttachments> XML node. 1425 * @param strg 1426 */ 1427 void MachineConfigFile::readHardDiskAttachments_pre1_7(const xml::ElementNode &elmHardDiskAttachments, 1428 Storage &strg) 1429 { 1430 StorageController *pIDEController = NULL; 1431 StorageController *pSATAController = NULL; 1432 1433 for (StorageControllersList::iterator it = strg.llStorageControllers.begin(); 1434 it != strg.llStorageControllers.end(); 1435 ++it) 1436 { 1437 StorageController &s = *it; 1438 if (s.storageBus == StorageBus_IDE) 1439 pIDEController = &s; 1440 else if (s.storageBus == StorageBus_SATA) 1441 pSATAController = &s; 1442 } 1443 1444 xml::NodesLoop nl1(elmHardDiskAttachments, "HardDiskAttachment"); 1445 const xml::ElementNode *pelmAttachment; 1446 while ((pelmAttachment = nl1.forAllNodes())) 1447 { 1448 AttachedDevice att; 1449 Utf8Str strUUID, strBus; 1450 1451 if (!pelmAttachment->getAttributeValue("hardDisk", strUUID)) 1452 throw ConfigFileError(this, N_("Required HardDiskAttachment/hardDisk attribute is missing")); 1453 parseUUID(att.uuid, strUUID); 1454 1455 if (!pelmAttachment->getAttributeValue("bus", strBus)) 1456 throw ConfigFileError(this, N_("Required HardDiskAttachment/bus attribute is missing")); 1457 // pre-1.7 'channel' is now port 1458 if (!pelmAttachment->getAttributeValue("channel", att.lPort)) 1459 throw ConfigFileError(this, N_("Required HardDiskAttachment/channel attribute is missing")); 1460 // pre-1.7 'device' is still device 1461 if (!pelmAttachment->getAttributeValue("device", att.lDevice)) 1462 throw ConfigFileError(this, N_("Required HardDiskAttachment/device attribute is missing")); 1463 1464 if (strBus == "IDE") 1465 { 1466 if (!pIDEController) 1467 throw ConfigFileError(this, N_("HardDiskAttachment/bus is 'IDE' but cannot find IDE controller")); 1468 pIDEController->llAttachedDevices.push_back(att); 1469 } 1470 else if (strBus == "SATA") 1471 { 1472 if (!pSATAController) 1473 throw ConfigFileError(this, N_("HardDiskAttachment/bus is 'SATA' but cannot find SATA controller")); 1474 pSATAController->llAttachedDevices.push_back(att); 1475 } 1476 else 1477 throw ConfigFileError(this, N_("HardDiskAttachment/bus attribute has illegal value '%s'"), strBus.c_str()); 1478 } 1479 } 1480 1481 /** 1340 1482 * Reads in a <StorageControllers> block and stores it in the given Storage structure. 1341 1483 * Used both directly from readMachine and from readSnapshot, since snapshots 1342 1484 * have their own storage controllers sections. 1485 * 1486 * This is only called for settings version 1.7 and above; see readHardDiskAttachments_pre1_7 1487 * for earlier versions. 1343 1488 * 1344 1489 * @param elmStorageControllers … … 1392 1537 throw ConfigFileError(this, N_("Invalid value %s for StorageController/type attribute"), strType.c_str()); 1393 1538 1394 pelmController->getAttributeValue("PortCount", sctl.ulPortCount); 1395 1396 pelmController->getAttributeValue("IDE0MasterEmulationPort", sctl.lIDE0MasterEmulationPort); 1397 pelmController->getAttributeValue("IDE0SlaveEmulationPort", sctl.lIDE0SlaveEmulationPort); 1398 pelmController->getAttributeValue("IDE1MasterEmulationPort", sctl.lIDE1MasterEmulationPort); 1399 pelmController->getAttributeValue("IDE1SlaveEmulationPort", sctl.lIDE1SlaveEmulationPort); 1539 readStorageControllerAttributes(*pelmController, sctl); 1400 1540 1401 1541 xml::NodesLoop nlAttached(*pelmController, "AttachedDevice"); … … 1461 1601 elmSnapshot.getAttributeValue("stateFile", snap.strStateFile); // online snapshots only 1462 1602 1603 // parse Hardware before the other elements because other things depend on it 1604 const xml::ElementNode *pelmHardware; 1605 if (!(pelmHardware = elmSnapshot.findChildElement("Hardware"))) 1606 throw ConfigFileError(this, N_("Required Snapshot/Hardware element is missing")); 1607 readHardware(*pelmHardware, snap.hardware, snap.storage); 1608 1463 1609 xml::NodesLoop nlSnapshotChildren(elmSnapshot); 1464 1610 const xml::ElementNode *pelmSnapshotChild; … … 1467 1613 if (pelmSnapshotChild->nameEquals("Description")) 1468 1614 snap.strDescription = pelmSnapshotChild->getValue(); 1469 else if (pelmSnapshotChild->nameEquals("Hardware")) 1470 readHardware(*pelmSnapshotChild, snap.hardware); 1471 else if (pelmSnapshotChild->nameEquals("StorageControllers")) 1615 else if ( (m->sv < SettingsVersion_v1_7) 1616 && (pelmSnapshotChild->nameEquals("HardDiskAttachments")) 1617 ) 1618 readHardDiskAttachments_pre1_7(*pelmSnapshotChild, snap.storage); 1619 else if ( (m->sv >= SettingsVersion_v1_7) 1620 && (pelmSnapshotChild->nameEquals("StorageControllers")) 1621 ) 1472 1622 readStorageControllers(*pelmSnapshotChild, snap.storage); 1473 1623 else if (pelmSnapshotChild->nameEquals("Snapshots")) … … 1487 1637 } 1488 1638 } 1639 else if (pelmSnapshotChild->nameEquals("Hardware")) 1640 ; // handled above 1489 1641 else 1490 1642 throw ConfigFileError(this, N_("Invalid element %s under Snapshot element"), pelmSnapshotChild->getName()); … … 1522 1674 // constructor has called RTTimeNow(&timeLastStateChange) before 1523 1675 1676 // parse Hardware before the other elements because other things depend on it 1677 const xml::ElementNode *pelmHardware; 1678 if (!(pelmHardware = elmMachine.findChildElement("Hardware"))) 1679 throw ConfigFileError(this, N_("Required Machine/Hardware element is missing")); 1680 readHardware(*pelmHardware, hardwareMachine, storageMachine); 1681 1524 1682 xml::NodesLoop nlRootChildren(elmMachine); 1525 1683 const xml::ElementNode *pelmMachineChild; … … 1529 1687 readExtraData(*pelmMachineChild, 1530 1688 mapExtraDataItems); 1531 else if (pelmMachineChild->nameEquals("Hardware")) 1532 readHardware(*pelmMachineChild, hardwareMachine); 1533 else if (pelmMachineChild->nameEquals("StorageControllers")) 1689 else if ( (m->sv < SettingsVersion_v1_7) 1690 && (pelmMachineChild->nameEquals("HardDiskAttachments")) 1691 ) 1692 readHardDiskAttachments_pre1_7(*pelmMachineChild, storageMachine); 1693 else if ( (m->sv >= SettingsVersion_v1_7) 1694 && (pelmMachineChild->nameEquals("StorageControllers")) 1695 ) 1534 1696 readStorageControllers(*pelmMachineChild, storageMachine); 1535 1697 else if (pelmMachineChild->nameEquals("Snapshot")) … … 1542 1704 else if (pelmMachineChild->nameEquals("Description")) 1543 1705 strDescription = pelmMachineChild->getValue(); 1706 else if (pelmMachineChild->nameEquals("Hardware")) 1707 ; // read above 1544 1708 else 1545 1709 throw ConfigFileError(this, N_("Invalid element %s under Machine element"), pelmMachineChild->getName());
Note:
See TracChangeset
for help on using the changeset viewer.