Changeset 18627 in vbox for trunk/src/VBox
- Timestamp:
- Apr 2, 2009 11:15:36 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImpl.cpp
r18623 r18627 2574 2574 pelmRoot->setAttribute("ovf:version", (task->enFormat == TaskWriteOVF::OVF_1_0) ? "1.0" : "0.9"); 2575 2575 pelmRoot->setAttribute("xml:lang", "en-US"); 2576 pelmRoot->setAttribute("xmlns", "http://schemas.dmtf.org/ovf/envelope/1"); 2577 pelmRoot->setAttribute("xmlns:ovf", "http://schemas.dmtf.org/ovf/envelope/1"); 2576 2577 Utf8Str strNamespace = (TaskWriteOVF::OVF_0_9) 2578 ? "http://www.vmware.com/schema/ovf/1/envelope" // 0.9 2579 : "http://schemas.dmtf.org/ovf/envelope/1"; // 1.0 2580 pelmRoot->setAttribute("xmlns", strNamespace); 2581 pelmRoot->setAttribute("xmlns:ovf", strNamespace); 2582 2578 2583 // pelmRoot->setAttribute("xmlns:ovfstr", "http://schema.dmtf.org/ovf/strings/1"); 2579 2584 pelmRoot->setAttribute("xmlns:rasd", "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData"); … … 2631 2636 2632 2637 // and here come the virtual systems: 2633 xml::ElementNode *pelmVirtualSystemCollection; 2634 if (task->enFormat == TaskWriteOVF::OVF_0_9) 2638 2639 // write a collection if we have more than one virtual system _and_ we're 2640 // writing OVF 1.0; otherwise fail since ovftool can't import more than 2641 // one machine, it seems 2642 xml::ElementNode *pelmToAddVirtualSystemsTo; 2643 if (pAppliance->m->virtualSystemDescriptions.size() > 1) 2635 2644 { 2636 // <Section xsi:type="ovf:NetworkSection_Type"> 2637 pelmVirtualSystemCollection = pelmRoot->createChild("Content"); 2638 pelmVirtualSystemCollection->setAttribute("xsi:type", "ovf:VirtualSystemCollection_Type"); 2645 if (task->enFormat == TaskWriteOVF::OVF_0_9) 2646 return setError(VBOX_E_FILE_ERROR, 2647 tr("Cannot export more than one virtual system with OVF 0.9, use OVF 1.0")); 2648 2649 pelmToAddVirtualSystemsTo = pelmRoot->createChild("VirtualSystemCollection"); 2650 /* xml::AttributeNode *pattrVirtualSystemCollectionId = */ pelmToAddVirtualSystemsTo->setAttribute("ovf:name", "ExportedVirtualBoxMachines"); // whatever 2639 2651 } 2640 2652 else 2641 pelmVirtualSystemCollection = pelmRoot->createChild("VirtualSystemCollection"); 2642 /* xml::AttributeNode *pattrVirtualSystemCollectionId = */ pelmVirtualSystemCollection->setAttribute("ovf:id", "ExportedVirtualBoxMachines"); // whatever 2653 pelmToAddVirtualSystemsTo = pelmRoot; // add virtual system directly under root element 2643 2654 2644 2655 list< ComObjPtr<VirtualSystemDescription> >::const_iterator it; … … 2654 2665 { 2655 2666 // <Section xsi:type="ovf:NetworkSection_Type"> 2656 pelmVirtualSystem = pelm VirtualSystemCollection->createChild("Content");2667 pelmVirtualSystem = pelmToAddVirtualSystemsTo->createChild("Content"); 2657 2668 pelmVirtualSystem->setAttribute("xsi:type", "ovf:VirtualSystem_Type"); 2658 2669 } 2659 2670 else 2660 pelmVirtualSystem = pelm VirtualSystemCollection->createChild("VirtualSystem");2671 pelmVirtualSystem = pelmToAddVirtualSystemsTo->createChild("VirtualSystem"); 2661 2672 2662 2673 /*xml::ElementNode *pelmVirtualSystemInfo =*/ pelmVirtualSystem->createChild("Info")->addContent("A virtual machine"); … … 2811 2822 pelmSystem->createChild("vssd:VirtualSystemIdentifier")->addContent(strVMName); 2812 2823 // <vssd:VirtualSystemType>vmx-4</vssd:VirtualSystemType> 2813 pelmSystem->createChild("vssd:VirtualSystemType")->addContent("virtualbox-2.2"); // instead of vmx-7? 2824 const char *pcszHardware = "virtualbox-2.2"; 2825 if (task->enFormat == TaskWriteOVF::OVF_0_9) 2826 // pretend to be vmware compatible then 2827 pcszHardware = "vmx-6"; 2828 pelmSystem->createChild("vssd:VirtualSystemType")->addContent(pcszHardware); 2814 2829 2815 2830 // loop thru all description entries twice; once to write out all … … 2898 2913 lVirtualQuantity = (int32_t)(uTemp / _1M); 2899 2914 strAllocationUnits = "MegaBytes"; 2915 strCaption = Utf8StrFmt("%d MB of memory", lVirtualQuantity); // without this ovftool won't eat the item 2900 2916 } 2901 2917 break; … … 3154 3170 pItem = pelmVirtualHardwareSection->createChild("Item"); 3155 3171 3172 // NOTE: do not change the order of these items without good reason! While we don't care 3173 // about ordering, VMware's ovftool does and fails if the items are not written in 3174 // exactly this order, as stupid as it seems. 3175 3176 if (!strCaption.isEmpty()) 3177 pItem->createChild("rasd:Caption")->addContent(strCaption); 3156 3178 if (!strDescription.isEmpty()) 3157 3179 pItem->createChild("rasd:Description")->addContent(strDescription); 3158 if (!strCaption.isEmpty())3159 pItem->createChild("rasd:Caption")->addContent(strCaption);3160 3161 if (!strAllocationUnits.isEmpty())3162 pItem->createChild("rasd:AllocationUnits")->addContent(strAllocationUnits);3163 3164 if (lAutomaticAllocation != -1)3165 pItem->createChild("rasd:AutomaticAllocation")->addContent( (lAutomaticAllocation) ? "true" : "false" );3166 3167 if (!strConnection.isEmpty())3168 pItem->createChild("rasd:Connection")->addContent(strConnection);3169 3180 3170 3181 // <rasd:InstanceID>1</rasd:InstanceID> 3171 pItem->createChild("rasd:InstanceID")->addContent(Utf8StrFmt("%d", ulInstanceID)); 3172 ++ulInstanceID; 3182 xml::ElementNode *pelmInstanceID; 3183 if (task->enFormat == TaskWriteOVF::OVF_0_9) 3184 pelmInstanceID = pItem->createChild("rasd:InstanceId"); 3185 else 3186 pelmInstanceID = pItem->createChild("rasd:InstanceID"); // capitalization changed... 3187 pelmInstanceID->addContent(Utf8StrFmt("%d", ulInstanceID++)); 3173 3188 3174 3189 // <rasd:ResourceType>3</rasd:ResourceType> … … 3177 3192 pItem->createChild("rasd:ResourceSubType")->addContent(strResourceSubType); 3178 3193 3194 if (!strHostResource.isEmpty()) 3195 pItem->createChild("rasd:HostResource")->addContent(strHostResource); 3196 3197 if (!strAllocationUnits.isEmpty()) 3198 pItem->createChild("rasd:AllocationUnits")->addContent(strAllocationUnits); 3199 3179 3200 // <rasd:VirtualQuantity>1</rasd:VirtualQuantity> 3180 3201 if (lVirtualQuantity != -1) 3181 3202 pItem->createChild("rasd:VirtualQuantity")->addContent(Utf8StrFmt("%d", lVirtualQuantity)); 3203 3204 if (lAutomaticAllocation != -1) 3205 pItem->createChild("rasd:AutomaticAllocation")->addContent( (lAutomaticAllocation) ? "true" : "false" ); 3206 3207 if (!strConnection.isEmpty()) 3208 pItem->createChild("rasd:Connection")->addContent(strConnection); 3182 3209 3183 3210 if (lAddress != -1) … … 3191 3218 if (lAddressOnParent != -1) 3192 3219 pItem->createChild("rasd:AddressOnParent")->addContent(Utf8StrFmt("%d", lAddressOnParent)); 3193 3194 if (!strHostResource.isEmpty())3195 pItem->createChild("rasd:HostResource")->addContent(strHostResource);3196 3220 } 3197 3221 } … … 3307 3331 pelmDisk->setAttribute("ovf:diskId", strDiskID); 3308 3332 pelmDisk->setAttribute("ovf:fileRef", strFileRef); 3309 pelmDisk->setAttribute("ovf:format", "http://www.vmware.com/specifications/vmdk.html# compressed");3333 pelmDisk->setAttribute("ovf:format", "http://www.vmware.com/specifications/vmdk.html#sparse"); // must be sparse or ovftool chokes 3310 3334 } 3311 3335
Note:
See TracChangeset
for help on using the changeset viewer.