Changeset 22226 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 13, 2009 9:25:03 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/xml/Settings.cpp
r22214 r22226 121 121 122 122 if (!(m->pelmRoot->getAttributeValue("version", m->strSettingsVersionFull))) 123 throw ConfigFileError(this, N_("Required VirtualBox/ version attribute is missing"));123 throw ConfigFileError(this, N_("Required VirtualBox/@version attribute is missing")); 124 124 125 125 m->sv = SettingsVersion_Null; … … 308 308 map[strName] = strValue; 309 309 else 310 throw ConfigFileError(this, N_(" ExtraDataItem element must have name and value attributes"));310 throw ConfigFileError(this, N_("Required ExtraDataItem/@name or @value attribute is missing")); 311 311 } 312 312 else 313 throw ConfigFileError(this, N_("Invalid element %sin ExtraData section"), pelmExtraDataItem->getName());313 throw ConfigFileError(this, N_("Invalid element '%s' in ExtraData section"), pelmExtraDataItem->getName()); 314 314 } 315 315 } … … 357 357 flt.action = USBDeviceFilterAction_Hold; 358 358 else 359 throw ConfigFileError(this, N_("Invalid value %s in DeviceFilter/action attribute"), strAction.c_str());359 throw ConfigFileError(this, N_("Invalid value '%s' in DeviceFilter/@action attribute"), strAction.c_str()); 360 360 } 361 361 … … 532 532 } 533 533 else 534 throw ConfigFileError(this, N_("MachineEntry element must have uuid and src attributes")); 535 } 536 else 537 throw ConfigFileError(this, N_("Invalid element %s in MachineRegistry section"), pelmChild1->getName()); 534 throw ConfigFileError(this, N_("Required MachineEntry/@uuid or @src attribute is missing")); 535 } 538 536 } 539 537 } … … 562 560 { 563 561 if (!(elmMedium.getAttributeValue("format", med.strFormat))) 564 throw ConfigFileError(this, N_(" HardDisk element must have format attribute"));562 throw ConfigFileError(this, N_("Required HardDisk/@format attribute is missing")); 565 563 566 564 if (!(elmMedium.getAttributeValue("autoReset", med.fAutoReset))) … … 577 575 med.hdType = HardDiskType_Writethrough; 578 576 else 579 throw ConfigFileError(this, N_("HardDisk/ type attribute must be one of Normal, Immutable or Writethrough"));577 throw ConfigFileError(this, N_("HardDisk/@type attribute must be one of Normal, Immutable or Writethrough")); 580 578 } 581 579 } … … 601 599 med.properties[strPropName] = strPropValue; 602 600 else 603 throw ConfigFileError(this, N_(" HardDisk/Property element must have name and value attributes"));601 throw ConfigFileError(this, N_("Required HardDisk/Property/@name or @value attribute is missing")); 604 602 } 605 603 } … … 608 606 } 609 607 else 610 throw ConfigFileError(this, N_(" %s element must have uuid and location attributes"), elmMedium.getName());608 throw ConfigFileError(this, N_("Required %s/@uuid or @location attribute is missing"), elmMedium.getName()); 611 609 } 612 610 … … 617 615 void MainConfigFile::readMediaRegistry(const xml::ElementNode &elmMediaRegistry) 618 616 { 619 // <MachineEntry uuid="{ xxx }" src=" xxx "/>620 617 xml::NodesLoop nl1(elmMediaRegistry); 621 618 const xml::ElementNode *pelmChild1; … … 630 627 t = FloppyImage; 631 628 else 632 throw ConfigFileError(this, N_("Invalid element %s in MediaRegistry section"), pelmChild1->getName());629 continue; 633 630 634 631 xml::NodesLoop nl1(*pelmChild1); … … 680 677 llDhcpServers.push_back(srv); 681 678 else 682 throw ConfigFileError(this, N_("DHCPServer element must have networkName, IPAddress, networkMask, lowerIP, upperIP and enabled attributes")); 683 } 684 else 685 throw ConfigFileError(this, N_("Invalid element %s in DHCPServers section"), pelmServer->getName()); 679 throw ConfigFileError(this, N_("Required DHCPServer/@networkName, @IPAddress, @networkMask, @lowerIP, @upperIP or @enabled attribute is missing")); 680 } 686 681 } 687 682 } … … 740 735 if (pelmLevel4Child->nameEquals("DHCPServers")) 741 736 readDHCPServers(*pelmLevel4Child); 742 else743 throw ConfigFileError(this, N_("Invalid element %s in NetserviceRegistry section"), pelmLevel4Child->getName());744 737 } 745 738 } 746 739 else if (pelmGlobalChild->nameEquals("USBDeviceFilters")) 747 740 readUSBDeviceFilters(*pelmGlobalChild, host.llUSBDeviceFilters); 748 else749 throw ConfigFileError(this, N_("Invalid element %s in Global section"), pelmGlobalChild->getName());750 741 } 751 742 } // end if (pelmRootChild->nameEquals("Global")) … … 950 941 951 942 if (!pelmAdapter->getAttributeValue("slot", nic.ulSlot)) 952 throw ConfigFileError(this, N_("Required Adapter/ slot attribute is missing"));943 throw ConfigFileError(this, N_("Required Adapter/@slot attribute is missing")); 953 944 954 945 Utf8Str strTemp; … … 966 957 nic.type = NetworkAdapterType_I82545EM; 967 958 else 968 throw ConfigFileError(this, N_("Invalid value %sin Adapter/type attribute"), strTemp.c_str());959 throw ConfigFileError(this, N_("Invalid value '%s' in Adapter/type attribute"), strTemp.c_str()); 969 960 } 970 961 … … 993 984 nic.mode = NetworkAttachmentType_Internal; 994 985 if (!pelmAdapterChild->getAttributeValue("name", nic.strName)) // required network name 995 throw ConfigFileError(this, N_("Required 'name' element is missing under 'InternalNetwork' element"));986 throw ConfigFileError(this, N_("Required InternalNetwork/name element is missing")); 996 987 } 997 988 else if ((pelmAdapterChild = pelmAdapter->findChildElement("HostOnlyInterface"))) … … 999 990 nic.mode = NetworkAttachmentType_HostOnly; 1000 991 if (!pelmAdapterChild->getAttributeValue("name", nic.strName)) // required network name 1001 throw ConfigFileError(this, N_("Required 'name' element is missing under 'HostOnlyInterface' element"));992 throw ConfigFileError(this, N_("Required HostOnlyInterface/name element is missing")); 1002 993 } 1003 994 // else: default is NetworkAttachmentType_Null … … 1021 1012 SerialPort port; 1022 1013 if (!pelmPort->getAttributeValue("slot", port.ulSlot)) 1023 throw ConfigFileError(this, N_("Required UART/Port/ slot attribute is missing"));1014 throw ConfigFileError(this, N_("Required UART/Port/@slot attribute is missing")); 1024 1015 1025 1016 // slot must be unique … … 1028 1019 ++it) 1029 1020 if ((*it).ulSlot == port.ulSlot) 1030 throw ConfigFileError(this, N_("UART/Port/ slot attribute value %d is used twice, must be unique"), port.ulSlot);1021 throw ConfigFileError(this, N_("UART/Port/@slot attribute value %d is used twice, must be unique"), port.ulSlot); 1031 1022 1032 1023 if (!pelmPort->getAttributeValue("enabled", port.fEnabled)) 1033 throw ConfigFileError(this, N_("Required UART/Port/ enabled attribute is missing"));1024 throw ConfigFileError(this, N_("Required UART/Port/@enabled attribute is missing")); 1034 1025 if (!pelmPort->getAttributeValue("IOBase", port.ulIOBase)) 1035 throw ConfigFileError(this, N_("Required UART/Port/ IOBase attribute is missing"));1026 throw ConfigFileError(this, N_("Required UART/Port/@IOBase attribute is missing")); 1036 1027 if (!pelmPort->getAttributeValue("IRQ", port.ulIRQ)) 1037 throw ConfigFileError(this, N_("Required UART/Port/ IRQ attribute is missing"));1028 throw ConfigFileError(this, N_("Required UART/Port/@IRQ attribute is missing")); 1038 1029 1039 1030 Utf8Str strPortMode; 1040 1031 if (!pelmPort->getAttributeValue("hostMode", strPortMode)) 1041 throw ConfigFileError(this, N_("Required UART/Port/ hostMode attribute is missing"));1032 throw ConfigFileError(this, N_("Required UART/Port/@hostMode attribute is missing")); 1042 1033 if (strPortMode == "RawFile") 1043 1034 port.portMode = PortMode_RawFile; … … 1049 1040 port.portMode = PortMode_Disconnected; 1050 1041 else 1051 throw ConfigFileError(this, N_("Invalid value %s in UART/Port/hostMode attribute"), strPortMode.c_str());1042 throw ConfigFileError(this, N_("Invalid value '%s' in UART/Port/@hostMode attribute"), strPortMode.c_str()); 1052 1043 1053 1044 pelmPort->getAttributeValue("path", port.strPath); … … 1072 1063 ParallelPort port; 1073 1064 if (!pelmPort->getAttributeValue("slot", port.ulSlot)) 1074 throw ConfigFileError(this, N_("Required LPT/Port/ slot attribute is missing"));1065 throw ConfigFileError(this, N_("Required LPT/Port/@slot attribute is missing")); 1075 1066 1076 1067 // slot must be unique … … 1079 1070 ++it) 1080 1071 if ((*it).ulSlot == port.ulSlot) 1081 throw ConfigFileError(this, N_("LPT/Port/ slot attribute value %d is used twice, must be unique"), port.ulSlot);1072 throw ConfigFileError(this, N_("LPT/Port/@slot attribute value %d is used twice, must be unique"), port.ulSlot); 1082 1073 1083 1074 if (!pelmPort->getAttributeValue("enabled", port.fEnabled)) 1084 throw ConfigFileError(this, N_("Required LPT/Port/ enabled attribute is missing"));1075 throw ConfigFileError(this, N_("Required LPT/Port/@enabled attribute is missing")); 1085 1076 if (!pelmPort->getAttributeValue("IOBase", port.ulIOBase)) 1086 throw ConfigFileError(this, N_("Required LPT/Port/ IOBase attribute is missing"));1077 throw ConfigFileError(this, N_("Required LPT/Port/@IOBase attribute is missing")); 1087 1078 if (!pelmPort->getAttributeValue("IRQ", port.ulIRQ)) 1088 throw ConfigFileError(this, N_("Required LPT/Port/ IRQ attribute is missing"));1079 throw ConfigFileError(this, N_("Required LPT/Port/@IRQ attribute is missing")); 1089 1080 1090 1081 pelmPort->getAttributeValue("path", port.strPath); … … 1181 1172 Utf8Str strDevice; 1182 1173 if (!pelmOrder->getAttributeValue("position", ulPos)) 1183 throw ConfigFileError(this, N_(" 'Order' element lacks 'position' attribute"));1174 throw ConfigFileError(this, N_("Required Order/@position attribute is missing")); 1184 1175 if (!pelmOrder->getAttributeValue("device", strDevice)) 1185 throw ConfigFileError(this, N_(" 'Order' element lacks 'device' attribute"));1176 throw ConfigFileError(this, N_("Required Order/@device attribute is missing")); 1186 1177 if (hw.mapBootOrder.find(ulPos) != hw.mapBootOrder.end()) 1187 throw ConfigFileError(this, N_(" Value %d of 'position' attribute in 'Order' elementis not unique"), ulPos);1178 throw ConfigFileError(this, N_("Order/@attribute value %d is not unique"), ulPos); 1188 1179 1189 1180 DeviceType_T type; … … 1199 1190 type = DeviceType_Network; 1200 1191 else 1201 throw ConfigFileError(this, N_("Invalid value %s in Boot/Order/device attribute"), strDevice.c_str());1192 throw ConfigFileError(this, N_("Invalid value '%s' in Boot/Order/@device attribute"), strDevice.c_str()); 1202 1193 hw.mapBootOrder[ulPos] = type; 1203 1194 } … … 1226 1217 hw.vrdpSettings.authType = VRDPAuthType_External; 1227 1218 else 1228 throw ConfigFileError(this, N_("Invalid value %s in RemoteDisplay/authType attribute"), strAuthType.c_str());1219 throw ConfigFileError(this, N_("Invalid value '%s' in RemoteDisplay/@authType attribute"), strAuthType.c_str()); 1229 1220 } 1230 1221 … … 1259 1250 hw.biosSettings.biosBootMenuMode = BIOSBootMenuMode_MessageAndMenu; 1260 1251 else 1261 throw ConfigFileError(this, N_("Invalid value %s in BootMenu/mode attribute"), strBootMenuMode.c_str());1252 throw ConfigFileError(this, N_("Invalid value '%s' in BootMenu/@mode attribute"), strBootMenuMode.c_str()); 1262 1253 } 1263 1254 } … … 1286 1277 sctl.controllerType = StorageControllerType_ICH6; 1287 1278 else 1288 throw ConfigFileError(this, N_("Invalid value %s for IDEController/type attribute"), strType.c_str());1279 throw ConfigFileError(this, N_("Invalid value '%s' for IDEController/@type attribute"), strType.c_str()); 1289 1280 } 1290 1281 sctl.ulPortCount = 2; … … 1361 1352 hw.audioAdapter.controllerType = AudioControllerType_AC97; 1362 1353 else 1363 throw ConfigFileError(this, N_("Invalid value %s in AudioAdapter/controller attribute"), strTemp.c_str());1354 throw ConfigFileError(this, N_("Invalid value '%s' in AudioAdapter/@controller attribute"), strTemp.c_str()); 1364 1355 } 1365 1356 if (pelmHwChild->getAttributeValue("driver", strTemp)) … … 1384 1375 hw.audioAdapter.driverType = AudioDriverType_MMPM; 1385 1376 else 1386 throw ConfigFileError(this, N_("Invalid value %s in AudioAdapter/driver attribute"), strTemp.c_str());1377 throw ConfigFileError(this, N_("Invalid value '%s' in AudioAdapter/@driver attribute"), strTemp.c_str()); 1387 1378 } 1388 1379 } … … 1414 1405 hw.clipboardMode = ClipboardMode_Bidirectional; 1415 1406 else 1416 throw ConfigFileError(this, N_("Invalid value %s in Clipbord/mode attribute"), strTemp.c_str());1407 throw ConfigFileError(this, N_("Invalid value '%s' in Clipbord/@mode attribute"), strTemp.c_str()); 1417 1408 } 1418 1409 } … … 1425 1416 readGuestProperties(*pelmHwChild, hw); 1426 1417 else 1427 throw ConfigFileError(this, N_("Invalid element %sin Hardware section"), pelmHwChild->getName());1418 throw ConfigFileError(this, N_("Invalid element '%s' in Hardware section"), pelmHwChild->getName()); 1428 1419 } 1429 1420 1430 1421 if (hw.ulMemorySizeMB == (uint32_t)-1) 1431 throw ConfigFileError(this, N_("Required Memory/ RAMSize element/attribute is missing"));1422 throw ConfigFileError(this, N_("Required Memory/@RAMSize element/attribute is missing")); 1432 1423 } 1433 1424 … … 1466 1457 1467 1458 if (!pelmAttachment->getAttributeValue("hardDisk", strUUID)) 1468 throw ConfigFileError(this, N_("Required HardDiskAttachment/ hardDisk attribute is missing"));1459 throw ConfigFileError(this, N_("Required HardDiskAttachment/@hardDisk attribute is missing")); 1469 1460 parseUUID(att.uuid, strUUID); 1470 1461 1471 1462 if (!pelmAttachment->getAttributeValue("bus", strBus)) 1472 throw ConfigFileError(this, N_("Required HardDiskAttachment/ bus attribute is missing"));1463 throw ConfigFileError(this, N_("Required HardDiskAttachment/@bus attribute is missing")); 1473 1464 // pre-1.7 'channel' is now port 1474 1465 if (!pelmAttachment->getAttributeValue("channel", att.lPort)) 1475 throw ConfigFileError(this, N_("Required HardDiskAttachment/ channel attribute is missing"));1466 throw ConfigFileError(this, N_("Required HardDiskAttachment/@channel attribute is missing")); 1476 1467 // pre-1.7 'device' is still device 1477 1468 if (!pelmAttachment->getAttributeValue("device", att.lDevice)) 1478 throw ConfigFileError(this, N_("Required HardDiskAttachment/ device attribute is missing"));1469 throw ConfigFileError(this, N_("Required HardDiskAttachment/@device attribute is missing")); 1479 1470 1480 1471 if (strBus == "IDE") 1481 1472 { 1482 1473 if (!pIDEController) 1483 throw ConfigFileError(this, N_("HardDiskAttachment/ bus is 'IDE' but cannot find IDE controller"));1474 throw ConfigFileError(this, N_("HardDiskAttachment/@bus is 'IDE' but cannot find IDE controller")); 1484 1475 pIDEController->llAttachedDevices.push_back(att); 1485 1476 } … … 1487 1478 { 1488 1479 if (!pSATAController) 1489 throw ConfigFileError(this, N_("HardDiskAttachment/ bus is 'SATA' but cannot find SATA controller"));1480 throw ConfigFileError(this, N_("HardDiskAttachment/@bus is 'SATA' but cannot find SATA controller")); 1490 1481 pSATAController->llAttachedDevices.push_back(att); 1491 1482 } 1492 1483 else 1493 throw ConfigFileError(this, N_("HardDiskAttachment/ bus attribute has illegal value '%s'"), strBus.c_str());1484 throw ConfigFileError(this, N_("HardDiskAttachment/@bus attribute has illegal value '%s'"), strBus.c_str()); 1494 1485 } 1495 1486 } … … 1515 1506 1516 1507 if (!pelmController->getAttributeValue("name", sctl.strName)) 1517 throw ConfigFileError(this, N_("Required StorageController/ name attribute is missing"));1508 throw ConfigFileError(this, N_("Required StorageController/@name attribute is missing")); 1518 1509 Utf8Str strType; 1519 1510 if (!pelmController->getAttributeValue("type", strType)) 1520 throw ConfigFileError(this, N_("Required StorageController/ type attribute is missing"));1511 throw ConfigFileError(this, N_("Required StorageController/@type attribute is missing")); 1521 1512 1522 1513 if (strType == "AHCI") … … 1551 1542 } 1552 1543 else 1553 throw ConfigFileError(this, N_("Invalid value %s for StorageController/type attribute"), strType.c_str());1544 throw ConfigFileError(this, N_("Invalid value '%s' for StorageController/@type attribute"), strType.c_str()); 1554 1545 1555 1546 readStorageControllerAttributes(*pelmController, sctl); … … 1563 1554 Utf8Str strTemp; 1564 1555 pelmAttached->getAttributeValue("type", strTemp); 1565 if (strTemp != "HardDisk") 1566 throw ConfigFileError(this, N_("AttachedDevice element must have 'HardDisk' type")); 1567 1568 const xml::ElementNode *pelmImage; 1569 if (!(pelmImage = pelmAttached->findChildElement("Image"))) 1570 throw ConfigFileError(this, N_("Required AttachedDevice/Image element is missing")); 1571 1572 if (!pelmImage->getAttributeValue("uuid", strTemp)) 1573 throw ConfigFileError(this, N_("Required AttachedDevice/Image/uuid attributeis missing")); 1574 parseUUID(att.uuid, strTemp); 1575 1576 if (!pelmAttached->getAttributeValue("port", att.lPort)) 1577 throw ConfigFileError(this, N_("Required AttachedDevice/port attribute is missing")); 1578 if (!pelmAttached->getAttributeValue("device", att.lDevice)) 1579 throw ConfigFileError(this, N_("Required AttachedDevice/device attribute is missing")); 1580 1581 sctl.llAttachedDevices.push_back(att); 1556 // ignore everything but HardDisk entries for forward compatibility 1557 if (strTemp == "HardDisk") 1558 { 1559 const xml::ElementNode *pelmImage; 1560 if (!(pelmImage = pelmAttached->findChildElement("Image"))) 1561 throw ConfigFileError(this, N_("Required AttachedDevice/Image element is missing")); 1562 1563 if (!pelmImage->getAttributeValue("uuid", strTemp)) 1564 throw ConfigFileError(this, N_("Required AttachedDevice/Image/@uuid attribute is missing")); 1565 parseUUID(att.uuid, strTemp); 1566 1567 if (!pelmAttached->getAttributeValue("port", att.lPort)) 1568 throw ConfigFileError(this, N_("Required AttachedDevice/@port attribute is missing")); 1569 if (!pelmAttached->getAttributeValue("device", att.lDevice)) 1570 throw ConfigFileError(this, N_("Required AttachedDevice/@device attribute is missing")); 1571 1572 sctl.llAttachedDevices.push_back(att); 1573 } 1582 1574 } 1583 1575 … … 1603 1595 1604 1596 if (!elmSnapshot.getAttributeValue("uuid", strTemp)) 1605 throw ConfigFileError(this, N_("Required Snapshot/ uuid attribute is missing"));1597 throw ConfigFileError(this, N_("Required Snapshot/@uuid attribute is missing")); 1606 1598 parseUUID(snap.uuid, strTemp); 1607 1599 1608 1600 if (!elmSnapshot.getAttributeValue("name", snap.strName)) 1609 throw ConfigFileError(this, N_("Required Snapshot/ name attribute is missing"));1601 throw ConfigFileError(this, N_("Required Snapshot/@name attribute is missing")); 1610 1602 1611 1603 elmSnapshot.getAttributeValue("Description", snap.strDescription); 1612 1604 1613 1605 if (!elmSnapshot.getAttributeValue("timeStamp", strTemp)) 1614 throw ConfigFileError(this, N_("Required Snapshot/ timeStamp attribute is missing"));1606 throw ConfigFileError(this, N_("Required Snapshot/@timeStamp attribute is missing")); 1615 1607 parseTimestamp(snap.timestamp, strTemp); 1616 1608 … … 1620 1612 const xml::ElementNode *pelmHardware; 1621 1613 if (!(pelmHardware = elmSnapshot.findChildElement("Hardware"))) 1622 throw ConfigFileError(this, N_("Required Snapshot/ Hardware element is missing"));1614 throw ConfigFileError(this, N_("Required Snapshot/@Hardware element is missing")); 1623 1615 readHardware(*pelmHardware, snap.hardware, snap.storage); 1624 1616 … … 1649 1641 snap.llChildSnapshots.push_back(child); 1650 1642 } 1651 else1652 throw ConfigFileError(this, N_("Invalid element %s under Snapshots element"), pelmChildSnapshot->getName());1653 1643 } 1654 1644 } 1655 else if (pelmSnapshotChild->nameEquals("Hardware"))1656 ; // handled above1657 else1658 throw ConfigFileError(this, N_("Invalid element %s under Snapshot element"), pelmSnapshotChild->getName());1659 1645 } 1660 1646 } … … 1720 1706 else if (pelmMachineChild->nameEquals("Description")) 1721 1707 strDescription = pelmMachineChild->getValue(); 1722 else if (pelmMachineChild->nameEquals("Hardware"))1723 ; // read above1724 else1725 throw ConfigFileError(this, N_("Invalid element %s under Machine element"), pelmMachineChild->getName());1726 1708 } 1727 1709 } 1728 1710 else 1729 throw ConfigFileError(this, N_(" Machine element must have uuid and name attributes"));1711 throw ConfigFileError(this, N_("Required Machine/@uuid or @name attributes is missing")); 1730 1712 } 1731 1713
Note:
See TracChangeset
for help on using the changeset viewer.