diff options
Diffstat (limited to 'src/VBox/Main/xml')
-rw-r--r-- | src/VBox/Main/xml/SchemaDefs.xsl | 4 | ||||
-rw-r--r-- | src/VBox/Main/xml/Settings.cpp | 933 | ||||
-rw-r--r-- | src/VBox/Main/xml/SettingsConverter.xsl | 1043 | ||||
-rw-r--r-- | src/VBox/Main/xml/VirtualBox-settings-freebsd.xsd | 69 | ||||
-rw-r--r-- | src/VBox/Main/xml/VirtualBox-settings-linux.xsd | 70 | ||||
-rw-r--r-- | src/VBox/Main/xml/VirtualBox-settings-macosx.xsd | 68 | ||||
-rw-r--r-- | src/VBox/Main/xml/VirtualBox-settings-os2.xsd | 69 | ||||
-rw-r--r-- | src/VBox/Main/xml/VirtualBox-settings-solaris.xsd | 69 | ||||
-rw-r--r-- | src/VBox/Main/xml/VirtualBox-settings-windows.xsd | 69 | ||||
-rw-r--r-- | src/VBox/Main/xml/VirtualBox-settings.xsd (renamed from src/VBox/Main/xml/VirtualBox-settings-common.xsd) | 734 | ||||
-rw-r--r-- | src/VBox/Main/xml/ovfreader.cpp | 519 |
11 files changed, 1663 insertions, 1984 deletions
diff --git a/src/VBox/Main/xml/SchemaDefs.xsl b/src/VBox/Main/xml/SchemaDefs.xsl index 3d91dea8..ea5ba45b 100644 --- a/src/VBox/Main/xml/SchemaDefs.xsl +++ b/src/VBox/Main/xml/SchemaDefs.xsl @@ -8,7 +8,7 @@ * This template depends on XML Schema structure (type names and constraints) * and should be reviewed on every Schema change. - Copyright (C) 2006-2011 Oracle Corporation + Copyright (C) 2006-2012 Oracle Corporation This file is part of VirtualBox Open Source Edition (OSE), as available from http://www.virtualbox.org. This file is free software; @@ -168,7 +168,7 @@ namespace SchemaDefs <xsl:call-template name="defineEnumMember"> <xsl:with-param name="member" select="' MaxGuestMonitors'"/> <xsl:with-param name="select" select=" - xsd:complexType[@name='TDisplay']/xsd:attribute[@name='monitorCount']//xsd:maxInclusive/@value + xsd:simpleType[@name='TMonitorCount']//xsd:maxInclusive/@value "/> </xsl:call-template> diff --git a/src/VBox/Main/xml/Settings.cpp b/src/VBox/Main/xml/Settings.cpp index 8cb1e126..3520c9c7 100644 --- a/src/VBox/Main/xml/Settings.cpp +++ b/src/VBox/Main/xml/Settings.cpp @@ -54,7 +54,7 @@ */ /* - * Copyright (C) 2007-2012 Oracle Corporation + * Copyright (C) 2007-2013 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -327,7 +327,9 @@ ConfigFileBase::ConfigFileBase(const com::Utf8Str *pstrFilename) m->sv = SettingsVersion_v1_12; else if (ulMinor == 13) m->sv = SettingsVersion_v1_13; - else if (ulMinor > 13) + else if (ulMinor == 14) + m->sv = SettingsVersion_v1_14; + else if (ulMinor > 14) m->sv = SettingsVersion_Future; } else if (ulMajor > 1) @@ -382,7 +384,9 @@ void ConfigFileBase::parseUUID(Guid &guid, const Utf8Str &strUUID) const { guid = strUUID.c_str(); - if (guid.isEmpty()) + if (guid.isZero()) + throw ConfigFileError(this, NULL, N_("UUID \"%s\" has zero format"), strUUID.c_str()); + else if (!guid.isValid()) throw ConfigFileError(this, NULL, N_("UUID \"%s\" has invalid format"), strUUID.c_str()); } @@ -488,9 +492,8 @@ void ConfigFileBase::readExtraData(const xml::ElementNode &elmExtraData, { // <ExtraDataItem name="GUI/LastWindowPostion" value="97,88,981,858"/> Utf8Str strName, strValue; - if ( ((pelmExtraDataItem->getAttributeValue("name", strName))) - && ((pelmExtraDataItem->getAttributeValue("value", strValue))) - ) + if ( pelmExtraDataItem->getAttributeValue("name", strName) + && pelmExtraDataItem->getAttributeValue("value", strValue) ) map[strName] = strValue; else throw ConfigFileError(this, pelmExtraDataItem, N_("Required ExtraDataItem/@name or @value attribute is missing")); @@ -516,9 +519,8 @@ void ConfigFileBase::readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilte USBDeviceFilter flt; flt.action = USBDeviceFilterAction_Ignore; Utf8Str strAction; - if ( (pelmLevel4Child->getAttributeValue("name", flt.strName)) - && (pelmLevel4Child->getAttributeValue("active", flt.fActive)) - ) + if ( pelmLevel4Child->getAttributeValue("name", flt.strName) + && pelmLevel4Child->getAttributeValue("active", flt.fActive)) { if (!pelmLevel4Child->getAttributeValue("vendorId", flt.strVendorId)) pelmLevel4Child->getAttributeValue("vendorid", flt.strVendorId); // used before 1.3 @@ -571,7 +573,7 @@ void ConfigFileBase::readMedium(MediaType t, // <HardDisk uuid="{5471ecdb-1ddb-4012-a801-6d98e226868b}" location="/mnt/innotek-unix/vdis/Windows XP.vdi" format="VDI" type="Normal"> settings::Medium med; Utf8Str strUUID; - if (!(elmMedium.getAttributeValue("uuid", strUUID))) + if (!elmMedium.getAttributeValue("uuid", strUUID)) throw ConfigFileError(this, &elmMedium, N_("Required %s/@uuid attribute is missing"), elmMedium.getName()); parseUUID(med.uuid, strUUID); @@ -664,14 +666,14 @@ void ConfigFileBase::readMedium(MediaType t, } if (med.strFormat.isEmpty()) // not set with 1.4 format above, or 1.4 Custom format? - if (!(elmMedium.getAttributeValue("format", med.strFormat))) + if (!elmMedium.getAttributeValue("format", med.strFormat)) throw ConfigFileError(this, &elmMedium, N_("Required %s/@format attribute is missing"), elmMedium.getName()); - if (!(elmMedium.getAttributeValue("autoReset", med.fAutoReset))) + if (!elmMedium.getAttributeValue("autoReset", med.fAutoReset)) med.fAutoReset = false; Utf8Str strType; - if ((elmMedium.getAttributeValue("type", strType))) + if (elmMedium.getAttributeValue("type", strType)) { // pre-1.4 used lower case, so make this case-insensitive strType.toUpper(); @@ -696,13 +698,13 @@ void ConfigFileBase::readMedium(MediaType t, if (m->sv < SettingsVersion_v1_4) { // DVD and floppy images before 1.4 had "src" attribute instead of "location" - if (!(elmMedium.getAttributeValue("src", med.strLocation))) + if (!elmMedium.getAttributeValue("src", med.strLocation)) throw ConfigFileError(this, &elmMedium, N_("Required %s/@src attribute is missing"), elmMedium.getName()); fNeedsLocation = false; } - if (!(elmMedium.getAttributeValue("format", med.strFormat))) + if (!elmMedium.getAttributeValue("format", med.strFormat)) { // DVD and floppy images before 1.11 had no format attribute. assign the default. med.strFormat = "RAW"; @@ -716,7 +718,7 @@ void ConfigFileBase::readMedium(MediaType t, if (fNeedsLocation) // current files and 1.4 CustomHardDisk elements must have a location attribute - if (!(elmMedium.getAttributeValue("location", med.strLocation))) + if (!elmMedium.getAttributeValue("location", med.strLocation)) throw ConfigFileError(this, &elmMedium, N_("Required %s/@location attribute is missing"), elmMedium.getName()); elmMedium.getAttributeValue("Description", med.strDescription); // optional @@ -740,9 +742,8 @@ void ConfigFileBase::readMedium(MediaType t, else if (pelmHDChild->nameEquals("Property")) { Utf8Str strPropName, strPropValue; - if ( (pelmHDChild->getAttributeValue("name", strPropName)) - && (pelmHDChild->getAttributeValue("value", strPropValue)) - ) + if ( pelmHDChild->getAttributeValue("name", strPropName) + && pelmHDChild->getAttributeValue("value", strPropValue) ) med.properties[strPropName] = strPropValue; else throw ConfigFileError(this, pelmHDChild, N_("Required HardDisk/Property/@name or @value attribute is missing")); @@ -807,6 +808,47 @@ void ConfigFileBase::readMediaRegistry(const xml::ElementNode &elmMediaRegistry, } /** + * This is common version for reading NAT port forward rule in per-_machine's_adapter_ and + * per-network approaches. + * Note: this function doesn't in fill given list from xml::ElementNodesList, because there is conflicting + * declaration in ovmfreader.h. + */ +void ConfigFileBase::readNATForwardRuleList(const xml::ElementNode &elmParent, NATRuleList &llRules) +{ + xml::ElementNodesList plstRules; + elmParent.getChildElements(plstRules, "Forwarding"); + for (xml::ElementNodesList::iterator pf = plstRules.begin(); pf != plstRules.end(); ++pf) + { + NATRule rule; + uint32_t port = 0; + (*pf)->getAttributeValue("name", rule.strName); + (*pf)->getAttributeValue("proto", (uint32_t&)rule.proto); + (*pf)->getAttributeValue("hostip", rule.strHostIP); + (*pf)->getAttributeValue("hostport", port); + rule.u16HostPort = port; + (*pf)->getAttributeValue("guestip", rule.strGuestIP); + (*pf)->getAttributeValue("guestport", port); + rule.u16GuestPort = port; + llRules.push_back(rule); + } +} + +void ConfigFileBase::readNATLoopbacks(const xml::ElementNode &elmParent, NATLoopbackOffsetList &llLoopbacks) +{ + xml::ElementNodesList plstLoopbacks; + elmParent.getChildElements(plstLoopbacks, "Loopback4"); + for (xml::ElementNodesList::iterator lo = plstLoopbacks.begin(); + lo != plstLoopbacks.end(); ++lo) + { + NATHostLoopbackOffset loopback; + (*lo)->getAttributeValue("address", loopback.strLoopbackHostAddress); + (*lo)->getAttributeValue("offset", (uint32_t&)loopback.u32Offset); + llLoopbacks.push_back(loopback); + } +} + + +/** * Adds a "version" attribute to the given XML element with the * VirtualBox settings version (e.g. "1.10-linux"). Used by * the XML format for the root element and by the OVF export @@ -842,11 +884,15 @@ void ConfigFileBase::setVersionAttribute(xml::ElementNode &elm) pcszVersion = "1.13"; break; + case SettingsVersion_v1_14: + pcszVersion = "1.14"; + break; + case SettingsVersion_Future: // can be set if this code runs on XML files that were created by a future version of VBox; // in that case, downgrade to current version when writing since we can't write future versions... - pcszVersion = "1.13"; - m->sv = SettingsVersion_v1_13; + pcszVersion = "1.14"; + m->sv = SettingsVersion_v1_14; break; default: @@ -1132,6 +1178,45 @@ void ConfigFileBase::buildMediaRegistry(xml::ElementNode &elmParent, } /** + * Serialize NAT port-forwarding rules in parent container. + * Note: it's responsibility of caller to create parent of the list tag. + * because this method used for serializing per-_mahine's_adapter_ and per-network approaches. + */ +void ConfigFileBase::buildNATForwardRuleList(xml::ElementNode &elmParent, const NATRuleList &natRuleList) +{ + for (NATRuleList::const_iterator r = natRuleList.begin(); + r != natRuleList.end(); ++r) + { + xml::ElementNode *pelmPF; + pelmPF = elmParent.createChild("Forwarding"); + if ((*r).strName.length()) + pelmPF->setAttribute("name", (*r).strName); + pelmPF->setAttribute("proto", (*r).proto); + if ((*r).strHostIP.length()) + pelmPF->setAttribute("hostip", (*r).strHostIP); + if ((*r).u16HostPort) + pelmPF->setAttribute("hostport", (*r).u16HostPort); + if ((*r).strGuestIP.length()) + pelmPF->setAttribute("guestip", (*r).strGuestIP); + if ((*r).u16GuestPort) + pelmPF->setAttribute("guestport", (*r).u16GuestPort); + } +} + + +void ConfigFileBase::buildNATLoopbacks(xml::ElementNode &elmParent, const NATLoopbackOffsetList &natLoopbackOffsetList) +{ + for (NATLoopbackOffsetList::const_iterator lo = natLoopbackOffsetList.begin(); + lo != natLoopbackOffsetList.end(); ++lo) + { + xml::ElementNode *pelmLo; + pelmLo = elmParent.createChild("Loopback4"); + pelmLo->setAttribute("address", (*lo).strLoopbackHostAddress); + pelmLo->setAttribute("offset", (*lo).u32Offset); + } +} + +/** * Cleans up memory allocated by the internal XML parser. To be called by * descendant classes when they're done analyzing the DOM tree to discard it. */ @@ -1213,9 +1298,8 @@ void MainConfigFile::readMachineRegistry(const xml::ElementNode &elmMachineRegis { MachineRegistryEntry mre; Utf8Str strUUID; - if ( ((pelmChild1->getAttributeValue("uuid", strUUID))) - && ((pelmChild1->getAttributeValue("src", mre.strSettingsFile))) - ) + if ( pelmChild1->getAttributeValue("uuid", strUUID) + && pelmChild1->getAttributeValue("src", mre.strSettingsFile) ) { parseUUID(mre.uuid, strUUID); llMachines.push_back(mre); @@ -1239,20 +1323,104 @@ void MainConfigFile::readDHCPServers(const xml::ElementNode &elmDHCPServers) if (pelmServer->nameEquals("DHCPServer")) { DHCPServer srv; - if ( (pelmServer->getAttributeValue("networkName", srv.strNetworkName)) - && (pelmServer->getAttributeValue("IPAddress", srv.strIPAddress)) - && (pelmServer->getAttributeValue("networkMask", srv.strIPNetworkMask)) - && (pelmServer->getAttributeValue("lowerIP", srv.strIPLower)) - && (pelmServer->getAttributeValue("upperIP", srv.strIPUpper)) - && (pelmServer->getAttributeValue("enabled", srv.fEnabled)) - ) + if ( pelmServer->getAttributeValue("networkName", srv.strNetworkName) + && pelmServer->getAttributeValue("IPAddress", srv.strIPAddress) + && pelmServer->getAttributeValue("networkMask", srv.GlobalDhcpOptions[DhcpOpt_SubnetMask]) + && pelmServer->getAttributeValue("lowerIP", srv.strIPLower) + && pelmServer->getAttributeValue("upperIP", srv.strIPUpper) + && pelmServer->getAttributeValue("enabled", srv.fEnabled) ) + { + xml::NodesLoop nlOptions(*pelmServer, "Options"); + const xml::ElementNode *options; + /* XXX: Options are in 1:1 relation to DHCPServer */ + + while ((options = nlOptions.forAllNodes())) + { + readDhcpOptions(srv.GlobalDhcpOptions, *options); + } /* end of forall("Options") */ + xml::NodesLoop nlConfig(*pelmServer, "Config"); + const xml::ElementNode *cfg; + while ((cfg = nlConfig.forAllNodes())) + { + com::Utf8Str strVmName; + uint32_t u32Slot; + cfg->getAttributeValue("vm-name", strVmName); + cfg->getAttributeValue("slot", u32Slot); + readDhcpOptions(srv.VmSlot2OptionsM[VmNameSlotKey(strVmName, u32Slot)], *cfg); + } llDhcpServers.push_back(srv); + } else throw ConfigFileError(this, pelmServer, N_("Required DHCPServer/@networkName, @IPAddress, @networkMask, @lowerIP, @upperIP or @enabled attribute is missing")); } } } +void MainConfigFile::readDhcpOptions(DhcpOptionMap& map, + const xml::ElementNode& options) +{ + xml::NodesLoop nl2(options, "Option"); + const xml::ElementNode *opt; + while ((opt = nl2.forAllNodes())) + { + DhcpOpt_T OptName; + com::Utf8Str OptValue; + opt->getAttributeValue("name", (uint32_t&)OptName); + + if (OptName == DhcpOpt_SubnetMask) + continue; + + opt->getAttributeValue("value", OptValue); + + map.insert(std::map<DhcpOpt_T, Utf8Str>::value_type(OptName, OptValue)); + } /* end of forall("Option") */ + +} + +/** + * Reads in the <NATNetworks> chunk. + * @param elmNATNetworks + */ +void MainConfigFile::readNATNetworks(const xml::ElementNode &elmNATNetworks) +{ + xml::NodesLoop nl1(elmNATNetworks); + const xml::ElementNode *pelmNet; + while ((pelmNet = nl1.forAllNodes())) + { + if (pelmNet->nameEquals("NATNetwork")) + { + NATNetwork net; + if ( pelmNet->getAttributeValue("networkName", net.strNetworkName) + && pelmNet->getAttributeValue("enabled", net.fEnabled) + && pelmNet->getAttributeValue("network", net.strNetwork) + && pelmNet->getAttributeValue("ipv6", net.fIPv6) + && pelmNet->getAttributeValue("ipv6prefix", net.strIPv6Prefix) + && pelmNet->getAttributeValue("advertiseDefaultIPv6Route", net.fAdvertiseDefaultIPv6Route) + && pelmNet->getAttributeValue("needDhcp", net.fNeedDhcpServer) ) + { + pelmNet->getAttributeValue("loopback6", net.u32HostLoopback6Offset); + const xml::ElementNode *pelmMappings; + if ((pelmMappings = pelmNet->findChildElement("Mappings"))) + readNATLoopbacks(*pelmMappings, net.llHostLoopbackOffsetList); + + const xml::ElementNode *pelmPortForwardRules4; + if ((pelmPortForwardRules4 = pelmNet->findChildElement("PortForwarding4"))) + readNATForwardRuleList(*pelmPortForwardRules4, + net.llPortForwardRules4); + + const xml::ElementNode *pelmPortForwardRules6; + if ((pelmPortForwardRules6 = pelmNet->findChildElement("PortForwarding6"))) + readNATForwardRuleList(*pelmPortForwardRules6, + net.llPortForwardRules6); + + llNATNetworks.push_back(net); + } + else + throw ConfigFileError(this, pelmNet, N_("Required NATNetwork/@networkName, @gateway, @network,@advertiseDefaultIpv6Route , @needDhcp or @enabled attribute is missing")); + } + } +} + /** * Constructor. * @@ -1286,6 +1454,7 @@ MainConfigFile::MainConfigFile(const Utf8Str *pstrFilename) if (pelmGlobalChild->nameEquals("SystemProperties")) { pelmGlobalChild->getAttributeValue("defaultMachineFolder", systemProperties.strDefaultMachineFolder); + pelmGlobalChild->getAttributeValue("LoggingLevel", systemProperties.strLoggingLevel); pelmGlobalChild->getAttributeValue("defaultHardDiskFormat", systemProperties.strDefaultHardDiskFormat); if (!pelmGlobalChild->getAttributeValue("VRDEAuthLibrary", systemProperties.strVRDEAuthLibrary)) // pre-1.11 used @remoteDisplayAuthLibrary instead @@ -1294,6 +1463,8 @@ MainConfigFile::MainConfigFile(const Utf8Str *pstrFilename) pelmGlobalChild->getAttributeValue("defaultVRDEExtPack", systemProperties.strDefaultVRDEExtPack); pelmGlobalChild->getAttributeValue("LogHistoryCount", systemProperties.ulLogHistoryCount); pelmGlobalChild->getAttributeValue("autostartDatabasePath", systemProperties.strAutostartDatabasePath); + pelmGlobalChild->getAttributeValue("defaultFrontend", systemProperties.strDefaultFrontend); + pelmGlobalChild->getAttributeValue("exclusiveHwVirt", systemProperties.fExclusiveHwVirt); } else if (pelmGlobalChild->nameEquals("ExtraData")) readExtraData(*pelmGlobalChild, mapExtraDataItems); @@ -1313,6 +1484,8 @@ MainConfigFile::MainConfigFile(const Utf8Str *pstrFilename) { if (pelmLevel4Child->nameEquals("DHCPServers")) readDHCPServers(*pelmLevel4Child); + if (pelmLevel4Child->nameEquals("NATNetworks")) + readNATNetworks(*pelmLevel4Child); } } else if (pelmGlobalChild->nameEquals("USBDeviceFilters")) @@ -1341,7 +1514,7 @@ MainConfigFile::MainConfigFile(const Utf8Str *pstrFilename) "HostInterfaceNetworking-vboxnet0"; #endif srv.strIPAddress = "192.168.56.100"; - srv.strIPNetworkMask = "255.255.255.0"; + srv.GlobalDhcpOptions[DhcpOpt_SubnetMask] = "255.255.255.0"; srv.strIPLower = "192.168.56.101"; srv.strIPUpper = "192.168.56.254"; srv.fEnabled = true; @@ -1349,12 +1522,25 @@ MainConfigFile::MainConfigFile(const Utf8Str *pstrFilename) } } +void MainConfigFile::bumpSettingsVersionIfNeeded() +{ + if (m->sv < SettingsVersion_v1_14) + { + // VirtualBox 4.3 adds NAT networks. + if ( !llNATNetworks.empty()) + m->sv = SettingsVersion_v1_14; + } +} + + /** * Called from the IVirtualBox interface to write out VirtualBox.xml. This * builds an XML DOM tree and writes it out to disk. */ void MainConfigFile::write(const com::Utf8Str strFilename) { + bumpSettingsVersionIfNeeded(); + m->strFilename = strFilename; createStubDocument(); @@ -1384,17 +1570,110 @@ void MainConfigFile::write(const com::Utf8Str strFilename) { const DHCPServer &d = *it; xml::ElementNode *pelmThis = pelmDHCPServers->createChild("DHCPServer"); + DhcpOptConstIterator itOpt; + itOpt = d.GlobalDhcpOptions.find(DhcpOpt_SubnetMask); + pelmThis->setAttribute("networkName", d.strNetworkName); pelmThis->setAttribute("IPAddress", d.strIPAddress); - pelmThis->setAttribute("networkMask", d.strIPNetworkMask); + if (itOpt != d.GlobalDhcpOptions.end()) + pelmThis->setAttribute("networkMask", itOpt->second); pelmThis->setAttribute("lowerIP", d.strIPLower); pelmThis->setAttribute("upperIP", d.strIPUpper); pelmThis->setAttribute("enabled", (d.fEnabled) ? 1 : 0); // too bad we chose 1 vs. 0 here + /* We assume that if there're only 1 element it means that */ + int cOpt = d.GlobalDhcpOptions.size(); + /* We don't want duplicate validation check of networkMask here*/ + if ( ( itOpt == d.GlobalDhcpOptions.end() + && cOpt > 0) + || cOpt > 1) + { + xml::ElementNode *pelmOptions = pelmThis->createChild("Options"); + for (itOpt = d.GlobalDhcpOptions.begin(); + itOpt != d.GlobalDhcpOptions.end(); + ++itOpt) + { + if (itOpt->first == DhcpOpt_SubnetMask) + continue; + + xml::ElementNode *pelmOpt = pelmOptions->createChild("Option"); + + if (!pelmOpt) + break; + + pelmOpt->setAttribute("name", itOpt->first); + pelmOpt->setAttribute("value", itOpt->second); + } + } /* end of if */ + + if (d.VmSlot2OptionsM.size() > 0) + { + VmSlot2OptionsConstIterator itVmSlot; + DhcpOptConstIterator itOpt1; + for(itVmSlot = d.VmSlot2OptionsM.begin(); + itVmSlot != d.VmSlot2OptionsM.end(); + ++itVmSlot) + { + xml::ElementNode *pelmCfg = pelmThis->createChild("Config"); + pelmCfg->setAttribute("vm-name", itVmSlot->first.VmName); + pelmCfg->setAttribute("slot", itVmSlot->first.Slot); + + for (itOpt1 = itVmSlot->second.begin(); + itOpt1 != itVmSlot->second.end(); + ++itOpt1) + { + xml::ElementNode *pelmOpt = pelmCfg->createChild("Option"); + pelmOpt->setAttribute("name", itOpt1->first); + pelmOpt->setAttribute("value", itOpt1->second); + } + } + } /* and of if */ + + } + + xml::ElementNode *pelmNATNetworks; + /* don't create entry if no NAT networks are registered. */ + if (!llNATNetworks.empty()) + { + pelmNATNetworks = pelmNetserviceRegistry->createChild("NATNetworks"); + for (NATNetworksList::const_iterator it = llNATNetworks.begin(); + it != llNATNetworks.end(); + ++it) + { + const NATNetwork &n = *it; + xml::ElementNode *pelmThis = pelmNATNetworks->createChild("NATNetwork"); + pelmThis->setAttribute("networkName", n.strNetworkName); + pelmThis->setAttribute("network", n.strNetwork); + pelmThis->setAttribute("ipv6", n.fIPv6 ? 1 : 0); + pelmThis->setAttribute("ipv6prefix", n.strIPv6Prefix); + pelmThis->setAttribute("advertiseDefaultIPv6Route", (n.fAdvertiseDefaultIPv6Route)? 1 : 0); + pelmThis->setAttribute("needDhcp", (n.fNeedDhcpServer) ? 1 : 0); + pelmThis->setAttribute("enabled", (n.fEnabled) ? 1 : 0); // too bad we chose 1 vs. 0 here + if (n.llPortForwardRules4.size()) + { + xml::ElementNode *pelmPf4 = pelmThis->createChild("PortForwarding4"); + buildNATForwardRuleList(*pelmPf4, n.llPortForwardRules4); + } + if (n.llPortForwardRules6.size()) + { + xml::ElementNode *pelmPf6 = pelmThis->createChild("PortForwarding6"); + buildNATForwardRuleList(*pelmPf6, n.llPortForwardRules6); + } + + if (n.llHostLoopbackOffsetList.size()) + { + xml::ElementNode *pelmMappings = pelmThis->createChild("Mappings"); + buildNATLoopbacks(*pelmMappings, n.llHostLoopbackOffsetList); + + } + } } + xml::ElementNode *pelmSysProps = pelmGlobal->createChild("SystemProperties"); if (systemProperties.strDefaultMachineFolder.length()) pelmSysProps->setAttribute("defaultMachineFolder", systemProperties.strDefaultMachineFolder); + if (systemProperties.strLoggingLevel.length()) + pelmSysProps->setAttribute("LoggingLevel", systemProperties.strLoggingLevel); if (systemProperties.strDefaultHardDiskFormat.length()) pelmSysProps->setAttribute("defaultHardDiskFormat", systemProperties.strDefaultHardDiskFormat); if (systemProperties.strVRDEAuthLibrary.length()) @@ -1406,6 +1685,9 @@ void MainConfigFile::write(const com::Utf8Str strFilename) pelmSysProps->setAttribute("LogHistoryCount", systemProperties.ulLogHistoryCount); if (systemProperties.strAutostartDatabasePath.length()) pelmSysProps->setAttribute("autostartDatabasePath", systemProperties.strAutostartDatabasePath); + if (systemProperties.strDefaultFrontend.length()) + pelmSysProps->setAttribute("defaultFrontend", systemProperties.strDefaultFrontend); + pelmSysProps->setAttribute("exclusiveHwVirt", systemProperties.fExclusiveHwVirt); buildUSBDeviceFilters(*pelmGlobal->createChild("USBDeviceFilters"), host.llUSBDeviceFilters, @@ -1474,9 +1756,22 @@ bool BIOSSettings::operator==(const BIOSSettings &d) const bool USBController::operator==(const USBController &u) const { return ( (this == &u) - || ( (fEnabled == u.fEnabled) - && (fEnabledEHCI == u.fEnabledEHCI) - && (llDeviceFilters == u.llDeviceFilters) + || ( (strName == u.strName) + && (enmType == u.enmType) + ) + ); +} + +/** + * Comparison operator. This gets called from MachineConfigFile::operator==, + * which in turn gets called from Machine::saveSettings to figure out whether + * machine settings have really changed and thus need to be written out to disk. + */ +bool USB::operator==(const USB &u) const +{ + return ( (this == &u) + || ( (llUSBControllers == u.llUSBControllers) + && (llDeviceFilters == u.llDeviceFilters) ) ); } @@ -1579,37 +1874,34 @@ bool GuestProperty::operator==(const GuestProperty &g) const ); } -// use a define for the platform-dependent default value of -// hwvirt exclusivity, since we'll need to check that value -// in bumpSettingsVersionIfNeeded() -#if defined(RT_OS_DARWIN) || defined(RT_OS_WINDOWS) - #define HWVIRTEXCLUSIVEDEFAULT false -#else - #define HWVIRTEXCLUSIVEDEFAULT true -#endif - Hardware::Hardware() : strVersion("1"), fHardwareVirt(true), - fHardwareVirtExclusive(HWVIRTEXCLUSIVEDEFAULT), fNestedPaging(true), fVPID(true), + fUnrestrictedExecution(true), fHardwareVirtForce(false), fSyntheticCpu(false), + fTripleFaultReset(false), fPAE(false), + enmLongMode(HC_ARCH_BITS == 64 ? Hardware::LongMode_Enabled : Hardware::LongMode_Disabled), cCPUs(1), fCpuHotPlug(false), fHPETEnabled(false), ulCpuExecutionCap(100), ulMemorySizeMB((uint32_t)-1), + graphicsControllerType(GraphicsControllerType_VBoxVGA), ulVRAMSizeMB(8), cMonitors(1), fAccelerate3D(false), fAccelerate2DVideo(false), - ulVideoCaptureHorzRes(640), - ulVideoCaptureVertRes(480), + ulVideoCaptureHorzRes(1024), + ulVideoCaptureVertRes(768), + ulVideoCaptureRate(512), + ulVideoCaptureFPS(25), fVideoCaptureEnabled(false), - strVideoCaptureFile("Test.webm"), + u64VideoCaptureScreens(UINT64_C(0xffffffffffffffff)), + strVideoCaptureFile(""), firmwareType(FirmwareType_BIOS), pointingHIDType(PointingHIDType_PS2Mouse), keyboardHIDType(KeyboardHIDType_PS2Keyboard), @@ -1655,13 +1947,15 @@ bool Hardware::operator==(const Hardware& h) const || ( (strVersion == h.strVersion) && (uuid == h.uuid) && (fHardwareVirt == h.fHardwareVirt) - && (fHardwareVirtExclusive == h.fHardwareVirtExclusive) && (fNestedPaging == h.fNestedPaging) && (fLargePages == h.fLargePages) && (fVPID == h.fVPID) + && (fUnrestrictedExecution == h.fUnrestrictedExecution) && (fHardwareVirtForce == h.fHardwareVirtForce) && (fSyntheticCpu == h.fSyntheticCpu) && (fPAE == h.fPAE) + && (enmLongMode == h.enmLongMode) + && (fTripleFaultReset == h.fTripleFaultReset) && (cCPUs == h.cCPUs) && (fCpuHotPlug == h.fCpuHotPlug) && (ulCpuExecutionCap == h.ulCpuExecutionCap) @@ -1670,14 +1964,18 @@ bool Hardware::operator==(const Hardware& h) const && (llCpuIdLeafs == h.llCpuIdLeafs) && (ulMemorySizeMB == h.ulMemorySizeMB) && (mapBootOrder == h.mapBootOrder) + && (graphicsControllerType == h.graphicsControllerType) && (ulVRAMSizeMB == h.ulVRAMSizeMB) && (cMonitors == h.cMonitors) && (fAccelerate3D == h.fAccelerate3D) && (fAccelerate2DVideo == h.fAccelerate2DVideo) && (fVideoCaptureEnabled == h.fVideoCaptureEnabled) + && (u64VideoCaptureScreens == h.u64VideoCaptureScreens) && (strVideoCaptureFile == h.strVideoCaptureFile) && (ulVideoCaptureHorzRes == h.ulVideoCaptureHorzRes) && (ulVideoCaptureVertRes == h.ulVideoCaptureVertRes) + && (ulVideoCaptureRate == h.ulVideoCaptureRate) + && (ulVideoCaptureFPS == h.ulVideoCaptureFPS) && (firmwareType == h.firmwareType) && (pointingHIDType == h.pointingHIDType) && (keyboardHIDType == h.keyboardHIDType) @@ -1685,7 +1983,7 @@ bool Hardware::operator==(const Hardware& h) const && (fEmulatedUSBCardReader == h.fEmulatedUSBCardReader) && (vrdeSettings == h.vrdeSettings) && (biosSettings == h.biosSettings) - && (usbController == h.usbController) + && (usbSettings == h.usbSettings) && (llNetworkAdapters == h.llNetworkAdapters) && (llSerialPorts == h.llSerialPorts) && (llParallelPorts == h.llParallelPorts) @@ -1699,6 +1997,7 @@ bool Hardware::operator==(const Hardware& h) const && (strNotificationPatterns == h.strNotificationPatterns) && (ioSettings == h.ioSettings) && (pciAttachments == h.pciAttachments) + && (strDefaultFrontend == h.strDefaultFrontend) ) ); } @@ -1716,6 +2015,7 @@ bool AttachedDevice::operator==(const AttachedDevice &a) const && (fTempEject == a.fTempEject) && (fNonRotational == a.fNonRotational) && (fDiscard == a.fDiscard) + && (fHotPluggable == a.fHotPluggable) && (lPort == a.lPort) && (lDevice == a.lDevice) && (uuid == a.uuid) @@ -2069,25 +2369,11 @@ void MachineConfigFile::readAttachedNetworkMode(const xml::ElementNode &elmMode, pelmTFTP->getAttributeValue("boot-file", nic.nat.strTFTPBootFile); pelmTFTP->getAttributeValue("next-server", nic.nat.strTFTPNextServer); } - xml::ElementNodesList plstNatPF; - elmMode.getChildElements(plstNatPF, "Forwarding"); - for (xml::ElementNodesList::iterator pf = plstNatPF.begin(); pf != plstNatPF.end(); ++pf) - { - NATRule rule; - uint32_t port = 0; - (*pf)->getAttributeValue("name", rule.strName); - (*pf)->getAttributeValue("proto", (uint32_t&)rule.proto); - (*pf)->getAttributeValue("hostip", rule.strHostIP); - (*pf)->getAttributeValue("hostport", port); - rule.u16HostPort = port; - (*pf)->getAttributeValue("guestip", rule.strGuestIP); - (*pf)->getAttributeValue("guestport", port); - rule.u16GuestPort = port; - nic.nat.llRules.push_back(rule); - } + + readNATForwardRuleList(elmMode, nic.nat.llRules); } - else if ( (elmMode.nameEquals("HostInterface")) - || (elmMode.nameEquals("BridgedInterface"))) + else if ( elmMode.nameEquals("HostInterface") + || elmMode.nameEquals("BridgedInterface")) { enmAttachmentType = NetworkAttachmentType_Bridged; @@ -2121,15 +2407,21 @@ void MachineConfigFile::readAttachedNetworkMode(const xml::ElementNode &elmMode, if (pelmModeChild->nameEquals("Property")) { Utf8Str strPropName, strPropValue; - if ( (pelmModeChild->getAttributeValue("name", strPropName)) - && (pelmModeChild->getAttributeValue("value", strPropValue)) - ) + if ( pelmModeChild->getAttributeValue("name", strPropName) + && pelmModeChild->getAttributeValue("value", strPropValue) ) nic.genericProperties[strPropName] = strPropValue; else throw ConfigFileError(this, pelmModeChild, N_("Required GenericInterface/Property/@name or @value attribute is missing")); } } } + else if (elmMode.nameEquals("NATNetwork")) + { + enmAttachmentType = NetworkAttachmentType_NATNetwork; + + if (!elmMode.getAttributeValue("name", nic.strNATNetworkName)) // required network name + throw ConfigFileError(this, &elmMode, N_("Required NATNetwork/@name element is missing")); + } else if (elmMode.nameEquals("VDE")) { enmAttachmentType = NetworkAttachmentType_Generic; @@ -2391,7 +2683,6 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtEx"))) { pelmCPUChild->getAttributeValue("enabled", hw.fHardwareVirt); - pelmCPUChild->getAttributeValue("exclusive", hw.fHardwareVirtExclusive); // settings version 1.9 } if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtExNestedPaging"))) pelmCPUChild->getAttributeValue("enabled", hw.fNestedPaging); @@ -2399,6 +2690,8 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, pelmCPUChild->getAttributeValue("enabled", hw.fLargePages); if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtExVPID"))) pelmCPUChild->getAttributeValue("enabled", hw.fVPID); + if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtExUX"))) + pelmCPUChild->getAttributeValue("enabled", hw.fUnrestrictedExecution); if ((pelmCPUChild = pelmHwChild->findChildElement("HardwareVirtForce"))) pelmCPUChild->getAttributeValue("enabled", hw.fHardwareVirtForce); @@ -2411,8 +2704,19 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, else pelmCPUChild->getAttributeValue("enabled", hw.fPAE); + bool fLongMode; + if ( (pelmCPUChild = pelmHwChild->findChildElement("LongMode")) + && pelmCPUChild->getAttributeValue("enabled", fLongMode) ) + hw.enmLongMode = fLongMode ? Hardware::LongMode_Enabled : Hardware::LongMode_Disabled; + else + hw.enmLongMode = Hardware::LongMode_Legacy; + if ((pelmCPUChild = pelmHwChild->findChildElement("SyntheticCpu"))) pelmCPUChild->getAttributeValue("enabled", hw.fSyntheticCpu); + + if ((pelmCPUChild = pelmHwChild->findChildElement("TripleFaultReset"))) + pelmCPUChild->getAttributeValue("enabled", hw.fTripleFaultReset); + if ((pelmCPUChild = pelmHwChild->findChildElement("CpuIdTree"))) readCpuIdTree(*pelmCPUChild, hw.llCpuIdLeafs); } @@ -2478,6 +2782,8 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, hw.pointingHIDType = PointingHIDType_PS2Mouse; else if (strHIDType == "ComboMouse") hw.pointingHIDType = PointingHIDType_ComboMouse; + else if (strHIDType == "USBMultiTouch") + hw.pointingHIDType = PointingHIDType_USBMultiTouch; else throw ConfigFileError(this, pelmHwChild, @@ -2553,6 +2859,23 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, } else if (pelmHwChild->nameEquals("Display")) { + Utf8Str strGraphicsControllerType; + if (!pelmHwChild->getAttributeValue("controller", strGraphicsControllerType)) + hw.graphicsControllerType = GraphicsControllerType_VBoxVGA; + else + { + strGraphicsControllerType.toUpper(); + GraphicsControllerType_T type; + if (strGraphicsControllerType == "VBOXVGA") + type = GraphicsControllerType_VBoxVGA; + else if (strGraphicsControllerType == "VMSVGA") + type = GraphicsControllerType_VMSVGA; + else if (strGraphicsControllerType == "NONE") + type = GraphicsControllerType_Null; + else + throw ConfigFileError(this, pelmHwChild, N_("Invalid value '%s' in Display/@controller attribute"), strGraphicsControllerType.c_str()); + hw.graphicsControllerType = type; + } pelmHwChild->getAttributeValue("VRAMSize", hw.ulVRAMSizeMB); if (!pelmHwChild->getAttributeValue("monitorCount", hw.cMonitors)) pelmHwChild->getAttributeValue("MonitorCount", hw.cMonitors); // pre-v1.5 variant @@ -2560,14 +2883,16 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, pelmHwChild->getAttributeValue("Accelerate3D", hw.fAccelerate3D); // pre-v1.5 variant pelmHwChild->getAttributeValue("accelerate2DVideo", hw.fAccelerate2DVideo); } - else if (pelmHwChild->nameEquals("VideoRecording")) + else if (pelmHwChild->nameEquals("VideoCapture")) { - pelmHwChild->getAttributeValue("enabled", hw.fVideoCaptureEnabled); - pelmHwChild->getAttributeValue("file", hw.strVideoCaptureFile); - pelmHwChild->getAttributeValue("horzRes", hw.ulVideoCaptureHorzRes); - pelmHwChild->getAttributeValue("vertRes", hw.ulVideoCaptureVertRes); + pelmHwChild->getAttributeValue("enabled", hw.fVideoCaptureEnabled); + pelmHwChild->getAttributeValue("screens", hw.u64VideoCaptureScreens); + pelmHwChild->getAttributeValuePath("file", hw.strVideoCaptureFile); + pelmHwChild->getAttributeValue("horzRes", hw.ulVideoCaptureHorzRes); + pelmHwChild->getAttributeValue("vertRes", hw.ulVideoCaptureVertRes); + pelmHwChild->getAttributeValue("rate", hw.ulVideoCaptureRate); + pelmHwChild->getAttributeValue("fps", hw.ulVideoCaptureFPS); } - else if (pelmHwChild->nameEquals("RemoteDisplay")) { pelmHwChild->getAttributeValue("enabled", hw.vrdeSettings.fEnabled); @@ -2631,9 +2956,8 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, { /* <Property name="TCP/Ports" value="3000-3002"/> */ Utf8Str strName, strValue; - if ( ((pelmProperty->getAttributeValue("name", strName))) - && ((pelmProperty->getAttributeValue("value", strValue))) - ) + if ( pelmProperty->getAttributeValue("name", strName) + && pelmProperty->getAttributeValue("value", strValue)) hw.vrdeSettings.mapProperties[strName] = strValue; else throw ConfigFileError(this, pelmProperty, N_("Required VRDE Property/@name or @value attribute is missing")); @@ -2679,7 +3003,7 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, // legacy BIOS/IDEController (pre 1.7) if ( (m->sv < SettingsVersion_v1_7) - && ((pelmBIOSChild = pelmHwChild->findChildElement("IDEController"))) + && (pelmBIOSChild = pelmHwChild->findChildElement("IDEController")) ) { StorageController sctl; @@ -2702,22 +3026,75 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, strg.llStorageControllers.push_back(sctl); } } - else if (pelmHwChild->nameEquals("USBController")) + else if ( (m->sv <= SettingsVersion_v1_14) + && pelmHwChild->nameEquals("USBController")) { - pelmHwChild->getAttributeValue("enabled", hw.usbController.fEnabled); - pelmHwChild->getAttributeValue("enabledEhci", hw.usbController.fEnabledEHCI); + bool fEnabled = false; + + pelmHwChild->getAttributeValue("enabled", fEnabled); + if (fEnabled) + { + /* Create OHCI controller with default name. */ + USBController ctrl; + + ctrl.strName = "OHCI"; + ctrl.enmType = USBControllerType_OHCI; + hw.usbSettings.llUSBControllers.push_back(ctrl); + } + + pelmHwChild->getAttributeValue("enabledEhci", fEnabled); + if (fEnabled) + { + /* Create OHCI controller with default name. */ + USBController ctrl; + + ctrl.strName = "EHCI"; + ctrl.enmType = USBControllerType_EHCI; + hw.usbSettings.llUSBControllers.push_back(ctrl); + } readUSBDeviceFilters(*pelmHwChild, - hw.usbController.llDeviceFilters); + hw.usbSettings.llDeviceFilters); } - else if ( (m->sv < SettingsVersion_v1_7) - && (pelmHwChild->nameEquals("SATAController")) - ) + else if (pelmHwChild->nameEquals("USB")) + { + const xml::ElementNode *pelmUSBChild; + + if ((pelmUSBChild = pelmHwChild->findChildElement("Controllers"))) + { + xml::NodesLoop nl2(*pelmUSBChild, "Controller"); + const xml::ElementNode *pelmCtrl; + + while ((pelmCtrl = nl2.forAllNodes())) + { + USBController ctrl; + com::Utf8Str strCtrlType; + + pelmCtrl->getAttributeValue("name", ctrl.strName); + + if (pelmCtrl->getAttributeValue("type", strCtrlType)) + { + if (strCtrlType == "OHCI") + ctrl.enmType = USBControllerType_OHCI; + else if (strCtrlType == "EHCI") + ctrl.enmType = USBControllerType_EHCI; + else + throw ConfigFileError(this, pelmCtrl, N_("Invalid value '%s' for Controller/@type attribute"), strCtrlType.c_str()); + } + + hw.usbSettings.llUSBControllers.push_back(ctrl); + } + } + + if ((pelmUSBChild = pelmHwChild->findChildElement("DeviceFilters"))) + readUSBDeviceFilters(*pelmUSBChild, hw.usbSettings.llDeviceFilters); + } + else if ( m->sv < SettingsVersion_v1_7 + && pelmHwChild->nameEquals("SATAController")) { bool f; - if ( (pelmHwChild->getAttributeValue("enabled", f)) - && (f) - ) + if ( pelmHwChild->getAttributeValue("enabled", f) + && f) { StorageController sctl; sctl.strName = "SATA Controller"; @@ -2734,15 +3111,15 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, else if (pelmHwChild->nameEquals("RTC")) { Utf8Str strLocalOrUTC; - machineUserData.fRTCUseUTC = pelmHwChild->getAttributeValue("localOrUTC", strLocalOrUTC) - && strLocalOrUTC == "UTC"; + machineUserData.fRTCUseUTC = pelmHwChild->getAttributeValue("localOrUTC", strLocalOrUTC) + && strLocalOrUTC == "UTC"; } - else if ( (pelmHwChild->nameEquals("UART")) - || (pelmHwChild->nameEquals("Uart")) // used before 1.3 + else if ( pelmHwChild->nameEquals("UART") + || pelmHwChild->nameEquals("Uart") // used before 1.3 ) readSerialPorts(*pelmHwChild, hw.llSerialPorts); - else if ( (pelmHwChild->nameEquals("LPT")) - || (pelmHwChild->nameEquals("Lpt")) // used before 1.3 + else if ( pelmHwChild->nameEquals("LPT") + || pelmHwChild->nameEquals("Lpt") // used before 1.3 ) readParallelPorts(*pelmHwChild, hw.llParallelPorts); else if (pelmHwChild->nameEquals("AudioAdapter")) @@ -2844,7 +3221,9 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, hw.ioSettings.llBandwidthGroups.push_back(gr); } } - } else if (pelmHwChild->nameEquals("HostPci")) { + } + else if (pelmHwChild->nameEquals("HostPci")) + { const xml::ElementNode *pelmDevices; if ((pelmDevices = pelmHwChild->findChildElement("Devices"))) @@ -2877,6 +3256,15 @@ void MachineConfigFile::readHardware(const xml::ElementNode &elmHardware, pelmCardReader->getAttributeValue("enabled", hw.fEmulatedUSBCardReader); } } + else if (pelmHwChild->nameEquals("Frontend")) + { + const xml::ElementNode *pelmDefault; + + if ((pelmDefault = pelmHwChild->findChildElement("Default"))) + { + pelmDefault->getAttributeValue("type", hw.strDefaultFrontend); + } + } } if (hw.ulMemorySizeMB == (uint32_t)-1) @@ -3099,6 +3487,7 @@ void MachineConfigFile::readStorageControllers(const xml::ElementNode &elmStorag if (!pelmAttached->getAttributeValue("device", att.lDevice)) throw ConfigFileError(this, pelmImage, N_("Required AttachedDevice/@device attribute is missing")); + pelmAttached->getAttributeValue("hotpluggable", att.fHotPluggable); pelmAttached->getAttributeValue("bandwidthGroup", att.strBwGroup); sctl.llAttachedDevices.push_back(att); } @@ -3140,9 +3529,8 @@ void MachineConfigFile::readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHar const xml::ElementNode *pDriveChild; Utf8Str strTmp; - if ( ((pDriveChild = pelmHwChild->findChildElement("Image"))) - && (pDriveChild->getAttributeValue("uuid", strTmp)) - ) + if ( (pDriveChild = pelmHwChild->findChildElement("Image")) != NULL + && pDriveChild->getAttributeValue("uuid", strTmp)) parseUUID(att.uuid, strTmp); else if ((pDriveChild = pelmHwChild->findChildElement("HostDrive"))) pDriveChild->getAttributeValue("src", att.strHostDriveSrc); @@ -3170,9 +3558,8 @@ void MachineConfigFile::readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHar else if (pelmHwChild->nameEquals("FloppyDrive")) { bool fEnabled; - if ( (pelmHwChild->getAttributeValue("enabled", fEnabled)) - && (fEnabled) - ) + if ( pelmHwChild->getAttributeValue("enabled", fEnabled) + && fEnabled) { // create a new floppy controller and attach a floppy "attached device" StorageController sctl; @@ -3188,9 +3575,8 @@ void MachineConfigFile::readDVDAndFloppies_pre1_9(const xml::ElementNode &elmHar const xml::ElementNode *pDriveChild; Utf8Str strTmp; - if ( ((pDriveChild = pelmHwChild->findChildElement("Image"))) - && (pDriveChild->getAttributeValue("uuid", strTmp)) - ) + if ( (pDriveChild = pelmHwChild->findChildElement("Image")) + && pDriveChild->getAttributeValue("uuid", strTmp) ) parseUUID(att.uuid, strTmp); else if ((pDriveChild = pelmHwChild->findChildElement("HostDrive"))) pDriveChild->getAttributeValue("src", att.strHostDriveSrc); @@ -3296,17 +3682,26 @@ void MachineConfigFile::readGroups(const xml::ElementNode *pElmGroups, StringsLi * contain a list of child snapshots; such lists are maintained in the * Snapshot structure. * + * @param curSnapshotUuid + * @param depth * @param elmSnapshot * @param snap + * @returns true if curSnapshotUuid is in this snapshot subtree, otherwise false */ -void MachineConfigFile::readSnapshot(const xml::ElementNode &elmSnapshot, +bool MachineConfigFile::readSnapshot(const Guid &curSnapshotUuid, + uint32_t depth, + const xml::ElementNode &elmSnapshot, Snapshot &snap) { + if (depth > SETTINGS_SNAPSHOT_DEPTH_MAX) + throw ConfigFileError(this, &elmSnapshot, N_("Maximum snapshot tree depth of %u exceeded"), depth); + Utf8Str strTemp; if (!elmSnapshot.getAttributeValue("uuid", strTemp)) throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@uuid attribute is missing")); parseUUID(snap.uuid, strTemp); + bool foundCurrentSnapshot = (snap.uuid == curSnapshotUuid); if (!elmSnapshot.getAttributeValue("name", snap.strName)) throw ConfigFileError(this, &elmSnapshot, N_("Required Snapshot/@name attribute is missing")); @@ -3332,13 +3727,11 @@ void MachineConfigFile::readSnapshot(const xml::ElementNode &elmSnapshot, { if (pelmSnapshotChild->nameEquals("Description")) snap.strDescription = pelmSnapshotChild->getValue(); - else if ( (m->sv < SettingsVersion_v1_7) - && (pelmSnapshotChild->nameEquals("HardDiskAttachments")) - ) + else if ( m->sv < SettingsVersion_v1_7 + && pelmSnapshotChild->nameEquals("HardDiskAttachments")) readHardDiskAttachments_pre1_7(*pelmSnapshotChild, snap.storage); - else if ( (m->sv >= SettingsVersion_v1_7) - && (pelmSnapshotChild->nameEquals("StorageControllers")) - ) + else if ( m->sv >= SettingsVersion_v1_7 + && pelmSnapshotChild->nameEquals("StorageControllers")) readStorageControllers(*pelmSnapshotChild, snap.storage); else if (pelmSnapshotChild->nameEquals("Snapshots")) { @@ -3348,9 +3741,15 @@ void MachineConfigFile::readSnapshot(const xml::ElementNode &elmSnapshot, { if (pelmChildSnapshot->nameEquals("Snapshot")) { - Snapshot child; - readSnapshot(*pelmChildSnapshot, child); - snap.llChildSnapshots.push_back(child); + // Use the heap to reduce the stack footprint. Each + // recursion needs over 1K, and there can be VMs with + // deeply nested snapshots. The stack can be quite + // small, especially with XPCOM. + Snapshot *child = new Snapshot(); + bool found = readSnapshot(curSnapshotUuid, depth + 1, *pelmChildSnapshot, *child); + foundCurrentSnapshot = foundCurrentSnapshot || found; + snap.llChildSnapshots.push_back(*child); + delete child; } } } @@ -3364,6 +3763,8 @@ void MachineConfigFile::readSnapshot(const xml::ElementNode &elmSnapshot, readDebugging(elmSnapshot.findChildElement("Debugging"), &snap.debugging); readAutostart(elmSnapshot.findChildElement("Autostart"), &snap.autostart); // note: Groups exist only for Machine, not for Snapshot + + return foundCurrentSnapshot; } const struct { @@ -3430,9 +3831,8 @@ void MachineConfigFile::convertOldOSType_pre1_5(Utf8Str &str) void MachineConfigFile::readMachine(const xml::ElementNode &elmMachine) { Utf8Str strUUID; - if ( (elmMachine.getAttributeValue("uuid", strUUID)) - && (elmMachine.getAttributeValue("name", machineUserData.strName)) - ) + if ( elmMachine.getAttributeValue("uuid", strUUID) + && elmMachine.getAttributeValue("name", machineUserData.strName)) { parseUUID(uuid, strUUID); @@ -3441,7 +3841,6 @@ void MachineConfigFile::readMachine(const xml::ElementNode &elmMachine) Utf8Str str; elmMachine.getAttributeValue("Description", machineUserData.strDescription); - elmMachine.getAttributeValue("OSType", machineUserData.strOsType); if (m->sv < SettingsVersion_v1_5) convertOldOSType_pre1_5(machineUserData.strOsType); @@ -3461,6 +3860,8 @@ void MachineConfigFile::readMachine(const xml::ElementNode &elmMachine) if (elmMachine.getAttributeValue("aborted", fAborted)) fAborted = true; + elmMachine.getAttributeValue("icon", machineUserData.ovIcon); + // parse Hardware before the other elements because other things depend on it const xml::ElementNode *pelmHardware; if (!(pelmHardware = elmMachine.findChildElement("Hardware"))) @@ -3484,9 +3885,14 @@ void MachineConfigFile::readMachine(const xml::ElementNode &elmMachine) readStorageControllers(*pelmMachineChild, storageMachine); else if (pelmMachineChild->nameEquals("Snapshot")) { + if (uuidCurrentSnapshot.isZero()) + throw ConfigFileError(this, &elmMachine, N_("Snapshots present but required Machine/@currentSnapshot attribute is missing")); + bool foundCurrentSnapshot = false; Snapshot snap; // this will recurse into child snapshots, if necessary - readSnapshot(*pelmMachineChild, snap); + foundCurrentSnapshot = readSnapshot(uuidCurrentSnapshot, 1, *pelmMachineChild, snap); + if (!foundCurrentSnapshot) + throw ConfigFileError(this, &elmMachine, N_("Snapshots present but none matches the UUID in the Machine/@currentSnapshot attribute")); llFirstSnapshot.push_back(snap); } else if (pelmMachineChild->nameEquals("Description")) @@ -3544,8 +3950,10 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, if (m->sv >= SettingsVersion_v1_4) pelmHardware->setAttribute("version", hw.strVersion); - if ( (m->sv >= SettingsVersion_v1_9) - && (!hw.uuid.isEmpty()) + + if ((m->sv >= SettingsVersion_v1_9) + && !hw.uuid.isZero() + && hw.uuid.isValid() ) pelmHardware->setAttribute("uuid", hw.uuid.toStringCurly()); @@ -3553,15 +3961,18 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, xml::ElementNode *pelmHwVirtEx = pelmCPU->createChild("HardwareVirtEx"); pelmHwVirtEx->setAttribute("enabled", hw.fHardwareVirt); - if (m->sv >= SettingsVersion_v1_9) - pelmHwVirtEx->setAttribute("exclusive", hw.fHardwareVirtExclusive); pelmCPU->createChild("HardwareVirtExNestedPaging")->setAttribute("enabled", hw.fNestedPaging); pelmCPU->createChild("HardwareVirtExVPID")->setAttribute("enabled", hw.fVPID); + pelmCPU->createChild("HardwareVirtExUX")->setAttribute("enabled", hw.fUnrestrictedExecution); pelmCPU->createChild("PAE")->setAttribute("enabled", hw.fPAE); + if (m->sv >= SettingsVersion_v1_14 && hw.enmLongMode != Hardware::LongMode_Legacy) + pelmCPU->createChild("LongMode")->setAttribute("enabled", hw.enmLongMode == Hardware::LongMode_Enabled); if (hw.fSyntheticCpu) pelmCPU->createChild("SyntheticCpu")->setAttribute("enabled", hw.fSyntheticCpu); + if (hw.fTripleFaultReset) + pelmCPU->createChild("TripleFaultReset")->setAttribute("enabled", hw.fTripleFaultReset); pelmCPU->setAttribute("count", hw.cCPUs); if (hw.ulCpuExecutionCap != 100) pelmCPU->setAttribute("executionCap", hw.ulCpuExecutionCap); @@ -3642,12 +4053,13 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, switch (hw.pointingHIDType) { - case PointingHIDType_USBMouse: pcszHID = "USBMouse"; break; - case PointingHIDType_USBTablet: pcszHID = "USBTablet"; break; - case PointingHIDType_PS2Mouse: pcszHID = "PS2Mouse"; break; - case PointingHIDType_ComboMouse: pcszHID = "ComboMouse"; break; - case PointingHIDType_None: pcszHID = "None"; break; - default: Assert(false); pcszHID = "PS2Mouse"; break; + case PointingHIDType_USBMouse: pcszHID = "USBMouse"; break; + case PointingHIDType_USBTablet: pcszHID = "USBTablet"; break; + case PointingHIDType_PS2Mouse: pcszHID = "PS2Mouse"; break; + case PointingHIDType_ComboMouse: pcszHID = "ComboMouse"; break; + case PointingHIDType_USBMultiTouch: pcszHID = "USBMultiTouch";break; + case PointingHIDType_None: pcszHID = "None"; break; + default: Assert(false); pcszHID = "PS2Mouse"; break; } pelmHID->setAttribute("Pointing", pcszHID); @@ -3709,20 +4121,35 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, } xml::ElementNode *pelmDisplay = pelmHardware->createChild("Display"); + if (hw.graphicsControllerType != GraphicsControllerType_VBoxVGA) + { + const char *pcszGraphics; + switch (hw.graphicsControllerType) + { + case GraphicsControllerType_VBoxVGA: pcszGraphics = "VBoxVGA"; break; + case GraphicsControllerType_VMSVGA: pcszGraphics = "VMSVGA"; break; + default: /*case GraphicsControllerType_Null:*/ pcszGraphics = "None"; break; + } + pelmDisplay->setAttribute("controller", pcszGraphics); + } pelmDisplay->setAttribute("VRAMSize", hw.ulVRAMSizeMB); pelmDisplay->setAttribute("monitorCount", hw.cMonitors); pelmDisplay->setAttribute("accelerate3D", hw.fAccelerate3D); if (m->sv >= SettingsVersion_v1_8) pelmDisplay->setAttribute("accelerate2DVideo", hw.fAccelerate2DVideo); - xml::ElementNode *pelmVideoCapture = pelmHardware->createChild("VideoRecording"); + xml::ElementNode *pelmVideoCapture = pelmHardware->createChild("VideoCapture"); - if (m->sv >= SettingsVersion_v1_12) + if (m->sv >= SettingsVersion_v1_14) { - pelmVideoCapture->setAttribute("enabled", hw.fVideoCaptureEnabled); - pelmVideoCapture->setAttribute("file", hw.strVideoCaptureFile); - pelmVideoCapture->setAttribute("horzRes", hw.ulVideoCaptureHorzRes); - pelmVideoCapture->setAttribute("vertRes", hw.ulVideoCaptureVertRes); + pelmVideoCapture->setAttribute("enabled", hw.fVideoCaptureEnabled); + pelmVideoCapture->setAttribute("screens", hw.u64VideoCaptureScreens); + if (!hw.strVideoCaptureFile.isEmpty()) + pelmVideoCapture->setAttributePath("file", hw.strVideoCaptureFile); + pelmVideoCapture->setAttribute("horzRes", hw.ulVideoCaptureHorzRes); + pelmVideoCapture->setAttribute("vertRes", hw.ulVideoCaptureVertRes); + pelmVideoCapture->setAttribute("rate", hw.ulVideoCaptureRate); + pelmVideoCapture->setAttribute("fps", hw.ulVideoCaptureFPS); } xml::ElementNode *pelmVRDE = pelmHardware->createChild("RemoteDisplay"); @@ -3861,7 +4288,8 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, pelmDVD->setAttribute("passthrough", att.fPassThrough); if (att.fTempEject) pelmDVD->setAttribute("tempeject", att.fTempEject); - if (!att.uuid.isEmpty()) + + if (!att.uuid.isZero() && att.uuid.isValid()) pelmDVD->createChild("Image")->setAttribute("uuid", att.uuid.toStringCurly()); else if (att.strHostDriveSrc.length()) pelmDVD->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc); @@ -3877,7 +4305,8 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, { const AttachedDevice &att = sctl.llAttachedDevices.front(); pelmFloppy->setAttribute("enabled", true); - if (!att.uuid.isEmpty()) + + if (!att.uuid.isZero() && att.uuid.isValid()) pelmFloppy->createChild("Image")->setAttribute("uuid", att.uuid.toStringCurly()); else if (att.strHostDriveSrc.length()) pelmFloppy->createChild("HostDrive")->setAttribute("src", att.strHostDriveSrc); @@ -3893,13 +4322,68 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, throw ConfigFileError(this, NULL, N_("Internal error: cannot save more than one floppy drive with old settings format")); } - xml::ElementNode *pelmUSB = pelmHardware->createChild("USBController"); - pelmUSB->setAttribute("enabled", hw.usbController.fEnabled); - pelmUSB->setAttribute("enabledEhci", hw.usbController.fEnabledEHCI); + if (m->sv < SettingsVersion_v1_14) + { + bool fOhciEnabled = false; + bool fEhciEnabled = false; + xml::ElementNode *pelmUSB = pelmHardware->createChild("USBController"); + + for (USBControllerList::const_iterator it = hardwareMachine.usbSettings.llUSBControllers.begin(); + it != hardwareMachine.usbSettings.llUSBControllers.end(); + ++it) + { + const USBController &ctrl = *it; + + switch (ctrl.enmType) + { + case USBControllerType_OHCI: + fOhciEnabled = true; + break; + case USBControllerType_EHCI: + fEhciEnabled = true; + break; + default: + AssertMsgFailed(("Unknown USB controller type %d\n", ctrl.enmType)); + } + } + + pelmUSB->setAttribute("enabled", fOhciEnabled); + pelmUSB->setAttribute("enabledEhci", fEhciEnabled); + + buildUSBDeviceFilters(*pelmUSB, hw.usbSettings.llDeviceFilters, false /* fHostMode */); + } + else + { + xml::ElementNode *pelmUSB = pelmHardware->createChild("USB"); + xml::ElementNode *pelmCtrls = pelmUSB->createChild("Controllers"); + + for (USBControllerList::const_iterator it = hardwareMachine.usbSettings.llUSBControllers.begin(); + it != hardwareMachine.usbSettings.llUSBControllers.end(); + ++it) + { + const USBController &ctrl = *it; + com::Utf8Str strType; + xml::ElementNode *pelmCtrl = pelmCtrls->createChild("Controller"); - buildUSBDeviceFilters(*pelmUSB, - hw.usbController.llDeviceFilters, - false); // fHostMode + switch (ctrl.enmType) + { + case USBControllerType_OHCI: + strType = "OHCI"; + break; + case USBControllerType_EHCI: + strType = "EHCI"; + break; + default: + AssertMsgFailed(("Unknown USB controller type %d\n", ctrl.enmType)); + } + + pelmCtrl->setAttribute("name", ctrl.strName); + pelmCtrl->setAttribute("type", strType); + } + + xml::ElementNode *pelmFilters = pelmUSB->createChild("DeviceFilters"); + buildUSBDeviceFilters(*pelmFilters, hw.usbSettings.llDeviceFilters, false /* fHostMode */); + } xml::ElementNode *pelmNetwork = pelmHardware->createChild("Network"); for (NetworkAdaptersList::const_iterator it = hw.llNetworkAdapters.begin(); @@ -3986,11 +4470,13 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, if (nic.mode != NetworkAttachmentType_Bridged) buildNetworkXML(NetworkAttachmentType_Bridged, *pelmDisabledNode, false, nic); if (nic.mode != NetworkAttachmentType_Internal) - buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, false, nic); + buildNetworkXML(NetworkAttachmentType_Internal, *pelmDisabledNode, false, nic); if (nic.mode != NetworkAttachmentType_HostOnly) buildNetworkXML(NetworkAttachmentType_HostOnly, *pelmDisabledNode, false, nic); if (nic.mode != NetworkAttachmentType_Generic) buildNetworkXML(NetworkAttachmentType_Generic, *pelmDisabledNode, false, nic); + if (nic.mode != NetworkAttachmentType_NATNetwork) + buildNetworkXML(NetworkAttachmentType_NATNetwork, *pelmDisabledNode, false, nic); buildNetworkXML(nic.mode, *pelmAdapter, true, nic); } } @@ -4181,11 +4667,19 @@ void MachineConfigFile::buildHardwareXML(xml::ElementNode &elmParent, if (m->sv >= SettingsVersion_v1_12) { xml::ElementNode *pelmEmulatedUSB = pelmHardware->createChild("EmulatedUSB"); - xml::ElementNode *pelmCardReader = pelmEmulatedUSB->createChild("CardReader"); + xml::ElementNode *pelmCardReader = pelmEmulatedUSB->createChild("CardReader"); pelmCardReader->setAttribute("enabled", hw.fEmulatedUSBCardReader); } + if ( m->sv >= SettingsVersion_v1_14 + && !hw.strDefaultFrontend.isEmpty()) + { + xml::ElementNode *pelmFrontend = pelmHardware->createChild("Frontend"); + xml::ElementNode *pelmDefault = pelmFrontend->createChild("Default"); + pelmDefault->setAttribute("type", hw.strDefaultFrontend); + } + xml::ElementNode *pelmGuest = pelmHardware->createChild("Guest"); pelmGuest->setAttribute("memoryBalloonSize", hw.ulMemoryBalloonSize); @@ -4263,23 +4757,7 @@ void MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode, if (nic.nat.strTFTPNextServer.length()) pelmTFTP->setAttribute("next-server", nic.nat.strTFTPNextServer); } - for (NATRuleList::const_iterator rule = nic.nat.llRules.begin(); - rule != nic.nat.llRules.end(); ++rule) - { - xml::ElementNode *pelmPF; - pelmPF = pelmNAT->createChild("Forwarding"); - if ((*rule).strName.length()) - pelmPF->setAttribute("name", (*rule).strName); - pelmPF->setAttribute("proto", (*rule).proto); - if ((*rule).strHostIP.length()) - pelmPF->setAttribute("hostip", (*rule).strHostIP); - if ((*rule).u16HostPort) - pelmPF->setAttribute("hostport", (*rule).u16HostPort); - if ((*rule).strGuestIP.length()) - pelmPF->setAttribute("guestip", (*rule).strGuestIP); - if ((*rule).u16GuestPort) - pelmPF->setAttribute("guestport", (*rule).u16GuestPort); - } + buildNATForwardRuleList(*pelmNAT, nic.nat.llRules); break; case NetworkAttachmentType_Bridged: @@ -4313,6 +4791,11 @@ void MachineConfigFile::buildNetworkXML(NetworkAttachmentType_T mode, } break; + case NetworkAttachmentType_NATNetwork: + if (fEnabled || !nic.strNATNetworkName.isEmpty()) + elmParent.createChild("NATNetwork")->setAttribute("name", nic.strNATNetworkName); + break; + default: /*case NetworkAttachmentType_Null:*/ break; } @@ -4348,7 +4831,7 @@ void MachineConfigFile::buildStorageControllersXML(xml::ElementNode &elmParent, if ( (m->sv < SettingsVersion_v1_9) && (sc.controllerType == StorageControllerType_I82078) ) - // floppy controller already got written into <Hardware>/<FloppyController> in writeHardware() + // floppy controller already got written into <Hardware>/<FloppyController> in buildHardwareXML() // for pre-1.9 settings continue; @@ -4443,6 +4926,9 @@ void MachineConfigFile::buildStorageControllersXML(xml::ElementNode &elmParent, pelmDevice->setAttribute("type", pcszType); + if (att.fHotPluggable) + pelmDevice->setAttribute("hotpluggable", att.fHotPluggable); + pelmDevice->setAttribute("port", att.lPort); pelmDevice->setAttribute("device", att.lDevice); @@ -4450,8 +4936,9 @@ void MachineConfigFile::buildStorageControllersXML(xml::ElementNode &elmParent, pelmDevice->setAttribute("bandwidthGroup", att.strBwGroup); // attached image, if any - if ( !att.uuid.isEmpty() - && ( att.deviceType == DeviceType_HardDisk + if (!att.uuid.isZero() + && att.uuid.isValid() + && (att.deviceType == DeviceType_HardDisk || !fSkipRemovableMedia ) ) @@ -4547,12 +5034,18 @@ void MachineConfigFile::buildGroupsXML(xml::ElementNode *pElmParent, const Strin * Writes a single snapshot into the DOM tree. Initially this gets called from MachineConfigFile::write() * for the root snapshot of a machine, if present; elmParent then points to the <Snapshots> node under the * <Machine> node to which <Snapshot> must be added. This may then recurse for child snapshots. + * + * @param depth * @param elmParent * @param snap */ -void MachineConfigFile::buildSnapshotXML(xml::ElementNode &elmParent, +void MachineConfigFile::buildSnapshotXML(uint32_t depth, + xml::ElementNode &elmParent, const Snapshot &snap) { + if (depth > SETTINGS_SNAPSHOT_DEPTH_MAX) + throw ConfigFileError(this, NULL, N_("Maximum snapshot tree depth of %u exceeded"), SETTINGS_SNAPSHOT_DEPTH_MAX); + xml::ElementNode *pelmSnapshot = elmParent.createChild("Snapshot"); pelmSnapshot->setAttribute("uuid", snap.uuid.toStringCurly()); @@ -4584,7 +5077,7 @@ void MachineConfigFile::buildSnapshotXML(xml::ElementNode &elmParent, ++it) { const Snapshot &child = *it; - buildSnapshotXML(*pelmChildren, child); + buildSnapshotXML(depth + 1, *pelmChildren, child); } } } @@ -4613,7 +5106,7 @@ void MachineConfigFile::buildSnapshotXML(xml::ElementNode &elmParent, * that, if snapshots are present. Otherwise all snapshots are suppressed * (when called from OVF). * - * -- BuildMachineXML_WriteVboxVersionAttribute: If set, add a settingsVersion + * -- BuildMachineXML_WriteVBoxVersionAttribute: If set, add a settingsVersion * attribute to the machine tag with the vbox settings version. This is for * the OVF export case in which we don't have the settings version set in * the root element. @@ -4637,7 +5130,7 @@ void MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine, uint32_t fl, std::list<xml::ElementNode*> *pllElementsWithUuidAttributes) { - if (fl & BuildMachineXML_WriteVboxVersionAttribute) + if (fl & BuildMachineXML_WriteVBoxVersionAttribute) // add settings version attribute to machine element setVersionAttribute(elmMachine); @@ -4654,8 +5147,10 @@ void MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine, && !(fl & BuildMachineXML_SuppressSavedState) ) elmMachine.setAttributePath("stateFile", strStateFile); - if ( (fl & BuildMachineXML_IncludeSnapshots) - && !uuidCurrentSnapshot.isEmpty()) + + if ((fl & BuildMachineXML_IncludeSnapshots) + && !uuidCurrentSnapshot.isZero() + && uuidCurrentSnapshot.isValid()) elmMachine.setAttribute("currentSnapshot", uuidCurrentSnapshot.toStringCurly()); if (machineUserData.strSnapshotFolder.length()) @@ -4665,6 +5160,10 @@ void MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine, elmMachine.setAttribute("lastStateChange", makeString(timeLastStateChange)); if (fAborted) elmMachine.setAttribute("aborted", fAborted); + // Please keep the icon last so that one doesn't have to check if there + // is anything in the line after this very long attribute in the XML. + if (machineUserData.ovIcon.length()) + elmMachine.setAttribute("icon", machineUserData.ovIcon); if ( m->sv >= SettingsVersion_v1_9 && ( machineUserData.fTeleporterEnabled || machineUserData.uTeleporterPort @@ -4717,7 +5216,7 @@ void MachineConfigFile::buildMachineXML(xml::ElementNode &elmMachine, if ( (fl & BuildMachineXML_IncludeSnapshots) && llFirstSnapshot.size()) - buildSnapshotXML(elmMachine, llFirstSnapshot.front()); + buildSnapshotXML(1, elmMachine, llFirstSnapshot.front()); buildHardwareXML(elmMachine, hardwareMachine, storageMachine); buildStorageControllersXML(elmMachine, @@ -4842,6 +5341,69 @@ AudioDriverType_T MachineConfigFile::getHostDefaultAudioDriver() */ void MachineConfigFile::bumpSettingsVersionIfNeeded() { + if (m->sv < SettingsVersion_v1_14) + { + // VirtualBox 4.3 adds default frontend setting, graphics controller + // setting, explicit long mode setting, video capturing and NAT networking. + if ( !hardwareMachine.strDefaultFrontend.isEmpty() + || hardwareMachine.graphicsControllerType != GraphicsControllerType_VBoxVGA + || hardwareMachine.enmLongMode != Hardware::LongMode_Legacy + || machineUserData.ovIcon.length() > 0 + || hardwareMachine.fVideoCaptureEnabled) + { + m->sv = SettingsVersion_v1_14; + return; + } + NetworkAdaptersList::const_iterator netit; + for (netit = hardwareMachine.llNetworkAdapters.begin(); + netit != hardwareMachine.llNetworkAdapters.end(); + ++netit) + { + if (netit->mode == NetworkAttachmentType_NATNetwork) + { + m->sv = SettingsVersion_v1_14; + break; + } + } + } + + if (m->sv < SettingsVersion_v1_14) + { + unsigned cOhciCtrls = 0; + unsigned cEhciCtrls = 0; + bool fNonStdName = false; + + for (USBControllerList::const_iterator it = hardwareMachine.usbSettings.llUSBControllers.begin(); + it != hardwareMachine.usbSettings.llUSBControllers.end(); + ++it) + { + const USBController &ctrl = *it; + + switch (ctrl.enmType) + { + case USBControllerType_OHCI: + cOhciCtrls++; + if (ctrl.strName != "OHCI") + fNonStdName = true; + break; + case USBControllerType_EHCI: + cEhciCtrls++; + if (ctrl.strName != "EHCI") + fNonStdName = true; + break; + default: + AssertMsgFailed(("Unknown USB controller type %d\n", ctrl.enmType)); + } + + /* Skip checking other controllers if the settings bump is necessary. */ + if (cOhciCtrls > 1 || cEhciCtrls > 1 || fNonStdName) + { + m->sv = SettingsVersion_v1_14; + break; + } + } + } + if (m->sv < SettingsVersion_v1_13) { // VirtualBox 4.2 adds tracing, autostart, UUID in directory and groups. @@ -4872,15 +5434,9 @@ void MachineConfigFile::bumpSettingsVersionIfNeeded() if (m->sv < SettingsVersion_v1_12) { - // 4.1: Emulated USB devices. - if (hardwareMachine.fEmulatedUSBCardReader) - m->sv = SettingsVersion_v1_12; - } - - if (m->sv < SettingsVersion_v1_12) - { - // VirtualBox 4.1 adds PCI passthrough. - if (hardwareMachine.pciAttachments.size()) + // VirtualBox 4.1 adds PCI passthrough and emulated USB Smart Card reader + if ( hardwareMachine.pciAttachments.size() + || hardwareMachine.fEmulatedUSBCardReader) m->sv = SettingsVersion_v1_12; } @@ -5168,12 +5724,11 @@ void MachineConfigFile::bumpSettingsVersionIfNeeded() // all the following require settings version 1.9 if ( (m->sv < SettingsVersion_v1_9) && ( (hardwareMachine.firmwareType >= FirmwareType_EFI) - || (hardwareMachine.fHardwareVirtExclusive != HWVIRTEXCLUSIVEDEFAULT) || machineUserData.fTeleporterEnabled || machineUserData.uTeleporterPort || !machineUserData.strTeleporterAddress.isEmpty() || !machineUserData.strTeleporterPassword.isEmpty() - || !hardwareMachine.uuid.isEmpty() + || (!hardwareMachine.uuid.isZero() && hardwareMachine.uuid.isValid()) ) ) m->sv = SettingsVersion_v1_9; @@ -5212,7 +5767,7 @@ void MachineConfigFile::write(const com::Utf8Str &strFilename) buildMachineXML(*pelmMachine, MachineConfigFile::BuildMachineXML_IncludeSnapshots | MachineConfigFile::BuildMachineXML_MediaRegistry, - // but not BuildMachineXML_WriteVboxVersionAttribute + // but not BuildMachineXML_WriteVBoxVersionAttribute NULL); /* pllElementsWithUuidAttributes */ // now go write the XML diff --git a/src/VBox/Main/xml/SettingsConverter.xsl b/src/VBox/Main/xml/SettingsConverter.xsl deleted file mode 100644 index 9a31a4cc..00000000 --- a/src/VBox/Main/xml/SettingsConverter.xsl +++ /dev/null @@ -1,1043 +0,0 @@ -<?xml version="1.0"?> - -<!-- - * :tabSize=2:indentSize=2:noTabs=true: - * :folding=explicit:collapseFolds=1: - * - * Template to convert old VirtualBox settings files to the most recent format. - - Copyright (C) 2006-2009 Oracle Corporation - - This file is part of VirtualBox Open Source Edition (OSE), as - available from http://www.virtualbox.org. This file is free software; - you can redistribute it and/or modify it under the terms of the GNU - General Public License (GPL) as published by the Free Software - Foundation, in version 2 as it comes in the "COPYING" file of the - VirtualBox OSE distribution. VirtualBox OSE is distributed in the - hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ---> - -<xsl:stylesheet version="1.0" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns:vb="http://www.innotek.de/VirtualBox-settings" - xmlns="http://www.innotek.de/VirtualBox-settings" - exclude-result-prefixes="#default vb xsl xsd" -> - -<xsl:output method="xml" indent="yes"/> - -<xsl:variable name="curVer" select="substring-before(/vb:VirtualBox/@version, '-')"/> -<xsl:variable name="curVerPlat" select="substring-after(/vb:VirtualBox/@version, '-')"/> -<xsl:variable name="curVerFull" select="/vb:VirtualBox/@version"/> - -<xsl:template match="/"> - <xsl:comment> Automatically converted from version '<xsl:value-of select="$curVerFull"/>' </xsl:comment> - <xsl:copy> - <xsl:apply-templates select="@*|node()"/> - </xsl:copy> -</xsl:template> - -<!-- - * comments outside the root node are gathered to a single line, fix this ---> -<xsl:template match="/comment()"> - <xsl:copy-of select="."/> -</xsl:template> - -<!-- - * Forbid non-VirtualBox root nodes ---> -<xsl:template match="/*"> - <xsl:message terminate="yes"> -Cannot convert an unknown XML file with the root node '<xsl:value-of select="name()"/>'! - </xsl:message> -</xsl:template> - -<!-- - * Forbid all unsupported VirtualBox settings versions ---> -<xsl:template match="/vb:VirtualBox"> - <xsl:message terminate="yes"> -Cannot convert settings from version '<xsl:value-of select="@version"/>'. -The source version is not supported. - </xsl:message> -</xsl:template> - -<!-- - * Accept supported settings versions (source setting files we can convert) - * - * Note that in order to simplify conversion from versions prior to the previous - * one, we support multi-step conversion like this: step 1: 1.0 => 1.1, - * step 2: 1.1 => 1.2, where 1.2 is the most recent version. If you want to use - * such multi-step mode, you need to ensure that only 1.0 => 1.1 is possible, by - * using the 'mode=1.1' attribute on both 'apply-templates' within the starting - * '/vb:VirtualBox[1.0]' template and within all templates that this - * 'apply-templates' should apply. - * - * If no 'mode' attribute is used as described above, then a direct conversion - * (1.0 => 1.2 in the above example) will happen when version 1.0 of the settings - * files is detected. Note that the direct conversion from pre-previous versions - * will require to patch their conversion templates so that they include all - * modifications from all newer versions, which is error-prone. It's better to - * use the milt-step mode. ---> - -<!-- 1.1 => 1.2 --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.1']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.2','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.2"/> - </xsl:copy> -</xsl:template> - -<!-- 1.2 => 1.3.pre --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.2']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.3.pre','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.3.pre"/> - </xsl:copy> -</xsl:template> - -<!-- 1.3.pre => 1.3 --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.3.pre']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.3','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.3"/> - </xsl:copy> -</xsl:template> - -<!-- 1.3 => 1.4 --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.3']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.4','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.4"/> - </xsl:copy> -</xsl:template> - -<!-- 1.4 => 1.5 --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.4']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.5','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.5"/> - </xsl:copy> -</xsl:template> - -<!-- 1.5 => 1.6 --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.5']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.6','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.6"/> - </xsl:copy> -</xsl:template> - -<!-- 1.6 => 1.7 --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.6']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.7','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.7"/> - </xsl:copy> -</xsl:template> - -<!-- 1.7 => 1.8 --> -<xsl:template match="/vb:VirtualBox[substring-before(@version,'-')='1.7']"> - <xsl:copy> - <xsl:attribute name="version"><xsl:value-of select="concat('1.8','-',$curVerPlat)"/></xsl:attribute> - <xsl:apply-templates select="node()" mode="v1.8"/> - </xsl:copy> -</xsl:template> - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.1 => 1.2 - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> - -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.2"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.2"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.1']/ - vb:Global/vb:DiskImageRegistry/vb:HardDiskImages// - vb:Image" - mode="v1.2"> - <DiffHardDisk> - <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute> - <VirtualDiskImage> - <xsl:attribute name="filePath"><xsl:value-of select="@src"/></xsl:attribute> - </VirtualDiskImage> - <xsl:apply-templates select="vb:Image"/> - </DiffHardDisk> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.1']/ - vb:Global/vb:DiskImageRegistry" - mode="v1.2"> -<DiskRegistry> - <HardDisks> - <xsl:for-each select="vb:HardDiskImages/vb:Image"> - <HardDisk> - <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute> - <xsl:attribute name="type"> - <xsl:choose> - <xsl:when test="@independent='immutable'">immutable</xsl:when> - <xsl:when test="@independent='mutable'">immutable</xsl:when> - <xsl:otherwise>normal</xsl:otherwise> - </xsl:choose> - </xsl:attribute> - <VirtualDiskImage> - <xsl:attribute name="filePath"><xsl:value-of select="@src"/></xsl:attribute> - </VirtualDiskImage> - <xsl:apply-templates select="vb:Image"/> - </HardDisk> - </xsl:for-each> - </HardDisks> - <xsl:copy-of select="vb:DVDImages"/> - <xsl:copy-of select="vb:FloppyImages"/> -</DiskRegistry> -</xsl:template> - -<!-- - * Machine settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.1']/ - vb:Machine//vb:HardDisks" - mode="v1.2"> - <HardDiskAttachments> - <xsl:for-each select="vb:HardDisk"> - <HardDiskAttachment> - <xsl:attribute name="hardDisk"><xsl:value-of select="vb:Image/@uuid"/></xsl:attribute> - <xsl:apply-templates select="@*"/> - </HardDiskAttachment> - </xsl:for-each> - </HardDiskAttachments> -</xsl:template> - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.2 => 1.3.pre - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> - -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.3.pre"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.3.pre"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> - -<!-- - * Machine settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.2']/ - vb:Machine//vb:USBController" - mode="v1.3.pre"> - <xsl:copy> - <xsl:apply-templates select="@*|node()" mode="v1.3.pre"/> - </xsl:copy> - <SATAController enabled="false"/> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.2']/ - vb:Machine//vb:HardDiskAttachments/vb:HardDiskAttachment" - mode="v1.3.pre"> - <HardDiskAttachment> - <xsl:attribute name="hardDisk"><xsl:value-of select="@hardDisk"/></xsl:attribute> - <xsl:attribute name="bus"> - <xsl:choose> - <xsl:when test="@bus='ide0'"> - <xsl:text>IDE</xsl:text> - </xsl:when> - <xsl:when test="@bus='ide1'"> - <xsl:text>IDE</xsl:text> - </xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes"> -Value '<xsl:value-of select="@bus"/>' of 'HardDiskAttachment::bus' attribute is invalid. - </xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - <xsl:attribute name="channel">0</xsl:attribute> - <xsl:attribute name="device"> - <xsl:choose> - <xsl:when test="@device='master'"> - <xsl:text>0</xsl:text> - </xsl:when> - <xsl:when test="@device='slave'"> - <xsl:text>1</xsl:text> - </xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes"> -Value '<xsl:value-of select="@device"/>' of 'HardDiskAttachment::device' attribute is invalid. - </xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - </HardDiskAttachment> -</xsl:template> - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.3.pre => 1.3 - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> - -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.3"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.3"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Global//vb:SystemProperties" - mode="v1.3"> - <xsl:copy> - <xsl:apply-templates select="@*[not(name()='defaultSavedStateFolder')]|node()" mode="v1.3"/> - </xsl:copy> -</xsl:template> - -<!-- - * Machine settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Machine//vb:AudioAdapter" - mode="v1.3"> - <xsl:if test="not(../vb:Uart)"> - <UART/> - </xsl:if> - <xsl:if test="not(../vb:Lpt)"> - <LPT/> - </xsl:if> - <xsl:copy> - <xsl:apply-templates select="@*[not(name()='driver')]|node()" mode="v1.3"/> - <xsl:attribute name="driver"> - <xsl:choose> - <xsl:when test="@driver='null'">Null</xsl:when> - <xsl:when test="@driver='oss'">OSS</xsl:when> - <xsl:when test="@driver='alsa'">ALSA</xsl:when> - <xsl:when test="@driver='pulse'">Pulse</xsl:when> - <xsl:when test="@driver='coreaudio'">CoreAudio</xsl:when> - <xsl:when test="@driver='winmm'">WinMM</xsl:when> - <xsl:when test="@driver='dsound'">DirectSound</xsl:when> - <xsl:when test="@driver='solaudio'">SolAudio</xsl:when> - <xsl:when test="@driver='mmpm'">MMPM</xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes"> -Value '<xsl:value-of select="@driver"/>' of 'AudioAdapter::driver' attribute is invalid. - </xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - </xsl:copy> - <xsl:if test="not(../vb:SharedFolders)"> - <SharedFolders/> - </xsl:if> - <xsl:if test="not(../vb:Clipboard)"> - <Clipboard mode="Disabled"/> - </xsl:if> - <xsl:if test="not(../vb:Guest)"> - <Guest/> - </xsl:if> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Machine//vb:RemoteDisplay" - mode="v1.3"> - <xsl:copy> - <xsl:apply-templates select="@*[not(name()='authType')]|node()" mode="v1.3"/> - <xsl:attribute name="authType"> - <xsl:choose> - <xsl:when test="@authType='null'">Null</xsl:when> - <xsl:when test="@authType='guest'">Guest</xsl:when> - <xsl:when test="@authType='external'">External</xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes"> -Value '<xsl:value-of select="@authType"/>' of 'RemoteDisplay::authType' attribute is invalid. - </xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - </xsl:copy> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Machine//vb:BIOS/vb:BootMenu" - mode="v1.3"> - <xsl:copy> - <xsl:apply-templates select="@*[not(name()='mode')]|node()" mode="v1.3"/> - <xsl:attribute name="mode"> - <xsl:choose> - <xsl:when test="@mode='disabled'">Disabled</xsl:when> - <xsl:when test="@mode='menuonly'">MenuOnly</xsl:when> - <xsl:when test="@mode='messageandmenu'">MessageAndMenu</xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes"> -Value '<xsl:value-of select="@mode"/>' of 'BootMenu::mode' attribute is invalid. - </xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - </xsl:copy> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Machine//vb:USBController/vb:DeviceFilter | - vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Global/vb:USBDeviceFilters/vb:DeviceFilter" - mode="v1.3"> - <xsl:copy> - <xsl:apply-templates select="node()" mode="v1.3"/> - <xsl:for-each select="@*"> - <xsl:choose> - <xsl:when test="name()='vendorid'"> - <xsl:attribute name="vendorId"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:when test="name()='productid'"> - <xsl:attribute name="productId"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:when test="name()='serialnumber'"> - <xsl:attribute name="serialNumber"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates select="." mode="v1.3"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </xsl:copy> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Machine//vb:Guest" - mode="v1.3"> - <xsl:copy> - <xsl:apply-templates select="node()" mode="v1.3"/> - <xsl:for-each select="@*"> - <xsl:choose> - <xsl:when test="name()='MemoryBalloonSize'"> - <xsl:attribute name="memoryBalloonSize"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:when test="name()='StatisticsUpdateInterval'"> - <xsl:attribute name="statisticsUpdateInterval"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates select="node()" mode="v1.3"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </xsl:copy> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Machine//vb:Uart" - mode="v1.3"> - <UART> - <xsl:apply-templates select="@*|node()" mode="v1.3"/> - </UART> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3.pre']/ - vb:Machine//vb:Lpt" - mode="v1.3"> - <LPT> - <xsl:apply-templates select="@*|node()" mode="v1.3"/> - </LPT> -</xsl:template> - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.3 => 1.4 - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> - -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.4"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.4"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:DiskRegistry/vb:HardDisks/vb:HardDisk | - vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:DiskRegistry/vb:HardDisks//vb:DiffHardDisk" - mode="v1.4-HardDisk-format-location"> - <xsl:attribute name="format"> - <xsl:choose> - <xsl:when test="*[self::vb:VirtualDiskImage][1]">VDI</xsl:when> - <xsl:when test="*[self::vb:VMDKImage][1]">VMDK</xsl:when> - <xsl:when test="*[self::vb:VHDImage][1]">VHD</xsl:when> - <xsl:when test="*[self::vb:ISCSIHardDisk][1]">iSCSI</xsl:when> - <xsl:when test="*[self::vb:CustomHardDisk][1]"> - <xsl:value-of select="@format"/> - </xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes"> -Sub-element '<xsl:value-of select="name(*[1])"/>' of 'HardDisk' element is invalid. - </xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - <xsl:attribute name="location"> - <xsl:choose> - <xsl:when test="*[self::vb:VirtualDiskImage][1]"> - <xsl:value-of select="vb:VirtualDiskImage/@filePath"/> - </xsl:when> - <xsl:when test="*[self::vb:VMDKImage][1]"> - <xsl:value-of select="vb:VMDKImage/@filePath"/> - </xsl:when> - <xsl:when test="*[self::vb:VHDImage][1]"> - <xsl:value-of select="vb:VHDImage/@filePath"/> - </xsl:when> - <xsl:when test="*[self::vb:CustomHardDisk][1]"> - <xsl:value-of select="vb:CustomHardDisk/@location"/> - </xsl:when> - <xsl:when test="*[self::vb:ISCSIHardDisk][1]"> - <xsl:text>iscsi://</xsl:text> - <xsl:if test="vb:ISCSIHardDisk/@userName"> - <xsl:value-of select="vb:ISCSIHardDisk/@userName"/> - <!-- note that for privacy reasons we don't show the password in the - location string --> - <xsl:text>@</xsl:text> - </xsl:if> - <xsl:if test="vb:ISCSIHardDisk/@server"> - <xsl:value-of select="vb:ISCSIHardDisk/@server"/> - <xsl:if test="vb:ISCSIHardDisk/@port"> - <xsl:value-of select="concat(':',vb:ISCSIHardDisk/@port)"/> - </xsl:if> - </xsl:if> - <xsl:if test="vb:ISCSIHardDisk/@target"> - <xsl:value-of select="concat('/',vb:ISCSIHardDisk/@target)"/> - </xsl:if> - <xsl:if test="vb:ISCSIHardDisk/@lun"> - <xsl:value-of select="concat('/enc',vb:ISCSIHardDisk/@lun)"/> - </xsl:if> - <xsl:if test="not(vb:ISCSIHardDisk/@server) or not(vb:ISCSIHardDisk/@target)"> - <xsl:message terminate="yes"> -Required attribute 'server' or 'target' is missing from ISCSIHardDisk element! - </xsl:message> - </xsl:if> - </xsl:when> - </xsl:choose> - </xsl:attribute> - <xsl:if test="*[self::vb:ISCSIHardDisk][1]"> - <xsl:choose> - <xsl:when test="vb:ISCSIHardDisk/@server and vb:ISCSIHardDisk/@port"> - <xsl:element name="Property"> - <xsl:attribute name="name">TargetAddress</xsl:attribute> - <xsl:attribute name="value"> - <xsl:value-of select="concat(vb:ISCSIHardDisk/@server, - ':',vb:ISCSIHardDisk/@port)"/> - </xsl:attribute> - </xsl:element> - </xsl:when> - <xsl:when test="vb:ISCSIHardDisk/@server"> - <xsl:element name="Property"> - <xsl:attribute name="name">TargetAddress</xsl:attribute> - <xsl:attribute name="value"> - <xsl:value-of select="vb:ISCSIHardDisk/@server"/> - </xsl:attribute> - </xsl:element> - </xsl:when> - </xsl:choose> - <xsl:if test="vb:ISCSIHardDisk/@target"> - <xsl:element name="Property"> - <xsl:attribute name="name">TargetName</xsl:attribute> - <xsl:attribute name="value"> - <xsl:value-of select="vb:ISCSIHardDisk/@target"/> - </xsl:attribute> - </xsl:element> - </xsl:if> - <xsl:if test="vb:ISCSIHardDisk/@userName"> - <xsl:element name="Property"> - <xsl:attribute name="name">InitiatorUsername</xsl:attribute> - <xsl:attribute name="value"> - <xsl:value-of select="vb:ISCSIHardDisk/@userName"/> - </xsl:attribute> - </xsl:element> - </xsl:if> - <xsl:if test="vb:ISCSIHardDisk/@password"> - <xsl:element name="Property"> - <xsl:attribute name="name">InitiatorSecret</xsl:attribute> - <xsl:attribute name="value"> - <xsl:value-of select="vb:ISCSIHardDisk/@password"/> - </xsl:attribute> - </xsl:element> - </xsl:if> - <xsl:if test="vb:ISCSIHardDisk/@lun"> - <xsl:element name="Property"> - <xsl:attribute name="name">LUN</xsl:attribute> - <xsl:attribute name="value"> - <xsl:value-of select="concat('enc',vb:ISCSIHardDisk/@lun)"/> - </xsl:attribute> - </xsl:element> - </xsl:if> - </xsl:if> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:DiskRegistry/vb:HardDisks/vb:HardDisk" - mode="v1.4"> - <HardDisk> - <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute> - <xsl:attribute name="type"> - <xsl:choose> - <xsl:when test="@type='normal'">Normal</xsl:when> - <xsl:when test="@type='immutable'">Immutable</xsl:when> - <xsl:when test="@type='writethrough'">Writethrough</xsl:when> - <xsl:otherwise> - <xsl:message terminate="yes"> -Value '<xsl:value-of select="@type"/>' of 'HardDisk::type' attribute is invalid. - </xsl:message> - </xsl:otherwise> - </xsl:choose> - </xsl:attribute> - <xsl:apply-templates select="." mode="v1.4-HardDisk-format-location"/> - <xsl:apply-templates select="vb:DiffHardDisk" mode="v1.4"/> - </HardDisk> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:DiskRegistry/vb:HardDisks/vb:HardDisk// - vb:DiffHardDisk" - mode="v1.4"> - <HardDisk> - <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute> - <xsl:apply-templates select="." mode="v1.4-HardDisk-format-location"/> - <xsl:apply-templates select="vb:DiffHardDisk" mode="v1.4"/> - </HardDisk> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:DiskRegistry/vb:DVDImages/vb:Image | - vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:DiskRegistry/vb:FloppyImages/vb:Image" - mode="v1.4"> - <Image> - <xsl:attribute name="uuid"><xsl:value-of select="@uuid"/></xsl:attribute> - <xsl:attribute name="location"><xsl:value-of select="@src"/></xsl:attribute> - </Image> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:DiskRegistry" - mode="v1.4"> - <MediaRegistry> - <HardDisks> - <xsl:apply-templates select="vb:HardDisks/vb:HardDisk" mode="v1.4"/> - </HardDisks> - <DVDImages> - <xsl:apply-templates select="vb:DVDImages/vb:Image" mode="v1.4"/> - </DVDImages> - <FloppyImages> - <xsl:apply-templates select="vb:FloppyImages/vb:Image" mode="v1.4"/> - </FloppyImages> - </MediaRegistry> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Global/vb:SystemProperties" - mode="v1.4"> - <SystemProperties> - <xsl:apply-templates select="@*[not(name()='defaultVDIFolder')]|node()" mode="v1.4"/> - <!-- use the @defaultVDIFolder value for @defaultHardDiskFolder only when it - differs from the default (VDI) and otherwise simply delete it to let - VBoxSVC set the correct new default value --> - <xsl:if test="@defaultVDIFolder and not(translate(@defaultVDIFolder,'vdi','VDI')='VDI')"> - <xsl:attribute name="defaultHardDiskFolder"> - <xsl:value-of select="@defaultVDIFolder"/> - </xsl:attribute> - </xsl:if> - </SystemProperties> -</xsl:template> - -<!-- - * Machine settings ---> - - <xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.3']/ - vb:Machine/vb:Hardware" - mode="v1.4"> - <!-- add version attribute to Hardware if parent Machine has a stateFile attribute --> - <xsl:copy> - <xsl:if test="../@stateFile"> - <xsl:attribute name="version">1</xsl:attribute> - </xsl:if> - <xsl:apply-templates select="node()" mode="v1.4"/> - </xsl:copy> -</xsl:template> - - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.4 => 1.5 - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> - -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.5"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.5"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> - -<!-- - * Machine settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.4']/ - vb:Machine" - mode="v1.5"> - <xsl:copy> - <xsl:attribute name="OSType"> - <xsl:choose> - <xsl:when test="@OSType='unknown'">Other</xsl:when> - <xsl:when test="@OSType='dos'">DOS</xsl:when> - <xsl:when test="@OSType='win31'">Windows31</xsl:when> - <xsl:when test="@OSType='win95'">Windows95</xsl:when> - <xsl:when test="@OSType='win98'">Windows98</xsl:when> - <xsl:when test="@OSType='winme'">WindowsMe</xsl:when> - <xsl:when test="@OSType='winnt4'">WindowsNT4</xsl:when> - <xsl:when test="@OSType='win2k'">Windows2000</xsl:when> - <xsl:when test="@OSType='winxp'">WindowsXP</xsl:when> - <xsl:when test="@OSType='win2k3'">Windows2003</xsl:when> - <xsl:when test="@OSType='winvista'">WindowsVista</xsl:when> - <xsl:when test="@OSType='win2k8'">Windows2008</xsl:when> - <xsl:when test="@OSType='os2warp3'">OS2Warp3</xsl:when> - <xsl:when test="@OSType='os2warp4'">OS2Warp4</xsl:when> - <xsl:when test="@OSType='os2warp45'">OS2Warp45</xsl:when> - <xsl:when test="@OSType='ecs'">OS2eCS</xsl:when> - <xsl:when test="@OSType='linux22'">Linux22</xsl:when> - <xsl:when test="@OSType='linux24'">Linux24</xsl:when> - <xsl:when test="@OSType='linux26'">Linux26</xsl:when> - <xsl:when test="@OSType='archlinux'">ArchLinux</xsl:when> - <xsl:when test="@OSType='debian'">Debian</xsl:when> - <xsl:when test="@OSType='opensuse'">OpenSUSE</xsl:when> - <xsl:when test="@OSType='fedoracore'">Fedora</xsl:when> - <xsl:when test="@OSType='gentoo'">Gentoo</xsl:when> - <xsl:when test="@OSType='mandriva'">Mandriva</xsl:when> - <xsl:when test="@OSType='redhat'">RedHat</xsl:when> - <xsl:when test="@OSType='ubuntu'">Ubuntu</xsl:when> - <xsl:when test="@OSType='xandros'">Xandros</xsl:when> - <xsl:when test="@OSType='freebsd'">FreeBSD</xsl:when> - <xsl:when test="@OSType='openbsd'">OpenBSD</xsl:when> - <xsl:when test="@OSType='netbsd'">NetBSD</xsl:when> - <xsl:when test="@OSType='netware'">Netware</xsl:when> - <xsl:when test="@OSType='solaris'">Solaris</xsl:when> - <xsl:when test="@OSType='opensolaris'">OpenSolaris</xsl:when> - <xsl:when test="@OSType='l4'">L4</xsl:when> - </xsl:choose> - </xsl:attribute> - <xsl:apply-templates select="@*[name()!='OSType']" mode="v1.5"/> - <xsl:apply-templates select="node()" mode="v1.5"/> - </xsl:copy> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.4']/ - vb:Machine//vb:Hardware/vb:Display" - mode="v1.5"> - <xsl:copy> - <xsl:apply-templates select="node()" mode="v1.5"/> - <xsl:for-each select="@*"> - <xsl:choose> - <xsl:when test="name()='MonitorCount'"> - <xsl:attribute name="monitorCount"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:when test="name()='Accelerate3D'"> - <xsl:attribute name="accelerate3D"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates select="." mode="v1.5"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </xsl:copy> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.4']/ - vb:Machine//vb:Hardware/vb:CPU" - mode="v1.5"> - <xsl:copy> - <xsl:if test="vb:CPUCount/@count"> - <xsl:attribute name="count"><xsl:value-of select="vb:CPUCount/@count"/></xsl:attribute> - </xsl:if> - <xsl:apply-templates select="@*" mode="v1.5"/> - <xsl:apply-templates select="node()[not(self::vb:CPUCount)]" mode="v1.5"/> - </xsl:copy> -</xsl:template> - - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.5 => 1.6 - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> - - -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.6"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.6"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> - -<!-- - * Machine settings ---> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.5' and - not(substring-after(@version,'-')='windows')]/ - vb:Machine//vb:Hardware/vb:Network/vb:Adapter/ - vb:HostInterface[@TAPSetup or @TAPTerminate]" - mode="v1.6"> - <!-- just remove the node --> -</xsl:template> - - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.6 => 1.7 - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.7"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.7"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Global" - mode="v1.7" > - <xsl:copy> - <xsl:apply-templates mode="v1.7" /> - <NetserviceRegistry> - <DHCPServers> - <xsl:choose> - <xsl:when test="substring-after(../@version,'-')='windows'"> - <DHCPServer networkName="HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter" - IPAddress="192.168.56.100" networkMask="255.255.255.0" - lowerIP="192.168.56.101" upperIP="192.168.56.254" - enabled="1"/> - </xsl:when> - <xsl:otherwise> - <DHCPServer networkName="HostInterfaceNetworking-vboxnet0" - IPAddress="192.168.56.2" networkMask="255.255.255.0" - lowerIP="192.168.56.3" upperIP="192.168.56.255" - enabled="1"/> - </xsl:otherwise> - </xsl:choose> - </DHCPServers> - </NetserviceRegistry> - </xsl:copy> -</xsl:template> - -<!-- - * Machine settings ---> -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshots" - mode="v1.7"> - <xsl:for-each select="vb:Snapshot"> - <xsl:apply-templates select="." mode="v1.7"/> - </xsl:for-each> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:HardDiskAttachments | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshot/vb:HardDiskAttachments | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshot/vb:Snapshots//vb:Snapshot/vb:HardDiskAttachments" - mode="v1.7"> - <StorageControllers> - <StorageController name="IDE Controller"> - <xsl:choose> - <xsl:when test="not(../vb:Hardware/vb:BIOS/vb:IDEController)"> - <xsl:attribute name="type">PIIX3</xsl:attribute> - </xsl:when> - <xsl:otherwise> - <xsl:attribute name="type"><xsl:value-of select="../vb:Hardware/vb:BIOS/vb:IDEController/@type"/></xsl:attribute> - </xsl:otherwise> - </xsl:choose> - <xsl:attribute name="PortCount">2</xsl:attribute> - <xsl:for-each select="./vb:HardDiskAttachment[@bus = 'IDE']"> - <xsl:apply-templates select="." mode="v1.7-attached-device"/> - </xsl:for-each> - </StorageController> - <xsl:if test="../vb:Hardware/vb:SATAController/@enabled='true'"> - <StorageController name="SATA"> - <xsl:attribute name="type">AHCI</xsl:attribute> - <xsl:attribute name="PortCount"> - <xsl:value-of select="../vb:Hardware/vb:SATAController/@PortCount"/> - </xsl:attribute> - <xsl:attribute name="IDE0MasterEmulationPort"> - <xsl:value-of select="../vb:Hardware/vb:SATAController/@IDE0MasterEmulationPort"/> - </xsl:attribute> - <xsl:attribute name="IDE0SlaveEmulationPort"> - <xsl:value-of select="../vb:Hardware/vb:SATAController/@IDE0SlaveEmulationPort"/> - </xsl:attribute> - <xsl:attribute name="IDE1MasterEmulationPort"> - <xsl:value-of select="../vb:Hardware/vb:SATAController/@IDE1MasterEmulationPort"/> - </xsl:attribute> - <xsl:attribute name="IDE1SlaveEmulationPort"> - <xsl:value-of select="../vb:Hardware/vb:SATAController/@IDE1SlaveEmulationPort"/> - </xsl:attribute> - <xsl:for-each select="./vb:HardDiskAttachment[@bus = 'SATA']"> - <xsl:apply-templates select="." mode="v1.7-attached-device"/> - </xsl:for-each> - </StorageController> - </xsl:if> - </StorageControllers> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:HardDiskAttachments/vb:HardDiskAttachment | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshot/vb:HardDiskAttachments/vb:HardDiskAttachment | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshot/vb:Snapshots//vb:Snapshot/vb:HardDiskAttachments/ - vb:HardDiskAttachment" - mode="v1.7-attached-device"> - <AttachedDevice> - <xsl:attribute name="type">HardDisk</xsl:attribute> - <xsl:attribute name="port"><xsl:value-of select="@channel"/></xsl:attribute> - <xsl:attribute name="device"><xsl:value-of select="@device"/></xsl:attribute> - <xsl:element name="Image"> - <xsl:attribute name="uuid"><xsl:value-of select="@hardDisk"/></xsl:attribute> - </xsl:element> - </AttachedDevice> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine//vb:Hardware/vb:BIOS/vb:IDEController | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine//vb:Snapshot/vb:Hardware/vb:BIOS/vb:IDEController | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshot/vb:Snapshots//vb:Snapshot/vb:Hardware/vb:BIOS/vb:IDEController" - mode="v1.7"> - <!-- just remove the node --> -</xsl:template> - -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Hardware/vb:SATAController | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshot/vb:Hardware/vb:SATAController | - vb:VirtualBox[substring-before(@version,'-')='1.6']/ - vb:Machine/vb:Snapshot/vb:Snapshots//vb:Snapshot/vb:Hardware/vb:SATAController" - mode="v1.7"> - <!-- just remove the node --> -</xsl:template> - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * 1.7 => 1.8 - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> -<!-- - * all non-root elements that are not explicitly matched are copied as is ---> -<xsl:template match="@*|node()[../..]" mode="v1.8"> - <xsl:copy> - <xsl:apply-templates select="@*|node()[../..]" mode="v1.8"/> - </xsl:copy> -</xsl:template> - -<!-- - * Global settings ---> - -<!-- - * Machine settings ---> - -<!--xsl:template match="vb:VirtualBox[substring-before(@version,'-')='1.7']/ - vb:Machine//vb:Hardware/vb:Display" - mode="v1.8"> - <xsl:copy> - <xsl:apply-templates select="node()" mode="v1.8"/> - <xsl:for-each select="@*"> - <xsl:choose> - <xsl:when test="name()='Accelerate2DVideo'"> - <xsl:attribute name="accelerate2DVideo"><xsl:value-of select="."/></xsl:attribute> - </xsl:when> - <xsl:otherwise> - <xsl:apply-templates select="." mode="v1.8"/> - </xsl:otherwise> - </xsl:choose> - </xsl:for-each> - </xsl:copy> -</xsl:template--> - -<!-- - * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---> - - -<!-- @todo add lastStateChange with the current timestamp if missing. - * current-dateTime() is available only in XPath 2.0 so we will need to pass - * the current time as a parameter to the XSLT processor. --> -<!-- -<xsl:template match="vb:VirtualBox[substring-before(@version,'-')='Xo.Yo']/ - vb:Machine" - mode="X.Y"> - <xsl:copy> - <xsl:if test="not(@lastStateChange)"> - <xsl:attribute name="lastStateChange"> - <xsl:value-of select="current-dateTime()"/> - </xsl:attribute> - </xsl:if> - <xsl:apply-templates select="@*|node()" mode="vX.Y"/> - </xsl:copy> -</xsl:template> ---> - -</xsl:stylesheet> diff --git a/src/VBox/Main/xml/VirtualBox-settings-freebsd.xsd b/src/VBox/Main/xml/VirtualBox-settings-freebsd.xsd deleted file mode 100644 index d874c9c9..00000000 --- a/src/VBox/Main/xml/VirtualBox-settings-freebsd.xsd +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * :tabSize=2:indentSize=2:noTabs=true: - * :folding=explicit:collapseFolds=1: - * - * Oracle VM VirtualBox Settings Schema Version 1.0-freebsd - - Copyright (C) 2004-2010 Oracle Corporation - - This file is part of VirtualBox Open Source Edition (OSE), as - available from http://www.virtualbox.org. This file is free software; - you can redistribute it and/or modify it under the terms of the GNU - General Public License (GPL) as published by the Free Software - Foundation, in version 2 as it comes in the "COPYING" file of the - VirtualBox OSE distribution. VirtualBox OSE is distributed in the - hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ---> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.innotek.de/VirtualBox-settings" - xmlns:vb="http://www.innotek.de/VirtualBox-settings" - targetNamespace="http://www.innotek.de/VirtualBox-settings" - elementFormDefault="qualified" -> - -<xsd:annotation> - <xsd:documentation xml:lang="en"> - Oracle VM VirtualBox Settings Schema (freebsd). - Copyright (c) 2004-2010 Oracle Corporation - </xsd:documentation> -</xsd:annotation> - -<xsd:include schemaLocation="VirtualBox-settings-common.xsd"/> - -<!-- - this includes a computed VirtualBox element definition that contains - a proper 'version' attribute constraint (e.g. recent version number - and platform suffix) ---> -<xsd:include schemaLocation="VirtualBox-settings-root.xsd"/> - -<!-- -// Simple types -///////////////////////////////////////////////////////////////////////// ---> - -<!-- -// Complex types -///////////////////////////////////////////////////////////////////////// ---> - -<xsd:complexType name="TAudioAdapter"> - <xsd:complexContent> - <xsd:extension base="TAudioAdapterBase"> - <xsd:attribute name="driver" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="Null"/> - <xsd:enumeration value="OSS"/> - <xsd:enumeration value="ALSA"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - </xsd:extension> - </xsd:complexContent> -</xsd:complexType> - -</xsd:schema> diff --git a/src/VBox/Main/xml/VirtualBox-settings-linux.xsd b/src/VBox/Main/xml/VirtualBox-settings-linux.xsd deleted file mode 100644 index 461521eb..00000000 --- a/src/VBox/Main/xml/VirtualBox-settings-linux.xsd +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * :tabSize=2:indentSize=2:noTabs=true: - * :folding=explicit:collapseFolds=1: - * - * Oracle VM VirtualBox Settings Schema Version 1.0-linux - - Copyright (C) 2004-2010 Oracle Corporation - - This file is part of VirtualBox Open Source Edition (OSE), as - available from http://www.virtualbox.org. This file is free software; - you can redistribute it and/or modify it under the terms of the GNU - General Public License (GPL) as published by the Free Software - Foundation, in version 2 as it comes in the "COPYING" file of the - VirtualBox OSE distribution. VirtualBox OSE is distributed in the - hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ---> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.innotek.de/VirtualBox-settings" - xmlns:vb="http://www.innotek.de/VirtualBox-settings" - targetNamespace="http://www.innotek.de/VirtualBox-settings" - elementFormDefault="qualified" -> - -<xsd:annotation> - <xsd:documentation xml:lang="en"> - Oracle VM VirtualBox Settings Schema (linux). - Copyright (c) 2004-2010 Oracle Corporation - </xsd:documentation> -</xsd:annotation> - -<xsd:include schemaLocation="VirtualBox-settings-common.xsd"/> - -<!-- - this includes a computed VirtualBox element definition that contains - a proper 'version' attribute constraint (e.g. recent version number - and platform suffix) ---> -<xsd:include schemaLocation="VirtualBox-settings-root.xsd"/> - -<!-- -// Simple types -///////////////////////////////////////////////////////////////////////// ---> - -<!-- -// Complex types -///////////////////////////////////////////////////////////////////////// ---> - -<xsd:complexType name="TAudioAdapter"> - <xsd:complexContent> - <xsd:extension base="TAudioAdapterBase"> - <xsd:attribute name="driver" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="Null"/> - <xsd:enumeration value="OSS"/> - <xsd:enumeration value="ALSA"/> - <xsd:enumeration value="Pulse"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - </xsd:extension> - </xsd:complexContent> -</xsd:complexType> - -</xsd:schema> diff --git a/src/VBox/Main/xml/VirtualBox-settings-macosx.xsd b/src/VBox/Main/xml/VirtualBox-settings-macosx.xsd deleted file mode 100644 index 1d2efa76..00000000 --- a/src/VBox/Main/xml/VirtualBox-settings-macosx.xsd +++ /dev/null @@ -1,68 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * :tabSize=2:indentSize=2:noTabs=true: - * :folding=explicit:collapseFolds=1: - * - * Oracle VM VirtualBox Settings Schema Version 1.0-macosx - - Copyright (C) 2004-2010 Oracle Corporation - - This file is part of VirtualBox Open Source Edition (OSE), as - available from http://www.virtualbox.org. This file is free software; - you can redistribute it and/or modify it under the terms of the GNU - General Public License (GPL) as published by the Free Software - Foundation, in version 2 as it comes in the "COPYING" file of the - VirtualBox OSE distribution. VirtualBox OSE is distributed in the - hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ---> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.innotek.de/VirtualBox-settings" - xmlns:vb="http://www.innotek.de/VirtualBox-settings" - targetNamespace="http://www.innotek.de/VirtualBox-settings" - elementFormDefault="qualified" -> - -<xsd:annotation> - <xsd:documentation xml:lang="en"> - Oracle VM VirtualBox Settings Schema (macosx). - Copyright (c) 2004-2010 Oracle Corporation - </xsd:documentation> -</xsd:annotation> - -<xsd:include schemaLocation="VirtualBox-settings-common.xsd"/> - -<!-- - this includes a computed VirtualBox element definition that contains - a proper 'version' attribute constraint (e.g. recent version number - and platform suffix) ---> -<xsd:include schemaLocation="VirtualBox-settings-root.xsd"/> - -<!-- -// Simple types -///////////////////////////////////////////////////////////////////////// ---> - -<!-- -// Complex types -///////////////////////////////////////////////////////////////////////// ---> - -<xsd:complexType name="TAudioAdapter"> - <xsd:complexContent> - <xsd:extension base="TAudioAdapterBase"> - <xsd:attribute name="driver" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="Null"/> - <xsd:enumeration value="CoreAudio"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - </xsd:extension> - </xsd:complexContent> -</xsd:complexType> - -</xsd:schema> diff --git a/src/VBox/Main/xml/VirtualBox-settings-os2.xsd b/src/VBox/Main/xml/VirtualBox-settings-os2.xsd deleted file mode 100644 index 771a9738..00000000 --- a/src/VBox/Main/xml/VirtualBox-settings-os2.xsd +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- - * :tabSize=2:indentSize=2:noTabs=true: - * :folding=explicit:collapseFolds=1: - * - * Oracle VM VirtualBox Settings Schema Version 1.0-os2 - * - Copyright (C) 2004-2010 Oracle Corporation - - This file is part of VirtualBox Open Source Edition (OSE), as - available from http://www.virtualbox.org. This file is free software; - you can redistribute it and/or modify it under the terms of the GNU - General Public License (GPL) as published by the Free Software - Foundation, in version 2 as it comes in the "COPYING" file of the - VirtualBox OSE distribution. VirtualBox OSE is distributed in the - hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ---> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.innotek.de/VirtualBox-settings" - xmlns:vb="http://www.innotek.de/VirtualBox-settings" - targetNamespace="http://www.innotek.de/VirtualBox-settings" - elementFormDefault="qualified" -> - -<xsd:annotation> - <xsd:documentation xml:lang="en"> - Oracle VM VirtualBox Settings Schema (os2). - Copyright (c) 2004-2010 Oracle Corporation - </xsd:documentation> -</xsd:annotation> - -<xsd:include schemaLocation="VirtualBox-settings-common.xsd"/> - -<!-- - this includes a computed VirtualBox element definition that contains - a proper 'version' attribute constraint (e.g. recent version number - and platform suffix) ---> -<xsd:include schemaLocation="VirtualBox-settings-root.xsd"/> - -<!-- -// Simple types -///////////////////////////////////////////////////////////////////////// ---> - -<!-- -// Complex types -///////////////////////////////////////////////////////////////////////// ---> - -<xsd:complexType name="TAudioAdapter"> - <xsd:complexContent> - <xsd:extension base="TAudioAdapterBase"> - <xsd:attribute name="driver" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="Null"/> - <xsd:enumeration value="MMPM"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - </xsd:extension> - </xsd:complexContent> -</xsd:complexType> - -</xsd:schema> diff --git a/src/VBox/Main/xml/VirtualBox-settings-solaris.xsd b/src/VBox/Main/xml/VirtualBox-settings-solaris.xsd deleted file mode 100644 index 6e504e5a..00000000 --- a/src/VBox/Main/xml/VirtualBox-settings-solaris.xsd +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * :tabSize=2:indentSize=2:noTabs=true: - * :folding=explicit:collapseFolds=1: - * - * Oracle VM VirtualBox Settings Schema Version 1.0-solaris - - Copyright (C) 2004-2010 Oracle Corporation - - This file is part of VirtualBox Open Source Edition (OSE), as - available from http://www.virtualbox.org. This file is free software; - you can redistribute it and/or modify it under the terms of the GNU - General Public License (GPL) as published by the Free Software - Foundation, in version 2 as it comes in the "COPYING" file of the - VirtualBox OSE distribution. VirtualBox OSE is distributed in the - hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ---> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.innotek.de/VirtualBox-settings" - xmlns:vb="http://www.innotek.de/VirtualBox-settings" - targetNamespace="http://www.innotek.de/VirtualBox-settings" - elementFormDefault="qualified" -> - -<xsd:annotation> - <xsd:documentation xml:lang="en"> - Oracle VM VirtualBox Settings Schema (solaris). - Copyright (c) 2004-2010 Oracle Corporation - </xsd:documentation> -</xsd:annotation> - -<xsd:include schemaLocation="VirtualBox-settings-common.xsd"/> - -<!-- - this includes a computed VirtualBox element definition that contains - a proper 'version' attribute constraint (e.g. recent version number - and platform suffix) ---> -<xsd:include schemaLocation="VirtualBox-settings-root.xsd"/> - -<!-- -// Simple types -///////////////////////////////////////////////////////////////////////// ---> - -<!-- -// Complex types -///////////////////////////////////////////////////////////////////////// ---> - -<xsd:complexType name="TAudioAdapter"> - <xsd:complexContent> - <xsd:extension base="TAudioAdapterBase"> - <xsd:attribute name="driver" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="Null"/> - <xsd:enumeration value="SolAudio"/> - <xsd:enumeration value="OSS"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - </xsd:extension> - </xsd:complexContent> -</xsd:complexType> - -</xsd:schema> diff --git a/src/VBox/Main/xml/VirtualBox-settings-windows.xsd b/src/VBox/Main/xml/VirtualBox-settings-windows.xsd deleted file mode 100644 index 8bdae19e..00000000 --- a/src/VBox/Main/xml/VirtualBox-settings-windows.xsd +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * :tabSize=2:indentSize=2:noTabs=true: - * :folding=explicit:collapseFolds=1: - * - * Oracle VM VirtualBox Settings Schema Version 1.0-windows - - Copyright (C) 2004-2010 Oracle Corporation - - This file is part of VirtualBox Open Source Edition (OSE), as - available from http://www.virtualbox.org. This file is free software; - you can redistribute it and/or modify it under the terms of the GNU - General Public License (GPL) as published by the Free Software - Foundation, in version 2 as it comes in the "COPYING" file of the - VirtualBox OSE distribution. VirtualBox OSE is distributed in the - hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ---> - -<xsd:schema - xmlns:xsd="http://www.w3.org/2001/XMLSchema" - xmlns="http://www.innotek.de/VirtualBox-settings" - xmlns:vb="http://www.innotek.de/VirtualBox-settings" - targetNamespace="http://www.innotek.de/VirtualBox-settings" - elementFormDefault="qualified" -> - -<xsd:annotation> - <xsd:documentation xml:lang="en"> - Oracle VM VirtualBox Settings Schema (windows). - Copyright (c) 2004-2010 Oracle Corporation - </xsd:documentation> -</xsd:annotation> - -<xsd:include schemaLocation="VirtualBox-settings-common.xsd"/> - -<!-- - this includes a computed VirtualBox element definition that contains - a proper 'version' attribute constraint (e.g. recent version number - and platform suffix) ---> -<xsd:include schemaLocation="VirtualBox-settings-root.xsd"/> - -<!-- -// Simple types -///////////////////////////////////////////////////////////////////////// ---> - -<!-- -// Complex types -///////////////////////////////////////////////////////////////////////// ---> - -<xsd:complexType name="TAudioAdapter"> - <xsd:complexContent> - <xsd:extension base="TAudioAdapterBase"> - <xsd:attribute name="driver" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="Null"/> - <xsd:enumeration value="WinMM"/> - <xsd:enumeration value="DirectSound"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - </xsd:extension> - </xsd:complexContent> -</xsd:complexType> - -</xsd:schema> diff --git a/src/VBox/Main/xml/VirtualBox-settings-common.xsd b/src/VBox/Main/xml/VirtualBox-settings.xsd index ffc3866b..dc393df0 100644 --- a/src/VBox/Main/xml/VirtualBox-settings-common.xsd +++ b/src/VBox/Main/xml/VirtualBox-settings.xsd @@ -6,7 +6,7 @@ * Oracle VM VirtualBox Settings Schema * Common definitions - Copyright (C) 2004-2012 Oracle Corporation + Copyright (C) 2004-2013 Oracle Corporation This file is part of VirtualBox Open Source Edition (OSE), as available from http://www.virtualbox.org. This file is free software; @@ -28,7 +28,7 @@ <xsd:annotation> <xsd:documentation xml:lang="en"> Oracle VM VirtualBox Settings Schema (common definitions). - Copyright (c) 2004-2012 Oracle Corporation + Copyright (c) 2004-2013 Oracle Corporation </xsd:documentation> </xsd:annotation> @@ -77,6 +77,18 @@ </xsd:union> </xsd:simpleType> +<xsd:simpleType name="TUInt16Hex"> + <xsd:restriction base="xsd:string"> + <xsd:pattern value="0x[A-Fa-f0-9]{1,4}"/> + </xsd:restriction> +</xsd:simpleType> + +<xsd:simpleType name="TUInt16HexNoBase"> + <xsd:restriction base="xsd:string"> + <xsd:pattern value="[A-Fa-f0-9]{1,4}"/> + </xsd:restriction> +</xsd:simpleType> + <xsd:simpleType name="TUInt32Hex"> <xsd:restriction base="xsd:string"> <xsd:pattern value="0x[A-Fa-f0-9]{1,8}"/> @@ -95,21 +107,40 @@ </xsd:restriction> </xsd:simpleType> -<xsd:simpleType name="TDiskType"> +<xsd:simpleType name="TDeviceType"> <xsd:restriction base="xsd:token"> - <xsd:enumeration value="HD"/> + <xsd:enumeration value="None"/> + <xsd:enumeration value="Floppy"/> <xsd:enumeration value="DVD"/> - <xsd:enumeration value="FD"/> + <xsd:enumeration value="HardDisk"/> + <xsd:enumeration value="Network"/> </xsd:restriction> </xsd:simpleType> -<xsd:simpleType name="TDeviceType"> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="None"/> +<xsd:simpleType name="TMediumDeviceType"> + <xsd:restriction base="TDeviceType"> <xsd:enumeration value="Floppy"/> <xsd:enumeration value="DVD"/> <xsd:enumeration value="HardDisk"/> - <xsd:enumeration value="Network"/> + </xsd:restriction> +</xsd:simpleType> + +<xsd:simpleType name="TMediumType"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="Normal"/> + <xsd:enumeration value="Immutable"/> + <xsd:enumeration value="Writethrough"/> + <xsd:enumeration value="Shareable"/> + <xsd:enumeration value="Readonly"/> + <xsd:enumeration value="MultiAttach"/> + </xsd:restriction> +</xsd:simpleType> + +<xsd:simpleType name="TMonitorCount"> + <xsd:restriction base="xsd:unsignedInt"> + <xsd:minInclusive value="1"/> + <!-- This should be in sync with VBOX_VIDEO_MAX_SCREENS in VBoxVideoVBE.h --> + <xsd:maxInclusive value="64"/> </xsd:restriction> </xsd:simpleType> @@ -137,6 +168,7 @@ <xsd:simpleType name="TAuthType"> <xsd:restriction base="xsd:string"> + <xsd:enumeration value="null"/> <!-- deprecated --> <xsd:enumeration value="Null"/> <xsd:enumeration value="Guest"/> <xsd:enumeration value="External"/> @@ -167,6 +199,14 @@ <xsd:enumeration value="Disabled"/> <xsd:enumeration value="MenuOnly"/> <xsd:enumeration value="MessageAndMenu"/> + <xsd:enumeration value="messageandmenu"/> <!-- deprecated --> + </xsd:restriction> +</xsd:simpleType> + +<xsd:simpleType name="TLocalOrUTC"> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="local"/> + <xsd:enumeration value="UTC"/> </xsd:restriction> </xsd:simpleType> @@ -188,6 +228,13 @@ </xsd:restriction> </xsd:simpleType> +<xsd:simpleType name="TBandwidthGroupType"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="Disk"/> + <xsd:enumeration value="Network"/> + </xsd:restriction> +</xsd:simpleType> + <xsd:simpleType name="TPortMode"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Disconnected"/> @@ -210,15 +257,15 @@ <xsd:attribute name="enabled" type="xsd:boolean" use="required"/> </xsd:complexType> +<xsd:complexType name="TProperty"> + <xsd:attribute name="name" type="xsd:token" use="required"/> + <xsd:attribute name="value" type="xsd:string" use="required"/> +</xsd:complexType> + <xsd:complexType name="THardDiskBase"> <xsd:sequence> <xsd:element name="Description" type="xsd:string" minOccurs="0"/> - <xsd:element name="Property" minOccurs="0" maxOccurs="unbounded"> - <xsd:complexType> - <xsd:attribute name="name" type="xsd:token" use="required"/> - <xsd:attribute name="value" type="xsd:string" use="required"/> - </xsd:complexType> - </xsd:element> + <xsd:element name="Property" type="TProperty" minOccurs="0" maxOccurs="unbounded"/> <xsd:element name="HardDisk" type="TDiffHardDisk" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="uuid" type="TNonNullUUID" use="required"/> @@ -237,18 +284,7 @@ <xsd:complexType name="THardDisk"> <xsd:complexContent> <xsd:extension base="THardDiskBase"> - <xsd:attribute name="type" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:string"> - <xsd:enumeration value="Normal"/> - <xsd:enumeration value="Immutable"/> - <xsd:enumeration value="Writethrough"/> - <xsd:enumeration value="Shareable"/> - <xsd:enumeration value="Readonly"/> - <xsd:enumeration value="MultiAttach"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> + <xsd:attribute name="type" type="TMediumType" use="required"/> </xsd:extension> </xsd:complexContent> </xsd:complexType> @@ -259,6 +295,7 @@ </xsd:sequence> <xsd:attribute name="uuid" type="TNonNullUUID" use="required"/> <xsd:attribute name="location" type="TLocalFile" use="required"/> + <xsd:attribute name="type" type="TMediumType"/> </xsd:complexType> <xsd:complexType name="TImageRef"> @@ -300,6 +337,7 @@ <xsd:attribute name="defaultVRDELibrary" type="TLocalFile"/> <xsd:attribute name="HWVirtExEnabled" type="xsd:boolean"/> <xsd:attribute name="LogHistoryCount" type="xsd:unsignedInt" default="3"/> + <xsd:attribute name="defaultVRDEExtPack" type="xsd:string"/> </xsd:complexType> <xsd:complexType name="TExtraData"> @@ -313,6 +351,32 @@ </xsd:sequence> </xsd:complexType> +<xsd:complexType name="TMediaRegistry"> + <xsd:all> + <xsd:element name="HardDisks" minOccurs="0"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="HardDisk" type="THardDisk" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="DVDImages" minOccurs="0"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="Image" type="TImage2" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + <xsd:element name="FloppyImages" minOccurs="0"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="Image" type="TImage2" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:all> +</xsd:complexType> + <xsd:complexType name="TGlobal"> <xsd:all> <xsd:element name="MachineRegistry"> @@ -327,33 +391,7 @@ </xsd:sequence> </xsd:complexType> </xsd:element> - <xsd:element name="MediaRegistry"> - <xsd:complexType> - <xsd:all> - <xsd:element name="HardDisks" minOccurs="0"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="HardDisk" type="THardDisk" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - <xsd:element name="DVDImages" minOccurs="0"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="Image" type="TImage2" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - <xsd:element name="FloppyImages" minOccurs="0"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="Image" type="TImage2" minOccurs="0" maxOccurs="unbounded"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> - </xsd:all> - </xsd:complexType> - </xsd:element> + <xsd:element name="MediaRegistry" type="TMediaRegistry"/> <xsd:element name="NetserviceRegistry" minOccurs="0" maxOccurs="1"> <xsd:complexType> <xsd:all> @@ -401,6 +439,14 @@ <xsd:attribute name="enabled" type="xsd:boolean"/> </xsd:complexType> +<xsd:complexType name="THardwareVirtExLargePages"> + <xsd:attribute name="enabled" type="xsd:boolean"/> +</xsd:complexType> + +<xsd:complexType name="THardwareVirtForce"> + <xsd:attribute name="enabled" type="xsd:boolean"/> +</xsd:complexType> + <xsd:simpleType name="TCPUCount"> <xsd:restriction base="xsd:unsignedInt"> <xsd:minInclusive value="1"/> @@ -429,6 +475,8 @@ <xsd:element name="HardwareVirtExNestedPaging" type="THWVirtExNestedPagingType" minOccurs="0"/> <xsd:element name="HardwareVirtExVPID" type="THWVirtExVPIDType" minOccurs="0"/> <xsd:element name="PAE" type="TPAEType" minOccurs="0"/> + <xsd:element name="HardwareVirtExLargePages" type="THardwareVirtExLargePages" minOccurs="0"/> + <xsd:element name="HardwareVirtForce" type="THardwareVirtForce" minOccurs="0"/> <xsd:element name="SyntheticCpu" type="TSyntheticCpuType" minOccurs="0"/> <xsd:element name="CpuIdTree" type="TCpuIdTree" minOccurs="0"> <xsd:unique name="TCPU-CpuIdTree-CpuIdLeaf"> @@ -438,6 +486,7 @@ </xsd:element> </xsd:sequence> <xsd:attribute name="count" type="TCPUCount" default="1"/> + <xsd:attribute name="hotplug" type="xsd:boolean" default="false"/> </xsd:complexType> <xsd:complexType name="TBoot"> @@ -459,21 +508,6 @@ </xsd:complexType> <xsd:complexType name="TDisplay"> - <xsd:element name="VideoRecording"> - <xsd:complexType> - <xsd:attribute name="enabled" type="xsd:boolean"/> - <xsd:attribute name="file" type="xsd:string"/> - <xsd:attribute name="horzRes" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:unsignedInt"> - <xsd:minInclusive value="4"/> - <xsd:maxInclusive value="2097152"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - <xsd:attribute name="vertRes" type="xsd:unsignedInt"/> - </xsd:complexType> - </xsd:element> <xsd:attribute name="VRAMSize" use="required"> <xsd:simpleType> <xsd:restriction base="xsd:unsignedInt"> @@ -482,19 +516,46 @@ </xsd:restriction> </xsd:simpleType> </xsd:attribute> - <xsd:attribute name="monitorCount" default="1"> + <xsd:attribute name="monitorCount" type="TMonitorCount" default="1"/> + <xsd:attribute name="MonitorCount" type="TMonitorCount"/> <!-- deprecated --> + <xsd:attribute name="accelerate3D" type="xsd:boolean" default="false"/> + <xsd:attribute name="accelerate2DVideo" type="xsd:boolean" default="false"/> +</xsd:complexType> + +<xsd:complexType name="TVideoRecording"> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> + <xsd:attribute name="file" type="xsd:string"/> + <xsd:attribute name="horzRes"> <xsd:simpleType> <xsd:restriction base="xsd:unsignedInt"> - <xsd:maxInclusive value="8"/> - </xsd:restriction> - </xsd:simpleType> + <xsd:minInclusive value="4"/> + <xsd:maxInclusive value="2097152"/> + </xsd:restriction> + </xsd:simpleType> </xsd:attribute> - <xsd:attribute name="accelerate3D" type="xsd:boolean" default="false"/> - <xsd:attribute name="accelerate2DVideo" type="xsd:boolean" default="false"/> + <xsd:attribute name="vertRes" type="xsd:unsignedInt"/> +</xsd:complexType> + +<xsd:complexType name="TVRDEProperties"> + <xsd:sequence> + <xsd:element name="Property" type="TProperty" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="TVideoChannel"> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> + <xsd:attribute name="quality" type="xsd:unsignedByte" default="75"/> </xsd:complexType> <xsd:complexType name="TRemoteDisplay"> + <xsd:sequence> + <xsd:element name="VideoChannel" type="TVideoChannel" minOccurs="0"/> <!-- deprecated --> + <xsd:choice minOccurs="0"> + <xsd:element name="VRDEProperties" type="TVRDEProperties"/> + </xsd:choice> + </xsd:sequence> <xsd:attribute name="enabled" type="xsd:boolean" use="required"/> + <xsd:attribute name="port" type="xsd:string" default="3389"/> <!-- deprecated --> <xsd:attribute name="authType" type="TAuthType" default="Null"/> <xsd:attribute name="authTimeout" type="xsd:unsignedInt" default="5000"/> <xsd:attribute name="allowMultiConnection" type="xsd:boolean" default="false"/> @@ -528,12 +589,25 @@ </xsd:element> <xsd:element name="TimeOffset" minOccurs="0"> <xsd:complexType> - <xsd:attribute name="value" type="xsd:integer" default="0"/> + <xsd:attribute name="value" type="xsd:integer" default="0"/> </xsd:complexType> </xsd:element> <xsd:element name="PXEDebug" minOccurs="0"> <xsd:complexType> - <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> + </xsd:complexType> + </xsd:element> + <xsd:element name="IDEController" minOccurs="0"> <!-- deprecated --> + <xsd:complexType> + <xsd:attribute name="type"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="PIIX3"/> + <xsd:enumeration value="PIIX4"/> + <xsd:enumeration value="ICH6"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> </xsd:complexType> </xsd:element> </xsd:all> @@ -544,16 +618,14 @@ <xsd:element name="Image" type="TImageRef"/> <xsd:element name="HostDrive" type="THostDrive"/> </xsd:choice> - <xsd:attribute name="type" use="required"> - <xsd:simpleType> - <xsd:restriction base="xsd:token"> - <xsd:enumeration value="HardDisk"/> - <xsd:enumeration value="CD/DVD"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - <xsd:attribute name="port" type="xsd:unsignedInt" use="required"/> + <xsd:attribute name="type" type="TMediumDeviceType"/> + <xsd:attribute name="port" type="xsd:unsignedInt" default="0"/> <xsd:attribute name="device" type="xsd:unsignedInt" default="0"/> + <xsd:attribute name="passthrough" type="xsd:boolean" default="false"/> + <xsd:attribute name="tempeject" type="xsd:boolean" default="false"/> + <xsd:attribute name="nonrotational" type="xsd:boolean" default="false"/> + <xsd:attribute name="discard" type="xsd:boolean" default="false"/> + <xsd:attribute name="hotpluggable" type="xsd:boolean" default="false"/> </xsd:complexType> <xsd:complexType name="TStorageController"> @@ -572,11 +644,13 @@ <xsd:enumeration value="PIIX4"/> <xsd:enumeration value="ICH6"/> <xsd:enumeration value="LsiLogicSas"/> + <xsd:enumeration value="I82078"/> </xsd:restriction> </xsd:simpleType> </xsd:attribute> <xsd:attribute name="PortCount" type="xsd:unsignedInt" use="required"/> - <xsd:attribute name="bootable" type="xsd:boolean" use="optional"/> + <xsd:attribute name="useHostIOCache" type="xsd:boolean" use="optional" default="true"/> + <xsd:attribute name="Bootable" type="xsd:boolean" use="optional"/> <xsd:attribute name="PCIBus" type="xsd:unsignedInt" use="optional"/> <xsd:attribute name="PCIDevice" type="xsd:unsignedInt" use="optional"/> <xsd:attribute name="PCIFunction" type="xsd:unsignedInt" use="optional"/> @@ -586,6 +660,19 @@ <xsd:attribute name="IDE1SlaveEmulationPort" type="xsd:unsignedInt" use="optional"/> </xsd:complexType> +<xsd:complexType name="TSATAController"> <!-- deprecated --> + <xsd:sequence> + <xsd:element name="AttachedDevice" type="TStorageControllerDevice" + minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> + <xsd:attribute name="PortCount" type="xsd:unsignedInt" use="required"/> + <xsd:attribute name="IDE0MasterEmulationPort" type="xsd:unsignedInt" use="optional"/> + <xsd:attribute name="IDE0SlaveEmulationPort" type="xsd:unsignedInt" use="optional"/> + <xsd:attribute name="IDE1MasterEmulationPort" type="xsd:unsignedInt" use="optional"/> + <xsd:attribute name="IDE1SlaveEmulationPort" type="xsd:unsignedInt" use="optional"/> +</xsd:complexType> + <xsd:complexType name="TStorageControllers"> <xsd:sequence> <xsd:element name="StorageController" type="TStorageController" @@ -593,6 +680,27 @@ </xsd:sequence> </xsd:complexType> +<xsd:complexType name="THardDiskAttachment"> + <xsd:attribute name="hardDisk" type="TNonNullUUID"/> + <xsd:attribute name="bus" default="IDE"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="IDE"/> + <xsd:enumeration value="SATA"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + <xsd:attribute name="channel" type="xsd:unsignedInt" default="0"/> + <xsd:attribute name="device" type="xsd:unsignedInt" default="0"/> +</xsd:complexType> + +<xsd:complexType name="THardDiskAttachments"> <!-- deprecated --> + <xsd:sequence> + <xsd:element name="HardDiskAttachment" type="THardDiskAttachment" + minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> +</xsd:complexType> + <xsd:complexType name="TDVDDrive"> <xsd:choice minOccurs="0"> <xsd:element name="Image" type="TImageRef"/> @@ -618,133 +726,143 @@ <xsd:attribute name="enabledEhci" type="xsd:boolean" default="false"/> </xsd:complexType> -<xsd:complexType name="TAudioAdapterBase"> +<xsd:complexType name="TAudioAdapter"> <xsd:attribute name="enabled" type="xsd:boolean" use="required"/> <xsd:attribute name="controller" default="AC97"> <xsd:simpleType> <xsd:restriction base="xsd:token"> <xsd:enumeration value="AC97"/> <xsd:enumeration value="SB16"/> + <xsd:enumeration value="HDA"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + <xsd:attribute name="driver" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="null"/> <!-- deprecated --> + <xsd:enumeration value="Null"/> <!-- all platforms --> + <xsd:enumeration value="OSS"/> <!-- Linux, Solaris, FreeBSD --> + <xsd:enumeration value="ALSA"/> <!-- Linux, FreeBSD --> + <xsd:enumeration value="Pulse"/> <!-- Linux --> + <xsd:enumeration value="CoreAudio"/> <!-- Mac OS X --> + <xsd:enumeration value="MMPM"/> <!-- OS/2 --> + <xsd:enumeration value="SolAudio"/> <!-- Solaris --> + <xsd:enumeration value="WinMM"/> <!-- Windows --> + <xsd:enumeration value="DirectSound"/> <!-- Windows --> </xsd:restriction> </xsd:simpleType> </xsd:attribute> </xsd:complexType> -<xsd:complexType name="TNetworkAdapter"> - <xsd:choice minOccurs="0"> - <xsd:element name="NAT"> - <xsd:complexType> - <xsd:attribute name="network" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="hostip" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="mtu" type="xsd:unsignedInt"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="sockrcv" type="xsd:unsignedInt"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="socksnd" type="xsd:unsignedInt"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="tcprcv" type="xsd:unsignedInt"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="tcpsnd" type="xsd:unsignedInt"/> - </xsd:complexType> - <xsd:element name="DNS"> - <xsd:complexType> - <xsd:attribute name="pass-domain" type="xsd:boolean"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="use-proxy" type="xsd:boolean"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="use-host-resolver" type="xsd:boolean"/> - </xsd:complexType> - </xsd:element> - <xsd:element name="TFTP"> - <xsd:complexType> - <xsd:attribute name="prefix" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="boot-file" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="next-server" type="xsd:string"/> - </xsd:complexType> - </xsd:element> - <xsd:element name="Forwarding"> - <xsd:complexType> - <xsd:attribute name="name" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="proto" type="xsd:unsignedInt"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="hostip" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="hostport" type="xsd:unsignedInt"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="guestip" type="xsd:string"/> - </xsd:complexType> - <xsd:complexType> - <xsd:attribute name="guestport" type="xsd:unsignedInt"/> - </xsd:complexType> - </xsd:element> - </xsd:element> - <xsd:element name="HostInterface"> +<xsd:complexType name="TNetNAT"> + <xsd:choice minOccurs="0" maxOccurs="unbounded"> + <xsd:element name="DNS" minOccurs="0"> <xsd:complexType> - <xsd:attribute name="name" type="xsd:string" use="required"/> + <xsd:attribute name="pass-domain" type="xsd:boolean" default="true"/> + <xsd:attribute name="use-proxy" type="xsd:boolean" default="false"/> + <xsd:attribute name="use-host-resolver" type="xsd:boolean" default="false"/> </xsd:complexType> </xsd:element> - <xsd:element name="BridgedInterface"> + <xsd:element name="Alias" minOccurs="0"> <xsd:complexType> - <xsd:attribute name="name" type="xsd:string" use="required"/> + <xsd:attribute name="logging" type="xsd:boolean" default="false"/> + <xsd:attribute name="proxy-only" type="xsd:boolean" default="false"/> + <xsd:attribute name="use-same-ports" type="xsd:boolean" default="false"/> </xsd:complexType> </xsd:element> - <xsd:element name="InternalNetwork"> + <xsd:element name="TFTP" minOccurs="0"> <xsd:complexType> - <xsd:attribute name="name" type="xsd:string" use="required"/> + <xsd:attribute name="prefix" type="xsd:string"/> + <xsd:attribute name="boot-file" type="xsd:string"/> + <xsd:attribute name="next-server" type="xsd:string"/> </xsd:complexType> </xsd:element> - <xsd:element name="HostOnlyInterface"> + <xsd:element name="Forwarding" minOccurs="0" maxOccurs="unbounded"> <xsd:complexType> - <xsd:attribute name="name" type="xsd:string" use="required"/> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="proto" type="xsd:unsignedInt"/> + <xsd:attribute name="hostip" type="xsd:string"/> + <xsd:attribute name="hostport" type="xsd:unsignedInt"/> + <xsd:attribute name="guestip" type="xsd:string"/> + <xsd:attribute name="guestport" type="xsd:unsignedInt"/> </xsd:complexType> </xsd:element> - <xsd:element name="Generic"> + </xsd:choice> + <xsd:attribute name="network" type="xsd:string"/> + <xsd:attribute name="hostip" type="xsd:string"/> + <xsd:attribute name="mtu" type="xsd:unsignedInt"/> + <xsd:attribute name="sockrcv" type="xsd:unsignedInt"/> + <xsd:attribute name="socksnd" type="xsd:unsignedInt"/> + <xsd:attribute name="tcprcv" type="xsd:unsignedInt"/> + <xsd:attribute name="tcpsnd" type="xsd:unsignedInt"/> +</xsd:complexType> + +<xsd:complexType name="TNetBridged"> + <xsd:attribute name="name" type="xsd:string" use="required"/> +</xsd:complexType> + +<xsd:complexType name="TNetInternal"> + <xsd:attribute name="name" type="xsd:string" use="required"/> +</xsd:complexType> + +<xsd:complexType name="TNetHostOnly"> + <xsd:attribute name="name" type="xsd:string" use="required"/> +</xsd:complexType> + +<xsd:complexType name="TNetGeneric"> + <xsd:sequence> + <xsd:element name="Property" type="TProperty" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="driver" type="xsd:string" use="required"/> +</xsd:complexType> + +<xsd:complexType name="TNetworkConfig"> + <xsd:choice maxOccurs="2"> + <xsd:choice minOccurs="0"> + <xsd:element name="NAT" type="TNetNAT"/> + <xsd:element name="HostInterface" type="TNetBridged"/> + <xsd:element name="BridgedInterface" type="TNetBridged"/> + <xsd:element name="InternalNetwork" type="TNetInternal"/> + <xsd:element name="HostOnlyInterface" type="TNetHostOnly"/> + <xsd:element name="GenericInterface" type="TNetGeneric"/> + </xsd:choice> + <xsd:element name="DisabledModes"> <xsd:complexType> - <xsd:attribute name="driver" type="xsd:string" use="required"/> + <xsd:all> + <xsd:element name="NAT" type="TNetNAT" minOccurs="0"/> + <xsd:element name="HostInterface" type="TNetBridged" minOccurs="0"/> + <xsd:element name="BridgedInterface" type="TNetBridged" minOccurs="0"/> + <xsd:element name="InternalNetwork" type="TNetInternal" minOccurs="0"/> + <xsd:element name="HostOnlyInterface" type="TNetHostOnly" minOccurs="0"/> + <xsd:element name="GenericInterface" type="TNetGeneric" minOccurs="0"/> + </xsd:all> </xsd:complexType> - <xsd:element name="Property" minOccurs="0" maxOccurs="unbounded"> - <xsd:complexType> - <xsd:attribute name="name" type="xsd:token" use="required"/> - <xsd:attribute name="value" type="xsd:string" use="required"/> - </xsd:complexType> - </xsd:element> </xsd:element> - <!-- The DisabledModes tag is not part of this XSD file right now. --> </xsd:choice> - <xsd:attribute name="type" type="TNetworkAdapterType" default="Am79C970A"/> - <xsd:attribute name="slot" type="xsd:unsignedInt" use="required"/> - <xsd:attribute name="enabled" type="xsd:boolean" use="required"/> - <xsd:attribute name="MACAddress"> - <xsd:simpleType> - <xsd:restriction base="xsd:hexBinary"> - <xsd:pattern value="[0-9A-Fa-f][02468ACEace][0-9A-Fa-f]{10}"/> - </xsd:restriction> - </xsd:simpleType> - </xsd:attribute> - <xsd:attribute name="cable" type="xsd:boolean" use="required"/> - <xsd:attribute name="speed" type="xsd:unsignedInt" default="1000000"/> - <xsd:attribute name="trace" type="xsd:boolean" default="false"/> - <xsd:attribute name="tracefile" type="xsd:string"/> - <xsd:attribute name="bandwidthGroup" type="xsd:string"/> +</xsd:complexType> + +<xsd:complexType name="TNetworkAdapter"> + <xsd:complexContent> + <xsd:extension base="TNetworkConfig"> + <xsd:attribute name="type" type="TNetworkAdapterType" default="Am79C970A"/> + <xsd:attribute name="slot" type="xsd:unsignedInt" use="required"/> + <xsd:attribute name="enabled" type="xsd:boolean" use="required"/> + <xsd:attribute name="MACAddress"> + <xsd:simpleType> + <xsd:restriction base="xsd:hexBinary"> + <xsd:pattern value="[0-9A-Fa-f][02468ACEace][0-9A-Fa-f]{10}"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + <xsd:attribute name="cable" type="xsd:boolean" use="required"/> + <xsd:attribute name="speed" type="xsd:unsignedInt" default="1000000"/> + <xsd:attribute name="bootPriority" type="xsd:unsignedInt"/> + <xsd:attribute name="trace" type="xsd:boolean" default="false"/> + <xsd:attribute name="tracefile" type="xsd:string"/> + <xsd:attribute name="bandwidthGroup" type="xsd:string"/> + </xsd:extension> + </xsd:complexContent> </xsd:complexType> <xsd:complexType name="TNetwork"> @@ -778,6 +896,30 @@ </xsd:sequence> </xsd:complexType> +<xsd:complexType name="TUartPort"> <!-- deprecated --> + <xsd:attribute name="slot" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:unsignedInt"> + <xsd:minInclusive value="0"/> + <xsd:maxExclusive value="2"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + <xsd:attribute name="enabled" type="xsd:boolean" use="required"/> + <xsd:attribute name="IRQ" type="TUInt8" use="required"/> + <xsd:attribute name="IOBase" type="TUInt16HexNoBase" use="required"/> + <xsd:attribute name="hostMode" type="TPortMode" use="required"/> + <xsd:attribute name="path" type="TLocalFile"/> + <xsd:attribute name="server" type="xsd:boolean" default="false"/> +</xsd:complexType> + +<xsd:complexType name="TUart"> <!-- deprecated --> + <xsd:sequence> + <xsd:element name="Port" type="TUartPort" + minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> +</xsd:complexType> + <xsd:complexType name="TLPTPort"> <xsd:attribute name="slot" use="required"> <xsd:simpleType> @@ -800,10 +942,37 @@ </xsd:sequence> </xsd:complexType> +<xsd:complexType name="TLptPort"> <!-- deprecated --> + <xsd:attribute name="slot" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:unsignedInt"> + <xsd:minInclusive value="0"/> + <xsd:maxExclusive value="2"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + <xsd:attribute name="enabled" type="xsd:boolean" use="required"/> + <xsd:attribute name="IRQ" type="TUInt8" use="required"/> + <xsd:attribute name="IOBase" type="TUInt16HexNoBase" use="required"/> + <xsd:attribute name="path" type="TLocalFile"/> +</xsd:complexType> + +<xsd:complexType name="TLpt"> + <xsd:sequence> + <xsd:element name="Port" type="TLptPort" + minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="TRTC"> + <xsd:attribute name="localOrUTC" type="TLocalOrUTC" use="required"/> +</xsd:complexType> + <xsd:complexType name="TSharedFolder"> <xsd:attribute name="name" type="TNonEmptyString" use="required"/> <xsd:attribute name="hostPath" type="TLocalFile" use="required"/> <xsd:attribute name="writable" type="xsd:boolean" default="true"/> + <xsd:attribute name="autoMount" type="xsd:boolean" default="false"/> </xsd:complexType> <xsd:complexType name="TSharedFolders"> @@ -820,9 +989,69 @@ <xsd:attribute name="mode" type="TDragAndDropMode" use="required"/> </xsd:complexType> +<xsd:complexType name="TIoCache"> + <xsd:attribute name="enabled" type="xsd:boolean" default="true"/> + <xsd:attribute name="size" type="xsd:unsignedLong"/> +</xsd:complexType> + +<xsd:complexType name="TBandwidthGroup"> + <xsd:attribute name="name" type="xsd:token" use="required"/> + <xsd:attribute name="type" type="TBandwidthGroupType" use="required"/> + <xsd:attribute name="maxBytesPerSec" type="xsd:unsignedLong"/> + <xsd:attribute name="maxMbPerSec" type="xsd:unsignedLong"/> +</xsd:complexType> + +<xsd:complexType name="TBandwidthGroups"> + <xsd:sequence> + <xsd:element name="BandwidthGroup" type="TBandwidthGroup" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="TIO"> + <xsd:sequence> + <xsd:element name="IoCache" type="TIoCache" minOccurs="0"/> + <xsd:element name="BandwidthGroups" type="TBandwidthGroups" minOccurs="0"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="THostPciDevice"> + <xsd:attribute name="host" type="xsd:unsignedInt" use="required"/> + <xsd:attribute name="guest" type="xsd:unsignedInt" use="required"/> + <xsd:attribute name="name" type="xsd:token"/> +</xsd:complexType> + +<xsd:complexType name="THostPciDevices"> + <xsd:sequence> + <xsd:element name="Device" type="THostPciDevice" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="THostPci"> + <xsd:sequence> + <xsd:element name="Devices" type="THostPciDevices" minOccurs="0"/> + </xsd:sequence> +</xsd:complexType> + +<xsd:complexType name="TCardReader"> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> +</xsd:complexType> + +<xsd:complexType name="TWebcam"> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> +</xsd:complexType> + +<xsd:complexType name="TEmulatedUSB"> + <xsd:sequence> + <xsd:element name="CardReader" type="TCardReader" minOccurs="0"/> + <xsd:element name="Webcam" type="TWebcam" minOccurs="0"/> + </xsd:sequence> +</xsd:complexType> + <xsd:complexType name="TGuest"> <xsd:attribute name="memoryBalloonSize" type="xsd:unsignedInt" default="0"/> + <xsd:attribute name="MemoryBalloonSize" type="xsd:unsignedInt" default="0"/> <!-- deprecated --> <xsd:attribute name="statisticsUpdateInterval" type="xsd:unsignedInt" default="0"/> + <xsd:attribute name="StatisticsUpdateInterval" type="xsd:unsignedInt" default="0"/> <!-- deprecated --> </xsd:complexType> <xsd:complexType name="TGuestProperty"> @@ -848,12 +1077,91 @@ </xsd:restriction> </xsd:simpleType> </xsd:attribute> + <xsd:attribute name="PageFusion" type="xsd:boolean" default="false"/> +</xsd:complexType> + +<xsd:complexType name="TFirmware"> + <xsd:attribute name="type" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="BIOS"/> + <xsd:enumeration value="EFI"/> + <xsd:enumeration value="EFI32"/> + <xsd:enumeration value="EFI64"/> + <xsd:enumeration value="EFIDUAL"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> +</xsd:complexType> + +<xsd:complexType name="THID"> + <xsd:attribute name="Pointing" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="USBMouse"/> + <xsd:enumeration value="USBTablet"/> + <xsd:enumeration value="PS2Mouse"/> + <xsd:enumeration value="ComboMouse"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + <xsd:attribute name="Keyboard" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="USBKeyboard"/> + <xsd:enumeration value="PS2Keyboard"/> + <xsd:enumeration value="ComboKeyboard"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> +</xsd:complexType> + +<xsd:complexType name="THPET"> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> +</xsd:complexType> + +<xsd:complexType name="TChipset"> + <xsd:attribute name="type" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="PIIX3"/> + <xsd:enumeration value="ICH9"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> +</xsd:complexType> + +<xsd:complexType name="TTeleporter"> + <xsd:attribute name="enabled" type="xsd:boolean" default="false"/> + <xsd:attribute name="port" type="xsd:unsignedShort"/> + <xsd:attribute name="address" type="xsd:string"/> + <xsd:attribute name="password" type="xsd:string"/> +</xsd:complexType> + +<xsd:complexType name="TFaultTolerance"> + <xsd:attribute name="state" use="required"> + <xsd:simpleType> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="inactive"/> + <xsd:enumeration value="master"/> + <xsd:enumeration value="standby"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:attribute> + <xsd:attribute name="port" type="xsd:unsignedShort"/> + <xsd:attribute name="address" type="xsd:string"/> + <xsd:attribute name="interval" type="xsd:unsignedInt"/> + <xsd:attribute name="password" type="xsd:string"/> </xsd:complexType> <xsd:complexType name="THardware"> <xsd:all> <xsd:element name="CPU" type="TCPU" minOccurs="0"/> <xsd:element name="Memory" type="TMemory"/> + <xsd:element name="Firmware" type="TFirmware" minOccurs="0"/> + <xsd:element name="HID" type="THID" minOccurs="0"/> + <xsd:element name="HPET" type="THPET" minOccurs="0"/> + <xsd:element name="Chipset" type="TChipset" minOccurs="0"/> <xsd:element name="Boot" type="TBoot"> <xsd:unique name="THardware-Boot-Order"> <xsd:selector xpath="vb:Order"/> @@ -861,30 +1169,45 @@ </xsd:unique> </xsd:element> <xsd:element name="Display" type="TDisplay"/> + <xsd:element name="VideoRecording" type="TVideoRecording" minOccurs="0"/> <xsd:element name="RemoteDisplay" type="TRemoteDisplay" minOccurs="0"/> <xsd:element name="BIOS" type="TBIOS"/> - <xsd:element name="DVDDrive" type="TDVDDrive"/> - <xsd:element name="FloppyDrive" type="TFloppyDrive"/> + <xsd:element name="DVDDrive" type="TDVDDrive" minOccurs="0"/> + <xsd:element name="FloppyDrive" type="TFloppyDrive" minOccurs="0"/> <xsd:element name="USBController" type="TUSBController"/> + <xsd:element name="SATAController" type="TSATAController" minOccurs="0"/> <!-- deprecated --> <xsd:element name="Network" type="TNetwork"> <xsd:unique name="THardware-Network-Adapter"> <xsd:selector xpath="vb:Adapter"/> <xsd:field xpath="@slot"/> </xsd:unique> </xsd:element> - <xsd:element name="UART" type="TUART"> + <xsd:element name="UART" type="TUART" minOccurs="0"> <xsd:unique name="THardware-UART-Port"> <xsd:selector xpath="vb:Port"/> <xsd:field xpath="@slot"/> </xsd:unique> </xsd:element> - <xsd:element name="LPT" type="TLPT"> + <xsd:element name="Uart" type="TUart" minOccurs="0"> <!-- deprecated --> + <xsd:unique name="THardware-Uart-Port"> + <xsd:selector xpath="vb:Port"/> + <xsd:field xpath="@slot"/> + </xsd:unique> + </xsd:element> + <xsd:element name="LPT" type="TLPT" minOccurs="0"> <xsd:unique name="THardware-LPT-Port"> <xsd:selector xpath="vb:Port"/> <xsd:field xpath="@slot"/> </xsd:unique> </xsd:element> + <xsd:element name="Lpt" type="TLpt" minOccurs="0"> <!-- deprecated --> + <xsd:unique name="THardware-Lpt-Port"> + <xsd:selector xpath="vb:Port"/> + <xsd:field xpath="@slot"/> + </xsd:unique> + </xsd:element> <xsd:element name="AudioAdapter" type="TAudioAdapter"/> + <xsd:element name="RTC" type="TRTC" minOccurs="0"/> <xsd:element name="SharedFolders" type="TSharedFolders"> <xsd:unique name="THardware-SharedFolders-SharedFolder"> <xsd:selector xpath="vb:SharedFolder"/> @@ -892,7 +1215,10 @@ </xsd:unique> </xsd:element> <xsd:element name="Clipboard" type="TClipboard"/> - <xsd:element name="DragAndDrop" type="TDragAndDrop"/> + <xsd:element name="DragAndDrop" type="TDragAndDrop" minOccurs="0"/> + <xsd:element name="IO" type="TIO" minOccurs="0"/> + <xsd:element name="HostPci" type="THostPci" minOccurs="0"/> + <xsd:element name="EmulatedUSB" type="TEmulatedUSB" minOccurs="0"/> <xsd:element name="Guest" type="TGuest"/> <xsd:element name="GuestProperties" type="TGuestProperties" minOccurs="0"> <xsd:unique name="THardware-GuestProperties-GuestProperty"> @@ -904,16 +1230,32 @@ <xsd:attribute name="version" type="xsd:string" default="2"/> </xsd:complexType> +<xsd:complexType name="TGroup"> + <xsd:attribute name="name" type="xsd:string" use="required"/> +</xsd:complexType> + +<xsd:complexType name="TGroups"> + <xsd:sequence> + <xsd:element name="Group" type="TGroup" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> +</xsd:complexType> + <xsd:complexType name="TMachine"> <xsd:all> + <xsd:element name="MediaRegistry" type="TMediaRegistry" minOccurs="0"/> <xsd:element name="Description" type="xsd:string" minOccurs="0"/> + <xsd:element name="Teleporter" type="TTeleporter" minOccurs="0"/> + <xsd:element name="FaultTolerance" type="TFaultTolerance" minOccurs="0"/> <xsd:element name="Hardware" type="THardware"/> - <xsd:element name="StorageControllers" type="TStorageControllers"/> + <xsd:element name="StorageControllers" type="TStorageControllers" minOccurs="0"/> + <xsd:element name="HardDiskAttachments" type="THardDiskAttachments" minOccurs="0"/> <!-- deprecated --> + <xsd:element name="Groups" type="TGroups" minOccurs="0"/> <xsd:element name="ExtraData" type="TExtraData" minOccurs="0"/> <xsd:element name="Snapshot" type="TSnapshot" minOccurs="0"/> </xsd:all> <xsd:attribute name="name" type="TNonEmptyString" use="required"/> <xsd:attribute name="nameSync" type="xsd:boolean" default="true"/> + <xsd:attribute name="directoryIncludesUUID" type="xsd:boolean" default="false"/> <xsd:attribute name="OSType" type="TNonEmptyString" use="required"/> <xsd:attribute name="uuid" type="TNonNullUUID" use="required"/> <xsd:attribute name="stateFile" type="TLocalFile"/> @@ -943,7 +1285,7 @@ <xsd:attribute name="stateFile" type="TLocalFile"/> </xsd:complexType> -<xsd:complexType name="TVirtualBox" abstract="true"> +<xsd:complexType name="TVirtualBox"> <xsd:choice> <xsd:element name="Global" type="TGlobal"/> <xsd:element name="Machine" type="TMachine"> @@ -958,6 +1300,10 @@ </xsd:keyref> </xsd:element> </xsd:choice> + <xsd:attribute name="version" type="xsd:string"/> </xsd:complexType> +<!-- Root element for all VirtualBox config files --> +<xsd:element name="VirtualBox" type="TVirtualBox"/> + </xsd:schema> diff --git a/src/VBox/Main/xml/ovfreader.cpp b/src/VBox/Main/xml/ovfreader.cpp index eb685fd3..3762083b 100644 --- a/src/VBox/Main/xml/ovfreader.cpp +++ b/src/VBox/Main/xml/ovfreader.cpp @@ -6,7 +6,7 @@ */ /* - * Copyright (C) 2008-2009 Oracle Corporation + * Copyright (C) 2008-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -64,11 +64,38 @@ OVFReader::OVFReader(const RTCString &path) void OVFReader::parse() { const xml::ElementNode *pRootElem = m_doc.getRootElement(); - if ( !pRootElem - || strcmp(pRootElem->getName(), "Envelope") - ) + const xml::AttributeNode *pTypeAttr; + const char *pcszTypeAttr = ""; + RTCString pcszNamespaceURI; + + if (!pRootElem || strcmp(pRootElem->getName(), "Envelope")) throw OVFLogicError(N_("Root element in OVF file must be \"Envelope\".")); + pcszNamespaceURI = pRootElem->getNamespaceURI(); + if(pcszNamespaceURI.isEmpty()) + { + throw OVFLogicError(N_("Error reading namespace URI in 'Envelope' element, line %d"), pRootElem->getLineNumber()); + } + + if (strncmp(ovf::OVF20_URI_string, pcszNamespaceURI.c_str(), pcszNamespaceURI.length()) == 0) + { + m_envelopeData.setOVFVersion(ovf::OVFVersion_2_0); + } + else if (strncmp(OVF10_URI_string, pcszNamespaceURI.c_str(), pcszNamespaceURI.length()) == 0) + { + m_envelopeData.setOVFVersion(ovf::OVFVersion_1_0); + } + else + { + m_envelopeData.setOVFVersion(ovf::OVFVersion_0_9); + } + + if ((pTypeAttr = pRootElem->findAttribute("lang", "xml"))) + { + pcszTypeAttr = pTypeAttr->getValue(); + m_envelopeData.lang = pcszTypeAttr; + } + // OVF has the following rough layout: /* -- <References> .... files referenced from other parts of the file, such as VMDK images @@ -105,56 +132,52 @@ void OVFReader::LoopThruSections(const xml::ElementNode *pReferencesElem, while ((pElem = loopChildren.forAllNodes())) { const char *pcszElemName = pElem->getName(); - const char *pcszTypeAttr = ""; - const xml::AttributeNode *pTypeAttr; - if ( ((pTypeAttr = pElem->findAttribute("xsi:type"))) - || ((pTypeAttr = pElem->findAttribute("type"))) - ) - pcszTypeAttr = pTypeAttr->getValue(); + const xml::AttributeNode *pTypeAttr = pElem->findAttribute("type"); + const char *pcszTypeAttr = pTypeAttr ? pTypeAttr->getValue() : ""; - if ( (!strcmp(pcszElemName, "DiskSection")) - || ( (!strcmp(pcszElemName, "Section")) - && (!strcmp(pcszTypeAttr, "ovf:DiskSection_Type")) + if ( !strcmp(pcszElemName, "DiskSection") + || ( !strcmp(pcszElemName, "Section") + && !strcmp(pcszTypeAttr, "ovf:DiskSection_Type") ) ) { HandleDiskSection(pReferencesElem, pElem); } - else if ( (!strcmp(pcszElemName, "NetworkSection")) - || ( (!strcmp(pcszElemName, "Section")) - && (!strcmp(pcszTypeAttr, "ovf:NetworkSection_Type")) + else if ( !strcmp(pcszElemName, "NetworkSection") + || ( !strcmp(pcszElemName, "Section") + && !strcmp(pcszTypeAttr, "ovf:NetworkSection_Type") ) ) { HandleNetworkSection(pElem); } - else if ( (!strcmp(pcszElemName, "DeploymentOptionSection"))) + else if ( !strcmp(pcszElemName, "DeploymentOptionSection")) { // TODO } - else if ( (!strcmp(pcszElemName, "Info"))) + else if ( !strcmp(pcszElemName, "Info")) { // child of VirtualSystemCollection -- TODO } - else if ( (!strcmp(pcszElemName, "ResourceAllocationSection"))) + else if ( !strcmp(pcszElemName, "ResourceAllocationSection")) { // child of VirtualSystemCollection -- TODO } - else if ( (!strcmp(pcszElemName, "StartupSection"))) + else if ( !strcmp(pcszElemName, "StartupSection")) { // child of VirtualSystemCollection -- TODO } - else if ( (!strcmp(pcszElemName, "VirtualSystem")) - || ( (!strcmp(pcszElemName, "Content")) - && (!strcmp(pcszTypeAttr, "ovf:VirtualSystem_Type")) + else if ( !strcmp(pcszElemName, "VirtualSystem") + || ( !strcmp(pcszElemName, "Content") + && !strcmp(pcszTypeAttr, "ovf:VirtualSystem_Type") ) ) { HandleVirtualSystemContent(pElem); } - else if ( (!strcmp(pcszElemName, "VirtualSystemCollection")) - || ( (!strcmp(pcszElemName, "Content")) - && (!strcmp(pcszTypeAttr, "ovf:VirtualSystemCollection_Type")) + else if ( !strcmp(pcszElemName, "VirtualSystemCollection") + || ( !strcmp(pcszElemName, "Content") + && !strcmp(pcszTypeAttr, "ovf:VirtualSystemCollection_Type") ) ) { @@ -187,23 +210,23 @@ void OVFReader::HandleDiskSection(const xml::ElementNode *pReferencesElem, const char *pcszBad = NULL; const char *pcszDiskId; const char *pcszFormat; - if (!(pelmDisk->getAttributeValue("diskId", pcszDiskId))) + if (!pelmDisk->getAttributeValue("diskId", pcszDiskId)) pcszBad = "diskId"; - else if (!(pelmDisk->getAttributeValue("format", pcszFormat))) + else if (!pelmDisk->getAttributeValue("format", pcszFormat)) pcszBad = "format"; - else if (!(pelmDisk->getAttributeValue("capacity", d.iCapacity))) + else if (!pelmDisk->getAttributeValue("capacity", d.iCapacity)) pcszBad = "capacity"; else { d.strDiskId = pcszDiskId; d.strFormat = pcszFormat; - if (!(pelmDisk->getAttributeValue("populatedSize", d.iPopulatedSize))) + if (!pelmDisk->getAttributeValue("populatedSize", d.iPopulatedSize)) // optional d.iPopulatedSize = -1; // optional vbox:uuid attribute (if OVF was exported by VirtualBox != 3.2) - pelmDisk->getAttributeValue("vbox:uuid", d.uuidVbox); + pelmDisk->getAttributeValue("uuid", d.uuidVBox, "vbox"); const char *pcszFileRef; if (pelmDisk->getAttributeValue("fileRef", pcszFileRef)) // optional @@ -211,15 +234,16 @@ void OVFReader::HandleDiskSection(const xml::ElementNode *pReferencesElem, // look up corresponding /References/File nodes (list built above) const xml::ElementNode *pFileElem; if ( pReferencesElem - && ((pFileElem = pReferencesElem->findChildElementFromId(pcszFileRef))) + && (pFileElem = pReferencesElem->findChildElementFromId(pcszFileRef)) != NULL ) { + // copy remaining values from file node then const char *pcszBadInFile = NULL; const char *pcszHref; - if (!(pFileElem->getAttributeValue("href", pcszHref))) + if (!pFileElem->getAttributeValue("href", pcszHref)) pcszBadInFile = "href"; - else if (!(pFileElem->getAttributeValue("size", d.iSize))) + else if (!pFileElem->getAttributeValue("size", d.iSize)) d.iSize = -1; // optional d.strHref = pcszHref; @@ -253,11 +277,11 @@ void OVFReader::HandleDiskSection(const xml::ElementNode *pReferencesElem, // suggest a size in megabytes to help callers with progress reports d.ulSuggestedSizeMB = 0; if (d.iCapacity != -1) - d.ulSuggestedSizeMB = d.iCapacity / _1M; + d.ulSuggestedSizeMB = (uint32_t)(d.iCapacity / _1M); else if (d.iPopulatedSize != -1) - d.ulSuggestedSizeMB = d.iPopulatedSize / _1M; + d.ulSuggestedSizeMB = (uint32_t)(d.iPopulatedSize / _1M); else if (d.iSize != -1) - d.ulSuggestedSizeMB = d.iSize / _1M; + d.ulSuggestedSizeMB = (uint32_t)(d.iSize / _1M); if (d.ulSuggestedSizeMB == 0) d.ulSuggestedSizeMB = 10000; // assume 10 GB, this is for the progress bar only anyway @@ -306,7 +330,7 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy // peek under the <VirtualSystem> node whether we have a <vbox:Machine> node; // that case case, the caller can completely ignore the OVF but only load the VBox machine XML - vsys.pelmVboxMachine = pelmVirtualSystem->findChildElement("vbox", "Machine"); + vsys.pelmVBoxMachine = pelmVirtualSystem->findChildElementNS("vbox", "Machine"); // now look for real OVF const xml::AttributeNode *pIdAttr = pelmVirtualSystem->findAttribute("id"); @@ -321,10 +345,8 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy const char *pcszTypeAttr = ""; if (!strcmp(pcszElemName, "Section")) // OVF 0.9 used "Section" element always with a varying "type" attribute { - const xml::AttributeNode *pTypeAttr; - if ( ((pTypeAttr = pelmThis->findAttribute("type"))) - || ((pTypeAttr = pelmThis->findAttribute("xsi:type"))) - ) + const xml::AttributeNode *pTypeAttr = pelmThis->findAttribute("type"); + if (pTypeAttr) pcszTypeAttr = pTypeAttr->getValue(); else throw OVFLogicError(N_("Error reading \"%s\": element \"Section\" has no \"type\" attribute, line %d"), @@ -332,8 +354,8 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy pelmThis->getLineNumber()); } - if ( (!strcmp(pcszElemName, "EulaSection")) - || (!strcmp(pcszTypeAttr, "ovf:EulaSection_Type")) + if ( !strcmp(pcszElemName, "EulaSection") + || !strcmp(pcszTypeAttr, "ovf:EulaSection_Type") ) { /* <EulaSection> @@ -345,8 +367,8 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy if ((pelmLicense = pelmThis->findChildElement("License"))) vsys.strLicenseText = pelmLicense->getValue(); } - if ( (!strcmp(pcszElemName, "ProductSection")) - || (!strcmp(pcszTypeAttr, "ovf:ProductSection_Type")) + if ( !strcmp(pcszElemName, "ProductSection") + || !strcmp(pcszTypeAttr, "ovf:ProductSection_Type") ) { /* <Section ovf:required="false" xsi:type="ovf:ProductSection_Type"> @@ -373,8 +395,8 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy if ((pelmVendorUrl = pelmThis->findChildElement("VendorUrl"))) vsys.strVendorUrl = pelmVendorUrl->getValue(); } - else if ( (!strcmp(pcszElemName, "VirtualHardwareSection")) - || (!strcmp(pcszTypeAttr, "ovf:VirtualHardwareSection_Type")) + else if ( !strcmp(pcszElemName, "VirtualHardwareSection") + || !strcmp(pcszTypeAttr, "ovf:VirtualHardwareSection_Type") ) { const xml::ElementNode *pelmSystem, *pelmVirtualSystemType; @@ -391,93 +413,80 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy vsys.strVirtualSystemType = pelmVirtualSystemType->getValue(); } - xml::NodesLoop loopVirtualHardwareItems(*pelmThis, "Item"); // all "Item" child elements - const xml::ElementNode *pelmItem; - while ((pelmItem = loopVirtualHardwareItems.forAllNodes())) { - VirtualHardwareItem i; + xml::NodesLoop loopVirtualHardwareItems(*pelmThis, "Item"); // all "Item" child elements + const xml::ElementNode *pelmItem; + while ((pelmItem = loopVirtualHardwareItems.forAllNodes())) + { + VirtualHardwareItem i; + + i.ulLineNumber = pelmItem->getLineNumber(); + i.fillItem(pelmItem); + try{ + i.checkConsistencyAndCompliance(); + } + catch (OVFLogicError &e) + { + throw OVFLogicError(N_("Error reading \"%s\": \"%s\""), + m_strPath.c_str(), + e.what()); + } - i.ulLineNumber = pelmItem->getLineNumber(); + // store! + vsys.mapHardwareItems[i.ulInstanceID] = i; + } + } - xml::NodesLoop loopItemChildren(*pelmItem); // all child elements - const xml::ElementNode *pelmItemChild; - while ((pelmItemChild = loopItemChildren.forAllNodes())) + { + xml::NodesLoop loopVirtualHardwareItems(*pelmThis, "StorageItem");// all "StorageItem" child elements + const xml::ElementNode *pelmItem; + while ((pelmItem = loopVirtualHardwareItems.forAllNodes())) { - const char *pcszItemChildName = pelmItemChild->getName(); - if (!strcmp(pcszItemChildName, "Description")) - i.strDescription = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "Caption")) - i.strCaption = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "ElementName")) - i.strElementName = pelmItemChild->getValue(); - else if ( (!strcmp(pcszItemChildName, "InstanceID")) - || (!strcmp(pcszItemChildName, "InstanceId")) - ) - pelmItemChild->copyValue(i.ulInstanceID); - else if (!strcmp(pcszItemChildName, "HostResource")) - i.strHostResource = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "ResourceType")) + StorageItem i; + + i.ulLineNumber = pelmItem->getLineNumber(); + i.fillItem(pelmItem); + + try { - uint32_t ulType; - pelmItemChild->copyValue(ulType); - i.resourceType = (ResourceType_T)ulType; - i.fResourceRequired = true; - const char *pcszAttValue; - if (pelmItem->getAttributeValue("required", pcszAttValue)) - { - if (!strcmp(pcszAttValue, "false")) - i.fResourceRequired = false; - } + i.checkConsistencyAndCompliance(); } - else if (!strcmp(pcszItemChildName, "OtherResourceType")) - i.strOtherResourceType = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "ResourceSubType")) - i.strResourceSubType = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "AutomaticAllocation")) - i.fAutomaticAllocation = (!strcmp(pelmItemChild->getValue(), "true")) ? true : false; - else if (!strcmp(pcszItemChildName, "AutomaticDeallocation")) - i.fAutomaticDeallocation = (!strcmp(pelmItemChild->getValue(), "true")) ? true : false; - else if (!strcmp(pcszItemChildName, "Parent")) - pelmItemChild->copyValue(i.ulParent); - else if (!strcmp(pcszItemChildName, "Connection")) - i.strConnection = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "Address")) + catch (OVFLogicError &e) { - i.strAddress = pelmItemChild->getValue(); - pelmItemChild->copyValue(i.lAddress); - } - else if (!strcmp(pcszItemChildName, "AddressOnParent")) - i.strAddressOnParent = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "AllocationUnits")) - i.strAllocationUnits = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "VirtualQuantity")) - pelmItemChild->copyValue(i.ullVirtualQuantity); - else if (!strcmp(pcszItemChildName, "Reservation")) - pelmItemChild->copyValue(i.ullReservation); - else if (!strcmp(pcszItemChildName, "Limit")) - pelmItemChild->copyValue(i.ullLimit); - else if (!strcmp(pcszItemChildName, "Weight")) - pelmItemChild->copyValue(i.ullWeight); - else if (!strcmp(pcszItemChildName, "ConsumerVisibility")) - i.strConsumerVisibility = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "MappingBehavior")) - i.strMappingBehavior = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "PoolID")) - i.strPoolID = pelmItemChild->getValue(); - else if (!strcmp(pcszItemChildName, "BusNumber")) // seen in some old OVF, but it's not listed in the OVF specs - pelmItemChild->copyValue(i.ulBusNumber); - else - throw OVFLogicError(N_("Error reading \"%s\": unknown element \"%s\" under Item element, line %d"), + throw OVFLogicError(N_("Error reading \"%s\": \"%s\""), m_strPath.c_str(), - pcszItemChildName, - i.ulLineNumber); + e.what()); + } + + vsys.mapHardwareItems[i.ulInstanceID] = i; } + } + + { + xml::NodesLoop loopVirtualHardwareItems(*pelmThis, "EthernetPortItem");// all "EthernetPortItem" child elements + const xml::ElementNode *pelmItem; + while ((pelmItem = loopVirtualHardwareItems.forAllNodes())) + { + EthernetPortItem i; + + i.ulLineNumber = pelmItem->getLineNumber(); + i.fillItem(pelmItem); + + try{ + i.checkConsistencyAndCompliance(); + } + catch (OVFLogicError &e) + { + throw OVFLogicError(N_("Error reading \"%s\": \"%s\""), + m_strPath.c_str(), + e.what()); + } - // store! - vsys.mapHardwareItems[i.ulInstanceID] = i; + vsys.mapHardwareItems[i.ulInstanceID] = i; + } } - HardDiskController *pPrimaryIDEController = NULL; // will be set once found + HardDiskController *pPrimaryIDEController = NULL;// will be set once found // now go thru all hardware items and handle them according to their type; // in this first loop we handle all items _except_ hard disk images, @@ -510,11 +519,11 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy break; case ResourceType_Memory: // 4 - if ( (i.strAllocationUnits == "MegaBytes") // found in OVF created by OVF toolkit - || (i.strAllocationUnits == "MB") // found in MS docs - || (i.strAllocationUnits == "byte * 2^20") // suggested by OVF spec DSP0243 page 21 + if ( i.strAllocationUnits == "MegaBytes" // found in OVF created by OVF toolkit + || i.strAllocationUnits == "MB" // found in MS docs + || i.strAllocationUnits == "byte * 2^20" // suggested by OVF spec DSP0243 page 21 ) - vsys.ullMemorySize = i.ullVirtualQuantity * 1024 * 1024; + vsys.ullMemorySize = i.ullVirtualQuantity * _1M; else throw OVFLogicError(N_("Error reading \"%s\": Invalid allocation unit \"%s\" specified with memory size item, line %d"), m_strPath.c_str(), @@ -721,6 +730,15 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy // do some analysis switch (i.resourceType) { + case ResourceType_CDDrive: // 15 + /* <Item ovf:required="false"> + <rasd:Caption>cdrom1</rasd:Caption> + <rasd:InstanceId>7</rasd:InstanceId> + <rasd:ResourceType>15</rasd:ResourceType> + <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> + <rasd:Parent>5</rasd:Parent> + <rasd:AddressOnParent>0</rasd:AddressOnParent> + </Item> */ case ResourceType_HardDisk: // 17 { /* <Item> @@ -737,12 +755,11 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy // this is how the connection is specified in OVF ControllersMap::const_iterator it = vsys.mapControllers.find(i.ulParent); if (it == vsys.mapControllers.end()) - throw OVFLogicError(N_("Error reading \"%s\": Hard disk item with instance ID %d specifies invalid parent %d, line %d"), + throw OVFLogicError(N_("Error reading \"%s\": Disk item with instance ID %d specifies invalid parent %d, line %d"), m_strPath.c_str(), i.ulInstanceID, i.ulParent, i.ulLineNumber); - //const HardDiskController &hdc = it->second; VirtualDisk vd; vd.idController = i.ulParent; @@ -756,14 +773,14 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy else if (i.strHostResource.startsWith("/disk/")) vd.strDiskId = i.strHostResource.substr(6); - if ( !(vd.strDiskId.length()) - || (m_mapDisks.find(vd.strDiskId) == m_mapDisks.end()) - ) - throw OVFLogicError(N_("Error reading \"%s\": Hard disk item with instance ID %d specifies invalid host resource \"%s\", line %d"), - m_strPath.c_str(), - i.ulInstanceID, - i.strHostResource.c_str(), - i.ulLineNumber); + //the error may be missed for CD, because CD can be empty + if ((vd.strDiskId.isEmpty() || (m_mapDisks.find(vd.strDiskId) == m_mapDisks.end())) + && i.resourceType == ResourceType_HardDisk) + throw OVFLogicError(N_("Error reading \"%s\": Disk item with instance ID %d specifies invalid host resource \"%s\", line %d"), + m_strPath.c_str(), + i.ulInstanceID, + i.strHostResource.c_str(), + i.ulLineNumber); vsys.mapVirtualDisks[vd.strDiskId] = vd; break; @@ -773,8 +790,8 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy } } } - else if ( (!strcmp(pcszElemName, "OperatingSystemSection")) - || (!strcmp(pcszTypeAttr, "ovf:OperatingSystemSection_Type")) + else if ( !strcmp(pcszElemName, "OperatingSystemSection") + || !strcmp(pcszTypeAttr, "ovf:OperatingSystemSection_Type") ) { uint64_t cimos64; @@ -789,9 +806,9 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy vsys.strCimosDesc = pelmCIMOSDescription->getValue(); const xml::ElementNode *pelmVBoxOSType; - if ((pelmVBoxOSType = pelmThis->findChildElement("vbox", // namespace - "OSType"))) // element name - vsys.strTypeVbox = pelmVBoxOSType->getValue(); + if ((pelmVBoxOSType = pelmThis->findChildElementNS("vbox", // namespace + "OSType"))) // element name + vsys.strTypeVBox = pelmVBoxOSType->getValue(); } else if ( (!strcmp(pcszElemName, "AnnotationSection")) || (!strcmp(pcszTypeAttr, "ovf:AnnotationSection_Type")) @@ -807,6 +824,224 @@ void OVFReader::HandleVirtualSystemContent(const xml::ElementNode *pelmVirtualSy m_llVirtualSystems.push_back(vsys); } +void VirtualHardwareItem::fillItem(const xml::ElementNode *item) +{ + xml::NodesLoop loopItemChildren(*item);// all child elements + const xml::ElementNode *pelmItemChild; + while ((pelmItemChild = loopItemChildren.forAllNodes())) + { + const char *pcszItemChildName = pelmItemChild->getName(); + if (!strcmp(pcszItemChildName, "Description")) + strDescription = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "Caption")) + strCaption = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "ElementName")) + strElementName = pelmItemChild->getValue(); + else if ((!strcmp(pcszItemChildName, "InstanceID")) + ||(!strcmp(pcszItemChildName, "InstanceId")) + ) + pelmItemChild->copyValue(ulInstanceID); + else if (!strcmp(pcszItemChildName, "HostResource")) + strHostResource = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "ResourceType")) + { + uint32_t ulType; + pelmItemChild->copyValue(ulType); + resourceType = (ResourceType_T)ulType; + fResourceRequired = true; + const char *pcszAttValue; + if (item->getAttributeValue("required", pcszAttValue)) + { + if (!strcmp(pcszAttValue, "false")) + fResourceRequired = false; + } + } + else if (!strcmp(pcszItemChildName, "OtherResourceType")) + strOtherResourceType = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "ResourceSubType")) + strResourceSubType = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "AutomaticAllocation")) + fAutomaticAllocation = (!strcmp(pelmItemChild->getValue(), "true")) ? true : false; + else if (!strcmp(pcszItemChildName, "AutomaticDeallocation")) + fAutomaticDeallocation = (!strcmp(pelmItemChild->getValue(), "true")) ? true : false; + else if (!strcmp(pcszItemChildName, "Parent")) + pelmItemChild->copyValue(ulParent); + else if (!strcmp(pcszItemChildName, "Connection")) + strConnection = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "Address")) + { + strAddress = pelmItemChild->getValue(); + pelmItemChild->copyValue(lAddress); + } + else if (!strcmp(pcszItemChildName, "AddressOnParent")) + strAddressOnParent = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "AllocationUnits")) + strAllocationUnits = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "VirtualQuantity")) + pelmItemChild->copyValue(ullVirtualQuantity); + else if (!strcmp(pcszItemChildName, "Reservation")) + pelmItemChild->copyValue(ullReservation); + else if (!strcmp(pcszItemChildName, "Limit")) + pelmItemChild->copyValue(ullLimit); + else if (!strcmp(pcszItemChildName, "Weight")) + pelmItemChild->copyValue(ullWeight); + else if (!strcmp(pcszItemChildName, "ConsumerVisibility")) + strConsumerVisibility = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "MappingBehavior")) + strMappingBehavior = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "PoolID")) + strPoolID = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "BusNumber")) + pelmItemChild->copyValue(ulBusNumber); +// else if (pelmItemChild->getPrefix() == NULL +// || strcmp(pelmItemChild->getPrefix(), "vmw")) +// throw OVFLogicError(N_("Unknown element \"%s\" under Item element, line %d"), +// pcszItemChildName, +// ulLineNumber); + } +} + +void VirtualHardwareItem::_checkConsistencyAndCompliance() RT_THROW(OVFLogicError) +{ + RTCString name = getItemName(); + if (ulInstanceID == 0) + throw OVFLogicError(N_("Element InstanceID is absent under %s element, line %d. " + "see DMTF Schema Documentation %s"), + name.c_str(), ulLineNumber, DTMF_SPECS_URI); + if (resourceType == 0) + throw OVFLogicError(N_("Empty element ResourceType under %s element, line %d. " + "see DMTF Schema Documentation %s"), + name.c_str(), ulLineNumber, DTMF_SPECS_URI); +} + +void StorageItem::fillItem(const xml::ElementNode *item) +{ + VirtualHardwareItem::fillItem(item); + + xml::NodesLoop loopItemChildren(*item);// all child elements + const xml::ElementNode *pelmItemChild; + while ((pelmItemChild = loopItemChildren.forAllNodes())) + { + const char *pcszItemChildName = pelmItemChild->getName(); + if (!strcmp(pcszItemChildName, "HostExtentName")) + strHostExtentName = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "OtherHostExtentNameFormat")) + strOtherHostExtentNameFormat = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "OtherHostExtentNameNamespace")) + strOtherHostExtentNameNamespace = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "VirtualQuantityUnits")) + strVirtualQuantityUnits = pelmItemChild->getValue(); + else if (!strcmp(pcszItemChildName, "Access")) + { + uint32_t temp; + pelmItemChild->copyValue(temp); + accessType = (StorageAccessType_T)temp; + } + else if (!strcmp(pcszItemChildName, "HostExtentNameFormat")) + { + } + else if (!strcmp(pcszItemChildName, "HostExtentNameNamespace")) + { + } + else if (!strcmp(pcszItemChildName, "HostExtentStartingAddress")) + { + } + else if (!strcmp(pcszItemChildName, "HostResourceBlockSize")) + { + int64_t temp; + pelmItemChild->copyValue(temp); + hostResourceBlockSize = temp; + } + else if (!strcmp(pcszItemChildName, "Limit")) + { + int64_t temp; + pelmItemChild->copyValue(temp); + limit = temp; + } + else if (!strcmp(pcszItemChildName, "Reservation")) + { + int64_t temp; + pelmItemChild->copyValue(temp); + reservation = temp; + } + else if (!strcmp(pcszItemChildName, "VirtualQuantity")) + { + int64_t temp; + pelmItemChild->copyValue(temp); + virtualQuantity = temp; + } + else if (!strcmp(pcszItemChildName, "VirtualResourceBlockSize")) + { + int64_t temp; + pelmItemChild->copyValue(temp); + virtualResourceBlockSize = temp; + } + } +} + + +void StorageItem::_checkConsistencyAndCompliance() RT_THROW(OVFLogicError) +{ + VirtualHardwareItem::_checkConsistencyAndCompliance(); + + RTCString name = getItemName(); + + if (accessType == StorageAccessType_Unknown) + { + //throw OVFLogicError(N_("Access type is unknown under %s element, line %d"), + // name.c_str(), ulLineNumber); + } + + if (hostResourceBlockSize <= 0 && reservation > 0) + { + throw OVFLogicError(N_("Element HostResourceBlockSize is absent under %s element, line %d. " + "see DMTF Schema Documentation %s"), + name.c_str(), ulLineNumber, DTMF_SPECS_URI); + } + + if (virtualResourceBlockSize <= 0 && virtualQuantity > 0) + { + throw OVFLogicError(N_("Element VirtualResourceBlockSize is absent under %s element, line %d. " + "see DMTF Schema Documentation %s"), + name.c_str(), ulLineNumber, DTMF_SPECS_URI); + } + + if (virtualQuantity > 0 && strVirtualQuantityUnits.isEmpty()) + { + throw OVFLogicError(N_("Element VirtualQuantityUnits is absent under %s element, line %d. " + "see DMTF Schema Documentation %s"), + name.c_str(), ulLineNumber, DTMF_SPECS_URI); + } + + if (virtualResourceBlockSize <= 1 && + strVirtualQuantityUnits.compare(RTCString("count"), RTCString::CaseInsensitive) == 0 + ) + { + throw OVFLogicError(N_("Element VirtualQuantityUnits is set to \"count\" " + "while VirtualResourceBlockSize is set to 1. " + "under %s element, line %d. " + "It's needed to change on \"byte\". " + "see DMTF Schema Documentation %s"), + name.c_str(), ulLineNumber, DTMF_SPECS_URI); + } +} + +void EthernetPortItem::fillItem(const xml::ElementNode *item) +{ + VirtualHardwareItem::fillItem(item); + + xml::NodesLoop loopItemChildren(*item);// all child elements + const xml::ElementNode *pelmItemChild; + while ((pelmItemChild = loopItemChildren.forAllNodes())) + { + } +} + +void EthernetPortItem::_checkConsistencyAndCompliance() RT_THROW(OVFLogicError) +{ + VirtualHardwareItem::_checkConsistencyAndCompliance(); +} + //////////////////////////////////////////////////////////////////////////////// // // Errors |